diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index 7abc394a1f..d675ac0b01 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -89,6 +89,10 @@ namespace CalamityMod.Buffs //Vanilla buffs switch (type) { + case BuffID.Archery: + tip = "20% increased arrow speed and 1.05x arrow damage"; + break; + case BuffID.Swiftness: tip = "15% increased movement speed"; break; diff --git a/Buffs/Cooldowns/DivineBlessCooldown.cs b/Buffs/Cooldowns/DivineBlessCooldown.cs new file mode 100644 index 0000000000..7bfeebdbdb --- /dev/null +++ b/Buffs/Cooldowns/DivineBlessCooldown.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Cooldowns +{ + public class DivineBlessCooldown : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Divine Recharge"); + Description.SetDefault("Your divine powers are recharging"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + canBeCleared = false; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().divineBlessCooldown = true; + } + } +} diff --git a/Buffs/Cooldowns/DivineBlessCooldown.png b/Buffs/Cooldowns/DivineBlessCooldown.png new file mode 100644 index 0000000000..2057238c4e Binary files /dev/null and b/Buffs/Cooldowns/DivineBlessCooldown.png differ diff --git a/Buffs/Cooldowns/GodSlayerCooldown.cs b/Buffs/Cooldowns/GodSlayerCooldown.cs index 66d81edc11..954f20ce40 100644 --- a/Buffs/Cooldowns/GodSlayerCooldown.cs +++ b/Buffs/Cooldowns/GodSlayerCooldown.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Buffs.Cooldowns public override void SetDefaults() { DisplayName.SetDefault("God Slayer Cooldown"); - Description.SetDefault("Life regen is halved; godslayer effect is recharging"); + Description.SetDefault("God Slayer dash is recharging"); Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; diff --git a/Buffs/Cooldowns/UniverseSplitterCooldown.cs b/Buffs/Cooldowns/UniverseSplitterCooldown.cs new file mode 100644 index 0000000000..03270a884e --- /dev/null +++ b/Buffs/Cooldowns/UniverseSplitterCooldown.cs @@ -0,0 +1,19 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Cooldowns +{ + public class UniverseSplitterCooldown : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Universe Splitter Cooldown"); + Description.SetDefault("You cannot use the Universe Splitter"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + canBeCleared = false; + } + } +} diff --git a/Buffs/Cooldowns/UniverseSplitterCooldown.png b/Buffs/Cooldowns/UniverseSplitterCooldown.png new file mode 100644 index 0000000000..f24e416ef2 Binary files /dev/null and b/Buffs/Cooldowns/UniverseSplitterCooldown.png differ diff --git a/Buffs/DamageOverTime/BanishingFire.cs b/Buffs/DamageOverTime/BanishingFire.cs new file mode 100644 index 0000000000..50750405fe --- /dev/null +++ b/Buffs/DamageOverTime/BanishingFire.cs @@ -0,0 +1,31 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.DamageOverTime +{ + public class BanishingFire : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Banishing Fire"); + Description.SetDefault("You shall not be forgiven for your sins"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + longerExpertDebuff = false; + } + + public override void Update(Player player, ref int buffIndex) + { + player.Calamity().banishingFire = true; + } + + 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--; + } + } +} diff --git a/Buffs/DamageOverTime/BanishingFire.png b/Buffs/DamageOverTime/BanishingFire.png new file mode 100644 index 0000000000..32abe939dd Binary files /dev/null and b/Buffs/DamageOverTime/BanishingFire.png differ diff --git a/Buffs/DamageOverTime/SagePoison.cs b/Buffs/DamageOverTime/SagePoison.cs new file mode 100644 index 0000000000..b1763d9e41 --- /dev/null +++ b/Buffs/DamageOverTime/SagePoison.cs @@ -0,0 +1,24 @@ +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.DamageOverTime +{ + public class SagePoison : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Sage Poison"); + Description.SetDefault("Poisoned"); + Main.debuff[Type] = true; + Main.pvpBuff[Type] = true; + Main.buffNoSave[Type] = true; + } + public override void Update(NPC npc, ref int buffIndex) + { + if (npc.Calamity().sagePoisonTime < npc.buffTime[buffIndex]) + npc.Calamity().sagePoisonTime = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; + } + } +} diff --git a/Buffs/DamageOverTime/SagePoison.png b/Buffs/DamageOverTime/SagePoison.png new file mode 100644 index 0000000000..369f52e1ef Binary files /dev/null and b/Buffs/DamageOverTime/SagePoison.png differ diff --git a/Buffs/DamageOverTime/VulnerabilityHex.cs b/Buffs/DamageOverTime/VulnerabilityHex.cs index 17b1addd7e..005efdf936 100644 --- a/Buffs/DamageOverTime/VulnerabilityHex.cs +++ b/Buffs/DamageOverTime/VulnerabilityHex.cs @@ -20,5 +20,13 @@ namespace CalamityMod.Buffs.DamageOverTime { player.Calamity().vHex = true; } + + public override void Update(NPC npc, ref int buffIndex) + { + if (npc.Calamity().vulnerabilityHex < npc.buffTime[buffIndex]) + npc.Calamity().vulnerabilityHex = npc.buffTime[buffIndex]; + npc.DelBuff(buffIndex); + buffIndex--; + } } } diff --git a/Buffs/Pets/LittleLightBuff.cs b/Buffs/Pets/LittleLightBuff.cs new file mode 100644 index 0000000000..e1d860ee05 --- /dev/null +++ b/Buffs/Pets/LittleLightBuff.cs @@ -0,0 +1,28 @@ +using CalamityMod.Projectiles.Pets; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Pets +{ + public class LittleLightBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Little Light"); + Description.SetDefault("Endearing"); + Main.buffNoTimeDisplay[Type] = true; + Main.lightPet[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + player.buffTime[buffIndex] = 18000; + + player.Calamity().littleLightPet = true; + bool petProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + if (petProjectileNotSpawned && player.whoAmI == Main.myPlayer) + Projectile.NewProjectile(player.Center, -Vector2.UnitY * 10f, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); + } + } +} diff --git a/Buffs/Pets/LittleLightBuff.png b/Buffs/Pets/LittleLightBuff.png new file mode 100644 index 0000000000..9d35e2b3f6 Binary files /dev/null and b/Buffs/Pets/LittleLightBuff.png differ diff --git a/Buffs/StatBuffs/AdrenalineMode.png b/Buffs/StatBuffs/AdrenalineMode.png index 555478a614..bedcc91f12 100644 Binary files a/Buffs/StatBuffs/AdrenalineMode.png and b/Buffs/StatBuffs/AdrenalineMode.png differ diff --git a/Buffs/StatBuffs/ScarfMeleeBoost.cs b/Buffs/StatBuffs/DivineBless.cs similarity index 54% rename from Buffs/StatBuffs/ScarfMeleeBoost.cs rename to Buffs/StatBuffs/DivineBless.cs index 2a769c3254..4a75db454f 100644 --- a/Buffs/StatBuffs/ScarfMeleeBoost.cs +++ b/Buffs/StatBuffs/DivineBless.cs @@ -3,21 +3,22 @@ using Terraria.ModLoader; namespace CalamityMod.Buffs.StatBuffs { - public class ScarfMeleeBoost : ModBuff + public class DivineBless : ModBuff { public override void SetDefaults() { - DisplayName.SetDefault("Scarf Boost"); - Description.SetDefault("10% increased damage, 5% increased crit chance, and 5% increased melee speed"); - Main.debuff[Type] = false; + DisplayName.SetDefault("Divine Bless"); + Description.SetDefault("Increased health regen and minions inflict Banishing Fire"); + Main.debuff[Type] = true; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; longerExpertDebuff = false; + canBeCleared = false; } public override void Update(Player player, ref int buffIndex) { - player.Calamity().sMeleeBoost = true; + player.Calamity().divineBless = true; } } } diff --git a/Buffs/StatBuffs/DivineBless.png b/Buffs/StatBuffs/DivineBless.png new file mode 100644 index 0000000000..3d9c73ec00 Binary files /dev/null and b/Buffs/StatBuffs/DivineBless.png differ diff --git a/Buffs/StatBuffs/EvasionScarfBoost.cs b/Buffs/StatBuffs/EvasionScarfBoost.cs deleted file mode 100644 index 8e06699c94..0000000000 --- a/Buffs/StatBuffs/EvasionScarfBoost.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Terraria; -using Terraria.ModLoader; - -namespace CalamityMod.Buffs.StatBuffs -{ - public class EvasionScarfBoost : ModBuff - { - public override void SetDefaults() - { - DisplayName.SetDefault("Evasion Scarf Boost"); - Description.SetDefault("10% increased damage, 10% increased crit chance, and 15% increased melee speed"); - 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().eScarfBoost = true; - } - } -} diff --git a/Buffs/StatBuffs/EvasionScarfBoost.png b/Buffs/StatBuffs/EvasionScarfBoost.png deleted file mode 100644 index 5e45380f0e..0000000000 Binary files a/Buffs/StatBuffs/EvasionScarfBoost.png and /dev/null differ diff --git a/Buffs/StatBuffs/HallowedRuneAtkBuff.cs b/Buffs/StatBuffs/HallowedRuneAtkBuff.cs index cda8a37727..a7dd6475f3 100644 --- a/Buffs/StatBuffs/HallowedRuneAtkBuff.cs +++ b/Buffs/StatBuffs/HallowedRuneAtkBuff.cs @@ -12,7 +12,6 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/HallowedRuneDefBuff.cs b/Buffs/StatBuffs/HallowedRuneDefBuff.cs index 4856abe2bf..22ed3eb7b9 100644 --- a/Buffs/StatBuffs/HallowedRuneDefBuff.cs +++ b/Buffs/StatBuffs/HallowedRuneDefBuff.cs @@ -12,7 +12,6 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/HallowedRuneRegenBuff.cs b/Buffs/StatBuffs/HallowedRuneRegenBuff.cs index c85e46f920..50968cfcde 100644 --- a/Buffs/StatBuffs/HallowedRuneRegenBuff.cs +++ b/Buffs/StatBuffs/HallowedRuneRegenBuff.cs @@ -12,7 +12,6 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/PhantomicArmourBuff.cs b/Buffs/StatBuffs/PhantomicArmourBuff.cs index fae17dd3a1..82e4305808 100644 --- a/Buffs/StatBuffs/PhantomicArmourBuff.cs +++ b/Buffs/StatBuffs/PhantomicArmourBuff.cs @@ -14,7 +14,6 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs b/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs index 52ba453934..868a457554 100644 --- a/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs +++ b/Buffs/StatBuffs/PhantomicEmpowermentBuff.cs @@ -13,7 +13,6 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/PhantomicRestorationBuff.cs b/Buffs/StatBuffs/PhantomicRestorationBuff.cs index ace3972774..936c8c7af2 100644 --- a/Buffs/StatBuffs/PhantomicRestorationBuff.cs +++ b/Buffs/StatBuffs/PhantomicRestorationBuff.cs @@ -13,7 +13,6 @@ namespace CalamityMod.Buffs.StatBuffs Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = true; - Main.buffNoTimeDisplay[Type] = true; longerExpertDebuff = false; } diff --git a/Buffs/StatBuffs/ScarfMeleeBoost.png b/Buffs/StatBuffs/ScarfMeleeBoost.png deleted file mode 100644 index 60b9c9e6db..0000000000 Binary files a/Buffs/StatBuffs/ScarfMeleeBoost.png and /dev/null differ diff --git a/Buffs/StatBuffs/SilvaRevival.cs b/Buffs/StatBuffs/SilvaRevival.cs index d8a6574a55..160890cc95 100644 --- a/Buffs/StatBuffs/SilvaRevival.cs +++ b/Buffs/StatBuffs/SilvaRevival.cs @@ -7,8 +7,8 @@ namespace CalamityMod.Buffs.StatBuffs { public override void SetDefaults() { - DisplayName.SetDefault("Silva Invulnerability"); - Description.SetDefault("You are invulnerable"); + DisplayName.SetDefault("Silva Immunity"); + Description.SetDefault("You are unkillable and immune to most debuffs"); Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; diff --git a/Buffs/Summon/DaedalusGolemBuff.cs b/Buffs/Summon/DaedalusGolemBuff.cs new file mode 100644 index 0000000000..6c0972e123 --- /dev/null +++ b/Buffs/Summon/DaedalusGolemBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class DaedalusGolemBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Daedalus Golem"); + Description.SetDefault("A crystal golem is following you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.daedalusGolem = true; + } + if (!modPlayer.daedalusGolem) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/DaedalusGolemBuff.png b/Buffs/Summon/DaedalusGolemBuff.png new file mode 100644 index 0000000000..011938595e Binary files /dev/null and b/Buffs/Summon/DaedalusGolemBuff.png differ diff --git a/Buffs/Summon/DeathstareBuff.cs b/Buffs/Summon/DeathstareBuff.cs new file mode 100644 index 0000000000..8c3de83967 --- /dev/null +++ b/Buffs/Summon/DeathstareBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class DeathstareBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Miniature Eye of Cthulhu"); + Description.SetDefault("It's watching you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.deathstareEyeball = true; + } + if (!modPlayer.deathstareEyeball) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/DeathstareBuff.png b/Buffs/Summon/DeathstareBuff.png new file mode 100644 index 0000000000..eaf73dcf4e Binary files /dev/null and b/Buffs/Summon/DeathstareBuff.png differ diff --git a/Buffs/Summon/EyeOfNightBuff.cs b/Buffs/Summon/EyeOfNightBuff.cs new file mode 100644 index 0000000000..db3f86b42b --- /dev/null +++ b/Buffs/Summon/EyeOfNightBuff.cs @@ -0,0 +1,34 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class EyeOfNightBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Eye of Night"); + Description.SetDefault("It eerily watches"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.eyeOfNight = true; + + if (modPlayer.eyeOfNight) + player.buffTime[buffIndex] = 18000; + else + { + player.DelBuff(buffIndex); + buffIndex--; + } + } + } +} diff --git a/Buffs/Summon/EyeOfNightBuff.png b/Buffs/Summon/EyeOfNightBuff.png new file mode 100644 index 0000000000..e4f07e8ac0 Binary files /dev/null and b/Buffs/Summon/EyeOfNightBuff.png differ diff --git a/Buffs/Summon/FleshOfInfidelityBuff.cs b/Buffs/Summon/FleshOfInfidelityBuff.cs new file mode 100644 index 0000000000..fea7a77d87 --- /dev/null +++ b/Buffs/Summon/FleshOfInfidelityBuff.cs @@ -0,0 +1,34 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class FleshOfInfidelityBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Flesh Ball"); + Description.SetDefault("Why is it following you?"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.fleshBall = true; + + if (modPlayer.fleshBall) + player.buffTime[buffIndex] = 18000; + else + { + player.DelBuff(buffIndex); + buffIndex--; + } + } + } +} diff --git a/Buffs/Summon/FleshOfInfidelityBuff.png b/Buffs/Summon/FleshOfInfidelityBuff.png new file mode 100644 index 0000000000..5fadbf39f8 Binary files /dev/null and b/Buffs/Summon/FleshOfInfidelityBuff.png differ diff --git a/Buffs/Summon/FlowersOfMortalityBuff.cs b/Buffs/Summon/FlowersOfMortalityBuff.cs new file mode 100644 index 0000000000..a27ece7655 --- /dev/null +++ b/Buffs/Summon/FlowersOfMortalityBuff.cs @@ -0,0 +1,35 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class FlowersOfMortalityBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Flowers of Mortality"); + Description.SetDefault("Celestial blossoms surround you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.flowersOfMortality = true; + + if (!modPlayer.flowersOfMortality) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/FlowersOfMortalityBuff.png b/Buffs/Summon/FlowersOfMortalityBuff.png new file mode 100644 index 0000000000..dbba97dc87 Binary files /dev/null and b/Buffs/Summon/FlowersOfMortalityBuff.png differ diff --git a/Buffs/Summon/PerditionBuff.cs b/Buffs/Summon/PerditionBuff.cs new file mode 100644 index 0000000000..1773a82e3e --- /dev/null +++ b/Buffs/Summon/PerditionBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class PerditionBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Perdition"); + Description.SetDefault("How unfortunate"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.perditionBeacon = true; + + if (!modPlayer.perditionBeacon) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/PerditionBuff.png b/Buffs/Summon/PerditionBuff.png new file mode 100644 index 0000000000..256653f0de Binary files /dev/null and b/Buffs/Summon/PerditionBuff.png differ diff --git a/Buffs/Summon/SageSpiritBuff.cs b/Buffs/Summon/SageSpiritBuff.cs new file mode 100644 index 0000000000..45034d0575 --- /dev/null +++ b/Buffs/Summon/SageSpiritBuff.cs @@ -0,0 +1,34 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class SageSpiritBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Sage Spirit"); + Description.SetDefault("It's uncomfortably close"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.sageSpirit = true; + + if (modPlayer.sageSpirit) + player.buffTime[buffIndex] = 18000; + else + { + player.DelBuff(buffIndex); + buffIndex--; + } + } + } +} diff --git a/Buffs/Summon/SageSpiritBuff.png b/Buffs/Summon/SageSpiritBuff.png new file mode 100644 index 0000000000..6f96cea427 Binary files /dev/null and b/Buffs/Summon/SageSpiritBuff.png differ diff --git a/Buffs/Summon/SoulSeekerBuff.cs b/Buffs/Summon/SoulSeekerBuff.cs new file mode 100644 index 0000000000..e552084a4b --- /dev/null +++ b/Buffs/Summon/SoulSeekerBuff.cs @@ -0,0 +1,35 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class SoulSeekerBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Soul Seeker"); + 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) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.soulSeeker = true; + + if (!modPlayer.soulSeeker) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/SoulSeekerBuff.png b/Buffs/Summon/SoulSeekerBuff.png new file mode 100644 index 0000000000..fe6b96bed3 Binary files /dev/null and b/Buffs/Summon/SoulSeekerBuff.png differ diff --git a/Buffs/Summon/ViridVanguardBuff.cs b/Buffs/Summon/ViridVanguardBuff.cs new file mode 100644 index 0000000000..ef7f387078 --- /dev/null +++ b/Buffs/Summon/ViridVanguardBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class ViridVanguardBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Virid Vanguard"); + Description.SetDefault("A perfect act of unity surrounds you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + { + modPlayer.viridVanguard = true; + } + if (!modPlayer.viridVanguard) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/ViridVanguardBuff.png b/Buffs/Summon/ViridVanguardBuff.png new file mode 100644 index 0000000000..5a824b9ddd Binary files /dev/null and b/Buffs/Summon/ViridVanguardBuff.png differ diff --git a/Buffs/Summon/WitherBlossomsBuff.cs b/Buffs/Summon/WitherBlossomsBuff.cs new file mode 100644 index 0000000000..2518bc18a0 --- /dev/null +++ b/Buffs/Summon/WitherBlossomsBuff.cs @@ -0,0 +1,35 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class WitherBlossomsBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Wither Blossoms"); + Description.SetDefault("Pestilence surrounds you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.witherBlossom = true; + + if (!modPlayer.witherBlossom) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/WitherBlossomsBuff.png b/Buffs/Summon/WitherBlossomsBuff.png new file mode 100644 index 0000000000..334f026255 Binary files /dev/null and b/Buffs/Summon/WitherBlossomsBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index a6b093998f..f3da624b30 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -32,6 +32,7 @@ using CalamityMod.NPCs.GreatSandShark; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PlaguebringerGoliath; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.Polterghast; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.Ravager; @@ -117,7 +118,10 @@ namespace CalamityMod.CalPlayer public int defenseDamage = 0; public float rangedAmmoCost = 1f; public bool heldGaelsLastFrame = false; - public float ScreenShakePower; + public bool blazingMouseDamageEffects = false; + public bool ableToDrawBlazingMouse = false; + public float blazingMouseAuraFade = 0f; + public float GeneralScreenShakePower = 0f; #endregion #region Tile Entity Trackers @@ -278,6 +282,7 @@ namespace CalamityMod.CalPlayer public float rogueStealthMax = 0f; public float stealthGenStandstill = 1f; public float stealthGenMoving = 1f; + public int flatStealthLossReduction = 0; public const float StealthAccelerationCap = 2f; public float stealthAcceleration = 1f; public bool stealthStrikeThisFrame = false; @@ -288,6 +293,8 @@ namespace CalamityMod.CalPlayer public float accStealthGenBoost = 0f; public float throwingDamage = 1f; + public float stealthDamage = 0f; // This is extra Rogue Damage that is only added for stealth strikes. + public float RogueDamageWithStealth => throwingDamage + stealthDamage; public float throwingVelocity = 1f; public int throwingCrit = 0; public float throwingAmmoCost = 1f; @@ -329,6 +336,7 @@ namespace CalamityMod.CalPlayer public bool radiator = false; public bool scalPet = false; public bool bendyPet = false; + public bool littleLightPet = false; #endregion #region Rage @@ -467,7 +475,7 @@ namespace CalamityMod.CalPlayer public bool nanotech = false; public bool eQuiver = false; public bool shadowMinions = false; - public bool tearMinions = false; + public bool holyMinions = false; public bool alchFlask = false; public bool reducedPlagueDmg = false; public bool abaddon = false; @@ -572,10 +580,13 @@ namespace CalamityMod.CalPlayer public bool rustyMedal = false; public bool noStupidNaturalARSpawns = false; public bool burdenBreakerYeet = 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 bool rottenDogTooth = false; + public bool angelicAlliance = false; + public int angelicActivate = -1; #endregion #region Armor Set @@ -604,7 +615,8 @@ namespace CalamityMod.CalPlayer public int tarraMageHealCooldown = 0; public int tarraCrits = 0; public bool tarraRanged = false; - public bool tarraThrowing = false; + public int tarraRangedCooldown = 0; + public bool tarraThrowing = false; public bool tarragonImmunityCooldown = false; public bool tarragonImmunity = false; public int tarraThrowingCrits = 0; @@ -627,6 +639,7 @@ namespace CalamityMod.CalPlayer public bool godSlayerRanged = false; public bool godSlayerThrowing = false; public bool godSlayerCooldown = false; + public bool godSlayerDashHotKeyPressed = false; public bool ataxiaBolt = false; public bool ataxiaFire = false; public bool ataxiaVolley = false; @@ -683,10 +696,10 @@ namespace CalamityMod.CalPlayer public int prismaticLasers = 0; public bool silvaSet = false; public bool silvaMage = false; - public bool silvaSummon = false; + public int silvaMageCooldown = 0; + public bool silvaSummon = false; public bool hasSilvaEffect = false; - public int silvaCountdown = 600; - public int silvaHitCounter = 0; + public int silvaCountdown = 480; public bool auricSet = false; public bool omegaBlueChestplate = false; public bool omegaBlueSet = false; @@ -740,6 +753,8 @@ namespace CalamityMod.CalPlayer public bool energyShellCooldown = false; public bool prismaticCooldown = false; public bool waterLeechBleeding = false; + public bool divineBlessCooldown = false; + public bool banishingFire = false; #endregion #region Buff @@ -754,8 +769,6 @@ namespace CalamityMod.CalPlayer public bool xWrath = false; public bool graxDefense = false; public bool encased = false; - public bool sMeleeBoost = false; - public bool eScarfBoost = false; public bool tFury = false; public bool cadence = false; public bool omniscience = false; @@ -833,8 +846,9 @@ namespace CalamityMod.CalPlayer public bool hallowedRegen = false; public bool hallowedPower = false; public bool kamiBoost = false; - public bool avertorBonus = false; - #endregion + public bool avertorBonus = false; + public bool divineBless = false; + #endregion #region Minion public bool wDroid = false; @@ -923,6 +937,17 @@ namespace CalamityMod.CalPlayer public bool plaguebringerPatronSummon = false; public bool howlTrio = false; public bool mountedScanner = false; + public bool daedalusGolem = false; + public bool deathstareEyeball = false; + public bool witherBlossom = false; + public bool flowersOfMortality = false; + public bool viridVanguard = false; + public bool sageSpirit = false; + public bool fleshBall = false; + public bool eyeOfNight = false; + public bool soulSeeker = false; + public bool perditionBeacon = false; + public List PendingProjectilesToRespawn = new List(); // Due to the way vanilla summons work, the buff must be applied manually for it to properly register, since @@ -1369,9 +1394,7 @@ namespace CalamityMod.CalPlayer if (BossRushEvent.BossRushActive) { if (CalamityConfig.Instance.BossRushAccessoryCurse) - { player.extraAccessorySlots = 0; - } } ResetRogueStealth(); @@ -1414,6 +1437,8 @@ namespace CalamityMod.CalPlayer radiator = false; scalPet = false; bendyPet = false; + littleLightPet = false; + onyxExcavator = false; angryDog = false; fab = false; @@ -1485,6 +1510,8 @@ namespace CalamityMod.CalPlayer noWings = false; blockAllDashes = false; + blazingMouseDamageEffects = false; + ableToDrawBlazingMouse = false; luxorsGift = false; fungalSymbiote = false; @@ -1535,7 +1562,7 @@ namespace CalamityMod.CalPlayer nuclearRod = false; heartOfDarkness = false; shadowMinions = false; - tearMinions = false; + holyMinions = false; alchFlask = false; reducedPlagueDmg = false; abaddon = false; @@ -1601,7 +1628,9 @@ namespace CalamityMod.CalPlayer rustyMedal = false; noStupidNaturalARSpawns = false; burdenBreakerYeet = false; - roverDrive = false; + roverDrive = false; + rottenDogTooth = false; + angelicAlliance = false; daedalusReflect = false; daedalusSplit = false; @@ -1756,6 +1785,8 @@ namespace CalamityMod.CalPlayer energyShellCooldown = false; prismaticCooldown = false; waterLeechBleeding = false; + divineBlessCooldown = false; + banishingFire = false; revivify = false; trinketOfChiBuff = false; @@ -1767,8 +1798,6 @@ namespace CalamityMod.CalPlayer xWrath = false; graxDefense = false; encased = false; - sMeleeBoost = false; - eScarfBoost = false; tFury = false; cadence = false; omniscience = false; @@ -1814,7 +1843,8 @@ namespace CalamityMod.CalPlayer polarisBoostTwo = false; polarisBoostThree = false; bloodfinBoost = false; - bloodPactBoost = false; + bloodPactBoost = false; + divineBless = false; killSpikyBalls = false; @@ -1943,6 +1973,16 @@ namespace CalamityMod.CalPlayer plaguebringerPatronSummon = false; howlTrio = false; mountedScanner = false; + daedalusGolem = false; + deathstareEyeball = false; + witherBlossom = false; + flowersOfMortality = false; + viridVanguard = false; + sageSpirit = false; + fleshBall = false; + eyeOfNight = false; + soulSeeker = false; + perditionBeacon = false; abyssalDivingSuitPrevious = abyssalDivingSuit; abyssalDivingSuit = abyssalDivingSuitHide = abyssalDivingSuitForce = abyssalDivingSuitPower = false; @@ -1967,6 +2007,8 @@ namespace CalamityMod.CalPlayer RageDuration = DefaultRageDuration; RageDamageBoost = DefaultRageDamageBoost; + flatStealthLossReduction = 0; + lastProjectileHit = null; } #endregion @@ -1974,10 +2016,13 @@ namespace CalamityMod.CalPlayer #region Screen Position Movements public override void ModifyScreenPosition() { - if (ScreenShakePower > 0f) - { - ScreenShakePower = MathHelper.Clamp(ScreenShakePower - 0.2f, 0f, 70f); - Main.screenPosition += Main.rand.NextVector2Circular(ScreenShakePower, ScreenShakePower); + if (CalamityConfig.Instance.DisableScreenShakes) + return; + + if (GeneralScreenShakePower > 0f) + { + Main.screenPosition += Main.rand.NextVector2Circular(GeneralScreenShakePower, GeneralScreenShakePower); + GeneralScreenShakePower = MathHelper.Clamp(GeneralScreenShakePower - 0.185f, 0f, 20f); } if (CalamityWorld.ScreenShakeSpots.Count > 0) @@ -2034,8 +2079,10 @@ namespace CalamityMod.CalPlayer gSabatonFall = 0; gSabatonCooldown = 0; astralStarRainCooldown = 0; - bloodflareMageCooldown = 0; - tarraMageHealCooldown = 0; + silvaMageCooldown = 0; + bloodflareMageCooldown = 0; + tarraRangedCooldown = 0; + tarraMageHealCooldown = 0; bossRushImmunityFrameCurseTimer = 0; aBulwarkRareMeleeBoostTimer = 0; acidRoundMultiplier = 1D; @@ -2055,18 +2102,16 @@ namespace CalamityMod.CalPlayer nanoFlareCooldown = 0; fleshTotemCooldown = false; sandCloakCooldown = false; - icicleCooldown = 0; - statisTimer = 0; - hallowedRuneCooldown = 0; - phantomicBulwarkCooldown = 0; - phantomicHeartRegen = 0; - sulphurBubbleCooldown = 0; - ladHearts = 0; - prismaticLasers = 0; - roverDriveTimer = 0; - 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; @@ -2112,6 +2157,8 @@ namespace CalamityMod.CalPlayer energyShellCooldown = false; prismaticCooldown = false; waterLeechBleeding = false; + divineBlessCooldown = false; + banishingFire = false; #endregion #region Rogue @@ -2121,6 +2168,7 @@ namespace CalamityMod.CalPlayer stealthAcceleration = 1f; throwingDamage = 1f; + stealthDamage = 0f; throwingVelocity = 1f; throwingCrit = 0; throwingAmmoCost = 1f; @@ -2155,8 +2203,6 @@ namespace CalamityMod.CalPlayer kamiBoost = false; graxDefense = false; encased = false; - sMeleeBoost = false; - eScarfBoost = false; tFury = false; cadence = false; omniscience = false; @@ -2236,10 +2282,11 @@ namespace CalamityMod.CalPlayer revivify = false; healCounter = 300; danceOfLightCharge = 0; - bloodPactBoost = false; - rangedAmmoCost = 1f; - avertorBonus = false; - #endregion + bloodPactBoost = false; + rangedAmmoCost = 1f; + avertorBonus = false; + divineBless = false; + #endregion #region Armorbonuses flamethrowerBoost = false; @@ -2249,13 +2296,13 @@ namespace CalamityMod.CalPlayer godSlayerDamage = false; godSlayerRanged = false; godSlayerThrowing = false; + godSlayerDashHotKeyPressed = false; auricBoost = false; silvaSet = false; silvaMage = false; silvaSummon = false; hasSilvaEffect = false; - silvaCountdown = 600; - silvaHitCounter = 0; + silvaCountdown = 480; auricSet = false; omegaBlueChestplate = false; omegaBlueSet = false; @@ -2418,6 +2465,15 @@ namespace CalamityMod.CalPlayer bool useNebulaS = NPC.AnyNPCs(ModContent.NPCType()); player.ManageSpecialBiomeVisuals("CalamityMod:DevourerofGodsHeadS", useNebulaS); + bool useFlash = NPC.AnyNPCs(ModContent.NPCType()); + if (SkyManager.Instance["CalamityMod:StormWeaverFlash"] != null && useFlash != SkyManager.Instance["CalamityMod:StormWeaverFlash"].IsActive()) + { + if (useFlash) + SkyManager.Instance.Activate("CalamityMod:StormWeaverFlash", player.Center); + else + SkyManager.Instance.Deactivate("CalamityMod:StormWeaverFlash"); + } + bool useBrimstone = NPC.AnyNPCs(ModContent.NPCType()); player.ManageSpecialBiomeVisuals("CalamityMod:CalamitasRun3", useBrimstone); @@ -2428,13 +2484,9 @@ namespace CalamityMod.CalPlayer if (SkyManager.Instance["CalamityMod:Cryogen"] != null && useCryogen != SkyManager.Instance["CalamityMod:Cryogen"].IsActive()) { if (useCryogen) - { SkyManager.Instance.Activate("CalamityMod:Cryogen", player.Center); - } else - { SkyManager.Instance.Deactivate("CalamityMod:Cryogen"); - } } Point point = player.Center.ToTileCoordinates(); @@ -2451,10 +2503,13 @@ namespace CalamityMod.CalPlayer bool useHoly = NPC.AnyNPCs(ModContent.NPCType()); player.ManageSpecialBiomeVisuals("CalamityMod:Providence", useHoly); - bool useSBrimstone = NPC.AnyNPCs(ModContent.NPCType()); + bool useSBrimstone = NPC.AnyNPCs(ModContent.NPCType()) || SCalSky.OverridingIntensity > 0f; player.ManageSpecialBiomeVisuals("CalamityMod:SupremeCalamitas", useSBrimstone); - bool inAstral = ZoneAstral; + bool useWyrmWater = NPC.AnyNPCs(ModContent.NPCType()); + player.ManageSpecialBiomeVisuals("CalamityMod:AdultEidolonWyrm", useWyrmWater); + + bool inAstral = ZoneAstral; player.ManageSpecialBiomeVisuals("CalamityMod:Astral", inAstral); bool cryogenActive = NPC.AnyNPCs(ModContent.NPCType()); @@ -2462,13 +2517,17 @@ namespace CalamityMod.CalPlayer if (SkyManager.Instance["CalamityMod:Cryogen"] != null && cryogenActive != SkyManager.Instance["CalamityMod:Cryogen"].IsActive()) { if (cryogenActive) - { SkyManager.Instance.Activate("CalamityMod:Cryogen"); - } else - { SkyManager.Instance.Deactivate("CalamityMod:Cryogen"); - } + } + + if (SkyManager.Instance["CalamityMod:StormWeaverFlash"] != null && useFlash != SkyManager.Instance["CalamityMod:StormWeaverFlash"].IsActive()) + { + if (useFlash) + SkyManager.Instance.Activate("CalamityMod:StormWeaverFlash", player.Center); + else + SkyManager.Instance.Deactivate("CalamityMod:StormWeaverFlash"); } } @@ -2712,12 +2771,39 @@ namespace CalamityMod.CalPlayer } } } + if (CalamityMod.AngelicAllianceHotKey.JustPressed && angelicAlliance && Main.myPlayer == player.whoAmI && !divineBless && !divineBlessCooldown) + { + int seconds = CalamityUtils.SecondsToFrames(15f); + player.AddBuff(ModContent.BuffType(), seconds, false); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/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); + } + } if (CalamityMod.SandCloakHotkey.JustPressed && sandCloak && Main.myPlayer == player.whoAmI && rogueStealth >= rogueStealthMax * 0.25f && wearingRogueArmor && rogueStealthMax > 0 && !sandCloakCooldown) { player.AddBuff(ModContent.BuffType(), 1800, false); //30 seconds rogueStealth -= rogueStealthMax * 0.25f; - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 7, 8, player.whoAmI, 0, 0); + 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 && @@ -3001,6 +3087,10 @@ namespace CalamityMod.CalPlayer } } + // Trigger for pressing the God Slayer dash key + if (CalamityMod.GodSlayerDashHotKey.JustPressed && (player.controlUp || player.controlDown || player.controlLeft || player.controlRight)) + godSlayerDashHotKeyPressed = true; + // Trigger for pressing the Rage hotkey. if (CalamityMod.RageHotKey.JustPressed) { @@ -3448,6 +3538,7 @@ namespace CalamityMod.CalPlayer for (int n = 13; n < 18 + player.extraAccessorySlots; n++) { Item item = player.armor[n]; + if (item.type == ModContent.ItemType()) { snowmanHide = false; @@ -3477,6 +3568,13 @@ namespace CalamityMod.CalPlayer public override void UpdateEquips(ref bool wallSpeedBuff, ref bool tileSpeedBuff, ref bool tileRangeBuff) { + // Ankh Shield Mighty Wind immunity. + for (int i = 0; i < 8 + player.extraAccessorySlots; i++) + { + if (player.armor[i].type == ItemID.AnkhShield) + player.buffImmune[BuffID.WindPushed] = true; + } + if (CalamityConfig.Instance.BossHealthBar) { drawBossHPBar = true; @@ -3500,9 +3598,9 @@ namespace CalamityMod.CalPlayer } // Takes the % move speed boost and reduces it to a quarter to get the actual speed increase - // 400% move speed boost = 100% run speed boost, so an 8 run speed would become 16 with a 400% move speed stat + // 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.0025f; + player.accRunSpeed += player.accRunSpeed * moveSpeedStat * 0.002f; if (player.accRunSpeed < accRunSpeedMin) player.accRunSpeed = accRunSpeedMin; @@ -3521,14 +3619,6 @@ namespace CalamityMod.CalPlayer { meleeSpeedMult += 0.1f; } - if (sMeleeBoost) - { - meleeSpeedMult += 0.05f; - } - if (eScarfBoost) - { - meleeSpeedMult += 0.15f; - } if (yPower) { meleeSpeedMult += 0.05f; @@ -3862,7 +3952,12 @@ namespace CalamityMod.CalPlayer } // Neither scarf can be used if either is on cooldown - bool playerDashing = player.pulley || player.grappling[0] == -1 && !player.tongued; + bool playerDashing = player.pulley || (player.grappling[0] == -1 && !player.tongued); + if (playerDashing && dashMod == 9 && player.dashDelay < 0) + { + GodSlayerDodge(); + return true; + } if (playerDashing && dashMod == 1 && player.dashDelay < 0 && dodgeScarf && !scarfCooldown && !eScarfCooldown) { OnDodge(); @@ -3923,39 +4018,62 @@ namespace CalamityMod.CalPlayer NetMessage.SendData(MessageID.Dodge, -1, -1, null, player.whoAmI, 1f, 0f, 0f, 0, 0, 0); } + private void GodSlayerDodge() + { + player.immune = true; + player.immuneTime = player.longInvince ? 100 : 60; + for (int k = 0; k < player.hurtCooldowns.Length; k++) + player.hurtCooldowns[k] = player.immuneTime; + + 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.PurpleCosmolite, 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); + } + private void OnDodge() { if (evasionScarf) - { - player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(9f)); player.AddBuff(ModContent.BuffType(), player.chaosState ? CalamityUtils.SecondsToFrames(20f) : CalamityUtils.SecondsToFrames(13f)); - } else - { - player.AddBuff(ModContent.BuffType(), 540); player.AddBuff(ModContent.BuffType(), player.chaosState ? 1800 : 900); - } + player.immune = true; player.immuneTime = player.longInvince ? 100 : 60; for (int k = 0; k < player.hurtCooldowns.Length; k++) - { player.hurtCooldowns[k] = player.immuneTime; - } + for (int j = 0; j < 100; j++) { int num = Dust.NewDust(player.position, player.width, player.height, 235, 0f, 0f, 100, default, 2f); Dust dust = Main.dust[num]; - dust.position.X += (float)Main.rand.Next(-20, 21); - dust.position.Y += (float)Main.rand.Next(-20, 21); + dust.position.X += Main.rand.Next(-20, 21); + dust.position.Y += Main.rand.Next(-20, 21); dust.velocity *= 0.4f; - dust.scale *= 1f + (float)Main.rand.Next(40) * 0.01f; + 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 + (float)Main.rand.Next(40) * 0.01f; + 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); } @@ -4153,62 +4271,21 @@ namespace CalamityMod.CalPlayer return false; } - if (godSlayer && !godSlayerCooldown) - { - Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 67); + if (dashMod == 9 && player.dashDelay < 0) + { + if (player.statLife < 1) + player.statLife = 1; - 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; - } - - int heal = draconicSurge && !draconicSurgeCooldown ? (player.statLifeMax2 / 2) : 150; - player.statLife += heal; - player.HealEffect(heal); - - if (player.statLife > player.statLifeMax2) - player.statLife = player.statLifeMax2; - - if (player.FindBuffIndex(ModContent.BuffType()) > -1) - { - player.ClearBuff(ModContent.BuffType()); - player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(60f)); - - // Additional potion sickness time - int additionalTime = 0; - for (int i = 0; i < Player.MaxBuffs; i++) - { - if (player.buffType[i] == BuffID.PotionSickness) - additionalTime = player.buffTime[i]; - } - - float potionSicknessTime = 30f + (float)Math.Ceiling(additionalTime / 60D); - player.AddBuff(BuffID.PotionSickness, CalamityUtils.SecondsToFrames(potionSicknessTime)); - } - - player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(45f)); - - return false; - } + return false; + } if (silvaSet && silvaCountdown > 0) { - if (hasSilvaEffect) - silvaHitCounter++; - if (player.FindBuffIndex(ModContent.BuffType()) == -1) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaActivation"), (int)player.position.X, (int)player.position.Y); - player.AddBuff(ModContent.BuffType(), auricSet ? 300 : 600); + player.AddBuff(ModContent.BuffType(), 480); if (draconicSurge && !draconicSurgeCooldown) { @@ -4310,7 +4387,7 @@ namespace CalamityMod.CalPlayer { damageSource = PlayerDeathReason.ByCustomReason(player.name + " was turned to ashes by the Profaned Goddess."); } - if (hFlames) + if (hFlames || banishingFire) { damageSource = PlayerDeathReason.ByCustomReason(player.name + " fell prey to their sins."); } @@ -4434,24 +4511,6 @@ namespace CalamityMod.CalPlayer } #endregion - #region Use Time Mult - public override float UseTimeMultiplier(Item item) - { - if (auricSet && godSlayerRanged) - { - if (item.ranged && item.useTime > 3) - return 1.05f; - } - if (auricSet && godSlayerThrowing) - { - if (player.statLife > (int)(player.statLifeMax2 * 0.5) && - item.Calamity().rogue && item.useTime > 3) - return 1.05f; - } - return 1f; - } - #endregion - #region Get Heal Life public override void GetHealLife(Item item, bool quickHeal, ref int healValue) { @@ -4468,87 +4527,71 @@ 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; - } + if (flamethrowerBoost && item.ranged && (item.useAmmo == AmmoID.Gel || CalamityLists.flamethrowerList.Contains(item.type))) - { mult += hoverboardBoost ? 0.35f : 0.25f; - } - if (cinnamonRoll && CalamityLists.fireWeaponList.Contains(item.type)) - { - mult += 0.15f; - } + + if (fireball && cinnamonRoll && CalamityLists.fireWeaponList.Contains(item.type)) + { + mult += 0.125f; + } + else + { + if (fireball && CalamityLists.fireWeaponList.Contains(item.type)) + mult += 0.05f; + + if (cinnamonRoll && CalamityLists.fireWeaponList.Contains(item.type)) + mult += 0.1f; + } + if (evergreenGin && CalamityLists.natureWeaponList.Contains(item.type)) - { - mult += 0.15f; - } - if (fireball && CalamityLists.fireWeaponList.Contains(item.type)) - { mult += 0.1f; - } + if (eskimoSet && CalamityLists.iceWeaponList.Contains(item.type)) - { mult += 0.1f; - } if (item.ranged) - { acidRoundMultiplier = item.useTime / 20D; - } else - { acidRoundMultiplier = 1D; - } + //Prismatic Breaker is a weird hybrid melee-ranged weapon so include it too. Why are you using desert prowler post-Yharon? don't ask me if (desertProwler && (item.ranged || item.type == ModContent.ItemType()) && item.ammo == AmmoID.None) - { flat += 1f; - } } public override void GetWeaponKnockback(Item item, ref float knockback) { if (auricBoost) - { knockback *= 1f + (1f - modStealth) * 0.5f; - } + if (whiskey) - { knockback *= 1.04f; - } + if (tequila && Main.dayTime) - { knockback *= 1.03f; - } + if (tequilaSunrise && Main.dayTime) - { knockback *= 1.07f; - } + if (moscowMule) - { knockback *= 1.09f; - } + if (titanHeartMask && item.Calamity().rogue) - { knockback *= 1.05f; - } + if (titanHeartMantle && item.Calamity().rogue) - { knockback *= 1.05f; - } + if (titanHeartBoots && item.Calamity().rogue) - { knockback *= 1.05f; - } + if (titanHeartSet && item.Calamity().rogue) - { knockback *= 1.2f; - } + if (titanHeartSet && StealthStrikeAvailable() && item.Calamity().rogue) - { knockback *= 2f; - } } #endregion @@ -5142,10 +5185,6 @@ namespace CalamityMod.CalPlayer { #region MultiplierBoosts double damageMult = 1.0; - if (auricSet && godSlayerDamage && item.melee) - { - damageMult += 0.15; - } if (item.melee && item.type != ModContent.ItemType() && item.type != ModContent.ItemType()) { damageMult += trueMeleeDamage; @@ -5270,31 +5309,15 @@ namespace CalamityMod.CalPlayer if (screwdriver) { if (proj.penetrate > 1 || proj.penetrate == -1) - damageMult += 0.1; + damageMult += 0.05; } - if (auricSet && godSlayerDamage && isTrueMelee) - damageMult += 0.15; - if (enraged) damageMult += 1.25; - if (silvaCountdown <= 0 && hasSilvaEffect && silvaMage && proj.magic) - damageMult += 0.1; - - if (silvaCountdown <= 0 && hasSilvaEffect && silvaSummon && isSummon) - damageMult += 0.1; - - if (proj.type == ModContent.ProjectileType()) - { - if (target.buffImmune[ModContent.BuffType()]) - damageMult += 0.1; - } - - else if (proj.type == ProjectileID.InfernoFriendlyBlast) - { + if (proj.type == ProjectileID.InfernoFriendlyBlast) damageMult += 0.33; - } + if (brimflameFrenzy && brimflameSet) { if (proj.magic) @@ -5372,7 +5395,7 @@ namespace CalamityMod.CalPlayer if (nanotech) penetrateAmt += 20; //nanotech is weaker else if (electricianGlove) - penetrateAmt += 30; + penetrateAmt += 20; else if (filthyGlove || bloodyGlove) penetrateAmt += 10; } @@ -5401,7 +5424,7 @@ namespace CalamityMod.CalPlayer { 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.hammer == 0 && heldItem.pick == 0 && heldItem.axe == 0 && heldItem.useStyle != 0 && !heldItem.accessory && heldItem.ammo == AmmoID.None) { damage = (int)(damage * summonNerfMult); @@ -5411,22 +5434,13 @@ namespace CalamityMod.CalPlayer if (proj.ranged) { - // Nerfed in prehardmode due to bullet damage being a balance meme - if (heldItem.type == ModContent.ItemType()) - { - if (!Main.hardMode) - damage = (int)(damage * 0.5); - if (proj.type == ProjectileID.IchorBullet || proj.type == ModContent.ProjectileType()) - damage = (int)(damage * 0.85); - } - switch (proj.type) { case ProjectileID.CrystalShard: damage = (int)(damage * 0.6); break; case ProjectileID.HallowStar: - damage = (int)(damage * 0.7); + damage = (int)(damage * 0.5); break; } @@ -5712,7 +5726,7 @@ namespace CalamityMod.CalPlayer contactDamageReduction += 0.1; if (vHex) - contactDamageReduction -= 0.3; + contactDamageReduction -= 0.1; if (irradiated) contactDamageReduction -= 0.1; @@ -6154,7 +6168,7 @@ namespace CalamityMod.CalPlayer projectileDamageReduction += 0.1; if (vHex) - projectileDamageReduction -= 0.3; + projectileDamageReduction -= 0.1; if (irradiated) projectileDamageReduction -= 0.1; @@ -6724,46 +6738,43 @@ 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 (CalamityWorld.revenge || CalamityWorld.malice) - { - 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, 180); - player.AddBuff(BuffID.Venom, 180); - player.AddBuff(BuffID.Bleeding, 300); - } - else if (npc.type == NPCID.PlanterasTentacle) - { - player.AddBuff(BuffID.Poisoned, 120); - player.AddBuff(BuffID.Venom, 120); - player.AddBuff(BuffID.Bleeding, 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, 180); + player.AddBuff(BuffID.Venom, 180); + player.AddBuff(BuffID.Bleeding, 300); + } + else if (npc.type == NPCID.PlanterasTentacle) + { + player.AddBuff(BuffID.Poisoned, 120); + player.AddBuff(BuffID.Venom, 120); + player.AddBuff(BuffID.Bleeding, 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) { @@ -6782,7 +6793,7 @@ namespace CalamityMod.CalPlayer } } - if ((CalamityWorld.revenge || CalamityWorld.malice) && proj.hostile) + if (proj.hostile) { if (proj.type == ProjectileID.Explosives) { @@ -6860,6 +6871,9 @@ namespace CalamityMod.CalPlayer #region Shoot public override bool Shoot(Item item, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { + if (rottenDogTooth && item.Calamity().rogue && item.type != ModContent.ItemType()) + damage = (int)(damage * (1f + RottenDogtooth.StealthStrikeDamageMultiplier)); + if (veneratedLocket) { if (item.Calamity().rogue && item.type != ModContent.ItemType()) @@ -7057,7 +7071,7 @@ namespace CalamityMod.CalPlayer if (weakPetrification) WeakPetrification(); - if (lol || (silvaCountdown > 0 && hasSilvaEffect && silvaSet)) + if (lol || (silvaCountdown > 0 && hasSilvaEffect && silvaSet) || (dashMod == 9 && player.dashDelay < 0)) { if (player.lifeRegen < 0) player.lifeRegen = 0; @@ -7405,7 +7419,7 @@ namespace CalamityMod.CalPlayer player.AddBuff(ModContent.BuffType(), 180); } - if (fBarrier || (sirenBoobs && NPC.downedBoss3)) + if ((fBarrier || (sirenBoobs && NPC.downedBoss3)) && !areThereAnyDamnBosses) { Main.PlaySound(SoundID.Item, (int)player.position.X, (int)player.position.Y, 27); for (int m = 0; m < Main.maxNPCs; m++) @@ -7425,7 +7439,10 @@ namespace CalamityMod.CalPlayer if (npcDist < freezeDist) { - float duration = Main.rand.Next(30 + (int)damage / 3, 80 + (int)damage / 2); + float duration = Main.rand.Next(10 + (int)damage / 4, 20 + (int)damage / 3); + if (duration > 120) + duration = 120; + npc.AddBuff(ModContent.BuffType(), (int)duration, false); } } @@ -8000,13 +8017,187 @@ namespace CalamityMod.CalPlayer #region Dash Stuff public void ModDashMovement() { + 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++) + { + 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 = 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); + bool isImmune = false; + for (int j = 0; j < player.hurtCooldowns.Length; j++) + { + if (player.hurtCooldowns[j] > 0) + isImmune = true; + } + if (!isImmune) + { + player.immune = true; + player.immuneNoBlink = true; + player.immuneTime += 4; + for (int k = 0; k < player.hurtCooldowns.Length; k++) + player.hurtCooldowns[k] = player.immuneTime; + } + } + } + } + } + if (dashMod == 3 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Elysian 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++) + { + 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 = 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; + bool isImmune = false; + for (int j = 0; j < player.hurtCooldowns.Length; j++) + { + if (player.hurtCooldowns[j] > 0) + isImmune = true; + } + if (!isImmune) + { + player.immune = true; + player.immuneNoBlink = true; + player.immuneTime += 4; + for (int k = 0; k < player.hurtCooldowns.Length; k++) + player.hurtCooldowns[k] = player.immuneTime; + } + } + } + } + } + if (dashMod == 2 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Asgard's Valor + { + 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 = 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; + bool isImmune = false; + for (int j = 0; j < player.hurtCooldowns.Length; j++) + { + if (player.hurtCooldowns[j] > 0) + isImmune = true; + } + if (!isImmune) + { + player.immune = true; + player.immuneNoBlink = true; + player.immuneTime += 4; + for (int k = 0; k < player.hurtCooldowns.Length; k++) + player.hurtCooldowns[k] = player.immuneTime; + } + } + } + } + } 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.immune[player.whoAmI] <= 0) + 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))) @@ -8035,13 +8226,10 @@ namespace CalamityMod.CalPlayer { direction = 1; } - if (player.whoAmI == Main.myPlayer) - { - player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); - } - if (npc.immune[player.whoAmI] < 6) - npc.immune[player.whoAmI] = 6; - npc.AddBuff(ModContent.BuffType(), 300); + 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(), 60); bool isImmune = false; for (int j = 0; j < player.hurtCooldowns.Length; j++) { @@ -8060,196 +8248,13 @@ namespace CalamityMod.CalPlayer } } } - 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++) - { - NPC npc = Main.npc[i]; - if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[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; - } - if (player.whoAmI == Main.myPlayer) - { - 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.immune[player.whoAmI] < 6) - npc.immune[player.whoAmI] = 6; - npc.AddBuff(ModContent.BuffType(), 300); - bool isImmune = false; - for (int j = 0; j < player.hurtCooldowns.Length; j++) - { - if (player.hurtCooldowns[j] > 0) - isImmune = true; - } - if (!isImmune) - { - player.immune = true; - player.immuneNoBlink = true; - player.immuneTime += 4; - for (int k = 0; k < player.hurtCooldowns.Length; k++) - player.hurtCooldowns[k] = player.immuneTime; - } - } - } - } - } - if (dashMod == 3 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Elysian 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++) - { - NPC npc = Main.npc[i]; - if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[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; - } - if (player.whoAmI == Main.myPlayer) - { - 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.immune[player.whoAmI] < 6) - npc.immune[player.whoAmI] = 6; - bool isImmune = false; - for (int j = 0; j < player.hurtCooldowns.Length; j++) - { - if (player.hurtCooldowns[j] > 0) - isImmune = true; - } - if (!isImmune) - { - player.immune = true; - player.immuneNoBlink = true; - player.immuneTime += 4; - for (int k = 0; k < player.hurtCooldowns.Length; k++) - player.hurtCooldowns[k] = player.immuneTime; - } - } - } - } - } - if (dashMod == 2 && player.dashDelay < 0 && player.whoAmI == Main.myPlayer) // Asgard's Valor - { - 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.immune[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; - } - if (player.whoAmI == Main.myPlayer) - { - 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.immune[player.whoAmI] < 6) - npc.immune[player.whoAmI] = 6; - bool isImmune = false; - for (int j = 0; j < player.hurtCooldowns.Length; j++) - { - if (player.hurtCooldowns[j] > 0) - isImmune = true; - } - if (!isImmune) - { - player.immune = true; - player.immuneNoBlink = true; - player.immuneTime += 4; - for (int k = 0; k < player.hurtCooldowns.Length; k++) - player.hurtCooldowns[k] = player.immuneTime; - } - } - } - } - } - 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++) { NPC npc = Main.npc[i]; - if (npc.active && !npc.dontTakeDamage && !npc.friendly && npc.immune[player.whoAmI] <= 0) + 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))) @@ -8266,12 +8271,9 @@ namespace CalamityMod.CalPlayer { direction = 1; } - if (player.whoAmI == Main.myPlayer) - { - player.ApplyDamageToNPC(npc, (int)num, num2, direction, crit); - } - if (npc.immune[player.whoAmI] < 6) - npc.immune[player.whoAmI] = 6; + 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); bool isImmune = false; for (int j = 0; j < player.hurtCooldowns.Length; j++) @@ -8291,7 +8293,79 @@ namespace CalamityMod.CalPlayer } } } - if (player.dashDelay > 0) + 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.PurpleCosmolite, 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(), 600); + bool isImmune = false; + for (int j = 0; j < player.hurtCooldowns.Length; j++) + { + if (player.hurtCooldowns[j] > 0) + isImmune = true; + } + if (!isImmune) + { + player.immune = true; + player.immuneNoBlink = true; + player.immuneTime += 4; + for (int k = 0; k < player.hurtCooldowns.Length; k++) + player.hurtCooldowns[k] = player.immuneTime; + } + } + } + } + } + if (player.dashDelay > 0) { return; } @@ -8445,30 +8519,91 @@ namespace CalamityMod.CalPlayer } num7 = 12.5f; } - 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.PurpleCosmolite, 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; + } + if (dashMod > 0) { player.vortexStealthActive = false; - if (player.velocity.X > num7 || player.velocity.X < -num7) - { - player.velocity.X = player.velocity.X * num8; - return; - } - if (player.velocity.X > num9 || player.velocity.X < -num9) - { - player.velocity.X = 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; - if (player.velocity.X < 0f) - { - player.velocity.X = -num9; - return; - } - if (player.velocity.X > 0f) - { - player.velocity.X = num9; - return; - } + + // Cooldown for God Slayer Armor dash + if (dashMod == 9) + { + player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(15f)); + 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; + } + } } } else if (dashMod > 0 && !player.mount.Active) @@ -8613,58 +8748,224 @@ 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); + + for (int d = 0; d < 60; d++) + { + int idx = Dust.NewDust(player.position, player.width, player.height, (int)CalamityDusts.PurpleCosmolite, 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 justDashed = false; int direction = 0; + if (dashTimeMod > 0) - { dashTimeMod--; - } if (dashTimeMod < 0) - { dashTimeMod++; - } - 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) { - player.velocity.X = dashDistance * (float)direction; - Point point5 = (player.Center + new Vector2((float)(direction * player.width / 2 + 2), player.gravDir * (float)-(float)player.height / 2f + player.gravDir * 2f)).ToTileCoordinates(); - Point point6 = (player.Center + new Vector2((float)(direction * player.width / 2 + 2), 0f)).ToTileCoordinates(); - if (WorldGen.SolidOrSlopedTile(point5.X, point5.Y) || WorldGen.SolidOrSlopedTile(point6.X, point6.Y)) - { - player.velocity.X = player.velocity.X / 2f; - } + 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; + + // Down Left + case -3: + player.velocity = possibleVelocities[5]; + 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; + + // Nothing + case 0: + 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 Right + case 3: + player.velocity = possibleVelocities[3]; + 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; + player.dashDelay = -1; } + return justDashed; } @@ -8736,7 +9037,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.PurpleCosmolite, -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) { @@ -8803,7 +9111,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.PurpleCosmolite, -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) @@ -8861,7 +9176,7 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < Main.maxNPCs; i++) { NPC nPC = Main.npc[i]; - if (nPC.active && !nPC.dontTakeDamage && !nPC.friendly && nPC.immune[player.whoAmI] == 0) + if (nPC.active && !nPC.dontTakeDamage && !nPC.friendly && nPC.Calamity().dashImmunityTime[player.whoAmI] <= 0) { Rectangle rect = nPC.getRect(); if (myRect.Intersects(rect) && (nPC.noTileCollide || Collision.CanHit(player.position, player.width, player.height, nPC.position, nPC.width, nPC.height))) @@ -8879,7 +9194,7 @@ namespace CalamityMod.CalPlayer { player.ApplyDamageToNPC(nPC, (int)Damage, Knockback, direction, false); } - nPC.immune[player.whoAmI] = NPCImmuneTime; + nPC.Calamity().dashImmunityTime[player.whoAmI] = NPCImmuneTime; bool isImmune = false; for (int j = 0; j < player.hurtCooldowns.Length; j++) { @@ -8985,6 +9300,7 @@ namespace CalamityMod.CalPlayer // rogueStealth doesn't reset every frame because it's a continuously building resource // these other parameters are rebuilt every frame based on the items you have equipped + stealthDamage = 0f; rogueStealthMax = 0f; stealthGenStandstill = 1f; stealthGenMoving = 1f; @@ -9028,7 +9344,7 @@ namespace CalamityMod.CalPlayer ProvideStealthStatBonuses(); - // If the player is using an item that deals damage and is on their first frame of doing so, + // If the player is using an item that deals damage and is on their first frame of a use of that item, // consume stealth if a stealth strike wasn't triggered manually by item code. // This doesn't trigger stealth strike effects (ConsumeStealthStrike instead of StealthStrike) @@ -9044,11 +9360,24 @@ namespace CalamityMod.CalPlayer bool isChannelable = it.channel; bool hasNonWeaponFunction = isPickaxe || isAxe || isHammer || isPlaced || isChannelable; bool playerUsingWeapon = hasDamage && hasHitboxes && !hasNonWeaponFunction; - bool animationCheck = player.itemAnimation == player.itemAnimationMax - 1; - if (it.useAnimation == it.useTime) - animationCheck = player.itemTime == player.itemAnimationMax - 1; + + // Animation check depends on whether the item is "clockwork", like Clockwork Assault Rifle. + // "Clockwork" weapons can chain-fire multiple stealth strikes (really only 2 max) until you run out of stealth. + bool animationCheck = it.useAnimation == it.useTime + ? player.itemAnimation == player.itemAnimationMax - 1 // Standard weapon (first frame of use animation) + : player.itemTime == it.useTime; // Clockwork weapon (first frame of any individual use event) + if (!stealthStrikeThisFrame && animationCheck && playerUsingWeapon) - ConsumeStealthByAttacking(); + { + bool canStealthStrike = StealthStrikeAvailable(); + + // If you can stealth strike, you do. + if (canStealthStrike) + ConsumeStealthByAttacking(); + // Otherwise you get a "partial stealth strike" (stealth damage is still added to the weapon) and return to normally attacking. + else + rogueStealth = 0f; + } } private void ProvideStealthStatBonuses() @@ -9083,9 +9412,7 @@ namespace CalamityMod.CalPlayer double stealthGenFactor = Math.Max(Math.Pow(fakeStealthTime, 2D / 3D), 1.5); double stealthAddedDamage = rogueStealth * StealthDamageConstant * useTimeFactor * stealthGenFactor; - // TODO -- Store stealth damage elsewhere so that it can't affect rogue on-hits while you stand around with this damage boost. - // This can be done in TML 1.4 using the new DamageClass system (Stealth becomes its own damage class which is a subclass of Rogue) - throwingDamage += (float)stealthAddedDamage; + stealthDamage += (float)stealthAddedDamage; // Show 100% crit chance if your stealth strikes always crit. // In practice, this is only for visuals because Terraria determines crit status on hit. @@ -9194,20 +9521,21 @@ namespace CalamityMod.CalPlayer stealthStrikeThisFrame = true; stealthAcceleration = 1f; // Reset acceleration when you attack + float lossReductionRatio = flatStealthLossReduction / (rogueStealthMax * 100f); if (stealthStrikeHalfCost) { - rogueStealth -= 0.5f * rogueStealthMax; + rogueStealth -= 0.5f * rogueStealthMax - lossReductionRatio; if (rogueStealth <= 0f) rogueStealth = 0f; } else if (stealthStrike75Cost) - { - rogueStealth -= 0.75f * rogueStealthMax; + { + rogueStealth -= 0.75f * rogueStealthMax - lossReductionRatio; if (rogueStealth <= 0f) rogueStealth = 0f; } - else - rogueStealth = 0f; + else + rogueStealth = lossReductionRatio; } #endregion diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 790c444a42..e62115cd7d 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Summon; +using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -472,32 +473,7 @@ namespace CalamityMod.CalPlayer int totalMoonlightDyes = drawPlayer.dye.Count(dyeItem => dyeItem.type == ModContent.ItemType()); if (totalMoonlightDyes <= 0) return; - float auroraCount = 5 + (int)MathHelper.Clamp(totalMoonlightDyes, 0f, 4f) * 2; - float opacity = MathHelper.Clamp(totalMoonlightDyes / 3f, 0f, 1f); - - opacity *= Main.dayTime ? 0.4f : 0.25f; - - float time = Main.GlobalTime % 3f / 3f; - Texture2D auroraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AuroraTexture"); - for (int i = 0; i < auroraCount; i++) - { - float incrementOffsetAngle = MathHelper.TwoPi * i / auroraCount; - float xOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f) * 20f; - float yOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f + MathHelper.ToRadians(60f)) * 6f; - float rotation = (float)Math.Sin(incrementOffsetAngle) * MathHelper.Pi / 12f; - Color color = GetCurrentMoonlightDyeColor(incrementOffsetAngle); - Vector2 offset = new Vector2(xOffset, yOffset - 14f); - DrawData drawData = new DrawData(auroraTexture, - drawPlayer.Top + offset - Main.screenPosition, - null, - color * opacity, - rotation + MathHelper.PiOver2, - auroraTexture.Size() * 0.5f, - 0.135f, - SpriteEffects.None, - 1); - Main.playerDrawData.Add(drawData); - } + CalamityUtils.DrawAuroras(drawPlayer, 5 + (int)MathHelper.Clamp(totalMoonlightDyes, 0f, 4f) * 2, MathHelper.Clamp(totalMoonlightDyes / 3f, 0f, 1f), GetCurrentMoonlightDyeColor()); }); public static readonly PlayerLayer AuralisAuroraEffects = new PlayerLayer("CalamityMod", "AuralisAurora", PlayerLayer.Body, drawInfo => @@ -506,30 +482,16 @@ namespace CalamityMod.CalPlayer CalamityPlayer modPlayer = drawPlayer.Calamity(); if (modPlayer.auralisAuroraCounter < 300 || modPlayer.auralisAuroraCooldown > 0) return; - float auroraCount = 7; - float opacity = 0.4f; + CalamityUtils.DrawAuroras(drawPlayer, 7, 0.4f, CalamityUtils.ColorSwap(Auralis.blueColor, Auralis.greenColor, 3f)); + }); - float time = Main.GlobalTime % 3f / 3f; - Texture2D auroraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AuroraTexture"); - for (int i = 0; i < auroraCount; i++) - { - float incrementOffsetAngle = MathHelper.TwoPi * i / auroraCount; - float xOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f) * 20f; - float yOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f + MathHelper.ToRadians(60f)) * 6f; - float rotation = (float)Math.Sin(incrementOffsetAngle) * MathHelper.Pi / 12f; - Color color = CalamityUtils.ColorSwap(Auralis.blueColor, Auralis.greenColor, 3f); - Vector2 offset = new Vector2(xOffset, yOffset - 14f); - DrawData drawData = new DrawData(auroraTexture, - drawPlayer.Top + offset - Main.screenPosition, - null, - color * opacity, - rotation + MathHelper.PiOver2, - auroraTexture.Size() * 0.5f, - 0.135f, - SpriteEffects.None, - 1); - Main.playerDrawData.Add(drawData); - } + public static readonly PlayerLayer AngelicAllianceAurora = new PlayerLayer("CalamityMod", "AngelicAllianceAurora", PlayerLayer.Body, drawInfo => + { + Player drawPlayer = drawInfo.drawPlayer; + CalamityPlayer modPlayer = drawPlayer.Calamity(); + if (!modPlayer.divineBless) + return; + CalamityUtils.DrawAuroras(drawPlayer, 7, 0.4f, CalamityUtils.ColorSwap(new Color(255, 163, 56), new Color(242, 48, 187), 3f)); }); public static readonly PlayerLayer IbanDevRobot = new PlayerLayer("CalamityMod", "IbanDevRobot", PlayerLayer.Body, drawInfo => @@ -686,6 +648,7 @@ namespace CalamityMod.CalPlayer list.Add(StratusSphereDrawing); list.Add(ProfanedMoonlightDyeEffects); list.Add(AuralisAuroraEffects); + list.Add(AngelicAllianceAurora); list.Add(IbanDevRobot); list.Add(DyeInvisibilityFix); } @@ -1010,7 +973,7 @@ namespace CalamityMod.CalPlayer Main.playerDrawDust.Add(dust); } } - if (calamityPlayer.hFlames || calamityPlayer.hInferno) + if (calamityPlayer.hFlames || calamityPlayer.hInferno || calamityPlayer.banishingFire) { if (Main.rand.NextBool(4) && drawInfo.shadow == 0f) { diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 7bbd4d7641..5eaaf80cc2 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.Alcohol; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Ranged; @@ -27,7 +28,7 @@ namespace CalamityMod.CalPlayer lifeRegenMult *= 0.8; int lifeRegenLost = 0; - // Initial Debuffs + // Initial Debuffs // Get fucked, Nebula Armor player.nebulaLevelLife = 0; @@ -208,6 +209,15 @@ namespace CalamityMod.CalPlayer lifeRegenLost += 16; } + if (modPlayer.banishingFire) + { + if (player.lifeRegen > 0) + player.lifeRegen = 0; + + player.lifeRegenTime = 0; + lifeRegenLost += 60; + } + if (modPlayer.waterLeechBleeding) { if (player.lifeRegen > 0) @@ -396,6 +406,15 @@ namespace CalamityMod.CalPlayer // Buffs + if (modPlayer.divineBless) + { + if (player.whoAmI == Main.myPlayer && player.miscCounter % 15 == 0) // Flat 4 health per second + { + if (!modPlayer.noLifeRegen) + player.statLife += 1; + } + } + if (modPlayer.bloodfinBoost) { if (player.lifeRegen < 0) @@ -564,7 +583,7 @@ namespace CalamityMod.CalPlayer player.mount.Dismount(player); } - if (modPlayer.lol || (modPlayer.silvaCountdown > 0 && modPlayer.hasSilvaEffect && modPlayer.silvaSet)) + if (modPlayer.lol || (modPlayer.silvaCountdown > 0 && modPlayer.hasSilvaEffect && modPlayer.silvaSet) || (modPlayer.dashMod == 9 && player.dashDelay < 0)) { if (player.lifeRegen < 0) player.lifeRegen = 0; @@ -748,8 +767,8 @@ namespace CalamityMod.CalPlayer { player.lifeRegen += 7; - if (player.lifeRegenTime < 1800) - player.lifeRegenTime = 1800; + if (player.lifeRegenTime < 1800) + player.lifeRegenTime = 1800; player.lifeRegenTime += 4; } @@ -933,12 +952,6 @@ namespace CalamityMod.CalPlayer } } - if (player.lifeRegen > 0) - { - if (modPlayer.godSlayerCooldown) - player.lifeRegen /= 2; - } - if (BossRushEvent.BossRushActive) { if (CalamityConfig.Instance.BossRushHealthCurse) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 43aae9e453..db106456cb 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -21,6 +21,7 @@ using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Environment; @@ -75,6 +76,10 @@ namespace CalamityMod.CalPlayer // Bool for any existing events, true if any event is active CalamityPlayer.areThereAnyDamnEvents = CalamityGlobalNPC.AnyEvents(player); + // Hurt the nearest NPC to the mouse if using the burning mouse. + if (modPlayer.blazingMouseDamageEffects) + HandleBlazingMouseEffects(player, modPlayer); + // Revengeance effects RevengeanceModeMiscEffects(player, modPlayer, mod); @@ -261,7 +266,7 @@ namespace CalamityMod.CalPlayer // If Revengeance Mode is not active, then set rippers to zero else if (player.whoAmI == Main.myPlayer) - { + { modPlayer.rage = 0; modPlayer.adrenaline = 0; } @@ -285,8 +290,8 @@ namespace CalamityMod.CalPlayer if (modPlayer.rageGainCooldown > 0) --modPlayer.rageGainCooldown; - // This is how much Rage will be changed by this frame. - float rageDiff = 0; + // This is how much Rage will be changed by this frame. + float rageDiff = 0; // If the player equips multiple rage generation accessories they get the max possible effect without stacking any of them. { @@ -395,87 +400,135 @@ namespace CalamityMod.CalPlayer bool rageFading = modPlayer.rageCombatFrames <= 0 && !modPlayer.heartOfDarkness && !modPlayer.shatteredCommunity; - // If Rage Mode is currently active, you smoothly lose all rage over the duration. - if (modPlayer.rageModeActive) + // If Rage Mode is currently active, you smoothly lose all rage over the duration. + if (modPlayer.rageModeActive) rageDiff -= modPlayer.rageMax / modPlayer.RageDuration; // If out of combat and NOT using Heart of Darkness or Shattered Community, Rage fades away. else if (!modPlayer.rageModeActive && rageFading) rageDiff -= modPlayer.rageMax / CalamityPlayer.RageFadeTime; - // Apply the rage change and cap rage in both directions. - modPlayer.rage += rageDiff; - if (modPlayer.rage < 0) - modPlayer.rage = 0; + // Apply the rage change and cap rage in both directions. + modPlayer.rage += rageDiff; + if (modPlayer.rage < 0) + modPlayer.rage = 0; - if (modPlayer.rage >= modPlayer.rageMax) - { + if (modPlayer.rage >= modPlayer.rageMax) + { // Rage IS NOT capped while active. It can go above 100%. if (!modPlayer.rageModeActive) - modPlayer.rage = modPlayer.rageMax; + modPlayer.rage = modPlayer.rageMax; - // Play a sound when the Rage Meter is full - if (modPlayer.playFullRageSound) - { - modPlayer.playFullRageSound = false; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/FullRage"), (int)player.position.X, (int)player.position.Y); - } - } - else - modPlayer.playFullRageSound = true; + // Play a sound when the Rage Meter is full + if (modPlayer.playFullRageSound) + { + modPlayer.playFullRageSound = false; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/FullRage"), (int)player.position.X, (int)player.position.Y); + } + } + else + modPlayer.playFullRageSound = true; - // This is how much Adrenaline will be changed by this frame. - float adrenalineDiff = 0; - bool SCalAlive = NPC.AnyNPCs(ModContent.NPCType()); - bool wofAndNotHell = Main.wof >= 0 && player.position.Y < (float)((Main.maxTilesY - 200) * 16); + // This is how much Adrenaline will be changed by this frame. + float adrenalineDiff = 0; + bool SCalAlive = NPC.AnyNPCs(ModContent.NPCType()); + bool wofAndNotHell = Main.wof >= 0 && player.position.Y < (float)((Main.maxTilesY - 200) * 16); - // If Adrenaline Mode is currently active, you smoothly lose all adrenaline over the duration. - if (modPlayer.adrenalineModeActive) + // If Adrenaline Mode is currently active, you smoothly lose all adrenaline over the duration. + if (modPlayer.adrenalineModeActive) adrenalineDiff = -modPlayer.adrenalineMax / modPlayer.AdrenalineDuration; - else - { - // If any boss is alive (or you are between DoG phases or Boss Rush is active), you gain adrenaline smoothly. - // EXCEPTION: Wall of Flesh is alive and you are not in hell. Then you don't get anything. - if ((CalamityPlayer.areThereAnyDamnBosses || CalamityWorld.DoGSecondStageCountdown > 0 || BossRushEvent.BossRushActive) && - !wofAndNotHell) - { + else + { + // If any boss is alive (or you are between DoG phases or Boss Rush is active), you gain adrenaline smoothly. + // EXCEPTION: Wall of Flesh is alive and you are not in hell. Then you don't get anything. + if ((CalamityPlayer.areThereAnyDamnBosses || CalamityWorld.DoGSecondStageCountdown > 0 || BossRushEvent.BossRushActive) && + !wofAndNotHell) + { adrenalineDiff += modPlayer.adrenalineMax / modPlayer.AdrenalineChargeTime; - } + } // If you aren't actively in a boss fight, adrenaline rapidly fades away. - else + else adrenalineDiff = -modPlayer.adrenalineMax / modPlayer.AdrenalineFadeTime; - } + } // In the SCal fight, adrenaline charges 33% slower (meaning it takes 50% longer to fully charge it). - if (SCalAlive && adrenalineDiff > 0f) - adrenalineDiff *= 0.67f; + if (SCalAlive && adrenalineDiff > 0f) + adrenalineDiff *= 0.67f; - // Apply the adrenaline change and cap adrenaline in both directions. - modPlayer.adrenaline += adrenalineDiff; - if (modPlayer.adrenaline < 0) - modPlayer.adrenaline = 0; + // Apply the adrenaline change and cap adrenaline in both directions. + modPlayer.adrenaline += adrenalineDiff; + if (modPlayer.adrenaline < 0) + modPlayer.adrenaline = 0; - if (modPlayer.adrenaline >= modPlayer.adrenalineMax) - { - modPlayer.adrenaline = modPlayer.adrenalineMax; + if (modPlayer.adrenaline >= modPlayer.adrenalineMax) + { + modPlayer.adrenaline = modPlayer.adrenalineMax; - // Play a sound when the Adrenaline Meter is full - if (modPlayer.playFullAdrenalineSound) - { - modPlayer.playFullAdrenalineSound = false; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/FullAdrenaline"), (int)player.position.X, (int)player.position.Y); - } - } - else - modPlayer.playFullAdrenalineSound = true; - } + // Play a sound when the Adrenaline Meter is full + if (modPlayer.playFullAdrenalineSound) + { + modPlayer.playFullAdrenalineSound = false; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/FullAdrenaline"), (int)player.position.X, (int)player.position.Y); + } + } + else + modPlayer.playFullAdrenalineSound = true; + } #endregion #region Misc Effects + + private static void HandleBlazingMouseEffects(Player player, CalamityPlayer modPlayer) + { + Rectangle auraRectangle = Utils.CenteredRectangle(Main.MouseWorld, new Vector2(35f, 62f)); + modPlayer.blazingMouseAuraFade = MathHelper.Clamp(modPlayer.blazingMouseAuraFade - 0.025f, 0.25f, 1f); + for (int i = 0; i < Main.maxNPCs; i++) + { + if (!Main.npc[i].CanBeChasedBy() || !Main.npc[i].Hitbox.Intersects(auraRectangle) || !Main.rand.NextBool(2)) + continue; + + harmNPC(Main.npc[i]); + modPlayer.blazingMouseAuraFade = MathHelper.Clamp(modPlayer.blazingMouseAuraFade + 0.15f, 0.25f, 1f); + } + + void harmNPC(NPC npc) + { + int damage = (int)(player.AverageDamage() * Main.rand.Next(1950, 2050)); + npc.StrikeNPC(damage, 0f, 0); + + player.addDPS(damage); + npc.AddBuff(ModContent.BuffType(), 900); + + for (int i = 0; i < 4; i++) + { + Dust fire = Dust.NewDustDirect(npc.position, npc.width, npc.height, 267); + fire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 3.45f); + fire.scale = 1f + fire.velocity.Length() / 6f; + fire.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0.85f)); + fire.noGravity = true; + } + } + } + private static void MiscEffects(Player player, CalamityPlayer modPlayer, Mod mod) { + // Do a vanity/social slot check for SCal's expert drop since alternatives to get this working are a pain in the ass to create. + int blazingMouseItem = ModContent.ItemType(); + for (int i = 13; i < 18 + player.extraAccessorySlots; i++) + { + if (player.armor[i].type == blazingMouseItem) + { + modPlayer.ableToDrawBlazingMouse = true; + break; + } + } + + // Dust on hand when holding the phosphorescent gauntlet. + if (player.ActiveItem().type == ModContent.ItemType()) + PhosphorescentGauntletPunches.GenerateDustOnOwnerHand(player); + if (modPlayer.stealthUIAlpha > 0f && (modPlayer.rogueStealth <= 0f || modPlayer.rogueStealthMax <= 0f)) { modPlayer.stealthUIAlpha -= 0.035f; @@ -1059,7 +1112,7 @@ namespace CalamityMod.CalPlayer { if (modPlayer.shadowMinions) player.maxMinions += 3; - else if (modPlayer.tearMinions) + else if (modPlayer.holyMinions) player.maxMinions += 2; if (modPlayer.starTaintedGenerator) @@ -1100,8 +1153,12 @@ namespace CalamityMod.CalPlayer modPlayer.gSabatonFall--; if (modPlayer.astralStarRainCooldown > 0) modPlayer.astralStarRainCooldown--; + if (modPlayer.tarraRangedCooldown > 0) + modPlayer.tarraRangedCooldown--; if (modPlayer.bloodflareMageCooldown > 0) modPlayer.bloodflareMageCooldown--; + if (modPlayer.silvaMageCooldown > 0) + modPlayer.silvaMageCooldown--; if (modPlayer.tarraMageHealCooldown > 0) modPlayer.tarraMageHealCooldown--; if (modPlayer.featherCrownCooldown > 0) @@ -1202,14 +1259,20 @@ namespace CalamityMod.CalPlayer if (modPlayer.auralisAuroraCooldown > 0) modPlayer.auralisAuroraCooldown--; + // God Slayer Armor dash debuff immunity + if (modPlayer.dashMod == 9 && player.dashDelay < 0) + { + foreach (int debuff in CalamityLists.debuffList) + player.buffImmune[debuff] = true; + } + // Silva invincibility effects if (modPlayer.silvaCountdown > 0 && modPlayer.hasSilvaEffect && modPlayer.silvaSet) { foreach (int debuff in CalamityLists.debuffList) player.buffImmune[debuff] = true; - player.buffImmune[ModContent.BuffType()] = true; - modPlayer.silvaCountdown -= modPlayer.auricSet ? 2 : 1; + modPlayer.silvaCountdown -= 1; if (modPlayer.silvaCountdown <= 0) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), player.Center); @@ -1477,7 +1540,7 @@ namespace CalamityMod.CalPlayer if (!npc.buffImmune[buffType] && Vector2.Distance(player.Center, npc.Center) <= freezeDist) { if (npc.FindBuffIndex(buffType) == -1) - npc.AddBuff(buffType, 120, false); + npc.AddBuff(buffType, 60, false); } } } @@ -1787,6 +1850,13 @@ namespace CalamityMod.CalPlayer modPlayer.prismaticLasers = 1800; player.AddBuff(ModContent.BuffType(), CalamityUtils.SecondsToFrames(30f), true); } + if (!modPlayer.angelicAlliance && modPlayer.divineBless) + { + modPlayer.divineBless = false; + player.ClearBuff(ModContent.BuffType()); + int seconds = CalamityUtils.SecondsToFrames(60f); + player.AddBuff(ModContent.BuffType(), seconds, false); + } } #endregion @@ -2012,24 +2082,6 @@ namespace CalamityMod.CalPlayer #region Max Life And Mana Effects private static void MaxLifeAndManaEffects(Player player, CalamityPlayer modPlayer, Mod mod) { - // Silva invincibility effects - if (modPlayer.silvaHitCounter > 0) - { - player.statLifeMax2 -= modPlayer.silvaHitCounter * 100; - if (player.statLifeMax2 <= 400) - { - player.statLifeMax2 = 400; - if (modPlayer.silvaCountdown > 0) - { - if (player.FindBuffIndex(ModContent.BuffType()) > -1) - player.ClearBuff(ModContent.BuffType()); - - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SilvaDispel"), (int)player.position.X, (int)player.position.Y); - } - modPlayer.silvaCountdown = 0; - } - } - // New textures if (Main.netMode != NetmodeID.Server && player.whoAmI == Main.myPlayer) { @@ -2452,7 +2504,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.irradiated) { - player.statDefense -= 10; + player.statDefense -= 10; player.moveSpeed -= 0.1f; player.allDamage += 0.05f; player.minionKB += 0.5f; @@ -2477,17 +2529,6 @@ namespace CalamityMod.CalPlayer player.meleeDamage += 0.2f; } - if (modPlayer.eScarfBoost) - { - player.allDamage += 0.1f; - modPlayer.AllCritBoost(10); - } - if (modPlayer.sMeleeBoost) - { - player.allDamage += 0.1f; - modPlayer.AllCritBoost(5); - } - if (modPlayer.tFury) { player.meleeDamage += 0.3f; @@ -2748,8 +2789,8 @@ namespace CalamityMod.CalPlayer { bool offenseBuffs = (Main.dayTime && !player.wet) || player.lavaWet; if (offenseBuffs) - flightTimeMult += 0.1; - } + flightTimeMult += 0.1; + } // Increase wing time if (player.wingTimeMax > 0) @@ -2758,7 +2799,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.vHex) { player.blind = true; - player.statDefense -= 30; + player.statDefense -= 10; player.moveSpeed -= 0.1f; if (player.wingTimeMax < 0) @@ -2905,7 +2946,19 @@ namespace CalamityMod.CalPlayer if (modPlayer.gState) { player.statDefense -= GlacialState.DefenseReduction; - player.velocity = Vector2.Zero; + player.velocity.X *= 0.5f; + player.velocity.Y += 0.05f; + if (player.velocity.Y > 15f) + player.velocity.Y = 15f; + } + + if (modPlayer.eFreeze) + { + player.statDefense -= GlacialState.DefenseReduction; + player.velocity.X *= 0.5f; + player.velocity.Y += 0.1f; + if (player.velocity.Y > 15f) + player.velocity.Y = 15f; } if (modPlayer.eFreeze || modPlayer.silvaStun || modPlayer.eutrophication) @@ -3311,15 +3364,16 @@ namespace CalamityMod.CalPlayer bool crystal = modPlayer.profanedCrystal && !modPlayer.profanedCrystalForce; bool summonSet = modPlayer.tarraSummon || modPlayer.bloodflareSummon || modPlayer.silvaSummon || modPlayer.dsSetBonus || modPlayer.omegaBlueSet || modPlayer.fearmongerSet; + int guardianAmt = 1; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < guardianAmt) Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -6f, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, 0f); if (crystal || player.Calamity().minionSlotStat >= 10) { player.Calamity().gDefense = true; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < guardianAmt) Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -3f, ModContent.ProjectileType(), 1, 1f, Main.myPlayer, 0f, 0f); } @@ -3327,7 +3381,7 @@ namespace CalamityMod.CalPlayer { player.Calamity().gOffense = true; - if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) + if (player.ownedProjectileCounts[ModContent.ProjectileType()] < guardianAmt) Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), 1, 1f, Main.myPlayer, 0f, 0f); } } @@ -3420,11 +3474,15 @@ namespace CalamityMod.CalPlayer ModContent.ProjectileType(), ModContent.ProjectileType(), ModContent.ProjectileType(), - ModContent.ProjectileType() + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType(), + ModContent.ProjectileType() }; + int projAmt = 1; for (int i = 0; i < summonDeleteList.Count; i++) { - if (player.ownedProjectileCounts[summonDeleteList[i]] > 1) + if (player.ownedProjectileCounts[summonDeleteList[i]] > projAmt) { for (int projIndex = 0; projIndex < Main.maxProjectiles; projIndex++) { @@ -3583,6 +3641,30 @@ namespace CalamityMod.CalPlayer } } + if (modPlayer.angelicAlliance && Main.myPlayer == player.whoAmI) + { + for (int l = 0; l < Player.MaxBuffs; l++) + { + int hasBuff = player.buffType[l]; + if (hasBuff == ModContent.BuffType()) + { + modPlayer.angelicActivate = player.buffTime[l]; + } + if (hasBuff == ModContent.BuffType()) + { + if (player.buffTime[l] == 1) + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, player.whoAmI); + } + } + if (modPlayer.angelicActivate == 1) + { + int seconds = CalamityUtils.SecondsToFrames(60f); + player.AddBuff(ModContent.BuffType(), seconds, false); + } + if (player.FindBuffIndex(ModContent.BuffType()) == -1) + modPlayer.angelicActivate = -1; + } + if (modPlayer.theBee) { if (player.statLife >= player.statLifeMax2) @@ -3602,8 +3684,8 @@ namespace CalamityMod.CalPlayer modPlayer.GetStatBonuses(); // True melee damage bonuses - double damageAdd = (modPlayer.dodgeScarf ? 0.15 : 0) + - (modPlayer.evasionScarf ? 0.1 : 0) + + double damageAdd = (modPlayer.dodgeScarf ? 0.1 : 0) + + (modPlayer.evasionScarf ? 0.05 : 0) + ((modPlayer.aBulwarkRare && modPlayer.aBulwarkRareMeleeBoostTimer > 0) ? 0.5 : 0) + (modPlayer.fungalSymbiote ? 0.15 : 0) + ((player.head == ArmorIDs.Head.MoltenHelmet && player.body == ArmorIDs.Body.MoltenBreastplate && player.legs == ArmorIDs.Legs.MoltenGreaves) ? 0.2 : 0) + @@ -3956,7 +4038,7 @@ namespace CalamityMod.CalPlayer // 10% is converted to 9%, 25% is converted to 20%, 50% is converted to 33%, 75% is converted to 43%, 100% is converted to 50% if (player.endurance > 0f) player.endurance = 1f - (1f / (1f + player.endurance)); - + // Do not apply reduced aggro if there are any bosses alive and it's singleplayer if (CalamityPlayer.areThereAnyDamnBosses && Main.netMode == NetmodeID.SinglePlayer) { @@ -3970,10 +4052,10 @@ namespace CalamityMod.CalPlayer private static void EnduranceReductions(Player player, CalamityPlayer modPlayer) { if (modPlayer.vHex) - player.endurance -= 0.3f; + player.endurance -= 0.1f; if (modPlayer.irradiated) - player.endurance -= 0.1f; + player.endurance -= 0.1f; if (modPlayer.corrEffigy) player.endurance -= 0.05f; diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 5c5942edcb..2862148680 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Armor; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles; using CalamityMod.Projectiles.Healing; using CalamityMod.Projectiles.Melee; @@ -17,6 +18,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; +using CalamityMod.Items.Accessories; namespace CalamityMod.CalPlayer { @@ -240,21 +242,12 @@ namespace CalamityMod.CalPlayer } } } - if (modPlayer.tarraRanged && Main.rand.Next(0, 100) >= 88 && player.ownedProjectileCounts[ProjectileType()] < 5 && (proj.timeLeft <= 2 || proj.penetrate <= 1)) - { - int projAmt = Main.rand.Next(2, 4); - for (int projCount = 0; projCount < projAmt; projCount++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile.NewProjectile(proj.Center, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.33, 65), 0f, proj.owner); - } - } if (npcCheck) { - if (modPlayer.tarraRanged && crit && proj.ranged) + if (modPlayer.tarraRanged && proj.ranged && modPlayer.tarraRangedCooldown <= 0) { - int leafAmt = Main.rand.Next(2, 4); - for (int l = 0; l < leafAmt; l++) + modPlayer.tarraRangedCooldown = 60; + for (int l = 0; l < 2; l++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); int FUCKYOU = Projectile.NewProjectile(position, velocity, ProjectileID.Leaf, CalamityUtils.DamageSoftCap(proj.damage * 0.25, 60), 0f, player.whoAmI); @@ -264,7 +257,15 @@ namespace CalamityMod.CalPlayer Main.projectile[FUCKYOU].netUpdate = true; } } - } + if (player.ownedProjectileCounts[ProjectileType()] < 2) + { + for (int projCount = 0; projCount < 2; projCount++) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + Projectile.NewProjectile(proj.Center, velocity, ProjectileType(), CalamityUtils.DamageSoftCap(proj.damage * 0.33, 65), 0f, proj.owner); + } + } + } if (proj.type == ProjectileType()) { modPlayer.polarisBoostCounter += 1; @@ -304,8 +305,9 @@ namespace CalamityMod.CalPlayer } } } - if (modPlayer.silvaMage && proj.penetrate == 1 && Main.rand.Next(0, 100) >= 97) + if (modPlayer.silvaMage && modPlayer.silvaMageCooldown <= 0 && (proj.penetrate == 1 || proj.timeLeft <= 5)) { + modPlayer.silvaMageCooldown = 300; Main.PlaySound(SoundID.Zombie, (int)proj.position.X, (int)proj.position.Y, 103); CalamityGlobalProjectile.ExpandHitboxBy(proj, 96); for (int d = 0; d < 3; d++) @@ -325,6 +327,7 @@ namespace CalamityMod.CalPlayer proj.localNPCHitCooldown = 10; proj.usesLocalNPCImmunity = true; proj.Damage(); + proj.Kill(); } } #endregion @@ -557,15 +560,18 @@ namespace CalamityMod.CalPlayer if (modPlayer.moonCrown && modProj.stealthStrike && modPlayer.moonCrownCooldown <= 0 && modProj.stealthStrikeHitCount < 5) { + int lunarFlareDamage = (int)(MoonstoneCrown.BaseDamage * player.RogueDamage()); + float lunarFlareKB = 3f; for (int i = 0; i < 3; i++) { Vector2 source = new Vector2(position.X + Main.rand.Next(-201, 201), Main.screenPosition.Y - 600f - Main.rand.Next(50)); Vector2 velocity = (position - source) / 10f; - int flare = Projectile.NewProjectile(source, velocity, ProjectileID.LunarFlare, (int)(60 * player.RogueDamage()), 3, proj.owner); + int flare = Projectile.NewProjectile(source, velocity, ProjectileID.LunarFlare, lunarFlareDamage, lunarFlareKB, proj.owner); if (flare.WithinBounds(Main.maxProjectiles)) Main.projectile[flare].Calamity().forceTypeless = true; - modPlayer.moonCrownCooldown = 60; } + + modPlayer.moonCrownCooldown = 60; } if (modPlayer.nanotech && modProj.stealthStrike && modPlayer.nanoFlareCooldown <= 0 && modProj.stealthStrikeHitCount < 5) @@ -729,6 +735,7 @@ namespace CalamityMod.CalPlayer public static void NPCDebuffs(Player player, Mod mod, NPC target, bool melee, bool ranged, bool magic, bool summon, bool rogue, bool proj) { CalamityPlayer modPlayer = player.Calamity(); + if (melee) //prevents Deep Sea Dumbell from snagging true melee debuff memes { if (modPlayer.eGauntlet) @@ -743,10 +750,6 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffType(), duration, false); target.AddBuff(BuffType(), duration, false); target.AddBuff(BuffType(), duration, false); - if (Main.rand.NextBool(5)) - { - target.AddBuff(BuffType(), duration, false); - } } if (modPlayer.cryogenSoul || modPlayer.frostFlare) { @@ -764,9 +767,6 @@ namespace CalamityMod.CalPlayer { CalamityUtils.Inflict246DebuffsNPC(target, BuffType()); } - - if (modPlayer.auricSet && modPlayer.godSlayerDamage && Main.rand.NextBool(4) && proj) - target.AddBuff(BuffType(), 60); } if (modPlayer.armorCrumbling || modPlayer.armorShattering) { @@ -820,10 +820,14 @@ namespace CalamityMod.CalPlayer { target.AddBuff(Main.dayTime ? BuffType() : BuffType(), 600); } - - if (modPlayer.tearMinions) + if (modPlayer.divineBless) { - target.AddBuff(BuffType(), 60); + target.AddBuff(BuffType(), 60); + } + + if (modPlayer.holyMinions) + { + target.AddBuff(BuffType(), 300); } if (modPlayer.shadowMinions) @@ -896,10 +900,6 @@ namespace CalamityMod.CalPlayer target.AddBuff(BuffType(), duration, false); target.AddBuff(BuffType(), duration, false); target.AddBuff(BuffType(), duration, false); - if (Main.rand.NextBool(5)) - { - target.AddBuff(BuffType(), duration, false); - } } if (modPlayer.aWeapon) { @@ -917,8 +917,6 @@ namespace CalamityMod.CalPlayer { CalamityUtils.Inflict246DebuffsPvp(target, BuffID.OnFire, 4f); } - if (modPlayer.auricSet && modPlayer.godSlayerDamage && Main.rand.NextBool(4) && proj) - target.AddBuff(BuffType(), 60); } if (modPlayer.armorCrumbling || modPlayer.armorShattering) { @@ -970,9 +968,9 @@ namespace CalamityMod.CalPlayer target.AddBuff(Main.dayTime ? BuffType() : BuffType(), 600); } - if (modPlayer.tearMinions) + if (modPlayer.holyMinions) { - target.AddBuff(BuffType(), 60); + target.AddBuff(BuffType(), 300); } if (modPlayer.shadowMinions) diff --git a/CalamityConfig.cs b/CalamityConfig.cs index d0e6edd9e7..b640141930 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -30,6 +30,12 @@ namespace CalamityMod [Tooltip("Enables rendering afterimages for Calamity NPCs, projectiles, etc.\nDisable to improve performance.")] public bool Afterimages { get; set; } + [Label("Disable Screenshakes")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(false)] + [Tooltip("Disables all screen-shaking effects.")] + public bool DisableScreenShakes { get; set; } + [Label("Stealth Invisibility")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] diff --git a/CalamityLists.cs b/CalamityLists.cs index 4b8f849235..3acec83e67 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -22,6 +22,7 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.AstrumAureus; @@ -35,12 +36,15 @@ using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.GreatSandShark; using CalamityMod.NPCs.HiveMind; +using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Perforator; using CalamityMod.NPCs.PlaguebringerGoliath; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.Providence; using CalamityMod.NPCs.Ravager; using CalamityMod.NPCs.Signus; @@ -146,6 +150,7 @@ namespace CalamityMod public static List mossHornetList; public static List bossMinionList; public static List minibossList; + public static List heartDropBlockList; public static List legOverrideList; @@ -305,11 +310,8 @@ namespace CalamityMod ProjectileID.MushroomSpear, ProjectileID.Gungnir, ProjectileID.ObsidianSwordfish, - ProjectileID.ChlorophytePartisan, ProjectileID.MonkStaffT1, ProjectileID.MonkStaffT2, - ProjectileID.MonkStaffT3, - ProjectileID.NorthPoleWeapon, // Tools ProjectileID.CobaltDrill, @@ -343,28 +345,14 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), ProjectileType(), - ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), ProjectileType(), - ProjectileType(), ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType() @@ -432,13 +420,15 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - // ProjectileType(), // TODO: ADD THE APOTHEOSIS WORM HERE LATER. IT IS IN A DIFFERENT BRANCH AS OF WRITING THIS. + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), + ProjectileType(), //Some hostile boss projectiles ProjectileType(), @@ -488,6 +478,8 @@ namespace CalamityMod NPCID.SkeletronHand, NPCID.WallofFlesh, NPCID.WallofFleshEye, + NPCID.PirateShipCannon, + NPCID.Probe, NPCID.Retinazer, NPCID.Spazmatism, NPCID.SkeletronPrime, @@ -496,7 +488,11 @@ namespace CalamityMod NPCID.PrimeLaser, NPCID.PrimeVice, NPCID.Plantera, + NPCID.PlanterasTentacle, + NPCID.Everscream, + NPCID.SantaNK1, NPCID.IceQueen, + NPCID.MourningWood, NPCID.Pumpking, NPCID.Mothron, NPCID.Golem, @@ -504,12 +500,21 @@ namespace CalamityMod NPCID.GolemHeadFree, NPCID.GolemFistRight, NPCID.GolemFistLeft, - NPCID.GolemHeadFree, + NPCID.MartianSaucerCore, + NPCID.MartianSaucerCannon, + NPCID.MartianSaucerTurret, NPCID.DukeFishron, NPCID.Sharkron, NPCID.Sharkron2, NPCID.CultistBoss, - NPCID.MoonLordHead, + NPCID.CultistDragonHead, + NPCID.CultistDragonBody1, + NPCID.CultistDragonBody2, + NPCID.CultistDragonBody3, + NPCID.CultistDragonBody4, + NPCID.CultistDragonTail, + NPCID.AncientCultistSquidhead, + NPCID.MoonLordHead, NPCID.MoonLordHand, NPCID.MoonLordCore, NPCID.MoonLordFreeEye, @@ -548,8 +553,47 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType() - }; + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; confusionEnemyList = new List() { @@ -754,8 +798,9 @@ namespace CalamityMod BuffType(), BuffType(), BuffType(), - BuffType() - }; + BuffType(), + BuffType() + }; fireWeaponList = new List() { @@ -1262,7 +1307,8 @@ namespace CalamityMod sixtySixDamageBuffList = new List() { - ItemID.TrueNightsEdge, + ItemID.PulseBow, + ItemID.TrueNightsEdge, ItemID.MedusaHead, ItemID.StaffofEarth, ItemID.ChristmasTreeSword, @@ -1274,11 +1320,12 @@ namespace CalamityMod fiftyDamageBuffList = new List() { - ItemID.EldMelter, + ItemID.IceBow, + ItemID.Marrow, + ItemID.EldMelter, ItemID.Flamethrower, ItemID.MoonlordTurretStaff, ItemID.WaspGun, - ItemID.PulseBow, ItemID.PaladinsHammer, ItemID.SolarEruption, ItemID.DayBreak, @@ -1296,8 +1343,6 @@ namespace CalamityMod thirtyThreeDamageBuffList = new List() { ItemID.WandofSparking, - ItemID.IceBow, - ItemID.Marrow, ItemID.CrystalVileShard, ItemID.SoulDrain, ItemID.ClingerStaff, @@ -1334,6 +1379,52 @@ namespace CalamityMod tenDamageBuffList = new List() { + ItemID.WoodenArrow, + ItemID.FlamingArrow, + ItemID.UnholyArrow, + ItemID.JestersArrow, + ItemID.HellfireArrow, + ItemID.HolyArrow, + ItemID.CursedArrow, + ItemID.FrostburnArrow, + ItemID.ChlorophyteArrow, + ItemID.IchorArrow, + ItemID.VenomArrow, + ItemID.BoneArrow, + ItemID.EndlessQuiver, + ItemID.MoonlordArrow, + ItemID.DD2BetsyBow, + ItemID.BorealWoodBow, + ItemID.CopperBow, + ItemID.DemonBow, + ItemID.EbonwoodBow, + ItemID.GoldBow, + ItemID.HellwingBow, + ItemID.IronBow, + ItemID.LeadBow, + ItemID.MoltenFury, + ItemID.PalmWoodBow, + ItemID.PearlwoodBow, + ItemID.DD2PhoenixBow, + ItemID.PlatinumBow, + ItemID.RichMahoganyBow, + ItemID.ShadewoodBow, + ItemID.ShadowFlameBow, + ItemID.SilverBow, + ItemID.TendonBow, + ItemID.BeesKnees, + ItemID.TinBow, + ItemID.Tsunami, + ItemID.TungstenBow, + ItemID.WoodenBow, + ItemID.AdamantiteRepeater, + ItemID.ChlorophyteShotbow, + ItemID.CobaltRepeater, + ItemID.HallowedRepeater, + ItemID.MythrilRepeater, + ItemID.OrichalcumRepeater, + ItemID.PalladiumRepeater, + ItemID.TitaniumRepeater, ItemID.MagnetSphere, ItemID.BatScepter, ItemID.ElectrosphereLauncher @@ -1431,8 +1522,8 @@ namespace CalamityMod tenDamageNerfList = new List() { - ItemID.Phantasm, - ItemID.StarWrath + ItemID.DaedalusStormbow, + ItemID.StarWrath }; quarterDamageNerfList = new List() @@ -1440,7 +1531,6 @@ namespace CalamityMod ItemID.LastPrism, ItemID.DemonScythe, ItemID.Razorpine, - ItemID.DaedalusStormbow, ItemID.PhoenixBlaster, ItemID.InfluxWaver, ItemID.Xenopopper, @@ -1714,7 +1804,10 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - }; + NPCType(), + NPCType(), + NPCType() + }; needsDebuffIconDisplayList = new List() { @@ -2369,7 +2462,69 @@ namespace CalamityMod NPCID.Mothron }; - bossMinionList = new List() + heartDropBlockList = new List() + { + NPCID.BlueSlime, + NPCID.YellowSlime, + NPCID.RedSlime, + NPCID.PurpleSlime, + NPCID.GreenSlime, + NPCID.IceSlime, + NPCID.SlimeSpiked, + NPCID.UmbrellaSlime, + NPCID.RainbowSlime, + NPCID.Pinky, + NPCID.ServantofCthulhu, + NPCID.EaterofWorldsHead, + NPCID.EaterofWorldsBody, + NPCID.EaterofWorldsTail, + NPCID.Creeper, + NPCID.TheHungryII, + NPCID.LeechHead, + NPCID.LeechBody, + NPCID.LeechTail, + NPCID.Probe, + NPCID.Bee, + NPCID.BeeSmall, + NPCID.PlanterasTentacle, + NPCID.Sharkron, + NPCID.Sharkron2, + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCID.DevourerHead, + NPCID.EaterofSouls, + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; + + bossMinionList = new List() { NPCType(), NPCType(), @@ -2458,8 +2613,6 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType(), - NPCType(), NPCType(), NPCType(), NPCType(), @@ -2588,6 +2741,7 @@ namespace CalamityMod mossHornetList = null; bossMinionList = null; minibossList = null; + heartDropBlockList = null; legOverrideList = null; diff --git a/CalamityMod.cs b/CalamityMod.cs index 9452051bd6..5589ef2ecf 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -10,6 +10,7 @@ using CalamityMod.Items.Armor; using CalamityMod.Items.Dyes.HairDye; using CalamityMod.Localization; using CalamityMod.NPCs; +using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.AstrumDeus; @@ -21,6 +22,7 @@ using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.HiveMind; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.OldDuke; @@ -76,6 +78,8 @@ namespace CalamityMod public static ModHotKey SandCloakHotkey; public static ModHotKey SpectralVeilHotKey; public static ModHotKey PlaguePackHotKey; + public static ModHotKey AngelicAllianceHotKey; + public static ModHotKey GodSlayerDashHotKey; // Boss Spawners public static int ghostKillCount = 0; @@ -172,11 +176,11 @@ namespace CalamityMod SandCloakHotkey = RegisterHotKey("Sand Cloak Effect", "C"); SpectralVeilHotKey = RegisterHotKey("Spectral Veil Teleport", "Z"); PlaguePackHotKey = RegisterHotKey("Booster Dash", "Q"); + AngelicAllianceHotKey = RegisterHotKey("Angelic Alliance Blessing", "G"); + GodSlayerDashHotKey = RegisterHotKey("God Slayer Dash", "H"); - if (!Main.dedServ) - { + if (!Main.dedServ) LoadClient(); - } ILChanges.Load(); BossRushEvent.Load(); @@ -251,7 +255,10 @@ namespace CalamityMod Filters.Scene["CalamityMod:SupremeCalamitas"] = new Filter(new SCalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.65f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:SupremeCalamitas"] = new SCalSky(); - Filters.Scene["CalamityMod:Signus"] = new Filter(new SignusScreenShaderData("FilterMiniTower").UseColor(0.35f, 0.1f, 0.55f).UseOpacity(0.35f), EffectPriority.VeryHigh); + Filters.Scene["CalamityMod:AdultEidolonWyrm"] = new Filter(new AEWScreenShaderData("FilterMiniTower").UseColor(0f, 0f, 0.25f).UseOpacity(0.35f), EffectPriority.VeryHigh); + SkyManager.Instance["CalamityMod:AdultEidolonWyrm"] = new AEWSky(); + + Filters.Scene["CalamityMod:Signus"] = new Filter(new SignusScreenShaderData("FilterMiniTower").UseColor(0.35f, 0.1f, 0.55f).UseOpacity(0.35f), EffectPriority.VeryHigh); SkyManager.Instance["CalamityMod:Signus"] = new SignusSky(); Filters.Scene["CalamityMod:BossRush"] = new Filter(new BossRushScreenShader("FilterMiniTower").UseColor(BossRushSky.GeneralColor).UseOpacity(0.75f), EffectPriority.VeryHigh); @@ -259,12 +266,15 @@ namespace CalamityMod SkyManager.Instance["CalamityMod:Astral"] = new AstralSky(); SkyManager.Instance["CalamityMod:Cryogen"] = new CryogenSky(); + SkyManager.Instance["CalamityMod:StormWeaverFlash"] = new StormWeaverFlashSky(); CalamityShaders.LoadShaders(); RipperUI.Load(); AstralArcanumUI.Load(this); + SupremeCalamitas.LoadHeadIcons(); + GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(0, 255, 171), ((float)player.Calamity().adrenaline / (float)player.Calamity().adrenalineMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(255, 83, 48), ((float)player.Calamity().rage / (float)player.Calamity().rageMax)))); GameShaders.Hair.BindShader(ModContent.ItemType(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(139, 205, 255), ((float)player.wingTime / (float)player.wingTimeMax)))); @@ -301,6 +311,8 @@ namespace CalamityMod SandCloakHotkey = null; SpectralVeilHotKey = null; PlaguePackHotKey = null; + AngelicAllianceHotKey = null; + GodSlayerDashHotKey = null; AstralCactusTexture = null; AstralCactusGlowTexture = null; @@ -552,12 +564,11 @@ namespace CalamityMod { ModContent.NPCType(), 5400 }, { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 14400 }, - { ModContent.NPCType(), 1200 }, - { ModContent.NPCType(), 1200 }, - { ModContent.NPCType(), 1200 }, - { ModContent.NPCType(), 5400 }, - { ModContent.NPCType(), 5400 }, - { ModContent.NPCType(), 5400 }, + { ModContent.NPCType(), 10800 }, + { ModContent.NPCType(), 1200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, + { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 7200 }, { ModContent.NPCType(), 10800 }, { ModContent.NPCType(), 10800 }, @@ -568,8 +579,13 @@ namespace CalamityMod { ModContent.NPCType(), 9000 }, { ModContent.NPCType(), 9000 }, { ModContent.NPCType(), 15300 }, - { ModContent.NPCType(), 18000 } - }; + { ModContent.NPCType(), 18000 }, + { ModContent.NPCType(), 21600 }, + { ModContent.NPCType(), 21600 }, + { ModContent.NPCType(), 21600 }, + { ModContent.NPCType(), 21600 }, + { ModContent.NPCType(), 18000 } + }; } #endregion @@ -668,8 +684,6 @@ namespace CalamityMod { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, - { ModContent.NPCType(), velocityScaleMin }, - { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), bitingEnemeyVelocityScale }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, @@ -693,8 +707,13 @@ namespace CalamityMod { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, { ModContent.NPCType(), velocityScaleMin }, - { ModContent.NPCType(), velocityScaleMin } - }; + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), velocityScaleMin }, + { ModContent.NPCType(), bitingEnemeyVelocityScale } + }; } #endregion diff --git a/Dusts/AstralBasic.cs b/Dusts/AstralBasic.cs index f771e84cdb..d9abf93c5b 100644 --- a/Dusts/AstralBasic.cs +++ b/Dusts/AstralBasic.cs @@ -13,14 +13,12 @@ namespace CalamityMod.Dusts public override bool Update(Dust dust) { - //update position + // Update position dust.position += dust.velocity; dust.scale -= 0.02f; if (dust.scale < 0.1f) - { dust.active = false; - } return false; } diff --git a/Dusts/CeaselessDust.cs b/Dusts/CeaselessDust.cs new file mode 100644 index 0000000000..c569eee0f8 --- /dev/null +++ b/Dusts/CeaselessDust.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Dusts +{ + public class CeaselessDust : ModDust + { + public override void OnSpawn(Dust dust) + { + 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); + + dust.position += dust.velocity; + dust.velocity *= 0.95f; + dust.scale -= 0.05f; + + if (dust.scale <= 0.05f) + dust.active = false; + + return false; + } + + 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/CeaselessDust.png b/Dusts/CeaselessDust.png new file mode 100644 index 0000000000..de9e295d65 Binary files /dev/null and b/Dusts/CeaselessDust.png differ diff --git a/Effects/BordernadoFire.fx b/Effects/BordernadoFire.fx new file mode 100644 index 0000000000..f21b52ac0d --- /dev/null +++ b/Effects/BordernadoFire.fx @@ -0,0 +1,71 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput) 0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + // Read the fade map as a streak. + float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.y + cos(uTime) * 0.01), frac(coords.x - uTime * 1.4 * uSaturation))); + fadeMapColor.r *= pow(coords.x, 0.2); + + float opacity = lerp(1.45, 1.95, fadeMapColor.r) * color.a; + opacity *= pow(sin(coords.y * 3.141), lerp(1, 4, pow(coords.x, 2))); + opacity *= fadeMapColor.r * 1.5 + 1; + opacity *= lerp(0.4, 0.9, fadeMapColor.r); + + float3 transformColor = lerp(float3(1, 205 / 255.0, 119 / 255.0), float3(1, 76 / 255.0, 79 / 255.0), fadeMapColor.r); + color.rgb = lerp(color.rgb, transformColor, fadeMapColor.r); + return color * opacity * 1.6; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/BordernadoFire.xnb b/Effects/BordernadoFire.xnb new file mode 100644 index 0000000000..2d0ac3b0dc Binary files /dev/null and b/Effects/BordernadoFire.xnb differ diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 407dc6b42c..1e4fad2bf1 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -10,9 +10,15 @@ namespace CalamityMod.Effects { public static Effect AstralFogShader; public static Effect LightShader; + public static Effect SCalMouseShader; public static Effect TentacleShader; public static Effect LightDistortionShader; + public static Effect PhaseslayerRipShader; public static Effect FadedUVMapStreakShader; + public static Effect ScarletDevilShader; + public static Effect BordernadoFireShader; + public static Effect PrismCrystalShader; + public static Effect SCalShieldShader; public static void LoadShaders() { @@ -21,17 +27,29 @@ namespace CalamityMod.Effects AstralFogShader = CalamityMod.Instance.GetEffect("Effects/CustomShader"); LightShader = CalamityMod.Instance.GetEffect("Effects/LightBurstShader"); TentacleShader = CalamityMod.Instance.GetEffect("Effects/TentacleShader"); + SCalMouseShader = CalamityMod.Instance.GetEffect("Effects/SCalMouseShader"); LightDistortionShader = CalamityMod.Instance.GetEffect("Effects/DistortionShader"); + PhaseslayerRipShader = CalamityMod.Instance.GetEffect("Effects/PhaseslayerRipShader"); + ScarletDevilShader = CalamityMod.Instance.GetEffect("Effects/ScarletDevilStreak"); + BordernadoFireShader = CalamityMod.Instance.GetEffect("Effects/BordernadoFire"); + PrismCrystalShader = CalamityMod.Instance.GetEffect("Effects/PrismCrystalStreak"); FadedUVMapStreakShader = CalamityMod.Instance.GetEffect("Effects/FadedUVMapStreak"); + SCalShieldShader = CalamityMod.Instance.GetEffect("Effects/SupremeShieldShader"); Filters.Scene["CalamityMod:Astral"] = new Filter(new AstralScreenShaderData(new Ref(AstralFogShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f), EffectPriority.VeryHigh); Filters.Scene["CalamityMod:LightBurst"] = new Filter(new ScreenShaderData(new Ref(LightShader), "BurstPass"), EffectPriority.VeryHigh); Filters.Scene["CalamityMod:LightBurst"].Load(); + GameShaders.Misc["CalamityMod:FireMouse"] = new MiscShaderData(new Ref(SCalMouseShader), "DyePass"); GameShaders.Misc["CalamityMod:SubsumingTentacle"] = new MiscShaderData(new Ref(TentacleShader), "BurstPass"); GameShaders.Misc["CalamityMod:LightDistortion"] = new MiscShaderData(new Ref(LightDistortionShader), "DistortionPass"); + GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"] = new MiscShaderData(new Ref(PhaseslayerRipShader), "TrailPass"); GameShaders.Misc["CalamityMod:TrailStreak"] = new MiscShaderData(new Ref(FadedUVMapStreakShader), "TrailPass"); + GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"] = new MiscShaderData(new Ref(ScarletDevilShader), "TrailPass"); + GameShaders.Misc["CalamityMod:Bordernado"] = new MiscShaderData(new Ref(BordernadoFireShader), "TrailPass"); + GameShaders.Misc["CalamityMod:PrismaticStreak"] = new MiscShaderData(new Ref(PrismCrystalShader), "TrailPass"); + GameShaders.Misc["CalamityMod:SupremeShield"] = new MiscShaderData(new Ref(SCalShieldShader), "ShieldPass"); } } } diff --git a/Effects/FabstaffStreak.fx b/Effects/FabstaffStreak.fx new file mode 100644 index 0000000000..497063c9da --- /dev/null +++ b/Effects/FabstaffStreak.fx @@ -0,0 +1,72 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + // Read the fade map as a streak. + float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.x - uTime * 2.5), coords.y)); + float opacity = fadeMapColor.r; + + // Fade out at the edges of the trail to give a blur effect. + // This is very important. + float power = lerp(3, 10, coords.x); + opacity = lerp(pow(sin(coords.y * 3.141), power), opacity, coords.x); + + // Fade out at the end of the streak. + if (coords.x > 0.7) + opacity *= pow(1 - (coords.x - 0.7) / 0.3, 6); + return color * opacity * 1.5; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/FabstaffStreak.xnb b/Effects/FabstaffStreak.xnb new file mode 100644 index 0000000000..45b95d5d3f Binary files /dev/null and b/Effects/FabstaffStreak.xnb differ diff --git a/Effects/PhaseslayerRipShader.fx b/Effects/PhaseslayerRipShader.fx new file mode 100644 index 0000000000..5f2870b13b --- /dev/null +++ b/Effects/PhaseslayerRipShader.fx @@ -0,0 +1,61 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + float slashMapColor = tex2D(uImage1, coords); + float opacity = 1 - slashMapColor.r; + return color * pow(opacity, 3); +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/PhaseslayerRipShader.xnb b/Effects/PhaseslayerRipShader.xnb new file mode 100644 index 0000000000..02b74566ba Binary files /dev/null and b/Effects/PhaseslayerRipShader.xnb differ diff --git a/Effects/PrismCrystalStreak.fx b/Effects/PrismCrystalStreak.fx new file mode 100644 index 0000000000..8ec86f9cd3 --- /dev/null +++ b/Effects/PrismCrystalStreak.fx @@ -0,0 +1,70 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +// Inputted images go into uImage1 sampler, in case you have a noise map or something similar. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + float areaFadeGlow = lerp(1.2, 17, coords.x); + if (coords.x < 0.25) + areaFadeGlow = lerp(areaFadeGlow, 1.2, 1 - coords.x / 0.25); + float2 mapColor = tex2D(uImage1, float2(frac(coords.x - uTime * 4.2), coords.y)); + float opacity = pow(sin(coords.y * 3.141), areaFadeGlow) + 0.6 * lerp(1.1, 0.3, coords.x) * mapColor.r; + + if (coords.x > 0.66) + opacity = lerp(opacity, 0, (coords.x - 0.66) / 0.3); + + return color * opacity; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/PrismCrystalStreak.xnb b/Effects/PrismCrystalStreak.xnb new file mode 100644 index 0000000000..43f330f1f6 Binary files /dev/null and b/Effects/PrismCrystalStreak.xnb differ diff --git a/Effects/SCalMouseShader.fx b/Effects/SCalMouseShader.fx new file mode 100644 index 0000000000..07151bc3b6 --- /dev/null +++ b/Effects/SCalMouseShader.fx @@ -0,0 +1,31 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float fadeInterpolant = cos(coords.y * coords.x * 6.283 - uTime * 13.1) * 0.5 + 0.5; + + float4 fadeColor = float4(lerp(uColor, uSecondaryColor, fadeInterpolant), 1); + float4 color = tex2D(uImage0, coords) * fadeColor; + color *= 1 + fadeInterpolant * 0.5; + return color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/SCalMouseShader.xnb b/Effects/SCalMouseShader.xnb new file mode 100644 index 0000000000..a6f0b32b7f Binary files /dev/null and b/Effects/SCalMouseShader.xnb differ diff --git a/Effects/ScarletDevilStreak.fx b/Effects/ScarletDevilStreak.fx new file mode 100644 index 0000000000..b79f4db97e --- /dev/null +++ b/Effects/ScarletDevilStreak.fx @@ -0,0 +1,70 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +// Inputted images go into uImage1 sampler, in case you have a noise map or something similar. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + float areaFadeGlow = lerp(1.2, 17, coords.x); + if (coords.x < 0.25) + areaFadeGlow = lerp(areaFadeGlow, 1.2, 1 - coords.x / 0.25); + float2 mapColor = tex2D(uImage1, float2(frac(coords.x - uTime * 2.5), coords.y)); + float opacity = pow(sin(coords.y * 3.141), areaFadeGlow) + 0.6 * lerp(1.1, 0.3, coords.x) * mapColor.r; + + if (coords.x > 0.66) + opacity = lerp(opacity, 0, (coords.x - 0.66) / 0.3); + + return color * opacity; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/ScarletDevilStreak.xnb b/Effects/ScarletDevilStreak.xnb new file mode 100644 index 0000000000..b68ab8631d Binary files /dev/null and b/Effects/ScarletDevilStreak.xnb differ diff --git a/Effects/SupremeShieldShader.fx b/Effects/SupremeShieldShader.fx new file mode 100644 index 0000000000..b91aff9481 --- /dev/null +++ b/Effects/SupremeShieldShader.fx @@ -0,0 +1,46 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity : register(C0); +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float inverseLerp(float x, float min, float max) +{ + return saturate((x - min) / (max - min)); +} +float4 PixelFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 baseColor = tex2D(uImage0, coords); + float4 noiseColor = tex2D(uImage1, float2(coords.x, frac(coords.y + uTime * 0.7))); + float start = 0.45 + sin(uTime * 3) * 0.04; + float ringRadus = 0.1; + float distanceRatio = distance(coords, float2(0.5, 0.5)) * 1.414; + float3 colorToUse = lerp(uColor, uSecondaryColor, pow(distanceRatio, 0.6)); + float originalAlpha = pow(inverseLerp(distanceRatio, 0, start), 2.6); + float ringAlpha = sin(3.141 * inverseLerp(distanceRatio, start, start + ringRadus)) * 1.96; + if (distanceRatio < start) + originalAlpha *= lerp(1, 2.6, noiseColor.r); + else + originalAlpha = lerp(originalAlpha, ringAlpha, inverseLerp(distanceRatio, start, start + ringRadus * 0.5)); + + originalAlpha *= lerp(1, 0.56, distanceRatio) * lerp(1, 2.45, min(1, pow(sin(uTime * 3.1), 10) * 0.7 + uSaturation)); + baseColor = float4(lerp(baseColor.rgb, colorToUse, 0.5), 1.0); + return baseColor * originalAlpha * uOpacity; +} + +technique Technique1 +{ + pass ShieldPass + { + PixelShader = compile ps_2_0 PixelFunction(); + } +} \ No newline at end of file diff --git a/Effects/SupremeShieldShader.xnb b/Effects/SupremeShieldShader.xnb new file mode 100644 index 0000000000..63dcfed3e6 Binary files /dev/null and b/Effects/SupremeShieldShader.xnb differ diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 11b694dbc9..01219088da 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -227,7 +227,8 @@ namespace CalamityMod.Events player.ClearBuff(ModContent.BuffType()); } } - NPC.SpawnOnPlayer(ClosestPlayerToWorldCenter, type); + Main.PlaySound(CalamityMod.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SupremeCalamitasSpawn"), Main.player[ClosestPlayerToWorldCenter].Center); + CalamityUtils.SpawnBossBetter(Main.player[ClosestPlayerToWorldCenter].Top - new Vector2(42f, 84f), type); }), new Boss(ModContent.NPCType(), TimeChangeContext.Day), new Boss(ModContent.NPCType(), TimeChangeContext.Day, type => diff --git a/ExtraTextures/CalamitasShield.png b/ExtraTextures/CalamitasShield.png new file mode 100644 index 0000000000..6adeaa39a5 Binary files /dev/null and b/ExtraTextures/CalamitasShield.png differ diff --git a/ExtraTextures/CalamityAura.png b/ExtraTextures/CalamityAura.png new file mode 100644 index 0000000000..fddcf00e77 Binary files /dev/null and b/ExtraTextures/CalamityAura.png differ diff --git a/ExtraTextures/EternityStreak.png b/ExtraTextures/EternityStreak.png new file mode 100644 index 0000000000..8b7fcd0246 Binary files /dev/null and b/ExtraTextures/EternityStreak.png differ diff --git a/ExtraTextures/FabstaffStreak.png b/ExtraTextures/FabstaffStreak.png new file mode 100644 index 0000000000..3a05118936 Binary files /dev/null and b/ExtraTextures/FabstaffStreak.png differ diff --git a/ExtraTextures/Lasers/ExoDestroyerBeamEnd.png b/ExtraTextures/Lasers/ExoDestroyerBeamEnd.png new file mode 100644 index 0000000000..8facdfbb48 Binary files /dev/null and b/ExtraTextures/Lasers/ExoDestroyerBeamEnd.png differ diff --git a/ExtraTextures/Lasers/ExoDestroyerBeamMiddle.png b/ExtraTextures/Lasers/ExoDestroyerBeamMiddle.png new file mode 100644 index 0000000000..fe2d7fe372 Binary files /dev/null and b/ExtraTextures/Lasers/ExoDestroyerBeamMiddle.png differ diff --git a/ExtraTextures/Lasers/FadeLaserEnd.png b/ExtraTextures/Lasers/FadeLaserEnd.png new file mode 100644 index 0000000000..899fa12378 Binary files /dev/null and b/ExtraTextures/Lasers/FadeLaserEnd.png differ diff --git a/ExtraTextures/Lasers/FadeLaserMid.png b/ExtraTextures/Lasers/FadeLaserMid.png new file mode 100644 index 0000000000..67af476cc0 Binary files /dev/null and b/ExtraTextures/Lasers/FadeLaserMid.png differ diff --git a/ExtraTextures/Lasers/FadeLaserStart.png b/ExtraTextures/Lasers/FadeLaserStart.png new file mode 100644 index 0000000000..0e661a1658 Binary files /dev/null and b/ExtraTextures/Lasers/FadeLaserStart.png differ diff --git a/ExtraTextures/Lasers/PrismLaserEnd.png b/ExtraTextures/Lasers/PrismLaserEnd.png new file mode 100644 index 0000000000..a8079f3418 Binary files /dev/null and b/ExtraTextures/Lasers/PrismLaserEnd.png differ diff --git a/ExtraTextures/Lasers/PrismLaserMid.png b/ExtraTextures/Lasers/PrismLaserMid.png new file mode 100644 index 0000000000..9f45394bd2 Binary files /dev/null and b/ExtraTextures/Lasers/PrismLaserMid.png differ diff --git a/ExtraTextures/Lasers/PrismLaserStart.png b/ExtraTextures/Lasers/PrismLaserStart.png new file mode 100644 index 0000000000..e8c3590839 Binary files /dev/null and b/ExtraTextures/Lasers/PrismLaserStart.png differ diff --git a/ExtraTextures/Lasers/UniverseSplitterHugeBeamEnd.png b/ExtraTextures/Lasers/UniverseSplitterHugeBeamEnd.png new file mode 100644 index 0000000000..4f303c2da1 Binary files /dev/null and b/ExtraTextures/Lasers/UniverseSplitterHugeBeamEnd.png differ diff --git a/ExtraTextures/Lasers/UniverseSplitterHugeBeamMid.png b/ExtraTextures/Lasers/UniverseSplitterHugeBeamMid.png new file mode 100644 index 0000000000..3fea77c900 Binary files /dev/null and b/ExtraTextures/Lasers/UniverseSplitterHugeBeamMid.png differ diff --git a/ExtraTextures/Lasers/UniverseSplitterSmallBeamBegin.png b/ExtraTextures/Lasers/UniverseSplitterSmallBeamBegin.png new file mode 100644 index 0000000000..1f385eb929 Binary files /dev/null and b/ExtraTextures/Lasers/UniverseSplitterSmallBeamBegin.png differ diff --git a/ExtraTextures/Lasers/UniverseSplitterSmallBeamEnd.png b/ExtraTextures/Lasers/UniverseSplitterSmallBeamEnd.png new file mode 100644 index 0000000000..2704d556d4 Binary files /dev/null and b/ExtraTextures/Lasers/UniverseSplitterSmallBeamEnd.png differ diff --git a/ExtraTextures/Lasers/UniverseSplitterSmallBeamMid.png b/ExtraTextures/Lasers/UniverseSplitterSmallBeamMid.png new file mode 100644 index 0000000000..ceb754745d Binary files /dev/null and b/ExtraTextures/Lasers/UniverseSplitterSmallBeamMid.png differ diff --git a/ExtraTextures/ScarletDevilStreak.png b/ExtraTextures/ScarletDevilStreak.png new file mode 100644 index 0000000000..389379b370 Binary files /dev/null and b/ExtraTextures/ScarletDevilStreak.png differ diff --git a/ExtraTextures/SwordSlashTexture.png b/ExtraTextures/SwordSlashTexture.png new file mode 100644 index 0000000000..4bb428f196 Binary files /dev/null and b/ExtraTextures/SwordSlashTexture.png differ diff --git a/ExtraTextures/ThanatosVentParticle.png b/ExtraTextures/ThanatosVentParticle.png new file mode 100644 index 0000000000..a66a5aa743 Binary files /dev/null and b/ExtraTextures/ThanatosVentParticle.png differ diff --git a/Gores/PrismShurikenBlade.png b/Gores/PrismShurikenBlade.png new file mode 100644 index 0000000000..650f27e8c1 Binary files /dev/null and b/Gores/PrismShurikenBlade.png differ diff --git a/Gores/Thanatos/ThanatosBody1.png b/Gores/Thanatos/ThanatosBody1.png new file mode 100644 index 0000000000..846ec8a27e Binary files /dev/null and b/Gores/Thanatos/ThanatosBody1.png differ diff --git a/Gores/Thanatos/ThanatosBody1_2.png b/Gores/Thanatos/ThanatosBody1_2.png new file mode 100644 index 0000000000..b5aa29046b Binary files /dev/null and b/Gores/Thanatos/ThanatosBody1_2.png differ diff --git a/Gores/Thanatos/ThanatosBody1_3.png b/Gores/Thanatos/ThanatosBody1_3.png new file mode 100644 index 0000000000..d22ecb673b Binary files /dev/null and b/Gores/Thanatos/ThanatosBody1_3.png differ diff --git a/Gores/Thanatos/ThanatosBody2.png b/Gores/Thanatos/ThanatosBody2.png new file mode 100644 index 0000000000..88b0bd01e5 Binary files /dev/null and b/Gores/Thanatos/ThanatosBody2.png differ diff --git a/Gores/Thanatos/ThanatosBody2_2.png b/Gores/Thanatos/ThanatosBody2_2.png new file mode 100644 index 0000000000..cb7ae15507 Binary files /dev/null and b/Gores/Thanatos/ThanatosBody2_2.png differ diff --git a/Gores/Thanatos/ThanatosBody2_3.png b/Gores/Thanatos/ThanatosBody2_3.png new file mode 100644 index 0000000000..97eb4cc715 Binary files /dev/null and b/Gores/Thanatos/ThanatosBody2_3.png differ diff --git a/Gores/Thanatos/ThanatosHead.png b/Gores/Thanatos/ThanatosHead.png new file mode 100644 index 0000000000..dfb3f287c6 Binary files /dev/null and b/Gores/Thanatos/ThanatosHead.png differ diff --git a/Gores/Thanatos/ThanatosHead2.png b/Gores/Thanatos/ThanatosHead2.png new file mode 100644 index 0000000000..7df1a911da Binary files /dev/null and b/Gores/Thanatos/ThanatosHead2.png differ diff --git a/Gores/Thanatos/ThanatosHead3.png b/Gores/Thanatos/ThanatosHead3.png new file mode 100644 index 0000000000..ecc13b3891 Binary files /dev/null and b/Gores/Thanatos/ThanatosHead3.png differ diff --git a/Gores/Thanatos/ThanatosTail.png b/Gores/Thanatos/ThanatosTail.png new file mode 100644 index 0000000000..38ec9513fb Binary files /dev/null and b/Gores/Thanatos/ThanatosTail.png differ diff --git a/Gores/Thanatos/ThanatosTail2.png b/Gores/Thanatos/ThanatosTail2.png new file mode 100644 index 0000000000..ec5cf41bdb Binary files /dev/null and b/Gores/Thanatos/ThanatosTail2.png differ diff --git a/Gores/Thanatos/ThanatosTail3.png b/Gores/Thanatos/ThanatosTail3.png new file mode 100644 index 0000000000..22acef22dc Binary files /dev/null and b/Gores/Thanatos/ThanatosTail3.png differ diff --git a/Gores/Thanatos/ThanatosTail4.png b/Gores/Thanatos/ThanatosTail4.png new file mode 100644 index 0000000000..09c638cebf Binary files /dev/null and b/Gores/Thanatos/ThanatosTail4.png differ diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index 1ba37cd449..c19082b208 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -11,8 +11,11 @@ using System; using System.Collections.Generic; using System.Reflection; using Terraria; +using Terraria.GameInput; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using Terraria.UI.Gamepad; using Terraria.Utilities; using Terraria.World.Generation; @@ -120,6 +123,8 @@ namespace CalamityMod.ILEditing DisableDemonAltarGeneration(); DisableTeleportersDuringBossFights(); FixSplittingWormBannerDrops(); + UseCoolFireCursorEffect(); + MakeMouseHoverItemsSupportAnimations(); } /// @@ -448,6 +453,33 @@ namespace CalamityMod.ILEditing }; } + private static void MakeMouseHoverItemsSupportAnimations() + { + IL.Terraria.Main.DrawInterface_40_InteractItemIcon += (il) => + { + var cursor = new ILCursor(il); + + // Locate the location where the frame rectangle is created. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchNewobj())) + return; + + int endIndex = cursor.Index; + + // And then go back to where it began, right after the draw position vector. + if (!cursor.TryGotoPrev(MoveType.After, i => i.MatchNewobj())) + return; + + // And delete the range that creates the rectangle with intent to replace it. + cursor.RemoveRange(Math.Abs(endIndex - cursor.Index)); + + cursor.Emit(OpCodes.Ldloc_0); + cursor.EmitDelegate>(itemType => + { + return Main.itemAnimations[itemType]?.GetFrame(Main.itemTexture[itemType]) ?? null; + }); + }; + } + #endregion #region IL Editing Injected/Hooked Functions @@ -498,7 +530,104 @@ namespace CalamityMod.ILEditing return orig(i, j, forced); } - private static void PreventSmashAltarCode(On.Terraria.WorldGen.orig_SmashAltar orig, int i, int j) + private static void UseCoolFireCursorEffect() + { + On.Terraria.Main.DrawCursor += (orig, bonus, smart) => + { + // Do nothing special if the player has a regular mouse or is on the menu. + if (Main.gameMenu || !Main.LocalPlayer.Calamity().ableToDrawBlazingMouse) + { + orig(bonus, smart); + return; + } + + if (Main.LocalPlayer.dead) + { + Main.SmartInteractShowingGenuine = false; + Main.SmartInteractShowingFake = false; + Main.SmartInteractNPC = -1; + Main.SmartInteractNPCsNearby.Clear(); + Main.SmartInteractTileCoords.Clear(); + Main.SmartInteractTileCoordsSelected.Clear(); + Main.TileInteractionLX = (Main.TileInteractionHX = (Main.TileInteractionLY = (Main.TileInteractionHY = -1))); + } + + Color flameColor = Color.Lerp(Color.DarkRed, Color.OrangeRed, (float)Math.Cos(Main.GlobalTime * 7.4f) * 0.5f + 0.5f); + Color cursorColor = flameColor * 1.9f; + Vector2 baseDrawPosition = Main.MouseScreen + bonus; + + // Draw the mouse as usual if the player isn't using the gamepad. + if (!PlayerInput.UsingGamepad) + { + int cursorIndex = smart.ToInt(); + + Color desaturatedCursorColor = cursorColor; + desaturatedCursorColor.R /= 5; + desaturatedCursorColor.G /= 5; + desaturatedCursorColor.B /= 5; + desaturatedCursorColor.A /= 2; + + Vector2 drawPosition = baseDrawPosition; + Vector2 desaturatedDrawPosition = drawPosition + Vector2.One; + + // If the blazing mouse is actually going to do damage, draw an indicator aura. + if (Main.LocalPlayer.Calamity().blazingMouseDamageEffects && !Main.mapFullscreen) + { + Texture2D auraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/CalamityAura"); + Rectangle auraFrame = auraTexture.Frame(1, 6, 0, (int)(Main.GlobalTime * 12.3f) % 6); + float auraScale = MathHelper.Lerp(0.95f, 1f, (float)Math.Sin(Main.GlobalTime * 1.1f) * 0.5f + 0.5f); + + for (int i = 0; i < 12; i++) + { + Color auraColor = Color.Orange * Main.LocalPlayer.Calamity().blazingMouseAuraFade * 0.125f; + auraColor.A = 0; + Vector2 offsetDrawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 12f + Main.GlobalTime * 5f).ToRotationVector2() * 2.5f; + offsetDrawPosition.Y -= 18f; + + Main.spriteBatch.Draw(auraTexture, offsetDrawPosition, auraFrame, auraColor, 0f, auraFrame.Size() * 0.5f, Main.cursorScale * auraScale, SpriteEffects.None, 0f); + } + } + + Main.spriteBatch.Draw(Main.cursorTextures[cursorIndex], drawPosition, null, desaturatedCursorColor, 0f, Vector2.Zero, Main.cursorScale, SpriteEffects.None, 0f); + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); + GameShaders.Misc["CalamityMod:FireMouse"].UseColor(Color.Red); + GameShaders.Misc["CalamityMod:FireMouse"].UseSecondaryColor(Color.Lerp(Color.Red, Color.Orange, 0.75f)); + GameShaders.Misc["CalamityMod:FireMouse"].Apply(); + + Main.spriteBatch.Draw(Main.cursorTextures[cursorIndex], desaturatedDrawPosition, null, cursorColor, 0f, Vector2.Zero, Main.cursorScale * 1.075f, SpriteEffects.None, 0f); + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); + return; + } + + // Don't bother doing any more drawing if the player is dead. + if (Main.LocalPlayer.dead && !Main.LocalPlayer.ghost && !Main.gameMenu) + return; + + if (PlayerInput.InvisibleGamepadInMenus) + return; + + // Draw a white circle instead if using the smart cursor. + if (smart && !(UILinkPointNavigator.Available && !PlayerInput.InBuildingMode)) + { + cursorColor = Color.White * Main.GamepadCursorAlpha; + int frameX = 0; + Texture2D smartCursorTexture = Main.cursorTextures[13]; + Rectangle frame = smartCursorTexture.Frame(2, 1, frameX, 0); + Main.spriteBatch.Draw(smartCursorTexture, baseDrawPosition, frame, cursorColor, 0f, frame.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); + return; + } + + // Otherwise draw an ordinary crosshair at the mouse position. + cursorColor = Color.White; + Texture2D crosshairTexture = Main.cursorTextures[15]; + Main.spriteBatch.Draw(crosshairTexture, baseDrawPosition, null, cursorColor, 0f, crosshairTexture.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); + }; + } + + private static void PreventSmashAltarCode(On.Terraria.WorldGen.orig_SmashAltar orig, int i, int j) { if (CalamityConfig.Instance.EarlyHardmodeProgressionRework) return; diff --git a/Items/Accessories/AngelicAlliance.cs b/Items/Accessories/AngelicAlliance.cs new file mode 100644 index 0000000000..40d80fe731 --- /dev/null +++ b/Items/Accessories/AngelicAlliance.cs @@ -0,0 +1,79 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.Furniture.CraftingStations; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +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"); + } + + 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 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(); + } + } +} diff --git a/Items/Accessories/AngelicAlliance.png b/Items/Accessories/AngelicAlliance.png new file mode 100644 index 0000000000..ced2c42de5 Binary files /dev/null and b/Items/Accessories/AngelicAlliance.png differ diff --git a/Items/Accessories/ArcanumoftheVoid.cs b/Items/Accessories/ArcanumoftheVoid.cs index fa9cf06b77..3935938937 100644 --- a/Items/Accessories/ArcanumoftheVoid.cs +++ b/Items/Accessories/ArcanumoftheVoid.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Items.Accessories item.value = CalamityGlobalItem.Rarity12BuyPrice; item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.Turquoise; - item.expert = true; } public override void UpdateAccessory(Player player, bool hideVisual) diff --git a/Items/Accessories/AsgardianAegis.cs b/Items/Accessories/AsgardianAegis.cs index 35ceb5509b..c7002d826b 100644 --- a/Items/Accessories/AsgardianAegis.cs +++ b/Items/Accessories/AsgardianAegis.cs @@ -66,6 +66,7 @@ namespace CalamityMod.Items.Accessories player.buffImmune[BuffID.Silenced] = true; player.buffImmune[BuffID.Cursed] = true; player.buffImmune[BuffID.Darkness] = true; + player.buffImmune[BuffID.WindPushed] = true; player.buffImmune[ModContent.BuffType()] = true; player.buffImmune[ModContent.BuffType()] = true; player.buffImmune[ModContent.BuffType()] = true; diff --git a/Items/Accessories/AsgardsValor.cs b/Items/Accessories/AsgardsValor.cs index ca086946d4..a0e1bd0fd4 100644 --- a/Items/Accessories/AsgardsValor.cs +++ b/Items/Accessories/AsgardsValor.cs @@ -49,6 +49,7 @@ namespace CalamityMod.Items.Accessories player.buffImmune[BuffID.Silenced] = true; player.buffImmune[BuffID.Cursed] = true; player.buffImmune[BuffID.Darkness] = true; + player.buffImmune[BuffID.WindPushed] = true; player.statLifeMax2 += 20; if (Collision.DrownCollision(player.position, player.width, player.height, player.gravDir)) { player.statDefense += 16; } diff --git a/Items/Accessories/Calamity.cs b/Items/Accessories/Calamity.cs new file mode 100644 index 0000000000..d96bc93ed9 --- /dev/null +++ b/Items/Accessories/Calamity.cs @@ -0,0 +1,39 @@ +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class Calamity : ModItem + { + public const float MaxNPCSpeed = 5f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Calamity"); + Tooltip.SetDefault("Lights your mouse ablaze with a brimstone fire and causes a flaming aura to appear around it\n" + + "Enemies near the aura take immense damage and are inflicted with Vulnerability Hex\n" + + "The mouse fire effect can be shown without the aura and damage effects by putting this item in a vanity slot"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 4)); + } + + public override void SetDefaults() + { + item.width = 44; + item.height = 108; + item.rare = ItemRarityID.Purple; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.expert = true; + item.vanity = true; + item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.Calamity().blazingMouseDamageEffects = true; + player.Calamity().ableToDrawBlazingMouse = true; + } + + public override void UpdateEquip(Player player) => player.Calamity().ableToDrawBlazingMouse = true; + } +} diff --git a/Items/Accessories/Calamity.png b/Items/Accessories/Calamity.png new file mode 100644 index 0000000000..f4f939e40b Binary files /dev/null and b/Items/Accessories/Calamity.png differ diff --git a/Items/Accessories/CounterScarf.cs b/Items/Accessories/CounterScarf.cs index 18080d81f2..8130cd6267 100644 --- a/Items/Accessories/CounterScarf.cs +++ b/Items/Accessories/CounterScarf.cs @@ -11,9 +11,8 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Counter Scarf"); - Tooltip.SetDefault("True melee strikes deal 15% more damage\n" + + Tooltip.SetDefault("True melee strikes deal 10% more damage\n" + "Grants the ability to dash; dashing into an attack will cause you to dodge it\n" + - "After a dodge you will be granted a buff to all damage, melee speed, and all crit chance for a short time\n" + "After a successful dodge you must wait 15 seconds before you can dodge again\n" + "This cooldown will be twice as long if you have Chaos State\n" + "While on cooldown, Chaos State will last twice as long"); diff --git a/Items/Accessories/EldritchSoulArtifact.cs b/Items/Accessories/EldritchSoulArtifact.cs index 895edb0f2e..23e67b95ab 100644 --- a/Items/Accessories/EldritchSoulArtifact.cs +++ b/Items/Accessories/EldritchSoulArtifact.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.width = 28; - item.height = 28; + item.width = 64; + item.height = 58; item.accessory = true; item.value = CalamityGlobalItem.Rarity11BuyPrice; item.rare = ItemRarityID.Purple; diff --git a/Items/Accessories/EldritchSoulArtifact.png b/Items/Accessories/EldritchSoulArtifact.png index 0fc8022c9d..c872eb32d5 100644 Binary files a/Items/Accessories/EldritchSoulArtifact.png and b/Items/Accessories/EldritchSoulArtifact.png differ diff --git a/Items/Accessories/ElectriciansGlove.cs b/Items/Accessories/ElectriciansGlove.cs index 57f85e9f05..d9d0f4dc16 100644 --- a/Items/Accessories/ElectriciansGlove.cs +++ b/Items/Accessories/ElectriciansGlove.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Electrician's Glove"); Tooltip.SetDefault(@"Stealth strikes summon sparks on enemy hits -Stealth strikes also have +30 armor penetration, deal 10% more damage, and heal for 1 HP"); +Stealth strikes also have +20 armor penetration, deal 10% more damage, and heal for 1 HP"); } public override void SetDefaults() diff --git a/Items/Accessories/EvasionScarf.cs b/Items/Accessories/EvasionScarf.cs index fbebe616b3..c6a06dc16d 100644 --- a/Items/Accessories/EvasionScarf.cs +++ b/Items/Accessories/EvasionScarf.cs @@ -11,9 +11,8 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Evasion Scarf"); - Tooltip.SetDefault("True melee strikes deal 25% more damage\n" + + Tooltip.SetDefault("True melee strikes deal 15% more damage\n" + "Grants the ability to dash; dashing into an attack will cause you to dodge it\n" + - "After a dodge you will be granted a buff to all damage, melee speed, and all crit chance for a short time\n" + "After a successful dodge you must wait 13 seconds before you can dodge again\n" + "This cooldown will be 50 percent longer if you have Chaos State\n" + "While on cooldown, Chaos State will be 50 percent longer"); diff --git a/Items/Accessories/FrigidBulwark.cs b/Items/Accessories/FrigidBulwark.cs index b0fbdce54f..5fb817fe84 100644 --- a/Items/Accessories/FrigidBulwark.cs +++ b/Items/Accessories/FrigidBulwark.cs @@ -22,8 +22,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.width = 38; - item.height = 44; + item.width = 34; + item.height = 40; item.value = CalamityGlobalItem.Rarity7BuyPrice; item.rare = ItemRarityID.Lime; item.defense = 8; diff --git a/Items/Accessories/FrigidBulwark.png b/Items/Accessories/FrigidBulwark.png index 63f44d9187..a4c3edc11b 100644 Binary files a/Items/Accessories/FrigidBulwark.png and b/Items/Accessories/FrigidBulwark.png differ diff --git a/Items/Accessories/GiantShell.cs b/Items/Accessories/GiantShell.cs index dc7e4c31c8..6fa7e98690 100644 --- a/Items/Accessories/GiantShell.cs +++ b/Items/Accessories/GiantShell.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { item.defense = 6; - item.width = 20; - item.height = 24; + item.width = 30; + item.height = 28; item.value = CalamityGlobalItem.Rarity1BuyPrice; item.rare = ItemRarityID.Blue; item.accessory = true; diff --git a/Items/Accessories/GiantShell.png b/Items/Accessories/GiantShell.png index b5efb638cd..1e3e44ac38 100644 Binary files a/Items/Accessories/GiantShell.png and b/Items/Accessories/GiantShell.png differ diff --git a/Items/Accessories/GravistarSabaton.cs b/Items/Accessories/GravistarSabaton.cs index b7ea4a4afe..5d72a08f37 100644 --- a/Items/Accessories/GravistarSabaton.cs +++ b/Items/Accessories/GravistarSabaton.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Gravistar Sabaton"); Tooltip.SetDefault("Tap the DOWN key to increase your fall speed for 5 seconds\n" + - "This has a 8 second cooldown\n" + + "This has an 8 second cooldown\n" + "Striking the ground with increased fall speed will cause an astral explosion"); } diff --git a/Items/Accessories/MoonstoneCrown.cs b/Items/Accessories/MoonstoneCrown.cs index 0f0b4f89c7..eb509e1d5b 100644 --- a/Items/Accessories/MoonstoneCrown.cs +++ b/Items/Accessories/MoonstoneCrown.cs @@ -8,6 +8,9 @@ namespace CalamityMod.Items.Accessories { public class MoonstoneCrown : ModItem { + // Base damage of lunar flares on stealth strikes. Increased by rogue damage stats, but not stealth damage. + internal const int BaseDamage = 85; + public override void SetStaticDefaults() { DisplayName.SetDefault("Moonstone Crown"); @@ -20,9 +23,9 @@ namespace CalamityMod.Items.Accessories { item.width = 46; item.height = 40; - 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/Nucleogenesis.cs b/Items/Accessories/Nucleogenesis.cs index de10a924fe..91161a160a 100644 --- a/Items/Accessories/Nucleogenesis.cs +++ b/Items/Accessories/Nucleogenesis.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.nucleogenesis = true; modPlayer.shadowMinions = true; //shadowflame - modPlayer.tearMinions = true; //temporal sadness + modPlayer.holyMinions = true; //holy flames modPlayer.voltaicJelly = true; //electrified modPlayer.starTaintedGenerator = true; //astral infection and irradiated player.minionKB += 3f; diff --git a/Items/Accessories/ProfanedSoulCrystal.cs b/Items/Accessories/ProfanedSoulCrystal.cs index a72cf2a678..898cea7fce 100644 --- a/Items/Accessories/ProfanedSoulCrystal.cs +++ b/Items/Accessories/ProfanedSoulCrystal.cs @@ -156,7 +156,7 @@ namespace CalamityMod.Items.Accessories { Vector2 perturbedspeed = new Vector2(correctedVelocity.X, correctedVelocity.Y + Main.rand.Next(-3, 4)).RotatedBy(MathHelper.ToRadians(spread)); - Projectile.NewProjectile(player.Center.X, player.Center.Y - 10, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), (int)((shouldNerf ? 350 : 700) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f); + Projectile.NewProjectile(player.Center.X, player.Center.Y - 10, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), (int)((shouldNerf ? 175 : 350) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f); spread -= Main.rand.Next(2, 4); Main.PlaySound(SoundID.Item20, player.Center); } @@ -164,7 +164,7 @@ namespace CalamityMod.Items.Accessories } else { - Projectile.NewProjectile(player.Center, correctedVelocity * 6.9f, ModContent.ProjectileType(), (int)((shouldNerf ? 250 : 500) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f, 1f); + Projectile.NewProjectile(player.Center, correctedVelocity * 6.9f, ModContent.ProjectileType(), (int)((shouldNerf ? 125 : 250) * player.MinionDamage()), 1f, player.whoAmI, Main.rand.NextBool(player.Calamity().profanedSoulWeaponUsage == 4 ? 5 : 7) ? 1f : 0f, 1f); Main.PlaySound(SoundID.Item20, player.Center); } @@ -181,7 +181,7 @@ namespace CalamityMod.Items.Accessories bool isSmallBoomer = Main.rand.NextDouble() <= (enrage ? 0.2 : 0.3); // 20% chance if enraged, else 30% This is intentional due to literally doubling the amount of projectiles fired. bool isThiccBoomer = isSmallBoomer && Main.rand.NextDouble() <= 0.05; // 5% int projType = isSmallBoomer ? isThiccBoomer ? 1 : 2 : 3; - int dam = (int)((shouldNerf ? 200 : 400) * player.MinionDamage()); + int dam = (int)((shouldNerf ? 100 : 200) * player.MinionDamage()); switch (projType) { case 1: //big boomer @@ -222,7 +222,7 @@ namespace CalamityMod.Items.Accessories player.statMana -= manaCost; correctedVelocity *= 25f; Main.PlaySound(SoundID.Item20, player.Center); - int dam = (int)((shouldNerf ? 900 : 1800) * player.MinionDamage()); + int dam = (int)((shouldNerf ? 450 : 900) * player.MinionDamage()); if (player.HasBuff(BuffID.ManaSickness)) { int sickPenalty = (int)(dam * (0.05f * ((player.buffTime[player.FindBuffIndex(BuffID.ManaSickness)] + 60) / 60))); @@ -248,7 +248,7 @@ namespace CalamityMod.Items.Accessories for (float i = 0; i < crystalCount; i++) { float angle = MathHelper.TwoPi / crystalCount * i; - int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 175 : 350) * player.MinionDamage()), 1f, player.whoAmI, 0f, 0f); + int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 88 : 176) * player.MinionDamage()), 1f, player.whoAmI, 0f, 0f); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].Calamity().forceMinion = true; Main.PlaySound(SoundID.Item20, player.Center); @@ -258,7 +258,7 @@ namespace CalamityMod.Items.Accessories else if (player.Calamity().profanedSoulWeaponUsage % (enrage ? 5 : 10) == 0) { float angle = MathHelper.TwoPi / (enrage ? 9 : 18) * (player.Calamity().profanedSoulWeaponUsage / (enrage ? 1 : 10)); - int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 220 : 440) * player.MinionDamage()), 1f, player.whoAmI, 1f, 0f); + int proj = Projectile.NewProjectile(player.Center, angle.ToRotationVector2() * 8f, ModContent.ProjectileType(), (int)((shouldNerf ? 110 : 220) * player.MinionDamage()), 1f, player.whoAmI, 1f, 0f); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].Calamity().forceMinion = true; Main.PlaySound(SoundID.Item20, player.Center); diff --git a/Items/Accessories/RampartofDeities.cs b/Items/Accessories/RampartofDeities.cs index d9d0b4fc39..1f522c8728 100644 --- a/Items/Accessories/RampartofDeities.cs +++ b/Items/Accessories/RampartofDeities.cs @@ -8,6 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { + [AutoloadEquip(EquipType.Shield)] public class RampartofDeities : ModItem { public override void SetStaticDefaults() @@ -26,8 +27,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - item.width = 38; - item.height = 44; + item.width = 64; + item.height = 62; item.value = CalamityGlobalItem.Rarity14BuyPrice; item.defense = 12; item.accessory = true; diff --git a/Items/Accessories/RampartofDeities.png b/Items/Accessories/RampartofDeities.png index 115623e6c8..a9edc4ae64 100644 Binary files a/Items/Accessories/RampartofDeities.png and b/Items/Accessories/RampartofDeities.png differ diff --git a/Items/Accessories/RampartofDeities_Shield.png b/Items/Accessories/RampartofDeities_Shield.png new file mode 100644 index 0000000000..9c9359a5e7 Binary files /dev/null and b/Items/Accessories/RampartofDeities_Shield.png differ diff --git a/Items/Accessories/RottenDogtooth.cs b/Items/Accessories/RottenDogtooth.cs new file mode 100644 index 0000000000..fb51bb1b1f --- /dev/null +++ b/Items/Accessories/RottenDogtooth.cs @@ -0,0 +1,34 @@ +using CalamityMod.CalPlayer; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class RottenDogtooth : ModItem + { + internal const int ArmorCrunchDebuffTime = 180; + internal const float StealthStrikeDamageMultiplier = 0.1f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rotten Dogtooth"); + Tooltip.SetDefault($"Makes Stealth strikes inflict Armor Crunch, deal {(int)(StealthStrikeDamageMultiplier * 100)}% more damage and cost 1 less unit of stealth."); + } + + public override void SetDefaults() + { + item.width = 14; + item.height = 22; + item.value = CalamityGlobalItem.Rarity1BuyPrice; + item.rare = ItemRarityID.Blue; + item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.Calamity().rottenDogTooth = true; + player.Calamity().flatStealthLossReduction++; + } + } +} diff --git a/Items/Accessories/RottenDogtooth.png b/Items/Accessories/RottenDogtooth.png new file mode 100644 index 0000000000..8a542b03b6 Binary files /dev/null and b/Items/Accessories/RottenDogtooth.png differ diff --git a/Items/Accessories/StatisBlessing.cs b/Items/Accessories/StatisBlessing.cs index e3b5baec9b..a2476b5cd2 100644 --- a/Items/Accessories/StatisBlessing.cs +++ b/Items/Accessories/StatisBlessing.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Statis' Blessing"); Tooltip.SetDefault("Increased max minions by 2 and 10% increased minion damage\n" + "Increased minion knockback\n" + - "Minions cause enemies to cry on hit"); + "Minions inflict holy flames on hit"); } public override void SetDefaults() @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { CalamityPlayer modPlayer = player.Calamity(); - modPlayer.tearMinions = true; + modPlayer.holyMinions = true; player.minionKB += 2.5f; player.minionDamage += 0.1f; } diff --git a/Items/Accessories/StatisCurse.cs b/Items/Accessories/StatisCurse.cs index 2040e34e93..cb76aae66c 100644 --- a/Items/Accessories/StatisCurse.cs +++ b/Items/Accessories/StatisCurse.cs @@ -15,8 +15,7 @@ namespace CalamityMod.Items.Accessories Tooltip.SetDefault("Increases max minions by 3, does not stack with downgrades\n" + "10% increased minion damage\n" + "Increased minion knockback\n" + - "Grants shadowflame powers to all minions\n" + - "Minions make enemies cry on hit"); + "Minions inflict holy flames and shadowflames on hit"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(8, 4)); } @@ -33,7 +32,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.shadowMinions = true; - modPlayer.tearMinions = true; + modPlayer.holyMinions = true; player.minionKB += 2.75f; player.minionDamage += 0.1f; } diff --git a/Items/Ammo/ArcticArrow.cs b/Items/Ammo/ArcticArrow.cs index 6c58499897..04a923661c 100644 --- a/Items/Ammo/ArcticArrow.cs +++ b/Items/Ammo/ArcticArrow.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 16; + item.damage = 18; item.ranged = true; item.width = 22; item.height = 36; diff --git a/Items/Ammo/BloodfireArrow.cs b/Items/Ammo/BloodfireArrow.cs index 5691cc88d9..303fb49dda 100644 --- a/Items/Ammo/BloodfireArrow.cs +++ b/Items/Ammo/BloodfireArrow.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 26; + item.damage = 29; item.ranged = true; item.width = 14; item.height = 36; diff --git a/Items/Ammo/ElysianArrow.cs b/Items/Ammo/ElysianArrow.cs index f78dee1983..cf2930ecdb 100644 --- a/Items/Ammo/ElysianArrow.cs +++ b/Items/Ammo/ElysianArrow.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 18; + item.damage = 20; item.ranged = true; item.width = 22; item.height = 36; diff --git a/Items/Ammo/IcicleArrow.cs b/Items/Ammo/IcicleArrow.cs index 1373462cb4..ac17b39ed5 100644 --- a/Items/Ammo/IcicleArrow.cs +++ b/Items/Ammo/IcicleArrow.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 14; + item.damage = 15; item.ranged = true; item.consumable = true; item.width = 18; diff --git a/Items/Ammo/NapalmArrow.cs b/Items/Ammo/NapalmArrow.cs index a8fb3b28e6..032e8f60f5 100644 --- a/Items/Ammo/NapalmArrow.cs +++ b/Items/Ammo/NapalmArrow.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 13; + item.damage = 14; item.ranged = true; item.width = 22; item.height = 36; diff --git a/Items/Ammo/TerraArrow.cs b/Items/Ammo/TerraArrow.cs index 8d50387403..12da4f9279 100644 --- a/Items/Ammo/TerraArrow.cs +++ b/Items/Ammo/TerraArrow.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 14; + item.damage = 15; item.ranged = true; item.width = 22; item.height = 36; diff --git a/Items/Ammo/VanquisherArrow.cs b/Items/Ammo/VanquisherArrow.cs index 448e0a2f8a..c3a3efd966 100644 --- a/Items/Ammo/VanquisherArrow.cs +++ b/Items/Ammo/VanquisherArrow.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -19,7 +18,7 @@ namespace CalamityMod.Items.Ammo public override void SetDefaults() { - item.damage = 22; + item.damage = 24; item.ranged = true; item.width = 22; item.height = 46; diff --git a/Items/Armor/AuricTeslaHelm.cs b/Items/Armor/AuricTeslaHelm.cs index 2e222ea4e7..de05c1cd72 100644 --- a/Items/Armor/AuricTeslaHelm.cs +++ b/Items/Armor/AuricTeslaHelm.cs @@ -41,8 +41,7 @@ namespace CalamityMod.Items.Armor player.setBonus = "Melee Tarragon, Bloodflare and God Slayer effects\n" + "Enemies are more likely to target you\n" + "All projectiles spawn healing auric orbs on enemy hits\n" + - "Max run speed and acceleration boosted by 10%\n" + - "Your melee damage is multiplied based on how high your HP is; at full HP this effect is at max"; + "Max run speed and acceleration boosted by 10%"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.tarraSet = true; modPlayer.tarraMelee = true; @@ -61,7 +60,10 @@ namespace CalamityMod.Items.Armor player.statDefense += 30; player.lifeRegen += 10; } - } + + if (!modPlayer.godSlayerCooldown && modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/AuricTeslaHoodedFacemask.cs b/Items/Armor/AuricTeslaHoodedFacemask.cs index 96022515e4..03e52fe7b2 100644 --- a/Items/Armor/AuricTeslaHoodedFacemask.cs +++ b/Items/Armor/AuricTeslaHoodedFacemask.cs @@ -58,7 +58,10 @@ namespace CalamityMod.Items.Armor player.statDefense += 30; player.lifeRegen += 10; } - } + + if (!modPlayer.godSlayerCooldown && modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/AuricTeslaPlumedHelm.cs b/Items/Armor/AuricTeslaPlumedHelm.cs index 0003a0a62d..0975186372 100644 --- a/Items/Armor/AuricTeslaPlumedHelm.cs +++ b/Items/Armor/AuricTeslaPlumedHelm.cs @@ -41,7 +41,6 @@ namespace CalamityMod.Items.Armor player.setBonus = "Rogue Tarragon, Bloodflare and God Slayer armor effects\n" + "All projectiles spawn healing auric orbs on enemy hits\n" + "Max run speed and acceleration boosted by 10%\n" + - "Rogue weapon critical strikes will do 1.25 times damage while you are above 50% HP\n" + "Rogue stealth builds while not attacking and slower while moving, up to a max of 130\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" + @@ -65,7 +64,10 @@ namespace CalamityMod.Items.Armor player.statDefense += 30; player.lifeRegen += 10; } - } + + if (!modPlayer.godSlayerCooldown && modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/AuricTeslaSpaceHelmet.cs b/Items/Armor/AuricTeslaSpaceHelmet.cs index cf084dc02c..59c452eddd 100644 --- a/Items/Armor/AuricTeslaSpaceHelmet.cs +++ b/Items/Armor/AuricTeslaSpaceHelmet.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Armor player.setBonus = "Summoner Tarragon, Bloodflare and Silva armor effects\n" + "All projectiles spawn healing auric orbs on enemy hits\n" + "Max run speed and acceleration boosted by 10%\n" + - "+8 max minions and 120% increased minion damage"; + "+8 max minions and 90% increased minion damage"; CalamityPlayer modPlayer = player.Calamity(); modPlayer.tarraSet = true; modPlayer.tarraSummon = true; @@ -58,7 +58,7 @@ namespace CalamityMod.Items.Armor player.lavaMax += 240; player.ignoreWater = true; player.crimsonRegen = true; - player.minionDamage += 1.2f; + player.minionDamage += 0.9f; player.maxMinions += 8; if (player.lavaWet) { diff --git a/Items/Armor/GodSlayerHelm.cs b/Items/Armor/GodSlayerHelm.cs index 8c51094372..b269d4e2a7 100644 --- a/Items/Armor/GodSlayerHelm.cs +++ b/Items/Armor/GodSlayerHelm.cs @@ -39,16 +39,22 @@ namespace CalamityMod.Items.Armor CalamityPlayer modPlayer = player.Calamity(); modPlayer.godSlayer = true; modPlayer.godSlayerDamage = true; - player.setBonus = "You will survive fatal damage and will be healed 150 HP if an attack would have killed you\n" + - "This effect can only occur once every 45 seconds\n" + - "While the cooldown for this effect is active all life regen is halved\n" + + string hotkey = CalamityMod.GodSlayerDashHotKey.TooltipHotkeyString(); + player.setBonus = "Allows you to dash for an immense distance in 8 directions\n" + + "Press " + hotkey + " while holding down the movement keys in the direction you want to dash\n" + + "Enemies you dash through take massive damage\n" + + "During the dash you are immune to most debuffs\n" + + "The dash has a 15 second cooldown\n" + "Enemies are more likely to target you\n" + "Taking over 80 damage in one hit will cause you to release a swarm of high-damage god killer darts\n" + "Enemies take a lot of damage when they hit you\n" + "An attack that would deal 80 damage or less will have its damage reduced to 1"; player.thorns += 2.5f; player.aggro += 1000; - } + + if (!modPlayer.godSlayerCooldown && modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/GodSlayerHelmet.cs b/Items/Armor/GodSlayerHelmet.cs index edcd33d805..62b8c32f92 100644 --- a/Items/Armor/GodSlayerHelmet.cs +++ b/Items/Armor/GodSlayerHelmet.cs @@ -39,10 +39,16 @@ namespace CalamityMod.Items.Armor CalamityPlayer modPlayer = player.Calamity(); modPlayer.godSlayer = true; modPlayer.godSlayerRanged = true; - player.setBonus = "You will survive fatal damage and will be healed 150 HP if an attack would have killed you\n" + - "This effect can only occur once every 45 seconds\n" + - "While the cooldown for this effect is active all life regen is halved\n" + - "You fire a god killer shrapnel round while firing ranged weapons every 2.5 seconds"; + string hotkey = CalamityMod.GodSlayerDashHotKey.TooltipHotkeyString(); + player.setBonus = "Allows you to dash for an immense distance in 8 directions\n" + + "Press " + hotkey + " while holding down the movement keys in the direction you want to dash\n" + + "Enemies you dash through take massive damage\n" + + "During the dash you are immune to most debuffs\n" + + "The dash has a 15 second cooldown\n" + + "You fire a god killer shrapnel round while firing ranged weapons every 2.5 seconds"; + + if (!modPlayer.godSlayerCooldown && modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/GodSlayerMask.cs b/Items/Armor/GodSlayerMask.cs index 054e8e975b..4a2c915cdd 100644 --- a/Items/Armor/GodSlayerMask.cs +++ b/Items/Armor/GodSlayerMask.cs @@ -41,16 +41,22 @@ namespace CalamityMod.Items.Armor modPlayer.godSlayerThrowing = true; modPlayer.rogueStealthMax += 1.2f; modPlayer.wearingRogueArmor = true; - player.setBonus = "You will survive fatal damage and will be healed 150 HP if an attack would have killed you\n" + - "This effect can only occur once every 45 seconds\n" + - "While the cooldown for this effect is active all life regen is halved\n" + - "While at full HP all of your rogue stats are boosted by 10%\n" + + string hotkey = CalamityMod.GodSlayerDashHotKey.TooltipHotkeyString(); + player.setBonus = "Allows you to dash for an immense distance in 8 directions\n" + + "Press " + hotkey + " while holding down the movement keys in the direction you want to dash\n" + + "Enemies you dash through take massive damage\n" + + "During the dash you are immune to most debuffs\n" + + "The dash has a 15 second cooldown\n" + + "While at full HP all of your rogue stats are boosted by 10%\n" + "If you take over 80 damage in one hit you will be given extra immunity frames\n" + "Rogue stealth builds while not attacking and slower while moving, up to a max of 120\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"; - } + + if (!modPlayer.godSlayerCooldown && modPlayer.godSlayerDashHotKeyPressed) + modPlayer.dashMod = 9; + } public override void UpdateEquip(Player player) { diff --git a/Items/Armor/SilvaHelmet.cs b/Items/Armor/SilvaHelmet.cs index 2b27be10b0..9f318c27bc 100644 --- a/Items/Armor/SilvaHelmet.cs +++ b/Items/Armor/SilvaHelmet.cs @@ -45,12 +45,9 @@ namespace CalamityMod.Items.Armor player.setBonus = "75% increased minion damage and +5 max minions\n" + "All projectiles spawn healing leaf orbs on enemy hits\n" + "Max run speed and acceleration boosted by 5%\n" + - "If you are reduced to 1 HP you will not die from any further damage for 10 seconds\n" + - "If you get reduced to 1 HP again while this effect is active you will lose 100 max life\n" + - "This effect only triggers once per life and if you are reduced to 400 max life the invincibility effect will stop\n" + - "Your max life will return to normal if you die\n" + - "Summons an ancient leaf prism to blast your enemies with life energy\n" + - "After the silva invulnerability time your minions will deal 10% more damage"; + "If you are reduced to 1 HP you will not die from any further damage for 8 seconds\n" + + "This effect only triggers once per life\n" + + "Summons an ancient leaf prism to blast your enemies with life energy"; if (player.whoAmI == Main.myPlayer) { if (player.FindBuffIndex(ModContent.BuffType()) == -1) diff --git a/Items/Armor/SilvaMaskedCap.cs b/Items/Armor/SilvaMaskedCap.cs index a13cd4a36e..536bc0e960 100644 --- a/Items/Armor/SilvaMaskedCap.cs +++ b/Items/Armor/SilvaMaskedCap.cs @@ -44,12 +44,9 @@ namespace CalamityMod.Items.Armor modPlayer.silvaMage = true; player.setBonus = "All projectiles spawn healing leaf orbs on enemy hits\n" + "Max run speed and acceleration boosted by 5%\n" + - "If you are reduced to 1 HP you will not die from any further damage for 10 seconds\n" + - "If you get reduced to 1 HP again while this effect is active you will lose 100 max life\n" + - "This effect only triggers once per life and if you are reduced to 400 max life the invincibility effect will stop\n" + - "Your max life will return to normal if you die\n" + - "Magic projectiles have a 10% chance to cause a massive explosion on enemy hits\n" + - "After the silva invulnerability time your magic weapons will do 10% more damage"; + "If you are reduced to 1 HP you will not die from any further damage for 8 seconds\n" + + "This effect only triggers once per life\n" + + "Magic projectiles have a 10% chance to cause a massive explosion on enemy hits"; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/TarragonHornedHelm.cs b/Items/Armor/TarragonHornedHelm.cs index f07b85d644..4417928680 100644 --- a/Items/Armor/TarragonHornedHelm.cs +++ b/Items/Armor/TarragonHornedHelm.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Armor DisplayName.SetDefault("Tarragon Horned Helm"); Tooltip.SetDefault("Temporary immunity to lava\n" + "Can move freely through liquids\n" + - "5% increased damage reduction"); + "5% increased damage reduction and minion damage"); } public override void SetDefaults() @@ -59,19 +59,20 @@ namespace CalamityMod.Items.Armor CalamityPlayer modPlayer = player.Calamity(); modPlayer.tarraSet = true; modPlayer.tarraSummon = true; - player.setBonus = "55% increased minion damage and +3 max minions\n" + + player.setBonus = "50% increased minion damage and +3 max minions\n" + "Reduces enemy spawn rates\n" + "Increased heart pickup range\n" + "Enemies have a chance to drop extra hearts on death\n" + "Summons a life aura around you that damages nearby enemies"; - player.minionDamage += 0.55f; + player.minionDamage += 0.5f; player.maxMinions += 3; } public override void UpdateEquip(Player player) { player.endurance += 0.05f; - player.lavaMax += 240; + player.minionDamage += 0.05f; + player.lavaMax += 240; player.ignoreWater = true; } diff --git a/Items/Armor/TarragonVisage.cs b/Items/Armor/TarragonVisage.cs index acf2a59ff7..f236ffe489 100644 --- a/Items/Armor/TarragonVisage.cs +++ b/Items/Armor/TarragonVisage.cs @@ -63,8 +63,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 critical strikes will cause an explosion of leaves\n" + - "Ranged projectiles have a chance to split into life energy on death by hitting an enemy"; + "Ranged projectiles split into homing life energy and leaves on death"; } public override void UpdateEquip(Player player) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index ce6eefdcf8..88221b654d 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -60,9 +60,21 @@ namespace CalamityMod.Items public bool devItem = false; public bool challengeDrop = false; - // See RogueWeapon.cs for rogue modifier shit - #region Modifiers - public CalamityGlobalItem() + public static readonly Color[] ExoPalette = new Color[] + { + new Color(250, 255, 112), + new Color(211, 235, 108), + new Color(166, 240, 105), + new Color(105, 240, 220), + new Color(64, 130, 145), + new Color(145, 96, 145), + new Color(242, 112, 73), + new Color(199, 62, 62), + }; + + // See RogueWeapon.cs for rogue modifier shit + #region Modifiers + public CalamityGlobalItem() { StealthGenBonus = 1f; } @@ -215,6 +227,8 @@ namespace CalamityMod.Items } if (item.type == ItemID.StarCannon) item.UseSound = null; + if (item.type == ItemID.CelestialSigil) + item.consumable = false; } #endregion @@ -810,7 +824,15 @@ namespace CalamityMod.Items #region Modify Weapon Damage public override void ModifyWeaponDamage(Item item, Player player, ref float add, ref float mult, ref float flat) { - if (item.type < ItemID.Count) + // Nerf yoyo glove and bag because it's bad and stupid and dumb and bad. + if (player.yoyoGlove && ItemID.Sets.Yoyo[item.type]) + mult *= 0.66f; + + // Nerf archery potion damage buff from 1.2x to 1.05x. + if (item.useAmmo == AmmoID.Arrow && player.archery) + mult *= 0.875f; + + if (item.type < ItemID.Count) return; // Summon weapons specifically do not have their damage affected by charge. They still require charge to function however. @@ -1487,7 +1509,7 @@ namespace CalamityMod.Items public override void HorizontalWingSpeeds(Item item, Player player, ref float speed, ref float acceleration) { CalamityPlayer modPlayer = player.Calamity(); - float moveSpeedBoost = modPlayer.moveSpeedStat * 0.0015f; + float moveSpeedBoost = modPlayer.moveSpeedStat * 0.001f; float flightSpeedMult = 1f + (modPlayer.soaring ? 0.1f : 0f) + diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index e356723fb4..43f918915b 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -82,7 +82,7 @@ namespace CalamityMod.Items { // Apply standard post-ML rarities to the item's color first. Color? standardRarityColor = CalamityUtils.GetRarityColor(customRarity); - if (standardRarityColor.HasValue) + if (!item.expert && standardRarityColor.HasValue) nameLine.overrideColor = standardRarityColor.Value; #region Uniquely Colored Developer Items @@ -124,6 +124,15 @@ namespace CalamityMod.Items nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(154, 255, 151), new Color(228, 151, 255), 4f); if (item.type == ModContent.ItemType() || item.type == ModContent.ItemType() || item.type == ModContent.ItemType()) nameLine.overrideColor = CalamityUtils.ColorSwap(new Color(255, 132, 22), new Color(221, 85, 7), 4f); + if (item.type == ModContent.ItemType()) + { + nameLine.overrideColor = CalamityUtils.MulticolorLerp(Main.GlobalTime / 2f % 1f, new Color[] + { + new Color(255, 196, 55), + new Color(255, 231, 107), + new Color(255, 254, 243) + }); + } // TODO -- for cleanliness, ALL color math should either be a one-line color swap or inside the item's own file // The items that currently violate this are all below: @@ -255,6 +264,10 @@ namespace CalamityMod.Items if (item.type == ItemID.RodofDiscord) EditTooltipByNum(0, (line) => line.text += "\nTeleportation is disabled while Chaos State is active"); + // Indicate that the Ankh Shield provides sandstorm wind push immunity + if (item.type == ItemID.AnkhShield) + EditTooltipByNum(1, (line) => line.text += ", including Mighty Wind"); + // Water removing items cannot be used in the Abyss string noAbyssLine = "\nCannot be used in the Abyss"; if (item.type == ItemID.SuperAbsorbantSponge) @@ -279,6 +292,10 @@ namespace CalamityMod.Items EditTooltipByNum(0, (line) => line.text += immunityLine); } + // Nerfed Archery Potion tooltip + if (item.type == ItemID.ArcheryPotion) + EditTooltipByNum(0, (line) => line.text = "20% increased arrow speed and 1.05x arrow damage"); + // Hand Warmer provides Death Mode cold protection and has a side bonus with Eskimo armor if (item.type == ItemID.HandWarmer) { @@ -309,7 +326,7 @@ namespace CalamityMod.Items // Black Belt and Master Ninja Gear have guaranteed dodges on a 60 second cooldown. #region Dodging Belt Tooltips string beltDodgeLine = "Grants the ability to dodge attacks\n" + - $"The dodge has a {CalamityPlayer.BeltDodgeCooldown} second cooldown which is shared with all other dodges and reflects"; + $"The dodge has a {CalamityPlayer.BeltDodgeCooldown / 60} second cooldown which is shared with all other dodges and reflects"; if (item.type == ItemID.BlackBelt) EditTooltipByNum(0, (line) => line.text = beltDodgeLine); if (item.type == ItemID.MasterNinjaGear) diff --git a/Items/Materials/BloodSample.cs b/Items/Materials/BloodSample.cs index 01b9f526d8..b8e413188f 100644 --- a/Items/Materials/BloodSample.cs +++ b/Items/Materials/BloodSample.cs @@ -13,8 +13,8 @@ namespace CalamityMod.Items.Materials public override void SetDefaults() { - item.width = 16; - item.height = 22; + item.width = 26; + item.height = 34; item.maxStack = 999; item.value = Item.buyPrice(0, 0, 50, 0); item.rare = ItemRarityID.Green; diff --git a/Items/Materials/BloodSample.png b/Items/Materials/BloodSample.png index 52a28ee266..421a652516 100644 Binary files a/Items/Materials/BloodSample.png and b/Items/Materials/BloodSample.png differ diff --git a/Items/Materials/RuinousSoul.cs b/Items/Materials/RuinousSoul.cs index 2f7606bafe..e5c7030d4a 100644 --- a/Items/Materials/RuinousSoul.cs +++ b/Items/Materials/RuinousSoul.cs @@ -1,4 +1,5 @@ using Terraria; +using Terraria.DataStructures; using Terraria.ModLoader; namespace CalamityMod.Items.Materials @@ -9,12 +10,13 @@ namespace CalamityMod.Items.Materials { DisplayName.SetDefault("Ruinous Soul"); Tooltip.SetDefault("A shard of the distant past"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 6)); } public override void SetDefaults() { - item.width = 20; - item.height = 20; + item.width = 26; + item.height = 42; item.maxStack = 999; item.value = Item.buyPrice(0, 7, 0, 0); item.Calamity().customRarity = CalamityRarity.PureGreen; diff --git a/Items/Materials/RuinousSoul.png b/Items/Materials/RuinousSoul.png index 04dec2f3de..2f4f6d2463 100644 Binary files a/Items/Materials/RuinousSoul.png and b/Items/Materials/RuinousSoul.png differ diff --git a/Items/Materials/StormlionMandible.cs b/Items/Materials/StormlionMandible.cs index 99fd67a72f..45f3b367fd 100644 --- a/Items/Materials/StormlionMandible.cs +++ b/Items/Materials/StormlionMandible.cs @@ -10,13 +10,13 @@ namespace CalamityMod.Items.Materials public override void SetStaticDefaults() { DisplayName.SetDefault("Stormlion Mandible"); - Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 6)); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 8)); } public override void SetDefaults() { - item.width = 12; - item.height = 24; + item.width = 36; + item.height = 38; item.maxStack = 999; item.value = Item.sellPrice(silver: 1, copper: 40); item.rare = ItemRarityID.Blue; diff --git a/Items/Materials/StormlionMandible.png b/Items/Materials/StormlionMandible.png index 6a5f91d07d..4a248d6291 100644 Binary files a/Items/Materials/StormlionMandible.png and b/Items/Materials/StormlionMandible.png differ diff --git a/Items/Pets/LittleLight.cs b/Items/Pets/LittleLight.cs new file mode 100644 index 0000000000..e2e06f7d6b --- /dev/null +++ b/Items/Pets/LittleLight.cs @@ -0,0 +1,37 @@ +using CalamityMod.Buffs.Pets; +using CalamityMod.Projectiles.Pets; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Pets +{ + public class LittleLight : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Little Light"); + Tooltip.SetDefault("It's been looking for you for a long time.\n" + + "Summons a small construct that follows you and provides a great amount of light"); + } + + public override void SetDefaults() + { + item.CloneDefaults(ItemID.WispinaBottle); + item.UseSound = SoundID.Item83; + item.shoot = ModContent.ProjectileType(); + item.buffType = ModContent.BuffType(); + + item.value = Item.sellPrice(gold: 15); + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.PureGreen; + item.Calamity().donorItem = 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/LittleLight.png b/Items/Pets/LittleLight.png new file mode 100644 index 0000000000..1aa82dc885 Binary files /dev/null and b/Items/Pets/LittleLight.png differ diff --git a/Items/Placeables/SCalAltarItem.cs b/Items/Placeables/SCalAltarItem.cs new file mode 100644 index 0000000000..1d015749e5 --- /dev/null +++ b/Items/Placeables/SCalAltarItem.cs @@ -0,0 +1,45 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Tiles; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Placeables +{ + public class SCalAltarItem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Calamitous Altar"); + Tooltip.SetDefault("Death\n" + + "Allows you to summon Supreme Calamitas with Ashes of Calamity\n" + + "She creates a large square arena of blocks upon being summoned\n" + + "When she is summoned the arena will spawn around her with her at the center\n" + + "During the battle, heart pickups will heal half as much HP"); + } + + public override void SetDefaults() + { + item.createTile = ModContent.TileType(); + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 60; + item.height = 48; + item.maxStack = 999; + item.useStyle = ItemUseStyleID.SwingThrow; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Placeables/SCalAltarItem.png b/Items/Placeables/SCalAltarItem.png new file mode 100644 index 0000000000..c4bb03cb8b Binary files /dev/null and b/Items/Placeables/SCalAltarItem.png differ diff --git a/Items/Potions/Alcohol/CinnamonRoll.cs b/Items/Potions/Alcohol/CinnamonRoll.cs index ebb6761c37..f90441a393 100644 --- a/Items/Potions/Alcohol/CinnamonRoll.cs +++ b/Items/Potions/Alcohol/CinnamonRoll.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Potions.Alcohol { DisplayName.SetDefault("Cinnamon Roll"); Tooltip.SetDefault(@"A great-tasting cinnamon whiskey with a touch of cream soda -Boosts mana regeneration rate and all fire-based weapon damage by 15% +Boosts mana regeneration rate and multiplies all fire-based weapon damage by 1.1 Cursed flame, shadowflame, god slayer inferno, brimstone flame, and frostburn weapons will not receive this benefit The weapon must be more fire-related than anything else Reduces defense by 10%"); diff --git a/Items/Potions/Alcohol/EvergreenGin.cs b/Items/Potions/Alcohol/EvergreenGin.cs index ef479c97ce..234647eb09 100644 --- a/Items/Potions/Alcohol/EvergreenGin.cs +++ b/Items/Potions/Alcohol/EvergreenGin.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Potions.Alcohol { DisplayName.SetDefault("Evergreen Gin"); Tooltip.SetDefault(@"It tastes like a Christmas tree if you can imagine that -Boosts nature-based weapon damage by 15% and damage reduction by 5% +Multiplies nature-based weapon damage by 1.1 and increases damage reduction by 5% Reduces life regen by 1"); } diff --git a/Items/Potions/Alcohol/Fireball.cs b/Items/Potions/Alcohol/Fireball.cs index ab948129bd..749c870248 100644 --- a/Items/Potions/Alcohol/Fireball.cs +++ b/Items/Potions/Alcohol/Fireball.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Potions.Alcohol { DisplayName.SetDefault("Fireball"); Tooltip.SetDefault(@"A great-tasting cinnamon whiskey -Boosts all fire-based weapon damage by 10% +Multiplies all fire-based weapon damage by 1.05 Cursed flame, shadowflame, god slayer inferno, brimstone flame, and frostburn weapons will not receive this benefit The weapon must be more fire-related than anything else Reduces life regen by 1"); diff --git a/Items/Potions/Alcohol/OddMushroom.cs b/Items/Potions/Alcohol/OddMushroom.cs index 10bcb5b0d7..983d631458 100644 --- a/Items/Potions/Alcohol/OddMushroom.cs +++ b/Items/Potions/Alcohol/OddMushroom.cs @@ -10,7 +10,9 @@ namespace CalamityMod.Items.Potions.Alcohol public override void SetStaticDefaults() { DisplayName.SetDefault("Odd Mushroom"); - Tooltip.SetDefault("Trippy"); + Tooltip.SetDefault("Causes you to see many fake, vibrant copies of all nearby entities\n" + + "These visual effects may be nauseating or otherwise bad for some\n" + + "Trippy"); } public override void SetDefaults() diff --git a/Items/Potions/Alcohol/Screwdriver.cs b/Items/Potions/Alcohol/Screwdriver.cs index 59959d7b24..2848c8dd9a 100644 --- a/Items/Potions/Alcohol/Screwdriver.cs +++ b/Items/Potions/Alcohol/Screwdriver.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Potions.Alcohol { DisplayName.SetDefault("Screwdriver"); Tooltip.SetDefault(@"Do you have a screw loose? -Boosts piercing projectile damage by 10% +Multiplies piercing projectile damage by 1.05 Reduces life regen by 1"); } diff --git a/Items/Potions/DraconicElixir.cs b/Items/Potions/DraconicElixir.cs index e6df747ac1..e1bf89dabc 100644 --- a/Items/Potions/DraconicElixir.cs +++ b/Items/Potions/DraconicElixir.cs @@ -12,9 +12,8 @@ namespace CalamityMod.Items.Potions { DisplayName.SetDefault("Draconic Elixir"); Tooltip.SetDefault("Greatly increases wing flight time and speed and increases defense by 16\n" + - "God slayer revival heals you to half HP instead of 150 HP when triggered\n" + "Silva invincibility heals you to half HP when triggered\n" + - "If you trigger the above heals you cannot drink this potion again for 60 seconds and you gain 30 seconds of potion sickness"); + "If you trigger the above heal you cannot drink this potion again for 60 seconds and you gain 30 seconds of potion sickness"); } public override void SetDefaults() diff --git a/Items/SummonItems/EyeofExtinction.cs b/Items/SummonItems/EyeofExtinction.cs index f4d7bd38c3..a0c7b5f962 100644 --- a/Items/SummonItems/EyeofExtinction.cs +++ b/Items/SummonItems/EyeofExtinction.cs @@ -1,11 +1,5 @@ -using CalamityMod.Events; using CalamityMod.Items.Materials; -using CalamityMod.NPCs.SupremeCalamitas; -using CalamityMod.Tiles; using CalamityMod.Tiles.Furniture.CraftingStations; -using CalamityMod.World; -using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.SummonItems @@ -15,69 +9,21 @@ namespace CalamityMod.Items.SummonItems public override void SetStaticDefaults() { DisplayName.SetDefault("Eye of Extinction"); - Tooltip.SetDefault("Death\n" + - "Summons Supreme Calamitas\n" + - "Creates a large square arena of blocks around your player\n" + - "Your player is the CENTER of the arena so be sure to use this item in a good location\n" + - "During the battle, heart pickups will heal half as much HP\n" + - "Not consumable"); + Tooltip.SetDefault("Summons Supreme Calamitas at the altar but is not consumed"); } public override void SetDefaults() { - item.width = 40; - item.height = 40; - item.useAnimation = 45; - item.useTime = 45; - item.useStyle = ItemUseStyleID.HoldingUp; - item.consumable = false; + item.width = 54; + item.height = 42; item.Calamity().customRarity = CalamityRarity.Violet; } - public override bool CanUseItem(Player player) - { - return !NPC.AnyNPCs(ModContent.NPCType()) && !BossRushEvent.BossRushActive; - } - - public override bool UseItem(Player player) - { - int surface = (int)Main.worldSurface; - for (int i = 0; i < Main.maxTilesX; i++) - { - for (int j = 0; j < surface; j++) - { - if (Main.tile[i, j] != null) - { - if (Main.tile[i, j].type == ModContent.TileType()) - { - WorldGen.KillTile(i, j, false, false, false); - if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendTileSquare(-1, i, j, 1, TileChangeType.None); - } - else - { - WorldGen.SquareTileFrame(i, j, true); - } - } - } - } - } - - 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; - } - public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/SummonItems/RuneofCos.cs b/Items/SummonItems/RuneofCos.cs index eb02f595bd..64a37ea826 100644 --- a/Items/SummonItems/RuneofCos.cs +++ b/Items/SummonItems/RuneofCos.cs @@ -47,20 +47,7 @@ namespace CalamityMod.Items.SummonItems if (player.ZoneDungeon) { if (Main.netMode != NetmodeID.MultiplayerClient) - { NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); - - bool expertMode = Main.expertMode; - bool revenge = CalamityWorld.revenge; - bool death = CalamityWorld.death || CalamityWorld.malice; - int glob = death ? 5 : revenge ? 4 : expertMode ? 3 : 2; - for (int i = 0; i < glob; i++) - { - NPC.NewNPC((int)player.Center.X - 200, (int)player.Center.Y - 200, ModContent.NPCType()); - NPC.NewNPC((int)player.Center.X + 200, (int)player.Center.Y - 200, ModContent.NPCType()); - NPC.NewNPC((int)player.Center.X, (int)player.Center.Y + 200, ModContent.NPCType()); - } - } else NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); } diff --git a/Items/SummonItems/Seafood.cs b/Items/SummonItems/Seafood.cs index 0af68efd6d..2e33f85676 100644 --- a/Items/SummonItems/Seafood.cs +++ b/Items/SummonItems/Seafood.cs @@ -19,8 +19,8 @@ namespace CalamityMod.Items.SummonItems public override void SetDefaults() { - item.width = 28; - item.height = 28; + item.width = 26; + item.height = 24; item.maxStack = 20; item.rare = ItemRarityID.Pink; item.useAnimation = 45; diff --git a/Items/SummonItems/Seafood.png b/Items/SummonItems/Seafood.png index d8b63605d4..49a953c5e8 100644 Binary files a/Items/SummonItems/Seafood.png and b/Items/SummonItems/Seafood.png differ diff --git a/Items/Tools/BobbitHook.cs b/Items/Tools/BobbitHook.cs index f9c834c700..904c086a72 100644 --- a/Items/Tools/BobbitHook.cs +++ b/Items/Tools/BobbitHook.cs @@ -1,9 +1,10 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -using static Terraria.ModLoader.ModContent; using CalamityMod.Projectiles.Typeless; +using static Terraria.ModLoader.ModContent; + namespace CalamityMod.Items.Tools { public class BobbitHook : ModItem @@ -11,17 +12,18 @@ namespace CalamityMod.Items.Tools public override void SetStaticDefaults() { DisplayName.SetDefault("Bobbit Hook"); - Tooltip.SetDefault(@"Retracts upon attaching to a tile with extreme speeds -Reach: 40 -Launch Velocity: 25 -Pull Velocity: 28"); + 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 = 25f; // how quickly the hook is shot. + 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; diff --git a/Items/Tools/CrystylCrusher.cs b/Items/Tools/CrystylCrusher.cs index 600a0e2a37..de2c1bb9bb 100644 --- a/Items/Tools/CrystylCrusher.cs +++ b/Items/Tools/CrystylCrusher.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Tools public override void SetDefaults() { - item.damage = 2000; + item.damage = 400; item.melee = true; item.noMelee = true; item.channel = true; diff --git a/Items/Tools/PurityAxe.cs b/Items/Tools/PurityAxe.cs index 133b52367d..5bf188a4ab 100644 --- a/Items/Tools/PurityAxe.cs +++ b/Items/Tools/PurityAxe.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Tools item.damage = 43; item.melee = true; item.width = 58; - item.height = 46; + item.height = 54; item.useTime = 19; item.useAnimation = 19; item.useTurn = true; diff --git a/Items/Tools/PurityAxe.png b/Items/Tools/PurityAxe.png index 75b68ffd8d..7a4a9bd655 100644 Binary files a/Items/Tools/PurityAxe.png and b/Items/Tools/PurityAxe.png differ diff --git a/Items/TreasureBags/SlimeGodBag.cs b/Items/TreasureBags/SlimeGodBag.cs index 3df7456c7b..533e2d577c 100644 --- a/Items/TreasureBags/SlimeGodBag.cs +++ b/Items/TreasureBags/SlimeGodBag.cs @@ -51,7 +51,8 @@ namespace CalamityMod.Items.TreasureBags DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) ); // Equipment diff --git a/Items/TreasureBags/StormWeaverBag.cs b/Items/TreasureBags/StormWeaverBag.cs index 5f17f841ae..df2d8d51a5 100644 --- a/Items/TreasureBags/StormWeaverBag.cs +++ b/Items/TreasureBags/StormWeaverBag.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.NPCs.StormWeaver; @@ -53,6 +54,9 @@ namespace CalamityMod.Items.TreasureBags DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItem(player, ModContent.ItemType()); } + + // Light pet. + DropHelper.DropItemChance(player, ModContent.ItemType(), 8); } } } diff --git a/Items/Weapons/DraedonsArsenal/GaussDagger.cs b/Items/Weapons/DraedonsArsenal/GaussDagger.cs index 780a838702..0d597fed37 100644 --- a/Items/Weapons/DraedonsArsenal/GaussDagger.cs +++ b/Items/Weapons/DraedonsArsenal/GaussDagger.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal target.Calamity().GaussFluxTimer = 0; if (player.whoAmI == Main.myPlayer) { - Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), damage, 0f, player.whoAmI, 0f, target.whoAmI); + Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), 0f, player.whoAmI, 0f, target.whoAmI); } } } diff --git a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs index 8c494e15b1..01199662ac 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.width = 22; item.height = 28; - item.damage = 1312; + item.damage = 1378; item.noMelee = true; item.noUseGraphic = true; item.consumable = true; @@ -48,6 +48,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) { + if (player.Calamity().StealthStrikeAvailable()) + damage = (int)(damage * 1.05); + 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(); diff --git a/Items/Weapons/DraedonsArsenal/PoleWarper.cs b/Items/Weapons/DraedonsArsenal/PoleWarper.cs index 709fd95d9e..5155800c48 100644 --- a/Items/Weapons/DraedonsArsenal/PoleWarper.cs +++ b/Items/Weapons/DraedonsArsenal/PoleWarper.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal CalamityGlobalItem modItem = item.Calamity(); item.shootSpeed = 10f; - item.damage = 310; + item.damage = 248; item.mana = 12; item.width = 38; item.height = 24; diff --git a/Items/Weapons/Magic/ApoctosisArray.cs b/Items/Weapons/Magic/ApoctosisArray.cs index 697bcfefef..12b0b3658a 100644 --- a/Items/Weapons/Magic/ApoctosisArray.cs +++ b/Items/Weapons/Magic/ApoctosisArray.cs @@ -45,8 +45,8 @@ namespace CalamityMod.Items.Weapons.Magic if (injectionNerf) manaRatio = MathHelper.Min(manaRatio, 0.65f); - // 20% to 220% damage. Astral Injection caps it at 124% damage. - float damageRatio = 0.2f + 1.6f * manaRatio; + // 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); diff --git a/Items/Weapons/Magic/Apotheosis.cs b/Items/Weapons/Magic/Apotheosis.cs index 71824bfd6d..7066a7686c 100644 --- a/Items/Weapons/Magic/Apotheosis.cs +++ b/Items/Weapons/Magic/Apotheosis.cs @@ -22,13 +22,12 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 420; + item.damage = 77; item.magic = true; - item.mana = (int)42.0; // TODO -- is there a reason for this? + item.mana = 42; item.width = 30; item.height = 34; - item.useTime = 15; - item.useAnimation = 15; + item.useTime = item.useAnimation = 177; item.useStyle = ItemUseStyleID.HoldingOut; item.useTurn = false; item.noMelee = true; @@ -40,8 +39,8 @@ namespace CalamityMod.Items.Weapons.Magic item.UseSound = SoundID.Item92; item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 15.69f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 42.0f; } public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI) diff --git a/Items/Weapons/Magic/CarnageRay.cs b/Items/Weapons/Magic/CarnageRay.cs index c02ffe9401..5799ff4e61 100644 --- a/Items/Weapons/Magic/CarnageRay.cs +++ b/Items/Weapons/Magic/CarnageRay.cs @@ -12,7 +12,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Carnage Ray"); - Tooltip.SetDefault("Fires a blood ray that splits if enemies are near it"); + Tooltip.SetDefault("Fires a blood ray\n" + + "The farther along the ray hit enemies are, the more damage they take"); Item.staff[item.type] = true; } diff --git a/Items/Weapons/Magic/Climax.cs b/Items/Weapons/Magic/Climax.cs index ff177f9721..15d9c50a84 100644 --- a/Items/Weapons/Magic/Climax.cs +++ b/Items/Weapons/Magic/Climax.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 131; + item.damage = 105; item.magic = true; item.mana = 30; item.width = 78; item.height = 78; - item.useTime = 33; - item.useAnimation = 33; + item.useTime = 55; + item.useAnimation = 55; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 5f; diff --git a/Items/Weapons/Magic/DeathValley.cs b/Items/Weapons/Magic/DeathValley.cs index 519fc663f2..9faf1ada62 100644 --- a/Items/Weapons/Magic/DeathValley.cs +++ b/Items/Weapons/Magic/DeathValley.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/DeathhailStaff.cs b/Items/Weapons/Magic/DeathhailStaff.cs index e9f89d7ad1..af14db8a61 100644 --- a/Items/Weapons/Magic/DeathhailStaff.cs +++ b/Items/Weapons/Magic/DeathhailStaff.cs @@ -20,13 +20,13 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 132; + item.damage = 155; item.magic = true; item.mana = 12; item.width = 80; item.height = 84; - item.useTime = 6; - item.useAnimation = 12; + item.useTime = 8; + item.useAnimation = 16; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 4f; diff --git a/Items/Weapons/Magic/ElementalRay.cs b/Items/Weapons/Magic/ElementalRay.cs index 078d899a2a..2c6d165a4e 100644 --- a/Items/Weapons/Magic/ElementalRay.cs +++ b/Items/Weapons/Magic/ElementalRay.cs @@ -12,7 +12,11 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Elemental Ray"); - Tooltip.SetDefault("Casts a rainbow ray that splits when enemies are near it"); + Tooltip.SetDefault("Casts four celestial beams near the player\n" + + "Solar beams explode into fire on enemy hits\n" + + "Nebula beams sweep a little bit over time\n" + + "Vortex beams act like fast lightning and electrify enemies on hit\n" + + "Stardust beams release small stars that home on enemy hits"); Item.staff[item.type] = true; } @@ -23,8 +27,8 @@ namespace CalamityMod.Items.Weapons.Magic item.mana = 18; item.width = 62; item.height = 62; - item.useTime = 20; - item.useAnimation = 20; + item.useTime = 4; + item.reuseDelay = item.useAnimation = 15; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 7.5f; @@ -32,16 +36,51 @@ namespace CalamityMod.Items.Weapons.Magic item.rare = ItemRarityID.Purple; item.UseSound = SoundID.Item60; item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); + item.shoot = 1; item.shootSpeed = 6f; } - public override Vector2? HoldoutOrigin() - { - return new Vector2(15, 15); - } + public override Vector2? HoldoutOrigin() => new Vector2(15); - public override void AddRecipes() + 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); + float shootSpeed = 1f; + switch (player.itemAnimation) + { + case 14: + type = ModContent.ProjectileType(); + break; + case 10: + type = ModContent.ProjectileType(); + offsetAngle -= NebulaElementalBeam.UniversalAngularSpeed * 0.5f; + break; + case 6: + type = ModContent.ProjectileType(); + shootSpeed = 2f; + break; + case 2: + type = ModContent.ProjectileType(); + break; + default: + return false; + } + + Vector2 spawnOffset = player.SafeDirectionTo(Main.MouseWorld, Vector2.UnitY).RotatedBy(offsetAngle) * -Main.rand.NextFloat(40f, 96f); + Vector2 shootDirection = (Main.MouseWorld - (position + spawnOffset)).SafeNormalize(Vector2.UnitX * player.direction); + int beam = Projectile.NewProjectile(position + spawnOffset, shootDirection * shootSpeed, type, damage, knockBack, player.whoAmI); + + // Define specific values for fired lightning. + if (type == ModContent.ProjectileType()) + { + Main.projectile[beam].ai[0] = shootDirection.ToRotation(); + Main.projectile[beam].ai[1] = Main.rand.Next(100); + } + return false; + } + + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Weapons/Magic/Eternity.cs b/Items/Weapons/Magic/Eternity.cs index 2e9549aa84..ff5129e621 100644 --- a/Items/Weapons/Magic/Eternity.cs +++ b/Items/Weapons/Magic/Eternity.cs @@ -12,8 +12,8 @@ namespace CalamityMod.Items.Weapons.Magic { public class Eternity : ModItem { - public const int BaseDamage = 4200; - public const int ExplosionDamage = 42000; + public const int BaseDamage = 840; + public const int ExplosionDamage = 8400; public const int MaxHomers = 40; public const int DustID = 16; public static readonly Color BlueColor = new Color(34, 34, 160); @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ItemID.UnicornHorn, 5); diff --git a/Items/Weapons/Magic/Fabstaff.cs b/Items/Weapons/Magic/Fabstaff.cs index f63c97e4f1..f581260826 100644 --- a/Items/Weapons/Magic/Fabstaff.cs +++ b/Items/Weapons/Magic/Fabstaff.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 616; + item.damage = 125; item.magic = true; item.mana = 50; item.width = 84; @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Magic item.UseSound = SoundID.Item60; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 6f; + item.shootSpeed = 13.5f; } public override Vector2? HoldoutOrigin() diff --git a/Items/Weapons/Magic/HadopelagicEcho.cs b/Items/Weapons/Magic/HadopelagicEcho.cs index a3993bb905..8fbdcfc37c 100644 --- a/Items/Weapons/Magic/HadopelagicEcho.cs +++ b/Items/Weapons/Magic/HadopelagicEcho.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 769; + item.damage = 230; item.magic = true; item.mana = 15; item.width = 60; diff --git a/Items/Weapons/Magic/HeliumFlash.cs b/Items/Weapons/Magic/HeliumFlash.cs index ef89816add..9f44eb0892 100644 --- a/Items/Weapons/Magic/HeliumFlash.cs +++ b/Items/Weapons/Magic/HeliumFlash.cs @@ -97,7 +97,7 @@ namespace CalamityMod.Items.Weapons.Magic r.AddTile(TileID.LunarCraftingStation); r.AddIngredient(ModContent.ItemType()); r.AddIngredient(ModContent.ItemType()); - r.AddIngredient(ModContent.ItemType()); + r.AddIngredient(ModContent.ItemType()); r.AddIngredient(ModContent.ItemType(), 4); r.AddIngredient(ItemID.FragmentSolar, 80); r.AddIngredient(ItemID.FragmentNebula, 20); diff --git a/Items/Weapons/Magic/Heresy.cs b/Items/Weapons/Magic/Heresy.cs new file mode 100644 index 0000000000..6d04804a89 --- /dev/null +++ b/Items/Weapons/Magic/Heresy.cs @@ -0,0 +1,44 @@ +using CalamityMod.Projectiles.Magic; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class Heresy : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heresy"); + Tooltip.SetDefault("Releases fire and souls upward from a held book\n" + + "As the book is held the power of both increases"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 6)); + } + + public override void SetDefaults() + { + item.damage = 444; + item.magic = true; + item.mana = 10; + item.width = 38; + item.height = 40; + item.useTime = item.useAnimation = 120; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.UseSound = SoundID.DD2_EtherianPortalDryadTouch; + item.knockBack = 0f; + + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + + item.autoReuse = true; + item.noUseGraphic = true; + item.shoot = ModContent.ProjectileType(); + item.channel = true; + item.shootSpeed = 0f; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + } +} \ No newline at end of file diff --git a/Items/Weapons/Magic/Heresy.png b/Items/Weapons/Magic/Heresy.png new file mode 100644 index 0000000000..4c8e3e4f8b Binary files /dev/null and b/Items/Weapons/Magic/Heresy.png differ diff --git a/Items/Weapons/Magic/IonBlaster.cs b/Items/Weapons/Magic/IonBlaster.cs index fd77de50fa..e1cf2a27fc 100644 --- a/Items/Weapons/Magic/IonBlaster.cs +++ b/Items/Weapons/Magic/IonBlaster.cs @@ -46,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Magic if (injectionNerf) manaRatio = MathHelper.Min(manaRatio, 0.65f); - // 20% to 180% damage. Astral Injection caps it at 124% damage. - float damageRatio = 0.2f + 1.6f * manaRatio; + // 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); diff --git a/Items/Weapons/Magic/Judgement.cs b/Items/Weapons/Magic/Judgement.cs index 64d7e15ad4..a2285e9054 100644 --- a/Items/Weapons/Magic/Judgement.cs +++ b/Items/Weapons/Magic/Judgement.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Weapons.Magic public class Judgement : ModItem { public const int HitsPerFlash = 300; - public const int FlashBaseDamage = 80000; + public const int FlashBaseDamage = 16000; private const float SpawnAngleSpread = 0.4f * MathHelper.Pi; private const float SpeedRandomness = 0.08f; @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Magic { item.width = 40; item.height = 42; - item.damage = 2077; + item.damage = 415; item.knockBack = 4f; item.magic = true; item.mana = 6; diff --git a/Items/Weapons/Magic/NightsRay.cs b/Items/Weapons/Magic/NightsRay.cs index eff05e11fe..d30410c68c 100644 --- a/Items/Weapons/Magic/NightsRay.cs +++ b/Items/Weapons/Magic/NightsRay.cs @@ -12,7 +12,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Night's Ray"); - Tooltip.SetDefault("Fires a dark ray that splits if enemies are near it"); + Tooltip.SetDefault("Fires a dark ray\n" + + "When hitting enemies, they are hit by several new beams from their sides"); Item.staff[item.type] = true; } diff --git a/Items/Weapons/Magic/PhoenixFlameBarrage.cs b/Items/Weapons/Magic/PhoenixFlameBarrage.cs index 3ef8ca0ee9..95db22cf7f 100644 --- a/Items/Weapons/Magic/PhoenixFlameBarrage.cs +++ b/Items/Weapons/Magic/PhoenixFlameBarrage.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 290; + item.damage = 150; item.magic = true; item.mana = 20; item.width = 72; diff --git a/Items/Weapons/Magic/PrimordialAncient.cs b/Items/Weapons/Magic/PrimordialAncient.cs index ccbfe09aee..fc3e985452 100644 --- a/Items/Weapons/Magic/PrimordialAncient.cs +++ b/Items/Weapons/Magic/PrimordialAncient.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/Items/Weapons/Magic/RainbowPartyCannon.cs b/Items/Weapons/Magic/RainbowPartyCannon.cs new file mode 100644 index 0000000000..94188df883 --- /dev/null +++ b/Items/Weapons/Magic/RainbowPartyCannon.cs @@ -0,0 +1,78 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Magic; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Magic +{ + public class RainbowPartyCannon : ModItem + { + public static readonly Color[] ColorSet = new Color[] + { + new Color(188, 192, 193), // White + new Color(157, 100, 183), // Purple + new Color(249, 166, 77), // Honey-ish orange + new Color(255, 105, 234), // Pink + new Color(67, 204, 219), // Sky blue + new Color(249, 245, 99), // Bright yellow + new Color(236, 168, 247), // Purplish pink + }; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rainbow Party Cannon"); + Tooltip.SetDefault("Let the rainbow remind you that together we will always shine..."); + } + + public override void SetDefaults() + { + item.damage = 225; + item.magic = true; + item.mana = 25; + item.width = 52; + item.height = 30; + item.crit += 4; + item.useTime = item.useAnimation = 24; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 3.5f; + item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; + item.rare = 10; + item.Calamity().customRarity = CalamityRarity.HotPink; + item.UseSound = SoundID.Item11; + item.autoReuse = true; + item.noUseGraphic = true; + item.shoot = ModContent.ProjectileType(); + item.channel = true; + item.shootSpeed = 20f; + } + + public override void ModifyTooltips(List tooltips) + { + var tt2 = tooltips.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria"); + tt2.overrideColor = new Color(MathHelper.Lerp(156f, 255f, Main.DiscoR / 256f), 108f, 251f); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.ConfettiCannon); + recipe.AddIngredient(ModContent.ItemType()); + + // This is the Celebration. The ItemID name is a bit unclear. + // TODO: Replace this with Celebration MK2 in 1.4. + recipe.AddIngredient(ItemID.FireworksLauncher); + recipe.AddIngredient(ItemID.FlaskofParty, 5); + recipe.AddIngredient(ItemID.SoulofLight, 25); + recipe.AddIngredient(ItemID.Confetti, 50); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Magic/RainbowPartyCannon.png b/Items/Weapons/Magic/RainbowPartyCannon.png new file mode 100644 index 0000000000..10b7ca96e9 Binary files /dev/null and b/Items/Weapons/Magic/RainbowPartyCannon.png differ diff --git a/Items/Weapons/Magic/SubsumingVortex.cs b/Items/Weapons/Magic/SubsumingVortex.cs index 91b73e0d48..01566b5b5f 100644 --- a/Items/Weapons/Magic/SubsumingVortex.cs +++ b/Items/Weapons/Magic/SubsumingVortex.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 1000; + item.damage = 175; item.magic = true; item.mana = 78; item.width = 38; diff --git a/Items/Weapons/Magic/T1000.cs b/Items/Weapons/Magic/T1000.cs index 872b6fc0b6..8ac53ca068 100644 --- a/Items/Weapons/Magic/T1000.cs +++ b/Items/Weapons/Magic/T1000.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 142; + item.damage = 250; item.magic = true; item.mana = 10; item.width = 20; @@ -30,13 +30,13 @@ namespace CalamityMod.Items.Weapons.Magic item.noUseGraphic = true; item.channel = true; item.knockBack = 4f; - item.value = Item.buyPrice(1, 80, 0, 0); - item.rare = ItemRarityID.Red; - item.autoReuse = true; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 24f; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.Calamity().customRarity = CalamityRarity.Violet; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Magic { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); diff --git a/Items/Weapons/Magic/TerraRay.cs b/Items/Weapons/Magic/TerraRay.cs index 0d17f2fc30..2eaacb9a7a 100644 --- a/Items/Weapons/Magic/TerraRay.cs +++ b/Items/Weapons/Magic/TerraRay.cs @@ -12,7 +12,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Terra Ray"); - Tooltip.SetDefault("Casts an energy ray that splits if enemies are near it"); + Tooltip.SetDefault("Casts an energy ray that splits into energy on enemy hits\n" + + "More energy is created the farther along the ray the hit enemy is"); Item.staff[item.type] = true; } @@ -41,7 +42,15 @@ namespace CalamityMod.Items.Weapons.Magic return new Vector2(15, 15); } - public override void AddRecipes() + 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() { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); diff --git a/Items/Weapons/Magic/TheWand.cs b/Items/Weapons/Magic/TheWand.cs index 26e76d92f6..43f34b0c29 100644 --- a/Items/Weapons/Magic/TheWand.cs +++ b/Items/Weapons/Magic/TheWand.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.Magic { public class TheWand : ModItem { - public static int BaseDamage = 1998; + public static int BaseDamage = 599; public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/Vehemenc.cs b/Items/Weapons/Magic/Vehemenc.cs index ae86596497..78ca7bb07f 100644 --- a/Items/Weapons/Magic/Vehemenc.cs +++ b/Items/Weapons/Magic/Vehemenc.cs @@ -8,26 +8,27 @@ namespace CalamityMod.Items.Weapons.Magic { public class Vehemenc : ModItem { + public const int VehemenceSkullDamage = 7000; public override void SetStaticDefaults() { DisplayName.SetDefault("Vehemence"); Tooltip.SetDefault("Casts an intense energy blast\n" + "Does far more damage the more HP an enemy has left\n" + - "Max damage is capped at 1,000,000\n" + - "If an enemy has full HP it will inflict several long-lasting debuffs\n" + - "Revengeance drop"); + "Max damage is capped at 200,000\n" + + "If an enemy has full HP it will inflict Demon Flames for an extremely long time"); Item.staff[item.type] = true; } public override void SetDefaults() { - item.damage = 7; + item.damage = 3; item.magic = true; item.mana = 590; item.width = 44; item.height = 44; - item.useTime = 50; - item.useAnimation = 50; + item.useTime = item.useAnimation = 50; + item.noUseGraphic = true; + item.channel = true; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 5.75f; @@ -35,20 +36,19 @@ namespace CalamityMod.Items.Weapons.Magic item.rare = ItemRarityID.Red; item.UseSound = SoundID.Item73; item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 16f; } - public override Vector2? HoldoutOrigin() - { - return new Vector2(25, 25); - } + public override Vector2? HoldoutOrigin() => new Vector2(25, 25); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); player.AddBuff(BuffID.ManaSickness, 600, true); return false; } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; } } diff --git a/Items/Weapons/Magic/VividClarity.cs b/Items/Weapons/Magic/VividClarity.cs index d2148b3f70..a602bd5e23 100644 --- a/Items/Weapons/Magic/VividClarity.cs +++ b/Items/Weapons/Magic/VividClarity.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 515; + item.damage = 155; item.magic = true; item.mana = 42; item.width = 90; @@ -84,7 +84,6 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); diff --git a/Items/Weapons/Magic/VoidVortex.cs b/Items/Weapons/Magic/VoidVortex.cs index dbf29e5dc3..c199cf4eaf 100644 --- a/Items/Weapons/Magic/VoidVortex.cs +++ b/Items/Weapons/Magic/VoidVortex.cs @@ -18,13 +18,13 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 195; + item.damage = 82; item.magic = true; item.mana = 60; item.width = 130; item.height = 130; - item.useTime = 41; - item.useAnimation = 41; + item.useTime = 80; + item.useAnimation = 80; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 0f; diff --git a/Items/Weapons/Magic/YharimsCrystal.cs b/Items/Weapons/Magic/YharimsCrystal.cs index 502dd75a30..e69c022965 100644 --- a/Items/Weapons/Magic/YharimsCrystal.cs +++ b/Items/Weapons/Magic/YharimsCrystal.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 350; + item.damage = 125; item.magic = true; item.mana = 15; item.width = 16; diff --git a/Items/Weapons/Melee/AbsoluteZero.cs b/Items/Weapons/Melee/AbsoluteZero.cs index d7c10d6a05..3f04f7afad 100644 --- a/Items/Weapons/Melee/AbsoluteZero.cs +++ b/Items/Weapons/Melee/AbsoluteZero.cs @@ -36,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { target.AddBuff(BuffID.Frostburn, 600); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 60); int p = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), knockBack * 3f, player.whoAmI); Main.projectile[p].Kill(); @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(BuffID.Frostburn, 600); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 60); int p = Projectile.NewProjectile(target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(item.damage * player.MeleeDamage()), 12f, player.whoAmI); Main.projectile[p].Kill(); diff --git a/Items/Weapons/Melee/Animus.cs b/Items/Weapons/Melee/Animus.cs index aad4357be9..6a087479bf 100644 --- a/Items/Weapons/Melee/Animus.cs +++ b/Items/Weapons/Melee/Animus.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 82; item.height = 84; item.scale = 1.5f; - item.damage = 4000; + item.damage = 800; item.melee = true; item.useAnimation = 11; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index 1a52ecbaea..aeef4ac3ea 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 102; - item.damage = 501; + item.damage = 140; item.melee = true; item.useAnimation = 15; item.useTime = 15; @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Melee item.UseSound = SoundID.Item60; item.autoReuse = true; item.height = 102; - item.value = Item.buyPrice(2, 50, 0, 0); - item.rare = ItemRarityID.Red; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 28f; item.Calamity().customRarity = CalamityRarity.Violet; diff --git a/Items/Weapons/Melee/ArkoftheElements.cs b/Items/Weapons/Melee/ArkoftheElements.cs index 97a7a561a1..d7fc7a9786 100644 --- a/Items/Weapons/Melee/ArkoftheElements.cs +++ b/Items/Weapons/Melee/ArkoftheElements.cs @@ -125,7 +125,7 @@ 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(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } @@ -133,7 +133,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Items/Weapons/Melee/Ataraxia.cs b/Items/Weapons/Melee/Ataraxia.cs index 79888221cc..23f4d63bee 100644 --- a/Items/Weapons/Melee/Ataraxia.cs +++ b/Items/Weapons/Melee/Ataraxia.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 94; item.height = 92; item.melee = true; - item.damage = 3651; + item.damage = 1095; item.knockBack = 2.5f; item.useAnimation = 19; item.useTime = 19; diff --git a/Items/Weapons/Melee/Azathoth.cs b/Items/Weapons/Melee/Azathoth.cs index c42734ac15..7257e550ae 100644 --- a/Items/Weapons/Melee/Azathoth.cs +++ b/Items/Weapons/Melee/Azathoth.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 40; item.height = 54; item.melee = true; - item.damage = 200; + item.damage = 50; item.knockBack = 6f; item.useTime = 20; item.useAnimation = 20; diff --git a/Items/Weapons/Melee/CosmicShiv.cs b/Items/Weapons/Melee/CosmicShiv.cs index 35f391275f..df5fba12a9 100644 --- a/Items/Weapons/Melee/CosmicShiv.cs +++ b/Items/Weapons/Melee/CosmicShiv.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Items.Weapons.Melee } target.AddBuff(ModContent.BuffType(), 420); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 420); target.AddBuff(ModContent.BuffType(), 420); target.AddBuff(ModContent.BuffType(), 420); target.AddBuff(ModContent.BuffType(), 360); @@ -92,7 +92,7 @@ namespace CalamityMod.Items.Weapons.Melee } target.AddBuff(ModContent.BuffType(), 420); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 420); target.AddBuff(ModContent.BuffType(), 420); target.AddBuff(ModContent.BuffType(), 420); target.AddBuff(ModContent.BuffType(), 360); diff --git a/Items/Weapons/Melee/DraconicDestruction.cs b/Items/Weapons/Melee/DraconicDestruction.cs index cadaa44d0e..a33aa1bbff 100644 --- a/Items/Weapons/Melee/DraconicDestruction.cs +++ b/Items/Weapons/Melee/DraconicDestruction.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 94; - item.damage = 350; + item.damage = 80; item.melee = true; item.useAnimation = 24; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/DraedonsExoblade.cs b/Items/Weapons/Melee/DraedonsExoblade.cs index 71f303f585..5a119fb044 100644 --- a/Items/Weapons/Melee/DraedonsExoblade.cs +++ b/Items/Weapons/Melee/DraedonsExoblade.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 80; - item.damage = 5000; + item.damage = 900; item.useAnimation = 14; item.useStyle = ItemUseStyleID.SwingThrow; item.useTime = 14; diff --git a/Items/Weapons/Melee/DragonPow.cs b/Items/Weapons/Melee/DragonPow.cs index 4809a32c77..e67e97b43a 100644 --- a/Items/Weapons/Melee/DragonPow.cs +++ b/Items/Weapons/Melee/DragonPow.cs @@ -29,7 +29,7 @@ Summons a barrage of petals and waterfalls on enemy hits"); item.width = 76; item.height = 82; item.melee = true; - item.damage = 4500; + item.damage = 660; item.knockBack = 9f; item.useAnimation = 20; item.useTime = 20; diff --git a/Items/Weapons/Melee/DragonRage.cs b/Items/Weapons/Melee/DragonRage.cs index c0985f3cc4..683d97d6be 100644 --- a/Items/Weapons/Melee/DragonRage.cs +++ b/Items/Weapons/Melee/DragonRage.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - item.damage = 800; + item.damage = 1275; item.knockBack = 7.5f; item.useAnimation = item.useTime = 25; item.melee = true; @@ -27,8 +27,8 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 14f; item.shoot = ModContent.ProjectileType(); - item.width = 68; - item.height = 82; + item.width = 128; + item.height = 140; item.noUseGraphic = true; item.useStyle = ItemUseStyleID.HoldingOut; item.UseSound = SoundID.DD2_SkyDragonsFurySwing; diff --git a/Items/Weapons/Melee/DragonRage.png b/Items/Weapons/Melee/DragonRage.png index ca3c08ba59..4dada2773a 100644 Binary files a/Items/Weapons/Melee/DragonRage.png and b/Items/Weapons/Melee/DragonRage.png differ diff --git a/Items/Weapons/Melee/Earth.cs b/Items/Weapons/Melee/Earth.cs index 5760484f0c..4f36e38f17 100644 --- a/Items/Weapons/Melee/Earth.cs +++ b/Items/Weapons/Melee/Earth.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 92; item.height = 104; item.scale = 1.5f; - item.damage = 840; + item.damage = 170; item.melee = true; item.useAnimation = 16; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/ElementalExcalibur.cs b/Items/Weapons/Melee/ElementalExcalibur.cs index ec07a8a2ad..1174c47e2b 100644 --- a/Items/Weapons/Melee/ElementalExcalibur.cs +++ b/Items/Weapons/Melee/ElementalExcalibur.cs @@ -13,9 +13,9 @@ namespace CalamityMod.Items.Weapons.Melee { public class ElementalExcalibur : ModItem { - private static int BaseDamage = 10000; + private static int BaseDamage = 2000; private int BeamType = 0; - private int alpha = 50; + private const int alpha = 50; public override void SetStaticDefaults() { @@ -147,9 +147,8 @@ 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(), 30); target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 240); target.AddBuff(ModContent.BuffType(), 240); target.AddBuff(BuffID.CursedInferno, 240); @@ -167,9 +166,8 @@ 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(), 30); target.AddBuff(ModContent.BuffType(), 240); - target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 240); target.AddBuff(ModContent.BuffType(), 240); target.AddBuff(BuffID.CursedInferno, 240); diff --git a/Items/Weapons/Melee/ElementalShortsword.cs b/Items/Weapons/Melee/ElementalShortsword.cs index bd57db77b9..816c701ad3 100644 --- a/Items/Weapons/Melee/ElementalShortsword.cs +++ b/Items/Weapons/Melee/ElementalShortsword.cs @@ -68,7 +68,7 @@ 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(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } @@ -76,7 +76,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Items/Weapons/Melee/ExoGladius.cs b/Items/Weapons/Melee/ExoGladius.cs index d7796b267d..38ce59ea03 100644 --- a/Items/Weapons/Melee/ExoGladius.cs +++ b/Items/Weapons/Melee/ExoGladius.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Melee item.useTime = 12; item.width = 56; item.height = 56; - item.damage = 2700; + item.damage = 690; item.melee = true; item.knockBack = 9.9f; item.UseSound = SoundID.Item1; diff --git a/Items/Weapons/Melee/GlacialCrusher.cs b/Items/Weapons/Melee/GlacialCrusher.cs index bd7e3e1ac3..1e9344c060 100644 --- a/Items/Weapons/Melee/GlacialCrusher.cs +++ b/Items/Weapons/Melee/GlacialCrusher.cs @@ -14,14 +14,13 @@ namespace CalamityMod.Items.Weapons.Melee DisplayName.SetDefault("Glacial Crusher"); Tooltip.SetDefault("Fires very slow frost projectiles that gain strength as they travel and freeze enemies\n" + "Enemies are frozen for longer the further the projectile travels\n" + - "True melee strikes cause tremendous damage to frozen enemies\n" + - "Enemies that cannot be frozen take increased damage"); + "True melee strikes cause tremendous damage to frozen enemies"); } public override void SetDefaults() { item.width = 60; - item.damage = 65; + item.damage = 120; item.melee = true; item.useAnimation = 27; item.useTime = 27; @@ -40,19 +39,12 @@ namespace CalamityMod.Items.Weapons.Melee public override void MeleeEffects(Player player, Rectangle hitbox) { if (Main.rand.NextBool(3)) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 67); - } + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 67); } public override void ModifyHitNPC(Player player, NPC target, ref int damage, ref float knockBack, ref bool crit) { - if (target.buffImmune[ModContent.BuffType()]) - { - damage *= 2; - knockBack *= 2f; - } - else if (target.Calamity().gState > 0) + if (target.Calamity().gState > 0) { damage *= 3; knockBack *= 3f; diff --git a/Items/Weapons/Melee/LionHeart.cs b/Items/Weapons/Melee/LionHeart.cs index 6dda28a40e..386badac26 100644 --- a/Items/Weapons/Melee/LionHeart.cs +++ b/Items/Weapons/Melee/LionHeart.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 60; item.height = 62; - item.damage = 420; + item.damage = 323; item.knockBack = 5.5f; item.scale = 1.5f; item.useStyle = ItemUseStyleID.SwingThrow; @@ -54,9 +54,7 @@ namespace CalamityMod.Items.Weapons.Melee if (player.altFunctionUse == 2) { if (!player.Calamity().energyShellCooldown && player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0) - { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI, 0f, 0f); - } + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); } return false; } @@ -89,9 +87,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void MeleeEffects(Player player, Rectangle hitbox) { if (Main.rand.NextBool(3)) - { Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 132); - } } } } diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index efc3691e56..28ea5cf715 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.height = 128; item.width = 56; - item.damage = 20001; + item.damage = 2001; item.melee = true; item.noMelee = true; item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/Omniblade.cs b/Items/Weapons/Melee/Omniblade.cs index 77835d62e0..0ccd879f86 100644 --- a/Items/Weapons/Melee/Omniblade.cs +++ b/Items/Weapons/Melee/Omniblade.cs @@ -1,6 +1,5 @@ -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Materials; -using Microsoft.Xna.Framework; +using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -29,28 +28,18 @@ namespace CalamityMod.Items.Weapons.Melee item.autoReuse = true; item.height = 146; item.value = Item.buyPrice(0, 80, 0, 0); + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 24f; item.rare = ItemRarityID.Yellow; } // Terraria seems to really dislike high crit values in SetDefaults public override void GetWeaponCrit(Player player, ref int crit) => crit += 45; - public override void UseItemHitbox(Player player, ref Rectangle hitbox, ref bool noHitbox) - { - hitbox = CalamityUtils.FixSwingHitbox(102, 102); - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - if (Main.rand.NextBool(5)) - target.AddBuff(ModContent.BuffType(), 360); - } - - public override void OnHitPvp(Player player, Player target, int damage, bool crit) - { - if (Main.rand.NextBool(5)) - target.AddBuff(ModContent.BuffType(), 360); - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; public override void AddRecipes() { diff --git a/Items/Weapons/Melee/Oracle.cs b/Items/Weapons/Melee/Oracle.cs index b6ac219769..fd80f86eb2 100644 --- a/Items/Weapons/Melee/Oracle.cs +++ b/Items/Weapons/Melee/Oracle.cs @@ -10,9 +10,9 @@ namespace CalamityMod.Items.Weapons.Melee { public class Oracle : ModItem { - public const int YoyoBaseDamage = 380; - public const int AuraBaseDamage = 120; - public const int AuraMaxDamage = 400; + public const int YoyoBaseDamage = 115; + public const int AuraBaseDamage = 40; + public const int AuraMaxDamage = 105; public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/PhosphorescentGauntlet.cs b/Items/Weapons/Melee/PhosphorescentGauntlet.cs new file mode 100644 index 0000000000..4167740a72 --- /dev/null +++ b/Items/Weapons/Melee/PhosphorescentGauntlet.cs @@ -0,0 +1,50 @@ +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class PhosphorescentGauntlet : ModItem + { + 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 = 750; + 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; + } + + // 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 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/PhosphorescentGauntlet.png b/Items/Weapons/Melee/PhosphorescentGauntlet.png new file mode 100644 index 0000000000..a470c6a68d Binary files /dev/null and b/Items/Weapons/Melee/PhosphorescentGauntlet.png differ diff --git a/Items/Weapons/Melee/PhotonRipper.cs b/Items/Weapons/Melee/PhotonRipper.cs new file mode 100644 index 0000000000..aa3deafe46 --- /dev/null +++ b/Items/Weapons/Melee/PhotonRipper.cs @@ -0,0 +1,51 @@ +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class PhotonRipper : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Photon Ripper"); + Tooltip.SetDefault("Unleashes a flurry of prismatic crystals at extremely fast speeds\n" + + "These crystals are capable of breaking trees"); + } + + public override void SetDefaults() + { + item.height = 134; + item.width = 54; + item.damage = 305; + item.axe = 3330; + item.axe /= 5; + item.melee = true; + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.useStyle = ItemUseStyleID.HoldingOut; + item.useTime = 5; + item.useAnimation = 25; + item.knockBack = 12f; + item.autoReuse = false; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Red; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 1f; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + 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 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/PhotonRipper.png b/Items/Weapons/Melee/PhotonRipper.png new file mode 100644 index 0000000000..7a425f4909 Binary files /dev/null and b/Items/Weapons/Melee/PhotonRipper.png differ diff --git a/Items/Weapons/Melee/PrismaticBreaker.cs b/Items/Weapons/Melee/PrismaticBreaker.cs index e5ccfb9e7f..da46d4a986 100644 --- a/Items/Weapons/Melee/PrismaticBreaker.cs +++ b/Items/Weapons/Melee/PrismaticBreaker.cs @@ -136,7 +136,6 @@ 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(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); @@ -148,7 +147,6 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); diff --git a/Items/Weapons/Melee/RedSun.cs b/Items/Weapons/Melee/RedSun.cs index 5a1e3f75e5..d964bc6292 100644 --- a/Items/Weapons/Melee/RedSun.cs +++ b/Items/Weapons/Melee/RedSun.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 62; item.height = 62; - item.damage = 2500; + item.damage = 500; item.melee = true; item.useTime = 5; item.reuseDelay = 20; @@ -107,9 +107,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void MeleeEffects(Player player, Rectangle hitbox) { if (Main.rand.NextBool(3)) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 64); - } + Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 64); } public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) diff --git a/Items/Weapons/Melee/RoyalKnivesMelee.cs b/Items/Weapons/Melee/RoyalKnivesMelee.cs index 5ec1b8cf86..a1121b06a9 100644 --- a/Items/Weapons/Melee/RoyalKnivesMelee.cs +++ b/Items/Weapons/Melee/RoyalKnivesMelee.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 18; - item.damage = 2000; + item.damage = 400; item.melee = true; item.noMelee = true; item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/SpineOfThanatos.cs b/Items/Weapons/Melee/SpineOfThanatos.cs new file mode 100644 index 0000000000..69b7b1c1df --- /dev/null +++ b/Items/Weapons/Melee/SpineOfThanatos.cs @@ -0,0 +1,51 @@ +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class SpineOfThanatos : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Spine of Thanatos"); + Tooltip.SetDefault("Releases 3 fast metallic whips outward\n" + + "Once all three collide, a prism of light is shot outward\n" + + "If an enemy is within the line of sight of the whips on collision, the light will fire towards it"); + } + + public override void SetDefaults() + { + item.width = item.height = 28; + item.damage = 410; + item.rare = ItemRarityID.Red; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.Calamity().customRarity = CalamityRarity.Violet; + item.noMelee = true; + item.noUseGraphic = true; + item.channel = true; + item.autoReuse = true; + item.melee = true; + item.useAnimation = item.useTime = 24; + item.useStyle = ItemUseStyleID.HoldingOut; + item.knockBack = 8f; + item.UseSound = SoundID.Item68; + item.shootSpeed = 1f; + item.shoot = ModContent.ProjectileType(); + } + + 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) + { + for (int i = 0; i < 2; i++) + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, (i == 0f).ToDirectionInt()); + + // Create a third, final whip that does not swing around at all and instead simply flies towards the mouse. + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } +} diff --git a/Items/Weapons/Melee/SpineOfThanatos.png b/Items/Weapons/Melee/SpineOfThanatos.png new file mode 100644 index 0000000000..cbac11a060 Binary files /dev/null and b/Items/Weapons/Melee/SpineOfThanatos.png differ diff --git a/Items/Weapons/Melee/Swordsplosion.cs b/Items/Weapons/Melee/Swordsplosion.cs index 3fb9b30a30..8964ea5e7a 100644 --- a/Items/Weapons/Melee/Swordsplosion.cs +++ b/Items/Weapons/Melee/Swordsplosion.cs @@ -106,7 +106,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 480); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 480); target.AddBuff(ModContent.BuffType(), 480); target.AddBuff(ModContent.BuffType(), 480); } @@ -114,7 +114,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 480); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 480); target.AddBuff(ModContent.BuffType(), 480); target.AddBuff(ModContent.BuffType(), 480); } diff --git a/Items/Weapons/Melee/TeardropCleaver.cs b/Items/Weapons/Melee/TeardropCleaver.cs index bfcbd9389d..10d49af2b4 100644 --- a/Items/Weapons/Melee/TeardropCleaver.cs +++ b/Items/Weapons/Melee/TeardropCleaver.cs @@ -33,7 +33,7 @@ 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(ModContent.BuffType(), 60); } } } diff --git a/Items/Weapons/Melee/TemporalFloeSword.cs b/Items/Weapons/Melee/TemporalFloeSword.cs index 6700d5f9b6..b5824845df 100644 --- a/Items/Weapons/Melee/TemporalFloeSword.cs +++ b/Items/Weapons/Melee/TemporalFloeSword.cs @@ -63,19 +63,13 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { - if (Main.rand.NextBool(3)) - { - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 600); } public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - if (Main.rand.NextBool(3)) - { - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 600); } } diff --git a/Items/Weapons/Melee/Terratomere.cs b/Items/Weapons/Melee/Terratomere.cs index 758599b82d..d06acaa6a6 100644 --- a/Items/Weapons/Melee/Terratomere.cs +++ b/Items/Weapons/Melee/Terratomere.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 64; - item.damage = 160; + item.damage = 260; item.melee = true; item.useAnimation = 21; item.useStyle = ItemUseStyleID.SwingThrow; @@ -80,7 +80,7 @@ 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(ModContent.BuffType(), 30); if (!target.canGhostHeal || player.moonLeech) return; @@ -92,7 +92,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitPvp(Player player, Player target, int damage, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); if (player.moonLeech) return; diff --git a/Items/Weapons/Melee/TheBurningSky.cs b/Items/Weapons/Melee/TheBurningSky.cs index 0e39b5713e..0b762aaddf 100644 --- a/Items/Weapons/Melee/TheBurningSky.cs +++ b/Items/Weapons/Melee/TheBurningSky.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 62; - item.damage = 200; + item.damage = 600; item.melee = true; item.useTime = 15; item.useAnimation = 15; diff --git a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs index 48580df177..78144a45c2 100644 --- a/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs +++ b/Items/Weapons/Melee/TriactisTruePaladinianMageHammerofMightMelee.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 160; item.height = 160; - item.damage = 10000; + item.damage = 2000; item.noMelee = true; item.noUseGraphic = true; item.autoReuse = true; diff --git a/Items/Weapons/Melee/Violence.cs b/Items/Weapons/Melee/Violence.cs new file mode 100644 index 0000000000..306590f0c4 --- /dev/null +++ b/Items/Weapons/Melee/Violence.cs @@ -0,0 +1,49 @@ +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Melee.Spears; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Melee +{ + public class Violence : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Violence"); + Tooltip.SetDefault("Releases a blazing fork which stays near the mouse and shreds enemies"); + } + + public override void SetDefaults() + { + item.height = item.width = 142; + item.damage = 204; + item.melee = true; + item.noMelee = true; + item.useTurn = true; + item.noUseGraphic = true; + item.useAnimation = 25; + item.useTime = 25; + item.useStyle = ItemUseStyleID.HoldingOut; + item.knockBack = 9f; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.channel = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 15f; + } + + public override bool CanUseItem(Player player) => player.altFunctionUse == 2 || 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) + { + Vector2 shootVelocity = new Vector2(speedX, speedY); + Projectile.NewProjectile(position, shootVelocity, type, damage, knockBack, player.whoAmI, 0f, shootVelocity.ToRotation()); + return false; + } + } +} diff --git a/Items/Weapons/Melee/Violence.png b/Items/Weapons/Melee/Violence.png new file mode 100644 index 0000000000..0946ba16ec Binary files /dev/null and b/Items/Weapons/Melee/Violence.png differ diff --git a/Items/Weapons/Ranged/AMR.cs b/Items/Weapons/Ranged/AMR.cs index 89e8b5111c..bb5728702a 100644 --- a/Items/Weapons/Ranged/AMR.cs +++ b/Items/Weapons/Ranged/AMR.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 3520; + item.damage = 3240; item.ranged = true; item.width = 76; item.height = 30; diff --git a/Items/Weapons/Ranged/AcesHigh.cs b/Items/Weapons/Ranged/AcesHigh.cs index 0f249f9cd4..8884fcf40e 100644 --- a/Items/Weapons/Ranged/AcesHigh.cs +++ b/Items/Weapons/Ranged/AcesHigh.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1599; + item.damage = 230; item.ranged = true; item.width = 48; item.height = 30; diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 6555f98a72..a04e4965b7 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 120; + item.damage = 165; item.ranged = true; item.width = 60; item.height = 90; diff --git a/Items/Weapons/Ranged/Arbalest.cs b/Items/Weapons/Ranged/Arbalest.cs index 84e4d61ad4..7cb7a5f98d 100644 --- a/Items/Weapons/Ranged/Arbalest.cs +++ b/Items/Weapons/Ranged/Arbalest.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 32; + item.damage = 36; item.ranged = true; item.width = 82; item.height = 34; diff --git a/Items/Weapons/Ranged/ArterialAssault.cs b/Items/Weapons/Ranged/ArterialAssault.cs index 0ad0be634b..2540705c3e 100644 --- a/Items/Weapons/Ranged/ArterialAssault.cs +++ b/Items/Weapons/Ranged/ArterialAssault.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 116; + item.damage = 128; item.ranged = true; item.width = 44; item.height = 100; diff --git a/Items/Weapons/Ranged/AstralRepeater.cs b/Items/Weapons/Ranged/AstralRepeater.cs index e321180af6..43525a57a8 100644 --- a/Items/Weapons/Ranged/AstralRepeater.cs +++ b/Items/Weapons/Ranged/AstralRepeater.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 90; + item.damage = 99; item.ranged = true; item.width = 38; item.height = 78; diff --git a/Items/Weapons/Ranged/AstrealDefeat.cs b/Items/Weapons/Ranged/AstrealDefeat.cs index 5cf4379c51..5dd3378fd9 100644 --- a/Items/Weapons/Ranged/AstrealDefeat.cs +++ b/Items/Weapons/Ranged/AstrealDefeat.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 139; + item.damage = 153; item.ranged = true; item.width = 40; item.height = 78; diff --git a/Items/Weapons/Ranged/Barinade.cs b/Items/Weapons/Ranged/Barinade.cs index f98abee769..df949f4a2a 100644 --- a/Items/Weapons/Ranged/Barinade.cs +++ b/Items/Weapons/Ranged/Barinade.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 8; + item.damage = 9; item.ranged = true; item.width = 30; item.height = 44; diff --git a/Items/Weapons/Ranged/Barinautical.cs b/Items/Weapons/Ranged/Barinautical.cs index 6b03d405bc..5497dd59bb 100644 --- a/Items/Weapons/Ranged/Barinautical.cs +++ b/Items/Weapons/Ranged/Barinautical.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 25; + item.damage = 28; item.ranged = true; item.width = 30; item.height = 42; diff --git a/Items/Weapons/Ranged/BladedgeGreatbow.cs b/Items/Weapons/Ranged/BladedgeGreatbow.cs index 545d583223..835e63e05b 100644 --- a/Items/Weapons/Ranged/BladedgeGreatbow.cs +++ b/Items/Weapons/Ranged/BladedgeGreatbow.cs @@ -12,12 +12,12 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Bladedge Railbow"); Tooltip.SetDefault("Fires 4 arrows at once\n" + - "Fires 2 additional leafs"); + "Fires 2 additional leaves"); } public override void SetDefaults() { - item.damage = 25; + item.damage = 28; item.ranged = true; item.width = 74; item.height = 24; @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-60, 61) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-60, 61) * 0.05f; - int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); Main.projectile[index].noDropItem = true; } Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); diff --git a/Items/Weapons/Ranged/BlossomFlux.cs b/Items/Weapons/Ranged/BlossomFlux.cs index 8368c9ad7b..76746e2800 100644 --- a/Items/Weapons/Ranged/BlossomFlux.cs +++ b/Items/Weapons/Ranged/BlossomFlux.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 22; + item.damage = 25; item.ranged = true; item.width = 38; item.height = 68; @@ -63,11 +63,11 @@ namespace CalamityMod.Items.Weapons.Ranged { if (player.altFunctionUse == 2) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)((double)damage * 4.0), knockBack * 60f, player.whoAmI, 0.0f, 0.0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 4D), knockBack * 60f, player.whoAmI); } else { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); } return false; } diff --git a/Items/Weapons/Ranged/BrimstoneFury.cs b/Items/Weapons/Ranged/BrimstoneFury.cs index 585546dc92..b2c3c43ffa 100644 --- a/Items/Weapons/Ranged/BrimstoneFury.cs +++ b/Items/Weapons/Ranged/BrimstoneFury.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 35; + item.damage = 39; item.ranged = true; item.width = 30; item.height = 58; diff --git a/Items/Weapons/Ranged/BulletFilledShotgun.cs b/Items/Weapons/Ranged/BulletFilledShotgun.cs new file mode 100644 index 0000000000..7b38b8dc0d --- /dev/null +++ b/Items/Weapons/Ranged/BulletFilledShotgun.cs @@ -0,0 +1,76 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + 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 ammo per fire\n" + + "Aim? What's that?"); + } + public override void SetDefaults() + { + item.damage = 1; + item.knockBack = 0f; + item.useTime = item.useAnimation = 45; + item.ranged = true; + item.noMelee = true; + item.autoReuse = true; + item.useAmmo = AmmoID.Bullet; + item.shootSpeed = 9f; + item.shoot = ModContent.ProjectileType(); + + item.width = 64; + item.height = 24; + item.useStyle = ItemUseStyleID.HoldingOut; + item.UseSound = SoundID.Item38; + item.value = CalamityGlobalItem.Rarity3BuyPrice; + item.rare = ItemRarityID.Orange; + item.Calamity().donorItem = true; + } + + public override Vector2? HoldoutOffset() => new Vector2(-7, 0); + + public override bool CanUseItem(Player player) => CalamityGlobalItem.HasEnoughAmmo(player, item, 5); + + // Disable vanilla ammo consumption + public override bool ConsumeAmmo(Player player) => 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) + { + type = item.shoot; + int bulletAmt = Main.rand.Next(25,35); + for (int i = 0; i < bulletAmt; i++) + { + float newSpeedX = speedX + Main.rand.NextFloat(-15f, 15f); + float newSpeedY = speedY + Main.rand.NextFloat(-15f, 15f); + Projectile.NewProjectile(position.X, position.Y, newSpeedX, newSpeedY, type, damage, knockBack, player.whoAmI); + } + + // Consume 5 ammo per shot + CalamityGlobalItem.ConsumeAdditionalAmmo(player, item, 5); + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.MusketBall, 100); + recipe.AddIngredient(ItemID.IronBar, 7); + recipe.anyIronBar = true; + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Ranged/BulletFilledShotgun.png b/Items/Weapons/Ranged/BulletFilledShotgun.png new file mode 100644 index 0000000000..2635f2a49c Binary files /dev/null and b/Items/Weapons/Ranged/BulletFilledShotgun.png differ diff --git a/Items/Weapons/Ranged/ChickenCannon.cs b/Items/Weapons/Ranged/ChickenCannon.cs index dbb9541285..9263922eb7 100644 --- a/Items/Weapons/Ranged/ChickenCannon.cs +++ b/Items/Weapons/Ranged/ChickenCannon.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 300; + item.damage = 90; item.ranged = true; item.width = 76; item.height = 24; diff --git a/Items/Weapons/Ranged/CleansingBlaze.cs b/Items/Weapons/Ranged/CleansingBlaze.cs index 658168e7df..7c691feecb 100644 --- a/Items/Weapons/Ranged/CleansingBlaze.cs +++ b/Items/Weapons/Ranged/CleansingBlaze.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 150; + item.damage = 130; item.ranged = true; item.width = 64; item.height = 32; diff --git a/Items/Weapons/Ranged/ClockworkBow.cs b/Items/Weapons/Ranged/ClockworkBow.cs index 2ea823ab10..d5cf85a26a 100644 --- a/Items/Weapons/Ranged/ClockworkBow.cs +++ b/Items/Weapons/Ranged/ClockworkBow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 60; + item.damage = 66; item.ranged = true; item.width = 34; item.height = 100; @@ -94,7 +94,7 @@ namespace CalamityMod.Items.Weapons.Ranged num79 *= num80; float speedX4 = num78 + (float)Main.rand.Next(-600, 601) * 0.01f; float speedY5 = num79 + (float)Main.rand.Next(-600, 601) * 0.01f; - int projectile = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, num73, num74, i, 0f, 0f); + int projectile = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, num73, num74, i); Main.projectile[projectile].tileCollide = false; Main.projectile[projectile].timeLeft = 240; Main.projectile[projectile].noDropItem = true; diff --git a/Items/Weapons/Ranged/Condemnation.cs b/Items/Weapons/Ranged/Condemnation.cs new file mode 100644 index 0000000000..ae59eee27d --- /dev/null +++ b/Items/Weapons/Ranged/Condemnation.cs @@ -0,0 +1,79 @@ +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class Condemnation : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Condemnation"); + Tooltip.SetDefault("Left clicks allows you to charge the repeater and release more arrows the longer the charge lasts\n" + + "Right clicks release fast moving arrows"); + } + + public override void SetDefaults() + { + item.damage = 566; + item.ranged = true; + item.width = 130; + item.height = 42; + item.useTime = item.useAnimation = 16; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 5f; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14.5f; + item.useAmmo = AmmoID.Arrow; + } + + public override Vector2? HoldoutOffset() => new Vector2(-50f, 0f); + + public override bool AltFunctionUse(Player player) => true; + + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.noUseGraphic = false; + item.UseSound = SoundID.DD2_BallistaTowerShot; + item.channel = false; + } + else + { + item.noUseGraphic = true; + item.UseSound = SoundID.Item20; + item.channel = true; + return player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + } + return base.CanUseItem(player); + } + + public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 0.7f : 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 shootVelocity = new Vector2(speedX, speedY); + Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); + + // Single arrow firing. + if (player.altFunctionUse == 2) + { + Vector2 tipPosition = position + shootDirection * 110f; + Projectile.NewProjectile(tipPosition, shootVelocity, item.shoot, damage, knockBack, player.whoAmI); + } + + // Charge-up. Done via a holdout projectile. + else + Projectile.NewProjectile(position, shootDirection, ModContent.ProjectileType(), 0, knockBack, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Ranged/Condemnation.png b/Items/Weapons/Ranged/Condemnation.png new file mode 100644 index 0000000000..09d5d3c1fb Binary files /dev/null and b/Items/Weapons/Ranged/Condemnation.png differ diff --git a/Items/Weapons/Ranged/Contagion.cs b/Items/Weapons/Ranged/Contagion.cs index 7ad7f1d945..669d33a369 100644 --- a/Items/Weapons/Ranged/Contagion.cs +++ b/Items/Weapons/Ranged/Contagion.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 4000; + item.damage = 880; item.ranged = true; item.width = 22; item.height = 50; @@ -53,7 +53,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) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0.0f, 0.0f); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); return false; } } diff --git a/Items/Weapons/Ranged/CorrodedCaustibow.cs b/Items/Weapons/Ranged/CorrodedCaustibow.cs index 945f52d4de..5c23f18ce0 100644 --- a/Items/Weapons/Ranged/CorrodedCaustibow.cs +++ b/Items/Weapons/Ranged/CorrodedCaustibow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 80; + item.damage = 88; item.ranged = true; item.width = 30; item.height = 38; diff --git a/Items/Weapons/Ranged/CosmicBolter.cs b/Items/Weapons/Ranged/CosmicBolter.cs index af5ae67f9d..068e05a682 100644 --- a/Items/Weapons/Ranged/CosmicBolter.cs +++ b/Items/Weapons/Ranged/CosmicBolter.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 35; + item.damage = 39; item.ranged = true; item.width = 40; item.height = 76; diff --git a/Items/Weapons/Ranged/DaemonsFlame.cs b/Items/Weapons/Ranged/DaemonsFlame.cs index 10e9fed762..fea2ef351e 100644 --- a/Items/Weapons/Ranged/DaemonsFlame.cs +++ b/Items/Weapons/Ranged/DaemonsFlame.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 123; + item.damage = 135; item.width = 62; item.height = 128; item.useTime = 12; diff --git a/Items/Weapons/Ranged/DarkechoGreatbow.cs b/Items/Weapons/Ranged/DarkechoGreatbow.cs index 54265c5709..d125919ff9 100644 --- a/Items/Weapons/Ranged/DarkechoGreatbow.cs +++ b/Items/Weapons/Ranged/DarkechoGreatbow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 34; + item.damage = 37; item.ranged = true; item.width = 34; item.height = 62; @@ -41,10 +41,10 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; - int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); Main.projectile[index].noDropItem = true; } - int projectile = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.CrystalDart, damage, knockBack, player.whoAmI, 0f, 0f); + int projectile = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.CrystalDart, damage / 2, knockBack, player.whoAmI); Main.projectile[projectile].penetrate = 3; return false; } diff --git a/Items/Weapons/Ranged/Deathwind.cs b/Items/Weapons/Ranged/Deathwind.cs index 36b8b1227b..11cf5186af 100644 --- a/Items/Weapons/Ranged/Deathwind.cs +++ b/Items/Weapons/Ranged/Deathwind.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 225; + item.damage = 248; item.ranged = true; item.width = 40; item.height = 82; @@ -50,11 +50,11 @@ namespace CalamityMod.Items.Weapons.Ranged 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, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); } else { - int num121 = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockBack, player.whoAmI, 0f, 0f); + int num121 = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, (int)(damage * 0.8), knockBack, player.whoAmI); Main.projectile[num121].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index 48b40c5cbc..daafd98c11 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 260; + item.damage = 200; item.ranged = true; item.width = 64; item.height = 28; diff --git a/Items/Weapons/Ranged/Drataliornus.cs b/Items/Weapons/Ranged/Drataliornus.cs index c8cac38a65..05c1402721 100644 --- a/Items/Weapons/Ranged/Drataliornus.cs +++ b/Items/Weapons/Ranged/Drataliornus.cs @@ -24,7 +24,7 @@ Right click to fire two devastating barrages of five empowered fireballs. public override void SetDefaults() { - item.damage = 700; + item.damage = 80; item.knockBack = 1f; item.shootSpeed = 18f; item.useStyle = ItemUseStyleID.HoldingOut; diff --git a/Items/Weapons/Ranged/EffluviumBow.cs b/Items/Weapons/Ranged/EffluviumBow.cs index 7f93344f01..b6ea7a4a0c 100644 --- a/Items/Weapons/Ranged/EffluviumBow.cs +++ b/Items/Weapons/Ranged/EffluviumBow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 51; + item.damage = 56; item.ranged = true; item.width = 26; item.height = 70; diff --git a/Items/Weapons/Ranged/EternalBlizzard.cs b/Items/Weapons/Ranged/EternalBlizzard.cs index b9cf8264a0..0655bc5e9f 100644 --- a/Items/Weapons/Ranged/EternalBlizzard.cs +++ b/Items/Weapons/Ranged/EternalBlizzard.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Ranged } public override void SetDefaults() { - item.damage = 73; + item.damage = 80; item.ranged = true; item.width = 38; item.height = 62; @@ -37,7 +37,7 @@ 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; - int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 0.7f), knockBack, player.whoAmI, 0f, 0f); + 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/FlarewingBow.cs b/Items/Weapons/Ranged/FlarewingBow.cs index 6ba4c06caa..6c4e1d6f48 100644 --- a/Items/Weapons/Ranged/FlarewingBow.cs +++ b/Items/Weapons/Ranged/FlarewingBow.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 15; + item.damage = 17; item.ranged = true; item.width = 20; item.height = 62; @@ -55,12 +55,12 @@ namespace CalamityMod.Items.Weapons.Ranged } if (type == ProjectileID.WoodenArrowFriendly) { - int num123 = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); + int num123 = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); Main.projectile[num123].noDropItem = true; } else { - int num123 = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); + int num123 = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); Main.projectile[num123].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/Galeforce.cs b/Items/Weapons/Ranged/Galeforce.cs index 3ab6e4f38e..07fb34fb34 100644 --- a/Items/Weapons/Ranged/Galeforce.cs +++ b/Items/Weapons/Ranged/Galeforce.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 16; + item.damage = 18; item.ranged = true; item.width = 32; item.height = 52; @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged for (int i = -8; i <= 8; i += 8) { Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.ToRadians(i)); - Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage / 4, 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position, perturbedSpeed, ModContent.ProjectileType(), damage / 4, 0f, player.whoAmI); } return true; } diff --git a/Items/Weapons/Ranged/Goobow.cs b/Items/Weapons/Ranged/Goobow.cs index 285b48b6cb..2683865d18 100644 --- a/Items/Weapons/Ranged/Goobow.cs +++ b/Items/Weapons/Ranged/Goobow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 30; + item.damage = 33; item.ranged = true; item.width = 30; item.height = 50; diff --git a/Items/Weapons/Ranged/GreatbowofTurmoil.cs b/Items/Weapons/Ranged/GreatbowofTurmoil.cs index 94ee9b1fbb..ee6f68dc88 100644 --- a/Items/Weapons/Ranged/GreatbowofTurmoil.cs +++ b/Items/Weapons/Ranged/GreatbowofTurmoil.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 31; + item.damage = 34; item.ranged = true; item.width = 18; item.height = 36; @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Ranged { type = ProjectileID.FireArrow; } - int num121 = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + int num121 = Projectile.NewProjectile(source + offset, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); Main.projectile[num121].noDropItem = true; } for (int i = 0; i < 2; i++) @@ -70,7 +70,7 @@ namespace CalamityMod.Items.Weapons.Ranged ProjectileID.HellfireArrow, ProjectileID.IchorArrow }); - int index = Projectile.NewProjectile(position, new Vector2(SpeedX, SpeedY), type, (int)(damage * 0.5f), knockBack, player.whoAmI, 0f, 0f); + 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; Main.projectile[index].localNPCHitCooldown = 10; diff --git a/Items/Weapons/Ranged/HalibutCannon.cs b/Items/Weapons/Ranged/HalibutCannon.cs index c5211b1f65..a51dfae60f 100644 --- a/Items/Weapons/Ranged/HalibutCannon.cs +++ b/Items/Weapons/Ranged/HalibutCannon.cs @@ -1,4 +1,3 @@ -using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -7,20 +6,16 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { public class HalibutCannon : ModItem - { - internal const float DropChance = 1E-5f; // 1 in 100,000 - + { public override void SetStaticDefaults() { DisplayName.SetDefault("Halibut Cannon"); - Tooltip.SetDefault("Becomes more powerful as you progress\n" + - "(Yes, it's still overpowered)\n" + - "Revengeance drop"); + Tooltip.SetDefault("Yes, it's still overpowered"); } public override void SetDefaults() { - item.damage = 12; + item.damage = 50; item.ranged = true; item.width = 108; item.height = 54; @@ -31,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.noMelee = true; item.knockBack = 1f; item.value = Item.buyPrice(1, 0, 0, 0); - item.UseSound = SoundID.Item38; + item.UseSound = null; item.autoReuse = true; item.shoot = ProjectileID.Bullet; item.shootSpeed = 12f; @@ -40,30 +35,19 @@ namespace CalamityMod.Items.Weapons.Ranged public override Vector2? HoldoutOffset() => new Vector2(-15, 0); - public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) - { - float damageMult = 0f + - (NPC.downedPlantBoss ? 0.1f : 0f) + - (NPC.downedGolemBoss ? 0.1f : 0f) + - (NPC.downedAncientCultist ? 0.2f : 0f) + - (NPC.downedMoonlord ? 1f : 0f) + - (CalamityWorld.downedProvidence ? 0.15f : 0f) + - (CalamityWorld.downedPolterghast ? 0.3f : 0f) + - (CalamityWorld.downedDoG ? 0.6f : 0f) + - (CalamityWorld.downedYharon ? 1f : 0f); - mult += damageMult; - } - 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 bulletAmt = Main.rand.Next(25, 36); + Main.PlaySound(SoundID.Item38, (int)player.Center.X, (int)player.Center.Y); + + int bulletAmt = Main.rand.Next(25, 36); for (int index = 0; index < bulletAmt; ++index) { float SpeedX = speedX + Main.rand.Next(-10, 11) * 0.05f; float SpeedY = speedY + Main.rand.Next(-10, 11) * 0.05f; - int shot = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + int shot = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); Main.projectile[shot].timeLeft = 120; } + return false; } } diff --git a/Items/Weapons/Ranged/HeavenlyGale.cs b/Items/Weapons/Ranged/HeavenlyGale.cs index 1e8d1de3c1..232861159f 100644 --- a/Items/Weapons/Ranged/HeavenlyGale.cs +++ b/Items/Weapons/Ranged/HeavenlyGale.cs @@ -2,6 +2,8 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Ranged; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -24,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 600; + item.damage = 198; item.ranged = true; item.width = 44; item.height = 58; @@ -38,7 +40,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.UseSound = SoundID.Item5; item.autoReuse = true; item.shoot = ProjectileID.WoodenArrowFriendly; - item.shootSpeed = 17f; + item.shootSpeed = 12f; item.useAmmo = AmmoID.Arrow; item.Calamity().customRarity = CalamityRarity.Violet; } @@ -46,7 +48,6 @@ 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 dmgMult = 1f; float piOver10 = MathHelper.Pi * 0.1f; int arrowAmt = 5; Vector2 speed = new Vector2(speedX, speedY); @@ -62,28 +63,45 @@ namespace CalamityMod.Items.Weapons.Ranged if (type == ProjectileID.WoodenArrowFriendly) { - int arrow = Utils.SelectRandom(Main.rand, new int[] - { - ProjectileType(), + int[] arrowTypes = new int[5] + { ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), - ProjectileType() - }); - - if (player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] > 5) + ProjectileType() + }; + int j = arrowTypes.Length; + var rng = new Random(); + while (j > 1) { - arrow = Utils.SelectRandom(Main.rand, new int[] - { - ProjectileType(), - ProjectileType(), - ProjectileType() - }); + int k = rng.Next(j--); + int randomArrow = arrowTypes[j]; + arrowTypes[j] = arrowTypes[k]; + arrowTypes[k] = randomArrow; + } + int newType = type; + switch (i) + { + case 0: + case 4: + newType = ProjectileType(); + break; + case 1: + newType = ProjectileType(); + break; + case 2: + newType = ProjectileType(); + break; + case 3: + newType = ProjectileType(); + break; } - if (arrow == ProjectileType()) + float dmgMult = 1f; + if (arrowTypes[i] == ProjectileType()) dmgMult = 0.5f; - Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, arrow, (int)(damage * dmgMult), knockBack, player.whoAmI); + Projectile.NewProjectile(source.X + offset.X, source.Y + offset.Y, speedX, speedY, arrowTypes[i], (int)(damage * dmgMult), knockBack, player.whoAmI); } else { diff --git a/Items/Weapons/Ranged/LunarianBow.cs b/Items/Weapons/Ranged/LunarianBow.cs index a906748203..b7ac84a6a4 100644 --- a/Items/Weapons/Ranged/LunarianBow.cs +++ b/Items/Weapons/Ranged/LunarianBow.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 29; + item.damage = 32; item.ranged = true; item.width = 22; item.height = 62; diff --git a/Items/Weapons/Ranged/MagnomalyCannon.cs b/Items/Weapons/Ranged/MagnomalyCannon.cs index c5c0088703..b56dc12554 100644 --- a/Items/Weapons/Ranged/MagnomalyCannon.cs +++ b/Items/Weapons/Ranged/MagnomalyCannon.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1450; + item.damage = 340; item.ranged = true; item.width = 84; item.height = 30; diff --git a/Items/Weapons/Ranged/Malevolence.cs b/Items/Weapons/Ranged/Malevolence.cs index 62e7d7bde6..5f6ad22d3b 100644 --- a/Items/Weapons/Ranged/Malevolence.cs +++ b/Items/Weapons/Ranged/Malevolence.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 51; + item.damage = 56; item.ranged = true; item.width = 36; item.height = 58; diff --git a/Items/Weapons/Ranged/MandibleBow.cs b/Items/Weapons/Ranged/MandibleBow.cs index ef54421387..1efd420107 100644 --- a/Items/Weapons/Ranged/MandibleBow.cs +++ b/Items/Weapons/Ranged/MandibleBow.cs @@ -1,7 +1,6 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -//using TerrariaOverhaul; namespace CalamityMod.Items.Weapons.Ranged { @@ -14,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 13; + item.damage = 14; item.ranged = true; item.width = 22; item.height = 40; @@ -28,13 +27,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.UseSound = SoundID.Item5; item.autoReuse = false; item.shoot = ProjectileID.PurificationPowder; - item.shootSpeed = 30f; + item.shootSpeed = 15f; item.useAmmo = AmmoID.Arrow; } - - /*public void OverhaulInit() - { - this.SetTag("bow"); - }*/ } } diff --git a/Items/Weapons/Ranged/MarksmanBow.cs b/Items/Weapons/Ranged/MarksmanBow.cs index ef39ff086c..7e1aba9f60 100644 --- a/Items/Weapons/Ranged/MarksmanBow.cs +++ b/Items/Weapons/Ranged/MarksmanBow.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 27; + item.damage = 30; item.ranged = true; item.width = 36; item.height = 110; @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Ranged 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, 0f, 0f); + 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) diff --git a/Items/Weapons/Ranged/Megafleet.cs b/Items/Weapons/Ranged/Megafleet.cs index 9813ee6a42..8ab31a915b 100644 --- a/Items/Weapons/Ranged/Megafleet.cs +++ b/Items/Weapons/Ranged/Megafleet.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1000; + item.damage = 200; item.ranged = true; item.width = 96; item.height = 38; diff --git a/Items/Weapons/Ranged/Monsoon.cs b/Items/Weapons/Ranged/Monsoon.cs index bfe974a56c..b83678ce00 100644 --- a/Items/Weapons/Ranged/Monsoon.cs +++ b/Items/Weapons/Ranged/Monsoon.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 110; + item.damage = 121; item.ranged = true; item.width = 46; item.height = 78; diff --git a/Items/Weapons/Ranged/NettlelineGreatbow.cs b/Items/Weapons/Ranged/NettlelineGreatbow.cs index 9e484532a9..12e903e8e3 100644 --- a/Items/Weapons/Ranged/NettlelineGreatbow.cs +++ b/Items/Weapons/Ranged/NettlelineGreatbow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 66; + item.damage = 73; item.ranged = true; item.width = 36; item.height = 64; @@ -53,7 +53,7 @@ namespace CalamityMod.Items.Weapons.Ranged { value9 -= vector7; } - int num121 = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + int num121 = Projectile.NewProjectile(vector2.X + value9.X, vector2.Y + value9.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); Main.projectile[num121].noDropItem = true; } for (int i = 0; i < 2; i++) @@ -71,7 +71,7 @@ namespace CalamityMod.Items.Weapons.Ranged default: break; } - int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f); + int index = Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI); Main.projectile[index].noDropItem = true; } return false; diff --git a/Items/Weapons/Ranged/Onyxia.cs b/Items/Weapons/Ranged/Onyxia.cs index cc892f3077..49eb1c93ca 100644 --- a/Items/Weapons/Ranged/Onyxia.cs +++ b/Items/Weapons/Ranged/Onyxia.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.ranged = true; item.width = 84; item.height = 34; - item.useTime = item.useAnimation = 7; + item.useTime = item.useAnimation = 10; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 4.5f; diff --git a/Items/Weapons/Ranged/PearlGod.cs b/Items/Weapons/Ranged/PearlGod.cs index 4b19f9360e..09058c828c 100644 --- a/Items/Weapons/Ranged/PearlGod.cs +++ b/Items/Weapons/Ranged/PearlGod.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 100; + item.damage = 125; item.ranged = true; item.width = 80; item.height = 46; diff --git a/Items/Weapons/Ranged/Phangasm.cs b/Items/Weapons/Ranged/Phangasm.cs index 7be777a21e..443615e0cd 100644 --- a/Items/Weapons/Ranged/Phangasm.cs +++ b/Items/Weapons/Ranged/Phangasm.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 125; + item.damage = 110; item.width = 20; item.height = 12; item.useTime = 12; diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index 227f542619..3193e384ae 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class Photoviscerator : ModItem { public const int CooldownTime = 60 * 7; // 7 second cooldown. - public const double AltFireDamageMult = 4.27; + public const double AltFireDamageMult = 2.5; public override void SetStaticDefaults() { @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 250; + item.damage = 75; item.ranged = true; item.width = 84; item.height = 30; diff --git a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs index 613c13324a..cac500b1b0 100644 --- a/Items/Weapons/Ranged/PlanetaryAnnihilation.cs +++ b/Items/Weapons/Ranged/PlanetaryAnnihilation.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 53; + item.damage = 58; item.ranged = true; item.width = 58; item.height = 102; @@ -96,7 +96,7 @@ namespace CalamityMod.Items.Weapons.Ranged { float speedX4 = num78 + Main.rand.Next(-120, 121) * 0.02f; float speedY5 = num79 + Main.rand.Next(-120, 121) * 0.02f; - int num121 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockBack, player.whoAmI, 0f, 0f); + int num121 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockBack, player.whoAmI); Main.projectile[num121].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/RaidersGlory.cs b/Items/Weapons/Ranged/RaidersGlory.cs index 8f1a6ee389..e9455cec62 100644 --- a/Items/Weapons/Ranged/RaidersGlory.cs +++ b/Items/Weapons/Ranged/RaidersGlory.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 40; + item.damage = 44; item.ranged = true; item.width = 50; item.height = 22; @@ -39,7 +39,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) { - int projectile = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.IchorArrow, damage, knockBack, player.whoAmI, 0f, 0f); + int projectile = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ProjectileID.IchorArrow, damage, knockBack, player.whoAmI); Main.projectile[projectile].extraUpdates++; return false; } diff --git a/Items/Weapons/Ranged/Seabow.cs b/Items/Weapons/Ranged/Seabow.cs index 3885ee3097..88ea30d220 100644 --- a/Items/Weapons/Ranged/Seabow.cs +++ b/Items/Weapons/Ranged/Seabow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 11; + item.damage = 12; item.ranged = true; item.width = 22; item.height = 46; @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Ranged { float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f; float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f; - Projectile.NewProjectile(position.X, position.Y, SpeedX * 0.5f, SpeedY * 0.5f, ModContent.ProjectileType(), (int)((double)damage * 0.4), 0f, player.whoAmI, 0f, 0f); + Projectile.NewProjectile(position.X, position.Y, SpeedX * 0.5f, SpeedY * 0.5f, ModContent.ProjectileType(), (int)(damage * 0.4), 0f, player.whoAmI); return true; } diff --git a/Items/Weapons/Ranged/Shellshooter.cs b/Items/Weapons/Ranged/Shellshooter.cs index d76e7cdcbc..3239ae9374 100644 --- a/Items/Weapons/Ranged/Shellshooter.cs +++ b/Items/Weapons/Ranged/Shellshooter.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 30; + item.damage = 33; item.ranged = true; item.width = 30; item.height = 38; diff --git a/Items/Weapons/Ranged/Skullmasher.cs b/Items/Weapons/Ranged/Skullmasher.cs index 518ec98cc7..bbf4b19e9e 100644 --- a/Items/Weapons/Ranged/Skullmasher.cs +++ b/Items/Weapons/Ranged/Skullmasher.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 924; + item.damage = 1100; item.ranged = true; item.width = 142; item.height = 40; diff --git a/Items/Weapons/Ranged/SomaPrime.cs b/Items/Weapons/Ranged/SomaPrime.cs index 5ab2eb98e5..b04090c06e 100644 --- a/Items/Weapons/Ranged/SomaPrime.cs +++ b/Items/Weapons/Ranged/SomaPrime.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1000; + item.damage = 200; item.ranged = true; item.width = 94; item.height = 34; diff --git a/Items/Weapons/Ranged/SpectralstormCannon.cs b/Items/Weapons/Ranged/SpectralstormCannon.cs index 861a381a26..de9976da87 100644 --- a/Items/Weapons/Ranged/SpectralstormCannon.cs +++ b/Items/Weapons/Ranged/SpectralstormCannon.cs @@ -57,7 +57,7 @@ namespace CalamityMod.Items.Weapons.Ranged 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); + 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; diff --git a/Items/Weapons/Ranged/SpectreRifle.cs b/Items/Weapons/Ranged/SpectreRifle.cs index 9433cdd22a..fb6d7094d7 100644 --- a/Items/Weapons/Ranged/SpectreRifle.cs +++ b/Items/Weapons/Ranged/SpectreRifle.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Ranged item.UseSound = SoundID.Item40; item.autoReuse = false; item.shoot = ProjectileID.LostSoulFriendly; - item.shootSpeed = 24f; + item.shootSpeed = 12f; item.useAmmo = AmmoID.Bullet; } @@ -44,8 +44,9 @@ namespace CalamityMod.Items.Weapons.Ranged { if (type == ProjectileID.Bullet) { - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + 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); diff --git a/Items/Weapons/Ranged/StarfleetMK2.cs b/Items/Weapons/Ranged/StarfleetMK2.cs index cd793b98fd..0e71a2c4b9 100644 --- a/Items/Weapons/Ranged/StarfleetMK2.cs +++ b/Items/Weapons/Ranged/StarfleetMK2.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 145; + item.damage = 135; item.knockBack = 15f; item.shootSpeed = 16f; item.useStyle = ItemUseStyleID.HoldingOut; diff --git a/Items/Weapons/Ranged/SurgeDriver.cs b/Items/Weapons/Ranged/SurgeDriver.cs new file mode 100644 index 0000000000..f3e8ed0a68 --- /dev/null +++ b/Items/Weapons/Ranged/SurgeDriver.cs @@ -0,0 +1,87 @@ +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class SurgeDriver : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Surge Driver"); + Tooltip.SetDefault("Left clicks release a laser ray that explodes on collision\n" + + "Right clicks release a barrage of laser beams that release homing energy on enemy hits"); + } + + public override void SetDefaults() + { + item.damage = 156; + item.ranged = true; + item.width = 164; + item.height = 58; + item.useTime = item.useAnimation = 56; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 8f; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 11f; + item.useAmmo = AmmoID.Bullet; + } + + public override Vector2? HoldoutOffset() => new Vector2(-50f, -8f); + + public override bool AltFunctionUse(Player player) => true; + + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse == 2) + { + item.noUseGraphic = false; + item.reuseDelay = 0; + item.UseSound = SoundID.Item14; + item.channel = false; + } + else + { + item.noUseGraphic = true; + item.reuseDelay = 28; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"); + item.channel = true; + return player.ownedProjectileCounts[ModContent.ProjectileType()] <= 0; + } + return base.CanUseItem(player); + } + + public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 5f : 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 shootVelocity = new Vector2(speedX, speedY); + Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); + Vector2 gunTip = position + shootDirection * item.scale * 126f; + gunTip.Y -= 6f; + + // Large bullet/rocket releasing. + if (player.altFunctionUse == 2) + { + for (int i = 0; i < 2; i++) + { + Vector2 newShootVelocity = shootVelocity * Main.rand.NextFloat(1f, 1.45f); + newShootVelocity = newShootVelocity.RotatedByRandom(0.15f); + Projectile.NewProjectile(gunTip, newShootVelocity, item.shoot, damage, knockBack, player.whoAmI); + } + } + + // Snipe blast. Done via a held projectile. + else + Projectile.NewProjectile(gunTip, shootVelocity, ModContent.ProjectileType(), 0, knockBack, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Ranged/SurgeDriver.png b/Items/Weapons/Ranged/SurgeDriver.png new file mode 100644 index 0000000000..12d9fe4928 Binary files /dev/null and b/Items/Weapons/Ranged/SurgeDriver.png differ diff --git a/Items/Weapons/Ranged/Svantechnical.cs b/Items/Weapons/Ranged/Svantechnical.cs index be0b0dc2bf..8945b125ce 100644 --- a/Items/Weapons/Ranged/Svantechnical.cs +++ b/Items/Weapons/Ranged/Svantechnical.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 720; + item.damage = 150; item.ranged = true; item.width = 60; item.height = 26; diff --git a/Items/Weapons/Ranged/TelluricGlare.cs b/Items/Weapons/Ranged/TelluricGlare.cs index e73b4c60e5..6d0280ffd7 100644 --- a/Items/Weapons/Ranged/TelluricGlare.cs +++ b/Items/Weapons/Ranged/TelluricGlare.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 160; + item.damage = 176; item.ranged = true; item.width = 54; item.height = 92; diff --git a/Items/Weapons/Ranged/TheBallista.cs b/Items/Weapons/Ranged/TheBallista.cs index 580fe39378..947b4357db 100644 --- a/Items/Weapons/Ranged/TheBallista.cs +++ b/Items/Weapons/Ranged/TheBallista.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 90; + item.damage = 99; item.ranged = true; item.width = 40; item.height = 70; diff --git a/Items/Weapons/Ranged/TheJailor.cs b/Items/Weapons/Ranged/TheJailor.cs new file mode 100644 index 0000000000..88451afad2 --- /dev/null +++ b/Items/Weapons/Ranged/TheJailor.cs @@ -0,0 +1,49 @@ +using CalamityMod.Projectiles.Ranged; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Ranged +{ + public class TheJailor : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Jailor"); + Tooltip.SetDefault("Releases electric mines outward that connect to each-other via arcs"); + } + + public override void SetDefaults() + { + item.damage = 360; + item.ranged = true; + item.width = 102; + item.height = 70; + item.useTime = item.useAnimation = 28; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 8f; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = SoundID.Item14; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 11f; + item.useAmmo = AmmoID.Bullet; + } + + public override Vector2? HoldoutOffset() => new Vector2(-40f, -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) + { + Vector2 shootVelocity = new Vector2(speedX, speedY); + Vector2 shootDirection = shootVelocity.SafeNormalize(Vector2.UnitX * player.direction); + Vector2 gunTip = position + shootDirection * item.scale * 45f; + + Projectile.NewProjectile(gunTip, shootVelocity, item.shoot, damage, knockBack, player.whoAmI); + return false; + } + } +} diff --git a/Items/Weapons/Ranged/TheJailor.png b/Items/Weapons/Ranged/TheJailor.png new file mode 100644 index 0000000000..fe3c9379ec Binary files /dev/null and b/Items/Weapons/Ranged/TheJailor.png differ diff --git a/Items/Weapons/Ranged/TheStorm.cs b/Items/Weapons/Ranged/TheStorm.cs index 3caceec9a9..21453f6289 100644 --- a/Items/Weapons/Ranged/TheStorm.cs +++ b/Items/Weapons/Ranged/TheStorm.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 22; + item.damage = 24; item.ranged = true; item.width = 34; item.height = 50; @@ -87,17 +87,17 @@ namespace CalamityMod.Items.Weapons.Ranged float speedY5 = num79 + (float)Main.rand.Next(-120, 121) * 0.01f; if (type == ProjectileID.WoodenArrowFriendly) { - Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, ModContent.ProjectileType(), damage, num74, i, 0f, 0f); - Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, ModContent.ProjectileType(), damage, num74, i, 0f, 0f); - Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.7f, ModContent.ProjectileType(), damage, num74, i, 0f, 0f); + Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, ModContent.ProjectileType(), damage, num74, i); + Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, ModContent.ProjectileType(), damage, num74, i); + Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.7f, ModContent.ProjectileType(), damage, num74, i); } else { - int num121 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, type, damage, num74, i, 0f, 0f); + int num121 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.9f, type, damage, num74, i); Main.projectile[num121].noDropItem = true; - int num122 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, type, damage, num74, i, 0f, 0f); + int num122 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.8f, type, damage, num74, i); Main.projectile[num122].noDropItem = true; - int num123 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.7f, type, damage, num74, i, 0f, 0f); + int num123 = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5 * 0.7f, type, damage, num74, i); Main.projectile[num123].noDropItem = true; } } diff --git a/Items/Weapons/Ranged/Toxibow.cs b/Items/Weapons/Ranged/Toxibow.cs index 8e04d265c1..54d92d0889 100644 --- a/Items/Weapons/Ranged/Toxibow.cs +++ b/Items/Weapons/Ranged/Toxibow.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 8; + item.damage = 9; item.ranged = true; item.width = 20; item.height = 54; diff --git a/Items/Weapons/Ranged/TyrannysEnd.cs b/Items/Weapons/Ranged/TyrannysEnd.cs index 933f26a7b9..2506f776bb 100644 --- a/Items/Weapons/Ranged/TyrannysEnd.cs +++ b/Items/Weapons/Ranged/TyrannysEnd.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 4200; + item.damage = 2250; item.knockBack = 9.5f; item.ranged = true; item.useTime = 55; diff --git a/Items/Weapons/Ranged/Ultima.cs b/Items/Weapons/Ranged/Ultima.cs index 4f555aaf8d..19d0b237cf 100644 --- a/Items/Weapons/Ranged/Ultima.cs +++ b/Items/Weapons/Ranged/Ultima.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 85; + item.damage = 116; item.ranged = true; item.width = 44; item.height = 58; diff --git a/Items/Weapons/Ranged/WulfrumBow.cs b/Items/Weapons/Ranged/WulfrumBow.cs index 232004bc1d..1660639d10 100644 --- a/Items/Weapons/Ranged/WulfrumBow.cs +++ b/Items/Weapons/Ranged/WulfrumBow.cs @@ -2,7 +2,6 @@ using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; using Terraria.ModLoader; -//using TerrariaOverhaul; namespace CalamityMod.Items.Weapons.Ranged { @@ -15,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 10; + item.damage = 11; item.ranged = true; item.width = 27; item.height = 38; @@ -33,11 +32,6 @@ namespace CalamityMod.Items.Weapons.Ranged item.useAmmo = AmmoID.Arrow; } - /*public void OverhaulInit() - { - this.SetTag("bow"); - }*/ - public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Items/Weapons/Rogue/Celestus.cs b/Items/Weapons/Rogue/Celestus.cs index 20953e8a1a..af511ced9e 100644 --- a/Items/Weapons/Rogue/Celestus.cs +++ b/Items/Weapons/Rogue/Celestus.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { - item.damage = 1130; + item.damage = 272; item.knockBack = 6f; item.useAnimation = item.useTime = 20; item.Calamity().rogue = true; @@ -41,7 +41,7 @@ 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); + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, (int)(damage * 0.65), knockBack, player.whoAmI); if (stealth.WithinBounds(Main.maxProjectiles)) Main.projectile[stealth].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/CorpusAvertor.cs b/Items/Weapons/Rogue/CorpusAvertor.cs index 85cc695c66..ff44328602 100644 --- a/Items/Weapons/Rogue/CorpusAvertor.cs +++ b/Items/Weapons/Rogue/CorpusAvertor.cs @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Weapons.Rogue } // Gains 10% of missing health as base damage. - public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + 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(); diff --git a/Items/Weapons/Rogue/CosmicKunai.cs b/Items/Weapons/Rogue/CosmicKunai.cs index b4843872dd..59dd4e0c13 100644 --- a/Items/Weapons/Rogue/CosmicKunai.cs +++ b/Items/Weapons/Rogue/CosmicKunai.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Rogue int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); if (player.Calamity().StealthStrikeAvailable() && player.ownedProjectileCounts[ModContent.ProjectileType()] < 10 && counter == 0 && stealth.WithinBounds(Main.maxProjectiles)) { - damage = (int)(damage * 1.07); + damage = (int)(damage * 3.21); Main.projectile[stealth].Calamity().stealthStrike = true; Main.PlaySound(SoundID.Item73, player.position); for (float i = 0; i < 5; i++) diff --git a/Items/Weapons/Rogue/DeepSeaDumbbell.cs b/Items/Weapons/Rogue/DeepSeaDumbbell.cs index 7affbff433..652f1c21c7 100644 --- a/Items/Weapons/Rogue/DeepSeaDumbbell.cs +++ b/Items/Weapons/Rogue/DeepSeaDumbbell.cs @@ -65,9 +65,9 @@ namespace CalamityMod.Items.Weapons.Rogue return base.CanUseItem(player); } - public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 5f / 9f : 1f; + public override float SafeSetUseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 5f / 9f : 1f; - public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + public override void SafeModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { mult += flexMult - 1f; } @@ -86,7 +86,10 @@ namespace CalamityMod.Items.Weapons.Rogue return false; } - int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, 0f); + if (player.Calamity().StealthStrikeAvailable()) + damage = (int)(damage * 1.3); + + 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; diff --git a/Items/Weapons/Rogue/DukesDecapitator.cs b/Items/Weapons/Rogue/DukesDecapitator.cs index 43aff6047f..632515a33c 100644 --- a/Items/Weapons/Rogue/DukesDecapitator.cs +++ b/Items/Weapons/Rogue/DukesDecapitator.cs @@ -2,6 +2,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Rogue { @@ -34,5 +35,13 @@ namespace CalamityMod.Items.Weapons.Rogue 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) + { + 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/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index 0fe299846b..39f4604d36 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { - item.damage = 512; + item.damage = 564; item.knockBack = 3.5f; item.useAnimation = item.useTime = 21; item.autoReuse = true; @@ -40,10 +40,7 @@ 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()) - { type = ModContent.ProjectileType(); - damage = (int)(damage * 0.6); - } int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); if (proj.WithinBounds(Main.maxProjectiles)) @@ -57,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Rogue recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Weapons/Rogue/Eradicator.cs b/Items/Weapons/Rogue/Eradicator.cs index 9eb4c37fac..709098ebd9 100644 --- a/Items/Weapons/Rogue/Eradicator.cs +++ b/Items/Weapons/Rogue/Eradicator.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 38; - item.damage = 257; + item.damage = 270; item.noMelee = true; item.noUseGraphic = true; item.autoReuse = true; @@ -39,6 +39,9 @@ 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()) + damage = (int)(damage * 0.4); + int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) { diff --git a/Items/Weapons/Rogue/ExecutionersBlade.cs b/Items/Weapons/Rogue/ExecutionersBlade.cs index 4a23b4dd1d..050935ff19 100644 --- a/Items/Weapons/Rogue/ExecutionersBlade.cs +++ b/Items/Weapons/Rogue/ExecutionersBlade.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 64; - item.damage = 181; + item.damage = 200; item.noMelee = true; item.noUseGraphic = true; item.useTime = 3; @@ -57,11 +57,13 @@ 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 (player.Calamity().StealthStrikeAvailable() && counter == 0 && stealth.WithinBounds(Main.maxProjectiles)) - { + bool usingStealth = player.Calamity().StealthStrikeAvailable() && counter == 0; + if (usingStealth) + damage = (int)(damage * 3.61); + + int stealth = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + if (usingStealth && stealth.WithinBounds(Main.maxProjectiles)) Main.projectile[stealth].Calamity().stealthStrike = true; - } counter++; if (counter >= item.useAnimation / item.useTime) diff --git a/Items/Weapons/Rogue/FinalDawn.cs b/Items/Weapons/Rogue/FinalDawn.cs index 90ca33a3f1..e8f4f344ce 100644 --- a/Items/Weapons/Rogue/FinalDawn.cs +++ b/Items/Weapons/Rogue/FinalDawn.cs @@ -16,9 +16,10 @@ namespace CalamityMod.Items.Weapons.Rogue "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 = 5000; + item.damage = 1500; item.Calamity().rogue = true; item.width = 78; item.height = 66; @@ -38,6 +39,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.channel = true; item.noUseGraphic = true; } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] + player.ownedProjectileCounts[ProjectileType()] + player.ownedProjectileCounts[ProjectileType()] + diff --git a/Items/Weapons/Rogue/GhoulishGouger.cs b/Items/Weapons/Rogue/GhoulishGouger.cs index 7a2f600c95..e3ae13baf5 100644 --- a/Items/Weapons/Rogue/GhoulishGouger.cs +++ b/Items/Weapons/Rogue/GhoulishGouger.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Rogue { DisplayName.SetDefault("Ghoulish Gouger"); Tooltip.SetDefault("Throws sets of four ghoulish scythes at ultra high velocity\n" + - "Stealth strikes spawn tormented souls on hit"); + "Stealth strikes summon a flurry of tormented souls on hit"); } public override void SafeSetDefaults() diff --git a/Items/Weapons/Rogue/GodsParanoia.cs b/Items/Weapons/Rogue/GodsParanoia.cs index 09ed7d02bc..6314525c45 100644 --- a/Items/Weapons/Rogue/GodsParanoia.cs +++ b/Items/Weapons/Rogue/GodsParanoia.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.Rogue { public class GodsParanoia : RogueWeapon { - private static int damage = 91; + private static int damage = 98; private static int knockBack = 5; public override void SetStaticDefaults() @@ -69,6 +69,7 @@ Right click to delete all existing spiky balls"); modPlayer.killSpikyBalls = false; if (modPlayer.StealthStrikeAvailable()) //setting the stealth strike { + damage = (int)(damage * 1.345); 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; diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index 3caaa16183..ddd8c0c2d6 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -7,13 +7,16 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Rogue { - public class Hypothermia : RogueWeapon + public class Hypothermia : RogueWeapon { + // For more consistent DPS, always alternates between throwing 1 and 2 instead of picking randomly + private bool throwTwo = true; + public override void SetStaticDefaults() { DisplayName.SetDefault("Hypothermia"); - Tooltip.SetDefault("Fires a constant barrage of black ice shards\n" + - "Stealth strikes additionally fire a short ranged ice chunk that shatters into ice shards"); + Tooltip.SetDefault("Throws a constant barrage of black ice shards\n" + + "Stealth strikes hurl a set of razor sharp ice chunks that shatter on impact"); } public override void SafeSetDefaults() @@ -24,11 +27,11 @@ namespace CalamityMod.Items.Weapons.Rogue item.noUseGraphic = true; item.noMelee = true; item.useStyle = ItemUseStyleID.SwingThrow; - item.UseSound = SoundID.Item9; + item.UseSound = SoundID.Item7; item.value = Item.buyPrice(1, 80, 0, 0); item.rare = ItemRarityID.Red; - item.damage = 195; + item.damage = 200; item.useAnimation = 21; item.useTime = 3; item.reuseDelay = 1; @@ -40,27 +43,37 @@ 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) { if (player.Calamity().StealthStrikeAvailable()) - damage = (int)(damage * 1.55); + { + int stealthDamage = (int)(damage * 1.2f); + for (int i = 0; i < 4; ++i) + { + Vector2 chunkVelocity = new Vector2(speedX, speedY).RotatedByRandom(0.07f) * Main.rand.NextFloat(1.1f, 1.18f); + int stealth = Projectile.NewProjectile(position, chunkVelocity, ModContent.ProjectileType(), stealthDamage, knockBack, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + } - if (player.Calamity().StealthStrikeAvailable() && player.itemAnimation == item.useAnimation - 1) //setting up the stealth strikes - { - 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; + // On a stealth strike, only the chunks are thrown. + return false; + } + + // Regular attacks alternate between throwing one and two shards at a time. + int projAmt = throwTwo ? 2 : 1; + throwTwo = !throwTwo; + + for (int i = 0; i < projAmt; ++i) + { + float SpeedX = speedX + Main.rand.NextFloat(-2f, 2f); + float SpeedY = speedY + Main.rand.NextFloat(-2f, 2f); + int texID = Main.rand.Next(4); + Projectile.NewProjectile(position, new Vector2(SpeedX, SpeedY), type, damage, knockBack, player.whoAmI, texID, 0f); } - int projAmt = Main.rand.Next(1, 3); - for (int index = 0; index < projAmt; ++index) - { - float SpeedX = speedX + Main.rand.NextFloat(-2f, 2f); - float SpeedY = speedY + Main.rand.NextFloat(-2f, 2f); - Projectile.NewProjectile(position, new Vector2(SpeedX, SpeedY), type, damage, knockBack, player.whoAmI, Main.rand.Next(4), 0f); - } return false; } diff --git a/Items/Weapons/Rogue/JawsOfOblivion.cs b/Items/Weapons/Rogue/JawsOfOblivion.cs index daa85d4e50..f0e3ca3140 100644 --- a/Items/Weapons/Rogue/JawsOfOblivion.cs +++ b/Items/Weapons/Rogue/JawsOfOblivion.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { - int p = Projectile.NewProjectile(position, currentDirection, type, damage, knockBack + 6f, player.whoAmI); + int p = Projectile.NewProjectile(position, currentDirection, type, (int)(damage * 1.8), knockBack + 6f, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/LeonidProgenitor.cs b/Items/Weapons/Rogue/LeonidProgenitor.cs index c536072ecf..f9c4b2476c 100644 --- a/Items/Weapons/Rogue/LeonidProgenitor.cs +++ b/Items/Weapons/Rogue/LeonidProgenitor.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Rogue return base.CanUseItem(player); } - public override float UseTimeMultiplier (Player player) + public override float SafeSetUseTimeMultiplier(Player player) { if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse != 2) return 1f; diff --git a/Items/Weapons/Rogue/LuminousStriker.cs b/Items/Weapons/Rogue/LuminousStriker.cs index 6cb5770e69..c4e48f7c47 100644 --- a/Items/Weapons/Rogue/LuminousStriker.cs +++ b/Items/Weapons/Rogue/LuminousStriker.cs @@ -3,6 +3,7 @@ using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Rogue { @@ -37,6 +38,14 @@ namespace CalamityMod.Items.Weapons.Rogue 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 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; + } + public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); diff --git a/Items/Weapons/Rogue/Malachite.cs b/Items/Weapons/Rogue/Malachite.cs index 89fef5abd9..b82323811f 100644 --- a/Items/Weapons/Rogue/Malachite.cs +++ b/Items/Weapons/Rogue/Malachite.cs @@ -59,7 +59,7 @@ namespace CalamityMod.Items.Weapons.Rogue return base.CanUseItem(player); } - public override float UseTimeMultiplier (Player player) + public override float SafeSetUseTimeMultiplier(Player player) { if (player.Calamity().StealthStrikeAvailable() || player.altFunctionUse == 2) return 1f; diff --git a/Items/Weapons/Rogue/NanoblackReaperRogue.cs b/Items/Weapons/Rogue/NanoblackReaperRogue.cs index 7a44b402e4..4630e9d635 100644 --- a/Items/Weapons/Rogue/NanoblackReaperRogue.cs +++ b/Items/Weapons/Rogue/NanoblackReaperRogue.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.Rogue { public class NanoblackReaperRogue : RogueWeapon { - public static int BaseDamage = 500; + public static int BaseDamage = 100; public static float Knockback = 9f; public static float Speed = 16f; diff --git a/Items/Weapons/Rogue/NightsGaze.cs b/Items/Weapons/Rogue/NightsGaze.cs index 63b41e949f..ba3a074909 100644 --- a/Items/Weapons/Rogue/NightsGaze.cs +++ b/Items/Weapons/Rogue/NightsGaze.cs @@ -44,6 +44,7 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { + damage = (int)(damage * 1.22); 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; diff --git a/Items/Weapons/Rogue/Penumbra.cs b/Items/Weapons/Rogue/Penumbra.cs index b563c239cb..afb2183f5e 100644 --- a/Items/Weapons/Rogue/Penumbra.cs +++ b/Items/Weapons/Rogue/Penumbra.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Rogue item.value = Item.buyPrice(1, 80, 0, 0); item.rare = ItemRarityID.Red; - item.damage = 983; + item.damage = 1008; item.useAnimation = 40; item.useTime = 40; item.knockBack = 8f; diff --git a/Items/Weapons/Rogue/PhantasmalRuin.cs b/Items/Weapons/Rogue/PhantasmalRuin.cs index edb6b28409..5381430c3c 100644 --- a/Items/Weapons/Rogue/PhantasmalRuin.cs +++ b/Items/Weapons/Rogue/PhantasmalRuin.cs @@ -43,6 +43,7 @@ Stealth strikes continuously leave spectral clones in their wake"); { if (player.Calamity().StealthStrikeAvailable()) { + damage = (int)(damage * 1.22); 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; diff --git a/Items/Weapons/Rogue/ProfanedTrident.cs b/Items/Weapons/Rogue/ProfanedTrident.cs index a7ffa0d01e..989447ddb2 100644 --- a/Items/Weapons/Rogue/ProfanedTrident.cs +++ b/Items/Weapons/Rogue/ProfanedTrident.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 72; - item.damage = 1000; + item.damage = 700; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 13; @@ -38,6 +38,9 @@ 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()) + damage = (int)(damage * 0.6); + 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(); diff --git a/Items/Weapons/Rogue/RefractionRotor.cs b/Items/Weapons/Rogue/RefractionRotor.cs new file mode 100644 index 0000000000..16b39952a0 --- /dev/null +++ b/Items/Weapons/Rogue/RefractionRotor.cs @@ -0,0 +1,48 @@ +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + public class RefractionRotor : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Refraction Rotor"); + Tooltip.SetDefault("Fires a large prismatic razorblade\n" + + "After hitting something, the blade dies moments later\n" + + "The blade explodes into rockets on death\n" + + "Stealth strikes explode into more rockets on death"); + } + + public override void SafeSetDefaults() + { + item.width = item.height = 120; + item.damage = 110; + item.knockBack = 8.5f; + item.useAnimation = item.useTime = 14; + 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; + } + + 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 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/RefractionRotor.png b/Items/Weapons/Rogue/RefractionRotor.png new file mode 100644 index 0000000000..9b945f0278 Binary files /dev/null and b/Items/Weapons/Rogue/RefractionRotor.png differ diff --git a/Items/Weapons/Rogue/RogueWeapon.cs b/Items/Weapons/Rogue/RogueWeapon.cs index 673086e141..71498bbd17 100644 --- a/Items/Weapons/Rogue/RogueWeapon.cs +++ b/Items/Weapons/Rogue/RogueWeapon.cs @@ -1,3 +1,4 @@ +using CalamityMod.CalPlayer; using System; using System.Collections.Generic; using System.Linq; @@ -13,17 +14,17 @@ namespace CalamityMod.Items.Weapons.Rogue { } - public float StealthStrikeDamage; + public float StealthStrikePrefixBonus; public RogueWeapon() { - StealthStrikeDamage = 1f; + StealthStrikePrefixBonus = 1f; } public override ModItem Clone(Item itemClone) { RogueWeapon myClone = (RogueWeapon)base.Clone(itemClone); - myClone.StealthStrikeDamage = StealthStrikeDamage; + myClone.StealthStrikePrefixBonus = StealthStrikePrefixBonus; return myClone; } @@ -51,7 +52,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool NewPreReforge() { - StealthStrikeDamage = 1f; + StealthStrikePrefixBonus = 1f; return true; } @@ -74,19 +75,25 @@ namespace CalamityMod.Items.Weapons.Rogue item.summon = false; } - // Simply add the player's dedicated rogue damage. + // 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 override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) + public sealed override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat) { - add += player.Calamity().throwingDamage - 1f; - //Boost (or lower) the weapon's damage if it has a stealth strike available and an associated prefix - if (player.Calamity().StealthStrikeAvailable() && item.prefix > 0) - { - mult += StealthStrikeDamage - 1f; - } + CalamityPlayer mp = player.Calamity(); + + 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; + + // 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) { } + // 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) @@ -94,9 +101,10 @@ namespace CalamityMod.Items.Weapons.Rogue crit += player.Calamity().throwingCrit; } - public override float UseTimeMultiplier(Player player) + public sealed override float UseTimeMultiplier(Player player) { - float rogueAS = 1f; + float baseMultiplier = SafeSetUseTimeMultiplier(player); + float rogueAS = baseMultiplier == -1f ? 1f : baseMultiplier; if (player.Calamity().gloveOfPrecision) rogueAS -= 0.2f; if (player.Calamity().gloveOfRecklessness) @@ -106,35 +114,46 @@ namespace CalamityMod.Items.Weapons.Rogue return rogueAS; } + public virtual float SafeSetUseTimeMultiplier(Player player) => -1f; + public override void ModifyTooltips(List tooltips) { - TooltipLine tt = tooltips.FirstOrDefault(x => x.Name == "Damage" && x.mod == "Terraria"); - if (tt != null) + TooltipLine damageTooltip = tooltips.FirstOrDefault(x => x.Name == "Damage" && x.mod == "Terraria"); + if (damageTooltip != null) { - string[] splitText = tt.text.Split(' '); - string damageValue = splitText.First(); - string damageWord = splitText.Last(); - tt.text = damageValue + " rogue " + damageWord; + // 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(' '); + 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"; + } + + 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 = StealthStrikeDamage - 1f; - if (ssDmgBoost > 0) + float ssDmgBoost = StealthStrikePrefixBonus - 1f; + if (ssDmgBoost != 0f) { - TooltipLine StealthBonus = new TooltipLine(mod, "PrefixSSDmg", "+" + Math.Round(ssDmgBoost * 100f) + "% stealth strike damage") - { - isModifier = true - }; - tooltips.Add(StealthBonus); - } - else if (ssDmgBoost < 0) - { - TooltipLine StealthBonus = new TooltipLine(mod, "PrefixSSDmg", "-" + Math.Round(Math.Abs(ssDmgBoost) * 100f) + "% stealth strike damage") + 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 = true + isModifierBad = badModifier }; - tooltips.Add(StealthBonus); + tooltips.Add(stealthTooltip); } } } diff --git a/Items/Weapons/Rogue/Sacrifice.cs b/Items/Weapons/Rogue/Sacrifice.cs new file mode 100644 index 0000000000..c3665fa0c6 --- /dev/null +++ b/Items/Weapons/Rogue/Sacrifice.cs @@ -0,0 +1,69 @@ +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + public class Sacrifice : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sacrifice"); + Tooltip.SetDefault("Releases a dagger that sticks to enemies\n" + + "Right clicking causes all stuck daggers to fly back at you and give you life\n" + + "Daggers stuck to enemies release bloodsplosions over time"); + } + + public override void SafeSetDefaults() + { + item.damage = 266; + item.width = item.height = 68; + item.useAnimation = item.useTime = 6; + item.noMelee = true; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.knockBack = 4f; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = SoundID.Item1; + item.autoReuse = true; + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 12f; + item.Calamity().rogue = true; + } + + public override bool AltFunctionUse(Player player) => true; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (player.altFunctionUse == 2) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != type || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + continue; + + if (Main.projectile[i].ai[0] != 1f) + continue; + + NPC attachedNPC = Main.npc[(int)Main.projectile[i].ai[1]]; + Main.projectile[i].ai[0] = 2f; + Main.projectile[i].ModProjectile().AbleToHealOwner = attachedNPC.type != NPCID.TargetDummy && attachedNPC.type != ModContent.NPCType(); + Main.projectile[i].netUpdate = true; + } + return false; + } + + Vector2 velocity = new Vector2(speedX, speedY); + position += velocity * 3f; + int proj = Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI); + if (player.Calamity().StealthStrikeAvailable() && Main.projectile.IndexInRange(proj)) + Main.projectile[proj].Calamity().stealthStrike = true; + return false; + } + } +} diff --git a/Items/Weapons/Rogue/Sacrifice.png b/Items/Weapons/Rogue/Sacrifice.png new file mode 100644 index 0000000000..4ad5c25480 Binary files /dev/null and b/Items/Weapons/Rogue/Sacrifice.png differ diff --git a/Items/Weapons/Rogue/ScarletDevil.cs b/Items/Weapons/Rogue/ScarletDevil.cs index 49275ba1d2..41d9c88861 100644 --- a/Items/Weapons/Rogue/ScarletDevil.cs +++ b/Items/Weapons/Rogue/ScarletDevil.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -22,12 +23,11 @@ namespace CalamityMod.Items.Weapons.Rogue { item.width = 94; item.height = 94; - item.damage = 40000; + item.damage = 8000; item.noMelee = true; item.noUseGraphic = true; - item.useAnimation = 60; + item.useAnimation = item.useTime = 81; item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 60; item.knockBack = 8f; item.UseSound = SoundID.Item60; item.autoReuse = true; @@ -40,8 +40,16 @@ namespace CalamityMod.Items.Weapons.Rogue item.Calamity().devItem = true; } - // 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) + { + 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; + } + + // 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/ShinobiBlade.cs b/Items/Weapons/Rogue/ShinobiBlade.cs index 03aa14f1b8..ac324c7b90 100644 --- a/Items/Weapons/Rogue/ShinobiBlade.cs +++ b/Items/Weapons/Rogue/ShinobiBlade.cs @@ -17,7 +17,8 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { - item.width = 30; + item.width = 16; + item.height = 42; item.damage = 15; item.noMelee = true; item.noUseGraphic = true; @@ -27,7 +28,6 @@ namespace CalamityMod.Items.Weapons.Rogue item.knockBack = 1f; item.UseSound = SoundID.Item1; item.autoReuse = true; - item.height = 34; item.maxStack = 1; item.value = Item.buyPrice(0, 4, 0, 0); item.rare = ItemRarityID.Green; diff --git a/Items/Weapons/Rogue/ShinobiBlade.png b/Items/Weapons/Rogue/ShinobiBlade.png index 1cf29b4d30..023861ee02 100644 Binary files a/Items/Weapons/Rogue/ShinobiBlade.png and b/Items/Weapons/Rogue/ShinobiBlade.png differ diff --git a/Items/Weapons/Rogue/Supernova.cs b/Items/Weapons/Rogue/Supernova.cs index 7285c96039..a0819b7d78 100644 --- a/Items/Weapons/Rogue/Supernova.cs +++ b/Items/Weapons/Rogue/Supernova.cs @@ -21,7 +21,7 @@ Stealth strikes release energy as they fly"); public override void SafeSetDefaults() { item.width = 34; - item.damage = 2250; + item.damage = 675; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 24; @@ -43,6 +43,7 @@ Stealth strikes release energy as they fly"); { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { + damage = (int)(damage * 0.9f); 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; diff --git a/Items/Weapons/Rogue/TheAtomSplitter.cs b/Items/Weapons/Rogue/TheAtomSplitter.cs new file mode 100644 index 0000000000..18635adb8b --- /dev/null +++ b/Items/Weapons/Rogue/TheAtomSplitter.cs @@ -0,0 +1,46 @@ +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + public class TheAtomSplitter : RogueWeapon + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Atom Splitter"); + Tooltip.SetDefault("Fires a javelin that releases energy duplicates at enemies it hits\n" + + "Stealth strikes release duplicates much more quickly"); + } + + public override void SafeSetDefaults() + { + item.width = item.height = 128; + item.damage = 256; + item.knockBack = 7f; + item.useAnimation = item.useTime = 14; + 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; + } + + 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; + return false; + } + } +} diff --git a/Items/Weapons/Rogue/TheAtomSplitter.png b/Items/Weapons/Rogue/TheAtomSplitter.png new file mode 100644 index 0000000000..c1d0c0131b Binary files /dev/null and b/Items/Weapons/Rogue/TheAtomSplitter.png differ diff --git a/Items/Weapons/Rogue/TheReaper.cs b/Items/Weapons/Rogue/TheReaper.cs index af1add0a02..01eaa0217d 100644 --- a/Items/Weapons/Rogue/TheReaper.cs +++ b/Items/Weapons/Rogue/TheReaper.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = 106; - item.damage = 90; + item.damage = 153; item.noMelee = true; item.noUseGraphic = true; item.useAnimation = 22; diff --git a/Items/Weapons/Rogue/TimeBolt.cs b/Items/Weapons/Rogue/TimeBolt.cs index 66bc4f76e8..1f220218c9 100644 --- a/Items/Weapons/Rogue/TimeBolt.cs +++ b/Items/Weapons/Rogue/TimeBolt.cs @@ -40,6 +40,9 @@ 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()) + damage = (int)(damage * 0.68); + int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); if (player.Calamity().StealthStrikeAvailable() && proj.WithinBounds(Main.maxProjectiles)) { diff --git a/Items/Weapons/Rogue/UtensilPoker.cs b/Items/Weapons/Rogue/UtensilPoker.cs index c40b9b7876..4500d58c06 100644 --- a/Items/Weapons/Rogue/UtensilPoker.cs +++ b/Items/Weapons/Rogue/UtensilPoker.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Rogue 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 the first utensil with a powerful butcher knife"); + "Stealth strikes replace any utensil with a powerful butcher knife"); } public override void SafeSetDefaults() @@ -44,11 +44,12 @@ namespace CalamityMod.Items.Weapons.Rogue { CalamityPlayer mp = player.Calamity(); - // On a stealth strike, the first projectile is replaced with a butcher knife. - if (mp.StealthStrikeAvailable() && counter == 0) + if (mp.StealthStrikeAvailable()) { - int stealthDamage = damage; - int stealth = Projectile.NewProjectile(position.X, position.Y, speedX * 1.2f, speedY * 1.2f, ModContent.ProjectileType(), stealthDamage, knockBack, player.whoAmI); + 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; } diff --git a/Items/Weapons/Summon/AngryChickenStaff.cs b/Items/Weapons/Summon/AngryChickenStaff.cs index bc9167b617..ca405e227c 100644 --- a/Items/Weapons/Summon/AngryChickenStaff.cs +++ b/Items/Weapons/Summon/AngryChickenStaff.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { item.mana = 50; - item.damage = 130; + item.damage = 83; item.useStyle = ItemUseStyleID.SwingThrow; item.width = 32; item.height = 32; diff --git a/Items/Weapons/Summon/BensUmbrella.cs b/Items/Weapons/Summon/BensUmbrella.cs index dcc5758db5..5f970ff13e 100644 --- a/Items/Weapons/Summon/BensUmbrella.cs +++ b/Items/Weapons/Summon/BensUmbrella.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 963; + item.damage = 193; item.knockBack = 1f; item.mana = 99; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/CorvidHarbringerStaff.cs b/Items/Weapons/Summon/CorvidHarbringerStaff.cs index 5bc22b7197..2959295f06 100644 --- a/Items/Weapons/Summon/CorvidHarbringerStaff.cs +++ b/Items/Weapons/Summon/CorvidHarbringerStaff.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Summon item.UseSound = SoundID.DD2_BetsyFlyingCircleAttack; item.summon = true; item.mana = 11; - item.damage = 114; + item.damage = 97; item.knockBack = 2f; item.autoReuse = true; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/CosmicImmaterializer.cs b/Items/Weapons/Summon/CosmicImmaterializer.cs index c25feffde7..bd29889670 100644 --- a/Items/Weapons/Summon/CosmicImmaterializer.cs +++ b/Items/Weapons/Summon/CosmicImmaterializer.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { item.mana = 100; - item.damage = 3000; + item.damage = 630; item.useStyle = ItemUseStyleID.SwingThrow; item.width = 74; item.height = 72; diff --git a/Items/Weapons/Summon/CosmicViperEngine.cs b/Items/Weapons/Summon/CosmicViperEngine.cs index 921e12ebcf..13e8d4b50c 100644 --- a/Items/Weapons/Summon/CosmicViperEngine.cs +++ b/Items/Weapons/Summon/CosmicViperEngine.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 139; + item.damage = 111; item.mana = 10; item.width = 46; item.height = 28; diff --git a/Items/Weapons/Summon/DaedalusGolemStaff.cs b/Items/Weapons/Summon/DaedalusGolemStaff.cs new file mode 100644 index 0000000000..8486a97ddf --- /dev/null +++ b/Items/Weapons/Summon/DaedalusGolemStaff.cs @@ -0,0 +1,54 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class DaedalusGolemStaff : ModItem + { + public override void SetStaticDefaults() + { + 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. + } + + public override void SetDefaults() + { + item.damage = 70; + item.mana = 12; + item.width = item.height = 32; + item.useTime = item.useAnimation = 25; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 3f; + item.UseSound = SoundID.Item67; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + + 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) + { + Point mouseTileCoords = Main.MouseWorld.ToTileCoordinates(); + if (!CalamityUtils.ParanoidTileRetrieval(mouseTileCoords.X, mouseTileCoords.Y).IsTileSolidGround()) + Projectile.NewProjectile(Main.MouseWorld, Vector2.UnitY * 4f, type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/DaedalusGolemStaff.png b/Items/Weapons/Summon/DaedalusGolemStaff.png new file mode 100644 index 0000000000..974e746cb9 Binary files /dev/null and b/Items/Weapons/Summon/DaedalusGolemStaff.png differ diff --git a/Items/Weapons/Summon/DeathstareRod.cs b/Items/Weapons/Summon/DeathstareRod.cs new file mode 100644 index 0000000000..d528e934b8 --- /dev/null +++ b/Items/Weapons/Summon/DeathstareRod.cs @@ -0,0 +1,42 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + 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"); + } + + public override void SetDefaults() + { + item.damage = 33; + item.mana = 10; + item.width = item.height = 42; + item.useTime = item.useAnimation = 35; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 2f; + item.value = CalamityGlobalItem.Rarity1BuyPrice; + item.rare = ItemRarityID.Blue; + item.UseSound = SoundID.NPCHit8; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + 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); + Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f, 0f); + return false; + } + } +} diff --git a/Items/Weapons/Summon/DeathstareRod.png b/Items/Weapons/Summon/DeathstareRod.png new file mode 100644 index 0000000000..fdabc4bd48 Binary files /dev/null and b/Items/Weapons/Summon/DeathstareRod.png differ diff --git a/Items/Weapons/Summon/EndoHydraStaff.cs b/Items/Weapons/Summon/EndoHydraStaff.cs index 2d7eb22333..7895ed20d6 100644 --- a/Items/Weapons/Summon/EndoHydraStaff.cs +++ b/Items/Weapons/Summon/EndoHydraStaff.cs @@ -24,8 +24,8 @@ namespace CalamityMod.Items.Weapons.Summon item.noMelee = true; item.UseSound = SoundID.Item60; item.summon = true; - item.mana = 25; - item.damage = 225; + item.mana = 10; + item.damage = 180; item.knockBack = 3f; item.autoReuse = true; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/Endogenesis.cs b/Items/Weapons/Summon/Endogenesis.cs index 3755c66cce..d71f77e32c 100644 --- a/Items/Weapons/Summon/Endogenesis.cs +++ b/Items/Weapons/Summon/Endogenesis.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Summon item.summon = true; item.mana = 80; - item.damage = 6500; + item.damage = 1300; item.knockBack = 4f; item.autoReuse = true; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/EyeOfNight.cs b/Items/Weapons/Summon/EyeOfNight.cs new file mode 100644 index 0000000000..5b6c81d1b7 --- /dev/null +++ b/Items/Weapons/Summon/EyeOfNight.cs @@ -0,0 +1,56 @@ +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Materials; +using Terraria; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class EyeOfNight : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eye of Night"); + Tooltip.SetDefault("Summons a diseased eyeball that attaches to enemies and explodes"); + } + + public override void SetDefaults() + { + item.damage = 35; + item.mana = 10; + item.width = item.height = 36; + item.useTime = item.useAnimation = 30; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 1f; + item.value = CalamityGlobalItem.Rarity3BuyPrice; + item.rare = ItemRarityID.Orange; + + item.UseSound = SoundID.NPCHit1; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + 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) + { + if (player.altFunctionUse != 2) + Projectile.NewProjectile(Main.MouseWorld, Vector2.UnitY * -3f, 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(ModContent.ItemType()); + recipe.AddIngredient(ItemID.ImpStaff); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/EyeOfNight.png b/Items/Weapons/Summon/EyeOfNight.png new file mode 100644 index 0000000000..6e5a635902 Binary files /dev/null and b/Items/Weapons/Summon/EyeOfNight.png differ diff --git a/Items/Weapons/Summon/FleshOfInfidelity.cs b/Items/Weapons/Summon/FleshOfInfidelity.cs new file mode 100644 index 0000000000..3d0f142d8a --- /dev/null +++ b/Items/Weapons/Summon/FleshOfInfidelity.cs @@ -0,0 +1,49 @@ +using Terraria.ModLoader; +using Terraria.ID; +using TerrariaAudio = Terraria.Audio; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Items.Materials; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class FleshOfInfidelity : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Flesh of Infidelity"); + Tooltip.SetDefault("Summons a tentacled ball of flesh that splashes blood onto enemies"); + } + + public override void SetDefaults() + { + item.damage = 31; + item.mana = 10; + item.width = item.height = 48; + item.useTime = item.useAnimation = 30; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 1f; + item.value = CalamityGlobalItem.Rarity3BuyPrice; + item.rare = ItemRarityID.Orange; + + // SoundID has no Zombie24 sound instance, so we must create one ourselves. + item.UseSound = new TerrariaAudio.LegacySoundStyle(SoundID.Zombie, 24, TerrariaAudio.SoundType.Sound); + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.ImpStaff); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/FleshOfInfidelity.png b/Items/Weapons/Summon/FleshOfInfidelity.png new file mode 100644 index 0000000000..cb2bb8757c Binary files /dev/null and b/Items/Weapons/Summon/FleshOfInfidelity.png differ diff --git a/Items/Weapons/Summon/FlowersOfMortality.cs b/Items/Weapons/Summon/FlowersOfMortality.cs new file mode 100644 index 0000000000..8020b91c54 --- /dev/null +++ b/Items/Weapons/Summon/FlowersOfMortality.cs @@ -0,0 +1,64 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class FlowersOfMortality : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Flowers of Mortality"); + Tooltip.SetDefault("Summons five rainbow flowers over your head\n" + + "The combined flowers consume three minion slots"); + } + + public override void SetDefaults() + { + item.damage = 405; + item.summon = true; + item.mana = 10; + item.width = 36; + item.height = 36; + item.useTime = item.useAnimation = 15; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 5f; + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.rare = ItemRarityID.Red; + item.UseSound = SoundID.Item44; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.Calamity().customRarity = CalamityRarity.Turquoise; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] < 3; //If you already have all 3, no need to resummon + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + 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); + blossom.ai[0] = MathHelper.TwoPi * i / 5f; + blossom.rotation = blossom.ai[0]; + } + return false; + } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.LunarBar, 15); + recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/FlowersOfMortality.png b/Items/Weapons/Summon/FlowersOfMortality.png new file mode 100644 index 0000000000..6a81cbc728 Binary files /dev/null and b/Items/Weapons/Summon/FlowersOfMortality.png differ diff --git a/Items/Weapons/Summon/GammaHeart.cs b/Items/Weapons/Summon/GammaHeart.cs index b72784fbb9..e98a584151 100644 --- a/Items/Weapons/Summon/GammaHeart.cs +++ b/Items/Weapons/Summon/GammaHeart.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Summon item.UseSound = SoundID.Item42; item.summon = true; item.mana = 16; - item.damage = 216; + item.damage = 173; item.knockBack = 3f; item.autoReuse = true; item.useTime = item.useAnimation = 15; diff --git a/Items/Weapons/Summon/MidnightSunBeacon.cs b/Items/Weapons/Summon/MidnightSunBeacon.cs index a58bd10a06..447091eaa0 100644 --- a/Items/Weapons/Summon/MidnightSunBeacon.cs +++ b/Items/Weapons/Summon/MidnightSunBeacon.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 240; + item.damage = 96; item.mana = 12; item.width = item.height = 32; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/Perdition.cs b/Items/Weapons/Summon/Perdition.cs new file mode 100644 index 0000000000..ed08789e23 --- /dev/null +++ b/Items/Weapons/Summon/Perdition.cs @@ -0,0 +1,58 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class Perdition : ModItem + { + public override void SetStaticDefaults() + { + 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" + + "The beacon does not move"); + } + + public override void SetDefaults() + { + item.damage = 444; + item.mana = 25; + item.width = item.height = 56; + item.useTime = item.useAnimation = 42; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 4f; + item.UseSound = SoundID.DD2_EtherianPortalOpen; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + item.sentry = true; + + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + public override bool AltFunctionUse(Player player) => true; + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (player.altFunctionUse != 2) + { + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + player.UpdateMaxTurrets(); + } + else + { + // Play some demonic noises prior to a target being selected. + Main.PlaySound(SoundID.Zombie, player.Center, 93); + Main.PlaySound(SoundID.Item119, player.Center); + } + return false; + } + } +} diff --git a/Items/Weapons/Summon/Perdition.png b/Items/Weapons/Summon/Perdition.png new file mode 100644 index 0000000000..84db27a998 Binary files /dev/null and b/Items/Weapons/Summon/Perdition.png differ diff --git a/Items/Weapons/Summon/PolypLauncher.cs b/Items/Weapons/Summon/PolypLauncher.cs new file mode 100644 index 0000000000..faee489bb3 --- /dev/null +++ b/Items/Weapons/Summon/PolypLauncher.cs @@ -0,0 +1,44 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class PolypLauncher : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Polyp Launcher"); + Tooltip.SetDefault("Summons a polyp bunch that launches coral chunks at nearby enemies"); + } + + public override void SetDefaults() + { + item.damage = 12; + item.mana = 10; + item.width = 10; + item.height = 32; + item.useTime = item.useAnimation = 35; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 0f; + item.value = Item.buyPrice(0, 2, 0, 0); + item.rare = 2; + item.UseSound = SoundID.Item44; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + 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) + { + //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/PolypLauncher.png b/Items/Weapons/Summon/PolypLauncher.png new file mode 100644 index 0000000000..09678f9271 Binary files /dev/null and b/Items/Weapons/Summon/PolypLauncher.png differ diff --git a/Items/Weapons/Summon/PrototypeAndromechaRing.cs b/Items/Weapons/Summon/PrototypeAndromechaRing.cs index 91f015d49e..e5f2a09002 100644 --- a/Items/Weapons/Summon/PrototypeAndromechaRing.cs +++ b/Items/Weapons/Summon/PrototypeAndromechaRing.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { item.mana = 200; - item.damage = 9999; + item.damage = 1999; item.useStyle = ItemUseStyleID.HoldingUp; item.width = item.height = 28; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index 204798affb..1a19d8ed1a 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Summon item.summon = true; item.mana = 100; - item.damage = 170; + item.damage = 145; item.knockBack = 4f; item.useTime = item.useAnimation = 10; item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Summon/SlimePuppetStaff.cs b/Items/Weapons/Summon/SlimePuppetStaff.cs new file mode 100644 index 0000000000..93bea9288a --- /dev/null +++ b/Items/Weapons/Summon/SlimePuppetStaff.cs @@ -0,0 +1,48 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class SlimePuppetStaff : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slime Puppet Staff"); + Tooltip.SetDefault("Summons a slime ball that follows you\n" + + "The ball flies toward nearby enemies and explodes into slime on enemy hits\n" + + "Does not consume minion slots"); // In other words, bootleg mage :TaxEvasion: + Item.staff[item.type] = true; + } + + public override void SetDefaults() + { + item.damage = 26; + item.mana = 13; + item.width = 48; + item.height = 56; + item.useTime = item.useAnimation = 24; + item.useStyle = ItemUseStyleID.HoldingOut; + item.noMelee = true; + item.knockBack = 3.6f; + item.value = CalamityGlobalItem.Rarity4BuyPrice; + item.rare = ItemRarityID.LightRed; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SlimeGodPossession"); + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + + public override Vector2? HoldoutOrigin() => new Vector2(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) + { + if (player.altFunctionUse != 2) + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, Main.myPlayer); + + return false; + } + } +} diff --git a/Items/Weapons/Summon/SlimePuppetStaff.png b/Items/Weapons/Summon/SlimePuppetStaff.png new file mode 100644 index 0000000000..119db86506 Binary files /dev/null and b/Items/Weapons/Summon/SlimePuppetStaff.png differ diff --git a/Items/Weapons/Summon/StaffoftheMechworm.cs b/Items/Weapons/Summon/StaffoftheMechworm.cs index 3fc0a3b48d..2f5d64f4fd 100644 --- a/Items/Weapons/Summon/StaffoftheMechworm.cs +++ b/Items/Weapons/Summon/StaffoftheMechworm.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Weapons.Summon public class StaffoftheMechworm : ModItem { // This value is also referenced by the God Slayer and Auric summoner helmets. - public const int BaseDamage = 161; // originally 325 + public const int BaseDamage = 144; // originally 325 public override void SetStaticDefaults() { DisplayName.SetDefault("Staff of the Mechworm"); diff --git a/Items/Weapons/Summon/UniverseSplitter.cs b/Items/Weapons/Summon/UniverseSplitter.cs new file mode 100644 index 0000000000..66c282b95e --- /dev/null +++ b/Items/Weapons/Summon/UniverseSplitter.cs @@ -0,0 +1,90 @@ +using CalamityMod.Buffs.Cooldowns; +using CalamityMod.Items.Materials; +using CalamityMod.Items.SummonItems; +using CalamityMod.Projectiles.Summon; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class UniverseSplitter : ModItem + { + public const float ItemUseDustMaxRadius = 36f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Universe Splitter"); + Tooltip.SetDefault("Summons an energy field at the mouse cursor\n" + + "After the field has been deployed, it begins to summon multiple small beams\n" + + "After several seconds have passed, an enormous laser beam appears at the field's position\n" + + "This effect has a cooldown\n" + + "Attempting to use this item during the cooldown will cause it to short circuit and do damage to you.\n" + + "An ancient artifact from a previous age, it waits for your command...\n" + + "This is a terrible idea, but it isn't yours anyways... right?"); + Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 14)); + } + + public override void SetDefaults() + { + item.width = 54; + item.height = 76; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.Item122; + + item.summon = true; + item.mana = 300; + item.damage = 18000; + item.knockBack = 7f; + item.autoReuse = true; + item.useTime = item.useAnimation = 10; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.noUseGraphic = true; + + item.value = CalamityGlobalItem.RarityHotPinkBuyPrice; + item.Calamity().customRarity = CalamityRarity.HotPink; + } + + 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) + { + if (player.altFunctionUse != 2) + { + if (!player.HasBuff(ModContent.BuffType())) + { + player.AddBuff(ModContent.BuffType(), 45 * 60); + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + for (int i = 0; i < 36; i++) + { + float angle = MathHelper.TwoPi / 36f * i + Main.rand.NextFloat(MathHelper.TwoPi / 36f); + Dust dust = Dust.NewDustPerfect(position + angle.ToRotationVector2() * ItemUseDustMaxRadius, 247); + dust.velocity = Vector2.Normalize(angle.ToRotationVector2()) * 2.5f; + dust.noGravity = true; + dust.scale = 0.8f; + } + } + else + { + Projectile.NewProjectile(position, Vector2.UnitY * 3f, ProjectileID.SaucerScrap, 5, 0f, player.whoAmI); + } + } + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/UniverseSplitter.png b/Items/Weapons/Summon/UniverseSplitter.png new file mode 100644 index 0000000000..9397d8d05a Binary files /dev/null and b/Items/Weapons/Summon/UniverseSplitter.png differ diff --git a/Items/Weapons/Summon/Vigilance.cs b/Items/Weapons/Summon/Vigilance.cs new file mode 100644 index 0000000000..23b51e01f7 --- /dev/null +++ b/Items/Weapons/Summon/Vigilance.cs @@ -0,0 +1,66 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class Vigilance : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Vigilance"); + Tooltip.SetDefault("Summons a soul seeker to fight for you"); + } + + public override void SetDefaults() + { + item.damage = 333; + item.mana = 12; + item.width = item.height = 32; + item.useTime = item.useAnimation = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 4f; + item.UseSound = SoundID.DD2_BetsySummon; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + + item.value = CalamityGlobalItem.RarityVioletBuyPrice; + item.rare = ItemRarityID.Purple; + 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.altFunctionUse != 2) + { + int seekerIndex = 0; + int totalSeekers = 0; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != type || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + continue; + + totalSeekers++; + } + + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != type || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + continue; + Main.projectile[i].ai[0] = seekerIndex / (float)totalSeekers; + Main.projectile[i].netUpdate = true; + + seekerIndex++; + } + } + return false; + } + } +} diff --git a/Items/Weapons/Summon/Vigilance.png b/Items/Weapons/Summon/Vigilance.png new file mode 100644 index 0000000000..cdc748ad35 Binary files /dev/null and b/Items/Weapons/Summon/Vigilance.png differ diff --git a/Items/Weapons/Summon/ViralSprout.cs b/Items/Weapons/Summon/ViralSprout.cs new file mode 100644 index 0000000000..77be9227c7 --- /dev/null +++ b/Items/Weapons/Summon/ViralSprout.cs @@ -0,0 +1,67 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class ViralSprout : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Viral Sprout"); + Tooltip.SetDefault("Summons a sage spirit to fight for you\n" + + "Inflicts Sage Poison, a debuff that becomes stronger the more spirits you own"); + } + + public override void SetDefaults() + { + item.damage = 32; + item.mana = 10; + item.width = 48; + item.height = 56; + item.useTime = item.useAnimation = 20; + item.useStyle = ItemUseStyleID.HoldingUp; + item.noMelee = true; + item.knockBack = 2f; + item.value = CalamityGlobalItem.Rarity7BuyPrice; + item.rare = ItemRarityID.Lime; + item.UseSound = SoundID.Item44; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + 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) + { + if (player.altFunctionUse != 2) + { + Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI); + + int minionCount = 0; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != type || !Main.projectile[i].active || Main.projectile[i].owner != player.whoAmI) + continue; + + Main.projectile[i].localAI[0] = minionCount; + Main.projectile[i].netUpdate = true; + minionCount++; + } + } + return false; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/ViralSprout.png b/Items/Weapons/Summon/ViralSprout.png new file mode 100644 index 0000000000..062b3bc149 Binary files /dev/null and b/Items/Weapons/Summon/ViralSprout.png differ diff --git a/Items/Weapons/Summon/ViridVanguard.cs b/Items/Weapons/Summon/ViridVanguard.cs new file mode 100644 index 0000000000..1eb96eccdb --- /dev/null +++ b/Items/Weapons/Summon/ViridVanguard.cs @@ -0,0 +1,110 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Items.Weapons.Summon +{ + public class ViridVanguard : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Virid Vanguard"); + Tooltip.SetDefault("Summons 2 blades that rotate around you\n" + + "Right clicking prompts all blades to fly upward and redirect towards the mouse"); + Item.staff[item.type] = true; + } + + public override void SetDefaults() + { + item.damage = 156; + item.summon = true; + item.sentry = true; + item.mana = 25; + item.width = 26; + item.height = 36; + item.useTime = item.useAnimation = 15; + item.useStyle = ItemUseStyleID.HoldingUp; + item.noMelee = true; + item.knockBack = 5f; + item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; + item.rare = 10; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + 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) + { + float totalMinionSlots = 0f; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && Main.projectile[i].minion && Main.projectile[i].owner == player.whoAmI) + { + totalMinionSlots += Main.projectile[i].minionSlots; + } + } + if (player.altFunctionUse != 2 && totalMinionSlots + 1.5f < player.maxMinions) + { + position = Main.MouseWorld; + int swordCount = 0; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) + { + if ((Main.projectile[i].modProjectile as ViridVanguardBlade).FiringTime > 0f) + continue; + swordCount++; + for (int j = 0; j < 22; j++) + { + Dust dust = Dust.NewDustDirect(Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height, 2); + dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool(2).ToDirectionInt(); + dust.noGravity = true; + } + } + } + + Projectile newBlade = Projectile.NewProjectileDirect(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); + (newBlade.modProjectile as ViridVanguardBlade).AltTexture = swordCount % 2 == 1; + newBlade.netUpdate = true; + swordCount++; + + newBlade = Projectile.NewProjectileDirect(position, Vector2.Zero, type, damage, knockBack, player.whoAmI); + (newBlade.modProjectile as ViridVanguardBlade).AltTexture = swordCount % 2 == 1; + newBlade.netUpdate = true; + swordCount++; + + float angleVariance = MathHelper.TwoPi / swordCount; + float angle = 0f; + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].active && Main.projectile[i].type == type && Main.projectile[i].owner == player.whoAmI) + { + if ((Main.projectile[i].modProjectile as ViridVanguardBlade).FiringTime > 0f) + continue; + Main.projectile[i].ai[0] = angle; + Main.projectile[i].localAI[1] = 80f; + angle += angleVariance; + for (int j = 0; j < 22; j++) + { + Dust dust = Dust.NewDustDirect(Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height, 6); + dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool(2).ToDirectionInt(); + dust.noGravity = true; + } + } + } + } + return false; + } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddTile(TileID.LunarCraftingStation); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Weapons/Summon/ViridVanguard.png b/Items/Weapons/Summon/ViridVanguard.png new file mode 100644 index 0000000000..6455e12c54 Binary files /dev/null and b/Items/Weapons/Summon/ViridVanguard.png differ diff --git a/Items/Weapons/Summon/WitherBlossomsStaff.cs b/Items/Weapons/Summon/WitherBlossomsStaff.cs new file mode 100644 index 0000000000..2e541f0170 --- /dev/null +++ b/Items/Weapons/Summon/WitherBlossomsStaff.cs @@ -0,0 +1,63 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class WitherBlossomsStaff : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wither Blossoms Staff"); + Tooltip.SetDefault("Summons four decaying flowers over your head\n" + + "The combined flowers consume two minion slots"); + } + + public override void SetDefaults() + { + item.damage = 61; + item.mana = 10; + item.width = 52; + item.height = 60; + item.useTime = item.useAnimation = 20; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.knockBack = 3f; + item.value = CalamityGlobalItem.Rarity8BuyPrice; + item.rare = ItemRarityID.Yellow; + item.UseSound = SoundID.Item46; + item.autoReuse = true; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + item.summon = true; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] < 3; //If you already have all 3, no need to resummon + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + 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); + blossom.ai[0] = MathHelper.TwoPi * i / 4f; + blossom.rotation = blossom.ai[0]; + } + return false; + } + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + 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/Summon/WitherBlossomsStaff.png b/Items/Weapons/Summon/WitherBlossomsStaff.png new file mode 100644 index 0000000000..c74966ede5 Binary files /dev/null and b/Items/Weapons/Summon/WitherBlossomsStaff.png differ diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index 698cd3151c..07aca5bfa0 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -46,34 +46,44 @@ namespace CalamityMod.Localization new [] { "GhostBossText3", "Long-dead prisoners seek their zealous revenge..." }, new [] { "GhostBossText4", "The souls released stir the acidic storms..." }, - new [] { "SupremeBossText3", "Alright, let's get started. Not sure why you're bothering." }, // start - new [] { "SupremeBossText4", "You seem so confident, even though you are painfully ignorant of what has yet to transpire." }, //75% - new [] { "SupremeBossText5", "Everything was going well until you came along." }, //75% - new [] { "SupremeBossText6", "Brothers, could you assist me for a moment? This ordeal is growing tiresome." }, //45% - new [] { "SupremeBossText", "Don't worry, I still have plenty of tricks left." }, //40% - new [] { "SupremeBossText7", "Hmm...perhaps I should let the little ones out to play for a while." },//30% - new [] { "SupremeBossText8", "Impressive...but still not good enough!" }, //20% - new [] { "SupremeBossText9", "I'm just getting started!" }, //10% - new [] { "SupremeBossText20", "How are you still alive!?" }, //8% - new [] { "SupremeBossText21", "Just stop!" }, //6% - new [] { "SupremeBossText22", "Even if you defeat me you would still have the lord to contend with!" }, //4% - new [] { "SupremeBossText23", "He has never lost a battle!" }, //2% - new [] { "SupremeBossText24", "Not even I could defeat him! What hope do you have!?" }, //1% - new [] { "SupremeBossText25", "He has grown far stronger since we last fought...you stand no chance." }, //1% after 10 seconds - new [] { "SupremeBossText26", "Well...I suppose this is the end..." }, //1% after 15 seconds - new [] { "SupremeBossText27", "Perhaps one of these times I'll change my mind..." }, //1% after first win - new [] { "SupremeBossText28", "You aren't hurting as much as I'd like...are you cheating?" }, //not taking enough damage - new [] { "SupremeBossText2", "Go to hell." }, //cheater - new [] { "SupremeBossText10", "At long last I am free...for a time. I'll keep coming back, just like you. Until we meet again, farewell." }, //end after 20 seconds - new [] { "SupremeBossText11", "Do you enjoy going through hell?" }, //rebattle after killing once - new [] { "SupremeBossText12", "Don't get me wrong, I like pain too, but you're just ridiculous." }, //rebattle after killing four times - new [] { "SupremeBossText13", "You must enjoy dying more than most people, huh?" }, //rebattle five deaths - new [] { "SupremeBossText14", "Do you have a fetish for getting killed or something?" }, //rebattle twenty deaths - new [] { "SupremeBossText15", "Alright, I'm done counting. You probably died this much just to see what I'd say." }, //rebattle fifty deaths - new [] { "SupremeBossText16", "You didn't die at all huh? Welp, you probably cheated. Do it again, for real this time...but here's your reward I guess." }, //die 0 times - new [] { "SupremeBossText17", "One death? That's it? ...I guess you earned this then." }, //die 1 time and win - new [] { "SupremeBossText18", "Two deaths, nice job. Here's your reward." }, //die 2 times and win - new [] { "SupremeBossText19", "Third time's the charm. Here's a special reward." }, //die 3 times and win + new [] { "SCalSummonText", "Do you enjoy going through hell?" }, + new [] { "SCalStartText", "You should have just died..." }, + new [] { "SCalBH2Text", "It wasn't too long ago you barely managed to defeat my doppelganger. Quite the failure, wasn't it?" }, + new [] { "SCalBH3Text", "You've harnessed great power, but you wield it for no one but yourself." }, + new [] { "SCalBrothersText", "Would you like to meet my family? Horrible, isn't it?" }, + new [] { "SCalPhase2Text", "You will suffer greatly." }, + new [] { "SCalBH4Text", "It's absurd to even think of trying to get away. As long as you live, you will suffer." }, + new [] { "SCalSeekerRingText", "An upstart who recklessly stole and killed their way to power. I wonder, who does that remind me of...?" }, + new [] { "SCalBH5Text", "You have no stake in this battle. No one gave you any say in this matter!" }, + new [] { "SCalSepulcher2Text", "Once the dust has settled and only one remains, if it is you, what value will this have had?!" }, + new [] { "SCalDesparationText1", "Just stop!" }, + new [] { "SCalDesparationText2", "I have no future if I lose here." }, + new [] { "SCalDesparationText3", "Once you have bested me, you too will only have one path forward." }, + new [] { "SCalDesparationText4", "And that path... also has no future." }, + new [] { "SCalAcceptanceText1", "Even if he has thrown all else away, his power remains." }, + new [] { "SCalAcceptanceText2", "I have no more energy left to resent him, or you..." }, + new [] { "SCalAcceptanceText3", "It will all be in your hands now." }, + + // Some of these keys are incorrect in terms of their contents, but they remain as their bases + an addon at the end to make it + // easier to define them. + new [] { "SCalSummonTextRematch", "You called? If you're looking to get scorched, you've got the right person." }, + new [] { "SCalStartTextRematch", "Ha! You saw it coming this time." }, + new [] { "SCalBH2TextRematch", "Don't get cocky just because you've won once." }, + new [] { "SCalBH3TextRematch", "You know, I was expecting a house call from the Tyrant at this point. Think he died?" }, + new [] { "SCalBH3TextRematch2", "Haha, no way." }, + new [] { "SCalBrothersTextRematch", "Would you like to meet my family? Horrible, isn't it?" }, + new [] { "SCalBrothersTextRematch2", "I'm joking. They are but empty shells now. Did I frighten you?" }, + new [] { "SCalPhase2TextRematch", "Here we go again." }, + new [] { "SCalBH4TextRematch", "Remember these? I bet you've seen them a few times since the last battle... in your nightmares." }, + new [] { "SCalSeekerRingTextRematch", "It seems your skill hasn't faltered in the least." }, + new [] { "SCalBH5TextRematch", "One last go." }, + new [] { "SCalSepulcher2TextRematch", "And... you never cease to amaze." }, + new [] { "SCalDesparationText1Rematch", "You may even have a proper chance now." }, + new [] { "SCalDesparationText2Rematch", "I wonder if you've met his mechanic yet." }, + new [] { "SCalDesparationText3Rematch", "I trust you will not make the same mistakes he did." }, + new [] { "SCalDesparationText4Rematch", "Now... even I cannot see what your future holds." }, + + new [] { "SCalFunnyCheatText", "Go to hell." }, new [] { "EdgyBossText", "Don't get cocky, kid!" }, new [] { "EdgyBossText2", "You think...you can butcher...ME!?" }, diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 1ff4d2662c..96b6129f2f 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -248,6 +248,14 @@ namespace CalamityMod 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 diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index b5809c6b10..2a0af9787e 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -29,6 +29,7 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Items.Weapons.Typeless; +using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.AstrumAureus; @@ -103,6 +104,7 @@ namespace CalamityMod public static readonly Func DownedDoG = () => CalamityWorld.downedDoG; public static readonly Func DownedYharon = () => CalamityWorld.downedYharon; 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; @@ -140,6 +142,7 @@ namespace CalamityMod { "Yharon", 18f }, // { "Draedon", 18.5f }, { "SupremeCalamitas", 19f }, + { "AdultEidolonWyrm", 19.5f }, // { "Yharim", 20f }, // { "Noxus", 120f }, // { "Xeroc", 121f }, @@ -484,7 +487,7 @@ namespace CalamityMod // Ceaseless Void { BossDifficulty.TryGetValue("CeaselessVoid", out float order); - List bosses = new List() { NPCType(), NPCType(), NPCType(), NPCType() }; + List bosses = new List() { NPCType(), NPCType() }; int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType() }; @@ -564,7 +567,6 @@ namespace CalamityMod List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), /*ItemType(), */ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = $"Use a [i:{summon}] in the Jungle Biome"; - // TODO -- this setup code is only run once, so the despawn message can't be changed post-eclipse. Find a way around this. 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); @@ -575,12 +577,24 @@ namespace CalamityMod BossDifficulty.TryGetValue("SupremeCalamitas", 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(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; + List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType() }; List collection = new List() { ItemType(), ItemType(), ItemType(), ItemType() }; string instructions = $"Use an [i:{summon}]"; string despawn = CalamityUtils.ColorMessage("Please don't waste my time.", new Color(0xFF, 0xA5, 0x00)); AddBoss(bossChecklist, calamity, "Supreme Calamitas", order, type, DownedSCal, summon, loot, collection, instructions, despawn); } + + // 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() }; + List collection = new List() { ItemType() }; + string instructions = $"While in the Abyss, use an item that inflicts Chaos State"; + string despawn = CalamityUtils.ColorMessage("...", new Color(0x7F, 0xFF, 0xD4)); + AddBoss(bossChecklist, calamity, "Adult Eidolon Wyrm", order, type, DownedAdultEidolonWyrm, summon, loot, collection, instructions, despawn); + } } private static void AddCalamityInvasions(Mod bossChecklist, Mod calamity) diff --git a/NPCs/Abyss/AEWScreenShaderData.cs b/NPCs/Abyss/AEWScreenShaderData.cs new file mode 100644 index 0000000000..4d0c5fc4ab --- /dev/null +++ b/NPCs/Abyss/AEWScreenShaderData.cs @@ -0,0 +1,44 @@ +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Abyss +{ + public class AEWScreenShaderData : ScreenShaderData + { + private int AEWIndex; + + public AEWScreenShaderData(string passName) + : base(passName) + { + } + + private void UpdateAEWIndex() + { + int AEWType = ModContent.NPCType(); + if (AEWIndex >= 0 && Main.npc[AEWIndex].active && Main.npc[AEWIndex].type == AEWType) + { + return; + } + AEWIndex = -1; + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && Main.npc[i].type == AEWType) + { + AEWIndex = i; + break; + } + } + } + + public override void Apply() + { + UpdateAEWIndex(); + if (AEWIndex != -1) + { + UseTargetPosition(Main.npc[AEWIndex].Center); + } + base.Apply(); + } + } +} diff --git a/NPCs/Abyss/AEWSky.cs b/NPCs/Abyss/AEWSky.cs new file mode 100644 index 0000000000..074be772c1 --- /dev/null +++ b/NPCs/Abyss/AEWSky.cs @@ -0,0 +1,95 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.Abyss +{ + public class AEWSky : CustomSky + { + private bool isActive = false; + private float intensity = 0f; + private int AEWIndex = -1; + + public override void Update(GameTime gameTime) + { + if (isActive && intensity < 1f) + intensity += 0.01f; + else if (!isActive && intensity > 0f) + intensity -= 0.01f; + } + + private float GetIntensity() + { + if (UpdateAEWIndex()) + { + float x = 0f; + if (AEWIndex != -1) + x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[AEWIndex].Center); + + return 1f - Utils.SmoothStep(3000f, 6000f, x); + } + return 0f; + } + + public override Color OnTileColor(Color inColor) + { + float intensity = GetIntensity(); + return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); + } + + private bool UpdateAEWIndex() + { + int AEWType = ModContent.NPCType(); + if (AEWIndex >= 0 && Main.npc[AEWIndex].active && Main.npc[AEWIndex].type == AEWType) + { + return true; + } + AEWIndex = -1; + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && Main.npc[i].type == AEWType) + { + AEWIndex = i; + break; + } + } + return AEWIndex != -1; + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (maxDepth >= 0 && minDepth < 0) + { + float intensity = GetIntensity(); + spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), new Color(0, 0, 15) * intensity); + } + } + + public override float GetCloudAlpha() + { + return 0f; + } + + public override void Activate(Vector2 position, params object[] args) + { + isActive = true; + } + + public override void Deactivate(params object[] args) + { + isActive = false; + } + + public override void Reset() + { + isActive = false; + } + + public override bool IsActive() + { + return isActive || intensity > 0f; + } + } +} diff --git a/NPCs/Abyss/Bloatfish.cs b/NPCs/Abyss/Bloatfish.cs index f3e7ecb226..ae9c089056 100644 --- a/NPCs/Abyss/Bloatfish.cs +++ b/NPCs/Abyss/Bloatfish.cs @@ -188,7 +188,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItem(npc, ModContent.ItemType(), 10, 20); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 2, 5, 7); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 2, 2, 3); diff --git a/NPCs/Abyss/BobbitWormHead.cs b/NPCs/Abyss/BobbitWormHead.cs index adb10f91ed..672541c0f1 100644 --- a/NPCs/Abyss/BobbitWormHead.cs +++ b/NPCs/Abyss/BobbitWormHead.cs @@ -238,7 +238,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 2, 5, 7); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 2, 2, 3); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast, 3, 1, 1); diff --git a/NPCs/Abyss/ChaoticPuffer.cs b/NPCs/Abyss/ChaoticPuffer.cs index cac01b0c5b..444abd85a8 100644 --- a/NPCs/Abyss/ChaoticPuffer.cs +++ b/NPCs/Abyss/ChaoticPuffer.cs @@ -139,7 +139,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/ChaoticPufferGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/ChaoticPufferGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Yellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/ChaoticPufferGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -218,7 +218,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedGolemBoss, 1f, 10, 26); } diff --git a/NPCs/Abyss/ColossalSquid.cs b/NPCs/Abyss/ColossalSquid.cs index 26a36ef1c5..18d1160721 100644 --- a/NPCs/Abyss/ColossalSquid.cs +++ b/NPCs/Abyss/ColossalSquid.cs @@ -550,7 +550,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance * 100f); DropHelper.DropItem(npc, ItemID.BlackInk, 3, 5); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 2, 26, 38); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 2, 5, 7); diff --git a/NPCs/Abyss/Cuttlefish.cs b/NPCs/Abyss/Cuttlefish.cs index 5510b717bf..aba420d53a 100644 --- a/NPCs/Abyss/Cuttlefish.cs +++ b/NPCs/Abyss/Cuttlefish.cs @@ -361,7 +361,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/CuttlefishGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/CuttlefishGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Gold); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/CuttlefishGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -387,7 +387,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemChance(npc, ModContent.ItemType(), 2); int inkBombDropRate = Main.expertMode ? 50 : 100; DropHelper.DropItemChance(npc, ModContent.ItemType(), inkBombDropRate, 1, 1); diff --git a/NPCs/Abyss/DevilFish.cs b/NPCs/Abyss/DevilFish.cs index 05d7b423c5..36e7903cc0 100644 --- a/NPCs/Abyss/DevilFish.cs +++ b/NPCs/Abyss/DevilFish.cs @@ -274,7 +274,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/DevilFishGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/DevilFishGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Red); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/DevilFishGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -300,7 +300,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 1, 2); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f); diff --git a/NPCs/Abyss/DevilFishAlt.cs b/NPCs/Abyss/DevilFishAlt.cs index a721472861..e51d360bd4 100644 --- a/NPCs/Abyss/DevilFishAlt.cs +++ b/NPCs/Abyss/DevilFishAlt.cs @@ -274,7 +274,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/DevilFishGlowAlt").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/DevilFishGlowAlt").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Red); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/DevilFishGlowAlt"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -300,7 +300,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 1, 2); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f); diff --git a/NPCs/Abyss/EidolonWyrmBody.cs b/NPCs/Abyss/EidolonWyrmBody.cs index b79adab08c..130360d7ec 100644 --- a/NPCs/Abyss/EidolonWyrmBody.cs +++ b/NPCs/Abyss/EidolonWyrmBody.cs @@ -127,7 +127,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -145,10 +145,6 @@ namespace CalamityMod.NPCs.Abyss public override void HitEffect(int hitDirection, double damage) { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { for (int k = 0; k < 10; k++) @@ -158,10 +154,5 @@ namespace CalamityMod.NPCs.Abyss Gore.NewGore(npc.Center, npc.velocity, mod.GetGoreSlot("Gores/Wyrm2"), 1f); } } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 500, true); - } } } diff --git a/NPCs/Abyss/EidolonWyrmBodyAlt.cs b/NPCs/Abyss/EidolonWyrmBodyAlt.cs index 6bb26dbd13..03a97848a6 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAlt.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAlt.cs @@ -127,7 +127,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -145,10 +145,6 @@ namespace CalamityMod.NPCs.Abyss public override void HitEffect(int hitDirection, double damage) { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { for (int k = 0; k < 10; k++) @@ -158,10 +154,5 @@ namespace CalamityMod.NPCs.Abyss Gore.NewGore(npc.Center, npc.velocity, mod.GetGoreSlot("Gores/Wyrm3"), 1f); } } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 500, true); - } } } diff --git a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs index a27547108e..dab9292565 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs @@ -1,7 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,15 +17,17 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.damage = 100; //70 - npc.width = 60; //36 + npc.damage = 100; + npc.width = 60; npc.height = 88; npc.defense = 0; - npc.lifeMax = 1000000; - npc.aiStyle = -1; //new - aiType = -1; //new + npc.LifeMaxNERB(1750000, 2012500); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; npc.knockBackResist = 0f; - npc.alpha = 255; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -37,131 +39,160 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.localAI[0]); + } + + 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 void AI() { npc.damage = 0; + 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) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - npc.active = false; - } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - 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); + + // 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; + } + if (!shouldDespawn) + { + if (npc.ai[1] > 0f) + shouldDespawn = false; + else if (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; + } + + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + + float chargePhaseGateValue = 300f; + float lightningChargePhaseGateValue = 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 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 = 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); + 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((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; 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 void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector = center - Main.screenPosition; - vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); + vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge").Height) * 0.5f; + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyAltGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; - public override bool PreNPCLoot() - { - return 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, 4, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { for (int k = 0; k < 10; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - } + Gore.NewGore(npc.Center, npc.velocity, mod.GetGoreSlot("Gores/WyrmAdult3"), 1f); } } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 500, true); - } } } diff --git a/NPCs/Abyss/EidolonWyrmBodyHuge.cs b/NPCs/Abyss/EidolonWyrmBodyHuge.cs index 7a19413ba3..6b6f7a32b3 100644 --- a/NPCs/Abyss/EidolonWyrmBodyHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyHuge.cs @@ -1,7 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -17,15 +17,17 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.damage = 100; //70 - npc.width = 60; //36 + npc.damage = 100; + npc.width = 60; npc.height = 88; npc.defense = 0; - npc.lifeMax = 1000000; - npc.aiStyle = -1; //new - aiType = -1; //new + npc.LifeMaxNERB(1750000, 2012500); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; npc.knockBackResist = 0f; - npc.alpha = 255; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -37,131 +39,160 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; } - public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) - { - return false; - } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.localAI[0]); + } + + 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 void AI() { npc.damage = 0; + 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) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - npc.active = false; - } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - 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); + + // 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; + } + if (!shouldDespawn) + { + if (npc.ai[1] > 0f) + shouldDespawn = false; + else if (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; + } + + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + + float chargePhaseGateValue = 300f; + float lightningChargePhaseGateValue = 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 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 = 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); + 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((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; 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 void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector = center - Main.screenPosition; - vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); + vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge").Height) * 0.5f; + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmBodyGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; - public override bool PreNPCLoot() - { - return 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, 4, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { for (int k = 0; k < 10; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - } + Gore.NewGore(npc.Center, npc.velocity, mod.GetGoreSlot("Gores/WyrmAdult2"), 1f); } } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 500, true); - } } } diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 98d05788cd..7515be8701 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -73,7 +73,13 @@ namespace CalamityMod.NPCs.Abyss public override void AI() { - if (npc.justHit || detectsPlayer || Main.player[npc.target].chaosState) + 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; @@ -146,31 +152,23 @@ namespace CalamityMod.NPCs.Abyss npc.localAI[0] = 0f; npc.TargetClosest(true); npc.netUpdate = true; - int damage = 80; - if (Main.expertMode) - { - damage = 60; - } + 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 random = Main.rand.Next(3); if (random == 0) { - Projectile.NewProjectile(vector2.X, vector2.Y, 0f, 0f, ProjectileID.CultistBossLightningOrb, damage, 0f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(vector2, Vector2.Zero, ProjectileID.CultistBossLightningOrb, damage, 0f, Main.myPlayer, 0f, 0f); } else if (random == 1) { Vector2 vec = Vector2.Normalize(Main.player[npc.target].Center - npc.Center); - vec = Vector2.Normalize(Main.player[npc.target].Center - npc.Center + Main.player[npc.target].velocity * 20f); if (vec.HasNaNs()) { - vec = new Vector2((float)npc.direction, 0f); - } - for (int n = 0; n < 1; n++) - { - Vector2 vector4 = vec * 4f; - Projectile.NewProjectile(vector2.X, vector2.Y, vector4.X, vector4.Y, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); + vec = new Vector2(npc.direction, 0f); } + Vector2 vector4 = vec * (adultWyrmAlive ? 6f : 4f); + Projectile.NewProjectile(vector2, vector4, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); } else { @@ -279,6 +277,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; + } + } } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; @@ -425,7 +431,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -453,7 +459,6 @@ namespace CalamityMod.NPCs.Abyss DropHelper.DropItem(npc, ItemID.BlueLunaticHood); DropHelper.DropItem(npc, ItemID.BlueLunaticRobe); } - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance * 100f); 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.downedCalamitas, 1, 6, 8); diff --git a/NPCs/Abyss/EidolonWyrmHeadHuge.cs b/NPCs/Abyss/EidolonWyrmHeadHuge.cs index dd58aa7918..4ecf4c442c 100644 --- a/NPCs/Abyss/EidolonWyrmHeadHuge.cs +++ b/NPCs/Abyss/EidolonWyrmHeadHuge.cs @@ -1,9 +1,12 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; +using CalamityMod.Items.Potions; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -15,15 +18,57 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.Abyss { - public class EidolonWyrmHeadHuge : ModNPC + [AutoloadBossHead] + public class EidolonWyrmHeadHuge : ModNPC { - private Vector2 patrolSpot = Vector2.Zero; - public bool detectsPlayer = false; - public const int minLength = 40; - public const int maxLength = 41; - public float speed = 7.5f; //10 - public float turnSpeed = 0.15f; //0.15 - bool TailSpawned = false; + 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; + } + + // 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; + + // 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; + + // Length variables + private const int minLength = 40; + private const int maxLength = 41; + + // Variable used to stop the segment spawning loop + private bool TailSpawned = false; + + // 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; + + // How much less time is needed before activating fast charge + private const float fastChargeGateValue = 120f; public override void SetStaticDefaults() { @@ -33,17 +78,20 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 24f; - npc.damage = 1500; - npc.width = 254; //36 - npc.height = 138; //20 - npc.defense = 700; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.95f; - global.unbreakableDR = true; - npc.lifeMax = 1000000; - npc.aiStyle = -1; + npc.npcSlots = 50f; + npc.GetNPCDamage(); + npc.width = 254; + npc.height = 138; + npc.defense = 100; + npc.DR_NERD(0.4f); + CalamityGlobalNPC global = npc.Calamity(); + global.multDRReductions.Add(BuffID.CursedInferno, 0.9f); + npc.LifeMaxNERB(1750000, 2012500); + 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(10, 0, 0, 0); npc.behindTiles = true; @@ -52,465 +100,1345 @@ namespace CalamityMod.NPCs.Abyss npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath6; npc.netAlways = true; - } + npc.boss = true; + music = CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ?? MusicID.Boss3; + } public override void SendExtraAI(BinaryWriter writer) { - writer.WriteVector2(patrolSpot); - writer.Write(detectsPlayer); - writer.Write(npc.chaseable); - } + writer.Write(npc.dontTakeDamage); + 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) { - patrolSpot = reader.ReadVector2(); - detectsPlayer = reader.ReadBoolean(); - npc.chaseable = reader.ReadBoolean(); - } + npc.dontTakeDamage = reader.ReadBoolean(); + 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() { - if (npc.target < 0 || npc.target == 255 || Main.player[npc.target].dead) - { - npc.TargetClosest(true); - } - if (npc.justHit || detectsPlayer || Main.player[npc.target].chaosState) - { - if (!detectsPlayer) - { - if (Main.netMode != NetmodeID.Server) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Scare"), (int)Main.player[npc.target].position.X, (int)Main.player[npc.target].position.Y); - } - detectsPlayer = true; - } - npc.damage = 1500; - } - else - { - npc.damage = 0; - } - npc.chaseable = detectsPlayer; - if (detectsPlayer) - { - if (npc.soundDelay <= 0 && Main.netMode != NetmodeID.Server) - { - npc.soundDelay = 420; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose").WithVolume(2.5f), (int)npc.position.X, (int)npc.position.Y); - } - } - else - { - if (Main.rand.NextBool(900) && Main.netMode != NetmodeID.Server) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/EidolonWyrmRoarClose").WithVolume(2.5f), (int)npc.position.X, (int)npc.position.Y); - } - } - if (npc.ai[2] > 0f) - { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.adultEidolonWyrmHead = npc.whoAmI; + + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) + lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; + + // 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(); + + // 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]; + + bool targetDownDeep = player.Calamity().ZoneAbyssLayer4; + bool targetOnMount = player.mount.Active; + + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; - } - 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] = (float)npc.whoAmI; - Main.npc[lol].ai[1] = (float)Previous; - Main.npc[Previous].ai[0] = (float)lol; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); - Previous = lol; - } - TailSpawned = true; - } - if (detectsPlayer) - { - npc.localAI[0] += 1f; - if (npc.localAI[0] >= 300f) - { - npc.localAI[0] = 0f; - npc.TargetClosest(true); - npc.netUpdate = true; - int damage = Main.expertMode ? 300 : 400; - 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 random = Main.rand.Next(3); - if (random == 0) - { - Projectile.NewProjectile(vector2.X, vector2.Y, 0f, 0f, ProjectileID.CultistBossLightningOrb, damage, 0f, Main.myPlayer, 0f, 0f); - Projectile.NewProjectile(-vector2.X, -vector2.Y, 0f, 0f, ProjectileID.CultistBossLightningOrb, damage, 0f, Main.myPlayer, 0f, 0f); - } - else if (random == 1) - { - Vector2 vec = Vector2.Normalize(Main.player[npc.target].Center - npc.Center); - vec = Vector2.Normalize(Main.player[npc.target].Center - npc.Center + Main.player[npc.target].velocity * 20f); - if (vec.HasNaNs()) - { - vec = new Vector2((float)npc.direction, 0f); - } - for (int n = 0; n < 1; n++) - { - Vector2 vector4 = vec * 4f; - Projectile.NewProjectile(vector2.X, vector2.Y, vector4.X, vector4.Y, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); - Projectile.NewProjectile(-vector2.X, -vector2.Y, -vector4.X, -vector4.Y, ProjectileID.CultistBossIceMist, damage, 0f, Main.myPlayer, 0f, 1f); - } - } - else - { - if (Math.Abs(Main.player[npc.target].velocity.X) > 0.1f || Math.Abs(Main.player[npc.target].velocity.Y) > 0.1f) - { - Main.PlaySound(SoundID.Item117, Main.player[npc.target].position); - for (int num621 = 0; num621 < 20; num621++) - { - int num622 = Dust.NewDust(new Vector2(Main.player[npc.target].position.X, Main.player[npc.target].position.Y), - Main.player[npc.target].width, Main.player[npc.target].height, 185, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 0.6f; - 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 < 30; num623++) - { - int num624 = Dust.NewDust(new Vector2(Main.player[npc.target].position.X, Main.player[npc.target].position.Y), - Main.player[npc.target].width, Main.player[npc.target].height, 185, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - num624 = Dust.NewDust(new Vector2(Main.player[npc.target].position.X, Main.player[npc.target].position.Y), - Main.player[npc.target].width, Main.player[npc.target].height, 185, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 0.2f; - } - if (Math.Abs(Main.player[npc.target].velocity.X) > 0.1f) - { - Main.player[npc.target].velocity.X = -Main.player[npc.target].velocity.X * 2f; - } - if (Math.Abs(Main.player[npc.target].velocity.Y) > 0.1f) - { - Main.player[npc.target].velocity.Y = -Main.player[npc.target].velocity.Y * 2f; - } - } - } - } - } - } - if (npc.velocity.X < 0f) - { - npc.spriteDirection = -1; - } - else if (npc.velocity.X > 0f) - { - npc.spriteDirection = 1; - } + // 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); + } - if (Main.player[npc.target].dead) + // 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; + } + } + + // Despawn if target is dead + if (player.dead) { npc.TargetClosest(false); - - 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) + player = Main.player[npc.target]; + if (player.dead) { - for (int a = 0; a < Main.maxNPCs; a++) + 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; + calamityGlobalNPC.newAI[3] = 1f; + chargeVelocityScalar = 0f; + rotationDirection = 0; + + npc.velocity.Y += 2f; + if (npc.position.Y > Main.worldSurface * 16.0) + npc.velocity.Y += 2f; + + if (npc.position.Y > Main.rockLayer * 16.0) { - 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; + 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; - } + // 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 - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > 6400f || !NPC.AnyNPCs(ModContent.NPCType())) - { - npc.active = false; - } + // Final phase + // Spin around the target and summon Ancient Dooms and Shadow Fireballs - float num188 = speed; - float num189 = turnSpeed; - Vector2 vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + // 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 - if (patrolSpot == Vector2.Zero) - patrolSpot = Main.player[npc.target].Center; + // Phase gate values + float velocityAdjustTime = 20f; + float chargePhaseGateValue = 300f; + float lightningRainDuration = 180f; + float eidolonWyrmPhaseDuration = 180f; + float iceMistDuration = 180f; + float spinPhaseDuration = 300f; + float ancientDoomPhaseGateValue = 30f; + float ancientDoomGateValue = 120f; + float lightningChargePhaseGateValue = 180f; - float num191 = detectsPlayer ? Main.player[npc.target].Center.X : patrolSpot.X; - float num192 = detectsPlayer ? Main.player[npc.target].Center.Y : patrolSpot.Y; + // 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[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; - if (!detectsPlayer) + // 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; + npc.dontTakeDamage = invisiblePartOfChargePhase || invisiblePartOfLightningChargePhase || invisiblePhase; + if (!invisiblePartOfChargePhase && !invisiblePartOfLightningChargePhase && !invisiblePhase) { - num192 += 800; - if (Math.Abs(npc.Center.X - num191) < 400f) //500 - { - if (npc.velocity.X > 0f) + 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 = turnDistance * 0.2f; + 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 = 60f; + + // Lightning Rain variables + Vector2 lightningRainLocation = new Vector2(0f, -baseDistance); + float lightningRainLocationDistance = turnDistance * 0.2f; + + // Wyrm and Eidolist variables + Vector2 eidolonWyrmPhaseLocation = new Vector2(0f, baseDistance); + float eidolonWyrmPhaseLocationDistance = turnDistance * 0.5f; + int maxEidolists = targetDownDeep ? 3 : 5; + + // Ice Mist variables + Vector2 iceMistLocation = new Vector2(0f, baseDistance); + float iceMistLocationDistance = turnDistance * 0.2f; + + // Spin variables + float spinRadius = baseDistance; + Vector2 spinLocation = new Vector2(0f, -spinRadius); + float spinLocationDistance = turnDistance * 0.1f; + + // Ancient Doom variables + Vector2 ancientDoomLocation = new Vector2(0f, -baseDistance); + float ancientDoomLocationDistance = turnDistance * 0.2f; + int ancientDoomLimit = targetDownDeep ? 3 : 5; + int ancientDoomDistance = 550; + float maxAncientDoomRings = 3f; + + // Lightning charge variables + Vector2 lightningChargeVector = npc.localAI[2] == 0f ? new Vector2(baseDistance, 0f) : new Vector2(-baseDistance, 0f); + float lightningChargeLocationDistance = turnDistance * 0.2f; + Vector2 lightningChargeLocation = destination + lightningChargeVector; + Vector2 lightningChargeVectorFlipped = lightningChargeVector * -1f; + float lightningSpawnY = 540f; + Vector2 lightningSpawnLocation = new Vector2(lightningChargeVector.X, -lightningSpawnY); + int numLightningBolts = 10; + float distanceBetweenBolts = lightningSpawnY * 2f / numLightningBolts; + + // Velocity and turn speed values + float baseVelocity = targetDownDeep ? 12f : 18f; + float turnSpeed = targetDownDeep ? MathHelper.ToRadians(1.5f) : MathHelper.ToRadians(2.25f); + 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; + + // Phase switch + switch ((int)AIState) + { + // First charge combo + case (int)Phase.ChargeOne: + + if (calamityGlobalNPC.newAI[2] >= chargePhaseGateValue) { - num191 += 500f; + ChargeDust(7, (float)Math.PI); + + // Use a lerp to smoothly scale up velocity and turn speed + if (calamityGlobalNPC.newAI[3] == 1f) + { + 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; + } + else + { + // Charge + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[3] > 1f) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + 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; + calamityGlobalNPC.newAI[3] = 1f; + 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 + if (calamityGlobalNPC.newAI[3] == 1f) { - num191 -= 500f; + 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 lightningVelocity = (targetDownDeep && !targetOnMount) ? 6f : 8f; + 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) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + npc.localAI[0] = 0f; + AIState = (float)Phase.FastCharge; + calamityGlobalNPC.newAI[2] = fastChargeGateValue; + calamityGlobalNPC.newAI[3] = 1f; + 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 + if (calamityGlobalNPC.newAI[3] == 1f) + { + 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; + } + else + { + // Charge very quickly + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[3] > 1f) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + 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; + + calamityGlobalNPC.newAI[3] = 1f; + 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 + if (calamityGlobalNPC.newAI[3] == 1f) + { + 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; + } + else + { + // Charge + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + if ((destination - npc.Center).Length() < chargeLocationDistance || calamityGlobalNPC.newAI[3] > 1f) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + 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; + calamityGlobalNPC.newAI[3] = 1f; + 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 + if (calamityGlobalNPC.newAI[3] == 1f) + { + 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 iceMistVelocity = targetDownDeep ? 12f : 16f; + 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) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + npc.localAI[0] = 1f; + AIState = (float)Phase.FastCharge; + calamityGlobalNPC.newAI[2] = fastChargeGateValue; + calamityGlobalNPC.newAI[3] = 1f; + 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 + if (calamityGlobalNPC.newAI[3] == 1f) + { + 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 = baseVelocity * 2f; + 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) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + rotationDirection = 0; + AIState = phase4 ? (float)Phase.LightningCharge : (float)Phase.ChargeOne; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 1f; + 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 ancientDoomScale = (int)(aiGateValue / ancientDoomGateValue); + ancientDoomLimit += ancientDoomScale; + ancientDoomDistance += ancientDoomScale * 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 + if (calamityGlobalNPC.newAI[3] == 1f) + { + 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; + } + else + { + // Charge + + // Become totally visible + npc.Opacity = 1f; + + destination = chargeDestination; + + // Lightning barrage + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[3] == 0f) + { + npc.localAI[3] = 1f; + int type = ProjectileID.CultistBossLightningOrbArc; + int damage = npc.GetProjectileDamage(type); + for (int i = 0; i < numLightningBolts; i++) + { + lightningSpawnLocation.Y += distanceBetweenBolts * i; + Vector2 projectileDestination = player.Center - lightningSpawnLocation; + float ai = Main.rand.Next(100); + int proj = Projectile.NewProjectile(lightningSpawnLocation, npc.velocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + Main.projectile[proj].tileCollide = false; + } + } + + if ((destination - npc.Center).Length() < lightningChargeLocationDistance || calamityGlobalNPC.newAI[3] > 1f) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + AIState = npc.localAI[2] == 0f ? (float)Phase.LightningRain : (float)Phase.IceMist; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 1f; + + 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 ancientDoomScale = (int)(aiGateValue / ancientDoomGateValue); + ancientDoomLimit += ancientDoomScale; + ancientDoomDistance += ancientDoomScale * 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(); + } + } + } + + // Spin + // 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 = baseVelocity * 2f; + 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) + { + // Use a lerp to smoothly scale down velocity and turn speed + chargeVelocityScalar -= chargeVelocityScalarIncrement * 2f; + if (chargeVelocityScalar < 0f) + chargeVelocityScalar = 0f; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime + 1f) + { + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[3] = 1f; + + 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; } } - else - { - num188 = 10f; - num189 = 0.175f; - if (!Main.player[npc.target].wet) - { - num188 = 20f; - num189 = 0.25f; - } - } - 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 = (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)); - float num196 = System.Math.Abs(num191); - float num197 = System.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 ((double)System.Math.Abs(num192) < (double)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 ((double)System.Math.Abs(num191) < (double)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 ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)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 ((double)(System.Math.Abs(npc.velocity.X) + System.Math.Abs(npc.velocity.Y)) < (double)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)System.Math.Atan2((double)npc.velocity.Y, (double)npc.velocity.X) + 1.57f; - } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } + // Increase velocity if velocity is ever zero + if (npc.velocity == Vector2.Zero) + npc.velocity = Vector2.Normalize(player.Center - npc.Center).SafeNormalize(Vector2.Zero) * baseVelocity; - public override bool? CanBeHitByProjectile(Projectile projectile) - { - if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) - { - return detectsPlayer; - } - return null; - } + // 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; + } - public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) + // Velocity upper limit + if (npc.velocity.Length() > baseVelocity) + npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * baseVelocity; + + // Reduce Y velocity if it's less than 1 + if (Math.Abs(npc.velocity.Y) < 1f) + npc.velocity.Y -= 0.1f; + + // Storm code + if (calamityGlobalNPC.newAI[3] == 0f) + { + // Start a storm + if (Main.netMode == NetmodeID.MultiplayerClient || (Main.netMode == NetmodeID.SinglePlayer && Main.gameMenu)) + return; + + CalamityUtils.StartRain(true, true); + calamityGlobalNPC.newAI[3] = 1f; + } + } + + 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 StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + return !CalamityUtils.AntiButcher(npc, ref damage, 0.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 = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } - Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Vector2 center = npc.Center; + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector = center - Main.screenPosition; - vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); + vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge").Height) * 0.5f; + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmHeadGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override float SpawnChance(NPCSpawnInfo spawnInfo) - { - if (spawnInfo.player.Calamity().ZoneAbyssLayer4 && spawnInfo.water && !NPC.AnyNPCs(ModContent.NPCType()) && CalamityWorld.downedPolterghast) - { - return SpawnCondition.CaveJellyfish.Chance * 0.012f; - } - return 0f; - } + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } - public override void NPCLoot() + public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType(), 80, 100); DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItem(npc, ModContent.ItemType()); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge); + DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 1, 50, 108); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 2, 15, 27); DropHelper.DropItemCondition(npc, ItemID.Ectoplasm, NPC.downedPlantBoss, 1, 21, 32); } - public override void HitEffect(int hitDirection, double damage) - { - if (detectsPlayer) - { - 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 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); - public override bool CheckActive() - { - if (detectsPlayer && !Main.player[npc.target].dead) - { - return false; - } - if (npc.timeLeft <= 0 && Main.netMode != NetmodeID.MultiplayerClient) - { - for (int k = (int)npc.ai[0]; k > 0; k = (int)Main.npc[k].ai[0]) - { - if (Main.npc[k].active) - { - Main.npc[k].active = false; - if (Main.netMode == NetmodeID.Server) - { - Main.npc[k].life = 0; - Main.npc[k].netSkip = -1; - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, k, 0f, 0f, 0f, 0, 0, 0); - } - } - } - } - return true; - } + 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); - public override void OnHitPlayer(Player player, int damage, bool crit) + 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) { - player.AddBuff(ModContent.BuffType(), 1200, true); + if (npc.Opacity == 1f) + player.AddBuff(ModContent.BuffType(), 600, true); } } } diff --git a/NPCs/Abyss/EidolonWyrmHeadHuge_Head_Boss.png b/NPCs/Abyss/EidolonWyrmHeadHuge_Head_Boss.png new file mode 100644 index 0000000000..ffafb0bc3b Binary files /dev/null and b/NPCs/Abyss/EidolonWyrmHeadHuge_Head_Boss.png differ diff --git a/NPCs/Abyss/EidolonWyrmTail.cs b/NPCs/Abyss/EidolonWyrmTail.cs index 5410543ebc..7220f9aa9a 100644 --- a/NPCs/Abyss/EidolonWyrmTail.cs +++ b/NPCs/Abyss/EidolonWyrmTail.cs @@ -126,7 +126,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -144,10 +144,6 @@ namespace CalamityMod.NPCs.Abyss public override void HitEffect(int hitDirection, double damage) { - for (int k = 0; k < 3; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { for (int k = 0; k < 10; k++) @@ -157,11 +153,5 @@ namespace CalamityMod.NPCs.Abyss Gore.NewGore(npc.Center, npc.velocity, mod.GetGoreSlot("Gores/Wyrm4"), 1f); } } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Bleeding, 60, true); - player.AddBuff(ModContent.BuffType(), 60, true); - } } } diff --git a/NPCs/Abyss/EidolonWyrmTailHuge.cs b/NPCs/Abyss/EidolonWyrmTailHuge.cs index 7ea423cc0b..0c16cde15c 100644 --- a/NPCs/Abyss/EidolonWyrmTailHuge.cs +++ b/NPCs/Abyss/EidolonWyrmTailHuge.cs @@ -1,6 +1,6 @@ -using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,15 +16,17 @@ namespace CalamityMod.NPCs.Abyss public override void SetDefaults() { - npc.damage = 100; //70 - npc.width = 86; //28 - npc.height = 120; //28 + npc.damage = 100; + npc.width = 86; + npc.height = 120; npc.defense = 0; - npc.lifeMax = 1000000; - npc.aiStyle = -1; //new - aiType = -1; //new + npc.LifeMaxNERB(1750000, 2012500); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; npc.knockBackResist = 0f; - npc.alpha = 255; + npc.Opacity = 0f; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; @@ -36,132 +38,126 @@ namespace CalamityMod.NPCs.Abyss npc.chaseable = false; } - 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) => false; public override void AI() { npc.damage = 0; + 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) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } - if (!NPC.AnyNPCs(ModContent.NPCType())) - { - npc.active = false; - } - if (Main.npc[(int)npc.ai[1]].alpha < 128) - { - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } - 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); + + // 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; + } + if (!shouldDespawn) + { + if (npc.ai[1] > 0f) + shouldDespawn = false; + else if (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; + } + + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + + float chargePhaseGateValue = 300f; + float lightningChargePhaseGateValue = 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; + } + + 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((double)(num191 * num191 + num192 * num192)); - if (npc.ai[1] > 0f && npc.ai[1] < (float)Main.npc.Length) + + float num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); + if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) { try { - vector18 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (float)(Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (float)(Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; + vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; + num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; } catch { } - npc.rotation = (float)System.Math.Atan2((double)num192, (double)num191) + 1.57f; - num193 = (float)System.Math.Sqrt((double)(num191 * num191 + num192 * num192)); + + npc.rotation = (float)Math.Atan2(num192, num191) + MathHelper.PiOver2; + num193 = (float)Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; - num193 = (num193 - (float)num194) / num193; + num193 = (num193 - num194) / num193; num191 *= num193; num192 *= num193; npc.velocity = Vector2.Zero; 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 void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - { - spriteEffects = SpriteEffects.FlipHorizontally; - } + SpriteEffects spriteEffects = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / 2); Vector2 vector = center - Main.screenPosition; - vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); - Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); + vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Width, ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge").Height) * 0.5f; + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); + Color color = new Color(127, 127, 127, 0).MultiplyRGBA(Color.LightYellow) * npc.Opacity; Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/EidolonWyrmTailGlowHuge"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; - public override bool PreNPCLoot() - { - return 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, 4, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { for (int k = 0; k < 10; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, 4, hitDirection, -1f, 0, default, 1f); - } + Gore.NewGore(npc.Center, npc.velocity, mod.GetGoreSlot("Gores/WyrmAdult4"), 1f); } } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.Bleeding, 60, true); - player.AddBuff(ModContent.BuffType(), 60, true); - } } } diff --git a/NPCs/Abyss/GiantSquid.cs b/NPCs/Abyss/GiantSquid.cs index 0efbc60488..f9f9b6677f 100644 --- a/NPCs/Abyss/GiantSquid.cs +++ b/NPCs/Abyss/GiantSquid.cs @@ -220,7 +220,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/GiantSquidGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GiantSquidGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Cyan); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GiantSquidGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -247,7 +247,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 2, 4); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f, 1, 2); diff --git a/NPCs/Abyss/GulperEelBody.cs b/NPCs/Abyss/GulperEelBody.cs index a4384fb3ac..a8a8cf7e47 100644 --- a/NPCs/Abyss/GulperEelBody.cs +++ b/NPCs/Abyss/GulperEelBody.cs @@ -127,7 +127,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelBodyGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelBodyGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/Abyss/GulperEelBodyAlt.cs b/NPCs/Abyss/GulperEelBodyAlt.cs index 5bbe2a2c98..e5a02e6d21 100644 --- a/NPCs/Abyss/GulperEelBodyAlt.cs +++ b/NPCs/Abyss/GulperEelBodyAlt.cs @@ -127,7 +127,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelBodyAltGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/Abyss/GulperEelHead.cs b/NPCs/Abyss/GulperEelHead.cs index ec93fa97fe..d022691127 100644 --- a/NPCs/Abyss/GulperEelHead.cs +++ b/NPCs/Abyss/GulperEelHead.cs @@ -314,7 +314,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelHeadGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelHeadGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -335,7 +335,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 2, 3); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 6, 8); diff --git a/NPCs/Abyss/GulperEelTail.cs b/NPCs/Abyss/GulperEelTail.cs index 5adc3cf9db..9ffad34b42 100644 --- a/NPCs/Abyss/GulperEelTail.cs +++ b/NPCs/Abyss/GulperEelTail.cs @@ -127,7 +127,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelTailGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightYellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/GulperEelTailGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/Abyss/Laserfish.cs b/NPCs/Abyss/Laserfish.cs index d0c8bb2756..c2f0ead0b8 100644 --- a/NPCs/Abyss/Laserfish.cs +++ b/NPCs/Abyss/Laserfish.cs @@ -90,7 +90,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/LaserfishGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/LaserfishGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Yellow); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/LaserfishGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -111,7 +111,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f); } diff --git a/NPCs/Abyss/LuminousCorvina.cs b/NPCs/Abyss/LuminousCorvina.cs index c3971814bc..2a464acdf2 100644 --- a/NPCs/Abyss/LuminousCorvina.cs +++ b/NPCs/Abyss/LuminousCorvina.cs @@ -262,7 +262,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/LuminousCorvinaGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/LuminousCorvinaGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/LuminousCorvinaGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -285,7 +285,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType(), 8, 15); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 1, 2); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f); diff --git a/NPCs/Abyss/MirageJelly.cs b/NPCs/Abyss/MirageJelly.cs index 2d632bf850..4df2aebc7f 100644 --- a/NPCs/Abyss/MirageJelly.cs +++ b/NPCs/Abyss/MirageJelly.cs @@ -181,7 +181,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/MirageJellyGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/MirageJellyGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Purple); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/MirageJellyGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -207,7 +207,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { DropHelper.DropItemCondition(npc, ModContent.ItemType(), NPC.downedBoss3, 10, 1, 1); - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 2, 5, 7); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 2, 5, 7); DropHelper.DropItemChance(npc, ModContent.ItemType(), Main.expertMode ? 5 : 7); diff --git a/NPCs/Abyss/OarfishHead.cs b/NPCs/Abyss/OarfishHead.cs index e40e114ae2..6d439fa7b1 100644 --- a/NPCs/Abyss/OarfishHead.cs +++ b/NPCs/Abyss/OarfishHead.cs @@ -306,7 +306,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 3, 5); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f, 1, 2); } diff --git a/NPCs/Abyss/Reaper.cs b/NPCs/Abyss/Reaper.cs index 9b3afc646e..7e679ff5b5 100644 --- a/NPCs/Abyss/Reaper.cs +++ b/NPCs/Abyss/Reaper.cs @@ -649,7 +649,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance * 100f); DropHelper.DropItem(npc, ModContent.ItemType(), 40, 50); DropHelper.DropItem(npc, ModContent.ItemType(), 2, 3); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 2, 10, 17); diff --git a/NPCs/Abyss/ToxicMinnow.cs b/NPCs/Abyss/ToxicMinnow.cs index a21ae4647e..519f43f74c 100644 --- a/NPCs/Abyss/ToxicMinnow.cs +++ b/NPCs/Abyss/ToxicMinnow.cs @@ -105,7 +105,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/ToxicMinnowGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/ToxicMinnowGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightGreen); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/ToxicMinnowGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -148,7 +148,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 2, 3); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f, 2, 3); } diff --git a/NPCs/Abyss/Viperfish.cs b/NPCs/Abyss/Viperfish.cs index a1170a2eb4..bd3f24e2a3 100644 --- a/NPCs/Abyss/Viperfish.cs +++ b/NPCs/Abyss/Viperfish.cs @@ -88,7 +88,7 @@ namespace CalamityMod.NPCs.Abyss Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/Abyss/ViperfishGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/Abyss/ViperfishGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Gold); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Abyss/ViperfishGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); @@ -115,7 +115,6 @@ namespace CalamityMod.NPCs.Abyss public override void NPCLoot() { - DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.revenge, HalibutCannon.DropChance); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.25f); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.5f, 1, 2); DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 0.5f); diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index a6f24d9caf..6bda0229b1 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -9,6 +9,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Items.Weapons.Melee; namespace CalamityMod.NPCs.AcidRain { @@ -492,6 +493,7 @@ namespace CalamityMod.NPCs.AcidRain public override void NPCLoot() { DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); } } } diff --git a/NPCs/AquaticScourge/AquaticScourgeBody.cs b/NPCs/AquaticScourge/AquaticScourgeBody.cs index f83bfd048e..0e341dc802 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBody.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBody.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.AquaticScourge aiType = -1; npc.knockBackResist = 0f; npc.alpha = 255; - npc.LifeMaxNERB(80000, 92000, 10000000); + npc.LifeMaxNERB(80000, 92000, 1000000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.behindTiles = true; @@ -82,7 +82,7 @@ namespace CalamityMod.NPCs.AquaticScourge Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor); if (Main.npc[(int)npc.ai[2]].Calamity().newAI[3] > 480f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) diff --git a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs index e903f3841f..59f2339a34 100644 --- a/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs +++ b/NPCs/AquaticScourge/AquaticScourgeBodyAlt.cs @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.AquaticScourge aiType = -1; npc.knockBackResist = 0f; npc.alpha = 255; - npc.LifeMaxNERB(80000, 92000, 10000000); + npc.LifeMaxNERB(80000, 92000, 1000000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.behindTiles = true; @@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.AquaticScourge Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor); if (Main.npc[(int)npc.ai[2]].Calamity().newAI[3] > 480f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) diff --git a/NPCs/AquaticScourge/AquaticScourgeHead.cs b/NPCs/AquaticScourge/AquaticScourgeHead.cs index 58a3510805..e7bb9fe125 100644 --- a/NPCs/AquaticScourge/AquaticScourgeHead.cs +++ b/NPCs/AquaticScourge/AquaticScourgeHead.cs @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.AquaticScourge npc.DR_NERD(0.05f); npc.aiStyle = -1; aiType = -1; - npc.LifeMaxNERB(80000, 92000, 10000000); + npc.LifeMaxNERB(80000, 92000, 1000000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -82,6 +82,7 @@ namespace CalamityMod.NPCs.AquaticScourge { if (npc.justHit || npc.life <= npc.lifeMax * 0.99 || BossRushEvent.BossRushActive) music = CalamityMod.Instance.GetMusicFromMusicMod("AquaticScourge") ?? MusicID.Boss2; + CalamityAI.AquaticScourgeAI(npc, mod, true); } @@ -96,7 +97,7 @@ namespace CalamityMod.NPCs.AquaticScourge Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor); if (npc.Calamity().newAI[3] > 480f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) @@ -130,23 +131,22 @@ namespace CalamityMod.NPCs.AquaticScourge public override bool? CanBeHitByProjectile(Projectile projectile) { if (projectile.minion && !projectile.Calamity().overridesMinionDamagePrevention) - { return npc.Calamity().newAI[0] == 1f; - } + return null; } public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.playerSafe) - { return 0f; - } + if (spawnInfo.player.Calamity().ZoneSulphur && spawnInfo.water) { if (!NPC.AnyNPCs(ModContent.NPCType())) return 0.01f; } + return 0f; } @@ -239,15 +239,13 @@ namespace CalamityMod.NPCs.AquaticScourge public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { for (int k = 0; k < 15; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AquaticScourgeGores/ASHead"), 1f); } } @@ -255,9 +253,8 @@ namespace CalamityMod.NPCs.AquaticScourge public override bool CheckActive() { if (npc.Calamity().newAI[0] == 1f && !Main.player[npc.target].dead && npc.Calamity().newAI[1] != 1f) - { return false; - } + return true; } diff --git a/NPCs/AquaticScourge/AquaticScourgeTail.cs b/NPCs/AquaticScourge/AquaticScourgeTail.cs index 5750ec01d7..147fd4bd66 100644 --- a/NPCs/AquaticScourge/AquaticScourgeTail.cs +++ b/NPCs/AquaticScourge/AquaticScourgeTail.cs @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.AquaticScourge aiType = -1; npc.knockBackResist = 0f; npc.alpha = 255; - npc.LifeMaxNERB(80000, 92000, 10000000); + npc.LifeMaxNERB(80000, 92000, 1000000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.behindTiles = true; @@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.AquaticScourge Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor); if (Main.npc[(int)npc.ai[2]].Calamity().newAI[3] > 480f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) diff --git a/NPCs/Astral/AstralProbe.cs b/NPCs/Astral/AstralProbe.cs index b6d9be2fb1..19031a1f44 100644 --- a/NPCs/Astral/AstralProbe.cs +++ b/NPCs/Astral/AstralProbe.cs @@ -221,7 +221,7 @@ namespace CalamityMod.NPCs.Astral 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, 4f + npc.gfxOffY); + 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); diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 7ecd9f4524..1782798cc0 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.AstrumAureus npc.height = 280; npc.defense = 40; npc.DR_NERD(0.15f); - npc.LifeMaxNERB(84000, NPC.downedMoonlord ? 292500 : 107000, 7400000); // 30 seconds in boss rush + npc.LifeMaxNERB(84000, NPC.downedMoonlord ? 292500 : 107000, 740000); // 30 seconds in boss rush npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; diff --git a/NPCs/AstrumAureus/AureusSpawn.cs b/NPCs/AstrumAureus/AureusSpawn.cs index a11865b1b1..542c154698 100644 --- a/NPCs/AstrumAureus/AureusSpawn.cs +++ b/NPCs/AstrumAureus/AureusSpawn.cs @@ -31,10 +31,6 @@ namespace CalamityMod.NPCs.AstrumAureus npc.alpha = 255; npc.defense = 10; npc.lifeMax = 3000; - if (BossRushEvent.BossRushActive) - { - npc.lifeMax = 30000; - } npc.knockBackResist = 0f; npc.noGravity = true; npc.noTileCollide = true; @@ -101,7 +97,7 @@ namespace CalamityMod.NPCs.AstrumAureus npc.life = 0; return; } - float num1372 = BossRushEvent.BossRushActive ? 24f : 18f; + float num1372 = 18f; Vector2 vector167 = new Vector2(npc.Center.X + (float)(npc.direction * 20), npc.Center.Y + 6f); float num1373 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector167.X; float num1374 = Main.player[npc.target].Center.Y - vector167.Y; @@ -114,7 +110,7 @@ namespace CalamityMod.NPCs.AstrumAureus return; } - float num1446 = BossRushEvent.BossRushActive ? 10f : 7f; + float num1446 = 7f; int num1447 = 480; if (npc.localAI[1] == 1f) { @@ -247,14 +243,14 @@ namespace CalamityMod.NPCs.AstrumAureus color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -269,7 +265,7 @@ namespace CalamityMod.NPCs.AstrumAureus 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -307,7 +303,9 @@ namespace CalamityMod.NPCs.AstrumAureus player.AddBuff(ModContent.BuffType(), 120, true); } - public override bool CheckDead() + public override bool PreNPCLoot() => false; + + 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 c7c1ec345b..f4ac21e06f 100644 --- a/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusBodySpectral.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.AstrumDeus npc.width = 38; npc.height = 44; npc.defense = 50; - npc.LifeMaxNERB(187500, 225000, 6500000); + npc.LifeMaxNERB(187500, 225000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -97,14 +97,14 @@ namespace CalamityMod.NPCs.AstrumDeus 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/AstrumDeus/AstrumDeusBodyAltGlow") : ModContent.GetTexture("CalamityMod/NPCs/AstrumDeus/AstrumDeusBodyGlow"); @@ -121,7 +121,7 @@ namespace CalamityMod.NPCs.AstrumDeus 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); if (npc.localAI[3] != 1f) diff --git a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs index 74c30d9772..2723515d0a 100644 --- a/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusHeadSpectral.cs @@ -41,7 +41,7 @@ namespace CalamityMod.NPCs.AstrumDeus npc.width = 56; npc.height = 56; npc.defense = 25; - npc.LifeMaxNERB(187500, 225000, 6500000); + npc.LifeMaxNERB(187500, 225000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -112,14 +112,14 @@ namespace CalamityMod.NPCs.AstrumDeus 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -136,7 +136,7 @@ namespace CalamityMod.NPCs.AstrumDeus 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, 4f + npc.gfxOffY); + 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; diff --git a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs index 2e433ce3cc..ffcde84d21 100644 --- a/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs +++ b/NPCs/AstrumDeus/AstrumDeusTailSpectral.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.AstrumDeus npc.width = 52; npc.height = 68; npc.defense = 75; - npc.LifeMaxNERB(187500, 225000, 6500000); + npc.LifeMaxNERB(187500, 225000, 650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -96,14 +96,14 @@ namespace CalamityMod.NPCs.AstrumDeus 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -119,7 +119,7 @@ namespace CalamityMod.NPCs.AstrumDeus 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index 341064d544..b8ff7fbce3 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental } if (BossRushEvent.BossRushActive) { - npc.lifeMax = 100000; + npc.lifeMax = 10000; } } @@ -89,7 +89,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental // Set DR based on boost status npc.Calamity().DR = boostDR ? boostedDR : normalDR; - float num1446 = goIntoShell ? 1f : (BossRushEvent.BossRushActive ? 12f : 6f); + float num1446 = goIntoShell ? 1f : 6f; int num1447 = 480; if (npc.localAI[1] == 1f) { @@ -111,7 +111,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental 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 = BossRushEvent.BossRushActive ? 7.5f : 5f; + float speed = 5f; Vector2 vector = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)(npc.height / 2)); float num6 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector.X + (float)Main.rand.Next(-10, 11); float num7 = Main.player[npc.target].position.Y + (float)Main.player[npc.target].height * 0.5f - vector.Y + (float)Main.rand.Next(-10, 11); diff --git a/NPCs/BrimstoneElemental/BrimstoneElemental.cs b/NPCs/BrimstoneElemental/BrimstoneElemental.cs index 4f2cca0c78..cc3d4cd060 100644 --- a/NPCs/BrimstoneElemental/BrimstoneElemental.cs +++ b/NPCs/BrimstoneElemental/BrimstoneElemental.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Items.Accessories; @@ -17,7 +16,6 @@ using Microsoft.Xna.Framework; using System.IO; using Terraria; using Terraria.ID; -using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs.BrimstoneElemental @@ -39,7 +37,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental npc.height = 150; npc.defense = 15; npc.value = Item.buyPrice(0, 12, 0, 0); - npc.LifeMaxNERB(30000, 41000, 6500000); + npc.LifeMaxNERB(30000, 41000, 650000); npc.DR_NERD(0.15f); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { @@ -91,7 +89,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental player.AddBuff(ModContent.BuffType(), 180, true); } - public override void FindFrame(int frameHeight) //9 total frames + public override void FindFrame(int frameHeight) // 9 total frames { npc.frameCounter += 1.0; if (npc.ai[0] <= 2f) diff --git a/NPCs/Bumblebirb/Bumblefuck.cs b/NPCs/Bumblebirb/Bumblefuck.cs index f4a0080002..ce206c6ccb 100644 --- a/NPCs/Bumblebirb/Bumblefuck.cs +++ b/NPCs/Bumblebirb/Bumblefuck.cs @@ -48,7 +48,7 @@ namespace CalamityMod.NPCs.Bumblebirb npc.DR_NERD(0.1f, null, null, null, true); CalamityGlobalNPC global = npc.Calamity(); global.multDRReductions.Add(BuffID.CursedInferno, 0.9f); - npc.LifeMaxNERB(170625, 189375, 3000000); // Old HP - 227500, 252500 + npc.LifeMaxNERB(170625, 189375, 300000); // Old HP - 227500, 252500 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -105,6 +105,10 @@ namespace CalamityMod.NPCs.Bumblebirb // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) + lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; + // Phases bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; bool phase3 = lifeRatio < (death ? 0.4f : revenge ? 0.25f : 0.1f); @@ -184,11 +188,15 @@ namespace CalamityMod.NPCs.Bumblebirb { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || CalamityWorld.malice || BossRushEvent.BossRushActive; // Percent life remaining - float lifeRatio = (float)npc.life / (float)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) + lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; // Phases bool phase2 = lifeRatio < (revenge ? 0.75f : 0.5f) || death; @@ -256,7 +264,7 @@ namespace CalamityMod.NPCs.Bumblebirb color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -311,7 +319,7 @@ namespace CalamityMod.NPCs.Bumblebirb 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, 4f + npc.gfxOffY); + vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -321,7 +329,7 @@ namespace CalamityMod.NPCs.Bumblebirb 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, 4f + npc.gfxOffY); + 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) @@ -352,7 +360,7 @@ namespace CalamityMod.NPCs.Bumblebirb 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } @@ -364,7 +372,7 @@ namespace CalamityMod.NPCs.Bumblebirb 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, 4f + npc.gfxOffY); + vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Bumblebirb/Bumblefuck2.cs b/NPCs/Bumblebirb/Bumblefuck2.cs index 2cee269829..c300b0016f 100644 --- a/NPCs/Bumblebirb/Bumblefuck2.cs +++ b/NPCs/Bumblebirb/Bumblefuck2.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Bumblebirb npc.width = 120; npc.height = 80; npc.defense = 20; - npc.LifeMaxNERB(9000, 11250, 50000); // Old HP - 12000, 15000 + npc.LifeMaxNERB(9000, 11250, 5000); // Old HP - 12000, 15000 npc.knockBackResist = 0f; npc.lavaImmune = true; npc.noGravity = true; @@ -300,10 +300,11 @@ namespace CalamityMod.NPCs.Bumblebirb } } - public override bool PreNPCLoot() => !CalamityPlayer.areThereAnyDamnBosses; - public override void NPCLoot() { + if (CalamityPlayer.areThereAnyDamnBosses) + return; + DropHelper.DropItemSpray(npc, ModContent.ItemType(), 2, 4); } @@ -343,14 +344,14 @@ namespace CalamityMod.NPCs.Bumblebirb 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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; diff --git a/NPCs/Calamitas/Calamitas.cs b/NPCs/Calamitas/Calamitas.cs index 66a7ad67ed..8f17bfe511 100644 --- a/NPCs/Calamitas/Calamitas.cs +++ b/NPCs/Calamitas/Calamitas.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.Calamitas npc.defense = 15; npc.DR_NERD(0.15f); npc.value = 0f; - npc.LifeMaxNERB(37500, 51750, 5200000); + npc.LifeMaxNERB(37500, 51750, 520000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage *= 3; @@ -100,14 +100,14 @@ namespace CalamityMod.NPCs.Calamitas 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/CalamitasGlow"); @@ -122,7 +122,7 @@ namespace CalamityMod.NPCs.Calamitas 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Calamitas/CalamitasRun.cs b/NPCs/Calamitas/CalamitasRun.cs index 687ce7ce36..bcbe90e9e1 100644 --- a/NPCs/Calamitas/CalamitasRun.cs +++ b/NPCs/Calamitas/CalamitasRun.cs @@ -32,7 +32,7 @@ namespace CalamityMod.NPCs.Calamitas npc.height = 120; npc.defense = 10; npc.DR_NERD(0.15f); - npc.LifeMaxNERB(9000, 13200, 800000); + npc.LifeMaxNERB(9000, 13200, 80000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage *= 3; @@ -98,14 +98,14 @@ namespace CalamityMod.NPCs.Calamitas color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -120,7 +120,7 @@ namespace CalamityMod.NPCs.Calamitas 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Calamitas/CalamitasRun2.cs b/NPCs/Calamitas/CalamitasRun2.cs index d8e4025eef..4f297c5c02 100644 --- a/NPCs/Calamitas/CalamitasRun2.cs +++ b/NPCs/Calamitas/CalamitasRun2.cs @@ -32,7 +32,7 @@ namespace CalamityMod.NPCs.Calamitas npc.height = 120; npc.defense = 10; npc.DR_NERD(0.15f); - npc.LifeMaxNERB(7500, 11025, 800000); + npc.LifeMaxNERB(7500, 11025, 80000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage *= 3; @@ -98,14 +98,14 @@ namespace CalamityMod.NPCs.Calamitas color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -120,7 +120,7 @@ namespace CalamityMod.NPCs.Calamitas 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Calamitas/CalamitasRun3.cs b/NPCs/Calamitas/CalamitasRun3.cs index bdebb54d74..47d4ebff58 100644 --- a/NPCs/Calamitas/CalamitasRun3.cs +++ b/NPCs/Calamitas/CalamitasRun3.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.Calamitas npc.defense = 25; npc.value = Item.buyPrice(0, 15, 0, 0); npc.DR_NERD(0.15f); - npc.LifeMaxNERB(28125, 38812, 3900000); + npc.LifeMaxNERB(28125, 38812, 390000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage *= 3; @@ -117,14 +117,14 @@ namespace CalamityMod.NPCs.Calamitas color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/CalamitasRun3Glow"); @@ -139,7 +139,7 @@ namespace CalamityMod.NPCs.Calamitas 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Calamitas/LifeSeeker.cs b/NPCs/Calamitas/LifeSeeker.cs index 9f9ee6f774..ecae78c18f 100644 --- a/NPCs/Calamitas/LifeSeeker.cs +++ b/NPCs/Calamitas/LifeSeeker.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Calamitas npc.lifeMax = 200; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 30000; + npc.lifeMax = 3000; } npc.aiStyle = 5; aiType = NPCID.Probe; @@ -76,14 +76,14 @@ namespace CalamityMod.NPCs.Calamitas color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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 / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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/Calamitas/LifeSeekerGlow"); @@ -98,7 +98,7 @@ namespace CalamityMod.NPCs.Calamitas color41 *= (float)(num153 - num163) / 15f; Vector2 vector44 = npc.oldPos[num163] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector44 -= new Vector2((float)texture.Width, (float)(texture.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -108,11 +108,6 @@ namespace CalamityMod.NPCs.Calamitas return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 120, true); diff --git a/NPCs/Calamitas/SoulSeeker.cs b/NPCs/Calamitas/SoulSeeker.cs index 3347c7233c..dcf59123b9 100644 --- a/NPCs/Calamitas/SoulSeeker.cs +++ b/NPCs/Calamitas/SoulSeeker.cs @@ -40,7 +40,7 @@ namespace CalamityMod.NPCs.Calamitas npc.lifeMax = CalamityWorld.death ? 1500 : 2500; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 150000; + npc.lifeMax = 15000; } npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; @@ -83,7 +83,7 @@ namespace CalamityMod.NPCs.Calamitas Vector2 velocity = Main.player[npc.target].Center - npc.Center; velocity.Normalize(); - velocity *= BossRushEvent.BossRushActive ? 14f : 9f; + velocity *= 9f; npc.rotation = velocity.ToRotation() + MathHelper.Pi; timer++; @@ -149,10 +149,7 @@ namespace CalamityMod.NPCs.Calamitas } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -176,14 +173,14 @@ namespace CalamityMod.NPCs.Calamitas 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -198,7 +195,7 @@ namespace CalamityMod.NPCs.Calamitas 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, 4f + npc.gfxOffY); + afterimagePos += origin * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture, afterimagePos, npc.frame, glowColor, npc.rotation, origin, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 08ce0440c2..f65507dcf2 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Dusts; @@ -35,10 +36,11 @@ namespace CalamityMod.NPCs public static void AquaticScourgeAI(NPC npc, Mod mod, bool head) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; // Adjust hostility and stats if (npc.justHit || npc.life <= npc.lifeMax * 0.99 || BossRushEvent.BossRushActive || @@ -96,10 +98,17 @@ namespace CalamityMod.NPCs float enrageScale = 0f; if ((!player.Calamity().ZoneSulphur && notOcean) || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 2f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } Vector2 vectorCenter = npc.Center; @@ -120,7 +129,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - float num742 = BossRushEvent.BossRushActive ? 16f : death ? 10f : 8f; + 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); @@ -165,7 +174,7 @@ namespace CalamityMod.NPCs { // Add 2 seconds to timer so that spinning happens more often if Scourge isn't wet when spin ends calamityGlobalNPC.newAI[3] = isWet ? 0f : 120f; - float chargeVelocity = (BossRushEvent.BossRushActive ? 24f : death ? 16f : 12f) + 3f * enrageScale; + float chargeVelocity = (death ? 16f : 12f) + 3f * enrageScale; npc.velocity = Vector2.Normalize(player.Center - npc.Center) * chargeVelocity; npc.TargetClosest(); } @@ -179,6 +188,20 @@ namespace CalamityMod.NPCs } } + // 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[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + if (Main.netMode != NetmodeID.MultiplayerClient) { if (head) @@ -218,7 +241,7 @@ namespace CalamityMod.NPCs if (player.gravDir == -1f && expertMode) npc.localAI[0] += 2f; - if (npc.localAI[0] >= (BossRushEvent.BossRushActive ? 300f : (revenge ? 360f : 420f))) + if (npc.localAI[0] >= (revenge ? 360f : 420f)) { if (Vector2.Distance(player.Center, npc.Center) > 320f) { @@ -228,7 +251,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - float velocity = BossRushEvent.BossRushActive ? 13f : death ? 9.5f : revenge ? 7.5f : 6.5f; + float velocity = death ? 9.5f : revenge ? 7.5f : 6.5f; int totalProjectiles = expertMode ? 30 : 20; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); @@ -253,9 +276,6 @@ namespace CalamityMod.NPCs if (expertMode) vector15 *= 1f + (death ? 0.25f : 0.25f * (1f - lifeRatio)); - if (BossRushEvent.BossRushActive) - vector15 *= 1.25f; - Projectile.NewProjectile(npc.Center, vector15, type, damage, 0f, Main.myPlayer, 0f, Main.rand.Next(-45, 1)); } } @@ -289,7 +309,7 @@ namespace CalamityMod.NPCs float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float num941 = BossRushEvent.BossRushActive ? 15f : death ? 9f : 8f; + float num941 = death ? 9f : 8f; num944 = num941 / num944; num942 *= num944; num943 *= num944; @@ -313,7 +333,7 @@ namespace CalamityMod.NPCs float num944 = (float)Math.Sqrt(num942 * num942 + num943 * num943); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float num941 = BossRushEvent.BossRushActive ? 24f : death ? 15f : 12f; + float num941 = death ? 15f : 12f; num944 = num941 / num944; num942 *= num944; num943 *= num944; @@ -430,11 +450,6 @@ namespace CalamityMod.NPCs } num188 += 3f * enrageScale; num189 += 0.06f * enrageScale; - if (BossRushEvent.BossRushActive) - { - num188 = 25f; - num189 = 0.3f; - } if (death) { num188 += Vector2.Distance(player.Center, npc.Center) * 0.004f * (1f - lifeRatio); @@ -656,10 +671,11 @@ namespace CalamityMod.NPCs // Variables for buffing the AI bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; bool phase2 = lifeRatio < 0.5f && revenge; bool phase3 = lifeRatio < 0.33f; @@ -667,10 +683,17 @@ namespace CalamityMod.NPCs if (!player.ZoneUnderworldHeight || malice) enrageScale += 1f; if (!modPlayer.ZoneCalamity || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 1f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } npc.Calamity().DR = npc.ai[0] == 4f ? 0.6f : 0.15f; @@ -692,7 +715,7 @@ namespace CalamityMod.NPCs } // Speed while moving in phase 1 - float speed = BossRushEvent.BossRushActive ? 12f : death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f; + float speed = death ? 6f : revenge ? 5.5f : expertMode ? 5f : 4.5f; if (expertMode) speed += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); speed += 3f * enrageScale; @@ -746,7 +769,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[1] += 1f; - if (npc.localAI[1] >= (BossRushEvent.BossRushActive ? 90f : death ? 150f : 180f)) + if (npc.localAI[1] >= (death ? 150f : 180f)) { npc.TargetClosest(); npc.localAI[1] = 0f; @@ -860,7 +883,7 @@ namespace CalamityMod.NPCs { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num742 = BossRushEvent.BossRushActive ? 8f : death ? 5f : 4f; + 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; @@ -891,9 +914,7 @@ namespace CalamityMod.NPCs } } - float projectileSpeed = BossRushEvent.BossRushActive ? 10f : death ? 6f : 5f; - if (calamityGlobalNPC.enraged > 0) - projectileSpeed += 4f; + float projectileSpeed = death ? 6f : 5f; if (revenge) projectileSpeed += 1f; projectileSpeed += 2f * enrageScale; @@ -927,7 +948,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > maxVelocityY) npc.velocity.Y = maxVelocityY; @@ -937,7 +958,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -maxVelocityY) npc.velocity.Y = -maxVelocityY; @@ -948,7 +969,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.985f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X -= death ? 0.12f : 0.1f; if (npc.velocity.X > maxVelocityX) npc.velocity.X = maxVelocityX; @@ -958,7 +979,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.985f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X += death ? 0.12f : 0.1f; if (npc.velocity.X < -maxVelocityX) npc.velocity.X = -maxVelocityX; @@ -986,15 +1007,13 @@ namespace CalamityMod.NPCs npc.localAI[0] += 1f; if (expertMode) npc.localAI[0] += 1f - lifeRatio; - if (calamityGlobalNPC.enraged > 0) - npc.localAI[0] += 2f; npc.localAI[0] += 1f * enrageScale; if (npc.localAI[0] >= 120f) { npc.localAI[0] = 0f; - float projectileSpeed = BossRushEvent.BossRushActive ? 12f : death ? 9f : revenge ? 8f : 6f; + float projectileSpeed = death ? 9f : revenge ? 8f : 6f; projectileSpeed += 3f * enrageScale; vectorCenter = player.Center - vectorCenter; @@ -1195,10 +1214,11 @@ namespace CalamityMod.NPCs } // Variables for increasing difficulty - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; // Percent life remaining @@ -1287,8 +1307,7 @@ namespace CalamityMod.NPCs } } - // Huge defense boost if brothers are alive - int num568 = 0; + // Huge DR boost if brothers are alive if (expertMode) { if (CalamityGlobalNPC.cataclysm != -1) @@ -1296,7 +1315,6 @@ namespace CalamityMod.NPCs if (Main.npc[CalamityGlobalNPC.cataclysm].active) { brotherAlive = true; - num568 += 255; } } if (CalamityGlobalNPC.catastrophe != -1) @@ -1304,12 +1322,18 @@ namespace CalamityMod.NPCs if (Main.npc[CalamityGlobalNPC.catastrophe].active) { brotherAlive = true; - num568 += 255; } } - npc.defense += num568 * 50; - if (!brotherAlive) - npc.defense = npc.defDefense; + if (brotherAlive) + { + calamityGlobalNPC.DR = 0.9999f; + calamityGlobalNPC.unbreakableDR = true; + } + else + { + calamityGlobalNPC.DR = 0.15f; + calamityGlobalNPC.unbreakableDR = false; + } } // Disable homing if brothers are alive @@ -1363,10 +1387,17 @@ namespace CalamityMod.NPCs float enrageScale = 0f; if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 2f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } // Rotation float num801 = npc.position.X + (npc.width / 2) - player.position.X - (player.width / 2); @@ -1460,15 +1491,9 @@ namespace CalamityMod.NPCs num824 *= 1.25f; } - if (BossRushEvent.BossRushActive) - { - num823 *= 1.5f; - num824 *= 1.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) - ((BossRushEvent.BossRushActive ? 400f : 300f) + (phase2 ? 60f : 0f)) - vector82.Y; + float num826 = player.position.Y + (player.height / 2) - (300f + (phase2 ? 60f : 0f)) - vector82.Y; float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); num827 = num823 / num827; num825 *= num827; @@ -1537,13 +1562,13 @@ namespace CalamityMod.NPCs npc.ai[0] += 1f; float hellblastGateValue = (expertMode ? 12f : 16f) - enrageScale; - if (npc.ai[0] > hellblastGateValue) + if (npc.ai[0] >= hellblastGateValue) { npc.ai[0] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); float projSpeed = malice ? 5f : 4f; - if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 3f) == 0f) + if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f) { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = distance == -1000f ? projSpeed : -projSpeed; @@ -1635,15 +1660,9 @@ namespace CalamityMod.NPCs num824 *= 1.25f; } - if (BossRushEvent.BossRushActive) - { - num823 *= 1.5f; - num824 *= 1.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) - ((BossRushEvent.BossRushActive ? 400f : 300f) + (phase2 ? 60f : 0f)) - vector82.Y; + float num826 = player.position.Y + (player.height / 2) - (300f + (phase2 ? 60f : 0f)) - vector82.Y; float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); num827 = num823 / num827; num825 *= num827; @@ -1704,10 +1723,8 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - float num828 = BossRushEvent.BossRushActive ? 18f : expertMode ? 14f : 12.5f; + float num828 = expertMode ? 14f : 12.5f; num828 += 3f * enrageScale; - if (calamityGlobalNPC.enraged > 0) - num828 += 5f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -1737,7 +1754,7 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - float num828 = BossRushEvent.BossRushActive ? 16f : expertMode ? 12f : 10.5f; + float num828 = expertMode ? 12f : 10.5f; num828 += 3f * enrageScale; int type = ModContent.ProjectileType(); @@ -1793,14 +1810,8 @@ namespace CalamityMod.NPCs num833 *= 1.25f; } - if (BossRushEvent.BossRushActive) - { - num832 *= 1.5f; - num833 *= 1.5f; - } - Vector2 vector83 = npc.Center; - float num834 = player.position.X + (player.width / 2) + (num831 * (BossRushEvent.BossRushActive ? 460 : 360)) - vector83.X; + float num834 = player.position.X + (player.width / 2) + (num831 * 360) - vector83.X; float num835 = player.position.Y + (player.height / 2) - vector83.Y; float num836 = (float)Math.Sqrt(num834 * num834 + num835 * num835); num836 = num832 / num836; @@ -1844,8 +1855,6 @@ namespace CalamityMod.NPCs { if (revenge) npc.localAI[1] += 0.5f; - if (calamityGlobalNPC.enraged > 0) - npc.localAI[1] += 0.5f; if (expertMode) npc.localAI[1] += 0.5f; } @@ -1854,7 +1863,7 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - float num837 = BossRushEvent.BossRushActive ? 16f : expertMode ? 12.5f : 11f; + float num837 = expertMode ? 12.5f : 11f; num837 += 3f * enrageScale; int type = brotherAlive ? ModContent.ProjectileType() : ModContent.ProjectileType(); @@ -1890,7 +1899,7 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - float num837 = BossRushEvent.BossRushActive ? 16f : expertMode ? 12f : 10.5f; + float num837 = expertMode ? 12f : 10.5f; num837 += 3f * enrageScale; int type = ModContent.ProjectileType(); @@ -1922,7 +1931,7 @@ namespace CalamityMod.NPCs { npc.rotation = num803; - float chargeVelocity = BossRushEvent.BossRushActive ? 40f : phase5 ? 30f : (25f + (death ? 4f * (1f - lifeRatio) : 0f)); + float chargeVelocity = phase5 ? 30f : (25f + (death ? 4f * (1f - lifeRatio) : 0f)); chargeVelocity += 5f * enrageScale; if (provy) @@ -1938,7 +1947,7 @@ namespace CalamityMod.NPCs { npc.ai[2] += 1f; - float chargeTime = BossRushEvent.BossRushActive ? 30f : phase5 ? 35f : (45f - (death ? 6f * (1f - lifeRatio) : 0f)); + float chargeTime = phase5 ? 35f : (45f - (death ? 6f * (1f - lifeRatio) : 0f)); if (npc.ai[2] >= chargeTime) { npc.velocity *= 0.9f; @@ -1974,8 +1983,8 @@ namespace CalamityMod.NPCs else { int num62 = phase5 ? 300 : 400; - float num63 = (calamityGlobalNPC.enraged > 0) ? 20f : 14f; - float num64 = (calamityGlobalNPC.enraged > 0) ? 0.5f : 0.35f; + float num63 = 14f; + float num64 = 0.35f; if (death) { @@ -1989,12 +1998,6 @@ namespace CalamityMod.NPCs num64 *= 1.25f; } - if (BossRushEvent.BossRushActive) - { - num63 *= 1.5f; - num64 *= 1.5f; - } - int num408 = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num408 = -1; @@ -2060,10 +2063,11 @@ namespace CalamityMod.NPCs CalamityGlobalNPC.cataclysm = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; // Get a target @@ -2078,10 +2082,17 @@ namespace CalamityMod.NPCs float enrageScale = 0f; if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 2f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } 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); @@ -2159,18 +2170,12 @@ namespace CalamityMod.NPCs num862 *= 1.25f; } - if (BossRushEvent.BossRushActive) - { - num861 *= 1.5f; - num862 *= 1.5f; - } - 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 * (BossRushEvent.BossRushActive ? 270 : 180)) - vector86.X; + 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); @@ -2219,7 +2224,7 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num862; } - npc.ai[2] += (calamityGlobalNPC.enraged > 0) ? 2f : 1f; + npc.ai[2] += 1f; if (npc.ai[2] >= (240f - (death ? 120f * (1f - lifeRatio) : 0f))) { npc.TargetClosest(); @@ -2248,7 +2253,7 @@ namespace CalamityMod.NPCs if (npc.localAI[1] > 12f) { npc.localAI[1] = 0f; - float num867 = BossRushEvent.BossRushActive ? 9f : NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; + float num867 = NPC.AnyNPCs(ModContent.NPCType()) ? 4f : 6f; num867 += enrageScale; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -2281,12 +2286,8 @@ namespace CalamityMod.NPCs num870 += 2f; if (revenge) num870 += 2f; - if (calamityGlobalNPC.enraged > 0) - num870 += 4f; if (provy) num870 *= 1.15f; - if (BossRushEvent.BossRushActive) - num870 *= 1.25f; Vector2 vector87 = npc.Center; float num871 = player.Center.X - vector87.X; @@ -2306,8 +2307,6 @@ namespace CalamityMod.NPCs npc.ai[2] += 0.25f; if (revenge) npc.ai[2] += 0.25f; - if (BossRushEvent.BossRushActive) - npc.ai[2] += 0.25f; if (npc.ai[2] >= 75f) { @@ -2357,10 +2356,11 @@ namespace CalamityMod.NPCs CalamityGlobalNPC.catastrophe = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; // Get a target @@ -2375,10 +2375,17 @@ namespace CalamityMod.NPCs float enrageScale = 0f; if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 2f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } 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); @@ -2456,18 +2463,12 @@ namespace CalamityMod.NPCs num862 *= 1.25f; } - if (BossRushEvent.BossRushActive) - { - num861 *= 1.5f; - num862 *= 1.5f; - } - int num863 = 1; if (npc.Center.X < player.Center.X) num863 = -1; Vector2 vector86 = npc.Center; - float num864 = player.Center.X + (num863 * (BossRushEvent.BossRushActive ? 270 : 180)) - vector86.X; + 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); @@ -2516,7 +2517,7 @@ namespace CalamityMod.NPCs npc.velocity.Y -= num862; } - npc.ai[2] += (calamityGlobalNPC.enraged > 0) ? 2f : 1f; + npc.ai[2] += 1f; if (npc.ai[2] >= (180f - (death ? 90f * (1f - lifeRatio) : 0f))) { npc.TargetClosest(); @@ -2545,7 +2546,7 @@ namespace CalamityMod.NPCs if (npc.localAI[1] > 50f) { npc.localAI[1] = 0f; - float num867 = BossRushEvent.BossRushActive ? 22f : death ? 14f : 12f; + float num867 = death ? 14f : 12f; num867 += 3f * enrageScale; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -2578,12 +2579,8 @@ namespace CalamityMod.NPCs num870 += 2f; if (revenge) num870 += 2f; - if (calamityGlobalNPC.enraged > 0) - num870 += 4f; if (provy) num870 *= 1.15f; - if (BossRushEvent.BossRushActive) - num870 *= 1.25f; 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; @@ -2603,8 +2600,6 @@ namespace CalamityMod.NPCs npc.ai[2] += 0.25f; if (revenge) npc.ai[2] += 0.25f; - if (BossRushEvent.BossRushActive) - npc.ai[2] += 0.25f; if (npc.ai[2] >= 60f) //50 { @@ -2655,10 +2650,11 @@ namespace CalamityMod.NPCs lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; // Variables - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float shootTimer = 1f; if (expertMode) @@ -2666,10 +2662,17 @@ namespace CalamityMod.NPCs float enrageScale = 0f; if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 2f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -2727,7 +2730,7 @@ namespace CalamityMod.NPCs Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 1.3f, 0.5f, 0f); // Fire projectiles while walking, teleporting, or falling - if (npc.ai[0] == 2f || npc.ai[0] >= 5f || calamityGlobalNPC.enraged > 0) + if (npc.ai[0] == 2f || npc.ai[0] >= 5f) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -2737,12 +2740,12 @@ namespace CalamityMod.NPCs if (npc.localAI[0] >= astralFlameGateValue) { // Fire astral flames while teleporting - if ((npc.ai[0] >= 5f && npc.ai[0] != 7) || calamityGlobalNPC.enraged > 0) + 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 = BossRushEvent.BossRushActive ? 14f : death ? 8f : 7f; + float velocity = death ? 8f : 7f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); if (NPC.downedMoonlord && revenge && !BossRushEvent.BossRushActive) @@ -2765,7 +2768,7 @@ namespace CalamityMod.NPCs npc.localAI[0] = 0f; Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 33); - float num179 = BossRushEvent.BossRushActive ? 24f : death ? 20f : 18.5f; + float num179 = death ? 20f : 18.5f; int maxProjectiles = death ? 6 : 4; int spread = death ? 60 : 45; @@ -2835,11 +2838,11 @@ namespace CalamityMod.NPCs npc.defense = 0; // Slow down - npc.velocity *= 0.98f; + npc.velocity.X *= 0.9f; // Stay vulnerable for a maximum of 1.5 or 2.5 seconds npc.ai[1] += 1f; - if (npc.ai[1] >= 120f || calamityGlobalNPC.enraged > 0) + if (npc.ai[1] >= 120f) { // Increase defense npc.defense = npc.defDefense; @@ -2861,7 +2864,7 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 2f) { // Set walking speed - float num823 = BossRushEvent.BossRushActive ? 12f : 6f; + float num823 = 6f; num823 += 4f * enrageScale; if (expertMode) num823 += death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); @@ -2959,7 +2962,7 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == -1f) { // Set jump velocity, reset and set AI to next phase (Stomp) - float velocityX = BossRushEvent.BossRushActive ? 12f : 9f; + float velocityX = 9f; velocityX += 6f * enrageScale; if (expertMode) velocityX += death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); @@ -3050,7 +3053,7 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 33); if (Main.netMode != NetmodeID.MultiplayerClient) { - float num179 = BossRushEvent.BossRushActive ? 24f : death ? 20f : 18.5f; + float num179 = death ? 20f : 18.5f; int maxProjectiles = death ? 6 : 4; int spread = death ? 60 : 45; Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -3122,7 +3125,7 @@ namespace CalamityMod.NPCs else if (npc.direction > 0) npc.velocity.X += velocityXChange; - float num626 = BossRushEvent.BossRushActive ? 18f : 12f; + float num626 = 12f; num626 += 8f * enrageScale; if (expertMode) num626 += death ? 4.5f * (1f - lifeRatio) : 3f * (1f - lifeRatio); @@ -3141,7 +3144,7 @@ namespace CalamityMod.NPCs else if (npc.ai[0] == 5f) { // Slow down - npc.velocity *= 0.95f; + npc.velocity.X *= 0.9f; // Spawn slimes and start teleport if (Main.netMode != NetmodeID.MultiplayerClient) @@ -3293,18 +3296,25 @@ namespace CalamityMod.NPCs CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); // Difficulty variables - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float enrageScale = 0f; if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 1.5f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 0.5f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 0.5f; + } // Deus cannot hit for 3 seconds if (calamityGlobalNPC.newAI[1] < 180f || npc.dontTakeDamage) @@ -3717,12 +3727,6 @@ namespace CalamityMod.NPCs fallSpeed *= revMultiplier; } - if (BossRushEvent.BossRushActive) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - speed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; turnSpeed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; fallSpeed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; @@ -3918,7 +3922,7 @@ namespace CalamityMod.NPCs if (Vector2.Distance(player.Center, npc.Center) > 80f) { Main.PlaySound(SoundID.Item12, npc.Center); - float num941 = (BossRushEvent.BossRushActive ? 24f : death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; + float num941 = (death ? 16f : revenge ? 14f : 13f) + enrageScale * 4f; if (targetFloatingUp) { num941 *= 2f; @@ -4000,6 +4004,11 @@ namespace CalamityMod.NPCs { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + CalamityGlobalNPC.voidBoss = npc.whoAmI; + + Vector2 vector = npc.Center; + + // Percent life remaining double lifeRatio = npc.life / (double)npc.lifeMax; // Increase aggression if player is taking a long time to kill the boss @@ -4007,13 +4016,50 @@ namespace CalamityMod.NPCs lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; int lifePercentage = (int)(100.0 * lifeRatio); - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - CalamityGlobalNPC.voidBoss = npc.whoAmI; - Vector2 vector = npc.Center; + // Difficulty modes + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; + + // 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) @@ -4025,11 +4071,7 @@ namespace CalamityMod.NPCs Player player = Main.player[npc.target]; - if (NPC.CountNPCS(ModContent.NPCType()) > 0 || NPC.CountNPCS(ModContent.NPCType()) > 0 || NPC.CountNPCS(ModContent.NPCType()) > 0) - npc.dontTakeDamage = true; - else - npc.dontTakeDamage = false; - + // Despawn if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) { npc.TargetClosest(false); @@ -4063,200 +4105,404 @@ namespace CalamityMod.NPCs else if (npc.timeLeft < 1800) npc.timeLeft = 1800; - // Detect active tiles around Void - int radius = 30; // 30 tile radius - int diameter = radius * 2; - int npcCenterX = (int)(npc.Center.X / 16f); - int npcCenterY = (int)(npc.Center.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++; - } - } - } - // Scale multiplier based on nearby active tiles - float tileEnrageMult = 1f; - if (nearbyActiveTiles < 1000) - tileEnrageMult += (1000 - nearbyActiveTiles) * 0.0005f; // Ranges from 1f to 1.5f - - if (malice && !BossRushEvent.BossRushActive) - tileEnrageMult = 1.5f; + float tileEnrageMult = enraged ? 1.5f : BossRushEvent.BossRushActive ? 1.375f : malice ? 1.25f : 1f; + npc.Calamity().CurrentlyEnraged = (tileEnrageMult > 1f && !BossRushEvent.BossRushActive) || enraged; + // 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(1f, 4f, 1f - ((tileEnrageMult - 1f) / 0.75f)); + float projectileFireRateMultiplier = MathHelper.Lerp(0.5f, 1.5f, 1f - ((tileEnrageMult - 1f) / 0.5f)); - // Decrease projectile time left based on number of nearby active tiles - int baseProjectileTimeLeft = (int)(300f * tileEnrageMult); - - if (lifePercentage < 90) + // Succ attack + if (!anyDarkEnergies) { - float num472 = npc.Center.X; - float num473 = npc.Center.Y; - float num474 = (death ? (float)(280D * (1D - lifeRatio)) : (float)(230D * (1D - lifeRatio))) * tileEnrageMult; - if (!player.ZoneDungeon) - num474 *= 1.25f; + // This is here because it's used in multiple places + float suckDistance = malice ? 1920f : death ? 1600f : revenge ? 1440f : expertMode ? 1280f : 1040f; - npc.ai[0] += 1f; - if (npc.ai[0] >= 45f * projectileFireRateMultiplier) + // Move closer to the target before trying to succ + if (movingDuringSuccPhase) { - npc.ai[0] = 0f; - - int numDust = (int)(0.2f * MathHelper.TwoPi * num474); - float angleIncrement = MathHelper.TwoPi / numDust; - Vector2 dustOffset = new Vector2(num474, 0f); - dustOffset = dustOffset.RotatedByRandom(MathHelper.TwoPi); - - for (int i = 0; i < numDust; i++) - { - dustOffset = dustOffset.RotatedBy(angleIncrement); - int dust = Dust.NewDust(npc.Center, 1, 1, (int)CalamityDusts.PurpleCosmolite); - Main.dust[dust].position = npc.Center + dustOffset; - Main.dust[dust].noGravity = true; - Main.dust[dust].fadeIn = 1f; - Main.dust[dust].velocity *= 0f; - Main.dust[dust].scale = 0.5f; - } - - float pullVelocity = (player.Calamity().gravityNormalizer ? 9f : 15f) * tileEnrageMult; - for (int num475 = 0; num475 < Main.maxPlayers; num475++) - { - if (Collision.CanHit(npc.Center, 1, 1, Main.player[num475].Center, 1, 1)) - { - float num476 = Main.player[num475].position.X + (Main.player[num475].width / 2); - float num477 = Main.player[num475].position.Y + (Main.player[num475].height / 2); - float num478 = Math.Abs(npc.position.X + (npc.width / 2) - num476) + Math.Abs(npc.position.Y + (npc.height / 2) - num477); - - if (num478 < num474) - { - if (Main.player[num475].position.X < num472) - Main.player[num475].velocity.X += pullVelocity; - else - Main.player[num475].velocity.X -= pullVelocity; - if (Main.player[num475].position.Y < num473) - Main.player[num475].velocity.Y += pullVelocity; - else - Main.player[num475].velocity.Y -= pullVelocity; - } - } - } + if (Vector2.Distance(vector, player.Center) > 320f || !Collision.CanHit(vector, 1, 1, player.Center, 1, 1)) + Movement(true); + else + npc.ai[3] = 1f; } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - calamityGlobalNPC.newAI[1] += expertMode ? 1.5f : 1f; - calamityGlobalNPC.newAI[1] += calamityGlobalNPC.newAI[2]; - if (calamityGlobalNPC.enraged > 0) - calamityGlobalNPC.newAI[1] += 2f; - - if (calamityGlobalNPC.newAI[1] >= 600f * projectileFireRateMultiplier) + else { - npc.TargetClosest(); - calamityGlobalNPC.newAI[1] = 0f; - if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + // Use this to generate more and more dust in final phase + float finalPhaseDustRatio = 1f; + if (succSoHardThatYouDie) { - float num941 = 3f * tileEnrageMult; - 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; - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - vector104.X += num942 * 5f; - vector104.Y += num943 * 5f; - int num947 = Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, type, damage, 0f, Main.myPlayer, tileEnrageMult, 0f); - Main.projectile[num947].timeLeft = baseProjectileTimeLeft / 2; - npc.netUpdate = true; + finalPhaseDustRatio = 5f; + } + else if (theBigSucc) + { + float amount = (10f - (float)(npc.life / (double)npc.lifeMax) * 100f) / 10f; + finalPhaseDustRatio += MathHelper.Lerp(0f, 2f, amount); } - if (revenge) + // 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++) { - if (lifePercentage < 50 || !player.ZoneDungeon) + 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++) { - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - float ai1 = player.ZoneDungeon ? 0f : 1f; - for (int i = 0; i < 12; i++) + if (Main.rand.NextBool(var)) { - int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0f, 0f, type, damage, 0f, Main.myPlayer, i * 30, ai1); - Main.projectile[proj].timeLeft = baseProjectileTimeLeft; + 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; } } - else - { - float spread = 45f * 0.0174f; - double startAngle = Math.Atan2(npc.velocity.X, npc.velocity.Y) - spread / 2; - double deltaAngle = spread / 8f; - double offsetAngle; - int i; - float passedVar = 1f; + } + 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); - for (i = 0; i < 4; i++) + 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++) { - offsetAngle = startAngle + deltaAngle * (i + i * i) / 2f + 32f * i; - int proj = Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)(Math.Sin(offsetAngle) * 3f), (float)(Math.Cos(offsetAngle) * 3f), type, damage, 0f, Main.myPlayer, passedVar, 0f); - Main.projectile[proj].timeLeft = baseProjectileTimeLeft; - passedVar += 1f; + 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); + } } } } } } - - float num823 = ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; - float num824 = death ? 0.1f : expertMode ? 0.08f : 0.06f; - if (!player.ZoneDungeon || BossRushEvent.BossRushActive) - num823 = expertMode ? 25f : 20f; - - Vector2 vector82 = npc.Center; - float num825 = player.Center.X - vector82.X; - float num826 = player.Center.Y - vector82.Y; - float num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - - num827 = num823 / num827; - num825 *= num827; - num826 *= num827; - - if (npc.velocity.X < num825) + else { - 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; + 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.PurpleCosmolite, 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 = (!player.ZoneDungeon || BossRushEvent.BossRushActive) ? 25f : ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; + float acceleration = malice ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f; + if (!player.ZoneDungeon || BossRushEvent.BossRushActive) + velocity = expertMode ? 25f : 20f; + + // 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; @@ -4264,23 +4510,67 @@ namespace CalamityMod.NPCs { if (Main.netMode != NetmodeID.MultiplayerClient) { - int num660 = (int)(npc.lifeMax * 0.26); - if ((npc.life + num660) < calamityGlobalNPC.newAI[0]) + int healthGateValue = (int)(npc.lifeMax * 0.3); + if ((npc.life + healthGateValue) < calamityGlobalNPC.newAI[0]) { + npc.TargetClosest(); calamityGlobalNPC.newAI[0] = npc.life; - calamityGlobalNPC.newAI[2] += 1f; + 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; - int glob = death ? 6 : revenge ? 5 : expertMode ? 4 : 3; - if (lifeRatio <= 0.7f) - glob = death ? 7 : revenge ? 6 : expertMode ? 5 : 4; - if (lifeRatio <= 0.4f) - glob = death ? 8 : revenge ? 7 : expertMode ? 6 : 5; - - for (int num662 = 0; num662 < glob; num662++) + if (phase4) { - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); - NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); + 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; + } + } } } } @@ -4308,12 +4598,27 @@ namespace CalamityMod.NPCs // Variables float rotationMult = 3f; float rotationAmt = 0.03f; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; 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[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + // If target is outside the jungle for more than 3 seconds, enrage if (!player.ZoneJungle) { @@ -4332,11 +4637,17 @@ namespace CalamityMod.NPCs // Enrage scale float enrageScale = death ? 1.5f : 1f; - if (npc.localAI[1] >= 300f || (malice && !BossRushEvent.BossRushActive)) + if (npc.localAI[1] >= 300f || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 1f; - if (npc.localAI[2] > 0f || (malice && !BossRushEvent.BossRushActive)) + } + if (npc.localAI[2] > 0f || malice) enrageScale += 1f; + if (enraged) + npc.Calamity().CurrentlyEnraged = true; + if (enrageScale > 3f) enrageScale = 3f; @@ -4393,7 +4704,7 @@ namespace CalamityMod.NPCs npc.dontTakeDamage = phaseSwitchPhase; - calamityGlobalNPC.DR = (npc.ai[0] == 5f || (enrageScale == 3f && !malice)) ? 0.75f : 0.1f; + calamityGlobalNPC.DR = (npc.ai[0] == 5f || (enrageScale == 3f && !malice && !enraged)) ? 0.75f : 0.1f; if (phaseSwitchPhase) { @@ -4471,10 +4782,10 @@ namespace CalamityMod.NPCs } // Max spawn amount - int maxBirbs = revenge ? 3 : 2; + int maxBirbs = enraged ? 5 : revenge ? 3 : 2; // Variable for charging - float chargeDistance = 600f; + float chargeDistance = enraged ? 500f : 600f; if (phase2) chargeDistance -= 50f; if (phase3) @@ -5036,6 +5347,7 @@ namespace CalamityMod.NPCs lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; // Variables + bool enraged = calamityGlobalNPC.enraged > 0; bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool expertMode = Main.expertMode || malice; bool revenge = CalamityWorld.revenge || malice; @@ -5199,13 +5511,14 @@ namespace CalamityMod.NPCs 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))); + npc.Calamity().CurrentlyEnraged = enrage || enraged; // If the player isn't in the ocean biome or Old Duke is transitioning between phases, become immune if (!phase3AI) npc.dontTakeDamage = npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f; // Enrage - if (enrage) + if (enrage || enraged) { toothBallBelchPhaseTimer = 30; toothBallBelchPhaseDivisor = 6; @@ -5218,8 +5531,12 @@ namespace CalamityMod.NPCs chargeVelocity += 8f; toothBallSpinPhaseDivisor = 6; toothBallSpinToothBallVelocity = 15f; - npc.damage = npc.defDamage * 2; - npc.defense = npc.defDefense * 3; + + if (!enraged) + { + npc.damage = npc.defDamage * 2; + npc.defense = npc.defDefense * 3; + } } // Set variables for spawn effects diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 0e28acf606..ce4e8dccf5 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -1,8 +1,12 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; +using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -40,9 +44,10 @@ namespace CalamityMod.NPCs bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + // 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 @@ -508,8 +513,8 @@ namespace CalamityMod.NPCs if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; bool phase2 = lifeRatio < 0.75f; bool phase3 = lifeRatio < 0.65f; bool phase4 = lifeRatio < 0.55f; @@ -517,11 +522,18 @@ namespace CalamityMod.NPCs float num5 = (float)(death ? 20 - Math.Round(5f * (1f - lifeRatio)) : 20); float enrageScale = 0f; - if (Main.dayTime || malice) - enrageScale += 2f; - + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -871,8 +883,8 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 0f) { - float num37 = (enraged ? 8f : 5.5f) + 3.5f * (0.75f - lifeRatio); - float num38 = (enraged ? 0.09f : 0.06f) + 0.025f * (0.75f - lifeRatio); + float num37 = 5.5f + 3.5f * (0.75f - lifeRatio); + float num38 = 0.06f + 0.025f * (0.75f - lifeRatio); num37 += 4f * enrageScale; num38 += 0.04f * enrageScale; @@ -882,12 +894,6 @@ namespace CalamityMod.NPCs num38 += 0.04f * (0.75f - lifeRatio); } - if (BossRushEvent.BossRushActive) - { - num37 *= 2f; - num38 *= 2f; - } - Vector2 vector8 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num39 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector8.X; float num40 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 120f - vector8.Y; @@ -959,7 +965,7 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.ForceRoar, (int)npc.position.X, (int)npc.position.Y, 0, 1f, 0f); npc.rotation = num8; - float num42 = (enraged ? 9.5f : 6.2f) + 4f * (0.75f - lifeRatio); + float num42 = 6.2f + 4f * (0.75f - lifeRatio); num42 += 4f * enrageScale; if (death) num42 += 5.5f * (0.75f - lifeRatio); @@ -967,8 +973,6 @@ namespace CalamityMod.NPCs num42 *= 1.15f; if (npc.ai[3] == 2f) num42 *= 1.3f; - if (BossRushEvent.BossRushActive) - num42 *= 2f; Vector2 vector9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num43 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector9.X; @@ -1047,10 +1051,8 @@ namespace CalamityMod.NPCs else if (Main.netMode != NetmodeID.MultiplayerClient) { float speedBoost = death ? 5f * (0.65f - lifeRatio) : 3.5f * (0.65f - lifeRatio); - float num48 = (enraged ? 26f : 18f) + speedBoost; + float num48 = 18f + speedBoost; num48 += 10f * enrageScale; - if (BossRushEvent.BossRushActive) - num48 *= 1.5f; Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; @@ -1170,13 +1172,8 @@ namespace CalamityMod.NPCs float num62 = 600f; float speedBoost = death ? 6f * (0.4f - lifeRatio) : 4f * (0.4f - lifeRatio); float speedBoost2 = death ? 0.15f * (0.4f - lifeRatio) : 0.1f * (0.4f - lifeRatio); - float num63 = (enraged ? 12f : 8f) + speedBoost; - float num64 = (enraged ? 0.4f : 0.25f) + speedBoost2; - if (BossRushEvent.BossRushActive) - { - num63 *= 2f; - num64 *= 2f; - } + float num63 = 8f + speedBoost; + float num64 = 0.25f + speedBoost2; Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector11.X; @@ -1227,7 +1224,7 @@ namespace CalamityMod.NPCs if (npc.ai[2] % 45f == 0f) { - float num19 = BossRushEvent.BossRushActive ? 9f : 6f; + float num19 = 6f; Vector2 vector = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num20 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector.X; float num21 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector.Y; @@ -1300,10 +1297,8 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { float speedBoost = death ? 6f * (0.4f - lifeRatio) : 4f * (0.4f - lifeRatio); - float num48 = (enraged ? 26f : 18f) + speedBoost; + float num48 = 18f + speedBoost; num48 += 10f * enrageScale; - if (BossRushEvent.BossRushActive) - num48 *= 1.5f; Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; @@ -1372,8 +1367,8 @@ namespace CalamityMod.NPCs { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -1384,13 +1379,20 @@ namespace CalamityMod.NPCs npc.TargetClosest(); float enrageScale = 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - enrageScale += 1f; - if (!Main.player[npc.target].ZoneCorrupt || malice) - enrageScale += 2f; - + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (!Main.player[npc.target].ZoneCorrupt || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + enrageScale += 1f; // Total body segments float totalSegments = GetEaterOfWorldsSegmentsCountRevDeath(); @@ -1453,7 +1455,7 @@ namespace CalamityMod.NPCs num349 *= num351; num350 *= num351; - float num418 = BossRushEvent.BossRushActive ? 18f : 12f; + float num418 = 12f; int type = ProjectileID.CursedFlameHostile; num351 = (float)Math.Sqrt(num349 * num349 + num350 * num350); num351 = num418 / num351; @@ -1620,8 +1622,6 @@ namespace CalamityMod.NPCs { Rectangle rectangle = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); int num35 = death ? 700 : 850; - if (BossRushEvent.BossRushActive) - num35 = 100; num35 -= (int)(enrageScale * 300f); if (num35 < 100) @@ -1708,7 +1708,7 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[1] += 1f; // Set velocity for when a new head spawns - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num37 * (BossRushEvent.BossRushActive ? 0.8f : death ? 0.5f : 0.4f)); + npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * (num37 * (death ? 0.5f : 0.4f)); } if (!inTiles) @@ -1898,7 +1898,7 @@ namespace CalamityMod.NPCs public static int GetEaterOfWorldsSegmentsCountRevDeath() { - return (CalamityWorld.death || BossRushEvent.BossRushActive) ? 82 : 77; + return (CalamityWorld.death || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 82 : 77; } #endregion @@ -1915,8 +1915,8 @@ namespace CalamityMod.NPCs // whoAmI variable NPC.crimsonBoss = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -1927,13 +1927,23 @@ namespace CalamityMod.NPCs npc.TargetClosest(); float enrageScale = 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - enrageScale += 1f; - if (!Main.player[npc.target].ZoneCrimson || malice) - enrageScale += 2f; - + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (!Main.player[npc.target].ZoneCrimson || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } // Spawn Creepers if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] == 0f) @@ -2030,8 +2040,6 @@ namespace CalamityMod.NPCs float velocityScale = death ? 4f : 2f; float velocityBoost = velocityScale * (1f - lifeRatio); float num798 = 8f + velocityBoost + 3f * enrageScale; - if (BossRushEvent.BossRushActive) - num798 *= 2f; if (phase2 && !phase3) num798 *= 0.9f; @@ -2068,7 +2076,7 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.ForceRoar, (int)npc.position.X, (int)npc.position.Y, -1, 1f, 0f); // Velocity - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ((BossRushEvent.BossRushActive ? 24f : death ? 16f : 14f) + 4f * enrageScale); + npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ((death ? 16f : 14f) + 4f * enrageScale); } } @@ -2126,7 +2134,7 @@ namespace CalamityMod.NPCs if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) < 400f) // 25 tile distance { npc.ai[2] -= 1f; - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ((BossRushEvent.BossRushActive ? -16f : death ? -8f : -6f) - 2f * enrageScale); + npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ((death ? -8f : -6f) - 2f * enrageScale); } } @@ -2190,9 +2198,6 @@ namespace CalamityMod.NPCs npc.localAI[1] -= Main.rand.Next(random); float num799 = (phase2 && !phase3) ? 60f : (death ? 105f : 90f); - if (BossRushEvent.BossRushActive) - num799 = 30f; - if (npc.localAI[1] >= num799) { npc.localAI[1] = 0f; @@ -2333,9 +2338,7 @@ namespace CalamityMod.NPCs float num803 = Main.player[npc.target].Center.X - vector99.X; float num804 = Main.player[npc.target].Center.Y - vector99.Y; float num805 = (float)Math.Sqrt(num803 * num803 + num804 * num804); - float num806 = (BossRushEvent.BossRushActive ? 5f : death ? 2f : 1f) + (creeperScale * 0.1f); - if (BossRushEvent.BossRushActive) - num806 *= 1.5f; + float num806 = (death ? 2f : 1f) + (creeperScale * 0.1f); if (num805 < num806) { @@ -2467,9 +2470,10 @@ namespace CalamityMod.NPCs enrageScale += 1f; if (!Main.player[npc.target].ZoneCrimson) enrageScale += 2f; - if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + enrageScale += 1f; // Creeper count, 0 to 20 int creeperCount = NPC.CountNPCS(NPCID.Creeper); @@ -2487,8 +2491,6 @@ namespace CalamityMod.NPCs float num813 = Main.npc[NPC.crimsonBoss].Center.Y - vector100.Y; float num814 = (float)Math.Sqrt(num812 * num812 + num813 * num813); float velocity = death ? 10f : 7f; - if (BossRushEvent.BossRushActive) - velocity *= 2f; velocity += 4f * enrageScale; // Max distance from Brain @@ -2553,7 +2555,7 @@ namespace CalamityMod.NPCs public static int GetBrainOfCthuluCreepersCountRevDeath() { - return (CalamityWorld.death || BossRushEvent.BossRushActive) ? 30 : 25; + return (CalamityWorld.death || CalamityWorld.malice || BossRushEvent.BossRushActive) ? 30 : 25; } private static float GetCrimsonBossKnockBack(NPC npc, int numPlayers, float lifeScale, float baseKnockBackResist) @@ -2594,24 +2596,36 @@ namespace CalamityMod.NPCs 3 - Fires stingers in a triple spread and they accelerate over time 4 - All attacks inflict Venom*/ #region Buffed Queen Bee AI - public static bool BuffedQueenBeeAI(NPC npc, Mod mod) + public static bool BuffedQueenBeeAI(NPC npc, bool enraged, Mod mod) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; float enrageScale = death ? 0.25f : 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - enrageScale += 0.5f; - if (!Main.player[npc.target].ZoneJungle || malice) - enrageScale += 0.5f; + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 0.5f; + } + if (!Main.player[npc.target].ZoneJungle || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 0.5f; + } if (enrageScale > 1f) enrageScale = 1f; if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale = 2f; + + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale = 3f; + } // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -2650,6 +2664,20 @@ namespace CalamityMod.NPCs if (Main.player[npc.target].dead) npc.ai[0] = 5f; + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = npc.ai[0] == 0f; + 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[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + if (npc.ai[0] == 5f) { npc.velocity.Y *= 0.98f; @@ -2720,19 +2748,14 @@ namespace CalamityMod.NPCs // Charge velocity float speed = 16f; - if (BossRushEvent.BossRushActive) - speed += 12f; - else - { - if (phase2) - speed += 2f; - if (phase3) - speed += 2f; - if (phase4) - speed += 2f; - if (phase5) - speed += 2f; - } + if (phase2) + speed += 2f; + if (phase3) + speed += 2f; + if (phase4) + speed += 2f; + if (phase5) + speed += 2f; speed += 8f * enrageScale; @@ -3099,6 +3122,8 @@ namespace CalamityMod.NPCs npc.ai[1] += 1f; int num650 = phase4 ? 15 : phase3 ? 20 : phase2 ? 25 : 30; num650 -= (int)Math.Ceiling(5f * enrageScale); + if (num650 < 3) + num650 = 3; // Fire stingers if (npc.ai[1] % num650 == (num650 - 1) && npc.position.Y + npc.height < Main.player[npc.target].position.Y && Collision.CanHit(vector78, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) @@ -3106,7 +3131,7 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.Item17, npc.position); if (Main.netMode != NetmodeID.MultiplayerClient) { - float num624 = BossRushEvent.BossRushActive ? 16f : 12f; + float num624 = 12f; if (phase3) num624 += 3f; num624 += 3f * enrageScale; @@ -3124,11 +3149,11 @@ namespace CalamityMod.NPCs } // Movement calculations - float num620 = BossRushEvent.BossRushActive ? 0.1f : 0.075f; + float num620 = 0.075f; num620 += 0.2f * enrageScale; if (!Collision.CanHit(new Vector2(vector78.X, vector78.Y - 30f), 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - num620 = BossRushEvent.BossRushActive ? 0.125f : 0.1f; + num620 = 0.1f; if (enrageScale > 0f) num620 = 0.5f; @@ -3245,8 +3270,9 @@ namespace CalamityMod.NPCs bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - Vector2 vectorCenter = npc.Center; + Vector2 vectorCenter = npc.Center; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -3355,7 +3381,9 @@ namespace CalamityMod.NPCs } bool handsDead = num156 == 0; npc.chaseable = handsDead; - npc.defense += num156 * (BossRushEvent.BossRushActive ? 2500 : 250); + calamityGlobalNPC.DR = 0.05f + num156 * 0.45f; + if (calamityGlobalNPC.DR > 0.95f) + calamityGlobalNPC.DR = 0.95f; // Teleport if (handsDead || phase2) @@ -3372,13 +3400,8 @@ namespace CalamityMod.NPCs // Fire magic bolt after teleport if (Main.netMode != NetmodeID.MultiplayerClient) { - float num151 = 2f + (distance * (BossRushEvent.BossRushActive ? 0.015f : 0.005f)); - if (BossRushEvent.BossRushActive) - { - if (num151 > 10f) - num151 = 10f; - } - else if (num151 > 5f) + float num151 = 2f + (distance * 0.005f); + if (num151 > 5f) num151 = 5f; int type = ProjectileID.Shadowflames; @@ -3513,7 +3536,7 @@ namespace CalamityMod.NPCs // Skull shooting if (handsDead && npc.ai[1] == 0f) { - float num158 = malice ? 15f : phase2 ? (60f - (death ? 30f * (1f - lifeRatio) : 0f)) : 75f; + float num158 = enraged ? 5f : BossRushEvent.BossRushActive ? 10f : malice ? 15f : phase2 ? (60f - (death ? 30f * (1f - lifeRatio) : 0f)) : 75f; if (Main.netMode != NetmodeID.MultiplayerClient && calamityGlobalNPC.newAI[1] >= num158) { calamityGlobalNPC.newAI[1] = 0f; @@ -3524,16 +3547,13 @@ namespace CalamityMod.NPCs if (Collision.CanHit(vector18, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { float num162 = phase2 ? (5f + (death ? 3f * (1f - lifeRatio) : 0f)) : 4f; - if (BossRushEvent.BossRushActive) - num162 *= 1.5f; - float num163 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector18.X + Main.rand.Next(-20, 21); float num164 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector18.Y + Main.rand.Next(-20, 21); float num165 = (float)Math.Sqrt(num163 * num163 + num164 * num164); num165 = num162 / num165; num163 *= num165; num164 *= num165; - int spread = malice ? 100 : 50; + int spread = enraged ? 200 : malice ? 100 : 50; Vector2 vector19 = new Vector2(num163 + Main.rand.Next(-spread, spread + 1) * 0.01f, num164 + Main.rand.Next(-spread, spread + 1) * 0.01f); vector19.Normalize(); vector19 *= num162; @@ -3583,11 +3603,6 @@ namespace CalamityMod.NPCs num171 *= 1.25f; num172 *= 0.75f; } - if (BossRushEvent.BossRushActive) - { - num169 *= 1.5f; - num171 *= 1.5f; - } if (npc.position.Y > Main.player[npc.target].position.Y - 250f) { @@ -3656,12 +3671,10 @@ namespace CalamityMod.NPCs // Increase speed while charging npc.damage = (int)(npc.defDamage * 1.3); - float num176 = BossRushEvent.BossRushActive ? 10f : malice ? 6f : 4.5f; + float num176 = enraged ? 12f : BossRushEvent.BossRushActive ? 9f : malice ? 6f : 4.5f; float velocityBoost = death ? 1f : 1f - lifeRatio; if (handsDead || malice) num176 += velocityBoost; - if (enraged) - num176 += 3f; if (num175 > 150f) { @@ -3678,7 +3691,8 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == 2f) { npc.damage = 1000; - npc.defense = 9999; + calamityGlobalNPC.DR = 0.9999f; + calamityGlobalNPC.unbreakableDR = true; npc.rotation += npc.direction * 0.3f; Vector2 vector21 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num177 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector21.X; @@ -3788,14 +3802,14 @@ namespace CalamityMod.NPCs if (Main.npc[(int)npc.ai[1]].ai[1] != 0f) { - float maxX = malice ? 4f : death ? 6f : 7f; - float maxY = malice ? 3f : death ? 4.5f : 5f; + float maxX = enraged ? 1f : malice ? 4f : death ? 6f : 7f; + float maxY = enraged ? 0.5f : malice ? 3f : death ? 4.5f : 5f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 100f * yMultiplier) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.94f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.16f : 0.08f; + npc.velocity.Y -= 0.08f; if (npc.velocity.Y > maxY) npc.velocity.Y = maxY; } @@ -3803,7 +3817,7 @@ namespace CalamityMod.NPCs { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.94f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.16f : 0.08f; + npc.velocity.Y += 0.08f; if (npc.velocity.Y < -maxY) npc.velocity.Y = -maxY; } @@ -3812,7 +3826,7 @@ namespace CalamityMod.NPCs { if (npc.velocity.X > 0f) npc.velocity.X *= 0.94f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.24f : 0.12f; + npc.velocity.X -= 0.12f; if (npc.velocity.X > maxX) npc.velocity.X = maxX; } @@ -3821,7 +3835,7 @@ namespace CalamityMod.NPCs { if (npc.velocity.X < 0f) npc.velocity.X *= 0.94f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.24f : 0.12f; + npc.velocity.X += 0.12f; if (npc.velocity.X < -maxX) npc.velocity.X = -maxX; } @@ -3836,14 +3850,14 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - float maxX = malice ? 4f : death ? 6f : 7f; - float maxY = malice ? 1f : death ? 2f : 2.5f; + float maxX = enraged ? 1f : malice ? 4f : death ? 6f : 7f; + float maxY = enraged ? 0.25f : malice ? 1f : death ? 2f : 2.5f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 230f * yMultiplier) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.92f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : 0.1f; + npc.velocity.Y -= 0.1f; if (npc.velocity.Y > maxY) npc.velocity.Y = maxY; } @@ -3851,7 +3865,7 @@ namespace CalamityMod.NPCs { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.92f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : 0.1f; + npc.velocity.Y += 0.1f; if (npc.velocity.Y < -maxY) npc.velocity.Y = -maxY; } @@ -3860,7 +3874,7 @@ namespace CalamityMod.NPCs { if (npc.velocity.X > 0f) npc.velocity.X *= 0.92f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.36f : 0.18f; + npc.velocity.X -= 0.18f; if (npc.velocity.X > maxX) npc.velocity.X = maxX; } @@ -3869,7 +3883,7 @@ namespace CalamityMod.NPCs { if (npc.velocity.X < 0f) npc.velocity.X *= 0.92f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.36f : 0.18f; + npc.velocity.X += 0.18f; if (npc.velocity.X < -maxX) npc.velocity.X = -maxX; } @@ -3973,9 +3987,10 @@ namespace CalamityMod.NPCs bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - // Despawn - if (npc.position.X < 160f || npc.position.X > ((Main.maxTilesX - 10) * 16)) + // Despawn + if (npc.position.X < 160f || npc.position.X > ((Main.maxTilesX - 10) * 16)) npc.active = false; // Get a target @@ -4219,10 +4234,8 @@ namespace CalamityMod.NPCs // NOTE: Max velocity is 8 in expert mode float velocityBoost = 4f * (1f - lifeRatio); - float velocityX = (death ? 3.5f : 2f) + velocityBoost; + float velocityX = (BossRushEvent.BossRushActive ? 7f : death ? 3.5f : 2f) + velocityBoost; velocityX *= speedMult; - if (BossRushEvent.BossRushActive) - velocityX *= 1.5f; // NOTE: Values below are based on Rev Mode only! // Max velocity without enrage is 12 @@ -4470,7 +4483,7 @@ namespace CalamityMod.NPCs npc.localAI[1] = 0f; } - float shootBoost = fireAcceleratingLasers ? (death ? 1.5f : 1.5f * (1f - lifeRatio)) : (death ? 3f : 4f * (1f - lifeRatio)); + float shootBoost = enraged ? 5f : fireAcceleratingLasers ? (death ? 1.5f : 1.5f * (1f - lifeRatio)) : (death ? 3f : 4f * (1f - lifeRatio)); npc.localAI[1] += 1f + shootBoost; bool canHit = Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); @@ -4495,14 +4508,12 @@ namespace CalamityMod.NPCs { bool phase2 = lifeRatio < 0.5 || malice; float velocity = (fireAcceleratingLasers ? 3f : 9f) + shootBoost; - if (BossRushEvent.BossRushActive) - velocity *= 1.5f; int projectileType = phase2 ? ProjectileID.DeathLaser : ProjectileID.EyeLaser; int damage = npc.GetProjectileDamage(projectileType); float laserSpawnDistance = fireAcceleratingLasers ? 30f : 10f; - Vector2 projectileVelocity = Vector2.Normalize(Main.player[npc.target].Center + (fireAcceleratingLasers ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center) * velocity; + Vector2 projectileVelocity = Vector2.Normalize(Main.player[npc.target].Center + (fireAcceleratingLasers ? Main.player[npc.target].velocity * 40f : Vector2.Zero) - npc.Center) * velocity; Vector2 projectileSpawn = npc.Center + projectileVelocity * laserSpawnDistance; int proj = Projectile.NewProjectile(projectileSpawn, projectileVelocity, projectileType, damage, 0f, Main.myPlayer, fireAcceleratingLasers ? 1f : 0f, 0f); @@ -4574,11 +4585,18 @@ namespace CalamityMod.NPCs npc.TargetClosest(); float enrageScale = 0f; - if (Main.dayTime || malice) - enrageScale += 2f; - + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } // Enrage variable if player is flying upside down bool targetFloatingUp = player.gravDir == -1f; @@ -4631,7 +4649,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.TheDestroyerBody) { // Enrage, fire more cyan lasers - if (targetFloatingUp || (enrageScale > 0f && !malice)) + if (targetFloatingUp || (enrageScale > 0f && !malice && !enraged)) { if (calamityGlobalNPC.newAI[2] < 480f) calamityGlobalNPC.newAI[2] += 1f; @@ -4674,11 +4692,6 @@ namespace CalamityMod.NPCs { // Laser rate of fire int shootTime = 1; - if (BossRushEvent.BossRushActive) - shootTime += 1; - if (enraged) - shootTime += 2; - calamityGlobalNPC.newAI[0] += 1f; float shootProjectile = 600 / shootTime; float timer = npc.ai[0] + 15f; @@ -4692,8 +4705,6 @@ namespace CalamityMod.NPCs // Laser speed float projectileSpeed = 4.5f; projectileSpeed += enrageScale; - if (BossRushEvent.BossRushActive) - projectileSpeed *= 1.25f; // Set projectile damage and type, set projectile to saucer scrap if probe has been launched int projectileType = ProjectileID.DeathLaser; @@ -4854,12 +4865,6 @@ namespace CalamityMod.NPCs speed *= speedMultiplier; } - if (BossRushEvent.BossRushActive) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - speed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; turnSpeed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; fallSpeed *= increaseSpeedMore ? 4f : increaseSpeed ? 2f : 1f; @@ -5581,8 +5586,8 @@ namespace CalamityMod.NPCs { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -5593,11 +5598,18 @@ namespace CalamityMod.NPCs npc.TargetClosest(); float enrageScale = 0f; - if (Main.dayTime || malice) - enrageScale += 1f; - + if (Main.dayTime || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 0.5f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 0.5f; + } // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -5699,12 +5711,6 @@ namespace CalamityMod.NPCs num383 += 0.1f * (1f - lifeRatio); } - if (BossRushEvent.BossRushActive) - { - num382 *= 1.5f; - num383 *= 1.5f; - } - int num384 = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num384 = -1; @@ -5768,7 +5774,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { - float num389 = BossRushEvent.BossRushActive ? 12f : 10.5f; + float num389 = 10.5f; num389 += 3f * enrageScale; int type = ProjectileID.EyeLaser; int damage = npc.GetProjectileDamage(type); @@ -5789,7 +5795,7 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == 1f) { npc.rotation = num378; - float num393 = BossRushEvent.BossRushActive ? 22.5f : 15f; + float num393 = 15f; num393 += 10f * enrageScale; if (death) num393 += 12f * (1f - lifeRatio); @@ -5914,11 +5920,12 @@ namespace CalamityMod.NPCs spazInPhase1 = Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.fireEye].ai[0] == 0f; } - int defenseGain = spazInPhase1 ? 9999 : 10; npc.chaseable = !spazInPhase1; npc.damage = (int)(npc.defDamage * 1.5); - npc.defense = npc.defDefense + defenseGain; + npc.defense = npc.defDefense + 10; + calamityGlobalNPC.DR = spazInPhase1 ? 0.9999f : 0.2f; + calamityGlobalNPC.unbreakableDR = spazInPhase1; npc.HitSound = SoundID.NPCHit4; @@ -5937,12 +5944,6 @@ namespace CalamityMod.NPCs num400 *= 0.5f; } - if (BossRushEvent.BossRushActive) - { - num399 *= 1.5f; - num400 *= 1.5f; - } - Vector2 vector42 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num401 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector42.X; float num402 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 300f - vector42.Y; @@ -6008,7 +6009,7 @@ namespace CalamityMod.NPCs if (canHit || !spazAlive || enrage) { npc.localAI[1] = 0f; - float num404 = BossRushEvent.BossRushActive ? 12f : 10f; + float num404 = 10f; num404 += enrageScale; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); @@ -6053,12 +6054,6 @@ namespace CalamityMod.NPCs num410 *= 0.5f; } - if (BossRushEvent.BossRushActive) - { - num409 *= 1.5f; - num410 *= 1.5f; - } - Vector2 vector43 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num411 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) + (num408 * 340) - vector43.X; float num412 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector43.Y; @@ -6113,7 +6108,7 @@ namespace CalamityMod.NPCs if (canHit || !spazAlive || enrage) { npc.localAI[1] = 0f; - float num414 = BossRushEvent.BossRushActive ? 11f : 9f; + float num414 = 9f; int type = ProjectileID.DeathLaser; int damage = (int)Math.Round(npc.GetProjectileDamage(type) * 0.75); @@ -6162,9 +6157,6 @@ namespace CalamityMod.NPCs if (targetFloatingUp) num450 += 2f; - if (BossRushEvent.BossRushActive) - num450 *= 1.5f; - Vector2 vector47 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num451 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector47.X; float num452 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector47.Y; @@ -6184,8 +6176,6 @@ namespace CalamityMod.NPCs chargeTime = spazAlive ? 90f : 60f; if (death) chargeTime -= chargeTime * 0.25f * (0.7f - lifeRatio); - if (BossRushEvent.BossRushActive) - chargeTime *= 0.8f; // Slow down if (npc.ai[2] >= chargeTime) @@ -6203,8 +6193,6 @@ namespace CalamityMod.NPCs if (npc.ai[3] % 3f == 0f) { float fireRate = spazAlive ? 13f : 9f; - if (BossRushEvent.BossRushActive) - fireRate = 7f; if (npc.ai[2] % fireRate == 0f) { @@ -6259,8 +6247,8 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == 4f) { int num62 = spazAlive ? 600 : 500; - float num63 = (enraged ? 18f : 12f) + (death ? 4f * (0.7f - lifeRatio) : 0f); - float num64 = (enraged ? 0.45f : 0.3f) + (death ? 0.1f * (0.7f - lifeRatio) : 0f); + float num63 = 12f + (death ? 4f * (0.7f - lifeRatio) : 0f); + float num64 = 0.3f + (death ? 0.1f * (0.7f - lifeRatio) : 0f); if (spazAlive) { @@ -6268,12 +6256,6 @@ namespace CalamityMod.NPCs num64 *= 0.75f; } - if (BossRushEvent.BossRushActive) - { - num63 *= 1.5f; - num64 *= 1.5f; - } - int num408 = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num408 = -1; @@ -6332,8 +6314,8 @@ namespace CalamityMod.NPCs { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -6346,9 +6328,10 @@ namespace CalamityMod.NPCs float enrageScale = 0f; if (Main.dayTime || malice) enrageScale += 1f; - if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 0.5f; + if (enraged) + enrageScale += 0.5f; // Enrage variable if player is floating upside down bool targetFloatingUp = Main.player[npc.target].gravDir == -1f; @@ -6456,12 +6439,6 @@ namespace CalamityMod.NPCs num425 += 0.3f * (1f - lifeRatio); } - if (BossRushEvent.BossRushActive) - { - num424 *= 1.5f; - num425 *= 1.5f; - } - int num426 = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num426 = -1; @@ -6525,7 +6502,7 @@ namespace CalamityMod.NPCs num428 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector44.Y; if (Main.netMode != NetmodeID.MultiplayerClient) { - float num430 = BossRushEvent.BossRushActive ? 20f : 15f; + float num430 = 15f; num430 += 3f * enrageScale; int type = ProjectileID.CursedFlameHostile; int damage = npc.GetProjectileDamage(type); @@ -6550,7 +6527,7 @@ namespace CalamityMod.NPCs { // Rotation and velocity npc.rotation = num420; - float num434 = BossRushEvent.BossRushActive ? 24f : 16f; + float num434 = 16f; num434 += 8f * enrageScale; if (death) num434 += 12f * (1f - lifeRatio); @@ -6689,15 +6666,16 @@ namespace CalamityMod.NPCs retInPhase1 = Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 1f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 2f || Main.npc[CalamityGlobalNPC.laserEye].ai[0] == 0f; } - int defenseGain = retInPhase1 ? 9999 : 18; npc.chaseable = !retInPhase1; // Increase defense and damage npc.damage = (int)(npc.defDamage * 1.5); - npc.defense = npc.defDefense + defenseGain; + npc.defense = npc.defDefense + 18; + calamityGlobalNPC.DR = retInPhase1 ? 0.9999f : 0.2f; + calamityGlobalNPC.unbreakableDR = retInPhase1; - // Change hit sound to metal - npc.HitSound = SoundID.NPCHit4; + // Change hit sound to metal + npc.HitSound = SoundID.NPCHit4; // Shadowflamethrower phase if (npc.ai[1] == 0f) @@ -6707,12 +6685,6 @@ namespace CalamityMod.NPCs num440 += 4f * enrageScale; num441 += 0.06f * enrageScale; - if (BossRushEvent.BossRushActive) - { - num440 *= 1.5f; - num441 *= 1.5f; - } - int num442 = 1; if (npc.position.X + (npc.width / 2) < Main.player[npc.target].position.X + Main.player[npc.target].width) num442 = -1; @@ -6732,10 +6704,6 @@ namespace CalamityMod.NPCs if (targetFloatingUp) num440 += 2f; - // Speed increase - if (enraged) - num440 += 2f; - num445 = num440 / num445; num443 *= num445; num444 *= num445; @@ -6795,7 +6763,7 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - float num446 = BossRushEvent.BossRushActive ? 9f : 6f; + float num446 = 6f; num446 += 2f * enrageScale; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -6844,9 +6812,6 @@ namespace CalamityMod.NPCs if (targetFloatingUp) num450 += 2f; - if (BossRushEvent.BossRushActive) - num450 *= 1.5f; - Vector2 vector47 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num451 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector47.X; float num452 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector47.Y; @@ -6866,9 +6831,6 @@ namespace CalamityMod.NPCs if (targetFloatingUp) npc.ai[2] += 0.25f; - if (BossRushEvent.BossRushActive) - npc.ai[2] += 0.4f; - float chargeTime = 50f - (death ? 12f * (0.7f - lifeRatio) : 0f); // Slow down @@ -6925,10 +6887,8 @@ namespace CalamityMod.NPCs else if (Main.netMode != NetmodeID.MultiplayerClient) { // Velocity - float num48 = (enraged ? 30f : 20f) + (death ? 6f * (0.7f - lifeRatio) : 0f); + float num48 = 20f + (death ? 6f * (0.7f - lifeRatio) : 0f); num48 += 10f * enrageScale; - if (BossRushEvent.BossRushActive) - num48 *= 1.5f; if (npc.ai[2] == -1f || (!retAlive && npc.ai[3] == secondFastCharge)) num48 *= 1.3f; @@ -6977,8 +6937,6 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0, 1f, 0f); float num60 = ((!retAlive && npc.ai[3] == 4f) ? 75f : 50f) - (float)Math.Round(death ? 14f * (0.7f - lifeRatio) : 0f); - if (BossRushEvent.BossRushActive) - num60 *= 0.8f; npc.ai[2] += 1f; @@ -7016,8 +6974,8 @@ namespace CalamityMod.NPCs else if (npc.ai[1] == 5f) { float num62 = retAlive ? 600f : 500f; - float num63 = (enraged ? 24f : 16f) + (death ? 5f * (0.7f - lifeRatio) : 0f); - float num64 = (enraged ? 0.6f : 0.4f) + (death ? 0.1f * (0.7f - lifeRatio) : 0f); + float num63 = 16f + (death ? 5f * (0.7f - lifeRatio) : 0f); + float num64 = 0.4f + (death ? 0.1f * (0.7f - lifeRatio) : 0f); if (retAlive) { @@ -7025,12 +6983,6 @@ namespace CalamityMod.NPCs num64 *= 0.75f; } - if (BossRushEvent.BossRushActive) - { - num63 *= 1.5f; - num64 *= 1.5f; - } - Vector2 vector11 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num65 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector11.X; float num66 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) + num62 - vector11.Y; @@ -7120,9 +7072,10 @@ namespace CalamityMod.NPCs bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + // 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 @@ -7263,8 +7216,22 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0, 1f, 0f); } - // Float near player - if (npc.ai[1] == 0f || npc.ai[1] == 4f) + // Adjust slowing debuff immunity + bool immuneToSlowingDebuffs = npc.ai[1] == 5f; + 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[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + // Float near player + if (npc.ai[1] == 0f || npc.ai[1] == 4f) { // Start other phases if arms are dead, start with spinning phase if (allArmsDead) @@ -7306,7 +7273,7 @@ namespace CalamityMod.NPCs float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); - float velocity = BossRushEvent.BossRushActive ? 6.5f : 5f; + float velocity = 5f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); @@ -7330,7 +7297,7 @@ namespace CalamityMod.NPCs if (npc.localAI[2] >= 300f) { npc.localAI[2] = 0f; - float num502 = BossRushEvent.BossRushActive ? 6f : 1f; + float num502 = 1f; int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); Vector2 value19 = Main.player[npc.target].Center - npc.Center; @@ -7342,10 +7309,10 @@ namespace CalamityMod.NPCs { for (int i = 0; i < numProj; i++) { - Projectile.NewProjectile(npc.Center, value19.RotatedBy(-rotation * (i + 1)), type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(npc.Center, value19.RotatedBy(+rotation * (i + 1)), type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.Center, value19.RotatedBy(-rotation * (i + 1)), type, damage, 0f, Main.myPlayer, 0f, 1f); + Projectile.NewProjectile(npc.Center, value19.RotatedBy(+rotation * (i + 1)), type, damage, 0f, Main.myPlayer, 0f, 1f); } - Projectile.NewProjectile(npc.Center, value19, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.Center, value19, type, damage, 0f, Main.myPlayer, 0f, 1f); } else { @@ -7363,7 +7330,7 @@ namespace CalamityMod.NPCs float velocityY = 3f - (death ? 1f - lifeRatio : 0f); float velocityX = 7f - (death ? 2f * (1f - lifeRatio) : 0f); - float acceleration = (BossRushEvent.BossRushActive ? 0.2f : 0.1f) + (death ? 0.03f * (1f - lifeRatio) : 0f); + float acceleration = 0.1f + (death ? 0.03f * (1f - lifeRatio) : 0f); if (!cannonAlive) { @@ -7419,7 +7386,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X -= death ? 0.12f : 0.1f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -7429,7 +7396,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X += death ? 0.12f : 0.1f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -7458,7 +7425,7 @@ namespace CalamityMod.NPCs float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); - float velocity = BossRushEvent.BossRushActive ? 6.5f : 5f; + float velocity = 5f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); @@ -7494,13 +7461,11 @@ namespace CalamityMod.NPCs float num456 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector48.Y; float num457 = (float)Math.Sqrt(num455 * num455 + num456 * num456); - float speed = BossRushEvent.BossRushActive ? 12f : 6f; - if (phase2 || BossRushEvent.BossRushActive) + float speed = enraged ? 12f : BossRushEvent.BossRushActive ? 9f : 6f; + if (phase2) speed += 1f; - if (phase3 || BossRushEvent.BossRushActive) + if (phase3) speed += 1f; - if (enraged) - speed += 3f; if (targetFloatingUp) speed += 5f; @@ -7519,7 +7484,8 @@ namespace CalamityMod.NPCs if (npc.ai[1] == 2f) { npc.damage = 1000; - npc.defense = 9999; + calamityGlobalNPC.DR = 0.9999f; + calamityGlobalNPC.unbreakableDR = true; npc.rotation += npc.direction * 0.3f; @@ -7613,11 +7579,11 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - // Spawn 6 Probes and maintain velocity, or spit skulls if probes are alive + // Maintain velocity and spit skulls else { npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocity * -calamityGlobalNPC.newAI[0]); - float skullSpawnDivisor = death ? 30f - (float)Math.Round(10f * (1f - lifeRatio)) : 30f; + float skullSpawnDivisor = enraged ? 10f : BossRushEvent.BossRushActive ? 15f : death ? 30f - (float)Math.Round(10f * (1f - lifeRatio)) : 30f; if (npc.ai[2] % skullSpawnDivisor == 0f) { calamityGlobalNPC.newAI[1] += 1f; @@ -7627,7 +7593,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector16 = npc.Center; - float num159 = (BossRushEvent.BossRushActive ? 8f : 4f) + (death ? 2f * (1f - lifeRatio) : 0f); + float num159 = enraged ? 8f : 4f + (death ? 2f * (1f - lifeRatio) : 0f); float num160 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector16.X + Main.rand.Next(-20, 21); float num161 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector16.Y + Main.rand.Next(-20, 21); float num162 = (float)Math.Sqrt(num160 * num160 + num161 * num161); @@ -7645,7 +7611,7 @@ namespace CalamityMod.NPCs int damage = npc.GetProjectileDamage(type); vector16 += value * 5f; int num165 = Projectile.NewProjectile(vector16.X, vector16.Y, num160, num161, type, damage, 0f, Main.myPlayer, -1f, 0f); - Main.projectile[num165].timeLeft = 180; + Main.projectile[num165].timeLeft = 300; Main.projectile[num165].tileCollide = false; } } @@ -7675,8 +7641,8 @@ namespace CalamityMod.NPCs npc.rotation = npc.velocity.X / 15f; - float flightVelocity = (BossRushEvent.BossRushActive ? 15f : 10f) + (death ? 3f * (1f - lifeRatio) : 0f); - float fligthAcceleration = (BossRushEvent.BossRushActive ? 0.18f : 0.12f) + (death ? 0.4f * (1f - lifeRatio) : 0f); + float flightVelocity = 10f + (death ? 3f * (1f - lifeRatio) : 0f); + float fligthAcceleration = 0.12f + (death ? 0.4f * (1f - lifeRatio) : 0f); // Spit homing missiles and then go to floating phase Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); @@ -7730,10 +7696,10 @@ namespace CalamityMod.NPCs { Vector2 velocity = new Vector2(-1f * (float)Main.rand.NextDouble() * 3f, 1f); velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * MathHelper.PiOver4); - velocity *= BossRushEvent.BossRushActive ? 7.5f : 5f; + velocity *= enraged ? 10f : 5f; int type = ProjectileID.SaucerMissile; int damage = npc.GetProjectileDamage(type); - float delayBeforeHoming = malice ? 30f : 45f; + float delayBeforeHoming = enraged ? 15f : malice ? 30f : 45f; Projectile.NewProjectile(npc.Center.X + Main.rand.Next(npc.width / 2), npc.Center.Y + 4f, velocity.X, velocity.Y, type, damage, 0f, Main.myPlayer, 0f, delayBeforeHoming); } @@ -7757,7 +7723,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeLaserAI(NPC npc, Mod mod) + public static bool BuffedPrimeLaserAI(NPC npc, bool enraged, Mod mod) { bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; @@ -7850,7 +7816,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -7860,7 +7826,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -7871,7 +7837,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.24f : death ? 0.16f : 0.14f; + npc.velocity.X -= death ? 0.16f : 0.14f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -7881,7 +7847,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.24f : death ? 0.16f : 0.14f; + npc.velocity.X += death ? 0.16f : 0.14f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -7949,7 +7915,7 @@ namespace CalamityMod.NPCs float num513 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - 320f - vector63.X; float num514 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 160f - vector63.Y; float num515 = (float)Math.Sqrt(num513 * num513 + num514 * num514); - num515 = (BossRushEvent.BossRushActive ? 10f : 7f) / num515; + num515 = 7f / num515; num513 *= num515; num514 *= num515; @@ -7957,25 +7923,25 @@ namespace CalamityMod.NPCs { if (npc.velocity.X > 0f) npc.velocity.X *= 0.9f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X -= death ? 0.12f : 0.1f; } if (npc.velocity.X < num513) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.9f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X += death ? 0.12f : 0.1f; } if (npc.velocity.Y > num514) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.12f : death ? 0.08f : 0.06f; + npc.velocity.Y -= death ? 0.08f : 0.06f; } if (npc.velocity.Y < num514) { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.12f : death ? 0.08f : 0.06f; + npc.velocity.Y += death ? 0.08f : 0.06f; } vector63 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -8002,7 +7968,7 @@ namespace CalamityMod.NPCs float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); - float velocity = malice ? 6.5f : 5f; + float velocity = enraged ? 8f : malice ? 6.5f : 5f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); @@ -8011,7 +7977,7 @@ namespace CalamityMod.NPCs { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 300; + Main.projectile[proj].timeLeft = enraged ? 600 : 300; } } } @@ -8020,7 +7986,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeCannonAI(NPC npc, Mod mod) + public static bool BuffedPrimeCannonAI(NPC npc, bool enraged, Mod mod) { bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; @@ -8149,7 +8115,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.16f : death ? 0.1f : 0.08f; + npc.velocity.Y -= death ? 0.1f : 0.08f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8159,7 +8125,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.16f : death ? 0.1f : 0.08f; + npc.velocity.Y += death ? 0.1f : 0.08f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8170,7 +8136,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.4f : death ? 0.22f : 0.2f; + npc.velocity.X -= death ? 0.22f : 0.2f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8180,7 +8146,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.4f : death ? 0.22f : 0.2f; + npc.velocity.X += death ? 0.22f : 0.2f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8207,7 +8173,7 @@ namespace CalamityMod.NPCs { npc.localAI[0] = 0f; npc.TargetClosest(); - float num495 = BossRushEvent.BossRushActive ? 6f : 1f; + float num495 = 1f; int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); num494 = num495 / num494; @@ -8227,7 +8193,7 @@ namespace CalamityMod.NPCs float num500 = Main.npc[(int)npc.ai[1]].position.Y - vector61.Y; num500 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 160f - vector61.Y; float num501 = (float)Math.Sqrt(num499 * num499 + num500 * num500); - num501 = (BossRushEvent.BossRushActive ? 10f : 7f) / num501; + num501 = 7f / num501; num499 *= num501; num500 *= num501; @@ -8235,25 +8201,25 @@ namespace CalamityMod.NPCs { if (npc.velocity.X > 0f) npc.velocity.X *= 0.9f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.16f : death ? 0.1f : 0.08f; + npc.velocity.X -= death ? 0.1f : 0.08f; } if (npc.velocity.X < num499) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.9f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.16f : death ? 0.1f : 0.08f; + npc.velocity.X += death ? 0.1f : 0.08f; } if (npc.velocity.Y > num500) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.16f : death ? 0.1f : 0.08f; + npc.velocity.Y -= death ? 0.1f : 0.08f; } if (npc.velocity.Y < num500) { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.16f : death ? 0.1f : 0.08f; + npc.velocity.Y += death ? 0.1f : 0.08f; } vector61 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -8272,11 +8238,11 @@ namespace CalamityMod.NPCs if (!sawAlive) npc.localAI[0] += 0.5f; - if (npc.localAI[0] >= 180f) + if (npc.localAI[0] >= (enraged ? 90f : 180f)) { npc.localAI[0] = 0f; npc.TargetClosest(); - float num502 = BossRushEvent.BossRushActive ? 6f : 1f; + float num502 = 1f; int type = ProjectileID.RocketSkeleton; int damage = npc.GetProjectileDamage(type); Vector2 value19 = Main.player[npc.target].Center - npc.Center; @@ -8288,10 +8254,10 @@ namespace CalamityMod.NPCs { for (int i = 0; i < numProj; i++) { - Projectile.NewProjectile(npc.Center, value19.RotatedBy(-rotation * (i + 1)), type, damage, 0f, Main.myPlayer); - Projectile.NewProjectile(npc.Center, value19.RotatedBy(+rotation * (i + 1)), type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.Center, value19.RotatedBy(-rotation * (i + 1)), type, damage, 0f, Main.myPlayer, 0f, 1f); + Projectile.NewProjectile(npc.Center, value19.RotatedBy(+rotation * (i + 1)), type, damage, 0f, Main.myPlayer, 0f, 1f); } - Projectile.NewProjectile(npc.Center, value19, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.Center, value19, type, damage, 0f, Main.myPlayer, 0f, 1f); } else { @@ -8308,7 +8274,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeViceAI(NPC npc, Mod mod) + public static bool BuffedPrimeViceAI(NPC npc, bool enraged, Mod mod) { bool death = CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice; @@ -8392,7 +8358,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8402,7 +8368,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8413,7 +8379,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 1f : death ? 0.55f : 0.5f; + npc.velocity.X -= death ? 0.55f : 0.5f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8423,7 +8389,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += BossRushEvent.BossRushActive ? 1f : death ? 0.55f : 0.5f; + npc.velocity.X += death ? 0.55f : 0.5f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8466,7 +8432,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8476,7 +8442,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8487,7 +8453,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.94f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.6f : death ? 0.33f : 0.3f; + npc.velocity.X -= death ? 0.33f : 0.3f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8497,7 +8463,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.94f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.4f : death ? 0.22f : 0.2f; + npc.velocity.X += death ? 0.22f : 0.2f; if (npc.velocity.X < -velocityX2) npc.velocity.X = -velocityX2; @@ -8530,7 +8496,7 @@ namespace CalamityMod.NPCs if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 280f) { - float chargeVelocity = BossRushEvent.BossRushActive ? 24f : 16f; + float chargeVelocity = enraged ? 24f : 16f; if (!cannonAlive) chargeVelocity += 1.5f; if (!laserAlive) @@ -8594,7 +8560,7 @@ namespace CalamityMod.NPCs if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) + 500f) { - float chargeVelocity = BossRushEvent.BossRushActive ? 21f : 14f; + float chargeVelocity = enraged ? 21f : 14f; if (!cannonAlive) chargeVelocity += 1.15f; if (!laserAlive) @@ -8643,7 +8609,7 @@ namespace CalamityMod.NPCs return false; } - public static bool BuffedPrimeSawAI(NPC npc, Mod mod) + public static bool BuffedPrimeSawAI(NPC npc, bool enraged, Mod mod) { bool death = CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice; @@ -8722,7 +8688,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8732,7 +8698,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8743,7 +8709,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 1f : death ? 0.55f : 0.5f; + npc.velocity.X -= death ? 0.55f : 0.5f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8753,7 +8719,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += BossRushEvent.BossRushActive ? 1f : death ? 0.55f : 0.5f; + npc.velocity.X += death ? 0.55f : 0.5f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8791,7 +8757,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.08f : death ? 0.05f : 0.04f; + npc.velocity.Y -= death ? 0.05f : 0.04f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8801,7 +8767,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.08f : death ? 0.05f : 0.04f; + npc.velocity.Y += death ? 0.05f : 0.04f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8812,7 +8778,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.6f : death ? 0.33f : 0.3f; + npc.velocity.X -= death ? 0.33f : 0.3f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8822,7 +8788,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.6f : death ? 0.33f : 0.3f; + npc.velocity.X += death ? 0.33f : 0.3f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8849,7 +8815,7 @@ namespace CalamityMod.NPCs if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) { - float chargeVelocity = BossRushEvent.BossRushActive ? 33f : 22f; + float chargeVelocity = enraged ? 33f : 22f; if (!cannonAlive) chargeVelocity += 1.5f; if (!laserAlive) @@ -8880,7 +8846,7 @@ namespace CalamityMod.NPCs { if (npc.ai[2] == 4f) { - float chargeVelocity = BossRushEvent.BossRushActive ? 16f : 11f; + float chargeVelocity = enraged ? 16.5f : 11f; if (!cannonAlive) chargeVelocity += 1.5f; if (!laserAlive) @@ -8896,7 +8862,7 @@ namespace CalamityMod.NPCs num474 *= num476; num475 *= num476; - float acceleration = BossRushEvent.BossRushActive ? 0.1f : death ? 0.06f : 0.05f; + float acceleration = death ? 0.06f : 0.05f; if (npc.velocity.X > num474) { if (npc.velocity.X > 0f) @@ -8957,8 +8923,8 @@ namespace CalamityMod.NPCs { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -8982,7 +8948,7 @@ namespace CalamityMod.NPCs bool phase4 = lifeRatio < 0.2f; // Variables and target - bool enrage = malice && !BossRushEvent.BossRushActive; + bool enrage = malice; bool despawn = false; // Check for Jungle @@ -9065,11 +9031,7 @@ namespace CalamityMod.NPCs acceleration = 0.15f; } - if (BossRushEvent.BossRushActive) - { - velocity *= 1.5f; - acceleration *= 1.5f; - } + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && enrage) || enraged; // Detect active tiles around Plantera int radius = 20; // 20 tile radius @@ -9098,6 +9060,9 @@ namespace CalamityMod.NPCs if (malice) tileEnrageMult = 1.6f; + if (enraged) + tileEnrageMult = 1.8f; + // Let hooks and tentacles know how enraged plantera is npc.ai[3] = tileEnrageMult; float tentacleEnrageMult = 1f - lifeRatio + (tileEnrageMult - 1f); @@ -9216,8 +9181,10 @@ namespace CalamityMod.NPCs } } - // Adjust stats - npc.defense = 32; + // Adjust stats + calamityGlobalNPC.DR = 0.15f; + calamityGlobalNPC.unbreakableDR = false; + npc.defense = 32; npc.damage = npc.defDamage; // Fire projectiles @@ -9246,12 +9213,12 @@ namespace CalamityMod.NPCs { npc.TargetClosest(); int projectileType = ProjectileID.SeedPlantera; - float projectileVelocity = BossRushEvent.BossRushActive ? 24f : 17f; + float projectileVelocity = 17f; int chance = malice ? 2 : 6; if (Main.rand.NextBool(chance)) { projectileType = ModContent.ProjectileType(); - projectileVelocity = BossRushEvent.BossRushActive ? 12f : 3f; + projectileVelocity = 3f; } if (lifeRatio < 0.9f && Main.rand.NextBool(2)) { @@ -9297,8 +9264,10 @@ namespace CalamityMod.NPCs // Phase 2 else { - // Adjust stats - npc.defense = 10; + // Adjust stats + calamityGlobalNPC.DR = 0.15f; + calamityGlobalNPC.unbreakableDR = false; + npc.defense = 10; npc.damage = (int)(npc.defDamage * 1.4f); npc.chaseable = true; @@ -9347,7 +9316,7 @@ namespace CalamityMod.NPCs } if (canHit) { - float num757 = BossRushEvent.BossRushActive ? 12f : 4f; + float num757 = 4f; Vector2 vector94 = npc.Center; float num758 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector94.X + Main.rand.Next(-10, 11); float num759 = Math.Abs(num758 * 0.2f); @@ -9394,8 +9363,6 @@ namespace CalamityMod.NPCs float num742 = 8f - ((0.5f - lifeRatio) * 4f); // 8f to 6f, slower projectiles are harder to avoid if (nearbyActiveTiles < 300) num742 = 8.5f; - if (BossRushEvent.BossRushActive) - num742 *= 1.5f; float num743 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector93.X; float num744 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector93.Y; @@ -9457,7 +9424,7 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.Item20, npc.position); Vector2 vector93 = npc.Center; - float num742 = BossRushEvent.BossRushActive ? 12f : 3f; + float num742 = 3f; float num743 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector93.X; float num744 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector93.Y; float num745 = (float)Math.Sqrt(num743 * num743 + num744 * num744); @@ -9535,9 +9502,8 @@ namespace CalamityMod.NPCs } else { - npc.defense += 250; - if (npc.defense > 9999) - npc.defense = 9999; + calamityGlobalNPC.DR = 0.9999f; + calamityGlobalNPC.unbreakableDR = true; } } @@ -9565,7 +9531,7 @@ namespace CalamityMod.NPCs public static bool BuffedPlanterasHookAI(NPC npc, Mod mod) { // Variables - bool enrage = CalamityWorld.malice && !BossRushEvent.BossRushActive; + bool enrage = CalamityWorld.malice; bool despawn = false; bool death = CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice; @@ -9612,7 +9578,7 @@ namespace CalamityMod.NPCs // Timer dictating whether to pick a new location or not float moveBoost = death ? 4f * (1f - lifeRatio) : 2f * (1f - lifeRatio); - npc.localAI[0] -= ((BossRushEvent.BossRushActive ? 4f : 1f) + moveBoost) * MathHelper.Lerp(1f, 3.6f, (tileEnrageMult - 1f) * 1.25f); + npc.localAI[0] -= (1f + moveBoost) * MathHelper.Lerp(1f, 3.6f, (tileEnrageMult - 1f) * 1.25f); if (enrage) npc.localAI[0] -= 6f; @@ -9680,7 +9646,7 @@ namespace CalamityMod.NPCs { // Hook movement velocity float velocityBoost = death ? 6f * (1f - lifeRatio) : 3f * (1f - lifeRatio); - float velocity = ((BossRushEvent.BossRushActive ? 10f : 7f) + velocityBoost) * tileEnrageMult; + float velocity = (7f + velocityBoost) * tileEnrageMult; if (enrage) velocity *= 2f; if (despawn) @@ -9751,9 +9717,9 @@ namespace CalamityMod.NPCs } // Velocity and acceleration - float num779 = (BossRushEvent.BossRushActive ? 3f : death ? 2.4f : 1.6f) * tileEnrageMult; + float num779 = (death ? 2.4f : 1.6f) * tileEnrageMult; float num781 = npc.ai[2]; - float num780 = (BossRushEvent.BossRushActive ? 200f : 100f) + (num781 * 150f); + float num780 = 100f + (num781 * 150f); float deceleration = (death ? 0.5f : 0.8f) / (1f + num781); // Despawn if Plantera is gone @@ -9893,6 +9859,11 @@ namespace CalamityMod.NPCs if (malice) enrage = true; + if (enraged) + turboEnrage = true; + + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && (enrage || turboEnrage)) || enraged; + // Alpha if (npc.alpha > 0) { @@ -9979,7 +9950,7 @@ namespace CalamityMod.NPCs Vector2 vector82 = new Vector2(npc.Center.X, npc.Center.Y - 60f); if (npc.localAI[1] % divisor == 0f && (Vector2.Distance(Main.player[npc.target].Center, vector82) > 160f || !flag43)) { - float num673 = enrage ? 12f : 6f; + float num673 = turboEnrage ? 12f : enrage ? 9f : 6f; float num674 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; float num675 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; float num676 = (float)Math.Sqrt(num674 * num674 + num675 * num675); @@ -10126,7 +10097,10 @@ namespace CalamityMod.NPCs velocity *= 1.5f; if (enrage) - velocity *= 1.5f; + velocity *= 1.25f; + + if (turboEnrage) + velocity *= 1.25f; int type = ProjectileID.Fireball; int damage = npc.GetProjectileDamage(type); @@ -10200,7 +10174,7 @@ namespace CalamityMod.NPCs } // Despawn - int num649 = turboEnrage ? 6000 : 4500; + int num649 = turboEnrage ? 7500 : enrage ? 6000 : 4500; if (Math.Abs(npc.Center.X - Main.player[npc.target].Center.X) + Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y) > num649) { npc.TargetClosest(); @@ -10275,8 +10249,11 @@ namespace CalamityMod.NPCs if (malice) enrage = true; - // Alpha - if (npc.alpha > 0) + if (enraged) + turboEnrage = true; + + // Alpha + if (npc.alpha > 0) { npc.alpha -= 10; if (npc.alpha < 0) @@ -10302,7 +10279,7 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; Vector2 vector81 = new Vector2(npc.Center.X, npc.Center.Y + 10f); - float num655 = turboEnrage ? 16f : enrage ? 12f : 8f; + float num655 = turboEnrage ? 12f : enrage ? 10f : 8f; float num656 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector81.X; float num657 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector81.Y; float num658 = (float)Math.Sqrt(num656 * num656 + num657 * num657); @@ -10353,7 +10330,7 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; - float num663 = turboEnrage ? 18f : enrage ? 15f : 12f; + float num663 = turboEnrage ? 16f : enrage ? 14f : 12f; float num664 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector82.X; float num665 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector82.Y; float num666 = (float)Math.Sqrt(num664 * num664 + num665 * num665); @@ -10512,7 +10489,19 @@ namespace CalamityMod.NPCs if (malice) enrage = true; - npc.defense = turboEnrage ? (npc.defDefense * 50) : npc.defDefense; + if (enraged) + turboEnrage = true; + + if (turboEnrage) + { + npc.Calamity().DR = 0.9999f; + npc.Calamity().unbreakableDR = true; + } + else + { + npc.Calamity().DR = 0.25f; + npc.Calamity().unbreakableDR = false; + } // Float through tiles or not bool flag44 = false; @@ -10705,7 +10694,7 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; Vector2 vector88 = new Vector2(npc.Center.X, npc.Center.Y - 10f); - float num706 = turboEnrage ? 10f : enrage ? 7.5f : 5f; + float num706 = turboEnrage ? 8f : enrage ? 6.5f : 5f; float num709 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector88.X; float num710 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector88.Y; float num711 = (float)Math.Sqrt(num709 * num709 + num710 * num710); @@ -10905,24 +10894,26 @@ namespace CalamityMod.NPCs (player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400))); + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && enrage) || enraged; + // If the player isn't in the ocean biome or Fishron is transitioning between phases, become immune if (!phase3AI) npc.dontTakeDamage = npc.ai[0] == -1f || npc.ai[0] == 4f || npc.ai[0] == 9f; // Enrage - if (enrage || malice) + if (enrage || malice || enraged) { - bubbleBelchPhaseTimer = 20; + bubbleBelchPhaseTimer = enraged ? 15 : 20; bubbleBelchPhaseDivisor = 1; - bubbleBelchPhaseAcceleration = 0.65f; - bubbleBelchPhaseVelocity = 10f; - idlePhaseTimer = 20; - idlePhaseAcceleration = 1f; - idlePhaseVelocity = 15f; - chargeTime = 24; - chargeVelocity += 5f; + bubbleBelchPhaseAcceleration = enraged ? 0.9f : 0.65f; + bubbleBelchPhaseVelocity = enraged ? 15f : 10f; + idlePhaseTimer = enraged ? 15 : 20; + idlePhaseAcceleration = enraged ? 1.3f : 1f; + idlePhaseVelocity = enraged ? 20f : 15f; + chargeTime = enraged ? 18 : 24; + chargeVelocity += enraged ? 8f : 5f; bubbleSpinPhaseDivisor = 1; - bubbleSpinBubbleVelocity = 15f; + bubbleSpinBubbleVelocity = enraged ? 20f : 15f; if (!malice) { @@ -11835,21 +11826,23 @@ namespace CalamityMod.NPCs int idleTime = phase3 ? 35 : 40; float timeToFinishRitual = phase5 ? 300f : 360f; - if (malice) + if (malice || enraged) { - iceMistFireRate = 40; - iceMistSpeed = 14f; - iceMistAmt = 3; - fireballFireRate = 8; + iceMistFireRate = enraged ? 30 : 40; + iceMistSpeed = enraged ? 20f : 14f; + iceMistAmt = enraged ? 4 : 3; + fireballFireRate = enraged ? 6 : 8; fireballSpeed *= 1.2f; - lightningOrbFireRate = 30; - ancientLightSpawnRate = 20; - ancientLightAmt = 4; - idleTime = 30; + lightningOrbFireRate = enraged ? 20 : 30; + ancientLightSpawnRate = enraged ? 15 : 20; + ancientLightAmt = enraged ? 5 : 4; + idleTime = enraged ? 15 : 30; } - // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(false); // Center and target @@ -12613,8 +12606,6 @@ namespace CalamityMod.NPCs Vector2 vector18 = npc.Center + new Vector2(npc.direction * 30, 12f); float scaleFactor = 10f; - if (BossRushEvent.BossRushActive) - scaleFactor *= 1.5f; float num48 = 0.251327425f; int num49 = 0; @@ -12806,6 +12797,16 @@ namespace CalamityMod.NPCs if (npc.ai[0] >= 0f) { + // Triple damage if the Adult Eidolon Wyrm is alive + if (npc.ai[0] == 0f) + { + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + npc.damage *= 3; + } + } + npc.ai[0] += 1f; float duration = 120f; @@ -12839,16 +12840,20 @@ namespace CalamityMod.NPCs int rateOfChange = 1; float splitProjVelocity = 5f; - // Percent life remaining for Cultist + // 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; + // Increase aggression if player is taking a long time to kill the boss + if (lifeRatio > Main.npc[(int)npc.ai[0]].Calamity().killTimeRatio_IncreasedAggression) + lifeRatio = Main.npc[(int)npc.ai[0]].Calamity().killTimeRatio_IncreasedAggression; + bool phase2 = lifeRatio < 0.7f; - bool phase3 = lifeRatio < 0.55f; + bool phase3 = lifeRatio < (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType() ? 0.6f : 0.55f); bool phase4 = lifeRatio < 0.4f; bool kill = npc.ai[1] < 0f || !Main.npc[(int)npc.ai[0]].active; int target = Main.maxPlayers; - if (Main.npc[(int)npc.ai[0]].type == NPCID.CultistBoss) + if (Main.npc[(int)npc.ai[0]].type == NPCID.CultistBoss || Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) { if (target == Main.maxPlayers) target = Main.npc[(int)npc.ai[0]].target; @@ -12858,6 +12863,9 @@ namespace CalamityMod.NPCs if (phase4 || death) rateOfChange = 3; + + if (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) + npc.dontTakeDamage = true; } else kill = true; @@ -12878,6 +12886,12 @@ namespace CalamityMod.NPCs double deg = npc.ai[3]; double rad = deg * (Math.PI / 180); double dist = 550; + if (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) + { + float aiGateValue = Main.npc[(int)npc.ai[0]].Calamity().newAI[2] - 30f; + int ancientDoomScale = (int)(aiGateValue / 120f); + dist += ancientDoomScale * 45; + } npc.position.X = Main.player[target].Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; npc.position.Y = Main.player[target].Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; float spinVelocity = 8f * (1f - (npc.ai[1] / duration)); @@ -12923,6 +12937,11 @@ namespace CalamityMod.NPCs { int type = ProjectileID.AncientDoomProjectile; int damage = npc.GetProjectileDamage(type); + + // Triple damage if the Adult Eidolon Wyrm is alive + if (Main.npc[(int)npc.ai[0]].type == ModContent.NPCType()) + damage *= 3; + kill = true; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -12978,7 +12997,12 @@ namespace CalamityMod.NPCs if (malice) aggressionLevel = 4; - if (npc.type == NPCID.MoonLordCore) + if (enraged) + aggressionLevel = 5; + + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + if (npc.type == NPCID.MoonLordCore) { // Play a random Moon Lord sound if (npc.ai[0] != -1f && npc.ai[0] != 2f && Main.rand.NextBool(200)) @@ -13103,9 +13127,12 @@ namespace CalamityMod.NPCs Vector2 value4 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, 130f); if (value4.Length() > 20f) { - float velocity = BossRushEvent.BossRushActive ? 12.5f : death ? 9.5f : 9.25f; + float velocity = death ? 9.5f : 9.25f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -13176,9 +13203,12 @@ namespace CalamityMod.NPCs Vector2 value5 = Main.player[npc.target].Center - npc.Center + new Vector2(0f, 130f); if (value5.Length() > 20f) { - float velocity = BossRushEvent.BossRushActive ? 12.5f : death ? 9.5f : 9.25f; + float velocity = death ? 9.5f : 9.25f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -13653,12 +13683,15 @@ namespace CalamityMod.NPCs { if (calamityGlobalNPC.newAI[1] == 0f) { - calamityGlobalNPC.newAI[1] = BossRushEvent.BossRushActive ? 390f : 420f; + calamityGlobalNPC.newAI[1] = 420f; if (death) calamityGlobalNPC.newAI[1] -= 60f; switch (aggressionLevel) { + case 5: + calamityGlobalNPC.newAI[1] -= 120f; + break; case 4: break; case 3: @@ -13776,6 +13809,9 @@ namespace CalamityMod.NPCs bool shootThirdBolt = num1207 == num1208; switch (aggressionLevel) { + case 5: + v4 = Main.player[npc.target].Center + Main.player[npc.target].velocity * 40f - npc.Center; + break; case 4: break; case 3: @@ -13806,9 +13842,12 @@ namespace CalamityMod.NPCs { Vector2 vector203 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), value19 * npc.localAI[1]); - float velocity = BossRushEvent.BossRushActive ? 9f : death ? 6.75f : 6.25f; + float velocity = death ? 6.75f : 6.25f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -13953,9 +13992,12 @@ namespace CalamityMod.NPCs { vector167.Normalize(); - float velocity = BossRushEvent.BossRushActive ? 10.5f : death ? 7.75f : 7.5f; + float velocity = death ? 7.75f : 7.5f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -13991,6 +14033,9 @@ namespace CalamityMod.NPCs float divisor = 6f; switch (aggressionLevel) { + case 5: + divisor = 4f; + break; case 4: break; case 3: @@ -14027,7 +14072,7 @@ namespace CalamityMod.NPCs Vector2 vector168 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), vector165 * npc.localAI[1]); Vector2 vector169 = npc.Center + Vector2.Normalize(vector168) * vector165.Length() * 0.4f + value11; - float velocity = BossRushEvent.BossRushActive ? 7.5f : death ? 3.5f : 3f; + float velocity = death ? 3.5f : 3f; switch (aggressionLevel) { case 4: @@ -14077,9 +14122,12 @@ namespace CalamityMod.NPCs value12 += new Vector2(num1177 * 100f, -50f); Vector2 value13 = new Vector2(400f * num1177, -60f); - float velocityMultiplier = BossRushEvent.BossRushActive ? 0.87f : death ? 0.88f : 0.885f; + float velocityMultiplier = death ? 0.88f : 0.885f; switch (aggressionLevel) { + case 5: + velocityMultiplier -= 0.02f; + break; case 4: break; case 3: @@ -14103,9 +14151,12 @@ namespace CalamityMod.NPCs Vector2 vector172 = vector171; vector172.Normalize(); - float velocity = BossRushEvent.BossRushActive ? 14f : death ? 11f : 10f; + float velocity = death ? 11f : 10f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -14132,6 +14183,9 @@ namespace CalamityMod.NPCs int divisor = 30; switch (aggressionLevel) { + case 5: + divisor = 15; + break; case 4: break; case 3: @@ -14166,9 +14220,12 @@ namespace CalamityMod.NPCs Vector2 vector175 = vector174; vector175.Normalize(); - float velocity = BossRushEvent.BossRushActive ? 32f : death ? 26.5f : 24f; + float velocity = death ? 26.5f : 24f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -14213,9 +14270,12 @@ namespace CalamityMod.NPCs if (float.IsNaN(vector176.X) || float.IsNaN(vector176.Y)) vector176 = Vector2.UnitY; - float velocity = BossRushEvent.BossRushActive ? 3f : death ? 2.2f : 2f; + float velocity = death ? 2.2f : 2f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -14250,9 +14310,12 @@ namespace CalamityMod.NPCs Vector2 vector178 = vector177; vector178.Normalize(); - float velocity = BossRushEvent.BossRushActive ? 24.5f : death ? 19.75f : 17.5f; + float velocity = death ? 19.75f : 17.5f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -14281,9 +14344,12 @@ namespace CalamityMod.NPCs Vector2 vector180 = vector179; vector180.Normalize(); - float velocity = BossRushEvent.BossRushActive ? 14f : death ? 11f : 10f; + float velocity = death ? 11f : 10f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -14319,6 +14385,9 @@ namespace CalamityMod.NPCs bool shootThirdBolt = num1178 == num1179; switch (aggressionLevel) { + case 5: + v = Main.player[npc.target].Center + Main.player[npc.target].velocity * 40f - npc.Center; + break; case 4: break; case 3: @@ -14350,9 +14419,12 @@ namespace CalamityMod.NPCs { Vector2 vector181 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), vector165 * npc.localAI[1]); - float velocity = BossRushEvent.BossRushActive ? 9f : death ? 6.75f : 6.25f; + float velocity = death ? 6.75f : 6.25f; switch (aggressionLevel) { + case 5: + velocity += 2f; + break; case 4: break; case 3: @@ -14544,7 +14616,7 @@ namespace CalamityMod.NPCs npc.localAI[2] = MathHelper.Lerp(npc.localAI[2], 1f, 0.2f); - float velocity = BossRushEvent.BossRushActive ? 42f : death ? 38f : 36f; + float velocity = death ? 38f : 36f; Vector2 center23 = npc.Center; Vector2 center24 = Main.player[npc.target].Center; Vector2 value24 = center24 - center23; @@ -14620,7 +14692,7 @@ namespace CalamityMod.NPCs if ((num1245 == num1241 - 14f || num1245 == num1241 - 7f || num1245 == num1241) && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector214 = Utils.Vector2FromElipse(npc.localAI[0].ToRotationVector2(), value22 * npc.localAI[1]); - float velocity = BossRushEvent.BossRushActive ? 12f : death ? 9f : 8f; + float velocity = death ? 9f : 8f; Vector2 vector215 = Vector2.Normalize(v8) * velocity; int type = ProjectileID.PhantasmalBolt; int damage = npc.GetProjectileDamage(type); @@ -14700,7 +14772,7 @@ namespace CalamityMod.NPCs if (vector217.HasNaNs()) vector217 = Vector2.UnitY * -1f; - float spreadVelocity = BossRushEvent.BossRushActive ? 6f : death ? 4.5f : 4f; + float spreadVelocity = death ? 4.5f : 4f; vector217 *= 4f; int proj = Projectile.NewProjectile(npc.Center.X + vector216.X, npc.Center.Y + vector216.Y, vector217.X, vector217.Y, type, 0, 0f, Main.myPlayer, 30f, npc.whoAmI); Main.projectile[proj].timeLeft = 1200; @@ -14750,7 +14822,7 @@ namespace CalamityMod.NPCs if (num1245 == 105f) npc.netUpdate = true; - float velocity = BossRushEvent.BossRushActive ? 16f : death ? 13.25f : 12f; + float velocity = death ? 13.25f : 12f; Vector2 velocity6 = (npc.ai[2] - MathHelper.PiOver2).ToRotationVector2() * velocity; npc.velocity = velocity6 * 2f; @@ -14835,7 +14907,7 @@ namespace CalamityMod.NPCs if ((num1245 - 15f - 30f) % 10f == 0f && Main.netMode != NetmodeID.MultiplayerClient) { Vector2 vector219 = npc.Center + Vector2.Normalize(vector218) * value22.Length() * 0.4f; - float velocity = BossRushEvent.BossRushActive ? 9f : death ? 6f : 5f; + float velocity = death ? 6f : 5f; Vector2 vector220 = Vector2.Normalize(vector218) * velocity; float ai3 = (MathHelper.TwoPi * (float)Main.rand.NextDouble() - MathHelper.Pi) / 30f + 0.0174532924f * npc.ai[2]; int type = ProjectileID.PhantasmalEye; @@ -14991,9 +15063,6 @@ namespace CalamityMod.NPCs // Heal limits int num1273 = death ? 1500 : 1250; - if (BossRushEvent.BossRushActive) - num1273 *= 10; - int num1274 = Main.npc[num1268].lifeMax - Main.npc[num1268].life; int num1275 = Main.npc[num1269].lifeMax - Main.npc[num1269].life; int num1276 = Main.npc[num1270].lifeMax - Main.npc[num1270].life; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 0c8bf5161e..b4559428a3 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -5,6 +5,8 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.Items; +using CalamityMod.Items.Accessories; using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; @@ -21,6 +23,7 @@ using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.HiveMind; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; @@ -57,6 +60,7 @@ using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; +using CalamityMod.NPCs.PlagueEnemies; namespace CalamityMod.NPCs { @@ -101,6 +105,10 @@ namespace CalamityMod.NPCs // 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]; + // Town NPC shop alert animation variables public int shopAlertAnimTimer = 0; public int shopAlertAnimFrame = 0; @@ -161,6 +169,10 @@ namespace CalamityMod.NPCs public int relicOfResilienceCooldown = 0; public int relicOfResilienceWeakness = 0; public int GaussFluxTimer = 0; + public int sagePoisonTime = 0; + public int sagePoisonDamage = 0; + public int vulnerabilityHex = 0; + public int banishingFire = 0; // whoAmI Variables public static int[] bobbitWormBottom = new int[5]; @@ -202,82 +214,91 @@ namespace CalamityMod.NPCs public static int draedonExoMechTwinRed = -1; public static int draedonExoMechTwinGreen = -1; public static int draedonExoMechPrime = -1; + public static int adultEidolonWyrmHead = -1; + + // 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; // Collections public static SortedDictionary BossRushHPChanges = new SortedDictionary { // Tier 1 - { NPCID.QueenBee, 3150000 }, // 30 seconds + { NPCID.QueenBee, 315000 }, // 30 seconds - { NPCID.BrainofCthulhu, 1000000 }, // 30 seconds with creepers - { NPCID.Creeper, 100000 }, + { NPCID.BrainofCthulhu, 100000 }, // 30 seconds with creepers + { NPCID.Creeper, 10000 }, - { NPCID.KingSlime, 3000000 }, // 30 seconds - { NPCID.BlueSlime, 36000 }, - { NPCID.SlimeSpiked, 72000 }, - { NPCID.GreenSlime, 27000 }, - { NPCID.RedSlime, 54000 }, - { NPCID.PurpleSlime, 72000 }, - { NPCID.YellowSlime, 63000 }, - { NPCID.IceSlime, 45000 }, - { NPCID.UmbrellaSlime, 54000 }, - { NPCID.RainbowSlime, 300000 }, - { NPCID.Pinky, 150000 }, + { NPCID.KingSlime, 300000 }, // 30 seconds + { NPCID.BlueSlime, 3600 }, + { NPCID.SlimeSpiked, 7200 }, + { NPCID.GreenSlime, 2700 }, + { NPCID.RedSlime, 5400 }, + { NPCID.PurpleSlime, 7200 }, + { NPCID.YellowSlime, 6300 }, + { NPCID.IceSlime, 4500 }, + { NPCID.UmbrellaSlime, 5400 }, + { NPCID.RainbowSlime, 30000 }, + { NPCID.Pinky, 15000 }, - { NPCID.EyeofCthulhu, 4500000 }, // 30 seconds - { NPCID.ServantofCthulhu, 60000 }, + { NPCID.EyeofCthulhu, 450000 }, // 30 seconds + { NPCID.ServantofCthulhu, 6000 }, - { NPCID.SkeletronPrime, 1100000 }, // 30 seconds - { NPCID.PrimeVice, 540000 }, - { NPCID.PrimeCannon, 450000 }, - { NPCID.PrimeSaw, 450000 }, - { NPCID.PrimeLaser, 380000 }, + { NPCID.SkeletronPrime, 110000 }, // 30 seconds + { NPCID.PrimeVice, 54000 }, + { NPCID.PrimeCannon, 45000 }, + { NPCID.PrimeSaw, 45000 }, + { NPCID.PrimeLaser, 38000 }, - { NPCID.Golem, 500000 }, // 30 seconds - { NPCID.GolemHead, 300000 }, - { NPCID.GolemHeadFree, 300000 }, - { NPCID.GolemFistLeft, 250000 }, - { NPCID.GolemFistRight, 250000 }, + { NPCID.Golem, 50000 }, // 30 seconds + { NPCID.GolemHead, 30000 }, + { NPCID.GolemHeadFree, 30000 }, + { NPCID.GolemFistLeft, 25000 }, + { NPCID.GolemFistRight, 25000 }, - { NPCID.EaterofWorldsHead, 100000 }, // 30 seconds + immunity timer at start - { NPCID.EaterofWorldsBody, 100000 }, - { NPCID.EaterofWorldsTail, 100000 }, + { NPCID.EaterofWorldsHead, 10000 }, // 30 seconds + immunity timer at start + { NPCID.EaterofWorldsBody, 10000 }, + { NPCID.EaterofWorldsTail, 10000 }, // Tier 2 - { NPCID.TheDestroyer, 2500000 }, // 30 seconds + immunity timer at start - { NPCID.TheDestroyerBody, 2500000 }, - { NPCID.TheDestroyerTail, 2500000 }, - { NPCID.Probe, 100000 }, + { NPCID.TheDestroyer, 250000 }, // 30 seconds + immunity timer at start + { NPCID.TheDestroyerBody, 250000 }, + { NPCID.TheDestroyerTail, 250000 }, + { NPCID.Probe, 10000 }, - { NPCID.Spazmatism, 1500000 }, // 30 seconds - { NPCID.Retinazer, 1250000 }, + { NPCID.Spazmatism, 150000 }, // 30 seconds + { NPCID.Retinazer, 125000 }, - { NPCID.WallofFlesh, 4500000 }, // 30 seconds - { NPCID.WallofFleshEye, 4500000 }, + { NPCID.WallofFlesh, 450000 }, // 30 seconds + { NPCID.WallofFleshEye, 450000 }, - { NPCID.SkeletronHead, 1600000 }, // 30 seconds - { NPCID.SkeletronHand, 600000 }, + { NPCID.SkeletronHead, 160000 }, // 30 seconds + { NPCID.SkeletronHand, 60000 }, // Tier 3 - { NPCID.CultistBoss, 2200000 }, // 30 seconds - { NPCID.CultistDragonHead, 600000 }, - { NPCID.CultistDragonBody1, 600000 }, - { NPCID.CultistDragonBody2, 600000 }, - { NPCID.CultistDragonBody3, 600000 }, - { NPCID.CultistDragonBody4, 600000 }, - { NPCID.CultistDragonTail, 600000 }, - { NPCID.AncientCultistSquidhead, 500000 }, + { NPCID.CultistBoss, 220000 }, // 30 seconds + { NPCID.CultistDragonHead, 60000 }, + { NPCID.CultistDragonBody1, 60000 }, + { NPCID.CultistDragonBody2, 60000 }, + { NPCID.CultistDragonBody3, 60000 }, + { NPCID.CultistDragonBody4, 60000 }, + { NPCID.CultistDragonTail, 60000 }, + { NPCID.AncientCultistSquidhead, 50000 }, - { NPCID.Plantera, 1600000 }, // 30 seconds - { NPCID.PlanterasTentacle, 400000 }, + { NPCID.Plantera, 160000 }, // 30 seconds + { NPCID.PlanterasTentacle, 40000 }, // Tier 4 - { NPCID.DukeFishron, 2900000 }, // 30 seconds + { NPCID.DukeFishron, 290000 }, // 30 seconds - { NPCID.MoonLordCore, 1600000 }, // 1 minute - { NPCID.MoonLordHand, 450000 }, - { NPCID.MoonLordHead, 600000 }, - { NPCID.MoonLordLeechBlob, 8000 } + { NPCID.MoonLordCore, 160000 }, // 1 minute + { NPCID.MoonLordHand, 45000 }, + { NPCID.MoonLordHead, 60000 }, + { NPCID.MoonLordLeechBlob, 800 } // 8 minutes in total for vanilla Boss Rush bosses }; @@ -373,6 +394,14 @@ namespace CalamityMod.NPCs NPCID.TheDestroyerTail }; + public static List ThanatosIDs = new List + { + NPCType(), + NPCType(), + NPCType(), + NPCType() + }; + public static List SkeletronPrimeIDs = new List { NPCID.SkeletronPrime, @@ -382,13 +411,6 @@ namespace CalamityMod.NPCs NPCID.PrimeVice }; - public static List DarkEnergyIDs = new List - { - NPCType(), - NPCType(), - NPCType() - }; - public static List StormWeaverIDs = new List { NPCType(), @@ -689,13 +711,18 @@ namespace CalamityMod.NPCs ResetSavedIndex(ref SCal, NPCType()); ResetSavedIndex(ref SCalWorm, NPCType()); - /*ResetSavedIndex(ref draedonExoMechWorm, NPCType()); - ResetSavedIndex(ref draedonExoMechTwinRed, NPCType()); + ResetSavedIndex(ref draedonExoMechWorm, NPCType()); + /*ResetSavedIndex(ref draedonExoMechTwinRed, NPCType()); ResetSavedIndex(ref draedonExoMechTwinGreen, NPCType()); ResetSavedIndex(ref draedonExoMechPrime, NPCType());*/ + ResetSavedIndex(ref adultEidolonWyrmHead, NPCType()); + CalamityGlobalTownNPC.ResetTownNPCNameBools(npc, mod); - } + + // Reset the enraged state every frame. The expectation is that bosses will continuously set it back to true if necessary. + CurrentlyEnraged = false; + } #endregion #region Life Regen @@ -891,17 +918,27 @@ namespace CalamityMod.NPCs { if (eFreeze > 0) { - npc.velocity.X *= 0.5f; - npc.velocity.Y += 0.1f; - if (npc.velocity.Y > 15f) - npc.velocity.Y = 15f; + if (!CalamityPlayer.areThereAnyDamnBosses) + { + npc.velocity.X *= 0.5f; + npc.velocity.Y += 0.1f; + if (npc.velocity.Y > 15f) + npc.velocity.Y = 15f; + } + else + npc.velocity *= 0.5f; } else if (gState > 0) { - npc.velocity.X *= 0.5f; - npc.velocity.Y += 0.05f; - if (npc.velocity.Y > 15f) - npc.velocity.Y = 15f; + if (!CalamityPlayer.areThereAnyDamnBosses) + { + npc.velocity.X *= 0.5f; + npc.velocity.Y += 0.05f; + if (npc.velocity.Y > 15f) + npc.velocity.Y = 15f; + } + else + npc.velocity *= 0.5f; } else if (tSad > 0) npc.velocity *= 0.5f; @@ -911,7 +948,7 @@ namespace CalamityMod.NPCs // Oiled debuff makes flame debuffs 25% more effective if (npc.oiled) { - int oiledDoT = (bFlames > 0 ? 10 : 0) + (hFlames > 0 ? 13 : 0) + (gsInferno > 0 ? 63 : 0) + (aFlames > 0 ? 32 : 0) + (dFlames > 0 ? 625 : 0); + int oiledDoT = (bFlames > 0 ? 10 : 0) + (hFlames > 0 ? 13 : 0) + (gsInferno > 0 ? 63 : 0) + (aFlames > 0 ? 32 : 0) + (dFlames > 0 ? 625 : 0) + (banishingFire > 0 ? 375 : 0); if (oiledDoT > 0) { int lifeRegenValue = oiledDoT * 4 + 12; @@ -934,14 +971,20 @@ namespace CalamityMod.NPCs ApplyDPSDebuff(dFlames, 2500, 500, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(bBlood, 50, 10, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(kamiFlu, 250, 25, ref npc.lifeRegen, ref damage); + ApplyDPSDebuff(vulnerabilityHex, 44440, 4444, ref npc.lifeRegen, ref damage); ApplyDPSDebuff(sulphurPoison, 180, 36, ref npc.lifeRegen, ref damage); + ApplyDPSDebuff(sagePoisonTime, 90, npc.Calamity().sagePoisonDamage, ref npc.lifeRegen, ref damage); - int electrifiedDamage = CalamityPlayer.areThereAnyDamnBosses ? 5 : 10; + int electrifiedDamage = CalamityPlayer.areThereAnyDamnBosses ? 5 : 10; int displayedValue = electrifiedDamage / 5; if (npc.velocity.X == 0) ApplyDPSDebuff(electrified, electrifiedDamage, displayedValue, ref npc.lifeRegen, ref damage); else ApplyDPSDebuff(electrified, electrifiedDamage * 4, displayedValue * 4, ref npc.lifeRegen, ref damage); + if (npc.lifeMax < 1000000) // 2000 hp per second as minimum + ApplyDPSDebuff(banishingFire, 4000, 800, ref npc.lifeRegen, ref damage); + else // On big health enemies, do 0.2% hp per second + ApplyDPSDebuff(banishingFire, npc.lifeMax / 500, npc.lifeMax / 2500, ref npc.lifeRegen, ref damage); } public void ApplyDPSDebuff(int debuff, int lifeRegenValue, int damageValue, ref int lifeRegen, ref int damage) @@ -962,7 +1005,10 @@ namespace CalamityMod.NPCs #region Set Defaults public override void SetDefaults(NPC npc) { - for (int m = 0; m < maxAIMod; m++) + for (int i = 0; i < maxPlayerImmunities; i++) + dashImmunityTime[i] = 0; + + for (int m = 0; m < maxAIMod; m++) newAI[m] = 0f; // Apply DR to vanilla NPCs. @@ -983,6 +1029,7 @@ namespace CalamityMod.NPCs if (npc.type == NPCID.WallofFleshEye) npc.netAlways = true; + sagePoisonDamage = 0; if (npc.type == NPCID.Golem && (CalamityWorld.revenge || CalamityWorld.malice)) npc.noGravity = true; @@ -1046,9 +1093,9 @@ namespace CalamityMod.NPCs // 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. + // 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 @@ -1825,7 +1872,8 @@ namespace CalamityMod.NPCs if (npc.type == NPCType() && !Main.dayTime) DRScalar = 10f; if ((DestroyerIDs.Contains(npc.type) && !NPC.downedPlantBoss) || (AquaticScourgeIDs.Contains(npc.type) && !NPC.downedPlantBoss) || - (AstrumDeusIDs.Contains(npc.type) && !NPC.downedMoonlord) || (StormWeaverIDs.Contains(npc.type) && !CalamityWorld.downedDoG)) + (AstrumDeusIDs.Contains(npc.type) && !NPC.downedMoonlord) || (StormWeaverIDs.Contains(npc.type) && !CalamityWorld.downedDoG) || + ThanatosIDs.Contains(npc.type)) DRScalar = 5f; // The limit for how much extra DR the boss can have @@ -1947,6 +1995,13 @@ namespace CalamityMod.NPCs { CalamityGlobalTownNPC.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]--; + } + if (CalamityPlayer.areThereAnyDamnBosses) { if (npc.velocity.Length() > maxVelocity) @@ -2000,6 +2055,13 @@ namespace CalamityMod.NPCs if (NPC.LunarApocalypseIsUp) PillarEventProgressionEdit(npc); + // Adult Wyrm Ancient Doom + if (npc.type == NPCID.AncientDoom) + { + if (Main.npc[(int)npc.ai[0]].type == NPCType()) + return CalamityGlobalAI.BuffedAncientDoomAI(npc, mod); + } + if (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice) { switch (npc.type) @@ -2021,7 +2083,7 @@ namespace CalamityMod.NPCs return CalamityGlobalAI.BuffedCreeperAI(npc, enraged > 0, mod); case NPCID.QueenBee: - return CalamityGlobalAI.BuffedQueenBeeAI(npc, mod); + return CalamityGlobalAI.BuffedQueenBeeAI(npc, enraged > 0, mod); case NPCID.SkeletronHand: return CalamityGlobalAI.BuffedSkeletronHandAI(npc, enraged > 0, mod); @@ -2049,13 +2111,13 @@ namespace CalamityMod.NPCs case NPCID.SkeletronPrime: return CalamityGlobalAI.BuffedSkeletronPrimeAI(npc, enraged > 0, mod); case NPCID.PrimeLaser: - return CalamityGlobalAI.BuffedPrimeLaserAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeLaserAI(npc, enraged > 0, mod); case NPCID.PrimeCannon: - return CalamityGlobalAI.BuffedPrimeCannonAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeCannonAI(npc, enraged > 0, mod); case NPCID.PrimeVice: - return CalamityGlobalAI.BuffedPrimeViceAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeViceAI(npc, enraged > 0, mod); case NPCID.PrimeSaw: - return CalamityGlobalAI.BuffedPrimeSawAI(npc, mod); + return CalamityGlobalAI.BuffedPrimeSawAI(npc, enraged > 0, mod); case NPCID.Plantera: return CalamityGlobalAI.BuffedPlanteraAI(npc, enraged > 0, mod); @@ -2951,8 +3013,7 @@ namespace CalamityMod.NPCs break; case 21: - if (npc.type != NPCType() && npc.type != NPCType() && - npc.type != NPCType() && npc.type != NPCType()) + if (npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; npc.netUpdate = true; @@ -3486,14 +3547,22 @@ namespace CalamityMod.NPCs clamDebuff--; if (sulphurPoison > 0) sulphurPoison--; - if (relicOfResilienceCooldown > 0) - relicOfResilienceCooldown--; - if (relicOfResilienceWeakness > 0) - relicOfResilienceWeakness--; - if (GaussFluxTimer > 0) - GaussFluxTimer--; - if (ladHearts > 0) + if (sagePoisonTime > 0) + sagePoisonTime--; + if (kamiFlu > 0) + kamiFlu--; + if (relicOfResilienceCooldown > 0) + relicOfResilienceCooldown--; + if (relicOfResilienceWeakness > 0) + relicOfResilienceWeakness--; + if (GaussFluxTimer > 0) + GaussFluxTimer--; + if (ladHearts > 0) ladHearts--; + if (vulnerabilityHex > 0) + vulnerabilityHex--; + if (banishingFire > 0) + banishingFire--; // Queen Bee is completely immune to having her movement impaired if not in a high difficulty mode. if (npc.type == NPCID.QueenBee && !CalamityWorld.revenge && !CalamityWorld.malice && !BossRushEvent.BossRushActive) @@ -3509,12 +3578,14 @@ namespace CalamityMod.NPCs npc.velocity *= 0.85f; else if (slowed > 0 || tesla > 0 || vaporfied > 0) npc.velocity *= 0.9f; - else if (kamiFlu > 0) + 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 (!CalamityPlayer.areThereAnyDamnBosses && !CalamityLists.enemyImmunityList.Contains(npc.type)) { if (pearlAura > 0) npc.velocity *= 0.9f; @@ -3658,7 +3729,12 @@ namespace CalamityMod.NPCs // Expert Mode resists, mostly worms if (Main.expertMode) { - if (AstrumDeusIDs.Contains(npc.type)) + if (ThanatosIDs.Contains(npc.type)) + { + GrenadeResist(projectile, ref damage); + PierceResistGlobal(projectile, ref damage); + } + else if (AstrumDeusIDs.Contains(npc.type)) { GrenadeResist(projectile, ref damage); PierceResistGlobal(projectile, ref damage); @@ -3680,7 +3756,12 @@ namespace CalamityMod.NPCs damage = (int)(damage * 0.75); } } - else if (DevourerOfGodsIDs.Contains(npc.type)) + else if (npc.type == NPCType()) + { + GrenadeResist(projectile, ref damage); + PierceResistGlobal(projectile, ref damage); + } + else if (DevourerOfGodsIDs.Contains(npc.type)) { // No grenade or global pierce resist here, body DR covers this appropriately @@ -3696,11 +3777,20 @@ namespace CalamityMod.NPCs else if (projectile.type == ProjectileType()) damage = (int)(damage * 0.85); } - else if (CosmicGuardianIDs.Contains(npc.type) || DarkEnergyIDs.Contains(npc.type)) + else if (CosmicGuardianIDs.Contains(npc.type)) { GrenadeResist(projectile, ref damage); PierceResistGlobal(projectile, ref damage); } + else if (npc.type == NPCType()) + { + // 50% resist to Nuclear Fury + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.5); + + GrenadeResist(projectile, ref damage); + PierceResistGlobal(projectile, ref damage); + } else if (StormWeaverIDs.Contains(npc.type)) { GrenadeResist(projectile, ref damage); @@ -3807,38 +3897,76 @@ namespace CalamityMod.NPCs } } + if (DevourerOfGodsIDs.Contains(npc.type)) + { + if (projectile.Calamity().stealthStrike) + { + if (projectile.type == ProjectileType()) + damage = (int)(damage * 1.15); + } + + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.9); + } + // Other projectile resists if (npc.type == NPCType()) { - // 10% resist to Time Bolt if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.9); + damage = (int)(damage * 0.795); + + if (projectile.type == ProjectileType() || projectile.type == ProjectileID.FlamingJack) + damage = (int)(damage * 0.39); } else if (npc.type == NPCType()) { - // 5% resist to Celestial Reaper if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) damage = (int)(damage * 0.95); } else if (npc.type == NPCType()) { - // 5% resist to Celestial Reaper if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) damage = (int)(damage * 0.95); - } + } + else if (npc.type == NPCType()) + { + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.5); + } + else if (npc.type == NPCType()) + { + // For Onyxia. + if (projectile.type == ProjectileID.BlackBolt) + damage = (int)(damage * 0.9); + } + else if (npc.type == NPCType() || npc.type == NPCType()) + { + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.9); + } + else if (npc.type == NPCType()) + { + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.8); + } + else if (npc.type == NPCType()) + { + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.7); + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.75); + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.9); + } else if (npc.type == NPCID.CultistBoss) { if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - { damage = (int)(damage * 0.75); - } } else if (npc.type == NPCID.DukeFishron) { if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) - { damage = (int)(damage * 1.35); - } } } @@ -3853,13 +3981,15 @@ namespace CalamityMod.NPCs if (projectile.IsSummon() || projectile.aiStyle == 99) return; - if (projectile.penetrate == -1) - damage = (int)(damage * 0.5); - else if (projectile.penetrate > 1) - { - float newBaseDamage = damage * (float)Math.Pow(0.9, projectile.penetrate) / projectile.Calamity().ResistDamagePenaltyHarshness; - damage = (int)MathHelper.Clamp(newBaseDamage, damage * projectile.Calamity().ResistDamagePenaltyMinCapFactor, damage); - } + if (projectile.penetrate == -1) + { + damage = (int)(damage * 0.5); + } + else if (projectile.penetrate > 1) + { + float newBaseDamage = damage * (float)Math.Pow(0.9, projectile.penetrate) / projectile.Calamity().ResistDamagePenaltyHarshness; + damage = (int)MathHelper.Clamp(newBaseDamage, damage * projectile.Calamity().ResistDamagePenaltyMinCapFactor, damage); + } } #endregion @@ -4358,7 +4488,7 @@ namespace CalamityMod.NPCs } } - if (hFlames > 0) + if (hFlames > 0 || banishingFire > 0) { if (Main.rand.Next(5) < 4) { @@ -4621,7 +4751,9 @@ namespace CalamityMod.NPCs buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SnapClamDebuff")); if (sulphurPoison > 0) buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SulphuricPoisoning")); - if (vaporfied > 0) + if (sagePoisonTime > 0) + buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/SagePoison")); + if (vaporfied > 0) buffTextureList.Add(GetTexture("CalamityMod/Buffs/DamageOverTime/Vaporfied")); // Stat debuffs @@ -5136,7 +5268,7 @@ namespace CalamityMod.NPCs { return CalamityWorld.downedProvidence; } - else if (type == NPCType() || type == NPCType() || type == NPCType()) + else if (type == NPCType() || type == NPCType()) { return CalamityWorld.downedSentinel1; } @@ -5168,6 +5300,10 @@ namespace CalamityMod.NPCs { return CalamityWorld.downedSCal; } + else if (type == NPCType()) + { + return CalamityWorld.downedAdultEidolonWyrm; + } return true; } diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index 4008c1d8b0..adb1b20baa 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -50,8 +50,8 @@ namespace CalamityMod.NPCs if (CalamityWorld.death && !SplittingWormLootBlockWrapper(npc, mod)) return false; - // Servants of Cthulhu and Probes do not provide free hearts in Rev+. - if ((CalamityWorld.revenge || CalamityWorld.malice) && (npc.type == NPCID.ServantofCthulhu || npc.type == NPCID.Probe)) + // Do not provide free hearts for certain boss NPCs in Rev+. + if ((CalamityWorld.revenge || CalamityWorld.malice) && CalamityLists.heartDropBlockList.Contains(npc.type) && CalamityPlayer.areThereAnyDamnBosses) NPCLoader.blockLoot.Add(ItemID.Heart); // diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index ad88aea9cf..6e040ed565 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -37,10 +37,12 @@ namespace CalamityMod.NPCs.CeaselessVoid npc.defense = 80; CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.5f; - npc.lifeMax = 25000; + + bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel1; + npc.LifeMaxNERB(notDoGFight ? 67200 : 16800, notDoGFight ? 77280 : 19320, 72000); // If fought alone, Ceaseless Void plays its own theme - if (CalamityWorld.DoGSecondStageCountdown <= 0) + if (notDoGFight) { npc.value = Item.buyPrice(0, 35, 0, 0); music = CalamityMod.Instance.GetMusicFromMusicMod("Void") ?? MusicID.Boss3; @@ -49,7 +51,9 @@ namespace CalamityMod.NPCs.CeaselessVoid else music = CalamityMod.Instance.GetMusicFromMusicMod("ScourgeofTheUniverse") ?? MusicID.Boss3; - 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,6 +66,10 @@ namespace CalamityMod.NPCs.CeaselessVoid 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]); } @@ -69,6 +77,10 @@ namespace CalamityMod.NPCs.CeaselessVoid 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(); } @@ -81,6 +93,11 @@ namespace CalamityMod.NPCs.CeaselessVoid npc.frame.Y = frame * frameHeight; } + public override void AI() + { + CalamityAI.CeaselessVoidAI(npc, mod); + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { SpriteEffects spriteEffects = SpriteEffects.None; @@ -103,14 +120,14 @@ namespace CalamityMod.NPCs.CeaselessVoid color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -125,7 +142,7 @@ namespace CalamityMod.NPCs.CeaselessVoid 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -135,12 +152,7 @@ namespace CalamityMod.NPCs.CeaselessVoid return false; } - public override void AI() - { - CalamityAI.CeaselessVoidAI(npc, mod); - } - - public override void NPCLoot() + public override void NPCLoot() { // Only drop items if fought at full strength bool fullStrength = !CalamityWorld.downedSentinel1 || CalamityWorld.DoGSecondStageCountdown <= 0; @@ -200,22 +212,30 @@ namespace CalamityMod.NPCs.CeaselessVoid } } - public override void BossLoot(ref string name, ref int potionType) + 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) { potionType = ModContent.ItemType(); } - public override void HitEffect(int hitDirection, double damage) + 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); } - for (int k = 0; k < 5; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); - } + + for (int k = 0; k < 5; k++) + { + int dust = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + } + if (npc.life <= 0) { npc.position.X = npc.position.X + (float)(npc.width / 2); @@ -228,7 +248,8 @@ namespace CalamityMod.NPCs.CeaselessVoid { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; - 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; @@ -240,8 +261,10 @@ 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.PurpleCosmolite, 0f, 0f, 100, default, 2f); + Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 2f; } + float randomSpread = (float)(Main.rand.Next(-200, 200) / 100); Gore.NewGore(npc.position, npc.velocity * randomSpread, mod.GetGoreSlot("Gores/CeaselessVoid"), 1f); Gore.NewGore(npc.position, npc.velocity * randomSpread, mod.GetGoreSlot("Gores/CeaselessVoid2"), 1f); diff --git a/NPCs/CeaselessVoid/DarkEnergy.cs b/NPCs/CeaselessVoid/DarkEnergy.cs index 0c9fa4ee4c..9412cd31e6 100644 --- a/NPCs/CeaselessVoid/DarkEnergy.cs +++ b/NPCs/CeaselessVoid/DarkEnergy.cs @@ -1,7 +1,5 @@ -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Projectiles.Rogue; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -10,13 +8,18 @@ using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.CeaselessVoid { public class DarkEnergy : ModNPC { - public int invinceTime = 120; + private int invinceTime = 180; + 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; @@ -27,6 +30,7 @@ namespace CalamityMod.NPCs.CeaselessVoid { npc.Calamity().canBreakPlayerDefense = true; npc.aiStyle = -1; + aiType = -1; npc.GetNPCDamage(); npc.dontTakeDamage = true; npc.width = 80; @@ -39,15 +43,14 @@ namespace CalamityMod.NPCs.CeaselessVoid } if (BossRushEvent.BossRushActive) { - npc.lifeMax = 44000; + npc.lifeMax = 4400; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.knockBackResist = 0.25f; - npc.noGravity = true; + npc.knockBackResist = 0f; + npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - aiType = -1; npc.HitSound = SoundID.NPCHit53; npc.DeathSound = SoundID.NPCDeath44; } @@ -55,14 +58,22 @@ namespace CalamityMod.NPCs.CeaselessVoid public override void SendExtraAI(BinaryWriter writer) { writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - } + 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(); - npc.dontTakeDamage = reader.ReadBoolean(); - } + 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) { @@ -72,6 +83,107 @@ namespace CalamityMod.NPCs.CeaselessVoid npc.frame.Y = frame * frameHeight; } + 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) + { + npc.damage = 0; + invinceTime--; + } + else + { + npc.damage = npc.defDamage; + 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; + } + + // 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 || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; + + // 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; + } + } + + // 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; + + // 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; @@ -80,11 +192,15 @@ namespace CalamityMod.NPCs.CeaselessVoid Texture2D texture2D15 = Main.npcTexture[npc.type]; Texture2D texture2D16 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/DarkEnergyGlow2"); - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Vector2 vector11 = new Vector2(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); + if (CalamityConfig.Instance.Afterimages) { for (int num155 = 1; num155 < num153; num155 += 2) @@ -92,17 +208,14 @@ namespace CalamityMod.NPCs.CeaselessVoid Color color38 = lightColor; color38 = Color.Lerp(color38, color36, amount9); color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/CeaselessVoid/DarkEnergyGlow"); @@ -116,16 +229,16 @@ namespace CalamityMod.NPCs.CeaselessVoid 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, 4f + npc.gfxOffY); + 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 *= (float)(num153 - num163) / 15f; + color43 *= (num153 - num163) / 15f; spriteBatch.Draw(texture2D16, vector44, npc.frame, color43, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -137,165 +250,12 @@ namespace CalamityMod.NPCs.CeaselessVoid return false; } - public override void AI() - { - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || CalamityWorld.malice; - - if (invinceTime > 0) - { - npc.damage = 0; - invinceTime--; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } - - Vector2 vectorCenter = npc.Center; - npc.TargetClosest(true); - Player player = Main.player[npc.target]; - - double mult = 0.5 + - ((CalamityWorld.revenge || CalamityWorld.malice) ? 0.2 : 0.0) + - ((CalamityWorld.death || CalamityWorld.malice) ? 0.2 : 0.0); - - if (npc.life < npc.lifeMax * mult || BossRushEvent.BossRushActive) - npc.knockBackResist = 0f; - - float tileEnrageMult = Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; - - float num1247 = 0.1f; - float maxDistance = 24f * MathHelper.Lerp(0.3333333334f, 1.6f, MathHelper.Clamp((tileEnrageMult - 1f) * 1.6666666667f, 0f, 1f)); - 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) < maxDistance) - { - if (npc.position.X < Main.npc[num1248].position.X) - npc.velocity.X = npc.velocity.X - num1247; - else - npc.velocity.X = npc.velocity.X + num1247; - - if (npc.position.Y < Main.npc[num1248].position.Y) - npc.velocity.Y = npc.velocity.Y - num1247; - else - npc.velocity.Y = npc.velocity.Y + num1247; - } - } - } - } - - if (npc.ai[1] == 0f) - { - npc.scale -= 0.01f; - npc.alpha += 15; - if (npc.alpha >= 125) - { - npc.alpha = 130; - npc.ai[1] = 1f; - } - } - else if (npc.ai[1] == 1f) - { - npc.scale += 0.01f; - npc.alpha -= 15; - if (npc.alpha <= 0) - { - npc.alpha = 0; - npc.ai[1] = 0f; - } - } - - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - npc.velocity = new Vector2(0f, -10f); - - if (npc.timeLeft > 150) - npc.timeLeft = 150; - - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - if (npc.ai[0] == 0f) - { - Vector2 vector96 = new Vector2(npc.Center.X, npc.Center.Y); - float num784 = Main.npc[CalamityGlobalNPC.voidBoss].Center.X - vector96.X; - float num785 = Main.npc[CalamityGlobalNPC.voidBoss].Center.Y - vector96.Y; - float num786 = (float)Math.Sqrt((double)(num784 * num784 + num785 * num785)); - if (num786 > 90f) - { - num786 = (BossRushEvent.BossRushActive ? 24f : 16f) * tileEnrageMult / num786; - num784 *= num786; - num785 *= num786; - npc.velocity.X = (npc.velocity.X * 15f + num784) / 16f; - npc.velocity.Y = (npc.velocity.Y * 15f + num785) / 16f; - return; - } - if (Math.Abs(npc.velocity.X) + Math.Abs(npc.velocity.Y) < 16f) - { - npc.velocity.Y = npc.velocity.Y * 1.1f; - npc.velocity.X = npc.velocity.X * 1.1f; - } - if (Main.netMode != NetmodeID.MultiplayerClient && ((expertMode && Main.rand.NextBool(50)) || Main.rand.NextBool(100))) - { - npc.TargetClosest(true); - vector96 = new Vector2(npc.Center.X, npc.Center.Y); - num784 = player.Center.X - vector96.X; - num785 = player.Center.Y - vector96.Y; - num786 = (float)Math.Sqrt((double)(num784 * num784 + num785 * num785)); - num786 = (BossRushEvent.BossRushActive ? 16f : 12f) * tileEnrageMult / num786; - npc.velocity.X = num784 * num786; - npc.velocity.Y = num785 * num786; - npc.ai[0] = 1f; - npc.netUpdate = true; - } - } - else - { - Vector2 value4 = player.Center - npc.Center; - value4.Normalize(); - value4 *= (BossRushEvent.BossRushActive ? 16f : 11f) * tileEnrageMult; - npc.velocity = (npc.velocity * 99f + value4) / 100f; - Vector2 vector97 = new Vector2(npc.Center.X, npc.Center.Y); - float num787 = Main.npc[CalamityGlobalNPC.voidBoss].Center.X - vector97.X; - float num788 = Main.npc[CalamityGlobalNPC.voidBoss].Center.Y - vector97.Y; - float num789 = (float)Math.Sqrt((double)(num787 * num787 + num788 * num788)); - npc.ai[2] += 1f; - if (num789 > 700f || npc.ai[2] >= 150f) - { - npc.ai[0] = 0f; - npc.ai[2] = 0f; - } - } - } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); } - public override bool CheckActive() - { - return CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active; - } + public override bool CheckActive() => false; public override void OnHitPlayer(Player player, int damage, bool crit) { @@ -305,17 +265,36 @@ namespace CalamityMod.NPCs.CeaselessVoid public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; - return true; - } - public override void HitEffect(int hitDirection, double damage) + 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 <= 35f; + } + + public override bool CheckDead() => false; + + public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) { - for (int k = 0; k < 20; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); - } + for (int k = 0; k < 20; k++) + { + int dust = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + } } } } diff --git a/NPCs/CeaselessVoid/DarkEnergy2.cs b/NPCs/CeaselessVoid/DarkEnergy2.cs deleted file mode 100644 index 8e69bf99b8..0000000000 --- a/NPCs/CeaselessVoid/DarkEnergy2.cs +++ /dev/null @@ -1,282 +0,0 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.NPCs.CeaselessVoid -{ - public class DarkEnergy2 : ModNPC - { - public int invinceTime = 120; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dark Energy"); - Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; - npc.GetNPCDamage(); - npc.dontTakeDamage = true; - npc.width = 80; - npc.height = 80; - npc.defense = 50; - npc.lifeMax = 3000; - if (CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel1) - { - npc.lifeMax = 12000; - } - if (BossRushEvent.BossRushActive) - { - npc.lifeMax = 44000; - } - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.knockBackResist = 0.1f; - npc.noGravity = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - aiType = -1; - npc.HitSound = SoundID.NPCHit53; - npc.DeathSound = SoundID.NPCDeath44; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - } - - 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 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((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, 4f + 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, 4f + npc.gfxOffY); - 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); - - 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, 4f + 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 *= (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(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void AI() - { - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || CalamityWorld.malice; - if (invinceTime > 0) - { - npc.damage = 0; - invinceTime--; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } - - double mult = 0.5 + - ((CalamityWorld.revenge || CalamityWorld.malice) ? 0.2 : 0.0) + - ((CalamityWorld.death || CalamityWorld.malice) ? 0.2 : 0.0); - - if (npc.life < npc.lifeMax * mult || BossRushEvent.BossRushActive) - npc.knockBackResist = 0f; - - float tileEnrageMult = Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; - - float num1247 = 0.1f; - float maxDistance = 24f * MathHelper.Lerp(0.3333333334f, 1.6f, MathHelper.Clamp((tileEnrageMult - 1f) * 1.6666666667f, 0f, 1f)); - 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) < maxDistance) - { - if (npc.position.X < Main.npc[num1248].position.X) - npc.velocity.X = npc.velocity.X - num1247; - else - npc.velocity.X = npc.velocity.X + num1247; - - if (npc.position.Y < Main.npc[num1248].position.Y) - npc.velocity.Y = npc.velocity.Y - num1247; - else - npc.velocity.Y = npc.velocity.Y + num1247; - } - } - } - } - - if (npc.ai[1] == 0f) - { - npc.scale -= 0.01f; - npc.alpha += 15; - if (npc.alpha >= 125) - { - npc.alpha = 130; - npc.ai[1] = 1f; - } - } - else if (npc.ai[1] == 1f) - { - npc.scale += 0.01f; - npc.alpha -= 15; - if (npc.alpha <= 0) - { - npc.alpha = 0; - npc.ai[1] = 0f; - } - } - - npc.TargetClosest(true); - Player player = Main.player[npc.target]; - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - npc.velocity = new Vector2(0f, -10f); - - if (npc.timeLeft > 150) - npc.timeLeft = 150; - - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - Vector2 vector145 = new Vector2(npc.Center.X, npc.Center.Y); - float num1258 = Main.player[npc.target].Center.X - vector145.X; - float num1259 = Main.player[npc.target].Center.Y - vector145.Y; - float num1260 = (float)Math.Sqrt((double)(num1258 * num1258 + num1259 * num1259)); - - float num1261 = (expertMode ? 15f : 12f) * tileEnrageMult; - if (CalamityWorld.revenge || CalamityWorld.malice || BossRushEvent.BossRushActive) - num1261 += 3f; - if (CalamityWorld.death || CalamityWorld.malice || BossRushEvent.BossRushActive) - num1261 += 3f; - - num1260 = num1261 / num1260; - num1258 *= num1260; - num1259 *= num1260; - npc.velocity.X = (npc.velocity.X * 100f + num1258) / 101f; - npc.velocity.Y = (npc.velocity.Y * 100f + num1259) / 101f; - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); - } - - public override bool CheckActive() - { - return CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.VortexDebuff, 20, true); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - for (int k = 0; k < 20; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); - } - } - } - } -} diff --git a/NPCs/CeaselessVoid/DarkEnergy2.png b/NPCs/CeaselessVoid/DarkEnergy2.png deleted file mode 100644 index ad834020e5..0000000000 Binary files a/NPCs/CeaselessVoid/DarkEnergy2.png and /dev/null differ diff --git a/NPCs/CeaselessVoid/DarkEnergy3.cs b/NPCs/CeaselessVoid/DarkEnergy3.cs deleted file mode 100644 index 3b5cad9096..0000000000 --- a/NPCs/CeaselessVoid/DarkEnergy3.cs +++ /dev/null @@ -1,310 +0,0 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using CalamityMod.Events; -using CalamityMod.Projectiles.Rogue; -using CalamityMod.World; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.CeaselessVoid -{ - public class DarkEnergy3 : ModNPC - { - public int invinceTime = 120; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Dark Energy"); - Main.npcFrameCount[npc.type] = 6; - NPCID.Sets.TrailingMode[npc.type] = 1; - } - - public override void SetDefaults() - { - npc.Calamity().canBreakPlayerDefense = true; - npc.GetNPCDamage(); - npc.dontTakeDamage = true; - npc.width = 80; - npc.height = 80; - npc.defense = 50; - npc.lifeMax = 3000; - if (CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel1) - { - npc.lifeMax = 12000; - } - if (BossRushEvent.BossRushActive) - { - npc.lifeMax = 44000; - } - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; - npc.lifeMax += (int)(npc.lifeMax * HPBoost); - npc.aiStyle = -1; - aiType = -1; - npc.knockBackResist = 0.3f; - npc.noGravity = true; - npc.noTileCollide = true; - npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit53; - npc.DeathSound = SoundID.NPCDeath44; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(invinceTime); - writer.Write(npc.dontTakeDamage); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - invinceTime = reader.ReadInt32(); - npc.dontTakeDamage = reader.ReadBoolean(); - } - - 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 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((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, 4f + 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, 4f + npc.gfxOffY); - 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); - - 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, 4f + 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 *= (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(texture2D16, vector43, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - return false; - } - - public override void AI() - { - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || CalamityWorld.malice; - if (invinceTime > 0) - { - npc.damage = 0; - invinceTime--; - } - else - { - npc.damage = npc.defDamage; - npc.dontTakeDamage = false; - } - - if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) - { - npc.active = false; - npc.netUpdate = true; - return; - } - - double mult = 0.5 + - ((CalamityWorld.revenge || CalamityWorld.malice) ? 0.2 : 0.0) + - ((CalamityWorld.death || CalamityWorld.malice) ? 0.2 : 0.0); - - if (npc.life < npc.lifeMax * mult || BossRushEvent.BossRushActive) - npc.knockBackResist = 0f; - - float tileEnrageMult = Main.npc[CalamityGlobalNPC.voidBoss].ai[1]; - - float num1247 = 0.1f; - float maxDistance = 24f * MathHelper.Lerp(0.3333333334f, 1.6f, MathHelper.Clamp((tileEnrageMult - 1f) * 1.6666666667f, 0f, 1f)); - 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) < maxDistance) - { - if (npc.position.X < Main.npc[num1248].position.X) - npc.velocity.X = npc.velocity.X - num1247; - else - npc.velocity.X = npc.velocity.X + num1247; - - if (npc.position.Y < Main.npc[num1248].position.Y) - npc.velocity.Y = npc.velocity.Y - num1247; - else - npc.velocity.Y = npc.velocity.Y + num1247; - } - } - } - } - - if (npc.ai[1] == 0f) - { - npc.scale -= 0.01f; - npc.alpha += 15; - if (npc.alpha >= 125) - { - npc.alpha = 130; - npc.ai[1] = 1f; - } - } - else if (npc.ai[1] == 1f) - { - npc.scale += 0.01f; - npc.alpha -= 15; - if (npc.alpha <= 0) - { - npc.alpha = 0; - npc.ai[1] = 0f; - } - } - - npc.TargetClosest(true); - Player player = Main.player[npc.target]; - if (!player.active || player.dead) - { - npc.TargetClosest(false); - player = Main.player[npc.target]; - if (!player.active || player.dead) - { - npc.velocity = new Vector2(0f, -10f); - - if (npc.timeLeft > 150) - npc.timeLeft = 150; - - return; - } - } - else if (npc.timeLeft < 1800) - npc.timeLeft = 1800; - - float num1372 = (expertMode ? 10f : 8f) * tileEnrageMult; - if (CalamityWorld.revenge || CalamityWorld.malice || BossRushEvent.BossRushActive) - num1372 += 2f; - if (CalamityWorld.death || CalamityWorld.malice || BossRushEvent.BossRushActive) - num1372 += 2f; - - Vector2 vector167 = new Vector2(npc.Center.X + (float)(npc.direction * 20), npc.Center.Y + 6f); - float num1373 = Main.player[npc.target].position.X + (float)Main.player[npc.target].width * 0.5f - vector167.X; - float num1374 = Main.player[npc.target].Center.Y - vector167.Y; - float num1375 = (float)Math.Sqrt((double)(num1373 * num1373 + num1374 * num1374)); - float num1376 = num1372 / num1375; - num1373 *= num1376; - num1374 *= num1376; - npc.ai[0] -= 1f; - if (num1375 < 200f || npc.ai[0] > 0f) - { - if (num1375 < 200f) - { - npc.ai[0] = 20f; - } - if (npc.velocity.X < 0f) - { - npc.direction = -1; - } - else - { - npc.direction = 1; - } - return; - } - - npc.velocity.X = (npc.velocity.X * 50f + num1373) / 51f; - npc.velocity.Y = (npc.velocity.Y * 50f + num1374) / 51f; - if (num1375 < 350f) - { - npc.velocity.X = (npc.velocity.X * 10f + num1373) / 11f; - npc.velocity.Y = (npc.velocity.Y * 10f + num1374) / 11f; - } - if (num1375 < 300f) - { - npc.velocity.X = (npc.velocity.X * 7f + num1373) / 8f; - npc.velocity.Y = (npc.velocity.Y * 7f + num1374) / 8f; - } - } - - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) - { - npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); - } - - public override bool CheckActive() - { - return CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active; - } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(BuffID.VortexDebuff, 20, true); - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) - { - cooldownSlot = 1; - return true; - } - - public override void HitEffect(int hitDirection, double damage) - { - if (npc.life <= 0) - { - for (int k = 0; k < 20; k++) - { - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); - } - } - } - } -} diff --git a/NPCs/CeaselessVoid/DarkEnergy3.png b/NPCs/CeaselessVoid/DarkEnergy3.png deleted file mode 100644 index ad834020e5..0000000000 Binary files a/NPCs/CeaselessVoid/DarkEnergy3.png and /dev/null differ diff --git a/NPCs/Crabulon/CrabShroom.cs b/NPCs/Crabulon/CrabShroom.cs index 37cada574c..fa2a3ea716 100644 --- a/NPCs/Crabulon/CrabShroom.cs +++ b/NPCs/Crabulon/CrabShroom.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Crabulon npc.lifeMax = 25; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 150000; + npc.lifeMax = 15000; } aiType = -1; npc.knockBackResist = 0.75f; @@ -47,22 +47,24 @@ 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 || CalamityWorld.malice; - float speed = revenge ? 1.25f : 1f; + bool enraged = npc.Calamity().enraged > 0; + bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice; + float xVelocityLimit = enraged ? 10f : 5f; + float yVelocityLimit = revenge ? 1.25f : 1f; Player player = Main.player[npc.target]; npc.velocity.Y += 0.02f; - if (npc.velocity.Y > speed) + if (npc.velocity.Y > yVelocityLimit) { - npc.velocity.Y = speed; + npc.velocity.Y = yVelocityLimit; } - npc.TargetClosest(true); + npc.TargetClosest(); if (npc.position.X + npc.width < player.position.X) { if (npc.velocity.X < 0f) { npc.velocity.X *= 0.98f; } - npc.velocity.X += BossRushEvent.BossRushActive ? 0.2f : 0.1f; + npc.velocity.X += 0.1f; } else if (npc.position.X > player.position.X + player.width) { @@ -70,9 +72,9 @@ namespace CalamityMod.NPCs.Crabulon { npc.velocity.X *= 0.98f; } - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.2f : 0.1f; + npc.velocity.X -= 0.1f; } - if (npc.velocity.X > (BossRushEvent.BossRushActive ? 15f : 5f) || npc.velocity.X < (BossRushEvent.BossRushActive ? -15f : -5f)) + if (npc.velocity.X > xVelocityLimit || npc.velocity.X < -xVelocityLimit) { npc.velocity.X *= 0.97f; } @@ -86,11 +88,11 @@ namespace CalamityMod.NPCs.Crabulon 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 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, 4f + npc.gfxOffY); - + 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"); @@ -115,5 +117,5 @@ namespace CalamityMod.NPCs.Crabulon } } } - } + } } diff --git a/NPCs/Crabulon/CrabulonIdle.cs b/NPCs/Crabulon/CrabulonIdle.cs index b12f975919..3898ad1aaa 100644 --- a/NPCs/Crabulon/CrabulonIdle.cs +++ b/NPCs/Crabulon/CrabulonIdle.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.Crabulon npc.width = 280; npc.height = 160; npc.defense = 8; - npc.LifeMaxNERB(3000, 4000, 11000000); + npc.LifeMaxNERB(3000, 4000, 1100000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -75,10 +75,11 @@ namespace CalamityMod.NPCs.Crabulon 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; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; npc.spriteDirection = npc.direction; @@ -135,13 +136,23 @@ namespace CalamityMod.NPCs.Crabulon npc.timeLeft = 1800; float enrageScale = 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - enrageScale += 1f; - if (!player.ZoneGlowshroom || malice) - enrageScale += 1f; - + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (!player.ZoneGlowshroom || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } if (npc.ai[0] != 0f && npc.ai[0] < 3f) { @@ -153,11 +164,6 @@ namespace CalamityMod.NPCs.Crabulon { int num352 = 1; npc.localAI[3] += 2f; - if (BossRushEvent.BossRushActive) - { - npc.localAI[3] += 2f; - num352 += 3; - } if (phase2) { npc.localAI[3] += 1f; @@ -187,10 +193,6 @@ namespace CalamityMod.NPCs.Crabulon float num353 = 10f; int type = ModContent.ProjectileType(); Main.PlaySound(SoundID.Item42, (int)npc.position.X, (int)npc.position.Y); - if (BossRushEvent.BossRushActive) - { - num353 += 3f; - } if (phase2) { num353 += 1f; @@ -255,10 +257,6 @@ namespace CalamityMod.NPCs.Crabulon num823 = 1.75f; if (death) num823 += 2f * (1f - lifeRatio); - if (BossRushEvent.BossRushActive) - num823 = 12f; - if (npc.Calamity().enraged > 0) - num823 = 16f; num823 += 4f * enrageScale; bool flag51 = false; @@ -388,8 +386,8 @@ namespace CalamityMod.NPCs.Crabulon } else if (npc.ai[1] == -1f) { - int velocityX = BossRushEvent.BossRushActive ? 12 : 4; - float velocityY = BossRushEvent.BossRushActive ? -16f : -12f; + int velocityX = 4; + float velocityY = -12f; float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); float speedMult = 1f; @@ -526,7 +524,7 @@ namespace CalamityMod.NPCs.Crabulon 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 += BossRushEvent.BossRushActive ? 0.3f : death ? 0.18f : 0.15f; + npc.velocity.Y += death ? 0.18f : 0.15f; } else { @@ -541,16 +539,12 @@ namespace CalamityMod.NPCs.Crabulon else if (npc.direction > 0) npc.velocity.X += velocityX; - float num626 = BossRushEvent.BossRushActive ? 5f : 2.5f; + float num626 = 2.5f; num626 += enrageScale; if (revenge) { num626 += 1f; } - if (npc.Calamity().enraged > 0) - { - num626 += 3f; - } if (phase2) { num626 += 1f; @@ -631,7 +625,7 @@ namespace CalamityMod.NPCs.Crabulon 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, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color37 = Color.Lerp(Color.White, Color.Cyan, 0.5f); if (npc.ai[0] > 2f) @@ -639,7 +633,7 @@ namespace CalamityMod.NPCs.Crabulon 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, 4f + npc.gfxOffY); + 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); @@ -650,7 +644,7 @@ namespace CalamityMod.NPCs.Crabulon 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, 4f + npc.gfxOffY); + 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); diff --git a/NPCs/Crags/SoulSlurper.cs b/NPCs/Crags/SoulSlurper.cs index 13eedfc458..b6dffd4fc4 100644 --- a/NPCs/Crags/SoulSlurper.cs +++ b/NPCs/Crags/SoulSlurper.cs @@ -241,14 +241,14 @@ namespace CalamityMod.NPCs.Crags 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -263,7 +263,7 @@ namespace CalamityMod.NPCs.Crags 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, 4f + npc.gfxOffY); + 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); } } diff --git a/NPCs/Cryogen/Cryocore.cs b/NPCs/Cryogen/Cryocore.cs index 8a27e5ebbf..3ad439f611 100644 --- a/NPCs/Cryogen/Cryocore.cs +++ b/NPCs/Cryogen/Cryocore.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Cryogen npc.lifeMax = 220; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 30000; + npc.lifeMax = 3000; } npc.aiStyle = -1; aiType = -1; @@ -99,11 +99,6 @@ namespace CalamityMod.NPCs.Cryogen player.AddBuff(BuffID.Chilled, 60, true); } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) diff --git a/NPCs/Cryogen/Cryocore2.cs b/NPCs/Cryogen/Cryocore2.cs index 2bcf04a2b2..c0481f955f 100644 --- a/NPCs/Cryogen/Cryocore2.cs +++ b/NPCs/Cryogen/Cryocore2.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Cryogen npc.lifeMax = 300; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 40000; + npc.lifeMax = 4000; } npc.aiStyle = -1; aiType = -1; @@ -99,11 +99,6 @@ namespace CalamityMod.NPCs.Cryogen player.AddBuff(BuffID.Chilled, 60, true); } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index abf643b65c..d3c2e2fb14 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -47,7 +47,7 @@ namespace CalamityMod.NPCs.Cryogen npc.height = 88; npc.defense = 12; npc.DR_NERD(0.1f); - npc.LifeMaxNERB(18795, 27615, 3000000); + npc.LifeMaxNERB(18795, 27615, 300000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -99,20 +99,30 @@ namespace CalamityMod.NPCs.Cryogen Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float enrageScale = death ? 0.5f : 0f; if (!player.ZoneSnow || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 2f; + } if (enrageScale > 2f) enrageScale = 2f; if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale = 3f; + + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale = 4f; + } // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -199,7 +209,7 @@ namespace CalamityMod.NPCs.Cryogen float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = BossRushEvent.BossRushActive ? 12f : 4f; + float velocity = 4f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); @@ -230,7 +240,7 @@ namespace CalamityMod.NPCs.Cryogen float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = (BossRushEvent.BossRushActive ? 12f : 9f) + enrageScale; + float velocity = 9f + enrageScale; Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { @@ -248,8 +258,6 @@ namespace CalamityMod.NPCs.Cryogen float num1246 = revenge ? 5f : 4f; num1246 += 2f * enrageScale; - if (BossRushEvent.BossRushActive) - num1246 = 14f; num1245 = num1246 / num1245; num1243 *= num1245; @@ -287,7 +295,7 @@ namespace CalamityMod.NPCs.Cryogen float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity2 = (BossRushEvent.BossRushActive ? 12f : 9f) + enrageScale; + float velocity2 = 9f + enrageScale; Vector2 spinningPoint = new Vector2(0f, -velocity2); for (int k = 0; k < totalProjectiles; k++) { @@ -300,13 +308,8 @@ namespace CalamityMod.NPCs.Cryogen float velocity = revenge ? 3.5f : 4f; float acceleration = 0.15f; - velocity -= enrageScale; + velocity -= enrageScale * 0.8f; acceleration += 0.07f * enrageScale; - if (BossRushEvent.BossRushActive) - { - velocity = 3f; - acceleration *= 1.5f; - } if (npc.position.Y > player.position.Y - 375f) { @@ -365,7 +368,7 @@ namespace CalamityMod.NPCs.Cryogen { if (npc.ai[1] == 390f) { - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (BossRushEvent.BossRushActive ? 30f : 18f + enrageScale * 2f); + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); npc.ai[1] = 450f; calamityGlobalNPC.newAI[0] = 0f; @@ -377,7 +380,7 @@ namespace CalamityMod.NPCs.Cryogen Main.PlaySound(SoundID.Item28, npc.Center); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = (BossRushEvent.BossRushActive ? 14f : 9f) + enrageScale; + float velocity = 9f + enrageScale; for (int i = 0; i < 2; i++) { int totalProjectiles = 10; @@ -449,7 +452,7 @@ namespace CalamityMod.NPCs.Cryogen float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = (BossRushEvent.BossRushActive ? 14f : 9f) + enrageScale; + float velocity = 9f + enrageScale; Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { @@ -467,8 +470,6 @@ namespace CalamityMod.NPCs.Cryogen float num1246 = revenge ? 7f : 6f; num1246 += 2f * enrageScale; - if (BossRushEvent.BossRushActive) - num1246 = 20f; num1245 = num1246 / num1245; num1243 *= num1245; @@ -491,7 +492,7 @@ namespace CalamityMod.NPCs.Cryogen { if (npc.ai[1] == 380f) { - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (BossRushEvent.BossRushActive ? 30f : 18f + enrageScale * 2f); + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); npc.ai[1] = 440f; calamityGlobalNPC.newAI[0] = 0f; @@ -503,7 +504,7 @@ namespace CalamityMod.NPCs.Cryogen Main.PlaySound(SoundID.Item28, npc.Center); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = (BossRushEvent.BossRushActive ? 14f : 9f) + enrageScale; + float velocity = 9f + enrageScale; for (int i = 0; i < 3; i++) { int totalProjectiles = 8; @@ -575,7 +576,7 @@ namespace CalamityMod.NPCs.Cryogen float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = (BossRushEvent.BossRushActive ? 15f : 10f) + enrageScale; + float velocity = 10f + enrageScale; Vector2 spinningPoint = new Vector2(0f, -velocity); for (int k = 0; k < totalProjectiles; k++) { @@ -593,8 +594,6 @@ namespace CalamityMod.NPCs.Cryogen float speed = revenge ? 5.5f : 5f; speed += 1.5f * enrageScale; - if (BossRushEvent.BossRushActive) - speed = 15f; num1245 = speed / num1245; num1243 *= num1245; @@ -607,7 +606,7 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[2] += 1f; - if (npc.localAI[2] >= (BossRushEvent.BossRushActive ? 90f : 180f)) + if (npc.localAI[2] >= 180f) { npc.TargetClosest(); npc.localAI[2] = 0f; @@ -677,7 +676,7 @@ namespace CalamityMod.NPCs.Cryogen Main.PlaySound(SoundID.Item28, npc.Center); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = (BossRushEvent.BossRushActive ? 14f : 9f) + enrageScale; + float velocity = 9f + enrageScale; for (int i = 0; i < 3; i++) { int totalProjectiles = 6; @@ -748,7 +747,7 @@ namespace CalamityMod.NPCs.Cryogen { if (npc.ai[1] == 60f) { - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (BossRushEvent.BossRushActive ? 30f : 18f + enrageScale * 2f); + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); if (phase7) { @@ -759,7 +758,7 @@ namespace CalamityMod.NPCs.Cryogen Main.PlaySound(SoundID.Item28, npc.Center); int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity = (BossRushEvent.BossRushActive ? 14f : 9f) + enrageScale; + float velocity = 9f + enrageScale; for (int i = 0; i < 4; i++) { int totalProjectiles = 4; @@ -815,8 +814,6 @@ namespace CalamityMod.NPCs.Cryogen } float num1372 = 16f + enrageScale * 2f; - if (BossRushEvent.BossRushActive) - num1372 = 32f; 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; @@ -864,7 +861,7 @@ namespace CalamityMod.NPCs.Cryogen float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - float velocity2 = BossRushEvent.BossRushActive ? 16f : 6f; + float velocity2 = 6f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(velocity2 * Math.Sin(angleA) / Math.Sin(angleB)); @@ -891,11 +888,6 @@ namespace CalamityMod.NPCs.Cryogen float acceleration = 0.2f; velocity -= enrageScale; acceleration += 0.07f * enrageScale; - if (BossRushEvent.BossRushActive) - { - velocity = 2f; - acceleration *= 1.5f; - } if (npc.position.Y > player.position.Y - 375f) { @@ -1017,7 +1009,7 @@ namespace CalamityMod.NPCs.Cryogen 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, 4f + npc.gfxOffY); + 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; } diff --git a/NPCs/Cryogen/CryogenIce.cs b/NPCs/Cryogen/CryogenIce.cs index 53764ccc5b..3c9a5781ce 100644 --- a/NPCs/Cryogen/CryogenIce.cs +++ b/NPCs/Cryogen/CryogenIce.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.Cryogen npc.lifeMax = 1400; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 100000; + npc.lifeMax = 10000; } npc.alpha = 255; npc.HitSound = SoundID.NPCHit5; @@ -78,7 +78,9 @@ namespace CalamityMod.NPCs.Cryogen npc.lifeMax = (int)(npc.lifeMax * 0.5f * bossLifeScale); } - public override void HitEffect(int hitDirection, double damage) + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) { @@ -112,7 +114,7 @@ namespace CalamityMod.NPCs.Cryogen double radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage2 = npc.GetProjectileDamage(type); - float velocity = BossRushEvent.BossRushActive ? 12f : 9f; + float velocity = 9f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); diff --git a/NPCs/Cryogen/IceMass.cs b/NPCs/Cryogen/IceMass.cs index eddd6bcf1b..c601254076 100644 --- a/NPCs/Cryogen/IceMass.cs +++ b/NPCs/Cryogen/IceMass.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.Cryogen npc.lifeMax = 220; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 30000; + npc.lifeMax = 3000; } npc.knockBackResist = 0f; npc.canGhostHeal = false; @@ -73,11 +73,6 @@ namespace CalamityMod.NPCs.Cryogen Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.02f, 0.7f, 0.7f); } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index dd84f1ea55..c9f31f86b7 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.height = 36; npc.defense = 6; npc.DR_NERD(0.05f); - npc.LifeMaxNERB(2600, 3000, 16500000); + npc.LifeMaxNERB(2600, 3000, 1650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -63,9 +63,10 @@ namespace CalamityMod.NPCs.DesertScourge } Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = npc.Calamity().enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float burrowTimeGateValue = death ? 420f : 540f; bool burrow = Main.npc[(int)npc.ai[2]].Calamity().newAI[0] >= burrowTimeGateValue; @@ -86,10 +87,6 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.netMode != NetmodeID.MultiplayerClient && revenge && !burrow) { npc.localAI[0] += (float)Main.rand.Next(4); - if (npc.Calamity().enraged > 0) - { - npc.localAI[0] += 4f; - } if (npc.localAI[0] >= (float)Main.rand.Next(1400, 26001)) { npc.localAI[0] = 0f; @@ -100,13 +97,13 @@ namespace CalamityMod.NPCs.DesertScourge 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 = BossRushEvent.BossRushActive ? 12f : 6f; + float num941 = enraged ? 9f : 6f; num944 = num941 / num944; num942 *= num944; num943 *= num944; vector104.X += num942 * 5f; vector104.Y += num943 * 5f; - if (Main.rand.NextBool(2) || BossRushEvent.BossRushActive) + if (Main.rand.NextBool(2) || enraged) { Projectile.NewProjectile(vector104.X, vector104.Y, num942, num943, projectileType, npc.GetProjectileDamage(projectileType), 0f, Main.myPlayer, 0f, 0f); } diff --git a/NPCs/DesertScourge/DesertScourgeBodySmall.cs b/NPCs/DesertScourge/DesertScourgeBodySmall.cs index 6c8e713b1b..eb756d8f7b 100644 --- a/NPCs/DesertScourge/DesertScourgeBodySmall.cs +++ b/NPCs/DesertScourge/DesertScourgeBodySmall.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.lifeMax = 800; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 350000; + npc.lifeMax = 35000; } npc.aiStyle = 6; aiType = -1; diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 986a0a8d86..4d65853932 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.npcSlots = 12f; npc.width = 32; npc.height = 80; - npc.LifeMaxNERB(2600, 3000, 16500000); + npc.LifeMaxNERB(2600, 3000, 1650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -83,10 +83,11 @@ namespace CalamityMod.NPCs.DesertScourge { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -99,11 +100,18 @@ namespace CalamityMod.NPCs.DesertScourge Player player = Main.player[npc.target]; float enrageScale = 0f; - if (!player.ZoneDesert || malice) - enrageScale += 2f; - + if (!player.ZoneDesert || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -141,18 +149,6 @@ namespace CalamityMod.NPCs.DesertScourge turnSpeed *= 1.5f; } - if (npc.Calamity().enraged > 0) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - - if (BossRushEvent.BossRushActive) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - if (npc.ai[3] > 0f) npc.realLife = (int)npc.ai[3]; @@ -226,11 +222,9 @@ namespace CalamityMod.NPCs.DesertScourge if (!flag94) { Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); - int num954 = (npc.Calamity().enraged > 0) ? 500 : 1000; + int num954 = 1000; if (enrageScale > 0f) num954 = 100; - if (BossRushEvent.BossRushActive) - num954 /= 2; bool flag95 = true; if (npc.position.Y > player.position.Y) diff --git a/NPCs/DesertScourge/DesertScourgeHeadSmall.cs b/NPCs/DesertScourge/DesertScourgeHeadSmall.cs index a95ab611df..de064cf9e3 100644 --- a/NPCs/DesertScourge/DesertScourgeHeadSmall.cs +++ b/NPCs/DesertScourge/DesertScourgeHeadSmall.cs @@ -10,8 +10,8 @@ namespace CalamityMod.NPCs.DesertScourge public class DesertScourgeHeadSmall : ModNPC { public bool flies = false; - public float speed = BossRushEvent.BossRushActive ? 20f : 12.5f; - public float turnSpeed = BossRushEvent.BossRushActive ? 0.2f : 0.125f; + public float speed = 12.5f; + public float turnSpeed = 0.125f; public int minLength = 12; public int maxLength = 13; bool TailSpawned = false; @@ -32,7 +32,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.lifeMax = 800; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 350000; + npc.lifeMax = 35000; } npc.aiStyle = 6; aiType = -1; @@ -131,8 +131,6 @@ namespace CalamityMod.NPCs.DesertScourge npc.localAI[1] = 1f; Rectangle rectangle12 = new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height); int num954 = (CalamityWorld.death || CalamityWorld.malice) ? 300 : 1000; - if (BossRushEvent.BossRushActive) - num954 = 150; bool flag95 = true; if (npc.position.Y > player.position.Y) @@ -375,11 +373,6 @@ namespace CalamityMod.NPCs.DesertScourge } } - public override bool PreNPCLoot() - { - return false; - } - public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 3; k++) diff --git a/NPCs/DesertScourge/DesertScourgeTail.cs b/NPCs/DesertScourge/DesertScourgeTail.cs index 81f820c434..0ec1efdfaf 100644 --- a/NPCs/DesertScourge/DesertScourgeTail.cs +++ b/NPCs/DesertScourge/DesertScourgeTail.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.height = 48; npc.defense = 9; npc.DR_NERD(0.1f); - npc.LifeMaxNERB(2600, 3000, 16500000); + npc.LifeMaxNERB(2600, 3000, 1650000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; diff --git a/NPCs/DesertScourge/DesertScourgeTailSmall.cs b/NPCs/DesertScourge/DesertScourgeTailSmall.cs index 4698c4bd36..fad410cd8d 100644 --- a/NPCs/DesertScourge/DesertScourgeTailSmall.cs +++ b/NPCs/DesertScourge/DesertScourgeTailSmall.cs @@ -22,7 +22,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.lifeMax = 800; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 350000; + npc.lifeMax = 35000; } npc.aiStyle = 6; aiType = -1; diff --git a/NPCs/DesertScourge/DriedSeekerBody.cs b/NPCs/DesertScourge/DriedSeekerBody.cs index f6c7601ce1..c527852e61 100644 --- a/NPCs/DesertScourge/DriedSeekerBody.cs +++ b/NPCs/DesertScourge/DriedSeekerBody.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.lifeMax = 100; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 50000; + npc.lifeMax = 5000; } npc.knockBackResist = 0f; npc.aiStyle = 6; diff --git a/NPCs/DesertScourge/DriedSeekerHead.cs b/NPCs/DesertScourge/DriedSeekerHead.cs index 8cd3b49879..ec6a636014 100644 --- a/NPCs/DesertScourge/DriedSeekerHead.cs +++ b/NPCs/DesertScourge/DriedSeekerHead.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.lifeMax = 100; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 50000; + npc.lifeMax = 5000; } npc.aiStyle = 6; aiType = -1; @@ -96,10 +96,5 @@ namespace CalamityMod.NPCs.DesertScourge } } } - - public override bool PreNPCLoot() - { - return false; - } } } diff --git a/NPCs/DesertScourge/DriedSeekerTail.cs b/NPCs/DesertScourge/DriedSeekerTail.cs index bc8dfd8d55..2a1e6d7155 100644 --- a/NPCs/DesertScourge/DriedSeekerTail.cs +++ b/NPCs/DesertScourge/DriedSeekerTail.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.DesertScourge npc.lifeMax = 100; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 50000; + npc.lifeMax = 5000; } npc.knockBackResist = 0f; npc.aiStyle = 6; diff --git a/NPCs/DevourerofGods/DevourerofGodsBody.cs b/NPCs/DevourerofGods/DevourerofGodsBody.cs index eedb1ac7ce..f40071661d 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody.cs @@ -180,7 +180,7 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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/DevourerofGodsBodyGlow"); diff --git a/NPCs/DevourerofGods/DevourerofGodsBody2.cs b/NPCs/DevourerofGods/DevourerofGodsBody2.cs index 14193dafde..2a8e7670cc 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBody2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBody2.cs @@ -154,7 +154,7 @@ namespace CalamityMod.NPCs.DevourerofGods 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/DevourerofGods/DevourerofGodsBodyS.cs b/NPCs/DevourerofGods/DevourerofGodsBodyS.cs index 4d6b9c910a..8e95007eec 100644 --- a/NPCs/DevourerofGods/DevourerofGodsBodyS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsBodyS.cs @@ -32,7 +32,7 @@ namespace CalamityMod.NPCs.DevourerofGods CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.925f; global.unbreakableDR = true; - npc.LifeMaxNERB(517500, 621000, 9200000); + npc.LifeMaxNERB(517500, 621000, 920000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -200,7 +200,7 @@ namespace CalamityMod.NPCs.DevourerofGods 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, 4f + npc.gfxOffY); + 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) diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index 16f516601e..70d762a4dc 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -121,6 +121,8 @@ namespace CalamityMod.NPCs.DevourerofGods bool phase2 = lifeRatio < 0.75f; bool phase3 = lifeRatio < 0.2f; + npc.Calamity().CurrentlyEnraged = malice; + // 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); @@ -875,7 +877,7 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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/DevourerofGodsHeadGlow"); diff --git a/NPCs/DevourerofGods/DevourerofGodsHead2.cs b/NPCs/DevourerofGods/DevourerofGodsHead2.cs index daa98fb752..345e53a3f7 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead2.cs @@ -320,7 +320,7 @@ namespace CalamityMod.NPCs.DevourerofGods 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs index 1b122ba9de..627b9464c0 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHeadS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHeadS.cs @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.width = 186; npc.height = 186; npc.defense = 50; - npc.LifeMaxNERB(517500, 621000, 9200000); + npc.LifeMaxNERB(517500, 621000, 920000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.takenDamageMultiplier = 1.1f; @@ -163,17 +163,20 @@ namespace CalamityMod.NPCs.DevourerofGods // Variables Vector2 vector = npc.Center; bool flies = npc.ai[3] == 0f; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; bool phase2 = lifeRatio < 0.8f; bool phase3 = lifeRatio < 0.6f; bool phase4 = lifeRatio < 0.3f; bool phase5 = lifeRatio < 0.15f; - // 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); + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + // 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 shit again if (npc.ai[2] > 0f) @@ -377,11 +380,11 @@ namespace CalamityMod.NPCs.DevourerofGods calamityGlobalNPC.newAI[0] = 0f; // Laser walls - if (!phase4 && (laserWallPhase == (int)LaserWallPhase.FireLaserWalls || calamityGlobalNPC.enraged > 0)) + if (!phase4 && laserWallPhase == (int)LaserWallPhase.FireLaserWalls) { float speed = 12f; float spawnOffset = 1500f; - float divisor = malice ? 100f : 120f; + float divisor = enraged ? 80f : malice ? 100f : 120f; if (calamityGlobalNPC.newAI[1] % divisor == 0f) { @@ -529,7 +532,7 @@ namespace CalamityMod.NPCs.DevourerofGods if (!NPC.AnyNPCs(ModContent.NPCType())) npc.active = false; - float fallSpeed = malice ? 19.5f : death ? 17.75f : 16f; + float fallSpeed = enraged ? 21f : malice ? 19.5f : death ? 17.75f : 16f; if (expertMode) fallSpeed += 3.5f * (1f - lifeRatio); @@ -596,10 +599,10 @@ namespace CalamityMod.NPCs.DevourerofGods npc.localAI[1] = 0f; - 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 = enraged ? 20f : malice ? 18f : death ? 16.5f : 15f; + float turnSpeed = enraged ? 0.4f : malice ? 0.36f : death ? 0.33f : 0.3f; + float homingSpeed = enraged ? 40f : malice ? 36f : death ? 30f : 24f; + float homingTurnSpeed = enraged ? 0.55f : malice ? 0.48f : death ? 0.405f : 0.33f; if (expertMode) { @@ -809,7 +812,7 @@ namespace CalamityMod.NPCs.DevourerofGods calamityGlobalNPC.newAI[2] += 1f; - float turnSpeed = malice ? 0.3f : death ? 0.24f : 0.18f; + float turnSpeed = enraged ? 0.36f : malice ? 0.3f : death ? 0.24f : 0.18f; if (expertMode) { @@ -935,8 +938,8 @@ namespace CalamityMod.NPCs.DevourerofGods } else { - double maximumSpeed1 = malice ? 0.52 : death ? 0.46 : 0.4; - double maximumSpeed2 = malice ? 1.25 : death ? 1.125 : 1D; + double maximumSpeed1 = enraged ? 0.6 : malice ? 0.52 : death ? 0.46 : 0.4; + double maximumSpeed2 = enraged ? 1.4 : malice ? 1.25 : death ? 1.125 : 1D; if (increaseSpeedMore) { @@ -1079,7 +1082,7 @@ namespace CalamityMod.NPCs.DevourerofGods Projectile.NewProjectile(targetVector, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI); } - teleportTimer = BossRushEvent.BossRushActive ? 100 : (CalamityWorld.death || CalamityWorld.malice) ? 120 : CalamityWorld.revenge ? 140 : Main.expertMode ? 160 : 180; + teleportTimer = (CalamityWorld.death || CalamityWorld.malice) ? 120 : CalamityWorld.revenge ? 140 : Main.expertMode ? 160 : 180; } private void Teleport(Player player, bool malice, bool death, bool revenge, bool expertMode, bool phase3) @@ -1120,7 +1123,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.TargetClosest(); npc.position = newPosition; - float chargeVelocity = BossRushEvent.BossRushActive ? 36f : malice ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; + float chargeVelocity = malice ? 30f : death ? 26f : revenge ? 24f : expertMode ? 22f : 20f; float maxChargeDistance = 1600f; postTeleportTimer = (int)Math.Round(maxChargeDistance / chargeVelocity); npc.alpha = postTeleportTimer; @@ -1170,7 +1173,7 @@ namespace CalamityMod.NPCs.DevourerofGods Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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) diff --git a/NPCs/DevourerofGods/DevourerofGodsTail.cs b/NPCs/DevourerofGods/DevourerofGodsTail.cs index f95b708ee2..09348e7048 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail.cs @@ -163,7 +163,7 @@ namespace CalamityMod.NPCs.DevourerofGods 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, 4f + npc.gfxOffY); + 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/DevourerofGodsTailGlow"); diff --git a/NPCs/DevourerofGods/DevourerofGodsTail2.cs b/NPCs/DevourerofGods/DevourerofGodsTail2.cs index 9a38cd2818..56d963d099 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTail2.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTail2.cs @@ -151,7 +151,7 @@ namespace CalamityMod.NPCs.DevourerofGods 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/DevourerofGods/DevourerofGodsTailS.cs b/NPCs/DevourerofGods/DevourerofGodsTailS.cs index 297b3e3456..2bc0b738b9 100644 --- a/NPCs/DevourerofGods/DevourerofGodsTailS.cs +++ b/NPCs/DevourerofGods/DevourerofGodsTailS.cs @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.DevourerofGods npc.width = 80; npc.height = 140; npc.defense = 50; - npc.LifeMaxNERB(517500, 621000, 9200000); + npc.LifeMaxNERB(517500, 621000, 920000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.takenDamageMultiplier = 1.25f; @@ -196,7 +196,7 @@ namespace CalamityMod.NPCs.DevourerofGods 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, 4f + npc.gfxOffY); + 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) diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs new file mode 100644 index 0000000000..f4777b1b0f --- /dev/null +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -0,0 +1,539 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Thanatos +{ + public class ThanatosBody1 : ModNPC + { + // 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, 4, 0f, 16f, 1.5f); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XM-05 Thanatos"); + Main.npcFrameCount[npc.type] = 5; + } + + public override void SetDefaults() + { + 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(1000000, 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.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.dontCountMe = true; + npc.chaseable = false; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + writer.Write(vulnerable); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + 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(); + vulnerable = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = 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 void AI() + { + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // 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; + } + if (!shouldDespawn) + { + if (npc.ai[1] > 0f) + shouldDespawn = false; + else if (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; + } + + // 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 = invisiblePhase; + if (!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; + } + + // Set timer to whoAmI so that segments don't all fire lasers at the same time + if (npc.localAI[2] == 0f) + npc.localAI[2] = npc.ai[0]; + + bool shootTrackingLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + if (shootTrackingLasers) + { + 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; + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + { + float divisor = 120f; + int numSegments = ThanatosHead.minLength; + double numSegmentsAbleToFire = malice ? 25D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + if ((npc.ai[3] % divisor == 0f && npc.localAI[2] % 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] >= 72f) + { + 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; + } + } + + 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] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + npc.ai[3] += 1f; + float shootProjectile = 120f; + float timer = npc.ai[0] + 15f; + float divisor = timer + shootProjectile; + if (npc.ai[3] % divisor == 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] >= 72f) + { + 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 ? 40f : death ? 25f : revenge ? 20f : expertMode ? 15f : 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 + { + // 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] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + } + } + else + { + // Set alternating laser-firing body segments every 3 seconds + npc.localAI[1] += 1f; + if (npc.localAI[1] >= 180f) + { + npc.localAI[1] = 0f; + npc.localAI[2] += 1f; + } + + npc.Calamity().newAI[0] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + else + { + // Body is vulnerable while venting + vulnerable = true; + } + } + + 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; + + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Noise + float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.25f : 1f; + if (npc.localAI[0] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent").WithVolume(volume), npc.Center); + + // Steam + float maxSteamTime = 180f; + npc.localAI[0] += 1f; + if (npc.localAI[0] < maxSteamTime) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = 3; + } + } + else + npc.localAI[0] = 0f; + + SmokeDrawer.Update(); + + 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)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)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; + } + } + + 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; + } + + 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 !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + } + + public override void FindFrame(int frameHeight) // 5 total frames + { + // Swap between venting and non-venting frames + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + bool shootTrackingLasers = (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 (shootTrackingLasers) + { + if (npc.Calamity().newAI[1] == 0f && npc.Calamity().newAI[0] > 0f) + { + if (npc.frameCounter >= 12D) + { + 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 >= 12D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + } + else + { + if (npc.frameCounter >= 12D) + { + 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/ThanatosBody1Glow"); + 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) + { + 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/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 OnHitPlayer(Player player, int damage, bool crit) + { + if (npc.Opacity == 1f) + { + int duration = vulnerable ? 120 : 60; + player.AddBuff(BuffID.Ichor, duration); + player.AddBuff(BuffID.CursedInferno, duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(BuffID.Frostburn, duration); + player.AddBuff(BuffID.OnFire, duration); + } + } + } +} diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.png b/NPCs/ExoMechs/Thanatos/ThanatosBody1.png new file mode 100644 index 0000000000..a1bbe33f52 Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosBody1.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow.png b/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow.png new file mode 100644 index 0000000000..cfa0941d35 Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs new file mode 100644 index 0000000000..33d377f148 --- /dev/null +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -0,0 +1,539 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Thanatos +{ + public class ThanatosBody2 : ModNPC + { + // 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, 4, 0f, 16f, 1.5f); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XM-05 Thanatos"); + Main.npcFrameCount[npc.type] = 5; + } + + public override void SetDefaults() + { + 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(1000000, 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.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.dontCountMe = true; + npc.chaseable = false; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + writer.Write(vulnerable); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + 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(); + vulnerable = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = 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 void AI() + { + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // 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; + } + if (!shouldDespawn) + { + if (npc.ai[1] > 0f) + shouldDespawn = false; + else if (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; + } + + // 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 = invisiblePhase; + if (!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; + } + + // Set timer to whoAmI so that segments don't all fire lasers at the same time + if (npc.localAI[2] == 0f) + npc.localAI[2] = npc.ai[0]; + + bool shootTrackingLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + if (shootTrackingLasers) + { + 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; + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + { + float divisor = 120f; + int numSegments = ThanatosHead.minLength; + double numSegmentsAbleToFire = malice ? 25D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + if ((npc.ai[3] % divisor == 0f && npc.localAI[2] % 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] >= 72f) + { + 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; + } + } + + 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] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + npc.ai[3] += 1f; + float shootProjectile = 120f; + float timer = npc.ai[0] + 15f; + float divisor = timer + shootProjectile; + if (npc.ai[3] % divisor == 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] >= 72f) + { + 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 ? 40f : death ? 25f : revenge ? 20f : expertMode ? 15f : 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 + { + // 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] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + } + } + else + { + // Set alternating laser-firing body segments every 3 seconds + npc.localAI[1] += 1f; + if (npc.localAI[1] >= 180f) + { + npc.localAI[1] = 0f; + npc.localAI[2] += 1f; + } + + npc.Calamity().newAI[0] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + else + { + // Body is vulnerable while venting + vulnerable = true; + } + } + + 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; + + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Noise + float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.25f : 1f; + if (npc.localAI[0] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent").WithVolume(volume), npc.Center); + + // Steam + float maxSteamTime = 180f; + npc.localAI[0] += 1f; + if (npc.localAI[0] < maxSteamTime) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = 3; + } + } + else + npc.localAI[0] = 0f; + + SmokeDrawer.Update(); + + 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)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)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; + } + } + + 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; + } + + 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 !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + } + + public override void FindFrame(int frameHeight) // 5 total frames + { + // Swap between venting and non-venting frames + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + bool shootTrackingLasers = (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 (shootTrackingLasers) + { + if (npc.Calamity().newAI[1] == 0f && npc.Calamity().newAI[0] > 0f) + { + if (npc.frameCounter >= 12D) + { + 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 >= 12D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + } + else + { + if (npc.frameCounter >= 12D) + { + 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) + { + 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()); + } + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + if (npc.Opacity == 1f) + { + int duration = vulnerable ? 120 : 60; + player.AddBuff(BuffID.Ichor, duration); + player.AddBuff(BuffID.CursedInferno, duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(BuffID.Frostburn, duration); + player.AddBuff(BuffID.OnFire, duration); + } + } + } +} diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.png b/NPCs/ExoMechs/Thanatos/ThanatosBody2.png new file mode 100644 index 0000000000..eb178bfffc Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosBody2.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow.png b/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow.png new file mode 100644 index 0000000000..8fea258abe Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs new file mode 100644 index 0000000000..933b025751 --- /dev/null +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -0,0 +1,870 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Items.Potions; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Thanatos +{ + //[AutoloadBossHead] + public class ThanatosHead : ModNPC + { + 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, 4, 0f, 16f, 1.5f); + + // 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; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Base distance from the target for most attacks + private const float baseDistance = 1200f; + + // 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; + } + + 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(1000000, 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(10, 0, 0, 0); + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + npc.chaseable = false; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + 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(); + 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 override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.draedonExoMechWorm = npc.whoAmI; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // 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 exoSpazAlive = false; + bool exoRetAlive = 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++; + exoSpazAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) + { + otherExoMechsAlive++; + exoRetAlive = true; + } + } + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoPrimeLifeRatio = defaultLifeRatio; + float exoSpazLifeRatio = defaultLifeRatio; + float exoRetLifeRatio = defaultLifeRatio; + if (exoPrimeAlive) + exoPrimeLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + if (exoSpazAlive) + exoSpazLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + if (exoRetAlive) + exoRetLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].lifeMax; + float totalOtherExoMechLifeRatio = exoPrimeLifeRatio + exoSpazLifeRatio + exoRetLifeRatio; + + // Check if any of the other mechs are passive + bool exoPrimePassive = false; + bool exoSpazPassive = false; + bool exoRetPassive = false; + /*if (exoPrimeAlive) + exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].newAI[1] == (float)AresBody.SecondaryPhase.Passive; + if (exoSpazAlive) + exoSpazPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].newAI[1] == (float)Apollo.SecondaryPhase.Passive; + if (exoRetAlive) + exoRetPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].newAI[1] == (float)Artemis.SecondaryPhase.Passive;*/ + bool anyOtherExoMechPassive = exoPrimePassive || exoSpazPassive || exoRetPassive; + + // Phases + bool lessThan70PercentLife = lifeRatio < 0.7f; + bool phase2 = lessThan70PercentLife && otherExoMechsAlive <= 1; + bool berserk = lifeRatio < 0.4f || totalOtherExoMechLifeRatio > 3f; + + // Set vulnerable to false by default + vulnerable = false; + + // If Thanatos doesn't go berserk + bool otherMechIsBerserk = exoPrimeLifeRatio < 0.4f || exoSpazLifeRatio < 0.4f || exoRetLifeRatio < 0.4f; + + // 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]; + + 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; + } + } + + // Despawn if target is dead + if (player.dead) + { + npc.TargetClosest(false); + + npc.velocity.Y += 2f; + if (npc.position.Y > Main.worldSurface * 16.0) + npc.velocity.Y += 2f; + + 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 + // 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 + // Fly underneath the target and fire barrages of lasers + // 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 + // Go passive and fly underneath the target while firing lasers + // 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 + // Phase 7 - 0, 1, 0, 2 + + // Phase gate values + float velocityAdjustTime = 20f; + float speedUpTime = 480f; + float slowDownTime = 120f; + float chargePhaseGateValue = speedUpTime + slowDownTime; + + float laserBarrageDuration = 420f; + + // 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; + } + + // 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; + + // Charge variables + float turnDistance = baseTurnDistance; + float chargeLocationDistance = turnDistance * 0.2f; + + // Laser Barrage variables + Vector2 laserBarrageLocation = new Vector2(0f, baseDistance); + float laserBarrageLocationDistance = turnDistance * 5f; + + // Velocity and turn speed values + float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; + float baseVelocity = 7f * baseVelocityMult; + float turnDegrees = baseVelocity * 0.11f; + if (berserk) + { + baseVelocity *= 1.2f; + turnDegrees *= 1.2f; + } + 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(1f, 4f, chargeVelocityScalar); + float deathrayTurnSpeedMult = MathHelper.Lerp(1f, 4f, 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 = 0.01f; + float laserBarrageVelocityScalarDecrement = 1f / velocityAdjustTime; + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); + + // Passive and Immune phases + switch ((int)SecondaryAIState) + { + case (int)SecondaryPhase.Nothing: + + // Spawn the other mechs if Thanatos is first + if (otherExoMechsAlive == 0) + { + if (phase2 && !berserk) + { + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Spawn code here + } + } + } + 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 || lessThan70PercentLife) && !berserk && totalOtherExoMechLifeRatio < 5f) + { + // Tells Thanatos to return to the battle in passive state + SecondaryAIState = (float)SecondaryPhase.Passive; + } + + // Go passive and immune if one of the other mechs is berserk + // This is only called if two exo mechs are alive + if (otherMechIsBerserk) + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + } + + break; + + // Fly underneath target and fire lasers + 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) + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + + // If Thanatos is the first mech to go berserk + if (berserk) + { + // Reset + AIState = (float)Phase.Charge; + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + } + + break; + + // Fly underneath target and become immune + case (int)SecondaryPhase.PassiveAndImmune: + + // Fire lasers while passive + AIState = (float)Phase.UndergroundLaserBarrage; + + // Enter the fight again if any of the other exo mechs is below 70% and the other mechs aren't berserk + if ((exoPrimeLifeRatio < 0.7f || exoSpazLifeRatio < 0.7f || exoRetLifeRatio < 0.7f) && !otherMechIsBerserk) + { + // Tells Thanatos to return to the battle in passive state + // Return to normal phases if one or more mechs have been downed + SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; + } + + if (berserk) + { + // Reset + AIState = (float)Phase.Charge; + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + } + + break; + } + + // 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 + if (distanceFromTarget < 320f) + turnSpeed *= distanceFromTarget / 320f; + + 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.localAI[0] = /*berserk ? 1f : 0f*/ 1f; + 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 + bool readyToFireDeathray = distanceFromTarget < 800f; + 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) + { + baseVelocity *= distanceFromTarget / 800f; + turnSpeed *= distanceFromTarget / 800f; + + if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) + { + // Fire deathray telegraph beams + if (calamityGlobalNPC.newAI[2] == 0f) + { + 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); + int laser = Projectile.NewProjectile(npc.Center, Vector2.Zero, type, damage, 0f, 255, npc.whoAmI); + if (Main.projectile.IndexInRange(laser)) + Main.projectile[laser].ai[0] = 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(); + } + calamityGlobalNPC.newAI[2] += 1f; + } + + break; + } + + 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; + + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Noise + if (npc.localAI[1] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); + + // Steam + float maxSteamTime = 180f; + npc.localAI[1] += 1f; + if (npc.localAI[1] < maxSteamTime) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = 3; + } + } + else + npc.localAI[1] = 0f; + + SmokeDrawer.Update(); + + // 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; + + // Reduce Y velocity if it's less than 1 + if (Math.Abs(npc.velocity.Y) < 1f) + npc.velocity.Y -= 0.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 <= 50f && npc.Opacity == 1f; + } + + 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 !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + } + + 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 >= 12D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + else + { + if (npc.frameCounter >= 12D) + { + 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); + + return false; + } + + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } + + public override void NPCLoot() + { + /*DropHelper.DropItem(npc, ModContent.ItemType(), 80, 100); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 1, 50, 108); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 2, 15, 27); + DropHelper.DropItemCondition(npc, ItemID.Ectoplasm, NPC.downedPlantBoss, 1, 21, 32);*/ + } + + 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/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 override void OnHitPlayer(Player player, int damage, bool crit) + { + if (npc.Opacity == 1f) + { + int duration = vulnerable ? 180 : 90; + player.AddBuff(BuffID.Ichor, duration); + player.AddBuff(BuffID.CursedInferno, duration); + player.AddBuff(ModContent.BuffType(), duration / 4); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(BuffID.Frostburn, duration); + player.AddBuff(BuffID.OnFire, duration); + } + } + } +} diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.png b/NPCs/ExoMechs/Thanatos/ThanatosHead.png new file mode 100644 index 0000000000..1cdc250fc9 Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosHead.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow.png b/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow.png new file mode 100644 index 0000000000..b4a0e95b3b Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs new file mode 100644 index 0000000000..2f718d7be1 --- /dev/null +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -0,0 +1,539 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Events; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Thanatos +{ + public class ThanatosTail : ModNPC + { + // 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, 4, 0f, 16f, 1.5f); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XM-05 Thanatos"); + Main.npcFrameCount[npc.type] = 5; + } + + public override void SetDefaults() + { + 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(1000000, 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.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.dontCountMe = true; + npc.chaseable = false; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + writer.Write(vulnerable); + writer.Write(npc.localAI[0]); + writer.Write(npc.localAI[1]); + 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(); + vulnerable = reader.ReadBoolean(); + npc.localAI[0] = reader.ReadSingle(); + npc.localAI[1] = 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 void AI() + { + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // 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; + } + if (!shouldDespawn) + { + if (npc.ai[1] > 0f) + shouldDespawn = false; + else if (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; + } + + // 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 = invisiblePhase; + if (!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; + } + + // Set timer to whoAmI so that segments don't all fire lasers at the same time + if (npc.localAI[2] == 0f) + npc.localAI[2] = npc.ai[0]; + + bool shootTrackingLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + if (shootTrackingLasers) + { + 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; + + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + { + float divisor = 120f; + int numSegments = ThanatosHead.minLength; + double numSegmentsAbleToFire = malice ? 25D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + if ((npc.ai[3] % divisor == 0f && npc.localAI[2] % 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] >= 72f) + { + 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; + } + } + + 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] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + else + { + npc.ai[3] += 1f; + float shootProjectile = 120f; + float timer = npc.ai[0] + 15f; + float divisor = timer + shootProjectile; + if (npc.ai[3] % divisor == 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] >= 72f) + { + 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 ? 40f : death ? 25f : revenge ? 20f : expertMode ? 15f : 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 + { + // 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] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + } + } + } + } + } + else + { + // Set alternating laser-firing body segments every 3 seconds + npc.localAI[1] += 1f; + if (npc.localAI[1] >= 180f) + { + npc.localAI[1] = 0f; + npc.localAI[2] += 1f; + } + + npc.Calamity().newAI[0] -= 1f; + if (npc.Calamity().newAI[0] <= 0f) + { + npc.Calamity().newAI[0] = 0f; + npc.Calamity().newAI[1] = 0f; + } + else + { + // Body is vulnerable while venting + vulnerable = true; + } + } + + 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; + + // Vent noise and steam + SmokeDrawer.ParticleSpawnRate = 9999999; + if (vulnerable) + { + // Noise + float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.25f : 1f; + if (npc.localAI[0] == 0f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent").WithVolume(volume), npc.Center); + + // Steam + float maxSteamTime = 180f; + npc.localAI[0] += 1f; + if (npc.localAI[0] < maxSteamTime) + { + SmokeDrawer.BaseMoveRotation = npc.rotation - MathHelper.PiOver2; + SmokeDrawer.ParticleSpawnRate = 3; + } + } + else + npc.localAI[0] = 0f; + + SmokeDrawer.Update(); + + 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)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)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; + } + } + + 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; + } + + 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 !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + } + + public override void FindFrame(int frameHeight) // 5 total frames + { + // Swap between venting and non-venting frames + CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); + bool shootTrackingLasers = (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 (shootTrackingLasers) + { + if (npc.Calamity().newAI[1] == 0f && npc.Calamity().newAI[0] > 0f) + { + if (npc.frameCounter >= 12D) + { + 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 >= 12D) + { + npc.frame.Y -= frameHeight; + npc.frameCounter = 0D; + } + if (npc.frame.Y < 0) + npc.frame.Y = 0; + } + } + else + { + if (npc.frameCounter >= 12D) + { + 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) + { + 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()); + } + + public override void OnHitPlayer(Player player, int damage, bool crit) + { + if (npc.Opacity == 1f) + { + int duration = vulnerable ? 60 : 30; + player.AddBuff(BuffID.Ichor, duration); + player.AddBuff(BuffID.CursedInferno, duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(ModContent.BuffType(), duration); + player.AddBuff(BuffID.Frostburn, duration); + player.AddBuff(BuffID.OnFire, duration); + } + } + } +} diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.png b/NPCs/ExoMechs/Thanatos/ThanatosTail.png new file mode 100644 index 0000000000..22edba05fd Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosTail.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTailGlow.png b/NPCs/ExoMechs/Thanatos/ThanatosTailGlow.png new file mode 100644 index 0000000000..54a5e2ecaf Binary files /dev/null and b/NPCs/ExoMechs/Thanatos/ThanatosTailGlow.png differ diff --git a/NPCs/HiveMind/DankCreeper.cs b/NPCs/HiveMind/DankCreeper.cs index 20ff3dce30..55a0ac975d 100644 --- a/NPCs/HiveMind/DankCreeper.cs +++ b/NPCs/HiveMind/DankCreeper.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.HiveMind npc.lifeMax = 90; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 20000; + npc.lifeMax = 2000; } npc.aiStyle = -1; aiType = -1; diff --git a/NPCs/HiveMind/DarkHeart.cs b/NPCs/HiveMind/DarkHeart.cs index 0c1eea2ef9..2e67ef38cb 100644 --- a/NPCs/HiveMind/DarkHeart.cs +++ b/NPCs/HiveMind/DarkHeart.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.HiveMind npc.lifeMax = 150; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 18000; + npc.lifeMax = 1800; } npc.aiStyle = -1; aiType = -1; @@ -120,11 +120,6 @@ namespace CalamityMod.NPCs.HiveMind } } - public override bool PreNPCLoot() - { - return false; - } - 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 d81b83f356..e42c56c57d 100644 --- a/NPCs/HiveMind/HiveBlob.cs +++ b/NPCs/HiveMind/HiveBlob.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.HiveMind npc.lifeMax = 100; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 13000; + npc.lifeMax = 1300; } npc.knockBackResist = 0f; aiType = -1; diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs index 01a0f444f7..00f8794dc3 100644 --- a/NPCs/HiveMind/HiveBlob2.cs +++ b/NPCs/HiveMind/HiveBlob2.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.HiveMind npc.lifeMax = 150; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 13000; + npc.lifeMax = 1300; } npc.knockBackResist = 0f; aiType = -1; diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index a98ad39595..fc52dfc390 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.HiveMind npc.width = 150; npc.height = 120; npc.defense = 10; - npc.LifeMaxNERB(1200, 1800, 350000); + npc.LifeMaxNERB(1200, 1800, 35000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -109,20 +109,25 @@ namespace CalamityMod.NPCs.HiveMind npc.noGravity = false; npc.noTileCollide = false; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; CalamityGlobalNPC.hiveMind = npc.whoAmI; float enrageScale = 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - enrageScale += 1f; - if (!player.ZoneCorrupt || malice) - enrageScale += 1f; - + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (!player.ZoneCorrupt || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -137,23 +142,18 @@ namespace CalamityMod.NPCs.HiveMind } } - bool flag100 = false; - int num568 = 0; if (expertMode) { - for (int num569 = 0; num569 < Main.maxNPCs; num569++) - { - if (Main.npc[num569].active && Main.npc[num569].type == ModContent.NPCType()) - { - flag100 = true; - num568++; - } - } - - npc.defense += num568 * 25; - - if (!flag100) - npc.defense = npc.defDefense; + if (NPC.AnyNPCs(ModContent.NPCType())) + { + npc.Calamity().DR = 0.9999f; + npc.Calamity().unbreakableDR = true; + } + else + { + npc.Calamity().DR = 0f; + npc.Calamity().unbreakableDR = false; + } } if (npc.ai[3] == 0f && npc.life > 0) @@ -175,7 +175,7 @@ namespace CalamityMod.NPCs.HiveMind 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 || npc.Calamity().enraged > 0) + if (NPC.CountNPCS(ModContent.NPCType()) < maxDankSpawns) { type = ModContent.NPCType(); } @@ -194,7 +194,7 @@ namespace CalamityMod.NPCs.HiveMind burrowTimer--; if (burrowTimer < -120) { - burrowTimer = (death ? 180 : revenge ? 300 : expertMode ? 360 : 420) - (int)enrageScale * 60; + burrowTimer = (death ? 180 : revenge ? 300 : expertMode ? 360 : 420) - (int)enrageScale * 55; npc.scale = 1f; npc.alpha = 0; npc.dontTakeDamage = false; diff --git a/NPCs/HiveMind/HiveMindP2.cs b/NPCs/HiveMind/HiveMindP2.cs index 8d45da909f..fc85ac2df0 100644 --- a/NPCs/HiveMind/HiveMindP2.cs +++ b/NPCs/HiveMind/HiveMindP2.cs @@ -75,7 +75,7 @@ namespace CalamityMod.NPCs.HiveMind npc.width = 177; npc.height = 142; npc.defense = 5; - npc.LifeMaxNERB(5800, 7560, 3000000); + npc.LifeMaxNERB(5800, 7560, 300000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -123,14 +123,6 @@ namespace CalamityMod.NPCs.HiveMind driftSpeed = 6f; driftBoost = 1f; } - if (BossRushEvent.BossRushActive) - { - lungeRots = 0.4; - minimumDriftTime = 20; - reelbackFade = 15; - lungeTime = 10; - driftSpeed = 12f; - } phase2timer = minimumDriftTime; rotationIncrement = 0.0246399424 * lungeRots * lungeFade; } @@ -323,16 +315,27 @@ namespace CalamityMod.NPCs.HiveMind if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - bool malice = CalamityWorld.malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; float enrageScale = 0f; - if ((npc.position.Y / 16f) < Main.worldSurface || malice) - enrageScale += 1f; - if (!player.ZoneCorrupt || malice) - enrageScale += 1f; - + if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } + if (!player.ZoneCorrupt || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } if (npc.alpha != 0) { @@ -350,9 +353,9 @@ namespace CalamityMod.NPCs.HiveMind if (nextState == 0) { npc.TargetClosest(); - if ((CalamityWorld.revenge || BossRushEvent.BossRushActive || malice) && lifeRatio < 0.66f) + if ((CalamityWorld.revenge || malice) && lifeRatio < 0.66f) { - if (CalamityWorld.death || BossRushEvent.BossRushActive || malice) + if (CalamityWorld.death || malice) { do nextState = Main.rand.Next(3, 6); @@ -376,7 +379,7 @@ namespace CalamityMod.NPCs.HiveMind } else { - if ((CalamityWorld.revenge || BossRushEvent.BossRushActive || malice) && (Main.rand.NextBool(3) || reelCount == 2)) + if ((CalamityWorld.revenge || malice) && (Main.rand.NextBool(3) || reelCount == 2)) { reelCount = 0; nextState = 2; @@ -446,7 +449,7 @@ namespace CalamityMod.NPCs.HiveMind else { npc.velocity.Normalize(); - if (Main.expertMode || BossRushEvent.BossRushActive || malice) //variable velocity in expert and up + if (Main.expertMode || malice) //variable velocity in expert and up { npc.velocity *= driftSpeed + enrageScale + driftBoost * lifeRatio; } @@ -496,7 +499,7 @@ namespace CalamityMod.NPCs.HiveMind npc.alpha = 255; npc.velocity = Vector2.Zero; dashStarted = false; - if ((CalamityWorld.revenge || BossRushEvent.BossRushActive || malice) && lifeRatio < 0.66f) + if ((CalamityWorld.revenge || malice) && lifeRatio < 0.66f) { state = nextState; nextState = 0; @@ -593,7 +596,7 @@ namespace CalamityMod.NPCs.HiveMind { if (npc.ai[0] == 2 || npc.ai[0] == 4) { - if ((Main.expertMode || BossRushEvent.BossRushActive || malice) && !NPC.AnyNPCs(ModContent.NPCType())) + if ((Main.expertMode || malice) && !NPC.AnyNPCs(ModContent.NPCType())) { NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, ModContent.NPCType()); } diff --git a/NPCs/Leviathan/AquaticAberration.cs b/NPCs/Leviathan/AquaticAberration.cs index e5e2ba6e5d..b706b04af9 100644 --- a/NPCs/Leviathan/AquaticAberration.cs +++ b/NPCs/Leviathan/AquaticAberration.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.Leviathan npc.lifeMax = 1600; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 100000; + npc.lifeMax = 10000; } npc.knockBackResist = 0f; npc.noGravity = true; diff --git a/NPCs/Leviathan/Leviathan.cs b/NPCs/Leviathan/Leviathan.cs index efd333eb20..19ffe9175f 100644 --- a/NPCs/Leviathan/Leviathan.cs +++ b/NPCs/Leviathan/Leviathan.cs @@ -1,4 +1,6 @@ -using CalamityMod.Events; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; @@ -46,7 +48,7 @@ namespace CalamityMod.NPCs.Leviathan npc.height = 450; npc.defense = 40; npc.DR_NERD(0.35f); - npc.LifeMaxNERB(55200, 72560, 6000000); + npc.LifeMaxNERB(55200, 72560, 600000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -84,10 +86,11 @@ namespace CalamityMod.NPCs.Leviathan CalamityGlobalNPC.leviathan = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; Vector2 vector = npc.Center; // Is in spawning animation @@ -153,15 +156,36 @@ namespace CalamityMod.NPCs.Leviathan bool notOcean = player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); float enrageScale = 0f; - if (notOcean || malice) - enrageScale += 2f; - + if (notOcean || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 2f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } npc.dontTakeDamage = spawnAnimation; - if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) + // 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[ModContent.BuffType()] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; + npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + + if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) { npc.TargetClosest(false); player = Main.player[npc.target]; @@ -231,12 +255,6 @@ namespace CalamityMod.NPCs.Leviathan num413 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); } - if (BossRushEvent.BossRushActive) - { - num412 *= 1.5f; - num413 *= 1.5f; - } - int num414 = 1; if (vector.X < player.position.X + player.width) num414 = -1; @@ -319,15 +337,9 @@ namespace CalamityMod.NPCs.Leviathan speed += 2f * enrageScale; - if (npc.Calamity().enraged > 0) - speed = 22f; - if (!sirenAlive || phase4) speed += 3f * (1f - lifeRatio); - if (BossRushEvent.BossRushActive) - speed *= 1.5f; - num417 = (float)Math.Sqrt(num415 * num415 + num416 * num416); num417 = speed / num417; num415 *= num417; @@ -400,12 +412,6 @@ namespace CalamityMod.NPCs.Leviathan num1064 += death ? 0.05f * (1f - lifeRatio) : 0.03f * (1f - lifeRatio); } - if (BossRushEvent.BossRushActive) - { - num1063 *= 1.5f; - num1064 *= 1.5f; - } - vector120 = vector119; num1058 = player.Center.X - vector120.X; num1059 = player.Center.Y - vector120.Y; @@ -497,12 +503,6 @@ namespace CalamityMod.NPCs.Leviathan if (revenge && (!sirenAlive || phase4)) num1044 += death ? 9f * (1f - lifeRatio) : 6f * (1f - lifeRatio); - if (npc.Calamity().enraged > 0) - num1044 += 4f; - - if (BossRushEvent.BossRushActive) - num1044 *= 1.25f; - Vector2 vector117 = vector; float num1045 = player.Center.X - vector117.X; float num1046 = player.Center.Y - vector117.Y; @@ -531,18 +531,6 @@ namespace CalamityMod.NPCs.Leviathan num1049 += death ? 0.15f * (1f - lifeRatio) : 0.1f * (1f - lifeRatio); } - if (npc.Calamity().enraged > 0) - { - num1048 += 3f; - num1049 += 0.2f; - } - - if (BossRushEvent.BossRushActive) - { - num1048 *= 1.25f; - num1049 *= 1.25f; - } - if (vector.Y < player.Center.Y) npc.velocity.Y += num1049; else diff --git a/NPCs/Leviathan/LeviathanStart.cs b/NPCs/Leviathan/LeviathanStart.cs index 7ff862c89c..c0bc063028 100644 --- a/NPCs/Leviathan/LeviathanStart.cs +++ b/NPCs/Leviathan/LeviathanStart.cs @@ -92,7 +92,7 @@ namespace CalamityMod.NPCs.Leviathan 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Leviathan/Parasea.cs b/NPCs/Leviathan/Parasea.cs index fa9d7bb70a..ed5662c6a6 100644 --- a/NPCs/Leviathan/Parasea.cs +++ b/NPCs/Leviathan/Parasea.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.Leviathan npc.lifeMax = 650; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 50000; + npc.lifeMax = 5000; } npc.knockBackResist = 0f; npc.HitSound = SoundID.NPCHit1; diff --git a/NPCs/Leviathan/Siren.cs b/NPCs/Leviathan/Siren.cs index b4d0b63279..2b69aa12f4 100644 --- a/NPCs/Leviathan/Siren.cs +++ b/NPCs/Leviathan/Siren.cs @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.Leviathan npc.height = 100; npc.defense = 20; npc.DR_NERD(0.2f); - npc.LifeMaxNERB(27400, 41600, 2600000); + npc.LifeMaxNERB(27400, 41600, 260000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -105,18 +105,26 @@ namespace CalamityMod.NPCs.Leviathan // Variables Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; bool notOcean = player.position.Y < 800f || player.position.Y > Main.worldSurface * 16.0 || (player.position.X > 6400f && player.position.X < (Main.maxTilesX * 16 - 6400)); float enrageScale = 0f; if (notOcean || malice) - enrageScale += 2f; - + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1.5f; + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 0.5f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 0.5f; + } float lifeRatio = npc.life / (float)npc.lifeMax; @@ -124,7 +132,7 @@ namespace CalamityMod.NPCs.Leviathan if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - float bubbleVelocity = BossRushEvent.BossRushActive ? 16f : death ? 9f : revenge ? 7f : expertMode ? 6f : 5f; + float bubbleVelocity = death ? 9f : revenge ? 7f : expertMode ? 6f : 5f; bubbleVelocity += 4f * enrageScale; if (!leviAlive) bubbleVelocity += 2f * (1f - lifeRatio); @@ -363,7 +371,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > maxVelocityY) npc.velocity.Y = maxVelocityY; } @@ -371,7 +379,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -maxVelocityY) npc.velocity.Y = -maxVelocityY; } @@ -380,7 +388,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X -= death ? 0.12f : 0.1f; if (npc.velocity.X > maxVelocityX) npc.velocity.X = maxVelocityX; } @@ -389,7 +397,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X += death ? 0.12f : 0.1f; if (npc.velocity.X < -maxVelocityX) npc.velocity.X = -maxVelocityX; } @@ -452,7 +460,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > maxVelocityY) npc.velocity.Y = maxVelocityY; } @@ -460,7 +468,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.98f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -maxVelocityY) npc.velocity.Y = -maxVelocityY; } @@ -469,7 +477,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X -= death ? 0.12f : 0.1f; if (npc.velocity.X > maxVelocityX) npc.velocity.X = maxVelocityX; } @@ -478,7 +486,7 @@ namespace CalamityMod.NPCs.Leviathan { if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X += death ? 0.12f : 0.1f; if (npc.velocity.X < -maxVelocityX) npc.velocity.X = -maxVelocityX; } @@ -504,10 +512,10 @@ namespace CalamityMod.NPCs.Leviathan npc.rotation = npc.velocity.X * 0.02f; Vector2 targetVector = player.Center + new Vector2(0f, -350f); - float velocity = BossRushEvent.BossRushActive ? 18f : death ? 13.5f : 12f; + float velocity = death ? 13.5f : 12f; velocity += 6f * enrageScale; Vector2 vector3 = Vector2.Normalize(targetVector - vector - npc.velocity) * velocity; - float acceleration = BossRushEvent.BossRushActive ? 0.5f : death ? 0.28f : 0.25f; + 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) @@ -574,7 +582,7 @@ namespace CalamityMod.NPCs.Leviathan } float phaseTimer = 300f; - phaseTimer -= 60f * enrageScale; + phaseTimer -= 50f * enrageScale; if (!leviAlive || phase4) phaseTimer -= 150f * (1f - lifeRatio); @@ -602,7 +610,7 @@ namespace CalamityMod.NPCs.Leviathan npc.localAI[0] = 0f; // Velocity and rotation - float chargeVelocity = BossRushEvent.BossRushActive ? 31f : (leviAlive && !phase4) ? 21f : 26f; + float chargeVelocity = (leviAlive && !phase4) ? 21f : 26f; chargeVelocity += 8f * enrageScale; if (revenge) @@ -684,7 +692,7 @@ namespace CalamityMod.NPCs.Leviathan npc.localAI[0] = (int)distance * Math.Sign((vector - player.Center).X); Vector2 vector3 = Vector2.Normalize(player.Center + new Vector2(npc.localAI[0], -distance) - vector - npc.velocity) * 12f; - float acceleration = BossRushEvent.BossRushActive ? 1f : revenge ? 0.75f : 0.5f; + float acceleration = revenge ? 0.75f : 0.5f; npc.SimpleFlyMovement(vector3, acceleration); // Rotation diff --git a/NPCs/Leviathan/SirenIce.cs b/NPCs/Leviathan/SirenIce.cs index caf70c5158..dd5b0b8f13 100644 --- a/NPCs/Leviathan/SirenIce.cs +++ b/NPCs/Leviathan/SirenIce.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.Leviathan npc.lifeMax = 650; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 10000; + npc.lifeMax = 1000; } npc.alpha = 255; npc.HitSound = SoundID.NPCHit5; @@ -113,7 +113,9 @@ namespace CalamityMod.NPCs.Leviathan player.AddBuff(BuffID.Frostburn, 240, true); } - public override void HitEffect(int hitDirection, double damage) + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) { diff --git a/NPCs/NormalNPCs/Cnidrion.cs b/NPCs/NormalNPCs/Cnidrion.cs index a1b798e7cc..1493e67304 100644 --- a/NPCs/NormalNPCs/Cnidrion.cs +++ b/NPCs/NormalNPCs/Cnidrion.cs @@ -300,6 +300,7 @@ namespace CalamityMod.NPCs.NormalNPCs DropHelper.DropItem(npc, ItemID.Starfish, 1, 3); DropHelper.DropItem(npc, ItemID.Seashell, 1, 3); DropHelper.DropItem(npc, ModContent.ItemType(), 1, 3); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); } } } diff --git a/NPCs/NormalNPCs/Eidolist.cs b/NPCs/NormalNPCs/Eidolist.cs index 907b26f985..922081c5e2 100644 --- a/NPCs/NormalNPCs/Eidolist.cs +++ b/NPCs/NormalNPCs/Eidolist.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.SummonItems; +using CalamityMod.NPCs.Abyss; using CalamityMod.World; using Microsoft.Xna.Framework; using System; @@ -8,6 +9,7 @@ using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.NormalNPCs { public class Eidolist : ModNPC @@ -30,7 +32,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.lifeMax = 10000; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 1, 0, 0); - npc.alpha = 50; + npc.Opacity = 0f; npc.noGravity = true; npc.noTileCollide = false; npc.HitSound = SoundID.NPCHit13; @@ -54,8 +56,19 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0f, 0.4f, 0.5f); - if (npc.justHit) + 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; + + Lighting.AddLight((int)(npc.Center.X / 16f), (int)(npc.Center.Y / 16f), 0f, 0.4f, 0.5f); + if (npc.justHit || adultWyrmAlive) { hasBeenHit = true; } @@ -112,7 +125,7 @@ namespace CalamityMod.NPCs.NormalNPCs return; } npc.noTileCollide = true; - float num1446 = 7f; + float num1446 = adultWyrmAlive ? 14f : 7f; float num1447 = 480f; if (npc.localAI[1] == 1f) { @@ -129,12 +142,13 @@ namespace CalamityMod.NPCs.NormalNPCs Vector2 vector251 = Main.player[npc.target].Center - value53; bool flag104 = Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1); npc.localAI[0] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 300f) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= Main.rand.Next(90, 601)) { - npc.localAI[0] = 0f; + npc.localAI[0] = -90f; + 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 = 5f; + float speed = adultWyrmAlive ? 10f : 5f; Vector2 vector = new Vector2(npc.Center.X, npc.Center.Y); float xDist = Main.player[npc.target].Center.X - vector.X + Main.rand.NextFloat(-10f, 10f); float yDist = Main.player[npc.target].Center.Y - vector.Y + Main.rand.NextFloat(-10f, 10f); @@ -143,7 +157,7 @@ namespace CalamityMod.NPCs.NormalNPCs targetDist = speed / targetDist; targetVec.X *= targetDist; targetVec.Y *= targetDist; - int damage = Main.expertMode ? 30 : 40; + int damage = adultWyrmAlive ? (Main.expertMode ? 150 : 200) : (Main.expertMode ? 30 : 40); if (Main.rand.NextBool(2)) { Projectile.NewProjectile(npc.Center, targetVec, ProjectileID.CultistBossLightningOrb, damage, 0f, Main.myPlayer, 0f, 0f); diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewel.cs index 8e3e2e5353..d9178a2d56 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel.cs @@ -49,8 +49,8 @@ namespace CalamityMod.NPCs.NormalNPCs npc.TargetClosest(true); - float velocity = BossRushEvent.BossRushActive ? 8f : 2f; - float acceleration = BossRushEvent.BossRushActive ? 0.4f : 0.1f; + float velocity = 2f; + float acceleration = 0.1f; if (npc.position.Y > Main.player[npc.target].position.Y - 350f) { @@ -98,7 +98,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.netMode != NetmodeID.MultiplayerClient) { // Fire bolt every 1.5 seconds - npc.localAI[0] += BossRushEvent.BossRushActive ? 2f : 1f; + npc.localAI[0] += 1f; if (npc.localAI[0] >= (CalamityWorld.malice ? 45f : CalamityWorld.death ? 60f : 75f)) { npc.localAI[0] = 0f; @@ -109,7 +109,7 @@ namespace CalamityMod.NPCs.NormalNPCs Vector2 projVector = new Vector2(xDist, yDist); float projLength = projVector.Length(); - float speed = BossRushEvent.BossRushActive ? 18f : 9f; + float speed = 9f; int type = ModContent.ProjectileType(); projLength = speed / projLength; diff --git a/NPCs/NormalNPCs/Pitbull.cs b/NPCs/NormalNPCs/Pitbull.cs index e5bf0f5e77..b23b78abea 100644 --- a/NPCs/NormalNPCs/Pitbull.cs +++ b/NPCs/NormalNPCs/Pitbull.cs @@ -1,3 +1,4 @@ +using CalamityMod.Items.Accessories; using CalamityMod.Items.Placeables.Banners; using CalamityMod.World; using Terraria; @@ -64,6 +65,7 @@ namespace CalamityMod.NPCs.NormalNPCs { float bandageDropRate = Main.expertMode ? 0.02f : 0.01f; DropHelper.DropItemChance(npc, ItemID.AdhesiveBandage, bandageDropRate); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 8); } } } diff --git a/NPCs/OldDuke/OldDuke.cs b/NPCs/OldDuke/OldDuke.cs index 920d219989..18fc5484d2 100644 --- a/NPCs/OldDuke/OldDuke.cs +++ b/NPCs/OldDuke/OldDuke.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.OldDuke npc.GetNPCDamage(); npc.defense = 90; npc.DR_NERD(0.5f, null, null, null, true); - npc.LifeMaxNERB(412500, 495000, 4000000); + npc.LifeMaxNERB(412500, 495000, 400000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -232,7 +232,7 @@ namespace CalamityMod.NPCs.OldDuke 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, 4f + npc.gfxOffY); + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -285,7 +285,7 @@ namespace CalamityMod.NPCs.OldDuke 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, 4f + npc.gfxOffY); + vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector42, npc.frame, color39, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -295,7 +295,7 @@ namespace CalamityMod.NPCs.OldDuke 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, 4f + npc.gfxOffY); + 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) @@ -340,7 +340,7 @@ namespace CalamityMod.NPCs.OldDuke 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } @@ -352,7 +352,7 @@ namespace CalamityMod.NPCs.OldDuke 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, 4f + npc.gfxOffY); + vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/OldDuke/OldDukeSharkron.cs b/NPCs/OldDuke/OldDukeSharkron.cs index 2e5a0ec6cc..12988856b5 100644 --- a/NPCs/OldDuke/OldDukeSharkron.cs +++ b/NPCs/OldDuke/OldDukeSharkron.cs @@ -33,7 +33,7 @@ namespace CalamityMod.NPCs.OldDuke npc.lifeMax = 6000; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 100000; + npc.lifeMax = 10000; } npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; @@ -183,14 +183,14 @@ namespace CalamityMod.NPCs.OldDuke 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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; diff --git a/NPCs/OldDuke/OldDukeToothBall.cs b/NPCs/OldDuke/OldDukeToothBall.cs index e9e3c84701..82f0f46799 100644 --- a/NPCs/OldDuke/OldDukeToothBall.cs +++ b/NPCs/OldDuke/OldDukeToothBall.cs @@ -32,7 +32,7 @@ namespace CalamityMod.NPCs.OldDuke npc.lifeMax = 3750; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 75000; + npc.lifeMax = 7500; } npc.alpha = 255; npc.knockBackResist = 0f; diff --git a/NPCs/Perforator/PerforatorBodyLarge.cs b/NPCs/Perforator/PerforatorBodyLarge.cs index 4f58dd4496..4d31e22e11 100644 --- a/NPCs/Perforator/PerforatorBodyLarge.cs +++ b/NPCs/Perforator/PerforatorBodyLarge.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 60; npc.height = 60; npc.defense = 8; - npc.LifeMaxNERB(2500, 2700, 800000); + npc.LifeMaxNERB(2500, 2700, 80000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -92,7 +92,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorBodyMedium.cs b/NPCs/Perforator/PerforatorBodyMedium.cs index 5bc4bb82ce..d581177a2d 100644 --- a/NPCs/Perforator/PerforatorBodyMedium.cs +++ b/NPCs/Perforator/PerforatorBodyMedium.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 40; npc.height = 40; npc.defense = 6; - npc.LifeMaxNERB(160, 180, 70000); + npc.LifeMaxNERB(160, 180, 7000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -171,7 +171,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorBodySmall.cs b/NPCs/Perforator/PerforatorBodySmall.cs index f8ee8a69da..6bb0b5b173 100644 --- a/NPCs/Perforator/PerforatorBodySmall.cs +++ b/NPCs/Perforator/PerforatorBodySmall.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 42; npc.height = 42; npc.defense = 4; - npc.LifeMaxNERB(1250, 1500, 500000); + npc.LifeMaxNERB(1250, 1500, 50000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -92,7 +92,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorCyst.cs b/NPCs/Perforator/PerforatorCyst.cs index 36052600a3..a39976d752 100644 --- a/NPCs/Perforator/PerforatorCyst.cs +++ b/NPCs/Perforator/PerforatorCyst.cs @@ -50,7 +50,7 @@ namespace CalamityMod.NPCs.Perforator Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index b733129d6c..f99789bd6f 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -31,7 +31,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 70; npc.height = 84; npc.defense = 4; - npc.LifeMaxNERB(2500, 2700, 800000); + npc.LifeMaxNERB(2500, 2700, 80000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -69,19 +69,21 @@ namespace CalamityMod.NPCs.Perforator { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float enrageScale = 0f; if ((npc.position.Y / 16f) < Main.worldSurface || malice) enrageScale += 1f; if (!Main.player[npc.target].ZoneCrimson || malice) enrageScale += 1f; - if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + enrageScale += 1f; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -116,18 +118,6 @@ namespace CalamityMod.NPCs.Perforator turnSpeed *= 1.25f; } - if (npc.Calamity().enraged > 0) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - - if (BossRushEvent.BossRushActive) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - if (npc.ai[3] > 0f) { npc.realLife = (int)npc.ai[3]; @@ -512,7 +502,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorHeadMedium.cs b/NPCs/Perforator/PerforatorHeadMedium.cs index dd41884c5b..74a3e72e3a 100644 --- a/NPCs/Perforator/PerforatorHeadMedium.cs +++ b/NPCs/Perforator/PerforatorHeadMedium.cs @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 58; npc.height = 68; npc.defense = 2; - npc.LifeMaxNERB(160, 180, 70000); + npc.LifeMaxNERB(160, 180, 7000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -53,19 +53,21 @@ namespace CalamityMod.NPCs.Perforator { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float enrageScale = 0f; if ((npc.position.Y / 16f) < Main.worldSurface || malice) enrageScale += 1f; if (!Main.player[npc.target].ZoneCrimson || malice) enrageScale += 1f; - if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + enrageScale += 1f; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -85,18 +87,6 @@ namespace CalamityMod.NPCs.Perforator turnSpeed += accelerationScale * (1f - lifeRatio); } - if (npc.Calamity().enraged > 0) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - - if (BossRushEvent.BossRushActive) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - npc.realLife = -1; // Get a target @@ -250,7 +240,7 @@ namespace CalamityMod.NPCs.Perforator npc.Calamity().newAI[1] += 1f; // Set velocity for when a new head spawns - npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (num37 * (BossRushEvent.BossRushActive ? 0.6f : death ? 0.3f : 0.2f)); + npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (num37 * (death ? 0.3f : 0.2f)); } if (!flag2) @@ -393,7 +383,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorHeadSmall.cs b/NPCs/Perforator/PerforatorHeadSmall.cs index b967ee24a1..9b8705e5c8 100644 --- a/NPCs/Perforator/PerforatorHeadSmall.cs +++ b/NPCs/Perforator/PerforatorHeadSmall.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.Perforator npc.npcSlots = 5f; npc.width = 42; npc.height = 62; - npc.LifeMaxNERB(1250, 1500, 500000); + npc.LifeMaxNERB(1250, 1500, 50000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -55,19 +55,21 @@ namespace CalamityMod.NPCs.Perforator { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float enrageScale = 0f; if ((npc.position.Y / 16f) < Main.worldSurface || malice) enrageScale += 1f; if (!Main.player[npc.target].ZoneCrimson || malice) enrageScale += 1f; - if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + enrageScale += 1f; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -87,18 +89,6 @@ namespace CalamityMod.NPCs.Perforator turnSpeed += accelerationScale * (1f - lifeRatio); } - if (npc.Calamity().enraged > 0) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - - if (BossRushEvent.BossRushActive) - { - speed *= 1.25f; - turnSpeed *= 1.25f; - } - if (npc.ai[3] > 0f) { npc.realLife = (int)npc.ai[3]; @@ -447,7 +437,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 000a1f2b15..ba94da2886 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -44,7 +44,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 110; npc.height = 100; npc.defense = 4; - npc.LifeMaxNERB(3750, 5400, 2700000); + npc.LifeMaxNERB(3750, 5400, 270000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -84,11 +84,11 @@ namespace CalamityMod.NPCs.Perforator // Variables for ichor spore phase float sporePhaseGateValue = 600f; - bool floatAboveToFireSpores = npc.ai[2] >= sporePhaseGateValue - 120f; + bool floatAboveToFireBlobs = npc.ai[2] >= sporePhaseGateValue - 120f; - // Don't deal damage for 3 seconds after spawning or while firing spores + // Don't deal damage for 3 seconds after spawning or while firing blobs npc.damage = npc.defDamage; - if (npc.ai[1] < 180f || floatAboveToFireSpores) + if (npc.ai[1] < 180f || floatAboveToFireBlobs) { if (npc.ai[1] < 180f) npc.ai[1] += 1f; @@ -98,10 +98,11 @@ namespace CalamityMod.NPCs.Perforator Player player = Main.player[npc.target]; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -115,12 +116,22 @@ namespace CalamityMod.NPCs.Perforator float enrageScale = 0f; if ((npc.position.Y / 16f) < Main.worldSurface || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 1f; + } if (!Main.player[npc.target].ZoneCrimson || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; enrageScale += 1f; - + } if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale += 1f; + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale += 1f; + } if (!player.active || player.dead || Vector2.Distance(player.Center, npc.Center) > 5600f) { @@ -196,10 +207,10 @@ namespace CalamityMod.NPCs.Perforator npc.rotation = npc.velocity.X * 0.04f; - // Emit ichor spores + // Emit ichor blobs if (phase2) { - if (wormsAlive == 0 || malice || floatAboveToFireSpores) + if (wormsAlive == 0 || malice || floatAboveToFireBlobs) { npc.ai[2] += 1f; if (npc.ai[2] >= sporePhaseGateValue) @@ -207,7 +218,7 @@ namespace CalamityMod.NPCs.Perforator if (npc.ai[2] < sporePhaseGateValue + 300f) { if (npc.velocity.Length() > 0.5f) - npc.velocity *= 0.95f; + npc.velocity *= 0.96f; else npc.ai[2] = sporePhaseGateValue + 300f; } @@ -230,24 +241,21 @@ namespace CalamityMod.NPCs.Perforator } } - int numSpores = expertMode ? 14 : 7; - int type = ModContent.ProjectileType(); + int numBlobs = expertMode ? 6 : 3; + int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - for (int i = 0; i < numSpores; i++) + for (int i = 0; i < numBlobs; i++) { - Vector2 sporeVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101)); - sporeVelocity.Normalize(); - sporeVelocity *= Main.rand.Next(200, 401) * 0.01f; + 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(sporeVelocity.Y) * 0.5f; - if (sporeVelocity.Y < 2f) - sporeVelocity.Y = 2f + sporeVelocityYAdd; + float sporeVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.5f; + if (blobVelocity.Y < 2f) + blobVelocity.Y = 2f + sporeVelocityYAdd; - if (BossRushEvent.BossRushActive) - sporeVelocity *= 2f; - - Projectile.NewProjectile(npc.Center, sporeVelocity, type, damage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.Center, blobVelocity, type, damage, 0f, Main.myPlayer); } } @@ -257,19 +265,19 @@ namespace CalamityMod.NPCs.Perforator } // Movement velocities, increased while enraged - float velocityXEnrageIncrease = 1.5f * enrageScale; - float velocityYEnrageIncrease = 0.5f * enrageScale; + float velocityXEnrageIncrease = 0.8f * enrageScale; + float velocityYEnrageIncrease = 0.2f * enrageScale; - // When firing spores, float above the target and don't call any other projectile firing or movement code - if (floatAboveToFireSpores) + // When firing blobs, float above the target and don't call any other projectile firing or movement code + if (floatAboveToFireBlobs) { if (revenge) { - Movement(player, 9f + velocityXEnrageIncrease, 3f + velocityYEnrageIncrease, BossRushEvent.BossRushActive ? 0.4f : 0.3f, 160f, 400f, 500f, false); + Movement(player, 9f - velocityXEnrageIncrease, 3f - velocityYEnrageIncrease, 0.3f, 160f, 400f, 500f, false); npc.ai[0] = 0f; } else - Movement(player, 7.5f + velocityXEnrageIncrease, 1.5f + velocityYEnrageIncrease, 0.2f, 160f, 400f, 500f, false); + Movement(player, 7.5f - velocityXEnrageIncrease, 1.5f - velocityYEnrageIncrease, 0.2f, 160f, 400f, 500f, false); return; } @@ -323,7 +331,7 @@ namespace CalamityMod.NPCs.Perforator { if (wormsAlive == 1) { - Movement(player, 4f + velocityXEnrageIncrease, 1f + velocityYEnrageIncrease, BossRushEvent.BossRushActive ? 0.2f : 0.15f, 160f, 300f, 400f, false); + Movement(player, 4f - velocityXEnrageIncrease, 1f - velocityYEnrageIncrease, 0.15f, 160f, 300f, 400f, false); npc.ai[0] = 0f; } else @@ -331,13 +339,13 @@ namespace CalamityMod.NPCs.Perforator if (npc.ai[0] == 1f) { if (large || death) - Movement(player, 3.5f + velocityXEnrageIncrease, 1f + velocityYEnrageIncrease, BossRushEvent.BossRushActive ? 0.195f : death ? 0.15f : 0.13f, 360f, 10f, 50f, true); + Movement(player, 3.5f - velocityXEnrageIncrease, 1f - velocityYEnrageIncrease, death ? 0.15f : 0.13f, 360f, 10f, 50f, true); else if (medium) - Movement(player, 4.5f + velocityXEnrageIncrease, 1.5f + velocityYEnrageIncrease, BossRushEvent.BossRushActive ? 0.18f : death ? 0.14f : 0.12f, 340f, 15f, 50f, true); + Movement(player, 4.5f - velocityXEnrageIncrease, 1.5f - velocityYEnrageIncrease, death ? 0.14f : 0.12f, 340f, 15f, 50f, true); else if (small) - Movement(player, 5.5f + velocityXEnrageIncrease, 2f + velocityYEnrageIncrease, BossRushEvent.BossRushActive ? 0.165f : death ? 0.13f : 0.11f, 320f, 20f, 50f, true); + Movement(player, 5.5f - velocityXEnrageIncrease, 2f - velocityYEnrageIncrease, death ? 0.13f : 0.11f, 320f, 20f, 50f, true); else - Movement(player, 6.5f + velocityXEnrageIncrease, 2.5f + velocityYEnrageIncrease, BossRushEvent.BossRushActive ? 0.15f : death ? 0.12f : 0.1f, 300f, 25f, 50f, true); + Movement(player, 6.5f - velocityXEnrageIncrease, 2.5f - velocityYEnrageIncrease, death ? 0.12f : 0.1f, 300f, 25f, 50f, true); } else { @@ -348,7 +356,7 @@ namespace CalamityMod.NPCs.Perforator } } else - Movement(player, 2.5f + velocityXEnrageIncrease, 0.5f + velocityYEnrageIncrease, 0.1f, 160f, 300f, 400f, false); + Movement(player, 7f - velocityXEnrageIncrease, 3f - velocityYEnrageIncrease, 0.1f, 160f, 300f, 400f, false); } private void Movement(Player target, float velocityX, float velocityY, float acceleration, float x, float y, float y2, bool charging) @@ -405,7 +413,7 @@ namespace CalamityMod.NPCs.Perforator Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorTailLarge.cs b/NPCs/Perforator/PerforatorTailLarge.cs index e12c2e747f..6b15f31b17 100644 --- a/NPCs/Perforator/PerforatorTailLarge.cs +++ b/NPCs/Perforator/PerforatorTailLarge.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 60; npc.height = 78; npc.defense = 12; - npc.LifeMaxNERB(2500, 2700, 800000); + npc.LifeMaxNERB(2500, 2700, 80000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -81,7 +81,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorTailMedium.cs b/NPCs/Perforator/PerforatorTailMedium.cs index 7b2ab1f0eb..28b35c0ac9 100644 --- a/NPCs/Perforator/PerforatorTailMedium.cs +++ b/NPCs/Perforator/PerforatorTailMedium.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 40; npc.height = 50; npc.defense = 10; - npc.LifeMaxNERB(160, 180, 70000); + npc.LifeMaxNERB(160, 180, 7000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -138,7 +138,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/Perforator/PerforatorTailSmall.cs b/NPCs/Perforator/PerforatorTailSmall.cs index bad7643bbf..354aa2f694 100644 --- a/NPCs/Perforator/PerforatorTailSmall.cs +++ b/NPCs/Perforator/PerforatorTailSmall.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.Perforator npc.width = 40; npc.height = 34; npc.defense = 8; - npc.LifeMaxNERB(1250, 1500, 500000); + npc.LifeMaxNERB(1250, 1500, 50000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = 6; @@ -82,7 +82,7 @@ namespace CalamityMod.NPCs.Perforator 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, 4f + npc.gfxOffY); + 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"); diff --git a/NPCs/NormalNPCs/PlagueBee.cs b/NPCs/PlagueEnemies/PlagueBee.cs similarity index 90% rename from NPCs/NormalNPCs/PlagueBee.cs rename to NPCs/PlagueEnemies/PlagueBee.cs index 3856a5a576..337d08d151 100644 --- a/NPCs/NormalNPCs/PlagueBee.cs +++ b/NPCs/PlagueEnemies/PlagueBee.cs @@ -8,7 +8,7 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.NPCs.NormalNPCs +namespace CalamityMod.NPCs.PlagueEnemies { public class PlagueBee : ModNPC { @@ -33,7 +33,6 @@ namespace CalamityMod.NPCs.NormalNPCs animationType = NPCID.Bee; npc.value = Item.buyPrice(0, 0, 5, 0); npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.noGravity = true; npc.noTileCollide = false; banner = npc.type; @@ -62,17 +61,17 @@ namespace CalamityMod.NPCs.NormalNPCs color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/NormalNPCs/PlagueBeeGlow"); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) @@ -84,7 +83,7 @@ namespace CalamityMod.NPCs.NormalNPCs 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -122,6 +121,7 @@ namespace CalamityMod.NPCs.NormalNPCs } if (npc.life <= 0) { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PlagueBoom" + Main.rand.Next(1, 5)), npc.Center); for (int k = 0; k < 10; k++) { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Plague, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/NormalNPCs/PlagueBee.png b/NPCs/PlagueEnemies/PlagueBee.png similarity index 100% rename from NPCs/NormalNPCs/PlagueBee.png rename to NPCs/PlagueEnemies/PlagueBee.png diff --git a/NPCs/NormalNPCs/PlagueBeeGlow.png b/NPCs/PlagueEnemies/PlagueBeeGlow.png similarity index 100% rename from NPCs/NormalNPCs/PlagueBeeGlow.png rename to NPCs/PlagueEnemies/PlagueBeeGlow.png diff --git a/NPCs/NormalNPCs/PlagueBeeLarge.cs b/NPCs/PlagueEnemies/PlagueBeeLarge.cs similarity index 90% rename from NPCs/NormalNPCs/PlagueBeeLarge.cs rename to NPCs/PlagueEnemies/PlagueBeeLarge.cs index 4fb181ef52..d1d391d517 100644 --- a/NPCs/NormalNPCs/PlagueBeeLarge.cs +++ b/NPCs/PlagueEnemies/PlagueBeeLarge.cs @@ -7,7 +7,8 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.NPCs.NormalNPCs + +namespace CalamityMod.NPCs.PlagueEnemies { public class PlagueBeeLarge : ModNPC { @@ -32,7 +33,6 @@ namespace CalamityMod.NPCs.NormalNPCs animationType = NPCID.Bee; npc.value = Item.buyPrice(0, 0, 10, 0); npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.noGravity = true; npc.noTileCollide = false; banner = ModContent.NPCType(); @@ -61,17 +61,17 @@ namespace CalamityMod.NPCs.NormalNPCs color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/NormalNPCs/PlagueBeeGlow"); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) @@ -83,7 +83,7 @@ namespace CalamityMod.NPCs.NormalNPCs 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -121,6 +121,7 @@ namespace CalamityMod.NPCs.NormalNPCs } if (npc.life <= 0) { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PlagueBoom" + Main.rand.Next(1, 5)), npc.Center); for (int k = 0; k < 10; k++) { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Plague, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/NormalNPCs/PlagueBeeLarge.png b/NPCs/PlagueEnemies/PlagueBeeLarge.png similarity index 100% rename from NPCs/NormalNPCs/PlagueBeeLarge.png rename to NPCs/PlagueEnemies/PlagueBeeLarge.png diff --git a/NPCs/NormalNPCs/PlaguedDerpling.cs b/NPCs/PlagueEnemies/PlaguedDerpling.cs similarity index 97% rename from NPCs/NormalNPCs/PlaguedDerpling.cs rename to NPCs/PlagueEnemies/PlaguedDerpling.cs index 0d99f51ae9..9ac9335c55 100644 --- a/NPCs/NormalNPCs/PlaguedDerpling.cs +++ b/NPCs/PlagueEnemies/PlaguedDerpling.cs @@ -8,7 +8,8 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.NPCs.NormalNPCs + +namespace CalamityMod.NPCs.PlagueEnemies { public class PlaguedDerpling : ModNPC { @@ -31,7 +32,6 @@ namespace CalamityMod.NPCs.NormalNPCs npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 0, 10, 0); npc.HitSound = SoundID.NPCHit22; - npc.DeathSound = SoundID.NPCDeath25; banner = npc.type; bannerItem = ModContent.ItemType(); } @@ -169,6 +169,7 @@ namespace CalamityMod.NPCs.NormalNPCs } if (npc.life <= 0) { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PlagueBoom" + Main.rand.Next(1, 5)), npc.Center); for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Plague, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/NormalNPCs/PlaguedDerpling.png b/NPCs/PlagueEnemies/PlaguedDerpling.png similarity index 100% rename from NPCs/NormalNPCs/PlaguedDerpling.png rename to NPCs/PlagueEnemies/PlaguedDerpling.png diff --git a/NPCs/NormalNPCs/PlaguedFlyingFox.cs b/NPCs/PlagueEnemies/PlaguedFlyingFox.cs similarity index 91% rename from NPCs/NormalNPCs/PlaguedFlyingFox.cs rename to NPCs/PlagueEnemies/PlaguedFlyingFox.cs index 6cc2b9a2e5..dc0f7e1d3f 100644 --- a/NPCs/NormalNPCs/PlaguedFlyingFox.cs +++ b/NPCs/PlagueEnemies/PlaguedFlyingFox.cs @@ -5,7 +5,8 @@ using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.NPCs.NormalNPCs + +namespace CalamityMod.NPCs.PlagueEnemies { public class PlaguedFlyingFox : ModNPC { @@ -29,7 +30,6 @@ namespace CalamityMod.NPCs.NormalNPCs npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 0, 10, 0); npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath4; banner = npc.type; bannerItem = ModContent.ItemType(); } @@ -56,6 +56,7 @@ namespace CalamityMod.NPCs.NormalNPCs } if (npc.life <= 0) { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PlagueBoom" + Main.rand.Next(1, 5)), npc.Center); for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Plague, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/NormalNPCs/PlaguedFlyingFox.png b/NPCs/PlagueEnemies/PlaguedFlyingFox.png similarity index 100% rename from NPCs/NormalNPCs/PlaguedFlyingFox.png rename to NPCs/PlagueEnemies/PlaguedFlyingFox.png diff --git a/NPCs/NormalNPCs/PlaguedJungleSlime.cs b/NPCs/PlagueEnemies/PlaguedJungleSlime.cs similarity index 96% rename from NPCs/NormalNPCs/PlaguedJungleSlime.cs rename to NPCs/PlagueEnemies/PlaguedJungleSlime.cs index 955a322888..a8ca82cdbd 100644 --- a/NPCs/NormalNPCs/PlaguedJungleSlime.cs +++ b/NPCs/PlagueEnemies/PlaguedJungleSlime.cs @@ -8,7 +8,8 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.NPCs.NormalNPCs + +namespace CalamityMod.NPCs.PlagueEnemies { public class PlaguedJungleSlime : ModNPC { @@ -36,7 +37,6 @@ namespace CalamityMod.NPCs.NormalNPCs npc.noGravity = false; npc.noTileCollide = false; npc.HitSound = SoundID.NPCHit1; - npc.DeathSound = SoundID.NPCDeath1; banner = npc.type; bannerItem = ModContent.ItemType(); } @@ -114,6 +114,7 @@ namespace CalamityMod.NPCs.NormalNPCs } if (npc.life <= 0) { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PlagueBoom" + Main.rand.Next(1, 5)), npc.Center); for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Plague, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/NormalNPCs/PlaguedJungleSlime.png b/NPCs/PlagueEnemies/PlaguedJungleSlime.png similarity index 100% rename from NPCs/NormalNPCs/PlaguedJungleSlime.png rename to NPCs/PlagueEnemies/PlaguedJungleSlime.png diff --git a/NPCs/NormalNPCs/PlaguedTortoise.cs b/NPCs/PlagueEnemies/PlaguedTortoise.cs similarity index 91% rename from NPCs/NormalNPCs/PlaguedTortoise.cs rename to NPCs/PlagueEnemies/PlaguedTortoise.cs index 993fa93dff..7feecda54e 100644 --- a/NPCs/NormalNPCs/PlaguedTortoise.cs +++ b/NPCs/PlagueEnemies/PlaguedTortoise.cs @@ -5,7 +5,8 @@ using CalamityMod.Items.Placeables.Banners; using Terraria; using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.NPCs.NormalNPCs + +namespace CalamityMod.NPCs.PlagueEnemies { public class PlaguedTortoise : ModNPC { @@ -28,7 +29,6 @@ namespace CalamityMod.NPCs.NormalNPCs animationType = NPCID.GiantTortoise; npc.value = Item.buyPrice(0, 0, 20, 0); npc.HitSound = SoundID.NPCHit24; - npc.DeathSound = SoundID.NPCDeath27; npc.noGravity = false; banner = npc.type; bannerItem = ModContent.ItemType(); @@ -42,6 +42,7 @@ namespace CalamityMod.NPCs.NormalNPCs } if (npc.life <= 0) { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PlagueBoom" + Main.rand.Next(1, 5)), npc.Center); for (int k = 0; k < 20; k++) { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Plague, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/NormalNPCs/PlaguedTortoise.png b/NPCs/PlagueEnemies/PlaguedTortoise.png similarity index 100% rename from NPCs/NormalNPCs/PlaguedTortoise.png rename to NPCs/PlagueEnemies/PlaguedTortoise.png diff --git a/NPCs/PlaguebringerGoliath/PlagueBeeG.cs b/NPCs/PlaguebringerGoliath/PlagueBeeG.cs index 52a8deeb4f..26ea15450a 100644 --- a/NPCs/PlaguebringerGoliath/PlagueBeeG.cs +++ b/NPCs/PlaguebringerGoliath/PlagueBeeG.cs @@ -29,7 +29,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.lifeMax = 300; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 50000; + npc.lifeMax = 5000; } npc.aiStyle = -1; aiType = -1; @@ -219,14 +219,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/NormalNPCs/PlagueBeeGlow"); @@ -241,7 +241,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -251,11 +251,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 120, true); diff --git a/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs b/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs index f1ad7bc792..9e71e33082 100644 --- a/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs +++ b/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.lifeMax = 400; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 100000; + npc.lifeMax = 10000; } npc.aiStyle = -1; aiType = -1; @@ -112,14 +112,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/NormalNPCs/PlagueBeeGlow"); @@ -134,7 +134,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -144,11 +144,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 180, true); diff --git a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs index f83e9fe159..6e5178b3a5 100644 --- a/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs +++ b/NPCs/PlaguebringerGoliath/PlagueHomingMissile.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.width = 22; npc.height = 22; npc.defense = 10; - npc.lifeMax = BossRushEvent.BossRushActive ? 30000 : 300; + npc.lifeMax = BossRushEvent.BossRushActive ? 3000 : 300; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -151,14 +151,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -173,7 +173,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -222,12 +222,9 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return true; } - public override bool PreNPCLoot() - { - return 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 a75c62059a..12ce326a39 100644 --- a/NPCs/PlaguebringerGoliath/PlagueMine.cs +++ b/NPCs/PlaguebringerGoliath/PlagueMine.cs @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.width = 42; npc.height = 42; npc.defense = 10; - npc.lifeMax = BossRushEvent.BossRushActive ? 30000 : 300; + npc.lifeMax = BossRushEvent.BossRushActive ? 3000 : 300; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return; } npc.TargetClosest(true); - float num1372 = BossRushEvent.BossRushActive ? 10f : 7f; + float num1372 = 7f; Vector2 vector167 = new Vector2(npc.Center.X + (float)(npc.direction * 20), npc.Center.Y + 6f); float num1373 = player.position.X + (float)player.width * 0.5f - vector167.X; float num1374 = player.Center.Y - vector167.Y; @@ -143,7 +143,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath 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, 4f + npc.gfxOffY); + 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); @@ -155,6 +155,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return false; } + public override bool PreNPCLoot() => false; + public override bool CheckDead() { Main.PlaySound(SoundID.Item14, npc.position); diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index 1358b5818e..e015eefacb 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -56,7 +56,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.height = 198; npc.defense = 40; npc.DR_NERD(0.3f); - npc.LifeMaxNERB(81000, 106500, 3700000); + npc.LifeMaxNERB(81000, 106500, 370000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -121,13 +121,28 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath bool phase5 = lifeRatio < 0.1f; // Mode variables - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; - // Light - Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0.3f, 0.7f, 0f); + // 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[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); // Show message if (!halfLife && phase3 && expertMode) @@ -135,6 +150,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath string key = "Mods.CalamityMod.PlagueBossText"; Color messageColor = Color.Lime; CalamityUtils.DisplayLocalizedText(key, messageColor); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGNukeWarning"), npc.Center); halfLife = true; } @@ -174,14 +190,23 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // Enrage float enrageScale = death ? 0.5f : 0f; - if (!player.ZoneJungle || malice) - enrageScale += 1.5f; + if (!player.ZoneJungle || malice) + { + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive; + enrageScale += 1.5f; + } if (enrageScale > 1.5f) enrageScale = 1.5f; if (BossRushEvent.BossRushActive) - enrageScale = 0f; + enrageScale = 2f; + + if (enraged) + { + npc.Calamity().CurrentlyEnraged = true; + enrageScale = 2.5f; + } bool diagonalDash = revenge && phase2; @@ -266,6 +291,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // A phase switch sync is a critical operation that must be synced. if (npc.netSpam >= 10) npc.netSpam = 9; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGAttackSwitch{Main.rand.Next(1, 3)}"), npc.Center); } } @@ -281,8 +307,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1044 += 1f; if (phase5) num1044 += 1f; - if (calamityGlobalNPC.enraged > 0) - num1044 += 2f; num1044 += 2f * enrageScale; @@ -298,6 +322,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // A phase switch sync is a critical operation that must be synced. if (npc.netSpam >= 10) npc.netSpam = 9; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGAttackSwitch{Main.rand.Next(1, 3)}"), npc.Center); return; } @@ -354,7 +379,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.netUpdate = true; npc.netSpam -= 5; - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PBGDash"), npc.Center); return; } @@ -372,11 +397,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { num1048 += 1f; num1049 += 0.05f; - } - if (calamityGlobalNPC.enraged > 0) - { - num1048 += 2f; - num1049 += 0.1f; } num1048 += 1.5f * enrageScale; num1049 += 0.25f * enrageScale; @@ -421,11 +441,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.spriteDirection = npc.direction; int num1050 = revenge ? 525 : 550; - if (calamityGlobalNPC.enraged > 0) - num1050 = 300; - else if (BossRushEvent.BossRushActive) - num1050 = 400; - else if (phase4) + if (phase4) num1050 = revenge ? 450 : 475; else if (phase3) num1050 = revenge ? 475 : 500; @@ -519,6 +535,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // A phase switch sync is a critical operation that must be synced. if (npc.netSpam >= 10) npc.netSpam = 9; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGAttackSwitch{Main.rand.Next(1, 3)}"), npc.Center); return; } @@ -570,7 +587,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath Main.npc[num1062].velocity = player.Center - npc.Center; Main.npc[num1062].velocity.Normalize(); - Main.npc[num1062].velocity *= BossRushEvent.BossRushActive ? 12f : 6f; + Main.npc[num1062].velocity *= 6f; Main.npc[num1062].localAI[0] = 60f; Main.npc[num1062].netUpdate = true; @@ -600,6 +617,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // A phase switch sync is a critical operation that must be synced. if (npc.netSpam >= 10) npc.netSpam = 9; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGAttackSwitch{Main.rand.Next(1, 3)}"), npc.Center); } } @@ -641,8 +659,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath NPC.NewNPC((int)vector119.X, (int)vector119.Y, ModContent.NPCType()); float projectileSpeed = (revenge ? 8f : 7f) + enrageScale * 2f; - if (BossRushEvent.BossRushActive) - projectileSpeed *= 2f; float num1071 = player.position.X + player.width * 0.5f - vector119.X; float num1072 = player.position.Y + player.height * 0.5f - vector119.Y; @@ -683,6 +699,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // A phase switch sync is a critical operation that must be synced. if (npc.netSpam >= 10) npc.netSpam = 9; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGAttackSwitch{Main.rand.Next(1, 3)}"), npc.Center); } } @@ -693,7 +710,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath vector121.X += npc.direction * 120; npc.ai[1] += 1f; - int num650 = (calamityGlobalNPC.enraged > 0) ? 10 : (phase5 ? 20 : (phase3 ? 25 : 30)); + 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) @@ -705,12 +722,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath float projectileSpeed = revenge ? 6.5f : 6f; projectileSpeed += 2f * enrageScale; - if (calamityGlobalNPC.enraged > 0) - projectileSpeed += 10f; - - if (BossRushEvent.BossRushActive) - projectileSpeed *= 1.5f; - float num1071 = player.position.X + player.width * 0.5f - vector121.X; float num1072 = player.position.Y + player.height * 0.5f - vector121.Y; float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); @@ -761,6 +772,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // A phase switch sync is a critical operation that must be synced. if (npc.netSpam >= 10) npc.netSpam = 9; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGAttackSwitch{Main.rand.Next(1, 3)}"), npc.Center); } } @@ -768,8 +780,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath else if (npc.ai[0] == 4f) { float num1044 = revenge ? 28f : 26f; - if (BossRushEvent.BossRushActive) - num1044 = 32f; num1044 += 3f * enrageScale; @@ -786,6 +796,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath // A phase switch sync is a critical operation that must be synced. if (npc.netSpam >= 10) npc.netSpam = 9; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, $"Sounds/Custom/PlagueSounds/PBGAttackSwitch{Main.rand.Next(1, 3)}"), npc.Center); return; } @@ -801,11 +812,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { if (MissileCountdown == 1) { - Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 116); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/PlagueSounds/PBGBarrageLaunch"), npc.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - float speed = BossRushEvent.BossRushActive ? 12f : revenge ? 6f : 5f; + float speed = revenge ? 6f : 5f; speed += 2f * enrageScale; int type = ModContent.ProjectileType(); @@ -856,11 +867,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath float num1049 = revenge ? 0.2f : 0.18f; num1048 += 1.5f * enrageScale; num1049 += 0.25f * enrageScale; - if (BossRushEvent.BossRushActive) - { - num1048 *= 1.5f; - num1049 *= 1.5f; - } if (vectorCenter.Y < player.Center.Y - 500f) npc.velocity.Y += num1049; @@ -958,12 +964,12 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath private void Movement(float xPos, float yPos, float yPos2, Player player, float enrageScale) { - Vector2 acceleration = new Vector2(BossRushEvent.BossRushActive ? 0.2f : 0.1f, BossRushEvent.BossRushActive ? 0.2f : 0.15f); + Vector2 acceleration = new Vector2(0.1f, 0.15f); Vector2 velocity = new Vector2(8f, 5f); float deceleration = 0.98f; acceleration *= 0.1f * enrageScale + 1f; - velocity *= 0.1f * enrageScale + 1f; + velocity *= 1f - enrageScale * 0.1f; deceleration *= 1f - enrageScale * 0.1f; if (npc.position.Y > player.position.Y - yPos) diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs b/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs index c5a280a9b2..2ada7a26c3 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerShade.cs @@ -39,7 +39,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.value = Item.buyPrice(0, 1, 50, 0); if (BossRushEvent.BossRushActive) { - npc.lifeMax = 200000; + npc.lifeMax = 20000; } npc.knockBackResist = 0f; npc.aiStyle = -1; @@ -158,10 +158,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { num1044 += 2f; } - if (BossRushEvent.BossRushActive) - { - num1044 *= 1.5f; - } Vector2 vector117 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num1045 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector117.X; float num1046 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector117.Y; @@ -181,11 +177,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1048 += 1f; num1049 += 0.075f; } - if (BossRushEvent.BossRushActive) - { - num1048 *= 1.5f; - num1049 *= 1.5f; - } if (npc.position.Y + (float)(npc.height / 2) < Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2)) { npc.velocity.Y = npc.velocity.Y + num1049; @@ -235,7 +226,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.direction = 1; } npc.spriteDirection = npc.direction; - int num1050 = BossRushEvent.BossRushActive ? 400 : 500; + int num1050 = 500; int num1051 = 1; if (npc.position.X + (float)(npc.width / 2) < Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2)) { @@ -255,7 +246,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath npc.localAI[0] = 0f; npc.velocity *= 0.9f; float num1052 = 0.105f; - if (flag113 || BossRushEvent.BossRushActive) + if (flag113) { npc.velocity *= 0.9f; num1052 += 0.075f; @@ -277,11 +268,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { num1054 = 0.12f; } - if (BossRushEvent.BossRushActive) - { - num1053 *= 1.5f; - num1054 *= 1.5f; - } Vector2 vector118 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num1055 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector118.X; float num1056 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - 200f - vector118.Y; @@ -373,11 +359,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath { float num1063 = 14.5f; float num1064 = 0.105f; - if (BossRushEvent.BossRushActive) - { - num1063 *= 1.5f; - num1064 *= 1.5f; - } vector120 = vector119; num1058 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector120.X; num1059 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector120.Y; @@ -437,11 +418,6 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath num1066 = 0.09f; num1065 = 8f; } - if (BossRushEvent.BossRushActive) - { - num1065 *= 1.5f; - num1066 *= 1.5f; - } Vector2 vector121 = new Vector2(npc.position.X + (float)(npc.width / 2) + (float)(40 * npc.direction), npc.position.Y + (float)npc.height * 0.8f); Vector2 vector122 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num1067 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector122.X; @@ -476,7 +452,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } 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)) { - num1066 = BossRushEvent.BossRushActive ? 0.12f : 0.105f; + num1066 = 0.105f; vector122 = vector121; num1067 = Main.player[npc.target].position.X + (float)(Main.player[npc.target].width / 2) - vector122.X; num1068 = Main.player[npc.target].position.Y + (float)(Main.player[npc.target].height / 2) - vector122.Y; @@ -589,14 +565,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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; @@ -651,10 +627,11 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath } } - public override bool PreNPCLoot() => !NPC.AnyNPCs(ModContent.NPCType()); //don't drop items in the PBG fight - public override void NPCLoot() { + if (NPC.AnyNPCs(ModContent.NPCType())) + return; + 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); diff --git a/NPCs/Polterghast/PhantomFuckYou.cs b/NPCs/Polterghast/PhantomFuckYou.cs index 10cfbbd867..9015c5b4dd 100644 --- a/NPCs/Polterghast/PhantomFuckYou.cs +++ b/NPCs/Polterghast/PhantomFuckYou.cs @@ -1,4 +1,4 @@ -using CalamityMod.Events; +using CalamityMod.Dusts; using CalamityMod.Projectiles.Boss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -47,14 +47,15 @@ namespace CalamityMod.NPCs.Polterghast public override bool PreAI() { - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive; - if (start) { start = false; - for (int num621 = 0; num621 < 5; num621++) - Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 2f); + 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]; } @@ -91,7 +92,8 @@ namespace CalamityMod.NPCs.Polterghast int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); float maxVelocity = 8f * tileEnrageMult; - Projectile.NewProjectile(npc.Center, direction, type, damage, 1f, npc.target, maxVelocity, 0f); + float acceleration = 1.05f + (tileEnrageMult - 1f) * 0.1f; + Projectile.NewProjectile(npc.Center, direction, type, damage, 1f, npc.target, maxVelocity, acceleration); } npc.ai[2] = 0f; } @@ -142,14 +144,14 @@ namespace CalamityMod.NPCs.Polterghast 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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; diff --git a/NPCs/Polterghast/PolterPhantom.cs b/NPCs/Polterghast/PolterPhantom.cs index 89204a66f3..c4f8ab0315 100644 --- a/NPCs/Polterghast/PolterPhantom.cs +++ b/NPCs/Polterghast/PolterPhantom.cs @@ -1,5 +1,3 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.World; @@ -74,10 +72,10 @@ namespace CalamityMod.NPCs.Polterghast { CalamityGlobalNPC.ghostBossClone = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; if (CalamityGlobalNPC.ghostBoss < 0 || !Main.npc[CalamityGlobalNPC.ghostBoss].active) { @@ -130,9 +128,6 @@ namespace CalamityMod.NPCs.Polterghast else despawnTimer++; - if (BossRushEvent.BossRushActive) - speedBoost = false; - if (Main.npc[CalamityGlobalNPC.ghostBoss].ai[2] < 300f) { velocity = 21f; @@ -146,15 +141,26 @@ namespace CalamityMod.NPCs.Polterghast acceleration += revenge ? 0.035f : 0.025f; } - // Look at target - float num740 = player.Center.X - vector.X; - float num741 = player.Center.Y - vector.Y; + // Predictiveness + float chargePredictionAmt = 10f + 20f * (tileEnrageMult - 1f); + Vector2 predictionVector = chargePhase && revenge ? player.velocity * chargePredictionAmt : Vector2.Zero; + Vector2 lookAt = player.Center + predictionVector; + Vector2 rotationVector = lookAt - vector; + + // Rotation + 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; npc.damage = npc.defDamage; if (!chargePhase) { + // Set this here to avoid despawn issues + reachedChargingPoint = false; + + npc.ai[0] = 0f; + npc.Opacity += 0.02f; if (npc.Opacity > 0.8f) npc.Opacity = 0.8f; @@ -265,7 +271,7 @@ namespace CalamityMod.NPCs.Polterghast if (npc.Calamity().newAI[1] == 0f) { - npc.velocity = Vector2.Normalize(player.Center - vector) * chargeVelocity; + npc.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; npc.Calamity().newAI[1] = 1f; } else @@ -284,6 +290,7 @@ namespace CalamityMod.NPCs.Polterghast 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) @@ -302,6 +309,7 @@ namespace CalamityMod.NPCs.Polterghast { npc.velocity = Vector2.Zero; npc.ai[0] = Main.rand.Next(2) + 1; + npc.netUpdate = true; } // Pick a charging location @@ -340,22 +348,31 @@ namespace CalamityMod.NPCs.Polterghast npc.Opacity = 0f; } - int numUpdates = reachedChargingPoint ? 5 : 1; - for (int i = 0; i < numUpdates; i++) + if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue || reachedChargingPoint) { - if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue) + // Emit dust + if (!reachedChargingPoint) { - reachedChargingPoint = true; + 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; + } + } - npc.velocity *= 0.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 - { - if (Vector2.Distance(vector, chargeVector) > 1200f) - npc.velocity = chargeLocationVelocity; - else - npc.SimpleFlyMovement(chargeLocationVelocity, chargeAcceleration); - } + npc.SimpleFlyMovement(chargeLocationVelocity, chargeAcceleration); } } @@ -401,7 +418,7 @@ namespace CalamityMod.NPCs.Polterghast 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, 4f + npc.gfxOffY); + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -413,7 +430,7 @@ namespace CalamityMod.NPCs.Polterghast 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, 4f + npc.gfxOffY); + 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"); @@ -425,7 +442,7 @@ namespace CalamityMod.NPCs.Polterghast { 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color43 = color42; color43 = Color.Lerp(color43, color36, amount9); color43 = npc.GetAlpha(color43); diff --git a/NPCs/Polterghast/Polterghast.cs b/NPCs/Polterghast/Polterghast.cs index 0efa789d2c..07781cbfa9 100644 --- a/NPCs/Polterghast/Polterghast.cs +++ b/NPCs/Polterghast/Polterghast.cs @@ -29,7 +29,8 @@ namespace CalamityMod.NPCs.Polterghast public class Polterghast : ModNPC { private int despawnTimer = 600; - private int chargeTelegraphTimer = 60; + private const int chargeTelegraphTimerMax = 15; + private int chargeTelegraphTimer = chargeTelegraphTimerMax; private bool reachedChargingPoint = false; public override void SetStaticDefaults() @@ -42,7 +43,7 @@ namespace CalamityMod.NPCs.Polterghast public override void SetDefaults() { npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 50f; + npc.npcSlots = 50f; npc.GetNPCDamage(); npc.width = 90; npc.height = 120; @@ -50,7 +51,7 @@ namespace CalamityMod.NPCs.Polterghast npc.DR_NERD(0.2f, null, null, null, true); CalamityGlobalNPC global = npc.Calamity(); global.multDRReductions.Add(BuffID.CursedInferno, 0.9f); - npc.LifeMaxNERB(350000, 420000, 3250000); + npc.LifeMaxNERB(350000, 420000, 325000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -115,12 +116,13 @@ namespace CalamityMod.NPCs.Polterghast // Variables Vector2 vector = npc.Center; - bool malice = CalamityWorld.malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool speedBoost = false; bool despawnBoost = false; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; 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); @@ -162,6 +164,23 @@ namespace CalamityMod.NPCs.Polterghast { speedBoost = true; despawnBoost = true; + reachedChargingPoint = false; + chargeTelegraphTimer = chargeTelegraphTimerMax; + 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; + } } } @@ -202,9 +221,6 @@ namespace CalamityMod.NPCs.Polterghast else despawnTimer++; - if (BossRushEvent.BossRushActive) - speedBoost = false; - // Despawn if (Vector2.Distance(player.Center, vector) > (despawnBoost ? 1500f : 6000f)) { @@ -295,23 +311,37 @@ namespace CalamityMod.NPCs.Polterghast if (malice) tileEnrageMult = 1.75f; + if (enraged) + tileEnrageMult = 2.25f; + + npc.Calamity().CurrentlyEnraged = !BossRushEvent.BossRushActive && tileEnrageMult >= 1.6f; + // Used to inform clone and hooks about number of active tiles nearby npc.ai[3] = tileEnrageMult; // Increase projectile fire rate based on number of nearby active tiles - float projectileFireRateMultiplier = MathHelper.Lerp(1f, 2f, 1f - ((tileEnrageMult - 1f) / 0.6f)); + float amount = 1f - ((tileEnrageMult - 1f) / 0.75f); + if (amount < 0f) + amount = 0f; + float projectileFireRateMultiplier = MathHelper.Lerp(1f, 2f, amount); // 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 = (BossRushEvent.BossRushActive ? 7f : 5f) * tileEnrageMult; - if (speedBoost || calamityGlobalNPC.enraged > 0) + float baseProjectileVelocity = 5f * tileEnrageMult; + if (speedBoost) baseProjectileVelocity *= 1.25f; - // Look at target - float num740 = player.Center.X - vector.X; - float num741 = player.Center.Y - vector.Y; + // Predictiveness + float chargePredictionAmt = 10f + 20f * (tileEnrageMult - 1f); + Vector2 predictionVector = chargePhase && revenge ? player.velocity * chargePredictionAmt : Vector2.Zero; + Vector2 lookAt = player.Center + predictionVector; + Vector2 rotationVector = lookAt - vector; + + // Rotation + 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; if (!chargePhase) @@ -431,7 +461,7 @@ namespace CalamityMod.NPCs.Polterghast if (calamityGlobalNPC.newAI[1] == 0f) { - npc.velocity = Vector2.Normalize(player.Center - vector) * chargeVelocity; + npc.velocity = Vector2.Normalize(rotationVector) * chargeVelocity; calamityGlobalNPC.newAI[1] = 1f; } else @@ -447,7 +477,7 @@ namespace CalamityMod.NPCs.Polterghast // Reset and either go back to normal or charge again if (calamityGlobalNPC.newAI[2] >= totalChargeTime) { - chargeTelegraphTimer = 15; + chargeTelegraphTimer = chargeTelegraphTimerMax; calamityGlobalNPC.newAI[1] = 0f; calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; @@ -490,59 +520,59 @@ namespace CalamityMod.NPCs.Polterghast float chargeDistanceGateValue = 40f; bool clonePositionCheck = cloneAlive ? Vector2.Distance(Main.npc[CalamityGlobalNPC.ghostBossClone].Center, cloneChargeVector) <= chargeDistanceGateValue : true; - // Loop velocity code multiple times per frame if charge location is reached - // This effectively quadruples the velocity and acceleration while maintaining smooth movement - int numUpdates = reachedChargingPoint ? 5 : 1; - for (int i = 0; i < numUpdates; i++) + // Line up a charge + if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue || reachedChargingPoint) { - // Line up a charge - if (Vector2.Distance(vector, chargeVector) <= chargeDistanceGateValue) + // Emit dust + if (!reachedChargingPoint) { - reachedChargingPoint = true; - - npc.velocity *= 0.5f; - - if (clonePositionCheck) + Main.PlaySound(SoundID.Item125, npc.position); + for (int i = 0; i < 30; i++) { - // Pause for 15 frames before actually charging - // This is 15 frames because this code runs 4 times per frame once a charge location is found - if (chargeTelegraphTimer > 0) + 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; + + if (clonePositionCheck) + { + // Pause for 15 frames before actually charging + if (chargeTelegraphTimer > 0) + { + chargeTelegraphTimer--; + } + else + { + // Initiate charge + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 1f; + + // Tell clone to charge + if (cloneAlive) { - chargeTelegraphTimer--; - } - else - { - // Initiate charge - npc.velocity = Vector2.Zero; - calamityGlobalNPC.newAI[1] = 0f; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 1f; + 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; - // Tell clone to charge - if (cloneAlive) - { - Main.npc[CalamityGlobalNPC.ghostBossClone].velocity = Vector2.Zero; - 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; - - // - // 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. - } - - // Break because looping beyond this point is useless - break; + // + // 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); } + else + npc.SimpleFlyMovement(chargeLocationVelocity, chargeAcceleration); } npc.netUpdate = true; @@ -654,7 +684,7 @@ namespace CalamityMod.NPCs.Polterghast calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; - Main.PlaySound(SoundID.Item122, npc.position); + 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); @@ -675,10 +705,10 @@ namespace CalamityMod.NPCs.Polterghast } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 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); + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } @@ -802,7 +832,7 @@ namespace CalamityMod.NPCs.Polterghast } } - Main.PlaySound(SoundID.Item122, npc.position); + 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); @@ -823,10 +853,10 @@ namespace CalamityMod.NPCs.Polterghast } for (int num623 = 0; num623 < 30; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 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); + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } @@ -989,14 +1019,14 @@ namespace CalamityMod.NPCs.Polterghast 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -1018,7 +1048,7 @@ namespace CalamityMod.NPCs.Polterghast 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, 4f + npc.gfxOffY); + 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; @@ -1045,9 +1075,10 @@ namespace CalamityMod.NPCs.Polterghast if (lifeRatio > npc.Calamity().killTimeRatio_IncreasedAggression) lifeRatio = npc.Calamity().killTimeRatio_IncreasedAggression; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || CalamityWorld.malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; 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; @@ -1106,7 +1137,7 @@ namespace CalamityMod.NPCs.Polterghast public override void HitEffect(int hitDirection, double damage) { - Dust.NewDust(npc.position, npc.width, npc.height, 180, hitDirection, -1f, 0, default, 1f); + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Ectoplasm, hitDirection, -1f, 0, default, 1f); if (npc.life <= 0) { npc.position.X = npc.position.X + (npc.width / 2); @@ -1127,10 +1158,10 @@ namespace CalamityMod.NPCs.Polterghast } for (int num623 = 0; num623 < 60; num623++) { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 180, 0f, 0f, 100, default, 3f); + int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 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); + num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Ectoplasm, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } diff --git a/NPCs/Polterghast/PolterghastHook.cs b/NPCs/Polterghast/PolterghastHook.cs index a595d1167c..4acb4bfdac 100644 --- a/NPCs/Polterghast/PolterghastHook.cs +++ b/NPCs/Polterghast/PolterghastHook.cs @@ -153,7 +153,7 @@ namespace CalamityMod.NPCs.Polterghast if (Main.netMode != NetmodeID.MultiplayerClient && npc.ai[2] == 20f) { - float num151 = (BossRushEvent.BossRushActive ? 14f : 10f) * tileEnrageMult; + float num151 = 10f * tileEnrageMult; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); num149 = num151 / num149; @@ -356,14 +356,14 @@ namespace CalamityMod.NPCs.Polterghast 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -382,7 +382,7 @@ namespace CalamityMod.NPCs.Polterghast 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs index a180c24218..671c920b85 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss.cs @@ -43,7 +43,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.height = 80; npc.defense = 40; npc.DR_NERD(0.3f); - npc.LifeMaxNERB(76875, 84375, 1650000); // Old HP - 102500, 112500 + npc.LifeMaxNERB(76875, 84375, 165000); // Old HP - 102500, 112500 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -143,20 +143,26 @@ namespace CalamityMod.NPCs.ProfanedGuardians bool isHoly = player.ZoneHoly; bool isHell = player.ZoneUnderworldHeight; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; // Become immune over time if target isn't in hell or hallow if (!isHoly && !isHell && !BossRushEvent.BossRushActive) { if (immuneTimer > 0) immuneTimer--; + else + npc.Calamity().CurrentlyEnraged = true; } else immuneTimer = 300; + if (enraged) + npc.Calamity().CurrentlyEnraged = true; + // Take damage or not npc.dontTakeDamage = immuneTimer <= 0; @@ -183,9 +189,10 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.spriteDirection = Math.Sign(npc.velocity.X); float num1000 = lifeRatio < 0.75f ? 14f : 16f; if (revenge) - { num1000 *= 0.9f; - } + if (enraged) + num1000 *= 0.8f; + float num1006 = 0.111111117f * num1000; int num1009 = (npc.ai[0] == 2f) ? 2 : 1; int num1010 = (npc.ai[0] == 2f) ? 80 : 60; @@ -201,9 +208,9 @@ namespace CalamityMod.NPCs.ProfanedGuardians } if (Main.netMode != NetmodeID.MultiplayerClient) { - float shootBoost = death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); + float shootBoost = enraged ? 4f : death ? 3f * (1f - lifeRatio) : 2f * (1f - lifeRatio); npc.localAI[0] += 1f + shootBoost; - if (npc.localAI[0] >= (BossRushEvent.BossRushActive ? 210f : 240f) && Vector2.Distance(vectorCenter, player.Center) > 160f) + if (npc.localAI[0] >= 240f && Vector2.Distance(vectorCenter, player.Center) > 160f) { npc.localAI[0] = 0f; @@ -247,7 +254,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians } if (npc.ai[0] == 0f) { - float scaleFactor6 = malice ? 20f : death ? 17f : revenge ? 16f : expertMode ? 15f : 14f; + float scaleFactor6 = enraged ? 24f : malice ? 20f : death ? 17f : revenge ? 16f : expertMode ? 15f : 14f; Vector2 center5 = player.Center; Vector2 vector126 = center5 - vectorCenter; Vector2 vector127 = vector126 - Vector2.UnitY * 300f; @@ -297,7 +304,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.netUpdate = true; Vector2 velocity = new Vector2(npc.ai[2], npc.ai[3]); velocity.Normalize(); - velocity *= malice ? 15f : death ? 13f : revenge ? 12f : expertMode ? 11f : 10f; + velocity *= enraged ? 18f : malice ? 15f : death ? 13f : revenge ? 12f : expertMode ? 11f : 10f; npc.velocity = velocity; } } @@ -378,14 +385,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -401,7 +408,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs index 01670e6bb8..5beea4876f 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss2.cs @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.height = 80; npc.defense = 50; npc.DR_NERD(0.4f); - npc.LifeMaxNERB(30000, 37500, 300000); // Old HP - 40000, 50000 + npc.LifeMaxNERB(30000, 37500, 30000); // Old HP - 40000, 50000 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -84,8 +84,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (npc.timeLeft < 1800) npc.timeLeft = 1800; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; bool isHoly = player.ZoneHoly; bool isHell = player.ZoneUnderworldHeight; @@ -94,6 +94,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians { if (immuneTimer > 0) immuneTimer--; + else + npc.Calamity().CurrentlyEnraged = true; } else immuneTimer = 300; @@ -230,14 +232,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -253,7 +255,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs index 17d79f2198..8f0f4d1d9b 100644 --- a/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs +++ b/NPCs/ProfanedGuardians/ProfanedGuardianBoss3.cs @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians npc.height = 80; npc.defense = 30; npc.DR_NERD(0.2f); - npc.LifeMaxNERB(18750, 26250, 200000); // Old HP - 25000, 35000 + npc.LifeMaxNERB(18750, 26250, 20000); // Old HP - 25000, 35000 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -84,8 +84,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians if (npc.timeLeft < 1800) npc.timeLeft = 1800; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; bool isHoly = player.ZoneHoly; bool isHell = player.ZoneUnderworldHeight; @@ -94,6 +94,8 @@ namespace CalamityMod.NPCs.ProfanedGuardians { if (immuneTimer > 0) immuneTimer--; + else + npc.Calamity().CurrentlyEnraged = true; } else immuneTimer = 300; @@ -229,14 +231,14 @@ namespace CalamityMod.NPCs.ProfanedGuardians 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -253,7 +255,7 @@ namespace CalamityMod.NPCs.ProfanedGuardians 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, 4f + npc.gfxOffY); + 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; diff --git a/NPCs/Providence/ProvSpawnDefense.cs b/NPCs/Providence/ProvSpawnDefense.cs index 69f6eef03a..2e44c17f11 100644 --- a/NPCs/Providence/ProvSpawnDefense.cs +++ b/NPCs/Providence/ProvSpawnDefense.cs @@ -33,7 +33,7 @@ namespace CalamityMod.NPCs.Providence npc.lifeMax = 18750; // Old HP - 25000 if (BossRushEvent.BossRushActive) { - npc.lifeMax = 300000; + npc.lifeMax = 30000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -147,14 +147,14 @@ namespace CalamityMod.NPCs.Providence color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -170,7 +170,7 @@ namespace CalamityMod.NPCs.Providence 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Providence/ProvSpawnHealer.cs b/NPCs/Providence/ProvSpawnHealer.cs index 9f43a3e1a1..059aa6a8af 100644 --- a/NPCs/Providence/ProvSpawnHealer.cs +++ b/NPCs/Providence/ProvSpawnHealer.cs @@ -33,7 +33,7 @@ namespace CalamityMod.NPCs.Providence npc.lifeMax = 30000; // Old HP - 40000 if (BossRushEvent.BossRushActive) { - npc.lifeMax = 400000; + npc.lifeMax = 40000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -134,14 +134,14 @@ namespace CalamityMod.NPCs.Providence color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -158,7 +158,7 @@ namespace CalamityMod.NPCs.Providence 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, 4f + npc.gfxOffY); + 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; diff --git a/NPCs/Providence/ProvSpawnOffense.cs b/NPCs/Providence/ProvSpawnOffense.cs index 7968872e6a..557065ce86 100644 --- a/NPCs/Providence/ProvSpawnOffense.cs +++ b/NPCs/Providence/ProvSpawnOffense.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.Providence npc.lifeMax = 31875; // Old HP - 42500 if (BossRushEvent.BossRushActive) { - npc.lifeMax = 400000; + npc.lifeMax = 40000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -224,14 +224,14 @@ namespace CalamityMod.NPCs.Providence color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -247,7 +247,7 @@ namespace CalamityMod.NPCs.Providence 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 5871d7faa6..996af43130 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -90,7 +90,7 @@ namespace CalamityMod.NPCs.Providence npc.DR_NERD(normalDR, null, null, null, true); CalamityGlobalNPC global = npc.Calamity(); global.flatDRReductions.Add(BuffID.CursedInferno, 0.05f); - npc.LifeMaxNERB(330000, 375000, 12500000); // Old HP - 440000, 500000 + npc.LifeMaxNERB(330000, 375000, 1250000); // Old HP - 440000, 500000 double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -214,6 +214,8 @@ namespace CalamityMod.NPCs.Providence if (nightTime) projectileDamageMult = 2; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && (nightTime || malice)) || enraged; + // Projectile damage values int holyLaserDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; int crystalDamage = npc.GetProjectileDamage(ModContent.ProjectileType()) * projectileDamageMult; @@ -483,13 +485,13 @@ namespace CalamityMod.NPCs.Providence flightPath = 0; // Velocity and acceleration - float speedIncreaseTimer = nightTime ? 90f : death ? 120f : 150f; + float speedIncreaseTimer = enraged ? 60f : nightTime ? 90f : death ? 120f : 150f; bool increaseSpeed = calamityGlobalNPC.newAI[0] > speedIncreaseTimer; 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) + if (BossRushEvent.BossRushActive || nightTime || enraged) { acceleration = 1.3f; velocity = 20f; @@ -934,10 +936,9 @@ namespace CalamityMod.NPCs.Providence } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - fireFrom) * cocoonProjVelocity; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - fireFrom) * cocoonProjVelocity * 1.5f; int type = ModContent.ProjectileType(); - int proj = Projectile.NewProjectile(fireFrom, velocity2, type, 0, 0f, Main.myPlayer, 0f, nightTime ? -300 : npc.GetProjectileDamageNoScaling(type)); - Main.projectile[proj].extraUpdates += 1; + Projectile.NewProjectile(fireFrom, velocity2, type, 0, 0f, Main.myPlayer, 0f, nightTime ? -300 : npc.GetProjectileDamageNoScaling(type)); } } } @@ -1344,10 +1345,8 @@ namespace CalamityMod.NPCs.Providence DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); } - if (Main.netMode != NetmodeID.MultiplayerClient) - { + if (Main.netMode != NetmodeID.MultiplayerClient && npc.Top.Y >= (Main.maxTilesY - 240f) * 16f) SpawnLootBox(); - } // If Providence has not been killed, notify players of Uelibloom Ore if (!CalamityWorld.downedProvidence) @@ -1380,7 +1379,7 @@ namespace CalamityMod.NPCs.Providence { int tileCenterX = (int)npc.Center.X / 16; int tileCenterY = (int)npc.Center.Y / 16; - int halfBox = npc.width / 2 / 16 + 1; + int halfBox = 5; for (int x = tileCenterX - halfBox; x <= tileCenterX + halfBox; x++) { for (int y = tileCenterY - halfBox; y <= tileCenterY + halfBox; y++) @@ -1491,14 +1490,14 @@ namespace CalamityMod.NPCs.Providence 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 / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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); Color color37 = Color.Lerp(Color.White, nightTime ? Color.Cyan : Color.Yellow, 0.5f) * npc.Opacity; @@ -1514,7 +1513,7 @@ namespace CalamityMod.NPCs.Providence color41 *= (num153 - num163) / 15f; 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(textureGlow, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); Color color43 = color42; diff --git a/NPCs/Ravager/FlamePillar.cs b/NPCs/Ravager/FlamePillar.cs index 9371a7d541..5f1d4159f3 100644 --- a/NPCs/Ravager/FlamePillar.cs +++ b/NPCs/Ravager/FlamePillar.cs @@ -139,7 +139,7 @@ namespace CalamityMod.NPCs.Ravager 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, 4f + npc.gfxOffY); + 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); @@ -151,10 +151,9 @@ namespace CalamityMod.NPCs.Ravager return false; } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; + + public override bool PreNPCLoot() => false; public override void HitEffect(int hitDirection, double damage) { diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index ff2fb5e549..b2fd9a1f86 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.Ravager npc.defense = 55; npc.value = Item.buyPrice(0, 25, 0, 0); npc.DR_NERD(0.35f); - npc.LifeMaxNERB(42700, 53500, 4600000); + npc.LifeMaxNERB(42700, 53500, 460000); if (CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive) { npc.damage = (int)(npc.damage * 1.5); @@ -99,9 +99,12 @@ namespace CalamityMod.NPCs.Ravager bool expertMode = Main.expertMode || malice; bool revenge = CalamityWorld.revenge || malice; bool death = CalamityWorld.death || malice; + bool enraged = calamityGlobalNPC.enraged > 0; - // Percent life remaining - float lifeRatio = npc.life / (float)npc.lifeMax; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; // Increase aggression if player is taking a long time to kill the boss if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) @@ -168,10 +171,6 @@ namespace CalamityMod.NPCs.Ravager bool immunePhase = headActive || rightClawActive || leftClawActive || rightLegActive || leftLegActive; bool finalPhase = !leftClawActive && !rightClawActive && !headActive && !leftLegActive && !rightLegActive && expertMode; - bool enrage = false; - if (player.position.Y + (player.height / 2) > npc.position.Y + (npc.height / 2) + 10f) - enrage = true; - if (immunePhase) { npc.dontTakeDamage = true; @@ -326,11 +325,11 @@ namespace CalamityMod.NPCs.Ravager npc.ai[1] += 1f; } - if ((!rightClawActive && !leftClawActive) || calamityGlobalNPC.enraged > 0) + if ((!rightClawActive && !leftClawActive) || enraged) npc.ai[1] += 1f; - if (!headActive || calamityGlobalNPC.enraged > 0) + if (!headActive || enraged) npc.ai[1] += 1f; - if ((!rightLegActive && !leftLegActive) || calamityGlobalNPC.enraged > 0) + if ((!rightLegActive && !leftLegActive) || enraged) npc.ai[1] += 1f; } @@ -342,7 +341,7 @@ namespace CalamityMod.NPCs.Ravager bool shouldFall = player.position.Y >= npc.Bottom.Y; float velocityXBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); - float velocityX = ((enrage || calamityGlobalNPC.enraged > 0) ? 8f : 4f) + velocityXBoost; + float velocityX = (enraged ? 8f : 4f) + velocityXBoost; velocityY = -16f; float distanceBelowTarget = npc.position.Y - (player.position.Y + 80f); @@ -552,7 +551,7 @@ namespace CalamityMod.NPCs.Ravager float velocityXBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); float velocityX = 8f + velocityXBoost + Math.Abs(npc.Center.X - player.Center.X) * 0.001f; - if (calamityGlobalNPC.enraged > 0) + if (enraged) velocityX += 3f; if (!rightClawActive) velocityX += 1f; @@ -637,7 +636,7 @@ namespace CalamityMod.NPCs.Ravager Vector2 vector11 = new Vector2(Main.npcTexture[npc.type].Width / 2, Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2); Vector2 vector = center - Main.screenPosition; vector -= new Vector2(ModContent.GetTexture("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Width, ModContent.GetTexture("CalamityMod/NPCs/Ravager/RavagerBodyGlow").Height / Main.npcFrameCount[npc.type]) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Color.Blue); spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/Ravager/RavagerBodyGlow"), vector, npc.frame, color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/Ravager/RavagerClawLeft.cs b/NPCs/Ravager/RavagerClawLeft.cs index 9e8d5770c0..55e9e95a87 100644 --- a/NPCs/Ravager/RavagerClawLeft.cs +++ b/NPCs/Ravager/RavagerClawLeft.cs @@ -43,7 +43,7 @@ namespace CalamityMod.NPCs.Ravager } if (BossRushEvent.BossRushActive) { - npc.lifeMax = 260000; + npc.lifeMax = 26000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -281,11 +281,6 @@ namespace CalamityMod.NPCs.Ravager return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 180, true); diff --git a/NPCs/Ravager/RavagerClawRight.cs b/NPCs/Ravager/RavagerClawRight.cs index 82f1800919..1d20291d29 100644 --- a/NPCs/Ravager/RavagerClawRight.cs +++ b/NPCs/Ravager/RavagerClawRight.cs @@ -43,7 +43,7 @@ namespace CalamityMod.NPCs.Ravager } if (BossRushEvent.BossRushActive) { - npc.lifeMax = 260000; + npc.lifeMax = 26000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -281,11 +281,6 @@ namespace CalamityMod.NPCs.Ravager return false; } - public override bool PreNPCLoot() - { - return false; - } - public override void OnHitPlayer(Player player, int damage, bool crit) { player.AddBuff(ModContent.BuffType(), 180, true); diff --git a/NPCs/Ravager/RavagerHead.cs b/NPCs/Ravager/RavagerHead.cs index 02a1fe8dcb..ac44e85e91 100644 --- a/NPCs/Ravager/RavagerHead.cs +++ b/NPCs/Ravager/RavagerHead.cs @@ -42,7 +42,7 @@ namespace CalamityMod.NPCs.Ravager } if (BossRushEvent.BossRushActive) { - npc.lifeMax = 450000; + npc.lifeMax = 45000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -51,9 +51,9 @@ namespace CalamityMod.NPCs.Ravager public override void AI() { bool provy = CalamityWorld.downedProvidence && !BossRushEvent.BossRushActive; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool death = CalamityWorld.death || malice; if (CalamityGlobalNPC.scavenger < 0 || !Main.npc[CalamityGlobalNPC.scavenger].active) { @@ -100,17 +100,11 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; - public override bool PreNPCLoot() - { - return 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 75e952bb5c..0b65ef701f 100644 --- a/NPCs/Ravager/RavagerHead2.cs +++ b/NPCs/Ravager/RavagerHead2.cs @@ -138,11 +138,6 @@ namespace CalamityMod.NPCs.Ravager num823 *= 1.25f; num824 *= 1.25f; } - if (BossRushEvent.BossRushActive) - { - num823 *= 1.5f; - num824 *= 1.5f; - } Vector2 vector82 = npc.Center; float distanceX = npc.ai[0] % 2f == 0f ? 480f : -480f; @@ -200,14 +195,8 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; - public override bool PreNPCLoot() - { - return false; - } + public override bool PreNPCLoot() => false; } } diff --git a/NPCs/Ravager/RavagerLegLeft.cs b/NPCs/Ravager/RavagerLegLeft.cs index 501459b908..4cc66e6863 100644 --- a/NPCs/Ravager/RavagerLegLeft.cs +++ b/NPCs/Ravager/RavagerLegLeft.cs @@ -40,7 +40,7 @@ namespace CalamityMod.NPCs.Ravager } if (BossRushEvent.BossRushActive) { - npc.lifeMax = 400000; + npc.lifeMax = 40000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -70,15 +70,7 @@ namespace CalamityMod.NPCs.Ravager npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(-70f, 88f); } - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return 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 cd84a025c3..0ef017fb54 100644 --- a/NPCs/Ravager/RavagerLegRight.cs +++ b/NPCs/Ravager/RavagerLegRight.cs @@ -40,7 +40,7 @@ namespace CalamityMod.NPCs.Ravager } if (BossRushEvent.BossRushActive) { - npc.lifeMax = 400000; + npc.lifeMax = 40000; } double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); @@ -70,15 +70,7 @@ namespace CalamityMod.NPCs.Ravager npc.Center = Main.npc[CalamityGlobalNPC.scavenger].Center + new Vector2(70f, 88f); } - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return 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 3a50b2914a..09f1be63ce 100644 --- a/NPCs/Ravager/RockPillar.cs +++ b/NPCs/Ravager/RockPillar.cs @@ -118,10 +118,9 @@ namespace CalamityMod.NPCs.Ravager } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; + + public override bool PreNPCLoot() => false; public override void OnHitPlayer(Player player, int damage, bool crit) { diff --git a/NPCs/Signus/CosmicLantern.cs b/NPCs/Signus/CosmicLantern.cs index 7c8ca41672..b0206589a0 100644 --- a/NPCs/Signus/CosmicLantern.cs +++ b/NPCs/Signus/CosmicLantern.cs @@ -105,14 +105,14 @@ namespace CalamityMod.NPCs.Signus color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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"); @@ -128,7 +128,7 @@ namespace CalamityMod.NPCs.Signus 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } diff --git a/NPCs/Signus/Signus.cs b/NPCs/Signus/Signus.cs index 30d743aaff..c2734c6dd4 100644 --- a/NPCs/Signus/Signus.cs +++ b/NPCs/Signus/Signus.cs @@ -42,10 +42,9 @@ namespace CalamityMod.NPCs.Signus npc.width = 130; npc.height = 130; npc.defense = 60; - bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel3; - npc.LifeMaxNERB(notDoGFight ? 224000 : 56000, notDoGFight ? 356400 : 87600, 2400000); + npc.LifeMaxNERB(notDoGFight ? 224000 : 56000, notDoGFight ? 356400 : 87600, 240000); // If fought alone, Signus plays his own theme if (notDoGFight) @@ -95,6 +94,7 @@ namespace CalamityMod.NPCs.Signus CalamityGlobalNPC.signus = npc.whoAmI; + bool enraged = calamityGlobalNPC.enraged > 0; bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; bool revenge = CalamityWorld.revenge || malice; @@ -111,13 +111,15 @@ namespace CalamityMod.NPCs.Signus 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; + float inertia = enraged ? 8f : malice ? 9f : death ? 10f : revenge ? 11f : expertMode ? 12f : 14f; + float chargeVelocity = enraged ? 18f : 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; - npc.damage = npc.defDamage; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + 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) @@ -202,13 +204,10 @@ namespace CalamityMod.NPCs.Signus if (phase3 || revenge) npc.knockBackResist = 0f; - float speed = malice ? 20f : revenge ? 15f : expertMode ? 14f : 12f; + float speed = enraged ? 24f : malice ? 20f : revenge ? 15f : expertMode ? 14f : 12f; if (expertMode) speed += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); - if (calamityGlobalNPC.enraged > 0) - speed += 3f; - float num795 = player.Center.X - vectorCenter.X; float num796 = player.Center.Y - vectorCenter.Y; float num797 = (float)Math.Sqrt(num795 * num795 + num796 * num796); @@ -239,7 +238,7 @@ namespace CalamityMod.NPCs.Signus { if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[1] += malice ? 1.5f : 1f; + npc.localAI[1] += enraged ? 2f : malice ? 1.5f : 1f; if (expertMode) npc.localAI[1] += death ? 3f * (float)(1D - lifeRatio) : 2f * (float)(1D - lifeRatio); @@ -413,10 +412,7 @@ namespace CalamityMod.NPCs.Signus { if (Main.netMode != NetmodeID.MultiplayerClient) { - float num1070 = 15f; - if (calamityGlobalNPC.enraged > 0) - num1070 += 3f; - + float num1070 = enraged ? 18f : 15f; float num1071 = player.Center.X - vectorCenter.X; float num1072 = player.Center.Y - vectorCenter.Y; float num1073 = (float)Math.Sqrt(num1071 * num1071 + num1072 * num1072); @@ -438,7 +434,7 @@ namespace CalamityMod.NPCs.Signus if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.975f; - npc.velocity.Y -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y -= death ? 0.12f : 0.1f; if (npc.velocity.Y > maxVelocityY) npc.velocity.Y = maxVelocityY; @@ -448,7 +444,7 @@ namespace CalamityMod.NPCs.Signus if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.975f; - npc.velocity.Y += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.Y += death ? 0.12f : 0.1f; if (npc.velocity.Y < -maxVelocityY) npc.velocity.Y = -maxVelocityY; @@ -459,7 +455,7 @@ namespace CalamityMod.NPCs.Signus if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; - npc.velocity.X -= BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X -= death ? 0.12f : 0.1f; if (npc.velocity.X > maxVelocityX) npc.velocity.X = maxVelocityX; @@ -470,7 +466,7 @@ namespace CalamityMod.NPCs.Signus if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; - npc.velocity.X += BossRushEvent.BossRushActive ? 0.2f : death ? 0.12f : 0.1f; + npc.velocity.X += death ? 0.12f : 0.1f; if (npc.velocity.X < -maxVelocityX) npc.velocity.X = -maxVelocityX; @@ -522,7 +518,7 @@ namespace CalamityMod.NPCs.Signus if (calamityGlobalNPC.newAI[0] == 0f) // Line up the charge { - float velocity = malice ? 18f : revenge ? 16f : expertMode ? 15f : 14f; + float velocity = enraged ? 20f : malice ? 18f : revenge ? 16f : expertMode ? 15f : 14f; if (expertMode) velocity += death ? 6f * (float)(1D - lifeRatio) : 4f * (float)(1D - lifeRatio); diff --git a/NPCs/Signus/SignusBomb.cs b/NPCs/Signus/SignusBomb.cs index 519e8bb1a6..fcb17a0a24 100644 --- a/NPCs/Signus/SignusBomb.cs +++ b/NPCs/Signus/SignusBomb.cs @@ -183,19 +183,21 @@ namespace CalamityMod.NPCs.Signus 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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 PreNPCLoot() => false; + public override bool CheckDead() { Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 14); diff --git a/NPCs/SlimeGod/SlimeGod.cs b/NPCs/SlimeGod/SlimeGod.cs index 0d1b8b3096..c934236acc 100644 --- a/NPCs/SlimeGod/SlimeGod.cs +++ b/NPCs/SlimeGod/SlimeGod.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.height = 92; npc.scale = 1.1f; npc.defense = 10; - npc.LifeMaxNERB(4650, 6400, 2200000); + npc.LifeMaxNERB(4650, 6400, 220000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -60,10 +60,13 @@ namespace CalamityMod.NPCs.SlimeGod CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); CalamityGlobalNPC.slimeGodPurple = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || npc.localAI[1] == 1f || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + Vector2 vector = npc.Center; float lifeRatio = npc.life / (float)npc.lifeMax; @@ -151,7 +154,7 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] += flag100 ? 1f : 2f; + npc.localAI[0] += enraged ? 6f : flag100 ? 1f : 2f; if (revenge) npc.localAI[0] += 0.5f; @@ -160,7 +163,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.localAI[0] = 0f; if (expertMode && Main.rand.NextBool(2)) { - float num179 = BossRushEvent.BossRushActive ? 16f : 8f; + float num179 = 8f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -189,7 +192,7 @@ namespace CalamityMod.NPCs.SlimeGod } else { - float num179 = BossRushEvent.BossRushActive ? 16f : 8f; + float num179 = 8f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -241,7 +244,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.velocity.X *= 0.8f; npc.ai[1] += flag100 ? 1f : 2f; float num1879 = 60f; - float num1880 = BossRushEvent.BossRushActive ? 12f : death ? 3.5f : revenge ? 3f : expertMode ? 2.5f : 2f; + float num1880 = death ? 3.5f : revenge ? 3f : expertMode ? 2.5f : 2f; if (revenge) { float moveBoost = death ? 80f * (1f - lifeRatio) : 40f * (1f - lifeRatio); @@ -297,7 +300,7 @@ namespace CalamityMod.NPCs.SlimeGod case 1: npc.ai[0] = 3f; npc.noTileCollide = true; - npc.velocity.Y = BossRushEvent.BossRushActive ? -16f : death ? -9f : revenge ? -8f : expertMode ? -7f : -6f; + npc.velocity.Y = death ? -9f : revenge ? -8f : expertMode ? -7f : -6f; break; case 2: npc.ai[0] = 5f; @@ -345,7 +348,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += 1f; vector272 = player.Center - vector; vector272.Normalize(); - vector272 *= BossRushEvent.BossRushActive ? 16f : death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; + vector272 *= death ? 9f : revenge ? 8f : expertMode ? 7f : 6f; npc.velocity = (npc.velocity * 4f + vector272) / 5f; if (npc.ai[1] > 12f) { @@ -364,7 +367,7 @@ namespace CalamityMod.NPCs.SlimeGod return; } vector272.Normalize(); - vector272 *= (BossRushEvent.BossRushActive ? 18f : death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; + vector272 *= (death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; npc.velocity = (npc.velocity * 5f + vector272) / 6f; } } @@ -397,7 +400,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.noGravity = true; } npc.velocity.Y += 0.2f; - float velocityLimit = BossRushEvent.BossRushActive ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; + float velocityLimit = death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; @@ -431,7 +434,7 @@ namespace CalamityMod.NPCs.SlimeGod if (value74.Length() > 100f) { value74.Normalize(); - value74 *= (BossRushEvent.BossRushActive ? 20f : death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; + value74 *= (death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost; } npc.velocity = (npc.velocity * 4f + value74) / 5f; return; @@ -475,14 +478,14 @@ namespace CalamityMod.NPCs.SlimeGod { npc.velocity.Y -= 2f; } - npc.velocity.X = ((BossRushEvent.BossRushActive ? 20f : death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost) * npc.direction; + npc.velocity.X = ((death ? 11f : revenge ? 10f : expertMode ? 9f : 8f) + distanceSpeedBoost) * npc.direction; npc.ai[2] += 1f; } } else { npc.velocity.X *= 0.98f; - float velocityLimit = (BossRushEvent.BossRushActive ? 12f : 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; diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 32e4e716fb..d88d886bc5 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -40,7 +40,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.width = 44; npc.height = 44; npc.defense = 6; - npc.LifeMaxNERB(2000, 2500, 2500000); + npc.LifeMaxNERB(2000, 2500, 250000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); NPCID.Sets.TrailCacheLength[npc.type] = 8; @@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.SlimeGod aiType = -1; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 8, 0, 0); - npc.alpha = 55; + npc.Opacity = 0.8f; npc.boss = true; npc.noGravity = true; npc.noTileCollide = true; @@ -89,10 +89,12 @@ namespace CalamityMod.NPCs.SlimeGod CalamityGlobalNPC.slimeGod = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -265,8 +267,9 @@ namespace CalamityMod.NPCs.SlimeGod { npc.velocity = Vector2.Zero; - if (npc.alpha < 255) - npc.alpha += 5; + npc.Opacity -= 0.2f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; } bool slimeDead = false; @@ -306,8 +309,9 @@ namespace CalamityMod.NPCs.SlimeGod return; } - if (npc.alpha > 55) - npc.alpha -= 5; + npc.Opacity += 0.2f; + if (npc.Opacity > 0.8f) + npc.Opacity = 0.8f; buffedSlime = 0; } @@ -326,10 +330,10 @@ namespace CalamityMod.NPCs.SlimeGod npc.rotation = npc.velocity.X * 0.1f; // Set teleport location, turn invisible, spin direction - npc.alpha += 20; - if (npc.alpha >= 255) + npc.Opacity -= 0.2f; + if (npc.Opacity <= 0f) { - npc.alpha = 255; + npc.Opacity = 0f; npc.velocity.Normalize(); int teleportX = player.velocity.X < 0f ? -20 : 20; @@ -349,17 +353,17 @@ namespace CalamityMod.NPCs.SlimeGod npc.rotation = npc.velocity.X * 0.1f; // Teleport to location - if (npc.alpha == 255) + 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.alpha -= 20; - if (npc.alpha < 55) + npc.Opacity += 0.2f; + if (npc.Opacity >= 0.8f) { - npc.alpha = 55; + npc.Opacity = 0.8f; npc.localAI[0] = vectorCenter.X - player.Center.X < 0 ? 1f : -1f; npc.localAI[1] = 2f; } @@ -392,7 +396,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[3] = 0f; npc.localAI[0] = 0f; npc.localAI[1] = 0f; - float chargeVelocity = BossRushEvent.BossRushActive ? 18f : death ? 12f : 9f; + float chargeVelocity = death ? 12f : 9f; npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * chargeVelocity; npc.TargetClosest(); return; @@ -400,14 +404,12 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - float divisor = malice ? 10f : 15f; + float divisor = enraged ? 5f : malice ? 10f : 15f; if (npc.ai[1] % divisor == 0f && Vector2.Distance(player.Center, vectorCenter) > 160f) { if (expertMode && Main.rand.NextBool(2)) { float num179 = revenge ? 2f : 3f; - if (BossRushEvent.BossRushActive) - num179 = 12f; 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; @@ -432,8 +434,6 @@ namespace CalamityMod.NPCs.SlimeGod else { float num179 = revenge ? 6f : 5f; - if (BossRushEvent.BossRushActive) - num179 = 12f; 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; @@ -465,13 +465,11 @@ namespace CalamityMod.NPCs.SlimeGod { if (Main.netMode != NetmodeID.MultiplayerClient && Vector2.Distance(player.Center, vectorCenter) > 160f) { - if (npc.ai[1] % 40f == 0f) + if (npc.ai[1] % (enraged ? 20f : 40f) == 0f) { if (expertMode && Main.rand.NextBool(2)) { float num179 = revenge ? 2f : 3f; - if (BossRushEvent.BossRushActive) - num179 = 12f; 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; @@ -496,8 +494,6 @@ namespace CalamityMod.NPCs.SlimeGod else { float num179 = revenge ? 6f : 5f; - if (BossRushEvent.BossRushActive) - num179 = 12f; 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; @@ -534,11 +530,11 @@ namespace CalamityMod.NPCs.SlimeGod { num1372 = revenge ? 18f : expertMode ? 16f : 14f; } - if (BossRushEvent.BossRushActive || player.gravDir == -1f) + if (player.gravDir == -1f) { num1372 = 22f; } - if (calamityGlobalNPC.enraged > 0 || player.gravDir == -1f) + if (enraged || player.gravDir == -1f) { num1372 += 8f; } @@ -652,7 +648,6 @@ namespace CalamityMod.NPCs.SlimeGod // This loot code is shared with every other Slime God component. public static void DropSlimeGodLoot(NPC npc) { - CalamityMod mod = ModContent.GetInstance(); DropHelper.DropBags(npc); DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); @@ -684,7 +679,8 @@ namespace CalamityMod.NPCs.SlimeGod DropHelper.WeightStack(w), DropHelper.WeightStack(w), DropHelper.WeightStack(w), - DropHelper.WeightStack(w) + DropHelper.WeightStack(w), + DropHelper.WeightStack(w) ); // Vanity diff --git a/NPCs/SlimeGod/SlimeGodRun.cs b/NPCs/SlimeGod/SlimeGodRun.cs index a1ca39f66d..45a09f2b30 100644 --- a/NPCs/SlimeGod/SlimeGodRun.cs +++ b/NPCs/SlimeGod/SlimeGodRun.cs @@ -30,7 +30,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.height = 92; npc.scale = 1.1f; npc.defense = 12; - npc.LifeMaxNERB(4150, 5700, 1600000); + npc.LifeMaxNERB(4150, 5700, 160000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -63,11 +63,14 @@ namespace CalamityMod.NPCs.SlimeGod CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); CalamityGlobalNPC.slimeGodRed = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || npc.localAI[1] == 1f || malice; - Vector2 vector = npc.Center; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + Vector2 vector = npc.Center; float lifeRatio = npc.life / (float)npc.lifeMax; @@ -161,7 +164,7 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] += flag100 ? 1f : 2f; + npc.localAI[0] += enraged ? 6f : flag100 ? 1f : 2f; if (revenge) npc.localAI[0] += 0.5f; @@ -171,8 +174,6 @@ namespace CalamityMod.NPCs.SlimeGod if (expertMode && Main.rand.NextBool(2)) { float num179 = revenge ? 9f : 8f; - if (BossRushEvent.BossRushActive) - num179 *= 1.5f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -202,8 +203,6 @@ namespace CalamityMod.NPCs.SlimeGod else { float num179 = revenge ? 9f : 8f; - if (BossRushEvent.BossRushActive) - num179 *= 1.5f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -254,7 +253,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.velocity.X *= 0.8f; npc.ai[1] += 1f; float num1879 = 50f; - float num1880 = BossRushEvent.BossRushActive ? 16f : death ? 4.5f : revenge ? 4f : expertMode ? 3.5f : 3f; + float num1880 = death ? 4.5f : revenge ? 4f : expertMode ? 3.5f : 3f; if (revenge) { float moveBoost = death ? 60f * (1f - lifeRatio) : 30f * (1f - lifeRatio); @@ -310,7 +309,7 @@ namespace CalamityMod.NPCs.SlimeGod case 1: npc.ai[0] = 3f; npc.noTileCollide = true; - npc.velocity.Y = BossRushEvent.BossRushActive ? -18f : death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; + npc.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; break; case 2: npc.ai[0] = 5f; @@ -357,7 +356,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += 1f; vector272 = player.Center - vector; vector272.Normalize(); - vector272 *= BossRushEvent.BossRushActive ? 18f : death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; + vector272 *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; npc.velocity = (npc.velocity * 4f + vector272) / 5f; if (npc.ai[1] > 12f) { @@ -378,7 +377,7 @@ namespace CalamityMod.NPCs.SlimeGod return; } vector272.Normalize(); - vector272 *= (BossRushEvent.BossRushActive ? 20f : death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; npc.velocity = (npc.velocity * 5f + vector272) / 6f; } } @@ -411,7 +410,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.noGravity = true; } npc.velocity.Y += 0.2f; - float velocityLimit = BossRushEvent.BossRushActive ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; + float velocityLimit = death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; @@ -445,7 +444,7 @@ namespace CalamityMod.NPCs.SlimeGod if (value74.Length() > 100f) { value74.Normalize(); - value74 *= (BossRushEvent.BossRushActive ? 22f : 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; @@ -489,14 +488,14 @@ namespace CalamityMod.NPCs.SlimeGod { npc.velocity.Y -= 2f; } - npc.velocity.X = ((BossRushEvent.BossRushActive ? 22f : death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; + 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 = (BossRushEvent.BossRushActive ? 12f : 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; diff --git a/NPCs/SlimeGod/SlimeGodRunSplit.cs b/NPCs/SlimeGod/SlimeGodRunSplit.cs index 0a0334067b..e549251fd3 100644 --- a/NPCs/SlimeGod/SlimeGodRunSplit.cs +++ b/NPCs/SlimeGod/SlimeGodRunSplit.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { npc.Calamity().canBreakPlayerDefense = true; - npc.LifeMaxNERB(875, 1205, 800000); + npc.LifeMaxNERB(875, 1205, 80000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.GetNPCDamage(); @@ -65,11 +65,14 @@ namespace CalamityMod.NPCs.SlimeGod if (CalamityGlobalNPC.slimeGodRed < 0 || !Main.npc[CalamityGlobalNPC.slimeGodRed].active) CalamityGlobalNPC.slimeGodRed = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || npc.localAI[1] == 1f || malice; - Vector2 vector = npc.Center; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + Vector2 vector = npc.Center; float lifeRatio = npc.life / (float)npc.lifeMax; @@ -146,7 +149,7 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] += flag100 ? 0.5f : 1f; + npc.localAI[0] += enraged ? 3f : flag100 ? 0.5f : 1f; if (revenge) npc.localAI[0] += 0.5f; @@ -156,8 +159,6 @@ namespace CalamityMod.NPCs.SlimeGod if (expertMode && Main.rand.NextBool(2)) { float num179 = revenge ? 9f : 8f; - if (BossRushEvent.BossRushActive) - num179 *= 1.5f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -184,8 +185,6 @@ namespace CalamityMod.NPCs.SlimeGod else { float num179 = revenge ? 9f : 8f; - if (BossRushEvent.BossRushActive) - num179 *= 1.5f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -235,7 +234,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.velocity.X *= 0.8f; npc.ai[1] += 1f; float num1879 = 35f; - float num1880 = BossRushEvent.BossRushActive ? 20f : death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f; + float num1880 = death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f; if (revenge) { float moveBoost = death ? 14f * (1f - lifeRatio) : 7f * (1f - lifeRatio); @@ -286,7 +285,7 @@ namespace CalamityMod.NPCs.SlimeGod case 1: npc.ai[0] = 3f; npc.noTileCollide = true; - npc.velocity.Y = BossRushEvent.BossRushActive ? -20f : death ? -11f : revenge ? -10f : expertMode ? -9f : -8f; + npc.velocity.Y = death ? -11f : revenge ? -10f : expertMode ? -9f : -8f; break; case 2: npc.ai[0] = 5f; @@ -333,7 +332,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += 1f; vector272 = player.Center - vector; vector272.Normalize(); - vector272 *= BossRushEvent.BossRushActive ? 20f : death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; + vector272 *= death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; npc.velocity = (npc.velocity * 4f + vector272) / 5f; if (npc.ai[1] > 12f) { @@ -353,7 +352,7 @@ namespace CalamityMod.NPCs.SlimeGod return; } vector272.Normalize(); - vector272 *= (BossRushEvent.BossRushActive ? 22f : death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; + vector272 *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; npc.velocity = (npc.velocity * 5f + vector272) / 6f; } } @@ -385,7 +384,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.noGravity = true; } npc.velocity.Y += 0.2f; - float velocityLimit = BossRushEvent.BossRushActive ? 22f : death ? 16f : revenge ? 15f : expertMode ? 14f : 13f; + float velocityLimit = death ? 16f : revenge ? 15f : expertMode ? 14f : 13f; if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; @@ -419,7 +418,7 @@ namespace CalamityMod.NPCs.SlimeGod if (value74.Length() > 50f) { value74.Normalize(); - value74 *= (BossRushEvent.BossRushActive ? 22f : 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; @@ -463,14 +462,14 @@ namespace CalamityMod.NPCs.SlimeGod { npc.velocity.Y -= 2f; } - npc.velocity.X = ((BossRushEvent.BossRushActive ? 22f : death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; + 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 = (BossRushEvent.BossRushActive ? 12f : death ? 7f : revenge ? 6f : expertMode ? 5f : 4f) + distanceSpeedBoost; + float velocityLimit = (death ? 7f : revenge ? 6f : expertMode ? 5f : 4f) + distanceSpeedBoost; if (npc.direction < 0 && npc.velocity.X > -velocityLimit) { npc.velocity.X = -velocityLimit; diff --git a/NPCs/SlimeGod/SlimeGodSplit.cs b/NPCs/SlimeGod/SlimeGodSplit.cs index a1f673ecd6..190827cb5c 100644 --- a/NPCs/SlimeGod/SlimeGodSplit.cs +++ b/NPCs/SlimeGod/SlimeGodSplit.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.SlimeGod public override void SetDefaults() { npc.Calamity().canBreakPlayerDefense = true; - npc.LifeMaxNERB(1350, 1800, 1100000); + npc.LifeMaxNERB(1350, 1800, 110000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.GetNPCDamage(); @@ -65,11 +65,14 @@ namespace CalamityMod.NPCs.SlimeGod if (CalamityGlobalNPC.slimeGodPurple < 0 || !Main.npc[CalamityGlobalNPC.slimeGodPurple].active) CalamityGlobalNPC.slimeGodPurple = npc.whoAmI; - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || npc.localAI[1] == 1f || malice; - Vector2 vector = npc.Center; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || npc.localAI[1] == 1f || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + + Vector2 vector = npc.Center; float lifeRatio = npc.life / (float)npc.lifeMax; @@ -140,7 +143,7 @@ namespace CalamityMod.NPCs.SlimeGod if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] += flag100 ? 0.5f : 1f; + npc.localAI[0] += enraged ? 3f : flag100 ? 0.5f : 1f; if (revenge) npc.localAI[0] += 0.5f; @@ -149,7 +152,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.localAI[0] = 0f; if (expertMode && Main.rand.NextBool(2)) { - float num179 = BossRushEvent.BossRushActive ? 16f : 8f; + float num179 = 8f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -175,7 +178,7 @@ namespace CalamityMod.NPCs.SlimeGod } else { - float num179 = BossRushEvent.BossRushActive ? 16f : 8f; + float num179 = 8f; Vector2 value9 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); float num180 = player.position.X + (float)player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -228,7 +231,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.velocity.X *= 0.8f; npc.ai[1] += flag100 ? 1f : 2f; float num1879 = 40f; - float num1880 = BossRushEvent.BossRushActive ? 15f : death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f; + float num1880 = death ? 5.5f : revenge ? 5f : expertMode ? 4.5f : 4f; if (revenge) { float moveBoost = death ? 20f * (1f - lifeRatio) : 10f * (1f - lifeRatio); @@ -278,7 +281,7 @@ namespace CalamityMod.NPCs.SlimeGod case 1: npc.ai[0] = 3f; npc.noTileCollide = true; - npc.velocity.Y = BossRushEvent.BossRushActive ? -18f : death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; + npc.velocity.Y = death ? -10f : revenge ? -9f : expertMode ? -8f : -7f; break; case 2: npc.ai[0] = 5f; @@ -326,7 +329,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.ai[1] += 1f; vector272 = player.Center - vector; vector272.Normalize(); - vector272 *= BossRushEvent.BossRushActive ? 18f : death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; + vector272 *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; npc.velocity = (npc.velocity * 4f + vector272) / 5f; if (npc.ai[1] > 12f) { @@ -346,7 +349,7 @@ namespace CalamityMod.NPCs.SlimeGod return; } vector272.Normalize(); - vector272 *= (BossRushEvent.BossRushActive ? 20f : death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; + vector272 *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; npc.velocity = (npc.velocity * 5f + vector272) / 6f; } } @@ -378,7 +381,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.noGravity = true; } npc.velocity.Y += 0.2f; - float velocityLimit = BossRushEvent.BossRushActive ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; + float velocityLimit = death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; if (npc.velocity.Y > velocityLimit) { npc.velocity.Y = velocityLimit; @@ -412,7 +415,7 @@ namespace CalamityMod.NPCs.SlimeGod if (value74.Length() > 50f) { value74.Normalize(); - value74 *= (BossRushEvent.BossRushActive ? 22f : 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; @@ -456,14 +459,14 @@ namespace CalamityMod.NPCs.SlimeGod { npc.velocity.Y -= 2f; } - npc.velocity.X = ((BossRushEvent.BossRushActive ? 22f : death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost) * npc.direction; + 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 = (BossRushEvent.BossRushActive ? 12f : 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; diff --git a/NPCs/SlimeGod/SlimeSpawnCorrupt.cs b/NPCs/SlimeGod/SlimeSpawnCorrupt.cs index f16310e06a..f18304783f 100644 --- a/NPCs/SlimeGod/SlimeSpawnCorrupt.cs +++ b/NPCs/SlimeGod/SlimeSpawnCorrupt.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.lifeMax = 180; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 100000; + npc.lifeMax = 10000; } npc.knockBackResist = 0f; animationType = 121; @@ -37,12 +37,9 @@ namespace CalamityMod.NPCs.SlimeGod npc.DeathSound = SoundID.NPCDeath1; } - public override bool PreNPCLoot() - { - return 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) { diff --git a/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs b/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs index 89b4f74a41..a8a73973e2 100644 --- a/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs +++ b/NPCs/SlimeGod/SlimeSpawnCorrupt2.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.lifeMax = 90; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 50000; + npc.lifeMax = 5000; } npc.knockBackResist = 0f; animationType = NPCID.CorruptSlime; diff --git a/NPCs/SlimeGod/SlimeSpawnCrimson.cs b/NPCs/SlimeGod/SlimeSpawnCrimson.cs index 6a7aeefb17..b65ef0b378 100644 --- a/NPCs/SlimeGod/SlimeSpawnCrimson.cs +++ b/NPCs/SlimeGod/SlimeSpawnCrimson.cs @@ -23,7 +23,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.lifeMax = 110; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 100000; + npc.lifeMax = 10000; } npc.knockBackResist = 0f; animationType = NPCID.CorruptSlime; diff --git a/NPCs/SlimeGod/SlimeSpawnCrimson2.cs b/NPCs/SlimeGod/SlimeSpawnCrimson2.cs index ada5e1b3a5..e872db3e4e 100644 --- a/NPCs/SlimeGod/SlimeSpawnCrimson2.cs +++ b/NPCs/SlimeGod/SlimeSpawnCrimson2.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.SlimeGod npc.lifeMax = 130; if (BossRushEvent.BossRushActive) { - npc.lifeMax = 120000; + npc.lifeMax = 12000; } npc.knockBackResist = 0f; animationType = NPCID.CorruptSlime; diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index 054efa6046..0e1b456c93 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.StormWeaver global.DR = 0.999999f; global.unbreakableDR = true; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 170000); + npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); // If fought alone, Storm Weaver plays its own theme if (notDoGFight) @@ -66,11 +66,6 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - if (npc.defense < 99999 && (CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2)) - npc.defense = 99999; - else - npc.defense = 0; - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.2f, 0.05f, 0.2f); if (npc.ai[2] > 0f) { @@ -194,7 +189,6 @@ namespace CalamityMod.NPCs.StormWeaver projectile.penetrate = 1; } } - } public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/StormWeaver/StormWeaverBodyNaked.cs b/NPCs/StormWeaver/StormWeaverBodyNaked.cs index 5b7bda7f08..61728c5214 100644 --- a/NPCs/StormWeaver/StormWeaverBodyNaked.cs +++ b/NPCs/StormWeaver/StormWeaverBodyNaked.cs @@ -26,12 +26,12 @@ namespace CalamityMod.NPCs.StormWeaver npc.npcSlots = 5f; npc.width = 40; npc.height = 40; - npc.lifeMax = 100000; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 585000 : 97500, notDoGFight ? 585000 : 97500, 3500000); + npc.lifeMax = notDoGFight ? 760500 : 126750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); // If fought alone, Storm Weaver plays its own theme - if (notDoGFight) + if (notDoGFight) music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; // If fought as a DoG interlude, keep the DoG music playing else @@ -80,8 +80,6 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - bool expertMode = Main.expertMode; - if (invinceTime > 0) { invinceTime--; @@ -97,9 +95,7 @@ namespace CalamityMod.NPCs.StormWeaver 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]; - } bool flag = false; if (npc.ai[1] <= 0f) @@ -128,11 +124,10 @@ namespace CalamityMod.NPCs.StormWeaver Main.dust[num935].noLight = true; } } + npc.alpha -= 42; if (npc.alpha < 0) - { npc.alpha = 0; - } } Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -144,6 +139,7 @@ namespace CalamityMod.NPCs.StormWeaver 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) { @@ -155,7 +151,8 @@ namespace CalamityMod.NPCs.StormWeaver } catch { } - npc.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; + + npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; num193 = (num193 - num194) / num193; @@ -164,14 +161,11 @@ namespace CalamityMod.NPCs.StormWeaver 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; - } } } @@ -201,14 +195,14 @@ namespace CalamityMod.NPCs.StormWeaver 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor); if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) @@ -243,17 +237,22 @@ namespace CalamityMod.NPCs.StormWeaver public override void HitEffect(int hitDirection, double damage) { - if (npc.life <= 0) + for (int k = 0; k < 3; k++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); + + if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeBody3"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; npc.position.X = npc.position.X - (npc.width / 2); npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); @@ -264,6 +263,7 @@ namespace CalamityMod.NPCs.StormWeaver Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int num623 = 0; num623 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 3f); diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 5f5689cbf6..7b7a42732c 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.StormWeaver global.DR = 0.999999f; global.unbreakableDR = true; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 170000); + npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); // If fought alone, Storm Weaver plays its own theme if (notDoGFight) @@ -80,18 +80,13 @@ namespace CalamityMod.NPCs.StormWeaver public override void AI() { - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - if (npc.defense < 99999 && (CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2)) - { - npc.defense = 99999; - } - else - { - npc.defense = 0; - } + bool enraged = npc.Calamity().enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; + if (!Main.raining && !BossRushEvent.BossRushActive && CalamityWorld.DoGSecondStageCountdown <= 0) { CalamityUtils.StartRain(); @@ -177,11 +172,7 @@ namespace CalamityMod.NPCs.StormWeaver BoltCountdown--; if (BoltCountdown == 0) { - int speed2 = revenge ? 8 : 7; - if (npc.Calamity().enraged > 0) - { - speed2 += 1; - } + int speed2 = enraged ? 10 : revenge ? 8 : 7; float spawnX2 = Main.rand.Next(2001) - 1000f + Main.player[npc.target].Center.X; float spawnY2 = -1000f + Main.player[npc.target].Center.Y; Vector2 baseSpawn = new Vector2(spawnX2, spawnY2); @@ -306,8 +297,8 @@ namespace CalamityMod.NPCs.StormWeaver } else { - num188 = malice ? 13f : revenge ? 11f : 10f; - num189 = malice ? 0.38f : revenge ? 0.31f : 0.28f; + num188 = enraged ? 15f : malice ? 13f : revenge ? 11f : 10f; + num189 = enraged ? 0.45f : malice ? 0.38f : revenge ? 0.31f : 0.28f; } float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; @@ -531,12 +522,9 @@ namespace CalamityMod.NPCs.StormWeaver return true; } - public override bool PreNPCLoot() - { - return false; - } + public override bool PreNPCLoot() => false; - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); } diff --git a/NPCs/StormWeaver/StormWeaverHeadNaked.cs b/NPCs/StormWeaver/StormWeaverHeadNaked.cs index c3d5bdc675..de834511bd 100644 --- a/NPCs/StormWeaver/StormWeaverHeadNaked.cs +++ b/NPCs/StormWeaver/StormWeaverHeadNaked.cs @@ -3,6 +3,7 @@ using CalamityMod.Events; using CalamityMod.Items.Armor.Vanity; using CalamityMod.Items.LoreItems; using CalamityMod.Items.Materials; +using CalamityMod.Items.Pets; using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; @@ -16,18 +17,24 @@ using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.StormWeaver { [AutoloadBossHead] public class StormWeaverHeadNaked : ModNPC { - private const float BoltAngleSpread = 280; + private const float BoltAngleSpread = 280; private const float speed = 13f; private const float turnSpeed = 0.35f; private bool tail = false; private int invinceTime = 180; - public override void SetStaticDefaults() + // Lightning flash variables + public float lightning = 0f; + private float lightningDecay = 1f; + private float lightningSpeed = 0f; + + public override void SetStaticDefaults() { DisplayName.SetDefault("Storm Weaver"); NPCID.Sets.TrailingMode[npc.type] = 1; @@ -41,10 +48,11 @@ namespace CalamityMod.NPCs.StormWeaver npc.width = 74; npc.height = 74; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 585000 : 97500, notDoGFight ? 585000 : 97500, 3500000); + npc.lifeMax = notDoGFight ? 760500 : 126750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - // 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(0, 35, 0, 0); music = CalamityMod.Instance.GetMusicFromMusicMod("Weaver") ?? MusicID.Boss3; @@ -100,10 +108,12 @@ namespace CalamityMod.NPCs.StormWeaver { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); - bool malice = CalamityWorld.malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && malice) || enraged; if (invinceTime > 0) { @@ -117,35 +127,30 @@ namespace CalamityMod.NPCs.StormWeaver npc.dontTakeDamage = false; } - if (!Main.raining && !BossRushEvent.BossRushActive && CalamityWorld.DoGSecondStageCountdown <= 0) - { + if (!Main.raining) CalamityUtils.StartRain(); - } - double lifeRatio = npc.life / (double)npc.lifeMax; + float lifeRatio = npc.life / (float)npc.lifeMax; // Increase aggression if player is taking a long time to kill the boss if (lifeRatio > calamityGlobalNPC.killTimeRatio_IncreasedAggression) lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; - int lifePercentage = (int)(100.0 * lifeRatio); + // Start charging at the target + bool phase2 = lifeRatio < 0.7f; - int BoltProjectiles = 2; - if (lifePercentage < 33 || death) - { - BoltProjectiles = 4; - } - else if (lifePercentage < 66) - { - BoltProjectiles = 3; - } + // Lightning strike flash phase + bool phase3 = lifeRatio < 0.4f; + + // Become weak and cancel the storm + bool phase4 = npc.life / (float)npc.lifeMax < 0.05f; + + 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) @@ -167,9 +172,7 @@ namespace CalamityMod.NPCs.StormWeaver npc.alpha -= 12; if (npc.alpha < 0) - { npc.alpha = 0; - } if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -198,9 +201,9 @@ namespace CalamityMod.NPCs.StormWeaver tail = true; } - if (expertMode) + if (expertMode && !phase4) { - npc.localAI[0] += malice ? 1.5f : 1f; + npc.localAI[0] += enraged ? 2f : malice ? 1.5f : 1f; if (npc.localAI[0] >= 450f) { npc.localAI[0] = 0f; @@ -224,11 +227,11 @@ namespace CalamityMod.NPCs.StormWeaver npc.localAI[1] = 0f; calamityGlobalNPC.newAI[0] = 0f; npc.TargetClosest(false); + npc.velocity.Y = npc.velocity.Y - 10f; if ((double)npc.position.Y < Main.topWorld + 16f) - { npc.velocity.Y = npc.velocity.Y - 10f; - } + if ((double)npc.position.Y < Main.topWorld + 16f) { CalamityWorld.DoGSecondStageCountdown = 0; @@ -239,7 +242,7 @@ namespace CalamityMod.NPCs.StormWeaver netMessage.Write(CalamityWorld.DoGSecondStageCountdown); netMessage.Send(); } - for (int num957 = 0; num957 < 200; num957++) + for (int num957 = 0; num957 < Main.maxNPCs; num957++) { if (Main.npc[num957].active && (Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType() @@ -261,7 +264,7 @@ namespace CalamityMod.NPCs.StormWeaver netMessage.Write(CalamityWorld.DoGSecondStageCountdown); netMessage.Send(); } - for (int num957 = 0; num957 < 200; num957++) + for (int num957 = 0; num957 < Main.maxNPCs; num957++) { if (Main.npc[num957].type == ModContent.NPCType() || Main.npc[num957].type == ModContent.NPCType() @@ -273,77 +276,77 @@ namespace CalamityMod.NPCs.StormWeaver } if (npc.velocity.X < 0f) - { npc.spriteDirection = -1; - } else if (npc.velocity.X > 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); - float num188 = malice ? 15f : revenge ? 13f : 12f; - float num189 = malice ? 0.36f : revenge ? 0.31f : 0.28f; + float num188 = enraged ? 17f : malice ? 15f : revenge ? 13f : 12f; + float num189 = enraged ? 0.41f : malice ? 0.36f : revenge ? 0.31f : 0.28f; - calamityGlobalNPC.newAI[0] += 1f; - if (calamityGlobalNPC.newAI[0] >= 400f) + // Start charging at the player when in phase 2 + if (phase2 && !phase4) { - if (npc.localAI[1] == 0f) - npc.localAI[1] = 1f; - - if (calamityGlobalNPC.newAI[0] >= 500f) + calamityGlobalNPC.newAI[0] += 1f; + if (calamityGlobalNPC.newAI[0] >= 400f) { - npc.TargetClosest(); - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - } + if (npc.localAI[1] == 0f) + npc.localAI[1] = 1f; - if (revenge) - { - if (npc.localAI[1] == 2f) + if (calamityGlobalNPC.newAI[0] >= 500f) { - num188 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.01f * (1f - (float)lifeRatio); - num189 += Vector2.Distance(Main.player[npc.target].Center, npc.Center) * 0.0001f * (1f - (float)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; - } - } + npc.TargetClosest(); + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] = 0f; } - int dustAmt = 5; - for (int num1474 = 0; num1474 < dustAmt; num1474++) + if (revenge) { - 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; + 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; + } + } + } + + 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); } - else if (revenge) - calamityGlobalNPC.newAI[0] += malice ? 4f : death ? 2f : 2f * (float)(1D - lifeRatio); float num48 = num188 * 1.3f; float num49 = num188 * 0.7f; @@ -362,48 +365,72 @@ namespace CalamityMod.NPCs.StormWeaver } } - if (npc.localAI[1] == 1f) + if (phase2 && !phase4) { - npc.localAI[1] = 2f; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)Main.player[npc.target].Center.X, (int)Main.player[npc.target].Center.Y); - - if (Main.netMode != NetmodeID.MultiplayerClient) + if (npc.localAI[1] == 1f) { - int speed2 = revenge ? 8 : 7; - if (npc.Calamity().enraged > 0) + // 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) { - speed2 += 1; + 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); + + 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; + } + } } - 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++) + else + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/LightningStrike"), (int)soundCenter.X, (int)soundCenter.Y); + + npc.localAI[1] = 2f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { - Vector2 source = baseSpawn; - source.X += i * 30 - (BoltProjectiles * 15); - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-BoltAngleSpread / 2 + (BoltAngleSpread * i / BoltProjectiles))); - velocity.X = velocity.X + 3 * 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); + int speed2 = enraged ? 10 : 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); + } } + + 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; + + npc.localAI[2] = chargeDirection; } - - 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 * (1f - (float)lifeRatio)) * 2f; - - float chargeDirection = 0; - if (npc.velocity.X < 0f) - chargeDirection = -1f; - else if (npc.velocity.X > 0f) - chargeDirection = 1f; - - npc.localAI[2] = chargeDirection; } num191 = (int)(num191 / 16f) * 16; @@ -418,6 +445,7 @@ namespace CalamityMod.NPCs.StormWeaver 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) @@ -427,10 +455,9 @@ namespace CalamityMod.NPCs.StormWeaver 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; @@ -438,31 +465,23 @@ namespace CalamityMod.NPCs.StormWeaver 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 - } + npc.velocity.X = npc.velocity.X + num189 * 2f; else - { - npc.velocity.X = npc.velocity.X - num189 * 2f; //changed from 2 - } + npc.velocity.X = npc.velocity.X - num189 * 2f; } } else @@ -470,50 +489,70 @@ namespace CalamityMod.NPCs.StormWeaver if (num196 > num197) { if (npc.velocity.X < num191) - { - npc.velocity.X = npc.velocity.X + num189 * 1.1f; //changed from 1.1 - } + npc.velocity.X = npc.velocity.X + num189 * 1.1f; else if (npc.velocity.X > num191) - { - npc.velocity.X = npc.velocity.X - num189 * 1.1f; //changed from 1.1 - } + npc.velocity.X = 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 = 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; - } + + 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; + } + + // 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; + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -541,14 +580,14 @@ namespace CalamityMod.NPCs.StormWeaver 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor); if (npc.Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) @@ -579,19 +618,20 @@ namespace CalamityMod.NPCs.StormWeaver 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.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeHead2"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; npc.position.X = npc.position.X - (npc.width / 2); npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); @@ -602,6 +642,7 @@ namespace CalamityMod.NPCs.StormWeaver Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int num623 = 0; num623 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 3f); @@ -615,13 +656,12 @@ namespace CalamityMod.NPCs.StormWeaver public override bool CheckDead() { - for (int num569 = 0; num569 < 200; num569++) + for (int num569 = 0; num569 < Main.maxNPCs; num569++) { if (Main.npc[num569].active && (Main.npc[num569].type == ModContent.NPCType() || Main.npc[num569].type == ModContent.NPCType())) - { Main.npc[num569].life = 0; - } } + return true; } @@ -666,7 +706,10 @@ namespace CalamityMod.NPCs.StormWeaver // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - if (Main.rand.NextBool(20)) + + // Light pet. + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + if (Main.rand.NextBool(20)) { DropHelper.DropItem(npc, ModContent.ItemType()); DropHelper.DropItem(npc, ModContent.ItemType()); diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index 0bb0798c71..467d5c8dfe 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -25,7 +25,7 @@ namespace CalamityMod.NPCs.StormWeaver npc.defense = 0; npc.takenDamageMultiplier = 3f; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 170000); + npc.LifeMaxNERB(notDoGFight ? 65000 : 13000, notDoGFight ? 65000 : 13000, 17000); // If fought alone, Storm Weaver plays its own theme if (notDoGFight) @@ -213,7 +213,7 @@ namespace CalamityMod.NPCs.StormWeaver Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2(texture2D15.Width, texture2D15.Height) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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/StormWeaver/StormWeaverTailGlow"); diff --git a/NPCs/StormWeaver/StormWeaverTailNaked.cs b/NPCs/StormWeaver/StormWeaverTailNaked.cs index 11bd661546..cb35add269 100644 --- a/NPCs/StormWeaver/StormWeaverTailNaked.cs +++ b/NPCs/StormWeaver/StormWeaverTailNaked.cs @@ -27,10 +27,11 @@ namespace CalamityMod.NPCs.StormWeaver npc.width = 48; npc.height = 80; bool notDoGFight = CalamityWorld.DoGSecondStageCountdown <= 0 || !CalamityWorld.downedSentinel2; - npc.LifeMaxNERB(notDoGFight ? 585000 : 97500, notDoGFight ? 585000 : 97500, 3500000); + npc.lifeMax = notDoGFight ? 760500 : 126750; + npc.LifeMaxNERB(npc.lifeMax, npc.lifeMax, 455000); - // 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 @@ -94,9 +95,7 @@ namespace CalamityMod.NPCs.StormWeaver 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]; - } bool flag = false; if (npc.ai[1] <= 0f) @@ -125,11 +124,10 @@ namespace CalamityMod.NPCs.StormWeaver Main.dust[num935].noLight = true; } } + npc.alpha -= 42; if (npc.alpha < 0) - { npc.alpha = 0; - } } Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -141,6 +139,7 @@ namespace CalamityMod.NPCs.StormWeaver 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) { @@ -152,7 +151,8 @@ namespace CalamityMod.NPCs.StormWeaver } catch { } - npc.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; + + npc.rotation = (float)System.Math.Atan2(num192, num191) + MathHelper.PiOver2; num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); int num194 = npc.width; num193 = (num193 - num194) / num193; @@ -161,14 +161,11 @@ namespace CalamityMod.NPCs.StormWeaver 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; - } } } @@ -198,14 +195,14 @@ namespace CalamityMod.NPCs.StormWeaver 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, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor); if (Main.npc[(int)npc.ai[2]].Calamity().newAI[0] > 280f && (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice)) @@ -230,20 +227,21 @@ namespace CalamityMod.NPCs.StormWeaver public override void HitEffect(int hitDirection, double damage) { - for (int k = 0; k < 5; k++) - { + for (int k = 0; k < 3; k++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail1"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SWNudeTail2"), 1f); + npc.position.X = npc.position.X + (npc.width / 2); npc.position.Y = npc.position.Y + (npc.height / 2); npc.width = 30; npc.height = 30; npc.position.X = npc.position.X - (npc.width / 2); npc.position.Y = npc.position.Y - (npc.height / 2); + for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 2f); @@ -254,6 +252,7 @@ namespace CalamityMod.NPCs.StormWeaver Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int num623 = 0; num623 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 3f); diff --git a/NPCs/SunkenSea/BlindedAngler.cs b/NPCs/SunkenSea/BlindedAngler.cs index 9a68f4b1e5..96b1ba525c 100644 --- a/NPCs/SunkenSea/BlindedAngler.cs +++ b/NPCs/SunkenSea/BlindedAngler.cs @@ -72,7 +72,7 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/BlindedAnglerGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/SunkenSea/EutrophicRay.cs b/NPCs/SunkenSea/EutrophicRay.cs index a5e9279d71..3de601059d 100644 --- a/NPCs/SunkenSea/EutrophicRay.cs +++ b/NPCs/SunkenSea/EutrophicRay.cs @@ -169,7 +169,7 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/EutrophicRayGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/SunkenSea/GhostBell.cs b/NPCs/SunkenSea/GhostBell.cs index 7374f4500c..249847c733 100644 --- a/NPCs/SunkenSea/GhostBell.cs +++ b/NPCs/SunkenSea/GhostBell.cs @@ -126,7 +126,7 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GhostBellGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GhostBellGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/SunkenSea/GhostBellSmall.cs b/NPCs/SunkenSea/GhostBellSmall.cs index 45cd962756..45bc1f1ada 100644 --- a/NPCs/SunkenSea/GhostBellSmall.cs +++ b/NPCs/SunkenSea/GhostBellSmall.cs @@ -132,7 +132,7 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GhostBellSmallGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GhostBellSmallGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GhostBellSmallGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/SunkenSea/GiantClam.cs b/NPCs/SunkenSea/GiantClam.cs index e5cdc81ffe..02728272db 100644 --- a/NPCs/SunkenSea/GiantClam.cs +++ b/NPCs/SunkenSea/GiantClam.cs @@ -393,7 +393,7 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GiantClamGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GiantClamGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.LightBlue); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/GiantClamGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/SunkenSea/PrismTurtle.cs b/NPCs/SunkenSea/PrismTurtle.cs index 3cb89292a7..a76e13742d 100644 --- a/NPCs/SunkenSea/PrismTurtle.cs +++ b/NPCs/SunkenSea/PrismTurtle.cs @@ -110,7 +110,7 @@ namespace CalamityMod.NPCs.SunkenSea Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Vector2 vector = center - Main.screenPosition; vector -= new Vector2((float)ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/PrismTurtleGlow").Width, (float)(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/PrismTurtleGlow").Height / Main.npcFrameCount[npc.type])) * 1f / 2f; - vector += vector11 * 1f + new Vector2(0f, 0f + 4f + npc.gfxOffY); + vector += vector11 * 1f + new Vector2(0f, 4f + npc.gfxOffY); Color color = new Color(127 - npc.alpha, 127 - npc.alpha, 127 - npc.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.Blue); Main.spriteBatch.Draw(ModContent.GetTexture("CalamityMod/NPCs/SunkenSea/PrismTurtleGlow"), vector, new Microsoft.Xna.Framework.Rectangle?(npc.frame), color, npc.rotation, vector11, 1f, spriteEffects, 0f); diff --git a/NPCs/SupremeCalamitas/HoodedHeadIcon.png b/NPCs/SupremeCalamitas/HoodedHeadIcon.png new file mode 100644 index 0000000000..9fa8485791 Binary files /dev/null and b/NPCs/SupremeCalamitas/HoodedHeadIcon.png differ diff --git a/NPCs/SupremeCalamitas/HoodedHeadIconP2.png b/NPCs/SupremeCalamitas/HoodedHeadIconP2.png new file mode 100644 index 0000000000..b58cdcfaad Binary files /dev/null and b/NPCs/SupremeCalamitas/HoodedHeadIconP2.png differ diff --git a/NPCs/SupremeCalamitas/HoodlessHeadIcon.png b/NPCs/SupremeCalamitas/HoodlessHeadIcon.png new file mode 100644 index 0000000000..6c12e09c8e Binary files /dev/null and b/NPCs/SupremeCalamitas/HoodlessHeadIcon.png differ diff --git a/NPCs/SupremeCalamitas/HoodlessHeadIconP2.png b/NPCs/SupremeCalamitas/HoodlessHeadIconP2.png new file mode 100644 index 0000000000..dc1377a577 Binary files /dev/null and b/NPCs/SupremeCalamitas/HoodlessHeadIconP2.png differ diff --git a/NPCs/SupremeCalamitas/SCalSky.cs b/NPCs/SupremeCalamitas/SCalSky.cs index 4b8ec5cb18..bf4233d713 100644 --- a/NPCs/SupremeCalamitas/SCalSky.cs +++ b/NPCs/SupremeCalamitas/SCalSky.cs @@ -1,3 +1,4 @@ +using CalamityMod.Projectiles.Boss; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -11,6 +12,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas private bool isActive = false; private float intensity = 0f; private int SCalIndex = -1; + public static float OverridingIntensity = 0f; public override void Update(GameTime gameTime) { @@ -26,6 +28,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas private float GetIntensity() { + if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) > 0) + return OverridingIntensity; + + OverridingIntensity = 0f; if (this.UpdateSCalIndex()) { float x = 0f; diff --git a/NPCs/SupremeCalamitas/SCalWormBody.cs b/NPCs/SupremeCalamitas/SCalWormBody.cs index ba98444bc2..a6265bf8d7 100644 --- a/NPCs/SupremeCalamitas/SCalWormBody.cs +++ b/NPCs/SupremeCalamitas/SCalWormBody.cs @@ -28,12 +28,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; global.unbreakableDR = true; - npc.lifeMax = CalamityWorld.revenge ? 1200000 : 1000000; - if (CalamityWorld.death) - { - npc.lifeMax = 2000000; - } - npc.aiStyle = -1; //new + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; npc.scale = 1.2f; @@ -183,7 +179,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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, 4f + npc.gfxOffY); + 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.localAI[3] == 1f) diff --git a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs index cc1b3890d4..9b5cfcba69 100644 --- a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs +++ b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs @@ -23,11 +23,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.npcSlots = 5f; npc.width = 20; npc.height = 20; - npc.lifeMax = CalamityWorld.revenge ? 1200000 : 1000000; - if (CalamityWorld.death) - { - npc.lifeMax = 2000000; - } + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; diff --git a/NPCs/SupremeCalamitas/SCalWormHead.cs b/NPCs/SupremeCalamitas/SCalWormHead.cs index 7377add402..bf98c7ff11 100644 --- a/NPCs/SupremeCalamitas/SCalWormHead.cs +++ b/NPCs/SupremeCalamitas/SCalWormHead.cs @@ -32,12 +32,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; global.unbreakableDR = true; - npc.lifeMax = CalamityWorld.revenge ? 1200000 : 1000000; - if (CalamityWorld.death) - { - npc.lifeMax = 2000000; - } - npc.aiStyle = -1; //new + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; npc.scale = 1.2f; @@ -305,7 +301,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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, 4f + npc.gfxOffY); + 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/SCalWormHeadGlow"); diff --git a/NPCs/SupremeCalamitas/SCalWormHeart.cs b/NPCs/SupremeCalamitas/SCalWormHeart.cs index 37f5062a72..43ea6157ca 100644 --- a/NPCs/SupremeCalamitas/SCalWormHeart.cs +++ b/NPCs/SupremeCalamitas/SCalWormHeart.cs @@ -1,4 +1,9 @@ using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -7,6 +12,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas { public class SCalWormHeart : ModNPC { + public PrimitiveTrail ChainDrawer = null; + public int ChainHeartIndex => (int)npc.ai[0]; + public List ChainEndpoints = new List(); public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Heart"); @@ -18,7 +26,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.width = 24; npc.height = 24; npc.defense = 0; - npc.LifeMaxNERB(160000, 180000, 90000); + npc.LifeMaxNERB(25600, 29440, 10000); npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; @@ -26,10 +34,25 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; + npc.hide = true; npc.HitSound = SoundID.NPCHit13; npc.DeathSound = SoundID.NPCDeath1; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(ChainEndpoints.Count); + for (int i = 0; i < ChainEndpoints.Count; i++) + writer.WriteVector2(ChainEndpoints[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + ChainEndpoints.Clear(); + for (int i = 0; i < reader.ReadInt32(); i++) + ChainEndpoints.Add(reader.ReadVector2()); + } + public override void AI() { if (CalamityGlobalNPC.SCal < 0 || !Main.npc[CalamityGlobalNPC.SCal].active) @@ -38,29 +61,75 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.netUpdate = true; return; } + npc.alpha -= 42; if (npc.alpha < 0) - { npc.alpha = 0; + } + + 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); + float baseWidth = MathHelper.Lerp(4f, 1f, widthInterpolant); + float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTime * 4.4f + npc.whoAmI * 1.3f + completionRatio), 16D)); + return baseWidth + pulseWidth; + } + + public Color PrimitiveColorFunction(float completionRatio) + { + float colorInterpolant = MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, 0.34f, completionRatio, true) * Utils.InverseLerp(1.07f, 0.66f, completionRatio, true)); + return Color.Lerp(Color.DarkRed * 0.7f, Color.Red, colorInterpolant) * 0.425f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + if (ChainDrawer is null) + ChainDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction); + for (int i = 0; i < ChainEndpoints.Count; i++) + { + List points = new List() + { + npc.Center, + ChainEndpoints[i] + npc.DirectionTo(ChainEndpoints[i]) * 25f + }; + ChainDrawer.Draw(points, -Main.screenPosition, 40); } + + return true; + } + + public void TendrilDestructionEffects(int tendrilIndex) + { + for (int i = 0; i < 70; i++) + { + Vector2 dustSpawnPosition = Vector2.Lerp(npc.Center, ChainEndpoints[tendrilIndex], i / 70f); + Dust blood = Dust.NewDustDirect(dustSpawnPosition, 4, 4, DustID.Blood); + blood.velocity = Main.rand.NextVector2Circular(3f, 3f); + blood.scale = Main.rand.NextFloat(1f, 1.4f); + } + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + for (int i = 0; i < ChainEndpoints.Count; i++) + TendrilDestructionEffects(i); + } + } + + public override void DrawBehind(int index) + { + Main.instance.DrawCacheNPCsBehindNonSolidTiles.Add(index); } public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { if (projectile.type == ModContent.ProjectileType()) - { damage = (int)(damage * 0.66); - } } - public override bool CheckActive() - { - return false; - } - - public override bool PreNPCLoot() - { - return false; - } - } + public override bool CheckActive() => false; + } } diff --git a/NPCs/SupremeCalamitas/SCalWormTail.cs b/NPCs/SupremeCalamitas/SCalWormTail.cs index 5f1df23a1d..3fb861c106 100644 --- a/NPCs/SupremeCalamitas/SCalWormTail.cs +++ b/NPCs/SupremeCalamitas/SCalWormTail.cs @@ -27,12 +27,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; global.unbreakableDR = true; - npc.lifeMax = CalamityWorld.revenge ? 1200000 : 1000000; - if (CalamityWorld.death) - { - npc.lifeMax = 2000000; - } - npc.aiStyle = -1; //new + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; npc.scale = 1.2f; @@ -165,7 +161,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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, 4f + npc.gfxOffY); + 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/SCalWormTailGlow"); diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs index 4e4b36ec1c..894bb0b395 100644 --- a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs +++ b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Boss; using CalamityMod.Dusts; using CalamityMod.World; @@ -35,7 +36,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.damage = 0; npc.defense = 60; npc.DR_NERD(0.25f); - npc.LifeMaxNERB(Main.expertMode ? 90000 : 50000, 170000); + npc.LifeMaxNERB(Main.expertMode ? 24000 : 15000, 28000); npc.HitSound = SoundID.NPCHit4; npc.DeathSound = SoundID.NPCDeath14; } @@ -124,12 +125,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas return false; } - public override bool PreNPCLoot() - { - return false; - } - - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; @@ -181,7 +177,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas spriteEffects = SpriteEffects.FlipHorizontally; Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); + Vector2 vector11 = new Vector2((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; @@ -195,15 +191,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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)) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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)) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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"); @@ -217,8 +213,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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)) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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); } } diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png b/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png index b43bd78635..27c809cbac 100644 Binary files a/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png and b/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index aaf1967da5..72ca0be300 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -14,21 +14,36 @@ using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.Boss; -using CalamityMod.Projectiles.Summon; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - [AutoloadBossHead] public class SupremeCalamitas : ModNPC { + internal enum FrameAnimationType + { + // The numbering of these values correspond to a frame on the sprite. If this enumeration or the sprite itself + // is updated, these numbers will need to be too. + UpwardDraft = 0, + FasterUpwardDraft = 1, + Casting = 2, + BlastCast = 3, + BlastPunchCast = 4, + OutwardHandCast = 5, + PunchHandCast = 6, + Count = 7 + } + private float bossLife; private float uDieLul = 1f; private float passedVar = 0f; @@ -38,6 +53,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas private bool despawnProj = false; private bool startText = false; private bool startBattle = false; //100% + private bool hasSummonedSepulcher1 = false; //100% private bool startSecondAttack = false; //80% private bool startThirdAttack = false; //60% private bool halfLife = false; //40% @@ -45,6 +61,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas private bool secondStage = false; //20% private bool startFifthAttack = false; //10% private bool gettingTired = false; //8% + private bool hasSummonedSepulcher2 = false; //8% private bool gettingTired2 = false; //6% private bool gettingTired3 = false; //4% private bool gettingTired4 = false; //2% @@ -52,6 +69,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas private bool willCharge = false; private bool canFireSplitingFireball = true; private bool spawnArena = false; + private bool enteredBrothersPhase = false; + private bool hasSummonedBrothers = false; private int giveUpCounter = 1200; private int lootTimer = 0; //900 * 5 = 4500 @@ -66,16 +85,92 @@ namespace CalamityMod.NPCs.SupremeCalamitas private int spawnYAdd = 0; private int bulletHellCounter = 0; private int bulletHellCounter2 = 0; + private int attackCastDelay = 0; + private int hitTimer = 0; + private float shieldOpacity = 1f; + private float shieldRotation = 0f; + private float forcefieldOpacity = 1f; + private float forcefieldScale = 1; + private FrameAnimationType FrameType + { + get => (FrameAnimationType)(int)npc.localAI[2]; + set => npc.localAI[2] = (int)value; + } + private bool AttackCloseToBeingOver + { + get + { + int attackLength = 0; + + // First phase. + if (npc.ai[0] == 0f) + { + if (npc.ai[1] == 0f) + attackLength = 300; + if (npc.ai[1] == 2f) + attackLength = 70; + if (npc.ai[1] == 3f) + attackLength = 480; + if (npc.ai[1] == 4f) + attackLength = 300; + } + else + { + if (npc.ai[1] == 0f) + attackLength = 240; + if (npc.ai[1] == 2f) + attackLength = 70; + if (npc.ai[1] == 3f) + attackLength = 300; + if (npc.ai[1] == 4f) + attackLength = 240; + } + return npc.ai[2] >= attackLength - 30f; + } + } + private ref float FrameChangeSpeed => ref npc.localAI[3]; + + private Vector2 cataclysmSpawnPosition; + private Vector2 catastropheSpawnPosition; + private Vector2 initialRitualPosition; private Rectangle safeBox = default; + public static int hoodedHeadIconIndex; + public static int hoodedHeadIconP2Index; + public static int hoodlessHeadIconIndex; + public static int hoodlessHeadIconP2Index; public static float normalDR = 0.25f; - public static float enragedDR = 0.99f; + public static float enragedDR = 0.9999f; + + private static readonly Color textColor = Color.Orange; + private const int sepulcherSpawnCastTime = 75; + private const int brothersSpawnCastTime = 150; + + // TODO: This is cumbersome. Change it to be better in 1.4. + internal static void LoadHeadIcons() + { + string hoodedIconPath = "CalamityMod/NPCs/SupremeCalamitas/HoodedHeadIcon"; + string hoodedIconP2Path = "CalamityMod/NPCs/SupremeCalamitas/HoodedHeadIconP2"; + string hoodlessIconPath = "CalamityMod/NPCs/SupremeCalamitas/HoodlessHeadIcon"; + string hoodlessIconP2Path = "CalamityMod/NPCs/SupremeCalamitas/HoodlessHeadIconP2"; + CalamityMod.Instance.AddBossHeadTexture(hoodedIconPath, -1); + hoodedHeadIconIndex = ModContent.GetModBossHeadSlot(hoodedIconPath); + + CalamityMod.Instance.AddBossHeadTexture(hoodedIconP2Path, -1); + hoodedHeadIconP2Index = ModContent.GetModBossHeadSlot(hoodedIconP2Path); + + CalamityMod.Instance.AddBossHeadTexture(hoodlessIconPath, -1); + hoodlessHeadIconIndex = ModContent.GetModBossHeadSlot(hoodlessIconPath); + + CalamityMod.Instance.AddBossHeadTexture(hoodlessIconP2Path, -1); + hoodlessHeadIconP2Index = ModContent.GetModBossHeadSlot(hoodlessIconP2Path); + } public override void SetStaticDefaults() { DisplayName.SetDefault("Supreme Calamitas"); - Main.npcFrameCount[npc.type] = 6; + Main.npcFrameCount[npc.type] = 21; NPCID.Sets.TrailingMode[npc.type] = 1; } @@ -84,14 +179,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.Calamity().canBreakPlayerDefense = true; npc.GetNPCDamage(); npc.npcSlots = 50f; - npc.width = 120; - npc.height = 120; + npc.width = npc.height = 44; npc.defense = 100; npc.DR_NERD(normalDR, null, null, null, true); CalamityGlobalNPC global = npc.Calamity(); global.multDRReductions.Add(BuffID.CursedInferno, 0.9f); npc.value = Item.buyPrice(10, 0, 0, 0); - npc.LifeMaxNERB(5000000, 5500000, 2100000); + npc.LifeMaxNERB(1000000, 1150000, 500000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -103,8 +197,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.canGhostHeal = false; npc.noGravity = true; npc.noTileCollide = true; - npc.HitSound = SoundID.NPCHit4; - music = CalamityMod.Instance.GetMusicFromMusicMod("SCG") ?? MusicID.Boss2; + npc.HitSound = SoundID.NPCHit1; + music = CalamityMod.Instance.GetMusicFromMusicMod("SCG") ?? MusicID.Boss2; + } + + public override void BossHeadSlot(ref int index) + { + bool inPhase2 = npc.ai[0] == 3f; + if (!CalamityWorld.downedSCal || BossRushEvent.BossRushActive) + index = inPhase2 ? hoodedHeadIconP2Index : hoodedHeadIconIndex; + else + index = inPhase2 ? hoodlessHeadIconP2Index : hoodlessHeadIconIndex; } public override void SendExtraAI(BinaryWriter writer) @@ -114,12 +217,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas writer.Write(despawnProj); writer.Write(startText); writer.Write(startBattle); + writer.Write(hasSummonedSepulcher1); writer.Write(startSecondAttack); writer.Write(startThirdAttack); writer.Write(startFourthAttack); writer.Write(startFifthAttack); writer.Write(halfLife); writer.Write(secondStage); + writer.Write(hasSummonedSepulcher2); writer.Write(gettingTired); writer.Write(gettingTired2); writer.Write(gettingTired3); @@ -128,6 +233,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas writer.Write(willCharge); writer.Write(canFireSplitingFireball); writer.Write(spawnArena); + writer.Write(hasSummonedBrothers); + writer.Write(enteredBrothersPhase); writer.Write(npc.dontTakeDamage); writer.Write(npc.chaseable); @@ -144,6 +251,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas writer.Write(spawnYAdd); writer.Write(bulletHellCounter); writer.Write(bulletHellCounter2); + writer.Write(hitTimer); + writer.Write(attackCastDelay); + + writer.Write(shieldRotation); } public override void ReceiveExtraAI(BinaryReader reader) @@ -153,12 +264,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas despawnProj = reader.ReadBoolean(); startText = reader.ReadBoolean(); startBattle = reader.ReadBoolean(); + hasSummonedSepulcher1 = reader.ReadBoolean(); startSecondAttack = reader.ReadBoolean(); startThirdAttack = reader.ReadBoolean(); startFourthAttack = reader.ReadBoolean(); startFifthAttack = reader.ReadBoolean(); halfLife = reader.ReadBoolean(); secondStage = reader.ReadBoolean(); + hasSummonedSepulcher2 = reader.ReadBoolean(); gettingTired = reader.ReadBoolean(); gettingTired2 = reader.ReadBoolean(); gettingTired3 = reader.ReadBoolean(); @@ -167,6 +280,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas willCharge = reader.ReadBoolean(); canFireSplitingFireball = reader.ReadBoolean(); spawnArena = reader.ReadBoolean(); + hasSummonedBrothers = reader.ReadBoolean(); + enteredBrothersPhase = reader.ReadBoolean(); npc.dontTakeDamage = reader.ReadBoolean(); npc.chaseable = reader.ReadBoolean(); @@ -183,11 +298,22 @@ namespace CalamityMod.NPCs.SupremeCalamitas spawnYAdd = reader.ReadInt32(); bulletHellCounter = reader.ReadInt32(); bulletHellCounter2 = reader.ReadInt32(); + hitTimer = reader.ReadInt32(); + attackCastDelay = reader.ReadInt32(); + + shieldRotation = reader.ReadSingle(); } public override void AI() { + #region Resets + + // Use an ordinary upward draft by default. + FrameType = FrameAnimationType.UpwardDraft; + FrameChangeSpeed = 0.15f; + #endregion #region StartUp + CalamityGlobalNPC.SCal = npc.whoAmI; lootTimer++; @@ -218,10 +344,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas CalamityMod.StopRain(); - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; bool enraged = npc.Calamity().enraged > 0; // Projectile damage values @@ -233,6 +359,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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 = enraged ? 6 : 8; Vector2 vectorCenter = npc.Center; @@ -248,62 +377,99 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!startText) { - if (Main.LocalPlayer.Calamity().sCalKillCount == 4) + if (!BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.SupremeBossText12"; //kill SCal 4 times - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - else if (Main.LocalPlayer.Calamity().sCalKillCount == 1) - { - string key = "Mods.CalamityMod.SupremeBossText11"; //kill SCal once - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - - if (Main.LocalPlayer.Calamity().sCalDeathCount < 51) - { - if (Main.LocalPlayer.Calamity().sCalDeathCount == 50) - { - string key = "Mods.CalamityMod.SupremeBossText15"; //die 50 or more times - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - else if (Main.LocalPlayer.Calamity().sCalDeathCount > 19) - { - string key = "Mods.CalamityMod.SupremeBossText14"; //die 20 or more times - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - else if (Main.LocalPlayer.Calamity().sCalDeathCount > 4) - { - string key = "Mods.CalamityMod.SupremeBossText13"; //die 5 or more times - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } + string key = "Mods.CalamityMod.SCalSummonText"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); } startText = true; } + #endregion + #region Directioning + + bool currentlyCharging = npc.ai[1] == 2f; + if (!currentlyCharging && Math.Abs(player.Center.X - npc.Center.X) > 16f) + npc.spriteDirection = (player.Center.X < npc.Center.X).ToDirectionInt(); + #endregion + #region Forcefield and Shield Logic + + if (hitTimer > 0) + hitTimer--; + + Vector2 hitboxSize = new Vector2(forcefieldScale * 216f / 1.4142f); + hitboxSize = Vector2.Max(hitboxSize, new Vector2(42, 44)); + if (npc.Size != hitboxSize) + npc.Size = hitboxSize; + + // Make the shield and forcefield fade away in her acceptance phase. + if (npc.life <= npc.lifeMax * 0.01) + { + shieldOpacity = MathHelper.Lerp(shieldOpacity, 0f, 0.08f); + forcefieldScale = MathHelper.Lerp(forcefieldScale, 0f, 0.08f); + } + + // Summon a shield if the next attack will be a charge. + else if (!npc.dontTakeDamage && ((willCharge && AttackCloseToBeingOver) || npc.ai[1] == 2f)) + { + if (npc.ai[1] != 2f) + { + float idealRotation = npc.AngleTo(player.Center); + float angularOffset = Math.Abs(MathHelper.WrapAngle(shieldRotation - idealRotation)); + + if (angularOffset > 0.04f) + { + shieldRotation = shieldRotation.AngleLerp(idealRotation, 0.125f); + shieldRotation = shieldRotation.AngleTowards(idealRotation, 0.18f); + } + } + else + { + // Emit dust off the skull at the position of its eye socket. + for (float num6 = 1f; num6 < 16f; num6 += 1f) + { + Dust dust = Dust.NewDustPerfect(npc.Center, 182); + dust.position = Vector2.Lerp(npc.position, npc.oldPosition, num6 / 16f) + npc.Size * 0.5f; + dust.position += shieldRotation.ToRotationVector2() * 42f; + dust.position += (shieldRotation - MathHelper.PiOver2).ToRotationVector2() * (float)Math.Cos(npc.velocity.ToRotation()) * -4f; + dust.noGravity = true; + dust.velocity = npc.velocity; + dust.color = Color.Red; + dust.scale = MathHelper.Lerp(0.6f, 0.85f, 1f - num6 / 16f); + } + } + + // Shrink the force-field since it looks strange when charging. + forcefieldScale = MathHelper.Lerp(forcefieldScale, 0.45f, 0.08f); + shieldOpacity = MathHelper.Lerp(shieldOpacity, 1f, 0.08f); + } + // Make the shield disappear if it is no longer relevant and regenerate the forcefield. + else + { + shieldOpacity = MathHelper.Lerp(shieldOpacity, 0f, 0.08f); + forcefieldScale = MathHelper.Lerp(forcefieldScale, 1f, 0.08f); + } + #endregion #region ArenaCreation if (!spawnArena) { spawnArena = true; - Vector2 vectorPlayer = new Vector2(player.position.X, player.position.Y); if (death) { - safeBox.X = spawnX = spawnXReset = (int)(vectorPlayer.X - 1000f); - spawnX2 = spawnXReset2 = (int)(vectorPlayer.X + 1000f); - safeBox.Y = spawnY = spawnYReset = (int)(vectorPlayer.Y - 1000f); + safeBox.X = spawnX = spawnXReset = (int)(npc.Center.X - 1000f); + spawnX2 = spawnXReset2 = (int)(npc.Center.X + 1000f); + safeBox.Y = spawnY = spawnYReset = (int)(npc.Center.Y - 1000f); safeBox.Width = 2000; safeBox.Height = 2000; spawnYAdd = 100; } else { - safeBox.X = spawnX = spawnXReset = (int)(vectorPlayer.X - 1250f); - spawnX2 = spawnXReset2 = (int)(vectorPlayer.X + 1250f); - safeBox.Y = spawnY = spawnYReset = (int)(vectorPlayer.Y - 1250f); + safeBox.X = spawnX = spawnXReset = (int)(npc.Center.X - 1250f); + spawnX2 = spawnXReset2 = (int)(npc.Center.X + 1250f); + safeBox.Y = spawnY = spawnYReset = (int)(npc.Center.Y - 1250f); safeBox.Width = 2500; safeBox.Height = 2500; spawnYAdd = 125; @@ -317,6 +483,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas { for (int num56 = num53 - num54; num56 <= num53 + num54; num56++) { + if (!WorldGen.InWorld(num55, num56, 2)) + continue; + if ((num55 == num52 - num54 || num55 == num52 + num54 || num56 == num53 - num54 || num56 == num53 + num54) && !Main.tile[num55, num56].active()) { Main.tile[num55, num56].type = (ushort)ModContent.TileType(); @@ -332,6 +501,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + + if (initialRitualPosition == Vector2.Zero) + { + initialRitualPosition = npc.Center + Vector2.UnitY * 24f; + npc.netUpdate = true; + } } } #endregion @@ -360,6 +535,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } protectionBoost = false; } + npc.Calamity().CurrentlyEnraged = !player.Hitbox.Intersects(safeBox); // Set DR to be 99% and unbreakable if enraged. Boost DR during the 5th attack. CalamityGlobalNPC global = npc.Calamity(); @@ -381,29 +557,76 @@ namespace CalamityMod.NPCs.SupremeCalamitas { npc.TargetClosest(false); player = Main.player[npc.target]; + + // Slow down and disappear in a burst of fire if should despawn. if (!player.active || player.dead) { canDespawn = true; - float num740 = player.Center.X - vectorCenter.X; - float num741 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num741, num740) - MathHelper.PiOver2; + 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)); + forcefieldOpacity = Utils.InverseLerp(0.1f, 0.6f, npc.Opacity, true); + if (npc.alpha >= 230) + { + // TODO: Spawn the town NPC variant of SCal here when it's on the public branch. + npc.active = false; + npc.netUpdate = true; + } - 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; + for (int i = 0; i < MathHelper.Lerp(2f, 6f, 1f - npc.Opacity); i++) + { + Dust brimstoneFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-24f, 24f), DustID.Fire); + brimstoneFire.color = Color.Red; + brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 3.25f); + brimstoneFire.scale = Main.rand.NextFloat(0.95f, 1.15f); + brimstoneFire.noGravity = true; + } } } else canDespawn = false; - #endregion - #region FirstAttack - if (bulletHellCounter2 < 900) + #endregion + #region Cast Charge Countdown + if (attackCastDelay > 0) + { + attackCastDelay--; + npc.velocity *= 0.94f; + npc.dontTakeDamage = true; + + // Make a magic effect over time. + for (int i = 0; i < (attackCastDelay == 0 ? 16 : 1); i++) + { + Vector2 dustSpawnPosition = npc.Bottom; + float horizontalSpawnOffset = bodyWidth * Main.rand.NextFloat(0.42f, 0.5f); + if (Main.rand.NextBool(2)) + horizontalSpawnOffset *= -1f; + dustSpawnPosition.X += horizontalSpawnOffset; + + Dust magic = Dust.NewDustPerfect(dustSpawnPosition, 267); + magic.color = Color.Lerp(Color.Red, Color.Orange, Main.rand.NextFloat(0.8f)); + magic.noGravity = true; + magic.velocity = Vector2.UnitY * -Main.rand.NextFloat(5f, 9f); + magic.scale = 1f + npc.velocity.Y * 0.35f; + } + + if ((startBattle && !hasSummonedSepulcher1) || (gettingTired && !hasSummonedSepulcher2)) + DoHeartsSpawningCastAnimation(player, death); + + if (enteredBrothersPhase && !hasSummonedBrothers) + DoBrothersSpawningCastAnimation(bodyWidth, bodyHeight); + + if (attackCastDelay == 0) + { + npc.dontTakeDamage = false; + npc.netUpdate = true; + } + + FrameType = FrameAnimationType.Casting; + return; + } + #endregion + #region FirstAttack + if (bulletHellCounter2 < 900) { despawnProj = true; bulletHellCounter2 += 1; @@ -414,17 +637,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) npc.velocity *= 0.95f; - float num740 = player.Center.X - vectorCenter.X; - float num741 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num741, num740) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) { bulletHellCounter += 1; - if (bulletHellCounter > (enraged ? 4 : 6)) + if (bulletHellCounter >= baseBulletHellProjectileGateValue) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((enraged ? 4 : 6) * 3) == 0) + if (bulletHellCounter2 % (baseBulletHellProjectileGateValue * 6) == 0) { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; @@ -447,34 +666,33 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + FrameType = FrameAnimationType.Casting; return; } else if (!startBattle) { - string key = "Mods.CalamityMod.SupremeBossText3"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - - if (Main.netMode != NetmodeID.MultiplayerClient) + attackCastDelay = sepulcherSpawnCastTime; + for (int i = 0; i < 40; i++) { - spawnY += 250; - if (death) - { - spawnY -= 50; - } - for (int x = 0; x < 5; x++) - { - NPC.NewNPC(spawnX + 50, spawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - spawnX += spawnXAdd; - NPC.NewNPC(spawnX2 - 50, spawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - spawnX2 -= spawnXAdd; - spawnY += spawnYAdd; - } - spawnX = spawnXReset; - spawnX2 = spawnXReset2; - spawnY = spawnYReset; - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + Dust castFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-70f, 70f), (int)CalamityDusts.Brimstone); + castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); + castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); + castFire.fadeIn = 1.25f; + castFire.noGravity = true; } + + npc.Center = safeBox.TopRight() + new Vector2(-120f, 620f); + + for (int i = 0; i < 40; i++) + { + Dust castFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-70f, 70f), (int)CalamityDusts.Brimstone); + castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); + castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); + castFire.fadeIn = 1.25f; + castFire.noGravity = true; + } + + Main.PlaySound(SoundID.DD2_DarkMageCastHeal, player.Center); startBattle = true; } #endregion @@ -490,10 +708,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) npc.velocity *= 0.95f; - float num740 = player.Center.X - vectorCenter.X; - float num741 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num741, num740) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) { if (bulletHellCounter2 < 1200) @@ -512,10 +726,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 5f * uDieLul, ModContent.ProjectileType(), gigablastDamage, 0f, Main.myPlayer); } bulletHellCounter += 1; - if (bulletHellCounter > (enraged ? 7 : 9)) + if (bulletHellCounter >= baseBulletHellProjectileGateValue + 2) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((enraged ? 7 : 9) * 3) == 0) + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 2) * 6) == 0) { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; @@ -536,13 +750,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + FrameType = FrameAnimationType.Casting; return; } if (!startSecondAttack && (npc.life <= npc.lifeMax * 0.75)) { - string key = "Mods.CalamityMod.SupremeBossText4"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalBH2Text"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } startSecondAttack = true; return; } @@ -559,10 +778,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) npc.velocity *= 0.95f; - float num740 = player.Center.X - vectorCenter.X; - float num741 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num741, num740) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) { if (bulletHellCounter2 % 180 == 0) // Blasts from top @@ -572,10 +787,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 10f * uDieLul, ModContent.ProjectileType(), fireblastDamage, 0f, Main.myPlayer); bulletHellCounter += 1; - if (bulletHellCounter > (enraged ? 9 : 11)) + if (bulletHellCounter >= baseBulletHellProjectileGateValue + 4) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((enraged ? 9 : 11) * 3) == 0) + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 4) * 6) == 0) { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; @@ -596,15 +811,23 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + FrameType = FrameAnimationType.Casting; return; } if (!startThirdAttack && (npc.life <= npc.lifeMax * 0.5)) { - // Switch from the Grief section of Stained, Brutal Calamity to the Lament section. - music = CalamityMod.Instance.GetMusicFromMusicMod("SCL") ?? MusicID.Boss3; - string key = "Mods.CalamityMod.SupremeBossText5"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + // Switch from the Grief section of Stained, Brutal Calamity to the Lament section. + music = CalamityMod.Instance.GetMusicFromMusicMod("SCL") ?? MusicID.Boss3; + + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalBH3Text"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + if (CalamityWorld.downedSCal) + CalamityUtils.DisplayLocalizedText(key + "2", textColor); + } startThirdAttack = true; return; } @@ -621,10 +844,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) npc.velocity *= 0.95f; - float num740 = player.Center.X - vectorCenter.X; - float num741 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num741, num740) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) // More clustered attack { if (bulletHellCounter2 % 180 == 0) // Blasts from top @@ -634,6 +853,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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; + + // TODO: Resprite Brimstone Monsters to be something else. if (bulletHellCounter2 % divisor == 0 && expertMode) // Giant homing fireballs { Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, 1f * uDieLul, ModContent.ProjectileType(), monsterDamage, 0f, Main.myPlayer, 0f, passedVar); @@ -641,10 +862,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas } bulletHellCounter += 1; - if (bulletHellCounter > (enraged ? 10 : 12)) + if (bulletHellCounter >= baseBulletHellProjectileGateValue + 6) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((enraged ? 10 : 12) * 3) == 0) + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 6) * 6) == 0) { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; @@ -665,15 +886,21 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + FrameType = FrameAnimationType.Casting; return; } 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("SCE") ?? MusicID.LunarBoss; - string key = "Mods.CalamityMod.SupremeBossText7"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalBH4Text"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } startFourthAttack = true; return; } @@ -690,10 +917,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) npc.velocity *= 0.95f; - float num740 = player.Center.X - vectorCenter.X; - float num741 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num741, num740) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) { if (bulletHellCounter2 % 240 == 0) // Blasts from top @@ -710,10 +933,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas } bulletHellCounter += 1; - if (bulletHellCounter > (enraged ? 12 : 14)) + if (bulletHellCounter >= baseBulletHellProjectileGateValue + 8) { bulletHellCounter = 0; - if (bulletHellCounter2 % ((enraged ? 12 : 14) * 3) == 0) + if (bulletHellCounter2 % ((baseBulletHellProjectileGateValue + 8) * 6) == 0) { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = (distance == -1000f ? 4f : -4f) * uDieLul; @@ -736,13 +959,19 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } } + FrameType = FrameAnimationType.Casting; return; } if (!startFifthAttack && (npc.life <= npc.lifeMax * 0.1)) { - string key = "Mods.CalamityMod.SupremeBossText9"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + string key = "Mods.CalamityMod.SCalBH5Text"; + + if (!BossRushEvent.BossRushActive) + { + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } startFifthAttack = true; return; } @@ -752,49 +981,66 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (gettingTired5) { - // Switch from the Epiphany section of Stained, Brutal Calamity to the Acceptance section. - music = CalamityMod.Instance.GetMusicFromMusicMod("SCA") ?? MusicID.Eerie; - npc.noGravity = false; + // Switch from the Epiphany section of Stained, Brutal Calamity to the Acceptance section. + music = CalamityMod.Instance.GetMusicFromMusicMod("SCA") ?? MusicID.Eerie; + + if (npc.velocity.Y < 9f) + npc.velocity.Y += 0.185f; npc.noTileCollide = false; + npc.noGravity = false; npc.damage = 0; if (!canDespawn) - npc.velocity.X *= 0.98f; + npc.velocity.X *= 0.96f; - float num = player.Center.X - vectorCenter.X; - float num1 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num1, num) - MathHelper.PiOver2; - - if (CalamityWorld.downedSCal) //after first time you kill her + if (CalamityWorld.downedSCal && !BossRushEvent.BossRushActive) { - if (giveUpCounter == 900) + // TODO: Spawn the town NPC variant of SCal again here. + if (giveUpCounter == 720) { - string key = "Mods.CalamityMod.SupremeBossText27"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + for (int i = 0; i < 24; i++) + { + Dust brimstoneFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-24f, 24f), DustID.Fire); + brimstoneFire.color = Color.Red; + brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 3.25f); + brimstoneFire.scale = Main.rand.NextFloat(0.95f, 1.15f); + brimstoneFire.fadeIn = 1.25f; + brimstoneFire.noGravity = true; + } + + npc.active = false; + npc.netUpdate = true; + NPCLoot(); } - giveUpCounter--; - bool canBeHit = giveUpCounter < 900; - npc.chaseable = canBeHit; - npc.dontTakeDamage = !canBeHit; - return; - } - if (giveUpCounter == 600) - { - string key = "Mods.CalamityMod.SupremeBossText25"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - if (giveUpCounter == 300) - { - string key = "Mods.CalamityMod.SupremeBossText26"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); } + else if (giveUpCounter == 900 && !BossRushEvent.BossRushActive) + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.SCalAcceptanceText1", textColor); + else if(giveUpCounter == 600 && !BossRushEvent.BossRushActive) + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.SCalAcceptanceText2", textColor); + else if(giveUpCounter == 300 && !BossRushEvent.BossRushActive) + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.SCalAcceptanceText3", textColor); if (giveUpCounter <= 0) { - npc.chaseable = true; - npc.dontTakeDamage = false; + if (BossRushEvent.BossRushActive) + { + npc.chaseable = true; + npc.dontTakeDamage = false; + return; + } + + for (int i = 0; i < 24; i++) + { + Dust brimstoneFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-24f, 24f), DustID.Fire); + brimstoneFire.color = Color.Red; + brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 3.25f); + brimstoneFire.scale = Main.rand.NextFloat(0.95f, 1.15f); + brimstoneFire.fadeIn = 1.25f; + brimstoneFire.noGravity = true; + } + + npc.active = false; + npc.netUpdate = true; + NPCLoot(); return; } giveUpCounter--; @@ -814,61 +1060,76 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - string key = "Mods.CalamityMod.SupremeBossText24"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalDesparationText4"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } gettingTired5 = true; return; } else if (!gettingTired4 && (npc.life <= npc.lifeMax * 0.02)) { - string key = "Mods.CalamityMod.SupremeBossText23"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalDesparationText3"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } gettingTired4 = true; return; } else if (!gettingTired3 && (npc.life <= npc.lifeMax * 0.04)) { - string key = "Mods.CalamityMod.SupremeBossText22"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalDesparationText2"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } gettingTired3 = true; return; } else if (!gettingTired2 && (npc.life <= npc.lifeMax * 0.06)) { - string key = "Mods.CalamityMod.SupremeBossText21"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalDesparationText1"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } gettingTired2 = true; return; } else if (!gettingTired && (npc.life <= npc.lifeMax * 0.08)) { - string key = "Mods.CalamityMod.SupremeBossText20"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - if (Main.netMode != NetmodeID.MultiplayerClient) + attackCastDelay = sepulcherSpawnCastTime; + for (int i = 0; i < 40; i++) { - spawnY += 250; - if (death) - { - spawnY -= 50; - } - for (int x = 0; x < 5; x++) - { - NPC.NewNPC(spawnX + 50, spawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - spawnX += spawnXAdd; - NPC.NewNPC(spawnX2 - 50, spawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255); - spawnX2 -= spawnXAdd; - spawnY += spawnYAdd; - } - spawnX = spawnXReset; - spawnX2 = spawnXReset2; - spawnY = spawnYReset; - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + Dust castFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-70f, 70f), (int)CalamityDusts.Brimstone); + castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); + castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); + castFire.fadeIn = 1.25f; + castFire.noGravity = true; } + + npc.Center = safeBox.TopRight() + new Vector2(-120f, 620f); + + for (int i = 0; i < 40; i++) + { + Dust castFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-70f, 70f), (int)CalamityDusts.Brimstone); + castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); + castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); + castFire.fadeIn = 1.25f; + castFire.noGravity = true; + } + + Main.PlaySound(SoundID.DD2_DarkMageCastHeal, player.Center); gettingTired = true; return; } @@ -904,19 +1165,28 @@ namespace CalamityMod.NPCs.SupremeCalamitas #region TransformSeekerandBrotherTriggers if (!halfLife && (npc.life <= npc.lifeMax * 0.4)) { - string key = "Mods.CalamityMod.SupremeBossText"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalPhase2Text"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } halfLife = true; } + // TODO: Resprite the seekers to be something other than eyeballs. if (npc.life <= npc.lifeMax * 0.2) { - if (secondStage == false) + if (!secondStage) { - string key = "Mods.CalamityMod.SupremeBossText8"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalSeekerRingText"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } if (Main.netMode != NetmodeID.MultiplayerClient) { Main.PlaySound(SoundID.Item74, npc.position); @@ -928,6 +1198,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Eye.ai[3] = I * 18; } } + Main.PlaySound(SoundID.DD2_DarkMageHealImpact, player.Center); secondStage = true; } } @@ -938,58 +1209,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (npc.life > 0) { - if (Main.netMode != NetmodeID.MultiplayerClient) + if (npc.life < npc.lifeMax * 0.45f && !enteredBrothersPhase) { - int num660 = (int)(npc.lifeMax * 0.55); - if ((npc.life + num660) < bossLife) - { - bossLife = npc.life; - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); - string key = "Mods.CalamityMod.SupremeBossText6"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } + enteredBrothersPhase = true; + attackCastDelay = brothersSpawnCastTime; + npc.netUpdate = true; } } - #endregion - #region TargetandRotation - 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; #endregion #region FirstStage if (npc.ai[0] == 0f) @@ -1010,10 +1237,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (!canDespawn) npc.velocity *= 0.95f; - - float num740 = player.Center.X - vectorCenter.X; - float num741 = player.Center.Y - vectorCenter.Y; - npc.rotation = (float)Math.Atan2(num741, num740) - MathHelper.PiOver2; return; } else @@ -1180,78 +1403,126 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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.rotation = (float)Math.Atan2(num826, num825) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += wormAlive ? 0.5f : 1f; - if (npc.localAI[1] > 90f) - { - npc.localAI[1] = 0f; + npc.localAI[1] += wormAlive ? 0.5f : 1f; + if (npc.localAI[1] > 90f) + { + npc.localAI[1] = 0f; - float num828 = 10f * uDieLul; - 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 num828 = 10f * uDieLul; + 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 = num828 / num183; - num180 *= num183; - num182 *= num183; - value9.X += num180; - value9.Y += num182; + num183 = num828 / num183; + num180 *= num183; + num182 *= num183; + value9.X += num180; + value9.Y += num182; - int randomShot = Main.rand.Next(6); - if (randomShot == 0 && canFireSplitingFireball) - { - canFireSplitingFireball = false; - randomShot = ModContent.ProjectileType(); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); - num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num828 / num827; - num825 *= num827; - num826 *= num827; - vector82.X += num825 * 8f; - vector82.Y += num826 * 8f; - Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, fireblastDamage, 0f, Main.myPlayer, 0f, 0f); - } - else if (randomShot == 1 && canFireSplitingFireball) - { - canFireSplitingFireball = false; - randomShot = ModContent.ProjectileType(); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); - num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num828 / num827; - num825 *= num827; - num826 *= num827; - vector82.X += num825 * 8f; - vector82.Y += num826 * 8f; - Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, gigablastDamage, 0f, Main.myPlayer, 0f, 0f); - } - else - { - canFireSplitingFireball = true; - randomShot = ModContent.ProjectileType(); - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); - for (int num186 = 0; num186 < 8; 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); - float speedBoost = num186 > 3 ? -(num186 - 3) : num186; - num183 = (8f + speedBoost) / num183; - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180 + speedBoost, num182 + speedBoost, randomShot, barrageDamage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } + int randomShot = Main.rand.Next(6); + if (randomShot == 0 && canFireSplitingFireball) + { + canFireSplitingFireball = false; + randomShot = ModContent.ProjectileType(); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); + num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); + num827 = num828 / num827; + num825 *= num827; + num826 *= num827; + vector82.X += num825 * 8f; + vector82.Y += num826 * 8f; + + for (int i = 0; i < 15; i++) + { + Dust magic = Dust.NewDustPerfect(value9, 264); + magic.velocity = new Vector2(num180, num182).RotatedByRandom(0.36f) * Main.rand.NextFloat(0.9f, 1.1f); + magic.color = Color.OrangeRed; + magic.scale = 1.2f; + magic.fadeIn = 0.6f; + magic.noLight = true; + magic.noGravity = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, fireblastDamage, 0f, Main.myPlayer, 0f, 0f); + npc.netUpdate = true; + } + } + else if (randomShot == 1 && canFireSplitingFireball) + { + canFireSplitingFireball = false; + randomShot = ModContent.ProjectileType(); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); + num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); + num827 = num828 / num827; + num825 *= num827; + num826 *= num827; + vector82.X += num825 * 8f; + vector82.Y += num826 * 8f; + + for (int i = 0; i < 20; i++) + { + Dust magic = Dust.NewDustPerfect(value9, (int)CalamityDusts.Brimstone); + magic.velocity = new Vector2(num180, num182).RotatedByRandom(0.36f) * Main.rand.NextFloat(0.9f, 1.1f) * 1.3f; + magic.color = Color.Red; + magic.scale = 1.425f; + magic.fadeIn = 0.75f; + magic.noLight = true; + magic.noGravity = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, gigablastDamage, 0f, Main.myPlayer, 0f, 0f); + npc.netUpdate = true; + } + } + else + { + canFireSplitingFireball = true; + randomShot = ModContent.ProjectileType(); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); + for (int num186 = 0; num186 < 8; 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); + float speedBoost = num186 > 3 ? -(num186 - 3) : num186; + num183 = (8f + speedBoost) / num183; + num180 *= num183; + num182 *= num183; + + for (int i = 0; i < 7; i++) + { + Vector2 magicDustVelocity = new Vector2(num180 + speedBoost, num182 + speedBoost); + magicDustVelocity *= MathHelper.Lerp(0.3f, 1f, i / 7f); + + Dust magic = Dust.NewDustPerfect(value9, 264); + magic.velocity = magicDustVelocity; + magic.color = Color.Red; + magic.scale = MathHelper.Lerp(0.85f, 1.5f, i / 7f); + magic.fadeIn = 0.67f; + magic.noLight = true; + magic.noGravity = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(value9.X, value9.Y, num180 + speedBoost, num182 + speedBoost, randomShot, barrageDamage, 0f, Main.myPlayer, 0f, 0f); + npc.netUpdate = true; + } + } + } + } + + FrameType = FrameAnimationType.FasterUpwardDraft; } else if (npc.ai[1] == 1f) { - npc.rotation = num803; float num383 = wormAlive ? 26f : 30f; if (npc.life < npc.lifeMax * 0.95) num383 += 1f; @@ -1274,7 +1545,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas { npc.velocity.X = num384 * num386; npc.velocity.Y = num385 * num386; - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/SCalDash"), npc.Center); + shieldRotation = npc.velocity.ToRotation(); + npc.netUpdate = true; + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/SCalDash"), npc.Center); } npc.ai[1] = 2f; @@ -1282,6 +1556,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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) @@ -1294,22 +1571,30 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.velocity.Y = 0f; } } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - if (npc.ai[2] >= 70f) + bool willChargeAgain = npc.ai[3] + 1 < 2; + + if (npc.ai[2] >= 70f) { npc.ai[3] += 1f; npc.ai[2] = 0f; npc.TargetClosest(); - npc.rotation = num803; - if (npc.ai[3] >= 2f) + if (!willChargeAgain) npc.ai[1] = -1f; else npc.ai[1] = 1f; - } - } + } + + if (willChargeAgain && npc.ai[2] > 50f) + { + float idealRotation = npc.AngleTo(player.Center); + shieldRotation = shieldRotation.AngleLerp(idealRotation, 0.125f); + shieldRotation = shieldRotation.AngleTowards(idealRotation, 0.18f); + } + + FrameType = FrameAnimationType.FasterUpwardDraft; + } else if (npc.ai[1] == 3f) { float num412 = 32f; @@ -1326,7 +1611,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (npc.position.X + (npc.width / 2) < player.position.X + player.width) num414 = -1; - Vector2 vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + 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); @@ -1383,6 +1669,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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++) + { + Dust brimstoneMagic = Dust.NewDustPerfect(handPosition, 264); + brimstoneMagic.velocity = npc.DirectionTo(player.Center).RotatedByRandom(0.31f) * Main.rand.NextFloat(3f, 5f) + npc.velocity; + brimstoneMagic.scale = Main.rand.NextFloat(1.25f, 1.35f); + brimstoneMagic.noGravity = true; + brimstoneMagic.color = Color.OrangeRed; + brimstoneMagic.fadeIn = 1.5f; + brimstoneMagic.noLight = true; + } + if (Main.netMode != NetmodeID.MultiplayerClient) { float num418 = 10f * uDieLul; @@ -1391,13 +1689,24 @@ namespace CalamityMod.NPCs.SupremeCalamitas num417 = num418 / num417; num415 *= num417; num416 *= num417; - vector40.X += num415 * 4f; - vector40.Y += num416 * 4f; + 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)) + { + Dust brimstoneMagic = Dust.NewDustPerfect(handPosition, 264); + brimstoneMagic.velocity = Vector2.UnitY.RotatedByRandom(0.14f) * Main.rand.NextFloat(-3.5f, -3f) + npc.velocity; + brimstoneMagic.scale = Main.rand.NextFloat(1.25f, 1.35f); + brimstoneMagic.noGravity = true; + brimstoneMagic.noLight = true; + } + + FrameType = FrameAnimationType.OutwardHandCast; + } else if (npc.ai[1] == 4f) { int num831 = 1; @@ -1454,15 +1763,32 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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; - npc.rotation = (float)Math.Atan2(num835, num834) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += wormAlive ? 0.5f : 1f; - if (npc.localAI[1] > 140f) + int shootRate = wormAlive ? 280 : 140; + npc.localAI[1]++; + FrameChangeSpeed = 0.175f; + FrameType = FrameAnimationType.BlastCast; + + if (npc.localAI[1] > shootRate) + { + Vector2 handPosition = npc.Center + new Vector2(npc.spriteDirection * -22f, 2f); + + // Release a burst of magic dust when punching. + for (int i = 0; i < 25; i++) + { + Dust brimstoneMagic = Dust.NewDustPerfect(handPosition, 264); + brimstoneMagic.velocity = npc.DirectionTo(player.Center).RotatedByRandom(0.24f) * Main.rand.NextFloat(5f, 7f) + npc.velocity; + brimstoneMagic.scale = Main.rand.NextFloat(1.25f, 1.35f); + brimstoneMagic.noGravity = true; + brimstoneMagic.color = Color.OrangeRed; + brimstoneMagic.fadeIn = 1.5f; + brimstoneMagic.noLight = true; + } + npc.localAI[1] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) { Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); - npc.localAI[1] = 0f; float num837 = 5f * uDieLul; int num839 = ModContent.ProjectileType(); num836 = (float)Math.Sqrt(num834 * num834 + num835 * num835); @@ -1481,9 +1807,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.ai[1] = -1f; npc.TargetClosest(); npc.netUpdate = true; - } - } - } + } + } + } if (npc.life < npc.lifeMax * 0.4) { @@ -1497,6 +1823,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas } #endregion #region Transition + + // TODO: Add a special flame that encases SCal during the transition phase instead of just dust. else if (npc.ai[0] == 1f || npc.ai[0] == 2f) { npc.dontTakeDamage = true; @@ -1515,8 +1843,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.ai[2] = 0f; } - npc.rotation += npc.ai[2]; - npc.ai[1] += 1f; if (npc.ai[1] == 100f) { @@ -1534,7 +1860,12 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); + for (int i = 0; i < 4; i++) + { + Dust brimstoneFire = Dust.NewDustPerfect(npc.Center + Main.rand.NextVector2Square(-24f, 24f), (int)CalamityDusts.Brimstone); + brimstoneFire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2.75f, 4.25f); + brimstoneFire.noGravity = true; + } if (!canDespawn) { @@ -1728,78 +2059,124 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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.rotation = (float)Math.Atan2(num826, num825) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += wormAlive ? 0.5f : 1f; - if (npc.localAI[1] > 60f) - { - npc.localAI[1] = 0f; + npc.localAI[1] += wormAlive ? 0.5f : 1f; + if (npc.localAI[1] > 60f) + { + npc.localAI[1] = 0f; - float num828 = 10f * uDieLul; - 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 num828 = 10f * uDieLul; + 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 = num828 / num183; - num180 *= num183; - num182 *= num183; - value9.X += num180; - value9.Y += num182; + num183 = num828 / num183; + num180 *= num183; + num182 *= num183; + value9.X += num180; + value9.Y += num182; - int randomShot = Main.rand.Next(6); - if (randomShot == 0 && canFireSplitingFireball) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); - canFireSplitingFireball = false; - randomShot = ModContent.ProjectileType(); - num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num828 / num827; - num825 *= num827; - num826 *= num827; - vector82.X += num825 * 8f; - vector82.Y += num826 * 8f; - Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, fireblastDamage, 0f, Main.myPlayer, 0f, 0f); - } - else if (randomShot == 1 && canFireSplitingFireball) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); - canFireSplitingFireball = false; - randomShot = ModContent.ProjectileType(); - num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); - num827 = num828 / num827; - num825 *= num827; - num826 *= num827; - vector82.X += num825 * 8f; - vector82.Y += num826 * 8f; - Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, gigablastDamage, 0f, Main.myPlayer, 0f, 0f); - } - else - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); - canFireSplitingFireball = true; - randomShot = ModContent.ProjectileType(); - for (int num186 = 0; num186 < 8; 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); - float speedBoost = num186 > 3 ? -(num186 - 3) : num186; - num183 = (8f + speedBoost) / num183; - num180 *= num183; - num182 *= num183; - Projectile.NewProjectile(value9.X, value9.Y, num180 + speedBoost, num182 + speedBoost, randomShot, barrageDamage, 0f, Main.myPlayer, 0f, 0f); - } - } - } - } - } + int randomShot = Main.rand.Next(6); + if (randomShot == 0 && canFireSplitingFireball) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); + canFireSplitingFireball = false; + randomShot = ModContent.ProjectileType(); + num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); + num827 = num828 / num827; + num825 *= num827; + num826 *= num827; + vector82.X += num825 * 8f; + vector82.Y += num826 * 8f; + + for (int i = 0; i < 16; i++) + { + Dust magic = Dust.NewDustPerfect(value9, 264); + magic.velocity = new Vector2(num180, num182).RotatedByRandom(0.36f) * Main.rand.NextFloat(0.9f, 1.1f) * 1.2f; + magic.color = Color.OrangeRed; + magic.scale = 1.3f; + magic.fadeIn = 0.6f; + magic.noLight = true; + magic.noGravity = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, fireblastDamage, 0f, Main.myPlayer, 0f, 0f); + npc.netUpdate = true; + } + } + else if (randomShot == 1 && canFireSplitingFireball) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); + canFireSplitingFireball = false; + randomShot = ModContent.ProjectileType(); + num827 = (float)Math.Sqrt(num825 * num825 + num826 * num826); + num827 = num828 / num827; + num825 *= num827; + num826 *= num827; + vector82.X += num825 * 8f; + vector82.Y += num826 * 8f; + + for (int i = 0; i < 24; i++) + { + Dust magic = Dust.NewDustPerfect(value9, (int)CalamityDusts.Brimstone); + magic.velocity = new Vector2(num180, num182).RotatedByRandom(0.36f) * Main.rand.NextFloat(0.9f, 1.1f) * 1.6f; + magic.color = Color.Red; + magic.scale = 1.5f; + magic.fadeIn = 0.8f; + magic.noLight = true; + magic.noGravity = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(vector82.X, vector82.Y, num825, num826, randomShot, gigablastDamage, 0f, Main.myPlayer, 0f, 0f); + npc.netUpdate = true; + } + } + else + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); + canFireSplitingFireball = true; + randomShot = ModContent.ProjectileType(); + for (int num186 = 0; num186 < 8; 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); + float speedBoost = num186 > 3 ? -(num186 - 3) : num186; + num183 = (8f + speedBoost) / num183; + num180 *= num183; + num182 *= num183; + + for (int i = 0; i < 10; i++) + { + Vector2 magicDustVelocity = new Vector2(num180 + speedBoost, num182 + speedBoost); + magicDustVelocity *= MathHelper.Lerp(0.3f, 1f, i / 10f); + + Dust magic = Dust.NewDustPerfect(value9, 264); + magic.velocity = magicDustVelocity; + magic.color = Color.Red; + magic.scale = MathHelper.Lerp(0.975f, 1.7f, i / 10f); + magic.fadeIn = 0.9f; + magic.noLight = true; + magic.noGravity = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Projectile.NewProjectile(value9.X, value9.Y, num180 + speedBoost, num182 + speedBoost, randomShot, barrageDamage, 0f, Main.myPlayer, 0f, 0f); + npc.netUpdate = true; + } + } + } + } + } else if (npc.ai[1] == 1f) { - npc.rotation = num803; float num383 = wormAlive ? 31f : 35f; if (npc.life < npc.lifeMax * 0.3) num383 += 1f; @@ -1818,7 +2195,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas { 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; } @@ -1837,22 +2218,31 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.velocity.Y = 0f; } } - else - npc.rotation = (float)Math.Atan2(npc.velocity.Y, npc.velocity.X) - MathHelper.PiOver2; - if (npc.ai[2] >= 70f) - { - npc.ai[3] += 1f; - npc.ai[2] = 0f; - npc.TargetClosest(); - npc.rotation = num803; - if (npc.ai[3] >= 1f) - npc.ai[1] = -1f; - else - npc.ai[1] = 1f; - } - } + bool willChargeAgain = npc.ai[3] + 1 < 1; + + if (npc.ai[2] >= 70f) + { + 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[2] > 50f) + { + float idealRotation = npc.AngleTo(player.Center); + shieldRotation = shieldRotation.AngleLerp(idealRotation, 0.125f); + shieldRotation = shieldRotation.AngleTowards(idealRotation, 0.18f); + } + + FrameType = FrameAnimationType.FasterUpwardDraft; + } else if (npc.ai[1] == 3f) { float num412 = 32f; @@ -1869,7 +2259,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (npc.position.X + (npc.width / 2) < player.position.X + player.width) num414 = -1; - Vector2 vector40 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + 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); @@ -1926,7 +2317,19 @@ namespace CalamityMod.NPCs.SupremeCalamitas num416 = player.position.Y + (player.height / 2) - vector40.Y; Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneHellblastSound"), npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) + // Release a burst of magic dust along with a brimstone hellblast skull. + for (int i = 0; i < 25; i++) + { + Dust brimstoneMagic = Dust.NewDustPerfect(handPosition, 264); + brimstoneMagic.velocity = npc.DirectionTo(player.Center).RotatedByRandom(0.31f) * Main.rand.NextFloat(3f, 5f) + npc.velocity; + brimstoneMagic.scale = Main.rand.NextFloat(1.25f, 1.35f); + brimstoneMagic.noGravity = true; + brimstoneMagic.color = Color.OrangeRed; + brimstoneMagic.fadeIn = 1.5f; + brimstoneMagic.noLight = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient) { float num418 = 10f * uDieLul; int num420 = ModContent.ProjectileType(); @@ -1939,8 +2342,20 @@ namespace CalamityMod.NPCs.SupremeCalamitas Projectile.NewProjectile(vector40.X, vector40.Y, num415, num416, num420, hellblastDamage, 0f, Main.myPlayer, 0f, 0f); } } - } - } + } + + if (Main.rand.NextBool(2)) + { + Dust brimstoneMagic = Dust.NewDustPerfect(handPosition, 264); + brimstoneMagic.velocity = Vector2.UnitY.RotatedByRandom(0.14f) * Main.rand.NextFloat(-3.5f, -3f) + npc.velocity; + brimstoneMagic.scale = Main.rand.NextFloat(1.25f, 1.35f); + brimstoneMagic.noGravity = true; + brimstoneMagic.noLight = true; + } + + FrameChangeSpeed = 0.245f; + FrameType = FrameAnimationType.PunchHandCast; + } else if (npc.ai[1] == 4f) { int num831 = 1; @@ -1997,40 +2412,290 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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; - npc.rotation = (float)Math.Atan2(num835, num834) - MathHelper.PiOver2; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - npc.localAI[1] += wormAlive ? 0.5f : 1f; - if (npc.localAI[1] > 100f) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); - npc.localAI[1] = 0f; - 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; - int shot = Projectile.NewProjectile(vector83.X, vector83.Y, num834, num835, num839, fireblastDamage, 0f, Main.myPlayer, 0f, 0f); - } - } + int shootRate = wormAlive ? 200 : 100; + npc.localAI[1]++; + if (npc.ai[2] > 40f && (npc.localAI[1] > shootRate - 18 || npc.localAI[1] <= 15f)) + { + FrameChangeSpeed = 0f; + FrameType = FrameAnimationType.BlastPunchCast; + } - npc.ai[2] += 1f; + if (npc.localAI[1] > shootRate) + { + Vector2 handPosition = npc.Center + new Vector2(npc.spriteDirection * -22f, 2f); + + // Release a burst of magic dust when punching. + for (int i = 0; i < 25; i++) + { + Dust brimstoneMagic = Dust.NewDustPerfect(handPosition, 264); + brimstoneMagic.velocity = npc.DirectionTo(player.Center).RotatedByRandom(0.24f) * Main.rand.NextFloat(5f, 7f) + npc.velocity; + brimstoneMagic.scale = Main.rand.NextFloat(1.25f, 1.35f); + brimstoneMagic.noGravity = true; + brimstoneMagic.color = Color.OrangeRed; + brimstoneMagic.fadeIn = 1.5f; + brimstoneMagic.noLight = true; + } + npc.localAI[1] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneBigShoot"), npc.Center); + npc.localAI[1] = 0f; + 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] >= 240f) { npc.ai[1] = -1f; npc.TargetClosest(); npc.netUpdate = true; - } - } + } + } } } #endregion } + public void DoHeartsSpawningCastAnimation(Player target, bool death) + { + int tempSpawnY = spawnY; + tempSpawnY += 250; + if (death) + tempSpawnY -= 50; + + List heartSpawnPositions = new List(); + for (int i = 0; i < 5; i++) + { + heartSpawnPositions.Add(new Vector2(spawnX + spawnXAdd * i + 50, tempSpawnY + spawnYAdd * i)); + heartSpawnPositions.Add(new Vector2(spawnX2 - spawnXAdd * i - 50, tempSpawnY + spawnYAdd * i)); + } + + float castCompletion = Utils.InverseLerp(sepulcherSpawnCastTime - 25f, 0f, attackCastDelay, true); + Vector2 armPosition = npc.Center + Vector2.UnitX * npc.spriteDirection * -8f; + + // Emit dust at the arm position as a sort of magic effect. + Dust magic = Dust.NewDustPerfect(armPosition, 264); + magic.velocity = Vector2.UnitY.RotatedByRandom(0.17f) * -Main.rand.NextFloat(2.7f, 4.1f); + magic.color = Color.OrangeRed; + magic.noLight = true; + magic.fadeIn = 0.6f; + magic.noGravity = true; + + foreach (Vector2 heartSpawnPosition in heartSpawnPositions) + { + Vector2 leftDustPosition = Vector2.CatmullRom(armPosition + Vector2.UnitY * 1000f, armPosition, heartSpawnPosition, heartSpawnPosition + Vector2.UnitY * 1000f, castCompletion); + + Dust castMagicDust = Dust.NewDustPerfect(leftDustPosition, 267); + castMagicDust.scale = 1.67f; + castMagicDust.velocity = Main.rand.NextVector2CircularEdge(0.2f, 0.2f); + castMagicDust.fadeIn = 0.67f; + castMagicDust.color = Color.Red; + castMagicDust.noGravity = true; + } + + if (attackCastDelay == 0) + { + string key = "Mods.CalamityMod.SCalStartText"; + if (npc.life <= npc.lifeMax * 0.08) + key = "Mods.CalamityMod.SCalSepulcher2Text"; + + if (!BossRushEvent.BossRushActive) + { + if (CalamityWorld.downedSCal) + key += "Rematch"; + CalamityUtils.DisplayLocalizedText(key, textColor); + } + foreach (Vector2 heartSpawnPosition in heartSpawnPositions) + { + // Make the hearts appear in a burst of flame. + for (int i = 0; i < 20; i++) + { + Dust castFire = Dust.NewDustPerfect(heartSpawnPosition + Main.rand.NextVector2Square(-30f, 30f), (int)CalamityDusts.Brimstone); + castFire.velocity = Vector2.UnitY.RotatedByRandom(0.08f) * -Main.rand.NextFloat(3f, 4.45f); + castFire.scale = Main.rand.NextFloat(1.35f, 1.6f); + castFire.fadeIn = 1.25f; + castFire.noGravity = true; + } + } + + // And play a fire-like sound effect. + Main.PlaySound(SoundID.DD2_BetsyWindAttack, target.Center); + hasSummonedSepulcher1 = true; + hasSummonedSepulcher2 = npc.life <= npc.lifeMax * 0.08; + + // TODO: Resprite brimstone hearts a bit. + if (Main.netMode != NetmodeID.MultiplayerClient) + { + List hearts = new List(); + for (int x = 0; x < 5; x++) + { + hearts.Add(NPC.NewNPC(spawnX + 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); + spawnX += spawnXAdd; + + hearts.Add(NPC.NewNPC(spawnX2 - 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); + spawnX2 -= spawnXAdd; + tempSpawnY += spawnYAdd; + } + + ConnectAllBrimstoneHearts(hearts); + + spawnX = spawnXReset; + spawnX2 = spawnXReset2; + spawnY = spawnYReset; + NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); + npc.netUpdate = true; + } + } + } + + public void DoBrothersSpawningCastAnimation(int bodyWidth, int bodyHeight) + { + Vector2 leftOfCircle = npc.Center + Vector2.UnitY * bodyHeight * 0.5f - Vector2.UnitX * bodyWidth * 0.45f; + Vector2 rightOfCircle = npc.Center + Vector2.UnitY * bodyHeight * 0.5f + Vector2.UnitX * bodyWidth * 0.45f; + + if (Main.netMode != NetmodeID.MultiplayerClient && catastropheSpawnPosition == Vector2.Zero) + { + catastropheSpawnPosition = npc.Center - Vector2.UnitX * 500f; + cataclysmSpawnPosition = npc.Center + Vector2.UnitX * 500f; + npc.netUpdate = true; + } + + // Draw some magic dust much like the sandstorm elemental cast that approaches where the brothers will spawn. + if (attackCastDelay < brothersSpawnCastTime - 45f && attackCastDelay >= 60f) + { + float castCompletion = Utils.InverseLerp(brothersSpawnCastTime - 45f, 60f, attackCastDelay); + + Vector2 leftDustPosition = Vector2.CatmullRom(leftOfCircle + Vector2.UnitY * 1000f, leftOfCircle, catastropheSpawnPosition, catastropheSpawnPosition + Vector2.UnitY * 1000f, castCompletion); + Vector2 rightDustPosition = Vector2.CatmullRom(rightOfCircle + Vector2.UnitY * 1000f, rightOfCircle, cataclysmSpawnPosition, cataclysmSpawnPosition + Vector2.UnitY * 1000f, castCompletion); + + Dust castMagicDust = Dust.NewDustPerfect(leftDustPosition, 267); + castMagicDust.scale = 1.67f; + castMagicDust.velocity = Main.rand.NextVector2CircularEdge(0.2f, 0.2f); + castMagicDust.color = Color.Red; + castMagicDust.noGravity = true; + + castMagicDust = Dust.CloneDust(castMagicDust); + castMagicDust.position = rightDustPosition; + } + + // Make some magic effects at where the bros will spawn. + if (attackCastDelay < 60f) + { + float burnPower = Utils.InverseLerp(60f, 20f, attackCastDelay); + if (attackCastDelay == 0f) + burnPower = 4f; + + for (int i = 0; i < MathHelper.Lerp(5, 25, burnPower); i++) + { + Dust fire = Dust.NewDustPerfect(catastropheSpawnPosition + Main.rand.NextVector2Circular(60f, 60f), 264); + fire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 4f); + if (attackCastDelay == 0) + { + fire.velocity += Main.rand.NextVector2Circular(4f, 4f); + fire.fadeIn = 1.6f; + } + fire.noGravity = true; + fire.noLight = true; + fire.color = Color.OrangeRed; + fire.scale = 1.4f + fire.velocity.Y * 0.16f; + + fire = Dust.NewDustPerfect(cataclysmSpawnPosition + Main.rand.NextVector2Circular(60f, 60f), 264); + fire.velocity = Vector2.UnitY * -Main.rand.NextFloat(2f, 4f); + if (attackCastDelay == 0) + { + fire.velocity += Main.rand.NextVector2Circular(4f, 4f); + fire.fadeIn = 1.6f; + } + fire.noGravity = true; + fire.noLight = true; + fire.color = Color.OrangeRed; + fire.scale = 1.4f + fire.velocity.Y * 0.16f; + } + } + + // And spawn them. + if (attackCastDelay == 0) + { + if (!BossRushEvent.BossRushActive) + { + string key = "Mods.CalamityMod.SCalBrothersText"; + if (CalamityWorld.downedSCal) + key += "Rematch"; + + CalamityUtils.DisplayLocalizedText(key, textColor); + if (CalamityWorld.downedSCal) + CalamityUtils.DisplayLocalizedText(key + "2", textColor); + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + CalamityUtils.SpawnBossBetter(catastropheSpawnPosition, ModContent.NPCType()); + CalamityUtils.SpawnBossBetter(cataclysmSpawnPosition, ModContent.NPCType()); + } + Main.PlaySound(SoundID.DD2_DarkMageHealImpact, npc.Center); + hasSummonedBrothers = true; + } + } + + public void ConnectAllBrimstoneHearts(List heartIndices) + { + int heartType = ModContent.NPCType(); + + // Ensure that the hearts go in order based on the arena. + IEnumerable hearts = heartIndices.Select(i => Main.npc[i]); + hearts = hearts.OrderByDescending(heart => Math.Abs(heart.Center.X - safeBox.Left)).ToList(); + + int firstHeartIndex = heartIndices.First(); + int lastHeartIndex = heartIndices.Last(); + + heartIndices = heartIndices.OrderByDescending(heart => Math.Abs(Main.npc[heart].Center.X - safeBox.Left)).ToList(); + + for (int i = 0; i < hearts.Count(); i++) + { + NPC heart = hearts.ElementAt(i); + + Vector2 endpoint = safeBox.TopLeft(); + Vector2 oppositePosition = Vector2.Zero; + + for (int j = 0; j < 2; j++) + { + int tries = 0; + do + { + endpoint.X = heart.Center.X + (j == 0).ToDirectionInt() * Main.rand.NextFloat(75f, 250f); + tries++; + if (tries >= 100) + break; + } + while (Math.Abs(endpoint.X - safeBox.Center.X) > safeBox.Width * 0.48f); + + if (tries >= 100) + endpoint.X = MathHelper.Clamp(endpoint.X, safeBox.Left, safeBox.Right); + + heart.ModNPC().ChainEndpoints.Add(endpoint); + } + + if (Main.rand.NextBool(2)) + { + endpoint.X = heart.Center.X + Main.rand.NextBool(2).ToDirectionInt() * Main.rand.NextFloat(45f, 360f); + endpoint.X = MathHelper.Clamp(endpoint.X, safeBox.Left, safeBox.Right); + heart.ModNPC().ChainEndpoints.Add(endpoint); + } + + heart.netUpdate = true; + } + } + #region Loot public override void BossLoot(ref string name, ref int potionType) { @@ -2044,9 +2709,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas //Does not occur in Boss Rush due to weakened SCal + stronger weapons (rarely occurs with just Cal gear) if ((lootTimer < 6000) && !BossRushEvent.BossRushActive) { - string key = "Mods.CalamityMod.SupremeBossText2"; - Color messageColor = Color.Orange; - CalamityUtils.DisplayLocalizedText(key, messageColor); + if (!BossRushEvent.BossRushActive) + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.SCalFunnyCheatText", textColor); return true; } @@ -2055,9 +2719,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void NPCLoot() { - DeathMessage(); + // Create a teleport line effect + Dust.QuickDustLine(npc.Center, initialRitualPosition, 500f, Color.Red); + npc.Center = initialRitualPosition; - // Incrase the player's SCal kill count + // Increase the player's SCal kill count if (Main.player[npc.target].Calamity().sCalKillCount < 5) Main.player[npc.target].Calamity().sCalKillCount++; @@ -2073,6 +2739,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Rejoice! Hybrid weapons are no more, so this list is no longer cluttered. DropHelper.DropItemFromSetCondition(npc, true, Main.expertMode, ModContent.ItemType(), + ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), ModContent.ItemType(), @@ -2103,62 +2770,30 @@ namespace CalamityMod.NPCs.SupremeCalamitas DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, !CalamityWorld.downedSCal); - // Mark Supreme Calamitas as dead + // Mark Supreme Calamitas as defeated CalamityWorld.downedSCal = true; CalamityNetcode.SyncWorld(); } #endregion - private void DeathMessage() - { - Color messageColor = Color.Orange; - string key; - - // If the player has never killed SCal before, comment on how many attempts it took - if (Main.player[npc.target].Calamity().sCalKillCount == 0) - { - switch (Main.LocalPlayer.Calamity().sCalDeathCount) - { - case 0: - key = "Mods.CalamityMod.SupremeBossText16"; - break; - case 1: - key = "Mods.CalamityMod.SupremeBossText17"; - break; - case 2: - key = "Mods.CalamityMod.SupremeBossText18"; - break; - case 3: // Three deaths exactly rewards Lul - key = "Mods.CalamityMod.SupremeBossText19"; - DropHelper.DropItem(npc, ModContent.ItemType()); - break; - default: // Four or more deaths: Lul is permanently missed - key = "Mods.CalamityMod.SupremeBossText10"; - break; - } - } - else - { - // If SCal has been killed before, instead comment on her respawning - key = "Mods.CalamityMod.SupremeBossText10"; - } - - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType()) - { - damage /= 2; - } - } - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); } + // Prevent the player from accidentally killing SCal instead of having her turn into a town NPC. + public override bool CheckDead() + { + if (BossRushEvent.BossRushActive) + return true; + + npc.life = 1; + npc.active = true; + npc.dontTakeDamage = true; + npc.netUpdate = true; + return false; + } + public override bool CheckActive() { return canDespawn; @@ -2173,21 +2808,44 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; - return true; + + Vector2 shieldCenter = npc.Center + shieldRotation.ToRotationVector2() * 24f; + Vector2 shieldTop = shieldCenter - (shieldRotation + MathHelper.PiOver2).ToRotationVector2() * 61f; + Vector2 shieldBottom = shieldCenter - (shieldRotation + MathHelper.PiOver2).ToRotationVector2() * 61f; + + float _ = 0f; + bool collidingWithShield = Collision.CheckAABBvLineCollision(target.TopLeft, target.Size, shieldTop, shieldBottom, 64f, ref _) && shieldOpacity > 0.55f; + return collidingWithShield || npc.Hitbox.Intersects(target.Hitbox); } 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; + bool wormAlive = false; + if (CalamityGlobalNPC.SCalWorm != -1) + wormAlive = Main.npc[CalamityGlobalNPC.SCalWorm].active; + int shootRate = wormAlive ? 200 : 100; + + // Special punch logic for the blast attack. + if (FrameType == FrameAnimationType.BlastPunchCast && (npc.localAI[1] > shootRate - 18 || npc.localAI[1] <= 15f)) + { + if (npc.localAI[1] > shootRate - 18) + npc.frame.Y = (int)MathHelper.Lerp(0, 3, Utils.InverseLerp(shootRate - 18, shootRate, npc.localAI[1], true)); + else + npc.frame.Y = (int)MathHelper.Lerp(3, 5, Utils.InverseLerp(0f, 15f, npc.localAI[1], true)); + npc.frame.Y += (int)FrameType * 6; + } + else + { + npc.frameCounter += FrameChangeSpeed; + npc.frameCounter %= 6; + npc.frame.Y = (int)npc.frameCounter + (int)FrameType * 6; + } } public override Color? GetAlpha(Color drawColor) { if (willCharge) - return new Color(0, 0, 0, npc.alpha); + return drawColor * npc.Opacity * 0.45f; return null; } @@ -2197,13 +2855,16 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = npc.ai[0] > 1f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SupremeCalamitas2") : 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 = 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; - if (CalamityConfig.Instance.Afterimages) + 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) { @@ -2212,41 +2873,135 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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, 4f + npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + 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, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + vector43 -= new Vector2(texture2D15.Width / 2f, texture2D15.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); - texture2D15 = npc.ai[0] > 1f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SupremeCalamitas2Glow") : ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SupremeCalamitasGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); + if (inPhase2) + { + // Make the sprite jitter with rage in phase 2. This does not happen in rematches since it would make little sense logically. + if (!CalamityWorld.downedSCal) + vector43 += Main.rand.NextVector2Circular(0.25f, 0.7f); - 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 / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, 4f + 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); + // And gain a flaming aura. + Color auraColor = npc.GetAlpha(Color.Red) * 0.4f; + for (int i = 0; i < 7; i++) + { + Vector2 rotationalDrawOffset = (MathHelper.TwoPi * i / 7f + Main.GlobalTime * 4f).ToRotationVector2(); + rotationalDrawOffset *= MathHelper.Lerp(3f, 4.25f, (float)Math.Cos(Main.GlobalTime * 4f) * 0.5f + 0.5f); + spriteBatch.Draw(texture2D15, vector43 + rotationalDrawOffset, frame, auraColor, npc.rotation, vector11, npc.scale * 1.1f, spriteEffects, 0f); + } + } + spriteBatch.Draw(texture2D15, vector43, frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + DrawForcefield(spriteBatch); + DrawShield(spriteBatch); return false; } + public void DrawForcefield(SpriteBatch spriteBatch) + { + spriteBatch.EnterShaderRegion(); + + float intensity = hitTimer / 35f; + + // Shield intensity is always high during invincibility, except during cast animations, so that she can be more easily seen. + if (npc.dontTakeDamage && attackCastDelay <= 0) + intensity = 0.75f + Math.Abs((float)Math.Cos(Main.GlobalTime * 1.7f)) * 0.1f; + + // Make the forcefield weaker in the second phase as a means of showing desparation. + if (npc.ai[0] >= 3f) + intensity *= 0.6f; + + float lifeRatio = npc.life / (float)npc.lifeMax; + float flickerPower = 0f; + if (lifeRatio < 0.6f) + flickerPower += 0.1f; + if (lifeRatio < 0.3f) + flickerPower += 0.15f; + if (lifeRatio < 0.1f) + flickerPower += 0.2f; + if (lifeRatio < 0.05f) + flickerPower += 0.1f; + float opacity = forcefieldOpacity; + opacity *= MathHelper.Lerp(1f, 1f - flickerPower, (float)Math.Pow(Math.Cos(Main.GlobalTime * MathHelper.Lerp(3f, 9f, flickerPower)), 24D)); + + // During/prior to a charge the forcefield is always darker than usual and thus its intensity is also higher. + if (!npc.dontTakeDamage && (willCharge || npc.ai[1] == 2f)) + intensity = 1.1f; + + Texture2D forcefieldTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/CalamitasShield"); + GameShaders.Misc["CalamityMod:SupremeShield"].UseImage("Images/Misc/Perlin"); + + Color forcefieldColor = Color.DarkViolet; + Color secondaryForcefieldColor = Color.Red * 1.4f; + + if (!npc.dontTakeDamage && (willCharge || npc.ai[1] == 2f)) + { + forcefieldColor *= 0.25f; + secondaryForcefieldColor = Color.Lerp(secondaryForcefieldColor, Color.Black, 0.7f); + } + + forcefieldColor *= opacity; + secondaryForcefieldColor *= opacity; + + GameShaders.Misc["CalamityMod:SupremeShield"].UseSecondaryColor(secondaryForcefieldColor); + GameShaders.Misc["CalamityMod:SupremeShield"].UseColor(forcefieldColor); + GameShaders.Misc["CalamityMod:SupremeShield"].UseSaturation(intensity); + GameShaders.Misc["CalamityMod:SupremeShield"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:SupremeShield"].Apply(); + + spriteBatch.Draw(forcefieldTexture, npc.Center - Main.screenPosition, null, Color.White * opacity, 0f, forcefieldTexture.Size() * 0.5f, forcefieldScale * 3f, SpriteEffects.None, 0f); + + spriteBatch.ExitShaderRegion(); + } + + public void DrawShield(SpriteBatch spriteBatch) + { + float jawRotation = shieldRotation; + float jawRotationOffset = 0f; + + // Have an agape mouth when charging. + if (npc.ai[1] == 2f) + jawRotationOffset -= 0.71f; + + // And a laugh right before the charge. + else if (willCharge && npc.ai[1] != 2f && AttackCloseToBeingOver) + jawRotationOffset += MathHelper.Lerp(0.04f, -0.82f, (float)Math.Sin(Main.GlobalTime * 17.2f) * 0.5f + 0.5f); + + Color shieldColor = Color.White * shieldOpacity; + Texture2D shieldSkullTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SupremeShieldTop"); + Texture2D shieldJawTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SupremeShieldBottom"); + Vector2 drawPosition = npc.Center + shieldRotation.ToRotationVector2() * 24f - Main.screenPosition; + Vector2 jawDrawPosition = drawPosition; + SpriteEffects direction = Math.Cos(shieldRotation) > 0 ? SpriteEffects.None : SpriteEffects.FlipVertically; + if (direction == SpriteEffects.FlipVertically) + jawDrawPosition += (shieldRotation - MathHelper.PiOver2).ToRotationVector2() * 42f; + else + { + jawDrawPosition += (shieldRotation + MathHelper.PiOver2).ToRotationVector2() * 42f; + jawRotationOffset *= -1f; + } + + spriteBatch.Draw(shieldJawTexture, jawDrawPosition, null, shieldColor, jawRotation + jawRotationOffset, shieldJawTexture.Size() * 0.5f, 1f, direction, 0f); + spriteBatch.Draw(shieldSkullTexture, drawPosition, null, shieldColor, shieldRotation, shieldSkullTexture.Size() * 0.5f, 1f, direction, 0f); + } + public override void HitEffect(int hitDirection, double damage) { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + hitTimer = 35; + npc.netUpdate = true; + } + for (int k = 0; k < 5; k++) { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, hitDirection, -1f, 0, default, 1f); diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.png b/NPCs/SupremeCalamitas/SupremeCalamitas.png index 0eea683573..1040ac0397 100644 Binary files a/NPCs/SupremeCalamitas/SupremeCalamitas.png and b/NPCs/SupremeCalamitas/SupremeCalamitas.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas2.png b/NPCs/SupremeCalamitas/SupremeCalamitas2.png deleted file mode 100644 index 87017c3b28..0000000000 Binary files a/NPCs/SupremeCalamitas/SupremeCalamitas2.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas2Glow.png b/NPCs/SupremeCalamitas/SupremeCalamitas2Glow.png deleted file mode 100644 index b7730d4549..0000000000 Binary files a/NPCs/SupremeCalamitas/SupremeCalamitas2Glow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitasGlow.png b/NPCs/SupremeCalamitas/SupremeCalamitasGlow.png deleted file mode 100644 index f09dcde7e3..0000000000 Binary files a/NPCs/SupremeCalamitas/SupremeCalamitasGlow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitasHooded.png b/NPCs/SupremeCalamitas/SupremeCalamitasHooded.png new file mode 100644 index 0000000000..23b956ca93 Binary files /dev/null and b/NPCs/SupremeCalamitas/SupremeCalamitasHooded.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas_Head_Boss.png b/NPCs/SupremeCalamitas/SupremeCalamitas_Head_Boss.png deleted file mode 100644 index 2b3078e2ef..0000000000 Binary files a/NPCs/SupremeCalamitas/SupremeCalamitas_Head_Boss.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index 69a90acd19..af55c1e4bf 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Summon; @@ -35,7 +36,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.DR_NERD(0.25f, null, null, null, true); CalamityGlobalNPC global = npc.Calamity(); global.multDRReductions.Add(BuffID.CursedInferno, 0.9f); - npc.LifeMaxNERB(1200000, 1500000); + npc.LifeMaxNERB(240000, 276000, 100000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; @@ -75,6 +76,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas return; } + float totalLifeRatio = npc.life / (float)npc.lifeMax; + if (CalamityGlobalNPC.SCalCatastrophe != -1) + { + if (Main.npc[CalamityGlobalNPC.SCalCatastrophe].active) + totalLifeRatio += Main.npc[CalamityGlobalNPC.SCalCatastrophe].life / (float)Main.npc[CalamityGlobalNPC.SCalCatastrophe].lifeMax; + } + totalLifeRatio *= 0.5f; + // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); @@ -93,8 +102,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas num677 *= 0.5f; } - bool deadBrother = !NPC.AnyNPCs(ModContent.NPCType()); - int scale = deadBrother ? 5 : 2; + int scale = (int)Math.Round(MathHelper.Lerp(2f, 6.5f, 1f - totalLifeRatio)); if (npc.ai[3] < distanceX) { npc.ai[3] += scale; @@ -154,11 +162,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (npc.localAI[0] >= 120f) { - npc.ai[1] += 1f; - if (deadBrother || CalamityWorld.malice) - { - npc.ai[1] += 1f; - } + float fireRate = CalamityWorld.malice ? 2f : MathHelper.Lerp(1f, 2.5f, 1f - totalLifeRatio); + npc.ai[1] += fireRate; if (npc.ai[1] >= 60f) { npc.ai[1] = 0f; @@ -170,11 +175,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas Projectile.NewProjectile(npc.Center, new Vector2(-8f, 0f), type, damage, 0f, Main.myPlayer); } } - npc.ai[2] += 1f; - if (deadBrother || CalamityWorld.malice) - { - npc.ai[2] += 2f; - } + fireRate = CalamityWorld.malice ? 3f : MathHelper.Lerp(1f, 4f, 1f - totalLifeRatio); + npc.ai[2] += fireRate; if (npc.ai[2] >= 300f) { npc.ai[2] = 0f; @@ -203,14 +205,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType()) - { - damage /= 2; - } - } - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); @@ -238,14 +232,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/SupremeCataclysmGlow"); @@ -260,7 +254,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -270,17 +264,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas return false; } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; - public override bool PreNPCLoot() - { - return 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/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index cd05d9fcdd..3f626975e3 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Summon; @@ -35,8 +36,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.DR_NERD(0.25f, null, null, null, true); CalamityGlobalNPC global = npc.Calamity(); global.multDRReductions.Add(BuffID.CursedInferno, 0.9f); - npc.LifeMaxNERB(1200000, 1500000); - double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.LifeMaxNERB(240000, 276000, 100000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.aiStyle = -1; aiType = -1; @@ -75,6 +76,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas return; } + float totalLifeRatio = npc.life / (float)npc.lifeMax; + if (CalamityGlobalNPC.SCalCataclysm != -1) + { + if (Main.npc[CalamityGlobalNPC.SCalCataclysm].active) + totalLifeRatio += Main.npc[CalamityGlobalNPC.SCalCataclysm].life / (float)Main.npc[CalamityGlobalNPC.SCalCataclysm].lifeMax; + } + totalLifeRatio *= 0.5f; + // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); @@ -93,9 +102,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas num677 *= 0.5f; } - bool deadBrother = !NPC.AnyNPCs(ModContent.NPCType()); - int scale = deadBrother ? 5 : 2; - if (npc.ai[3] < distanceX) + int scale = (int)Math.Round(MathHelper.Lerp(2f, 6.5f, 1f - totalLifeRatio)); + if (npc.ai[3] < distanceX) { npc.ai[3] += scale; distanceY -= scale; @@ -154,11 +162,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas } if (npc.localAI[0] >= 120f) { - npc.ai[1] += 1f; - if (deadBrother || CalamityWorld.malice) - { - npc.ai[1] += 1f; - } + float fireRate = CalamityWorld.malice ? 2f : MathHelper.Lerp(1f, 2.5f, 1f - totalLifeRatio); + npc.ai[1] += fireRate; if (npc.ai[1] >= 45f) { npc.ai[1] = 0f; @@ -170,12 +175,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas Projectile.NewProjectile(npc.Center, new Vector2(4f, 0f), type, damage, 0f, Main.myPlayer); } } - npc.ai[2] += 1f; - if (deadBrother || CalamityWorld.malice) - { - npc.ai[2] += 2f; - } - if (npc.ai[2] >= 300f) + fireRate = CalamityWorld.malice ? 3f : MathHelper.Lerp(1f, 4f, 1f - totalLifeRatio); + npc.ai[2] += fireRate; + if (npc.ai[2] >= 300f) { npc.ai[2] = 0f; float speed = 7f; @@ -203,14 +205,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) - { - if (projectile.type == ModContent.ProjectileType()) - { - damage /= 2; - } - } - public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) { return !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); @@ -238,14 +232,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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/SupremeCatastropheGlow"); @@ -260,7 +254,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas 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, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -270,17 +264,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas return false; } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; - public override bool PreNPCLoot() - { - return 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/SupremeCalamitas/SupremeShieldBottom.png b/NPCs/SupremeCalamitas/SupremeShieldBottom.png new file mode 100644 index 0000000000..dbcdfc736d Binary files /dev/null and b/NPCs/SupremeCalamitas/SupremeShieldBottom.png differ diff --git a/NPCs/SupremeCalamitas/SupremeShieldTop.png b/NPCs/SupremeCalamitas/SupremeShieldTop.png new file mode 100644 index 0000000000..5154a5a348 Binary files /dev/null and b/NPCs/SupremeCalamitas/SupremeShieldTop.png differ diff --git a/NPCs/SupremeCalamitas/unknown.png b/NPCs/SupremeCalamitas/unknown.png new file mode 100644 index 0000000000..8aec7550d7 Binary files /dev/null and b/NPCs/SupremeCalamitas/unknown.png differ diff --git a/NPCs/TownNPCs/FAP.cs b/NPCs/TownNPCs/FAP.cs index 9b24365075..355a5e0617 100644 --- a/NPCs/TownNPCs/FAP.cs +++ b/NPCs/TownNPCs/FAP.cs @@ -1,6 +1,7 @@ using CalamityMod.Events; using CalamityMod.Items.Placeables.Furniture; using CalamityMod.Items.Potions.Alcohol; +using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using System.Collections.Generic; @@ -388,13 +389,13 @@ namespace CalamityMod.NPCs.TownNPCs public override void TownNPCAttackProj(ref int projType, ref int attackDelay) { - projType = ModContent.ProjectileType(); + projType = ModContent.ProjectileType(); attackDelay = 1; } public override void TownNPCAttackProjSpeed(ref float multiplier, ref float gravityCorrection, ref float randomOffset) { - multiplier = 2f; + multiplier = 11.5f; } } } diff --git a/NPCs/TownNPCs/SEAHOE.cs b/NPCs/TownNPCs/SEAHOE.cs index 8d37fcb1a2..31044def25 100644 --- a/NPCs/TownNPCs/SEAHOE.cs +++ b/NPCs/TownNPCs/SEAHOE.cs @@ -374,7 +374,9 @@ namespace CalamityMod.NPCs.TownNPCs nextSlot++; shop.item[nextSlot].SetDefaults(ModContent.ItemType()); nextSlot++; - shop.item[nextSlot].SetDefaults(ItemID.GillsPotion); + shop.item[nextSlot].SetDefaults(ModContent.ItemType()); + nextSlot++; + shop.item[nextSlot].SetDefaults(ItemID.GillsPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); nextSlot++; shop.item[nextSlot].SetDefaults(ItemID.WaterWalkingPotion); @@ -383,7 +385,7 @@ namespace CalamityMod.NPCs.TownNPCs shop.item[nextSlot].SetDefaults(ItemID.FlipperPotion); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 1, 0, 0); nextSlot++; - if (CalamityWorld.downedDesertScourge) + if (CalamityWorld.downedDesertScourge) { shop.item[nextSlot].SetDefaults(ModContent.ItemType()); shop.item[nextSlot].shopCustomPrice = Item.buyPrice(0, 2, 0, 0); diff --git a/NPCs/Yharon/DetonatingFlare.cs b/NPCs/Yharon/DetonatingFlare.cs index 773851cab1..3106e6a234 100644 --- a/NPCs/Yharon/DetonatingFlare.cs +++ b/NPCs/Yharon/DetonatingFlare.cs @@ -263,14 +263,14 @@ namespace CalamityMod.NPCs.Yharon color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + 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, 4f + npc.gfxOffY); + 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; @@ -294,10 +294,5 @@ namespace CalamityMod.NPCs.Yharon int frame = (int)npc.frameCounter; npc.frame.Y = frame * frameHeight; } - - public override bool PreNPCLoot() - { - return false; - } } } diff --git a/NPCs/Yharon/DetonatingFlare2.cs b/NPCs/Yharon/DetonatingFlare2.cs index 77fe1c509d..6af9c4baf2 100644 --- a/NPCs/Yharon/DetonatingFlare2.cs +++ b/NPCs/Yharon/DetonatingFlare2.cs @@ -95,14 +95,14 @@ namespace CalamityMod.NPCs.Yharon color38 *= (float)(num153 - num155) / 15f; Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); } } Vector2 vector43 = npc.Center - Main.screenPosition; vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); return false; @@ -126,10 +126,5 @@ namespace CalamityMod.NPCs.Yharon int frame = (int)npc.frameCounter; npc.frame.Y = frame * frameHeight; } - - public override bool PreNPCLoot() - { - return false; - } } } diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 54fee0fc36..fe8964ca63 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -61,12 +61,12 @@ namespace CalamityMod.NPCs.Yharon public override void SetDefaults() { npc.Calamity().canBreakPlayerDefense = true; - npc.npcSlots = 50f; + npc.npcSlots = 50f; npc.GetNPCDamage(); npc.width = 200; npc.height = 200; npc.defense = 90; - npc.LifeMaxNERB(1080625, 1296750, 3700000); + npc.LifeMaxNERB(1080625, 1296750, 370000); double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; npc.lifeMax += (int)(npc.lifeMax * HPBoost); npc.knockBackResist = 0f; @@ -74,7 +74,6 @@ namespace CalamityMod.NPCs.Yharon aiType = -1; npc.value = Item.buyPrice(1, 0, 0, 0); npc.boss = true; - npc.DR_NERD(normalDR, null, null, null, true); CalamityGlobalNPC global = npc.Calamity(); global.flatDRReductions.Add(BuffID.CursedInferno, 0.05f); @@ -154,10 +153,10 @@ namespace CalamityMod.NPCs.Yharon CalamityMod.StopRain(); // Variables - bool malice = CalamityWorld.malice; - bool expertMode = Main.expertMode || BossRushEvent.BossRushActive || malice; - bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || malice; - bool death = CalamityWorld.death || BossRushEvent.BossRushActive || malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; float pie = (float)Math.PI; Vector2 vectorCenter = npc.Center; @@ -353,6 +352,7 @@ namespace CalamityMod.NPCs.Yharon else { enraged = !player.Hitbox.Intersects(safeBox); + npc.Calamity().CurrentlyEnraged = enraged; if (enraged) { phaseSwitchTimer = 15; @@ -603,7 +603,7 @@ namespace CalamityMod.NPCs.Yharon } else npc.localAI[1] += 1f; - } + } npc.netUpdate = true; } @@ -629,7 +629,7 @@ namespace CalamityMod.NPCs.Yharon // Fireball breath else if (npc.ai[0] == 2f) { - if (npc.ai[1] == 0f) + if (npc.ai[1] == 0f) npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); @@ -747,7 +747,7 @@ namespace CalamityMod.NPCs.Yharon // Phase switch else if (npc.ai[0] == 6f && !player.dead) { - if (npc.ai[1] == 0f) + if (npc.ai[1] == 0f) npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); @@ -759,7 +759,7 @@ namespace CalamityMod.NPCs.Yharon else npc.velocity *= 0.98f; - int num1477 = Math.Sign(player.Center.X - vectorCenter.X); + int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) { if (npc.ai[2] == 0f && num1477 != npc.direction) @@ -902,7 +902,7 @@ namespace CalamityMod.NPCs.Yharon } else npc.localAI[1] += 1f; - } + } else if (aiState == 6) { npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; @@ -1102,7 +1102,7 @@ namespace CalamityMod.NPCs.Yharon // Phase switch else if (npc.ai[0] == 13f && !player.dead) { - if (npc.ai[1] == 0f) + if (npc.ai[1] == 0f) npc.ai[1] = Math.Sign((vectorCenter - player.Center).X); Vector2 destination = player.Center + new Vector2(npc.ai[1], 0); @@ -1114,7 +1114,7 @@ namespace CalamityMod.NPCs.Yharon else npc.velocity *= 0.98f; - int num1477 = Math.Sign(player.Center.X - vectorCenter.X); + int num1477 = Math.Sign(player.Center.X - vectorCenter.X); if (num1477 != 0) { if (npc.ai[2] == 0f && num1477 != npc.direction) @@ -1260,7 +1260,7 @@ namespace CalamityMod.NPCs.Yharon } else npc.localAI[1] += 1f; - } + } else if (aiState == 6) { npc.velocity = Vector2.Normalize(player.Center - vectorCenter) * spinPhaseVelocity; @@ -1705,7 +1705,7 @@ namespace CalamityMod.NPCs.Yharon } else if (npc.ai[0] == 1f) { - if (npc.ai[2] == 0f) + if (npc.ai[2] == 0f) npc.ai[2] = (vectorCenter.X < targetData.Center.X) ? 1 : -1; Vector2 destination = targetData.Center + new Vector2(-npc.ai[2], 0f); @@ -1714,7 +1714,7 @@ namespace CalamityMod.NPCs.Yharon if (!targetDead) { if (Vector2.Distance(vectorCenter, destination) > reduceSpeedChargeDistance) - npc.SimpleFlyMovement(desiredVelocity, acceleration); + npc.SimpleFlyMovement(desiredVelocity, acceleration); else npc.velocity *= 0.98f; } @@ -2070,6 +2070,7 @@ namespace CalamityMod.NPCs.Yharon int direction = (targetData.Center.X > vectorCenter.X) ? 1 : -1; npc.velocity = new Vector2(direction, 0f) * fireballBreathPhaseVelocity; npc.direction = npc.spriteDirection = direction; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonFire"), npc.Center); } if (npc.ai[1] >= fireballBreathTimer) @@ -2131,6 +2132,7 @@ namespace CalamityMod.NPCs.Yharon npc.rotation += pie; npc.velocity = vector6 * splittingFireballBreathPhaseVelocity; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/YharonFire"), npc.Center); } else { @@ -2193,7 +2195,7 @@ namespace CalamityMod.NPCs.Yharon else { int ringReduction = (int)MathHelper.Lerp(0f, 12f, npc.ai[1] / spinPhaseTimer); - int totalProjectiles2 = (secondPhasePhase == 2 ? 42 : 38) - ringReduction; // 36 for first ring, 24 for last ring + int totalProjectiles2 = 38 - ringReduction; // 36 for first ring, 24 for last ring DoFlareDustBulletHell(0, flareDustSpawnDivisor2, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles2, 0f, 0f, true); } @@ -2224,7 +2226,7 @@ namespace CalamityMod.NPCs.Yharon if (npc.ai[1] % flareDustSpawnDivisor == 0f) { int ringReduction = (int)MathHelper.Lerp(0f, 12f, npc.ai[1] / spinPhaseTimer); - int totalProjectiles = (secondPhasePhase == 2 ? 42 : 38) - ringReduction; // 36 for first ring, 24 for last ring + int totalProjectiles = 38 - ringReduction; // 36 for first ring, 24 for last ring DoFlareDustBulletHell(0, flareDustSpawnDivisor, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, true); // Fire a flame towards every player, with a limit of 10 @@ -2530,7 +2532,7 @@ namespace CalamityMod.NPCs.Yharon int npc = NPC.NewNPC((int)origin.X, (int)origin.Y, type, 0, 0f, 0f, 0f, 0f, 255); Main.npc[npc].velocity = target.Center - origin; Main.npc[npc].velocity.Normalize(); - Main.npc[npc].velocity *= BossRushEvent.BossRushActive ? 15f : 10f; + Main.npc[npc].velocity *= 10f; Main.npc[npc].netUpdate = true; } } @@ -2674,7 +2676,7 @@ namespace CalamityMod.NPCs.Yharon 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 / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector41 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } @@ -2725,14 +2727,14 @@ namespace CalamityMod.NPCs.Yharon color39 *= 1f - num157; Vector2 vector42 = npc.Center + (num160 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; vector42 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector42 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector42 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture, vector42, npc.frame, color39, 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, 4f + npc.gfxOffY); + vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture, vector43, npc.frame, invincible ? invincibleColor : npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); if (flag8 || npc.ai[0] == 4f || startSecondAI) @@ -2801,7 +2803,7 @@ namespace CalamityMod.NPCs.Yharon color41 *= (num153 - num163) / 15f; Vector2 vector44 = npc.oldPos[num163] + new Vector2(npc.width, npc.height) / 2f - Main.screenPosition; vector44 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector44 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector44 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture, vector44, npc.frame, color41, npc.rotation, vector11, npc.scale, spriteEffects, 0f); if (flag9 || npc.ai[0] == 10f || startSecondAI) @@ -2829,7 +2831,7 @@ namespace CalamityMod.NPCs.Yharon color42 *= 1f - num157; Vector2 vector45 = npc.Center + (num164 / (float)num156 * MathHelper.TwoPi + npc.rotation).ToRotationVector2() * scaleFactor9 * num157 - Main.screenPosition; vector45 -= new Vector2(texture.Width, texture.Height / Main.npcFrameCount[npc.type]) * npc.scale / 2f; - vector45 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + vector45 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture, vector45, npc.frame, color42, npc.rotation, vector11, npc.scale, spriteEffects, 0f); if (flag9 || npc.ai[0] == 10f || startSecondAI) @@ -2944,10 +2946,10 @@ namespace CalamityMod.NPCs.Yharon #region Projectile Resists public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (projectile.type == ModContent.ProjectileType()) - damage = (int)(damage * 0.65); if (projectile.type == ModContent.ProjectileType()) damage = (int)(damage * 0.85); + if (projectile.type == ModContent.ProjectileType()) + damage = (int)(damage * 0.9); if (projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType() || projectile.type == ModContent.ProjectileType()) damage = (int)(damage * 0.95); } @@ -3013,13 +3015,13 @@ namespace CalamityMod.NPCs.Yharon } if (npc.frame.Y >= frameHeight * 5) npc.frame.Y = 0; - } + } else { npc.frame.Y = frameHeight * 5; if (doTelegraphRoarAnimation) npc.frame.Y = frameHeight * 6; - } + } return; } diff --git a/Particles/BaseParticleSet.cs b/Particles/BaseParticleSet.cs new file mode 100644 index 0000000000..8490181b26 --- /dev/null +++ b/Particles/BaseParticleSet.cs @@ -0,0 +1,77 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; + +namespace CalamityMod.Particles +{ + public abstract class BaseParticleSet + { + public int LocalTimer { get; internal set; } + public int SetLifetime { get; internal set; } + public int ParticleSpawnRate; + public List Particles = new List(); + public abstract int ParticleLifetime { get; } + public abstract void UpdateBehavior(Particle particle); + public abstract Particle SpawnParticle(); + public abstract Color DetermineParticleColor(float lifetimeCompletion); + public abstract Texture2D ParticleTexture { get; } + public virtual int ParticleFrameVariants => 1; + public virtual Func OrderFunction { get; } = null; + + 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; + + bool closeToDeath = LocalTimer >= SetLifetime - ParticleLifetime && SetLifetime > 0; + if (LocalTimer % ParticleSpawnRate == 0 && !closeToDeath) + { + Particle particle = SpawnParticle(); + particle.Lifetime = ParticleLifetime; + particle.Variant = Main.rand.Next(ParticleFrameVariants); + Particles.Add(particle); + } + + // Update and increment the time of all particles. + for (int i = 0; i < Particles.Count; i++) + { + Particles[i].Time++; + UpdateBehavior(Particles[i]); + } + + // Clear all expired particles. + Particles.RemoveAll(particle => particle.Time >= particle.Lifetime); + LocalTimer++; + } + + public virtual void DrawSet(Vector2 basePosition) + { + if (Main.netMode == NetmodeID.Server) + return; + + IEnumerable orderedParticles = Particles; + if (OrderFunction != null) + orderedParticles = orderedParticles.OrderBy(OrderFunction); + + foreach (Particle particle in Particles.OrderBy(p => p.Time)) + { + Vector2 drawPosition = basePosition - Main.screenPosition + particle.RelativeOffset; + Color particleColor = DetermineParticleColor(particle.Time / (float)particle.Lifetime); + Rectangle frame = ParticleTexture.Frame(1, ParticleFrameVariants, 0, particle.Variant); + + Main.spriteBatch.Draw(ParticleTexture, drawPosition, frame, particleColor, 0f, frame.Size() * 0.5f, particle.Scale, SpriteEffects.None, 0f); + } + } + } +} \ No newline at end of file diff --git a/Particles/Particle.cs b/Particles/Particle.cs new file mode 100644 index 0000000000..cf3bac931f --- /dev/null +++ b/Particles/Particle.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; + +namespace CalamityMod.Particles +{ + public class Particle + { + public int Time; + public int Lifetime; + public int Variant; + public float Scale; + public Vector2 RelativeOffset; + public Particle(int lifetime, Vector2 relativeOffset, float scale, int variant = 0) + { + Time = 0; + Lifetime = lifetime; + Variant = variant; + Scale = scale; + RelativeOffset = relativeOffset; + } + } +} \ No newline at end of file diff --git a/Particles/ThanatosSmokeParticleSet.cs b/Particles/ThanatosSmokeParticleSet.cs new file mode 100644 index 0000000000..dba17d45f6 --- /dev/null +++ b/Particles/ThanatosSmokeParticleSet.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class ThanatosSmokeParticleSet : BaseParticleSet + { + public float SpawnAreaCompactness; + public float RelativePower; + public float BaseMoveRotation; + public float MoveRotationOffset; + public override int ParticleLifetime => 50; + public override int ParticleFrameVariants => 3; + public override Texture2D ParticleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/ThanatosVentParticle"); + 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 void UpdateBehavior(Particle particle) + { + particle.Scale += RelativePower * 0.02f; + particle.RelativeOffset -= (BaseMoveRotation + Main.rand.NextFloat(-0.38f, 0.38f)).ToRotationVector2() * RelativePower * 4.5f; + } + + public override Color DetermineParticleColor(float lifetimeCompletion) => Color.White * Utils.InverseLerp(1f, 0.85f, lifetimeCompletion, true); + + public override Particle SpawnParticle() => new Particle(ParticleLifetime, Main.rand.NextVector2Circular(1f, 1f) * SpawnAreaCompactness, 0.06f, Main.rand.Next(3)); + } +} \ No newline at end of file diff --git a/Prefixes/RoguePrefix.cs b/Prefixes/RoguePrefix.cs index f88130b594..d17e4050cd 100644 --- a/Prefixes/RoguePrefix.cs +++ b/Prefixes/RoguePrefix.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Prefixes ModItem moddedItem = item.modItem; if (moddedItem != null && moddedItem is RogueWeapon rogueWep) { - rogueWep.StealthStrikeDamage = stealthDmgMult; + rogueWep.StealthStrikePrefixBonus = stealthDmgMult; } } diff --git a/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs b/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs index 3abf6c5637..78fe1d662a 100644 --- a/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseLaserbeamProjectile.cs @@ -38,7 +38,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles // Attach to some arbitrary thing/position optionally. (The ai[1] value is a reserved for this in vanilla's Phantasmal Deathray) AttachToSomething(); - // Ensure the the velocity is a unit vector and is not a <0,0> vector. + // Ensure the the velocity is a unit vector. This has NaN safety in place with a fallback of <0, -1>. projectile.velocity = projectile.velocity.SafeNormalize(-Vector2.UnitY); Time++; @@ -79,11 +79,9 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// public virtual void DetermineScale() { - projectile.scale = (float)Math.Sin(Time / Lifetime * MathHelper.Pi) * 6f * MaxScale; + projectile.scale = (float)Math.Sin(Time / Lifetime * MathHelper.Pi) * ScaleExpandRate * MaxScale; if (projectile.scale > MaxScale) - { projectile.scale = MaxScale; - } } /// @@ -92,7 +90,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles public virtual void AttachToSomething() { } /// - /// Calculates the current laser's length. By default does not collide with tiles. is a generic laser collision method if you want to do that. + /// Calculates the current laser's length. By default does not collide with tiles. is a generic laser collision method if you want to use it. /// /// The laser length as a float. public virtual float DetermineLaserLength() => MaxLaserLength; @@ -115,6 +113,62 @@ namespace CalamityMod.Projectiles.BaseProjectiles Collision.LaserScan(projectile.Center, projectile.velocity, projectile.scale, MaxLaserLength, laserLengthSamplePoints); return laserLengthSamplePoints.Average(); } + + protected internal void DrawBeamWithColor(SpriteBatch spriteBatch, Color beamColor, float scale) + { + // Start texture drawing. + spriteBatch.Draw(LaserBeginTexture, + projectile.Center - Main.screenPosition, + null, + beamColor, + projectile.rotation, + LaserBeginTexture.Size() / 2f, + scale, + SpriteEffects.None, + 0f); + + // Prepare things for body drawing. + float laserBodyLength = LaserLength; + laserBodyLength -= (LaserBeginTexture.Height / 2 + LaserEndTexture.Height) * scale; + Vector2 centerOnLaser = projectile.Center; + centerOnLaser += projectile.velocity * scale * LaserBeginTexture.Height / 2f; + + // Body drawing. + if (laserBodyLength > 0f) + { + float laserOffset = LaserMiddleTexture.Height * scale; + float incrementalBodyLength = 0f; + while (incrementalBodyLength + 1f < laserBodyLength) + { + spriteBatch.Draw(LaserMiddleTexture, + centerOnLaser - Main.screenPosition, + null, + beamColor, + projectile.rotation, + LaserMiddleTexture.Width * 0.5f * Vector2.UnitX, + scale, + SpriteEffects.None, + 0f); + incrementalBodyLength += laserOffset; + centerOnLaser += projectile.velocity * laserOffset; + } + } + + // End texture drawing. + if (Math.Abs(LaserLength - DetermineLaserLength()) < 30f) + { + Vector2 laserEndCenter = centerOnLaser - Main.screenPosition; + spriteBatch.Draw(LaserEndTexture, + laserEndCenter, + null, + beamColor, + projectile.rotation, + LaserEndTexture.Frame(1, 1, 0, 0).Top(), + scale, + SpriteEffects.None, + 0f); + } + } #endregion #region Hook Overrides @@ -134,78 +188,30 @@ namespace CalamityMod.Projectiles.BaseProjectiles if (projectile.velocity == Vector2.Zero) return false; - // Start texture drawing. - spriteBatch.Draw(LaserBeginTexture, - projectile.Center - Main.screenPosition, - null, - LaserOverlayColor, - projectile.rotation, - LaserBeginTexture.Size() / 2f, - projectile.scale, - SpriteEffects.None, - 0f); - - // Prepare things for body drawing. - float laserBodyLength = LaserLength; - laserBodyLength -= (LaserBeginTexture.Height / 2 + LaserEndTexture.Height) * projectile.scale; - Vector2 centerOnLaser = projectile.Center; - centerOnLaser += projectile.velocity * projectile.scale * LaserBeginTexture.Height / 2f; - - // Body drawing. - if (laserBodyLength > 0f) - { - float laserOffset = LaserMiddleTexture.Height * projectile.scale; - float incrementalBodyLength = 0f; - while (incrementalBodyLength + 1f < laserBodyLength) - { - spriteBatch.Draw(LaserMiddleTexture, - centerOnLaser - Main.screenPosition, - null, - LaserOverlayColor, - projectile.rotation, - LaserMiddleTexture.Width * 0.5f * Vector2.UnitX, - projectile.scale, - SpriteEffects.None, - 0f); - incrementalBodyLength += laserOffset; - centerOnLaser += projectile.velocity * laserOffset; - } - } - - // End texture drawing. - if (Math.Abs(LaserLength - DetermineLaserLength()) < 30f) - { - Vector2 laserEndCenter = centerOnLaser - Main.screenPosition; - spriteBatch.Draw(LaserEndTexture, - laserEndCenter, - null, - LaserOverlayColor, - projectile.rotation, - LaserEndTexture.Frame(1, 1, 0, 0).Top(), - projectile.scale, - SpriteEffects.None, - 0f); - } + DrawBeamWithColor(spriteBatch, LaserOverlayColor, projectile.scale); return false; } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { if (projHitbox.Intersects(targetHitbox)) return true; - float unused = 69420f; - return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.Size.Length() * projectile.scale, ref unused); + float _ = 0f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * LaserLength, projectile.Size.Length() * projectile.scale, ref _); } - #endregion - #region Virtual Properties - public virtual float Lifetime => 120f; - public virtual float MaxScale => 1f; - public virtual float MaxLaserLength => 2400f; // Be careful with this. Going too high will cause lag. + public override bool ShouldUpdatePosition() => false; + #endregion + + #region Overridable Properties + public abstract float Lifetime { get; } + public abstract float MaxScale { get; } + public abstract float MaxLaserLength { get; } // Be careful with this. Going too high will cause lag. + public abstract Texture2D LaserBeginTexture { get; } + public abstract Texture2D LaserMiddleTexture { get; } + public abstract Texture2D LaserEndTexture { get; } + public virtual float ScaleExpandRate => 4f; public virtual Color LightCastColor => Color.White; public virtual Color LaserOverlayColor => Color.White * 0.9f; - public virtual Texture2D LaserBeginTexture { get; } - public virtual Texture2D LaserMiddleTexture { get; } - public virtual Texture2D LaserEndTexture { get; } #endregion } } diff --git a/Projectiles/Boss/AstralLaser.cs b/Projectiles/Boss/AstralLaser.cs index ee59e5b66b..9cfb695807 100644 --- a/Projectiles/Boss/AstralLaser.cs +++ b/Projectiles/Boss/AstralLaser.cs @@ -39,9 +39,8 @@ namespace CalamityMod.Projectiles.Boss projectile.frameCounter = 0; } if (projectile.frame > 2) - { projectile.frame = 0; - } + if (projectile.velocity.X < 0f) { projectile.spriteDirection = -1; @@ -52,14 +51,14 @@ namespace CalamityMod.Projectiles.Boss projectile.spriteDirection = 1; projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); } + Lighting.AddLight(projectile.Center, 0.3f, 0.3f, 0f); + projectile.ai[0] += 1f; if (projectile.ai[0] > 9f) { if (projectile.alpha > 0) - { projectile.alpha -= 5; - } } } diff --git a/Projectiles/Boss/AstralShot2.cs b/Projectiles/Boss/AstralShot2.cs index 741e80fcd7..782ccaa384 100644 --- a/Projectiles/Boss/AstralShot2.cs +++ b/Projectiles/Boss/AstralShot2.cs @@ -43,20 +43,14 @@ namespace CalamityMod.Projectiles.Boss projectile.frameCounter = 0; } if (projectile.frame > 3) - { projectile.frame = 0; - } if (projectile.alpha > 0) - { projectile.alpha -= 25; - } if (projectile.alpha < 0) - { projectile.alpha = 0; - } - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; } public override void OnHitPlayer(Player target, int damage, bool crit) diff --git a/Projectiles/Boss/BrimstoneHellfireball.cs b/Projectiles/Boss/BrimstoneHellfireball.cs index f72085b059..fe9e600933 100644 --- a/Projectiles/Boss/BrimstoneHellfireball.cs +++ b/Projectiles/Boss/BrimstoneHellfireball.cs @@ -66,7 +66,7 @@ namespace CalamityMod.Projectiles.Boss //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; + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) - MathHelper.ToRadians(90f) * projectile.direction; projectile.velocity *= 1.01f; diff --git a/Projectiles/Boss/BrimstoneMonster.cs b/Projectiles/Boss/BrimstoneMonster.cs index 932027bf11..d46b5b78e1 100644 --- a/Projectiles/Boss/BrimstoneMonster.cs +++ b/Projectiles/Boss/BrimstoneMonster.cs @@ -5,6 +5,7 @@ using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; using System.IO; using Terraria; using Terraria.ModLoader; @@ -28,6 +29,7 @@ namespace CalamityMod.Projectiles.Boss projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; + projectile.hide = true; projectile.penetrate = -1; projectile.timeLeft = 36000; projectile.Opacity = 0f; @@ -193,6 +195,12 @@ namespace CalamityMod.Projectiles.Boss 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 ModifyHitPlayer(Player target, ref int damage, ref bool crit) { target.Calamity().lastProjectileHit = projectile; diff --git a/Projectiles/Boss/DarkEnergyBall.cs b/Projectiles/Boss/DarkEnergyBall.cs index 8679461a3c..a89d70e5a7 100644 --- a/Projectiles/Boss/DarkEnergyBall.cs +++ b/Projectiles/Boss/DarkEnergyBall.cs @@ -1,18 +1,15 @@ +using CalamityMod.Dusts; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class DarkEnergyBall : ModProjectile { - private double timeElapsed = 0.0; - private double circleSize = 1.0; - private double circleGrowth = 0.02; - public override void SetStaticDefaults() { DisplayName.SetDefault("Dark Energy"); @@ -30,39 +27,31 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.timeLeft = 600; projectile.penetrate = -1; + projectile.Opacity = 0f; cooldownSlot = 1; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(timeElapsed); - writer.Write(circleSize); - writer.Write(circleGrowth); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - timeElapsed = reader.ReadDouble(); - circleSize = reader.ReadDouble(); - circleGrowth = reader.ReadDouble(); - } - public override void AI() { - timeElapsed += 0.02; - projectile.velocity.X = (float)(Math.Sin(timeElapsed * (0.5f * projectile.ai[0])) * circleSize); - projectile.velocity.Y = (float)(Math.Cos(timeElapsed * (0.5f * projectile.ai[0])) * circleSize); - circleSize += circleGrowth; - projectile.frameCounter++; + if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) + projectile.Kill(); + + 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); + + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame > 5) - { projectile.frame = 0; - } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -70,27 +59,49 @@ namespace CalamityMod.Projectiles.Boss CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); Rectangle frame = new Rectangle(0, projectile.frame * Main.projectileTexture[projectile.type].Height, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]); - Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + + Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f) * projectile.Opacity; spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); - color = Color.Lerp(Color.White, Color.Cyan, 0.5f); + color = Color.Lerp(Color.White, Color.Cyan, 0.5f) * projectile.Opacity; spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow2"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); return false; } + 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 <= 35f && projectile.Opacity == 1f; + } + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(BuffID.VortexDebuff, 60); + if (projectile.Opacity == 1f) + target.AddBuff(BuffID.VortexDebuff, 60); } public override void Kill(int timeLeft) { - for (int num621 = 0; num621 < 5; num621++) + for (int num621 = 0; num621 < 3; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, 0f, 0f, 100, default, 1.2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 1.2f); Main.dust[num622].velocity *= 3f; Main.dust[num622].noGravity = true; if (Main.rand.NextBool(2)) @@ -99,12 +110,13 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int num623 = 0; num623 < 5; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, 0f, 0f, 100, default, 1.7f); + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmolite, 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, 90, 0f, 0f, 100, default, 1f); + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 1f); + Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 2f; } } diff --git a/Projectiles/Boss/DarkEnergyBall2.cs b/Projectiles/Boss/DarkEnergyBall2.cs index a0bb70bc01..8e4b5c5b2c 100644 --- a/Projectiles/Boss/DarkEnergyBall2.cs +++ b/Projectiles/Boss/DarkEnergyBall2.cs @@ -1,21 +1,17 @@ +using CalamityMod.Dusts; +using CalamityMod.NPCs; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class DarkEnergyBall2 : ModProjectile { public override string Texture => "CalamityMod/Projectiles/Boss/DarkEnergyBall"; - private bool start = true; - private float startingPosX = 0f; - private float startingPosY = 0f; - private double distance = 0D; - public override void SetStaticDefaults() { DisplayName.SetDefault("Dark Energy"); @@ -33,28 +29,24 @@ namespace CalamityMod.Projectiles.Boss projectile.tileCollide = false; projectile.timeLeft = 600; projectile.penetrate = -1; - cooldownSlot = 1; + projectile.Opacity = 0f; + cooldownSlot = 1; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(start); - writer.Write(startingPosX); - writer.Write(startingPosY); - writer.Write(distance); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - start = reader.ReadBoolean(); - startingPosX = reader.ReadSingle(); - startingPosY = reader.ReadSingle(); - distance = reader.ReadDouble(); - } - public override void AI() { - projectile.frameCounter++; + if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) + projectile.Kill(); + + 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); + + projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; @@ -62,20 +54,6 @@ namespace CalamityMod.Projectiles.Boss } if (projectile.frame > 5) projectile.frame = 0; - - if (start) - { - startingPosX = projectile.Center.X; - startingPosY = projectile.Center.Y; - start = false; - } - - double deg = projectile.ai[0]; - double rad = deg * (Math.PI / 180); - distance += projectile.ai[1] == 1f ? 2D : 1D; - 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[0] += 0.5f; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -83,27 +61,49 @@ namespace CalamityMod.Projectiles.Boss CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); Rectangle frame = new Rectangle(0, projectile.frame * Main.projectileTexture[projectile.type].Height, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]); - Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f); + + Color color = Color.Lerp(Color.White, Color.Fuchsia, 0.5f) * projectile.Opacity; spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); - color = Color.Lerp(Color.White, Color.Cyan, 0.5f); + color = Color.Lerp(Color.White, Color.Cyan, 0.5f) * projectile.Opacity; spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/DarkEnergyBallGlow2"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); return false; } + 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 <= 35f && projectile.Opacity == 1f; + } + public override void OnHitPlayer(Player target, int damage, bool crit) { - target.AddBuff(BuffID.VortexDebuff, 60); + if (projectile.Opacity == 1f) + target.AddBuff(BuffID.VortexDebuff, 60); } public override void Kill(int timeLeft) { - for (int num621 = 0; num621 < 5; num621++) + for (int num621 = 0; num621 < 3; num621++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, 0f, 0f, 100, default, 1.2f); + int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 1.2f); Main.dust[num622].velocity *= 3f; Main.dust[num622].noGravity = true; if (Main.rand.NextBool(2)) @@ -112,12 +112,13 @@ namespace CalamityMod.Projectiles.Boss Main.dust[num622].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } - for (int num623 = 0; num623 < 10; num623++) + for (int num623 = 0; num623 < 5; num623++) { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 90, 0f, 0f, 100, default, 1.7f); + int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmolite, 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, 90, 0f, 0f, 100, default, 1f); + num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, (int)CalamityDusts.PurpleCosmolite, 0f, 0f, 100, default, 1f); + Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 2f; } } diff --git a/Projectiles/Boss/DeusRitualDrama.cs b/Projectiles/Boss/DeusRitualDrama.cs index 4500b25e80..35c1eadd39 100644 --- a/Projectiles/Boss/DeusRitualDrama.cs +++ b/Projectiles/Boss/DeusRitualDrama.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Projectiles.Boss get => projectile.ai[0]; set => projectile.ai[0] = value; } + public bool CreatedWithStarcore => projectile.ai[1] == 1f; public const int TotalSinePeriods = 6; public const int PulseTime = 45; public const int TotalRitualTime = 420; @@ -37,26 +38,28 @@ namespace CalamityMod.Projectiles.Boss projectile.timeLeft = TotalRitualTime; } - public override void AI() - { - Time++; - if (Time == TotalRitualTime - PulseTime) - { - int idx = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y - (int)MaxUpwardRise, ModContent.NPCType(), 1); - if (idx != -1) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstrumDeusSpawn"), projectile.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - CalamityUtils.BossAwakenMessage(idx); - } - else - { - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, idx); - } - } - } - } + public override void AI() + { + projectile.extraUpdates = CreatedWithStarcore.ToInt(); + + Time++; + if (Time == TotalRitualTime - PulseTime) + { + int idx = NPC.NewNPC((int)projectile.Center.X, (int)projectile.Center.Y - (int)MaxUpwardRise, ModContent.NPCType(), 1); + if (idx != -1) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstrumDeusSpawn"), projectile.Center); + if (Main.netMode != NetmodeID.MultiplayerClient) + { + CalamityUtils.BossAwakenMessage(idx); + } + else + { + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, idx); + } + } + } + } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { diff --git a/Projectiles/Boss/DoGBeam.cs b/Projectiles/Boss/DoGBeam.cs index 5e44817202..4ad7dd6f33 100644 --- a/Projectiles/Boss/DoGBeam.cs +++ b/Projectiles/Boss/DoGBeam.cs @@ -1,8 +1,8 @@ -using CalamityMod.NPCs.CeaselessVoid; using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class DoGBeam : ModProjectile @@ -35,14 +35,15 @@ namespace CalamityMod.Projectiles.Boss projectile.frameCounter = 0; } if (projectile.frame > 1) - { projectile.frame = 0; - } + Lighting.AddLight(projectile.Center, 0f, 0.2f, 0.3f); - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; - int num103 = (int)Player.FindClosest(projectile.Center, 1, 1); + + projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2; + + int num103 = Player.FindClosest(projectile.Center, 1, 1); projectile.ai[1] += 1f; - if (projectile.ai[1] < 120f && projectile.ai[1] > 30f) + if (projectile.ai[1] < 90f && projectile.ai[1] > 30f) { float scaleFactor2 = projectile.velocity.Length(); Vector2 vector11 = Main.player[num103].Center - projectile.Center; @@ -52,15 +53,16 @@ namespace CalamityMod.Projectiles.Boss projectile.velocity.Normalize(); projectile.velocity *= scaleFactor2; } + if (projectile.timeLeft == 950) projectile.damage = (int)projectile.ai[0]; - if (projectile.timeLeft < 85) + if (projectile.timeLeft < 30) projectile.damage = 0; } public override bool CanHitPlayer(Player target) { - if (projectile.timeLeft > 950 || projectile.timeLeft < 85) + if (projectile.timeLeft > 950 || projectile.timeLeft < 30) { return false; } @@ -73,9 +75,9 @@ namespace CalamityMod.Projectiles.Boss { return new Color(0, 0, 0, 0); } - if (projectile.timeLeft < 85) + if (projectile.timeLeft < 30) { - byte b2 = (byte)(projectile.timeLeft * 3); + byte b2 = (byte)(projectile.timeLeft * 8.5); byte a2 = (byte)(100f * ((float)b2 / 255f)); return new Color((int)b2, (int)b2, (int)b2, (int)a2); } diff --git a/Projectiles/Boss/DoGBeamPortal.cs b/Projectiles/Boss/DoGBeamPortal.cs index ce4e01245a..b77e467f51 100644 --- a/Projectiles/Boss/DoGBeamPortal.cs +++ b/Projectiles/Boss/DoGBeamPortal.cs @@ -1,17 +1,21 @@ +using CalamityMod.Dusts; using CalamityMod.Events; +using CalamityMod.NPCs; using CalamityMod.World; using Microsoft.Xna.Framework; +using System; using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class DoGBeamPortal : ModProjectile { - private int beamTimer = 180; + public bool start = true; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Beam Portal"); Main.projFrames[projectile.type] = 6; @@ -31,17 +35,55 @@ namespace CalamityMod.Projectiles.Boss public override void SendExtraAI(BinaryWriter writer) { - writer.Write(beamTimer); + writer.Write(start); } public override void ReceiveExtraAI(BinaryReader reader) { - beamTimer = reader.ReadInt32(); + start = reader.ReadBoolean(); } public override void AI() { - Lighting.AddLight(projectile.Center, 0f, 0.95f, 1.15f); + Player player = Main.player[projectile.owner]; + + 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; + } + + projectile.ai[1] = projectile.ai[0]; + start = false; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; + + Lighting.AddLight(projectile.Center, 0f, 0.95f, 1.15f); + projectile.frameCounter++; if (projectile.frameCounter > 4) { @@ -49,91 +91,46 @@ namespace CalamityMod.Projectiles.Boss projectile.frameCounter = 0; } if (projectile.frame > 5) - { projectile.frame = 0; - } - beamTimer--; - if (beamTimer <= 0) - { - Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); - if (projectile.owner == Main.myPlayer) + + 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) { - float speed = 3f; - if (CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) + projectile.localAI[0] = 0f; + if (projectile.owner == Main.myPlayer) { - speed = 5f; - } - else if (CalamityWorld.revenge) - { - speed = 4.5f; - } - else if (Main.expertMode) - { - speed = 4f; - } - speed *= projectile.ai[0]; - int totalProjectiles = 8; - float radians = MathHelper.TwoPi / totalProjectiles; - for (int i = 0; i < totalProjectiles; i++) - { - Vector2 vector255 = new Vector2(0f, -speed).RotatedBy(radians * i); - Projectile.NewProjectile(projectile.Center, vector255, ModContent.ProjectileType(), 0, 0f, projectile.owner, projectile.damage, 0f); + Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); + float speed = (malice || 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); + } } } - beamTimer = 180; - } - int num103 = Player.FindClosest(projectile.Center, 1, 1); - float scaleFactor2 = projectile.velocity.Length(); - Vector2 vector11 = Main.player[num103].Center - projectile.Center; - if (Vector2.Distance(Main.player[num103].Center, projectile.Center) > 2000f) - { - projectile.position.X = Main.player[num103].Center.X / 16 * 16f - (projectile.width / 2); - projectile.position.Y = Main.player[num103].Center.Y / 16 * 16f - (projectile.height / 2) - 250f; - projectile.ai[1] = 0f; - beamTimer = 90; - } - vector11.Normalize(); - vector11 *= scaleFactor2; - projectile.velocity = (projectile.velocity * 24f + vector11) / 25f; - projectile.velocity.Normalize(); - projectile.velocity *= scaleFactor2; - if (projectile.ai[1] == 0f) - { - projectile.ai[1] = 1f; - Main.PlaySound(SoundID.Item92, (int)projectile.Center.X, (int)projectile.Center.Y); - for (int num621 = 0; num621 < 30; 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 < 60; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 173, 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, 173, 0f, 0f, 100, default, 1f); - Main.dust[num624].velocity *= 2f; - } - } - if (projectile.timeLeft < 85) - projectile.damage = 0; + } } - public override bool CanHitPlayer(Player target) - { - return false; - } + public override bool CanHitPlayer(Player target) => false; public override Color? GetAlpha(Color lightColor) { - if (projectile.timeLeft < 85) + if (projectile.timeLeft < 30) { - byte b2 = (byte)(projectile.timeLeft * 3); + byte b2 = (byte)(projectile.timeLeft * 8.5); byte a2 = (byte)(100f * (b2 / 255f)); return new Color(b2, b2, b2, a2); } diff --git a/Projectiles/Boss/ExoDestroyerBeamStart.cs b/Projectiles/Boss/ExoDestroyerBeamStart.cs new file mode 100644 index 0000000000..1c88e0cb97 --- /dev/null +++ b/Projectiles/Boss/ExoDestroyerBeamStart.cs @@ -0,0 +1,269 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Events; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class ExoDestroyerBeamStart : ModProjectile + { + public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[0]) ? Main.npc[(int)projectile.ai[0]] : null; + public ref float Time => ref projectile.localAI[0]; + public ref float LengthOfLaser => ref projectile.localAI[1]; + public const int Lifetime = 180; + public const float BeamPosOffset = 16f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Thanatos Deathray"); + Main.projFrames[projectile.type] = 4; + } + + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 32; + projectile.height = 32; + 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(Time); + writer.Write(LengthOfLaser); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Time = reader.ReadSingle(); + LengthOfLaser = reader.ReadSingle(); + } + + public override void AI() + { + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // Die if the thing to attach to disappears. + if (ThingToAttachTo is null || !ThingToAttachTo.active) + { + projectile.Kill(); + return; + } + + // 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 = -18f; + + // 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 = ThingToAttachTo.velocity.ToRotation(); + + Time++; + + float scale = 1f; + Time++; + if (Time >= Lifetime) + { + projectile.Kill(); + return; + } + + projectile.scale = (float)Math.Sin(Time * MathHelper.Pi / Lifetime) * 10f * scale; + if (projectile.scale > scale) + projectile.scale = scale; + + projectile.rotation = ThingToAttachTo.velocity.ToRotation(); + projectile.velocity = projectile.rotation.ToRotationVector2(); + + float arraySize = 3f; + Vector2 samplingPoint = projectile.Center; + float[] samples = new float[(int)arraySize]; + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, 2400f, samples); + float laserLength = 0f; + for (int i = 0; i < samples.Length; i++) + { + laserLength += samples[i]; + } + laserLength /= arraySize; + + // Fire laser through walls at max length if target cannot be seen + if (!Collision.CanHitLine(ThingToAttachTo.Center, 1, 1, Main.player[ThingToAttachTo.target].Center, 1, 1)) + laserLength = 2400f; + + float amount = 0.5f; + LengthOfLaser = MathHelper.Lerp(LengthOfLaser, laserLength, amount); + + // Fire beams along the laser + float divisor = expertMode ? 80f : 160f; + if (ThingToAttachTo.Calamity().newAI[2] % divisor == 0f && projectile.owner == Main.myPlayer) + { + Vector2 velocity = projectile.velocity; + velocity.Normalize(); + float distanceBetweenProjectiles = malice ? 160f : death ? 256f : revenge ? 288f : 320f; + Vector2 fireFrom = ThingToAttachTo.Center + velocity * distanceBetweenProjectiles; + int projectileAmt = (int)(LengthOfLaser / distanceBetweenProjectiles); + int type = ModContent.ProjectileType(); + int damage = projectile.GetProjectileDamage(ThingToAttachTo.type); + 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); + Projectile.NewProjectile(fireFrom, projVelocity, type, damage, 0f, Main.myPlayer, 0f, -1f); + } + fireFrom += velocity * distanceBetweenProjectiles; + } + } + + int dustType = (int)CalamityDusts.Brimstone; + + // Spawn dust at the start of the beam + Vector2 dustPos = projectile.Center + projectile.velocity * 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); + } + + // Spawn dust at the end of the beam + dustPos = projectile.Center + projectile.velocity * (LengthOfLaser - 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); + } + + DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); + Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * LengthOfLaser, 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 beamStart = Main.projectileTexture[projectile.type]; + Texture2D beamMiddle = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ExoDestroyerBeamMiddle"); + Texture2D beamEnd = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/ExoDestroyerBeamEnd"); + + float drawLength = LengthOfLaser; + Color color = new Color(250, 0, 0, 0); + + // Draw start of beam + Vector2 vector = projectile.Center - Main.screenPosition; + Rectangle? sourceRectangle = new Rectangle(0, 16 * (projectile.timeLeft / Main.projFrames[projectile.type] % 5), beamStart.Width, 16); + spriteBatch.Draw(beamStart, vector, sourceRectangle, color, projectile.rotation, beamStart.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + + // Draw middle of beam + drawLength -= (beamStart.Height / 2 + beamEnd.Height) * projectile.scale; + Vector2 center = projectile.Center; + center += projectile.velocity * projectile.scale * beamStart.Height / 2f; + if (drawLength > 0f) + { + float i = 0f; + Rectangle rectangle = new Rectangle(0, 16 * (projectile.timeLeft / Main.projFrames[projectile.type] % 5), beamMiddle.Width, 16); + while (i + 1f < drawLength) + { + if (drawLength - i < rectangle.Height) + rectangle.Height = (int)(drawLength - i); + + spriteBatch.Draw(beamMiddle, center - Main.screenPosition, rectangle, color, projectile.rotation, new Vector2(rectangle.Width / 2, 0f), projectile.scale, SpriteEffects.None, 0f); + + i += rectangle.Height * projectile.scale; + center += projectile.velocity * rectangle.Height * projectile.scale; + + rectangle.Y += 16; + if (rectangle.Y + rectangle.Height > beamMiddle.Height) + rectangle.Y = 0; + } + } + + // Draw end of beam + Vector2 vector2 = center - Main.screenPosition; + sourceRectangle = new Rectangle(0, 16 * (projectile.timeLeft / Main.projFrames[projectile.type] % 5), beamEnd.Width, 16); + spriteBatch.Draw(beamEnd, vector2, sourceRectangle, color, projectile.rotation, beamEnd.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 * LengthOfLaser, projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + return true; + + float collisionPoint = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * LengthOfLaser, 22f * projectile.scale, ref collisionPoint)) + return true; + + return false; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + target.AddBuff(ModContent.BuffType(), 360); + target.AddBuff(BuffID.OnFire, 360); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + } +} diff --git a/Projectiles/Boss/ExoDestroyerBeamStart.png b/Projectiles/Boss/ExoDestroyerBeamStart.png new file mode 100644 index 0000000000..a0c3da9735 Binary files /dev/null and b/Projectiles/Boss/ExoDestroyerBeamStart.png differ diff --git a/Projectiles/Boss/ExoDestroyerBeamTelegraph.cs b/Projectiles/Boss/ExoDestroyerBeamTelegraph.cs new file mode 100644 index 0000000000..cd9d0560cf --- /dev/null +++ b/Projectiles/Boss/ExoDestroyerBeamTelegraph.cs @@ -0,0 +1,95 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.IO; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class ExoDestroyerBeamTelegraph : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public NPC ThingToAttachTo => Main.npc.IndexInRange((int)projectile.ai[0]) ? Main.npc[(int)projectile.ai[0]] : null; + public float ConvergenceRatio => MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(25f, 120f, Time, true)); + public ref float StartingRotationalOffset => ref projectile.ai[1]; + public ref float ConvergenceAngle => ref projectile.localAI[0]; + 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("Telegraph"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 4; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.extraUpdates = 1; + projectile.timeLeft = Lifetime; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(ConvergenceAngle); + writer.Write(Time); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + ConvergenceAngle = reader.ReadSingle(); + Time = reader.ReadSingle(); + } + + public override void AI() + { + // Die if the thing to attach to disappears. + if (ThingToAttachTo is null || !ThingToAttachTo.active) + { + projectile.Kill(); + return; + } + + // 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 = -18f; + + // 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(); + + Time++; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); + + float verticalScale = Utils.InverseLerp(0f, 20f, Time, true) * Utils.InverseLerp(0f, 16f, projectile.timeLeft, true) * 4f; + + Vector2 origin = laserTelegraph.Size() * new Vector2(0f, 0.5f); + Vector2 scaleInner = new Vector2(TelegraphWidth / laserTelegraph.Width, verticalScale); + Vector2 scaleOuter = scaleInner * new Vector2(1f, 2.2f); + + Color colorOuter = Color.Lerp(Color.Red, Color.Crimson, Time / Lifetime * 2f % 1f); // Iterate through crimson and red twice and then flash. + colorOuter = Color.Lerp(colorOuter, Color.White, Utils.InverseLerp(40f, 0f, projectile.timeLeft, true) * 0.8f); + Color colorInner = Color.Lerp(colorOuter, Color.White, 0.5f); + + colorInner *= 0.85f; + colorOuter *= 0.7f; + + spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorOuter, projectile.rotation, origin, scaleOuter, SpriteEffects.None, 0f); + spriteBatch.Draw(laserTelegraph, projectile.Center - Main.screenPosition, null, colorInner, projectile.rotation, origin, scaleInner, SpriteEffects.None, 0f); + return false; + } + } +} diff --git a/Projectiles/Boss/ExoDestroyerLaser.cs b/Projectiles/Boss/ExoDestroyerLaser.cs new file mode 100644 index 0000000000..f3456966c7 --- /dev/null +++ b/Projectiles/Boss/ExoDestroyerLaser.cs @@ -0,0 +1,276 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.IO; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class ExoDestroyerLaser : 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 Vector2 Destination; + public Vector2 Velocity; + public const float TelegraphTotalTime = 30f; + public const float TelegraphFadeTime = 15f; + public const float TelegraphWidth = 4200f; + public const float LaserVelocity = 12f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Thanatos Beam"); + 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 = 300; + cooldownSlot = 1; + } + + 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 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 > 8) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; + + 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 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.velocity = Velocity * (CalamityWorld.malice ? 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)Velocity.Y, (double)-(double)Velocity.X); + } + else + { + projectile.spriteDirection = 1; + projectile.rotation = (float)Math.Atan2((double)Velocity.Y, (double)Velocity.X); + } + } + + TelegraphDelay++; + + 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; + + // 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.velocity = Velocity * (CalamityWorld.malice ? 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; + + // Set destination of the laser, the target's center. + Destination = projectile.velocity; + + // 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; + + // 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; + + // 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); + } + } + + TelegraphDelay++; + } + + 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); + target.AddBuff(BuffID.OnFire, 180); + } + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(255, 255, 255, projectile.alpha); + } + + public override void ModifyHitPlayer(Player target, ref int damage, ref bool crit) + { + target.Calamity().lastProjectileHit = projectile; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TelegraphDelay >= TelegraphTotalTime) + return true; + + Texture2D laserTelegraph = ModContent.GetTexture("CalamityMod/ExtraTextures/LaserWallTelegraphBeam"); + + float yScale = 4f; + if (TelegraphDelay < TelegraphFadeTime) + yScale = MathHelper.Lerp(0f, 4f, TelegraphDelay / 15f); + if (TelegraphDelay > TelegraphTotalTime - TelegraphFadeTime) + yScale = MathHelper.Lerp(4f, 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); + + 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; + + 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/ExoDestroyerLaser.png b/Projectiles/Boss/ExoDestroyerLaser.png new file mode 100644 index 0000000000..49cdca1d74 Binary files /dev/null and b/Projectiles/Boss/ExoDestroyerLaser.png differ diff --git a/Projectiles/Boss/HolyBomb.cs b/Projectiles/Boss/HolyBomb.cs index eb555202de..b61ec81001 100644 --- a/Projectiles/Boss/HolyBomb.cs +++ b/Projectiles/Boss/HolyBomb.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.NPCs.Providence; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -80,12 +81,12 @@ 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); + 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) { - Texture2D texture2D13 = (Main.dayTime && !CalamityWorld.malice) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyBombNight"); + 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 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); @@ -101,7 +102,7 @@ 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; + 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); @@ -119,7 +120,7 @@ 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) || !NPC.AnyNPCs(ModContent.NPCType())) ? ModContent.BuffType() : ModContent.BuffType(); target.AddBuff(buffType, 180); } diff --git a/Projectiles/Boss/HolyFlare.cs b/Projectiles/Boss/HolyFlare.cs index 6faec72a4a..dbf26f1530 100644 --- a/Projectiles/Boss/HolyFlare.cs +++ b/Projectiles/Boss/HolyFlare.cs @@ -1,5 +1,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; +using CalamityMod.NPCs.Providence; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -70,12 +71,12 @@ 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); + 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) { - Texture2D texture2D13 = (Main.dayTime && !CalamityWorld.malice) ? Main.projectileTexture[projectile.type] : ModContent.GetTexture("CalamityMod/Projectiles/Boss/HolyFlareNight"); + 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 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); @@ -91,7 +92,7 @@ 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) ? (int)CalamityDusts.ProfanedFire : (int)CalamityDusts.Nightwither; + 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); @@ -111,7 +112,7 @@ 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) || !NPC.AnyNPCs(ModContent.NPCType())) ? ModContent.BuffType() : ModContent.BuffType(); target.AddBuff(buffType, 120); } diff --git a/Projectiles/Boss/IchorBlob.cs b/Projectiles/Boss/IchorBlob.cs new file mode 100644 index 0000000000..6df530e4c4 --- /dev/null +++ b/Projectiles/Boss/IchorBlob.cs @@ -0,0 +1,212 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class IchorBlob : ModProjectile + { + 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; + } + + public override void SetDefaults() + { + projectile.width = 52; + projectile.height = 56; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + 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() + { + // Deal no damage and increment the variable used to kill the projectile after 15 seconds + projectile.ai[1] += 1f; + if (projectile.ai[1] > 900f) + { + projectile.localAI[0] += 10f; + projectile.damage = 0; + } + + // 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 + 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 + 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; + + 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; + + 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); + + // 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.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; + + // 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 OnTileCollide(Vector2 oldVelocity) => false; + + public override bool CanHitPlayer(Player target) + { + Rectangle targetHitbox = target.Hitbox; + + Vector2 blobCenter = new Vector2(projectile.Center.X, projectile.Center.Y + 14f); + 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.ai[1] <= 900f && projectile.ai[1] > 120f; + } + + public override Color? GetAlpha(Color lightColor) + { + if (projectile.ai[1] > 900f) + { + byte b2 = (byte)((26f - (projectile.ai[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) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + if (projectile.ai[1] <= 900f && projectile.ai[1] > 120f) + target.AddBuff(BuffID.Ichor, 240); + } + } +} diff --git a/Projectiles/Boss/IchorBlob.png b/Projectiles/Boss/IchorBlob.png new file mode 100644 index 0000000000..d5292dbe27 Binary files /dev/null and b/Projectiles/Boss/IchorBlob.png differ diff --git a/Projectiles/Boss/IchorSporeCloud.cs b/Projectiles/Boss/IchorSporeCloud.cs deleted file mode 100644 index 719cef1c4c..0000000000 --- a/Projectiles/Boss/IchorSporeCloud.cs +++ /dev/null @@ -1,108 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Boss -{ - public class IchorSporeCloud : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/Boss/SporeGasPlantera"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ichor Spore Gas"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 2; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } - - public override void SetDefaults() - { - 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; - } - - 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() - { - projectile.ai[1] += 1f; - if (projectile.ai[1] > 900f) - { - projectile.localAI[0] += 10f; - projectile.damage = 0; - } - - if (projectile.localAI[0] > 255f) - { - projectile.Kill(); - projectile.localAI[0] = 255f; - } - - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.2f / 255f, (255 - projectile.alpha) * 0.16f / 255f, (255 - projectile.alpha) * 0.04f / 255f); - - projectile.alpha = (int)(100.0 + projectile.localAI[0] * 0.7); - projectile.rotation += projectile.velocity.X * 0.02f; - projectile.rotation += projectile.direction * 0.002f; - - if (projectile.velocity.Length() > 0.5f) - projectile.velocity *= 0.99f; - } - - public override bool CanHitPlayer(Player target) => projectile.ai[1] <= 900f && projectile.ai[1] > 120f; - - public override Color? GetAlpha(Color lightColor) - { - if (projectile.ai[1] > 900f) - { - byte b2 = (byte)((26f - (projectile.ai[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) - { - // Changes the texture of the projectile - Texture2D texture = Main.projectileTexture[projectile.type]; - switch ((int)projectile.ai[0]) - { - case 0: - break; - case 1: - texture = ModContent.GetTexture("CalamityMod/Projectiles/Boss/SporeGasPlantera2"); - break; - case 2: - texture = ModContent.GetTexture("CalamityMod/Projectiles/Boss/SporeGasPlantera3"); - break; - default: - break; - } - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1, texture); - return false; - } - - public override void OnHitPlayer(Player target, int damage, bool crit) - { - if (projectile.ai[1] <= 900f && projectile.ai[1] > 120f) - target.AddBuff(BuffID.Ichor, 240); - } - } -} diff --git a/Projectiles/Boss/InfernadoRevenge.cs b/Projectiles/Boss/InfernadoRevenge.cs index 5f4ea978fc..d6c43e35ea 100644 --- a/Projectiles/Boss/InfernadoRevenge.cs +++ b/Projectiles/Boss/InfernadoRevenge.cs @@ -4,24 +4,25 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.IO; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { public class InfernadoRevenge : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Boss/Flarenado"; - + internal PrimitiveTrail TornadoDrawer; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public const int TornadoHeight = 8800; public override void SetStaticDefaults() { DisplayName.SetDefault("Infernado"); - Main.projFrames[projectile.type] = 12; } public override void SetDefaults() { projectile.width = 320; - projectile.height = 88; + projectile.height = 1020; projectile.hostile = true; projectile.tileCollide = false; projectile.ignoreWater = true; @@ -48,80 +49,56 @@ namespace CalamityMod.Projectiles.Boss projectile.active = false; projectile.netUpdate = true; return; - } - float scaleBase = 70f; - float scaleMult = 3.5f; - float baseWidth = 320f; - float baseHeight = 88f; - - projectile.frameCounter++; - if (projectile.frameCounter > 2) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } - if (projectile.localAI[0] == 0f) - { - projectile.localAI[0] = 1f; - projectile.scale = (scaleBase - projectile.ai[1]) * scaleMult / scaleBase; - CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(baseWidth * projectile.scale), (int)(baseHeight * projectile.scale)); - projectile.netUpdate = true; - } - if (projectile.ai[1] != -1f) - { - projectile.scale = (scaleBase - projectile.ai[1]) * scaleMult / scaleBase; - projectile.width = (int)(baseWidth * projectile.scale); - projectile.height = (int)(baseHeight * projectile.scale); - } - - if (!Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.alpha -= 30; - if (projectile.alpha < 60) - { - projectile.alpha = 60; - } - } - else - { - projectile.alpha += 30; - if (projectile.alpha > 150) - { - projectile.alpha = 150; - } - } - if (projectile.ai[0] > 0f) - { - projectile.ai[0] -= 1f; - } - - if (projectile.ai[0] == 1f && projectile.ai[1] > 0f && projectile.owner == Main.myPlayer) - { - projectile.netUpdate = true; - Vector2 center = projectile.Center; - center.Y -= baseHeight * projectile.scale / 2f; - float num618 = (scaleBase - projectile.ai[1] + 1f) * scaleMult / scaleBase; - center.Y -= baseHeight * num618 / 2f; - center.Y += 2f; - Projectile.NewProjectile(center, projectile.velocity, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 11f, projectile.ai[1] - 1f); } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, projectile.alpha); + internal Color ColorFunction(float completionRatio) + { + return Color.Lerp(Color.Yellow, Color.Yellow, completionRatio); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float _ = 0f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), + targetHitbox.Size(), + projectile.Bottom, + projectile.Bottom - Vector2.UnitY * TornadoHeight, + 72, + ref _); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(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; - 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.None, 0f); + if (TornadoDrawer is null) + TornadoDrawer = new PrimitiveTrail(_ => projectile.width * 0.5f + 16f, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:Bordernado"]); + + GameShaders.Misc["CalamityMod:Bordernado"].UseSaturation(-0.2f); + GameShaders.Misc["CalamityMod:Bordernado"].SetShaderTexture(ModContent.GetTexture("Terraria/Misc/Perlin")); + Vector2[] drawPoints = new Vector2[5]; + Vector2 upwardAscent = Vector2.UnitY * TornadoHeight; + Vector2 downwardOffset = Vector2.UnitY * projectile.height / (drawPoints.Length + 1); + + Vector2 bottom = projectile.Bottom + downwardOffset; + Vector2 top = bottom - upwardAscent; + for (int i = 0; i < drawPoints.Length - 1; i++) + drawPoints[i] = Vector2.Lerp(top, bottom, i / (float)(drawPoints.Length - 1)); + + drawPoints[drawPoints.Length - 1] = bottom; + TornadoDrawer.Draw(drawPoints, -Main.screenPosition, 85); + + 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; + Vector2 drawPosition = bottom + angle.ToRotationVector2() * 4f - Main.screenPosition; + + 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; } diff --git a/Projectiles/Boss/MoltenBlob.cs b/Projectiles/Boss/MoltenBlob.cs index 4b073a77d9..bd115c6f79 100644 --- a/Projectiles/Boss/MoltenBlob.cs +++ b/Projectiles/Boss/MoltenBlob.cs @@ -31,6 +31,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { projectile.velocity.X *= 0.95f; + if (projectile.wet || projectile.lavaWet) { projectile.velocity.Y = 0f; @@ -39,10 +40,9 @@ namespace CalamityMod.Projectiles.Boss { projectile.velocity.Y += 0.1f; if (projectile.velocity.Y > 5f) - { projectile.velocity.Y = 5f; - } } + projectile.frameCounter++; if (projectile.frameCounter > 6) { @@ -50,9 +50,7 @@ namespace CalamityMod.Projectiles.Boss projectile.frameCounter = 0; } if (projectile.frame > 1) - { projectile.frame = 0; - } } public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough) @@ -61,14 +59,7 @@ namespace CalamityMod.Projectiles.Boss return true; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; public override Color? GetAlpha(Color lightColor) { diff --git a/Projectiles/Boss/PhantomMine.cs b/Projectiles/Boss/PhantomMine.cs index c063f053a2..ba24575eef 100644 --- a/Projectiles/Boss/PhantomMine.cs +++ b/Projectiles/Boss/PhantomMine.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { if (projectile.velocity.Length() < projectile.ai[0]) - projectile.velocity *= 1.05f; + projectile.velocity *= projectile.ai[1]; } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Boss/SCalRitualDrama.cs b/Projectiles/Boss/SCalRitualDrama.cs new file mode 100644 index 0000000000..215ae94a4f --- /dev/null +++ b/Projectiles/Boss/SCalRitualDrama.cs @@ -0,0 +1,78 @@ +using CalamityMod.Dusts; +using CalamityMod.NPCs.SupremeCalamitas; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class SCalRitualDrama : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public ref float Time => ref projectile.ai[0]; + public const int PulseTime = 45; + public const int TotalRitualTime = 270; + public override void SetStaticDefaults() => DisplayName.SetDefault("Calamitous Ritual Drama"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 2; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = TotalRitualTime; + } + + public override void AI() + { + SCalSky.OverridingIntensity = Utils.InverseLerp(90f, TotalRitualTime - 25f, Time, true); + Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.InverseLerp(90f, TotalRitualTime - 25f, Time, true); + Main.LocalPlayer.Calamity().GeneralScreenShakePower *= Utils.InverseLerp(3400f, 1560f, Main.LocalPlayer.Distance(projectile.Center), true) * 4f; + + int fireReleaseRate = Time > 150f ? 2 : 1; + for (int i = 0; i < fireReleaseRate; i++) + { + if (Main.rand.NextBool(4)) + { + Dust brimstone = Dust.NewDustPerfect(projectile.Center + new Vector2(Main.rand.NextFloat(-20f, 24f), Main.rand.NextFloat(10f, 18f)), 267); + brimstone.scale = Main.rand.NextFloat(0.7f, 1f); + brimstone.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat()); + brimstone.fadeIn = 0.7f; + brimstone.velocity = -Vector2.UnitY * Main.rand.NextFloat(1.5f, 2.8f); + brimstone.noGravity = true; + } + } + + Time++; + } + + public override void Kill(int timeLeft) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + CalamityUtils.SpawnBossBetter(projectile.Center - new Vector2(60f), ModContent.NPCType()); + + // Make a laugh sound and create a burst of brimstone dust. + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SupremeCalamitasSpawn"), projectile.Center); + Main.PlaySound(SoundID.DD2_EtherianPortalDryadTouch, projectile.Center); + + Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.InverseLerp(3400f, 1560f, Main.LocalPlayer.Distance(projectile.Center), true) * 16f; + + // Generate a dust explosion + float burstDirectionVariance = 3; + float burstSpeed = 14f; + for (int j = 0; j < 16; j++) + { + burstDirectionVariance += j * 2; + for (int k = 0; k < 40; k++) + { + Dust burstDust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.Brimstone); + burstDust.scale = Main.rand.NextFloat(3.1f, 3.5f); + burstDust.position += Main.rand.NextVector2Circular(10f, 10f); + burstDust.velocity = Main.rand.NextVector2Square(-burstDirectionVariance, burstDirectionVariance).SafeNormalize(Vector2.UnitY) * burstSpeed; + burstDust.noGravity = true; + } + burstSpeed += 1.8f; + } + } + } +} diff --git a/Projectiles/Boss/SkyFlareRevenge.cs b/Projectiles/Boss/SkyFlareRevenge.cs index 71d404d7e9..f39d157b8c 100644 --- a/Projectiles/Boss/SkyFlareRevenge.cs +++ b/Projectiles/Boss/SkyFlareRevenge.cs @@ -74,6 +74,7 @@ namespace CalamityMod.Projectiles.Boss 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; } } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index 8559271bb3..a8e8b82a10 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -1,5 +1,8 @@ +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Events; +using CalamityMod.Items.Accessories; +using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; @@ -14,8 +17,11 @@ using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Utilities; using static Terraria.ModLoader.ModContent; +using NanotechProjectile = CalamityMod.Projectiles.Typeless.Nanotech; + namespace CalamityMod.Projectiles { public class CalamityGlobalProjectile : GlobalProjectile @@ -104,6 +110,7 @@ namespace CalamityMod.Projectiles // Boss projectile velocity multiplier in Malice Mode public bool affectedByMaliceModeVelocityMultiplier = false; public const float MaliceModeProjectileVelocityMultiplier = 1.25f; + public const float BossRushProjectileVelocityMultiplier = 1.35f; #region SetDefaults public override void SetDefaults(Projectile projectile) @@ -146,6 +153,30 @@ namespace CalamityMod.Projectiles projectile.idStaticNPCHitCooldown = 12; break; + case ProjectileID.WoodYoyo: + case ProjectileID.CorruptYoyo: + case ProjectileID.CrimsonYoyo: + case ProjectileID.JungleYoyo: + case ProjectileID.RedsYoyo: + case ProjectileID.ValkyrieYoyo: + case ProjectileID.Kraken: + case ProjectileID.Rally: + case ProjectileID.Code1: + case ProjectileID.Code2: + case ProjectileID.Valor: + case ProjectileID.Cascade: + case ProjectileID.Chik: + case ProjectileID.FormatC: + case ProjectileID.HelFire: + case ProjectileID.Amarok: + case ProjectileID.Gradient: + case ProjectileID.Yelets: + case ProjectileID.TheEyeOfCthulhu: + case ProjectileID.Terrarian: + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + break; + case ProjectileID.DD2BetsyFireball: case ProjectileID.DD2BetsyFlameBreath: case ProjectileID.CultistBossLightningOrbArc: @@ -331,7 +362,305 @@ namespace CalamityMod.Projectiles return false; } - if (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice) + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } + + if (adultWyrmAlive) + { + if (projectile.type == ProjectileID.CultistBossFireBallClone) + { + if (projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; + Main.PlaySound(SoundID.Item34, projectile.position); + } + else if (projectile.ai[1] == 1f && Main.netMode != NetmodeID.MultiplayerClient) + { + int num13 = -1; + float num14 = 2000f; + for (int num15 = 0; num15 < Main.maxPlayers; num15++) + { + if (Main.player[num15].active && !Main.player[num15].dead) + { + Vector2 center2 = Main.player[num15].Center; + float num16 = Vector2.Distance(center2, projectile.Center); + if ((num16 < num14 || num13 == -1) && Collision.CanHit(projectile.Center, 1, 1, center2, 1, 1)) + { + num14 = num16; + num13 = num15; + } + } + } + + if (num14 < 20f) + { + projectile.Kill(); + return false; + } + + if (num13 != -1) + { + projectile.ai[1] = 21f; + projectile.ai[0] = num13; + projectile.netUpdate = true; + } + } + else if (projectile.ai[1] > 20f && projectile.ai[1] < 200f) + { + projectile.ai[1] += 1f; + int num17 = (int)projectile.ai[0]; + if (!Main.player[num17].active || Main.player[num17].dead) + { + projectile.ai[1] = 1f; + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + else + { + float num18 = projectile.velocity.ToRotation(); + Vector2 vector2 = Main.player[num17].Center - projectile.Center; + if (vector2.Length() < 20f) + { + projectile.Kill(); + return false; + } + + float targetAngle2 = vector2.ToRotation(); + if (vector2 == Vector2.Zero) + targetAngle2 = num18; + + float num19 = num18.AngleLerp(targetAngle2, 0.01f); + projectile.velocity = new Vector2(projectile.velocity.Length(), 0f).RotatedBy(num19); + } + } + + if (projectile.ai[1] >= 1f && projectile.ai[1] < 20f) + { + projectile.ai[1] += 1f; + if (projectile.ai[1] == 20f) + projectile.ai[1] = 1f; + } + + projectile.alpha -= 40; + if (projectile.alpha < 0) + projectile.alpha = 0; + + projectile.spriteDirection = projectile.direction; + + projectile.frameCounter++; + if (projectile.frameCounter >= 3) + { + projectile.frame++; + projectile.frameCounter = 0; + if (projectile.frame >= 4) + projectile.frame = 0; + } + + if (Main.rand.Next(4) == 0) + { + Vector2 value4 = -Vector2.UnitX.RotatedByRandom(0.19634954631328583).RotatedBy(projectile.velocity.ToRotation()); + int num23 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 100); + Main.dust[num23].velocity *= 0.1f; + Main.dust[num23].position = projectile.Center + value4 * projectile.width / 2f; + Main.dust[num23].fadeIn = 0.9f; + } + + if (Main.rand.Next(32) == 0) + { + Vector2 value5 = -Vector2.UnitX.RotatedByRandom(0.39269909262657166).RotatedBy(projectile.velocity.ToRotation()); + int num25 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 31, 0f, 0f, 155, default, 0.8f); + Main.dust[num25].velocity *= 0.3f; + Main.dust[num25].position = projectile.Center + value5 * projectile.width / 2f; + if (Main.rand.Next(2) == 0) + Main.dust[num25].fadeIn = 1.4f; + } + + if (Main.rand.Next(2) == 0) + { + Vector2 value6 = -Vector2.UnitX.RotatedByRandom(0.78539818525314331).RotatedBy(projectile.velocity.ToRotation()); + int num27 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 0, default, 1.2f); + Main.dust[num27].velocity *= 0.3f; + Main.dust[num27].noGravity = true; + Main.dust[num27].position = projectile.Center + value6 * projectile.width / 2f; + if (Main.rand.Next(2) == 0) + Main.dust[num27].fadeIn = 1.4f; + } + + return false; + } + else if (projectile.type == ProjectileID.CultistBossIceMist) + { + if (projectile.localAI[1] == 0f) + { + projectile.localAI[1] = 1f; + Main.PlaySound(SoundID.Item120, projectile.position); + } + + projectile.ai[0] += 1f; + + // Main projectile + float duration = 300f; + if (projectile.ai[1] == 1f) + { + if (projectile.ai[0] >= duration - 20f) + projectile.alpha += 10; + else + projectile.alpha -= 10; + + if (projectile.alpha < 0) + projectile.alpha = 0; + if (projectile.alpha > 255) + projectile.alpha = 255; + + if (projectile.ai[0] >= duration) + { + projectile.Kill(); + return false; + } + + int num103 = Player.FindClosest(projectile.Center, 1, 1); + Vector2 vector11 = Main.player[num103].Center - projectile.Center; + float scaleFactor2 = projectile.velocity.Length(); + vector11.Normalize(); + vector11 *= scaleFactor2; + projectile.velocity = (projectile.velocity * 15f + vector11) / 16f; + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor2; + + if (projectile.ai[0] % 60f == 0f && Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 vector50 = projectile.rotation.ToRotationVector2(); + Projectile.NewProjectile(projectile.Center, vector50, projectile.type, projectile.damage, projectile.knockBack, projectile.owner); + } + + projectile.rotation += (float)Math.PI / 30f; + + return false; + } + + // Split projectiles + projectile.position -= projectile.velocity; + + if (projectile.ai[0] >= duration - 260f) + projectile.alpha += 3; + else + projectile.alpha -= 40; + + if (projectile.alpha < 0) + projectile.alpha = 0; + if (projectile.alpha > 255) + projectile.alpha = 255; + + if (projectile.ai[0] >= duration - 255f) + { + projectile.Kill(); + return false; + } + + Vector2 value39 = new Vector2(0f, -720f).RotatedBy(projectile.velocity.ToRotation()); + float scaleFactor3 = projectile.ai[0] % (duration - 255f) / (duration - 255f); + Vector2 spinningpoint13 = value39 * scaleFactor3; + + for (int num724 = 0; num724 < 6; num724++) + { + Vector2 vector51 = projectile.Center + spinningpoint13.RotatedBy(num724 * ((float)Math.PI * 2f) / 6f); + int num726 = Dust.NewDust(vector51 + Utils.RandomVector2(Main.rand, -8f, 8f) / 2f, 8, 8, 197, 0f, 0f, 100, Color.Transparent); + Main.dust[num726].noGravity = true; + } + + return false; + } + else if (projectile.type == ProjectileID.CultistBossLightningOrbArc) + { + projectile.frameCounter++; + if (projectile.velocity == Vector2.Zero) + { + if (projectile.frameCounter >= projectile.extraUpdates * 2) + { + projectile.frameCounter = 0; + bool flag30 = true; + for (int num742 = 1; num742 < projectile.oldPos.Length; num742++) + { + if (projectile.oldPos[num742] != projectile.oldPos[0]) + flag30 = false; + } + + if (flag30) + { + projectile.Kill(); + return false; + } + } + } + else + { + if (projectile.frameCounter < projectile.extraUpdates * 2) + return false; + + projectile.frameCounter = 0; + float num748 = projectile.velocity.Length(); + UnifiedRandom unifiedRandom = new UnifiedRandom((int)projectile.ai[1]); + int num749 = 0; + Vector2 spinningpoint14 = -Vector2.UnitY; + while (true) + { + int num750 = unifiedRandom.Next(); + projectile.ai[1] = num750; + num750 %= 100; + float f = (float)num750 / 100f * ((float)Math.PI * 2f); + Vector2 vector55 = f.ToRotationVector2(); + if (vector55.Y > 0f) + { + vector55.Y *= -1f; + } + + bool flag31 = false; + if (vector55.Y > -0.02f) + { + flag31 = true; + } + if (vector55.X * (float)(projectile.extraUpdates + 1) * 2f * num748 + projectile.localAI[0] > 40f) + { + flag31 = true; + } + if (vector55.X * (float)(projectile.extraUpdates + 1) * 2f * num748 + projectile.localAI[0] < -40f) + { + flag31 = true; + } + + if (flag31) + { + if (num749++ >= 100) + { + projectile.velocity = Vector2.Zero; + projectile.localAI[1] = 1f; + break; + } + continue; + } + + spinningpoint14 = vector55; + + break; + } + + if (projectile.velocity != Vector2.Zero) + { + projectile.localAI[0] += spinningpoint14.X * (float)(projectile.extraUpdates + 1) * 2f * num748; + projectile.velocity = spinningpoint14.RotatedBy(projectile.ai[0] + (float)Math.PI / 2f) * num748; + projectile.rotation = projectile.velocity.ToRotation() + (float)Math.PI / 2f; + } + } + + return false; + } + } + + if (CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice) { if (projectile.type == ProjectileID.DemonSickle && CalamityPlayer.areThereAnyDamnBosses) { @@ -361,31 +690,31 @@ namespace CalamityMod.Projectiles return false; } - else if (projectile.type == ProjectileID.EyeLaser && projectile.ai[0] == 1f) - { - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + else if (projectile.type == ProjectileID.EyeLaser && projectile.ai[0] == 1f) + { + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.3f / 255f, 0f, (255 - projectile.alpha) * 0.3f / 255f); + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.3f / 255f, 0f, (255 - projectile.alpha) * 0.3f / 255f); - if (projectile.alpha > 0) - projectile.alpha -= 125; - if (projectile.alpha < 0) - projectile.alpha = 0; + 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.localAI[1] == 0f) + { + Main.PlaySound(SoundID.Item33, (int)projectile.position.X, (int)projectile.position.Y); + projectile.localAI[1] = 1f; + } - if (projectile.velocity.Length() < 18f) - projectile.velocity *= 1.0025f; + if (projectile.velocity.Length() < 18f) + projectile.velocity *= 1.0025f; - return false; - } + return false; + } - else if (projectile.type == ProjectileID.DeathLaser && projectile.ai[0] == 1f) - { + else if (projectile.type == ProjectileID.DeathLaser && projectile.ai[0] == 1f) + { if (defDamage == 0) { // Reduce mech boss projectile damage depending on the new ore progression changes @@ -402,250 +731,250 @@ namespace CalamityMod.Projectiles projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.75f / 255f, 0f, 0f); + Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.75f / 255f, 0f, 0f); - if (projectile.alpha > 0) - projectile.alpha -= 125; - if (projectile.alpha < 0) - projectile.alpha = 0; + 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.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; + if (projectile.velocity.Length() < 12f) + projectile.velocity *= 1.0025f; - return false; - } + return false; + } - else if (projectile.type == ProjectileID.PoisonSeedPlantera) - { - projectile.frameCounter++; - if (projectile.frameCounter > 1) - { - projectile.frameCounter = 0; - projectile.frame++; + else if (projectile.type == ProjectileID.PoisonSeedPlantera) + { + projectile.frameCounter++; + if (projectile.frameCounter > 1) + { + projectile.frameCounter = 0; + projectile.frame++; - if (projectile.frame > 1) - projectile.frame = 0; - } + if (projectile.frame > 1) + projectile.frame = 0; + } - if (projectile.ai[1] == 0f) - { - projectile.ai[1] = 1f; - Main.PlaySound(SoundID.Item17, projectile.position); - } + if (projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; + Main.PlaySound(SoundID.Item17, projectile.position); + } - if (projectile.alpha > 0) - projectile.alpha -= 30; - if (projectile.alpha < 0) - projectile.alpha = 0; + if (projectile.alpha > 0) + projectile.alpha -= 30; + if (projectile.alpha < 0) + projectile.alpha = 0; - projectile.ai[0] += 1f; - if (projectile.ai[0] >= 120f) - { - projectile.ai[0] = 120f; + projectile.ai[0] += 1f; + if (projectile.ai[0] >= 120f) + { + projectile.ai[0] = 120f; - if (projectile.velocity.Length() < 18f) - projectile.velocity *= 1.01f; - } + if (projectile.velocity.Length() < 18f) + projectile.velocity *= 1.01f; + } - projectile.tileCollide = false; + projectile.tileCollide = false; - if (projectile.timeLeft > 600) - projectile.timeLeft = 600; + if (projectile.timeLeft > 600) + projectile.timeLeft = 600; - projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + 1.57f; - return false; - } + return false; + } - else if (projectile.type == ProjectileID.ThornBall) - { - if (projectile.alpha > 0) - { - projectile.alpha -= 30; - if (projectile.alpha < 0) - projectile.alpha = 0; - } + else if (projectile.type == ProjectileID.ThornBall) + { + if (projectile.alpha > 0) + { + projectile.alpha -= 30; + if (projectile.alpha < 0) + projectile.alpha = 0; + } - int num147 = Player.FindClosest(projectile.Center, 1, 1); - float num146 = 7.5f * projectile.ai[1] + Vector2.Distance(Main.player[num147].Center, projectile.Center) * 0.01f; - Vector2 vector12 = Main.player[num147].Center - projectile.Center; - vector12.Normalize(); - vector12 *= num146; - int num148 = 200; - projectile.velocity.X = (projectile.velocity.X * (num148 - 1) + vector12.X) / num148; + int num147 = Player.FindClosest(projectile.Center, 1, 1); + float num146 = 7.5f * projectile.ai[1] + Vector2.Distance(Main.player[num147].Center, projectile.Center) * 0.01f; + Vector2 vector12 = Main.player[num147].Center - projectile.Center; + vector12.Normalize(); + vector12 *= num146; + int num148 = 200; + projectile.velocity.X = (projectile.velocity.X * (num148 - 1) + vector12.X) / num148; - if (projectile.velocity.Length() > 16f) - { - projectile.velocity.Normalize(); - projectile.velocity *= 16f; - } + if (projectile.velocity.Length() > 16f) + { + projectile.velocity.Normalize(); + projectile.velocity *= 16f; + } - projectile.ai[0] += 1f; - if (projectile.ai[0] > 15f) - { - if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) - { - projectile.velocity.X *= 0.97f; - if (projectile.velocity.X > -0.01f && projectile.velocity.X < 0.01f) - projectile.Kill(); - } - projectile.velocity.Y += 0.1f; - } + projectile.ai[0] += 1f; + if (projectile.ai[0] > 15f) + { + if (projectile.velocity.Y == 0f && projectile.velocity.X != 0f) + { + projectile.velocity.X *= 0.97f; + if (projectile.velocity.X > -0.01f && projectile.velocity.X < 0.01f) + projectile.Kill(); + } + projectile.velocity.Y += 0.1f; + } - projectile.rotation += projectile.velocity.X * 0.05f; + projectile.rotation += projectile.velocity.X * 0.05f; - if (projectile.velocity.Y > 16f) - projectile.velocity.Y = 16f; + if (projectile.velocity.Y > 16f) + projectile.velocity.Y = 16f; - return false; - } + return false; + } - // Phase 1 sharknado - else if (projectile.type == ProjectileID.SharknadoBolt) - { - if (projectile.ai[1] < 0f) - { - float num623 = 0.209439516f; - float num624 = -2f; - float num625 = (float)(Math.Cos(num623 * projectile.ai[0]) - 0.5) * num624; + // Phase 1 sharknado + else if (projectile.type == ProjectileID.SharknadoBolt) + { + if (projectile.ai[1] < 0f) + { + float num623 = 0.209439516f; + float num624 = -2f; + float num625 = (float)(Math.Cos(num623 * projectile.ai[0]) - 0.5) * num624; - projectile.velocity.Y -= num625; + projectile.velocity.Y -= num625; - projectile.ai[0] += 1f; + projectile.ai[0] += 1f; - num625 = (float)(Math.Cos(num623 * projectile.ai[0]) - 0.5) * num624; + num625 = (float)(Math.Cos(num623 * projectile.ai[0]) - 0.5) * num624; - projectile.velocity.Y += num625; + projectile.velocity.Y += num625; - 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; - projectile.rotation += projectile.velocity.X * 0.1f; - projectile.frame = (int)(projectile.localAI[0] / 3f) % 3; - } + projectile.rotation += projectile.velocity.X * 0.1f; + projectile.frame = (int)(projectile.localAI[0] / 3f) % 3; + } - return false; - } - } + return false; + } + } - else if (projectile.type == ProjectileID.Sharknado) - { - projectile.damage = projectile.GetProjectileDamage(NPCID.DukeFishron); - } + else if (projectile.type == ProjectileID.Sharknado) + { + projectile.damage = projectile.GetProjectileDamage(NPCID.DukeFishron); + } - // Larger cthulhunadoes - else if (projectile.type == ProjectileID.Cthulunado) - { - projectile.damage = projectile.GetProjectileDamage(NPCID.DukeFishron); + // Larger cthulhunadoes + else if (projectile.type == ProjectileID.Cthulunado) + { + projectile.damage = projectile.GetProjectileDamage(NPCID.DukeFishron); - int num606 = 16; - int num607 = 16; - float num608 = 2f; - int num609 = 150; - int num610 = 42; + int num606 = 16; + int num607 = 16; + float num608 = 2f; + int num609 = 150; + int num610 = 42; - if (projectile.velocity.X != 0f) - projectile.direction = projectile.spriteDirection = -Math.Sign(projectile.velocity.X); + if (projectile.velocity.X != 0f) + projectile.direction = projectile.spriteDirection = -Math.Sign(projectile.velocity.X); - int num3 = projectile.frameCounter; - projectile.frameCounter = num3 + 1; - if (projectile.frameCounter > 2) - { - num3 = projectile.frame; - projectile.frame = num3 + 1; - projectile.frameCounter = 0; - } - if (projectile.frame >= 6) - projectile.frame = 0; + int num3 = projectile.frameCounter; + projectile.frameCounter = num3 + 1; + if (projectile.frameCounter > 2) + { + num3 = projectile.frame; + projectile.frame = num3 + 1; + projectile.frameCounter = 0; + } + if (projectile.frame >= 6) + projectile.frame = 0; - if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner) - { - projectile.localAI[0] = 1f; - projectile.position.X += projectile.width / 2; - projectile.position.Y += projectile.height / 2; - projectile.scale = (num606 + num607 - projectile.ai[1]) * num608 / (num607 + num606); - projectile.width = (int)(num609 * projectile.scale); - projectile.height = (int)(num610 * projectile.scale); - projectile.position.X -= projectile.width / 2; - projectile.position.Y -= projectile.height / 2; - projectile.netUpdate = true; - } + if (projectile.localAI[0] == 0f && Main.myPlayer == projectile.owner) + { + projectile.localAI[0] = 1f; + projectile.position.X += projectile.width / 2; + projectile.position.Y += projectile.height / 2; + projectile.scale = (num606 + num607 - projectile.ai[1]) * num608 / (num607 + num606); + projectile.width = (int)(num609 * projectile.scale); + projectile.height = (int)(num610 * projectile.scale); + projectile.position.X -= projectile.width / 2; + projectile.position.Y -= projectile.height / 2; + projectile.netUpdate = true; + } - if (projectile.ai[1] != -1f) - { - projectile.scale = (num606 + num607 - projectile.ai[1]) * num608 / (num607 + num606); - projectile.width = (int)(num609 * projectile.scale); - projectile.height = (int)(num610 * projectile.scale); - } + if (projectile.ai[1] != -1f) + { + projectile.scale = (num606 + num607 - projectile.ai[1]) * num608 / (num607 + num606); + projectile.width = (int)(num609 * projectile.scale); + projectile.height = (int)(num610 * projectile.scale); + } - if (!Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) - { - projectile.alpha -= 30; - if (projectile.alpha < 60) - projectile.alpha = 60; - if (projectile.alpha < 100) - projectile.alpha = 100; - } - else - { - projectile.alpha += 30; - if (projectile.alpha > 150) - projectile.alpha = 150; - } + if (!Collision.SolidCollision(projectile.position, projectile.width, projectile.height)) + { + projectile.alpha -= 30; + if (projectile.alpha < 60) + projectile.alpha = 60; + if (projectile.alpha < 100) + projectile.alpha = 100; + } + else + { + projectile.alpha += 30; + if (projectile.alpha > 150) + projectile.alpha = 150; + } - if (projectile.ai[0] > 0f) - projectile.ai[0] -= 1f; + if (projectile.ai[0] > 0f) + projectile.ai[0] -= 1f; - if (projectile.ai[0] == 1f && projectile.ai[1] > 0f && projectile.owner == Main.myPlayer) - { - projectile.netUpdate = true; + if (projectile.ai[0] == 1f && projectile.ai[1] > 0f && projectile.owner == Main.myPlayer) + { + projectile.netUpdate = true; - Vector2 center = projectile.Center; - center.Y -= num610 * projectile.scale / 2f; + Vector2 center = projectile.Center; + center.Y -= num610 * projectile.scale / 2f; - float num611 = (num606 + num607 - projectile.ai[1] + 1f) * num608 / (num607 + num606); - center.Y -= num610 * num611 / 2f; - center.Y += 2f; + float num611 = (num606 + num607 - projectile.ai[1] + 1f) * num608 / (num607 + num606); + center.Y -= num610 * num611 / 2f; + center.Y += 2f; - Projectile.NewProjectile(center.X, center.Y, projectile.velocity.X, projectile.velocity.Y, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); + Projectile.NewProjectile(center.X, center.Y, projectile.velocity.X, projectile.velocity.Y, projectile.type, projectile.damage, projectile.knockBack, projectile.owner, 10f, projectile.ai[1] - 1f); - if ((int)projectile.ai[1] % 3 == 0 && projectile.ai[1] != 0f) - { - int num614 = NPC.NewNPC((int)center.X, (int)center.Y, NPCID.Sharkron2); - Main.npc[num614].velocity = projectile.velocity; - Main.npc[num614].scale = 1.5f; - Main.npc[num614].netUpdate = true; - Main.npc[num614].ai[2] = projectile.width; - Main.npc[num614].ai[3] = -1.5f; - } - } + if ((int)projectile.ai[1] % 3 == 0 && projectile.ai[1] != 0f) + { + int num614 = NPC.NewNPC((int)center.X, (int)center.Y, NPCID.Sharkron2); + Main.npc[num614].velocity = projectile.velocity; + Main.npc[num614].scale = 1.5f; + Main.npc[num614].netUpdate = true; + Main.npc[num614].ai[2] = projectile.width; + Main.npc[num614].ai[3] = -1.5f; + } + } - if (projectile.ai[0] <= 0f) - { - float num615 = 0.104719758f; - float num616 = projectile.width / 5f * 2.5f; - float num617 = (float)(Math.Cos(num615 * -(double)projectile.ai[0]) - 0.5) * num616; + if (projectile.ai[0] <= 0f) + { + float num615 = 0.104719758f; + float num616 = projectile.width / 5f * 2.5f; + float num617 = (float)(Math.Cos(num615 * -(double)projectile.ai[0]) - 0.5) * num616; - projectile.position.X -= num617 * -projectile.direction; + projectile.position.X -= num617 * -projectile.direction; - projectile.ai[0] -= 1f; + projectile.ai[0] -= 1f; - num617 = (float)(Math.Cos(num615 * -(double)projectile.ai[0]) - 0.5) * num616; - projectile.position.X += num617 * -projectile.direction; - } + num617 = (float)(Math.Cos(num615 * -(double)projectile.ai[0]) - 0.5) * num616; + projectile.position.X += num617 * -projectile.direction; + } - return false; - } + return false; + } else if (projectile.type == ProjectileID.CultistBossLightningOrb) { @@ -850,226 +1179,226 @@ namespace CalamityMod.Projectiles return false; } - // Change the stupid homing eyes - else if (projectile.type == ProjectileID.PhantasmalEye) - { - projectile.alpha -= 40; - if (projectile.alpha < 0) - projectile.alpha = 0; + // Change the stupid homing eyes + else if (projectile.type == ProjectileID.PhantasmalEye) + { + projectile.alpha -= 40; + if (projectile.alpha < 0) + projectile.alpha = 0; - if (projectile.ai[0] == 0f) - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 45f) - { - projectile.localAI[0] = 0f; - projectile.ai[0] = 1f; - projectile.ai[1] = 0f - projectile.ai[1]; - projectile.netUpdate = true; - } + if (projectile.ai[0] == 0f) + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 45f) + { + projectile.localAI[0] = 0f; + projectile.ai[0] = 1f; + projectile.ai[1] = 0f - projectile.ai[1]; + projectile.netUpdate = true; + } - projectile.velocity.X = projectile.velocity.RotatedBy(projectile.ai[1]).X; - projectile.velocity.X = MathHelper.Clamp(projectile.velocity.X, -6f, 6f); - projectile.velocity.Y -= 0.08f; + projectile.velocity.X = projectile.velocity.RotatedBy(projectile.ai[1]).X; + projectile.velocity.X = MathHelper.Clamp(projectile.velocity.X, -6f, 6f); + projectile.velocity.Y -= 0.08f; - if (projectile.velocity.Y > 0f) - projectile.velocity.Y -= 0.2f; - if (projectile.velocity.Y < -7f) - projectile.velocity.Y = -7f; - } - else if (projectile.ai[0] == 1f) - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 90f) - { - projectile.localAI[0] = 0f; - projectile.ai[0] = 2f; - projectile.ai[1] = Player.FindClosest(projectile.position, projectile.width, projectile.height); - projectile.netUpdate = true; - } + if (projectile.velocity.Y > 0f) + projectile.velocity.Y -= 0.2f; + if (projectile.velocity.Y < -7f) + projectile.velocity.Y = -7f; + } + else if (projectile.ai[0] == 1f) + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 90f) + { + projectile.localAI[0] = 0f; + projectile.ai[0] = 2f; + projectile.ai[1] = Player.FindClosest(projectile.position, projectile.width, projectile.height); + projectile.netUpdate = true; + } - projectile.velocity.X = projectile.velocity.RotatedBy(projectile.ai[1]).X; - projectile.velocity.X = MathHelper.Clamp(projectile.velocity.X, -6f, 6f); - projectile.velocity.Y -= 0.08f; + projectile.velocity.X = projectile.velocity.RotatedBy(projectile.ai[1]).X; + projectile.velocity.X = MathHelper.Clamp(projectile.velocity.X, -6f, 6f); + projectile.velocity.Y -= 0.08f; - if (projectile.velocity.Y > 0f) - projectile.velocity.Y -= 0.2f; - if (projectile.velocity.Y < -7f) - projectile.velocity.Y = -7f; - } - else if (projectile.ai[0] == 2f) - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 45f) - { - projectile.localAI[0] = 0f; - projectile.ai[0] = 3f; - projectile.netUpdate = true; - } + if (projectile.velocity.Y > 0f) + projectile.velocity.Y -= 0.2f; + if (projectile.velocity.Y < -7f) + projectile.velocity.Y = -7f; + } + else if (projectile.ai[0] == 2f) + { + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 45f) + { + projectile.localAI[0] = 0f; + projectile.ai[0] = 3f; + projectile.netUpdate = true; + } - Vector2 value23 = Main.player[(int)projectile.ai[1]].Center - projectile.Center; - value23.Normalize(); - value23 *= 12f; - value23 = Vector2.Lerp(projectile.velocity, value23, 0.6f); + Vector2 value23 = Main.player[(int)projectile.ai[1]].Center - projectile.Center; + value23.Normalize(); + value23 *= 12f; + value23 = Vector2.Lerp(projectile.velocity, value23, 0.6f); - float num675 = 0.4f; - if (projectile.velocity.X < value23.X) - { - projectile.velocity.X += num675; - if (projectile.velocity.X < 0f && value23.X > 0f) - projectile.velocity.X += num675; - } - else if (projectile.velocity.X > value23.X) - { - projectile.velocity.X -= num675; - if (projectile.velocity.X > 0f && value23.X < 0f) - projectile.velocity.X -= num675; - } - if (projectile.velocity.Y < value23.Y) - { - projectile.velocity.Y += num675; - if (projectile.velocity.Y < 0f && value23.Y > 0f) - projectile.velocity.Y += num675; - } - else if (projectile.velocity.Y > value23.Y) - { - projectile.velocity.Y -= num675; - if (projectile.velocity.Y > 0f && value23.Y < 0f) - projectile.velocity.Y -= num675; - } - } - else if (projectile.ai[0] == 3f) - { - Vector2 value23 = Main.player[(int)projectile.ai[1]].Center - projectile.Center; - if (value23.Length() < 30f) - { - projectile.Kill(); - return false; - } + float num675 = 0.4f; + if (projectile.velocity.X < value23.X) + { + projectile.velocity.X += num675; + if (projectile.velocity.X < 0f && value23.X > 0f) + projectile.velocity.X += num675; + } + else if (projectile.velocity.X > value23.X) + { + projectile.velocity.X -= num675; + if (projectile.velocity.X > 0f && value23.X < 0f) + projectile.velocity.X -= num675; + } + if (projectile.velocity.Y < value23.Y) + { + projectile.velocity.Y += num675; + if (projectile.velocity.Y < 0f && value23.Y > 0f) + projectile.velocity.Y += num675; + } + else if (projectile.velocity.Y > value23.Y) + { + projectile.velocity.Y -= num675; + if (projectile.velocity.Y > 0f && value23.Y < 0f) + projectile.velocity.Y -= num675; + } + } + else if (projectile.ai[0] == 3f) + { + Vector2 value23 = Main.player[(int)projectile.ai[1]].Center - projectile.Center; + if (value23.Length() < 30f) + { + projectile.Kill(); + return false; + } - float velocityLimit = ((CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) ? 28f : 24f) / MathHelper.Clamp(lineColor * 0.75f, 1f, 3f); - if (projectile.velocity.Length() < velocityLimit) - projectile.velocity *= 1.01f; - } + float velocityLimit = ((CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice) ? 28f : 24f) / MathHelper.Clamp(lineColor * 0.75f, 1f, 3f); + if (projectile.velocity.Length() < velocityLimit) + projectile.velocity *= 1.01f; + } - if (projectile.alpha < 40) - { - int num676 = Dust.NewDust(projectile.Center - Vector2.One * 5f, 10, 10, 229, (0f - projectile.velocity.X) / 3f, (0f - projectile.velocity.Y) / 3f, 150, Color.Transparent, 1.2f); - Main.dust[num676].noGravity = true; - } + if (projectile.alpha < 40) + { + int num676 = Dust.NewDust(projectile.Center - Vector2.One * 5f, 10, 10, 229, (0f - projectile.velocity.X) / 3f, (0f - projectile.velocity.Y) / 3f, 150, Color.Transparent, 1.2f); + Main.dust[num676].noGravity = true; + } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - return false; - } + 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 || CalamityWorld.malice) ? 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 || CalamityWorld.malice) ? 14f : 12f; + if (projectile.velocity.Length() < velocityLimit) + projectile.velocity *= 1.0075f; - return true; - } + return true; + } - // Moon Lord Deathray - else if (projectile.type == ProjectileID.PhantasmalDeathray) - { - if (Main.npc[(int)projectile.ai[1]].type == NPCID.MoonLordHead) - { - Vector2? vector78 = null; + // Moon Lord Deathray + else if (projectile.type == ProjectileID.PhantasmalDeathray) + { + if (Main.npc[(int)projectile.ai[1]].type == NPCID.MoonLordHead) + { + 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) - { - Vector2 value21 = new Vector2(27f, 59f); - Vector2 value22 = Utils.Vector2FromElipse(Main.npc[(int)projectile.ai[1]].localAI[0].ToRotationVector2(), value21 * Main.npc[(int)projectile.ai[1]].localAI[1]); - projectile.position = Main.npc[(int)projectile.ai[1]].Center + value22 - new Vector2(projectile.width, projectile.height) / 2f; - } + if (Main.npc[(int)projectile.ai[1]].active) + { + Vector2 value21 = new Vector2(27f, 59f); + Vector2 value22 = Utils.Vector2FromElipse(Main.npc[(int)projectile.ai[1]].localAI[0].ToRotationVector2(), value21 * Main.npc[(int)projectile.ai[1]].localAI[1]); + projectile.position = Main.npc[(int)projectile.ai[1]].Center + value22 - new Vector2(projectile.width, projectile.height) / 2f; + } - 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 (projectile.localAI[0] == 0f) - Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 104, 1f, 0f); + if (projectile.localAI[0] == 0f) + Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 104, 1f, 0f); - float num801 = 1f; - projectile.localAI[0] += 1f; - if (projectile.localAI[0] >= 180f) - { - projectile.Kill(); - return false; - } + float num801 = 1f; + projectile.localAI[0] += 1f; + if (projectile.localAI[0] >= 180f) + { + projectile.Kill(); + return false; + } - projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / 180f) * 10f * num801; - if (projectile.scale > num801) - projectile.scale = num801; + projectile.scale = (float)Math.Sin(projectile.localAI[0] * MathHelper.Pi / 180f) * 10f * num801; + if (projectile.scale > num801) + projectile.scale = num801; - float num804 = projectile.velocity.ToRotation(); - num804 += projectile.ai[0]; - projectile.rotation = num804 - MathHelper.PiOver2; - projectile.velocity = num804.ToRotationVector2(); + float num804 = projectile.velocity.ToRotation(); + num804 += projectile.ai[0]; + projectile.rotation = num804 - MathHelper.PiOver2; + projectile.velocity = num804.ToRotationVector2(); - float num805 = 3f; - float num806 = projectile.width; + float num805 = 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; - int num3; - for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1) - { - num807 += array3[num808]; - num3 = num808; - } - num807 /= num805; + float[] array3 = new float[(int)num805]; + Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); + float num807 = 0f; + int num3; + for (int num808 = 0; num808 < array3.Length; num808 = num3 + 1) + { + num807 += array3[num808]; + num3 = 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) && - Main.npc[(int)projectile.ai[1]].Calamity().newAI[0] == 1f) - { - 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) && + Main.npc[(int)projectile.ai[1]].Calamity().newAI[0] == 1f) + { + num807 = 2400f; + } - float amount = 0.5f; - projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); + float amount = 0.5f; + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], num807, amount); - Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); - for (int num809 = 0; num809 < 2; num809 = num3 + 1) - { - float num810 = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; - float num811 = (float)Main.rand.NextDouble() * 2f + 2f; - Vector2 vector80 = new Vector2((float)Math.Cos(num810) * num811, (float)Math.Sin(num810) * num811); - int num812 = Dust.NewDust(vector79, 0, 0, 229, vector80.X, vector80.Y, 0, default, 1f); - Main.dust[num812].noGravity = true; - Main.dust[num812].scale = 1.7f; - num3 = num809; - } + Vector2 vector79 = projectile.Center + projectile.velocity * (projectile.localAI[1] - 14f); + for (int num809 = 0; num809 < 2; num809 = num3 + 1) + { + float num810 = projectile.velocity.ToRotation() + ((Main.rand.Next(2) == 1) ? -1f : 1f) * MathHelper.PiOver2; + float num811 = (float)Main.rand.NextDouble() * 2f + 2f; + Vector2 vector80 = new Vector2((float)Math.Cos(num810) * num811, (float)Math.Sin(num810) * num811); + int num812 = Dust.NewDust(vector79, 0, 0, 229, vector80.X, vector80.Y, 0, default, 1f); + Main.dust[num812].noGravity = true; + Main.dust[num812].scale = 1.7f; + num3 = num809; + } - if (Main.rand.Next(5) == 0) - { - Vector2 value29 = projectile.velocity.RotatedBy(MathHelper.PiOver2) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; - int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 31, 0f, 0f, 100, default, 1.5f); - Dust dust = Main.dust[num813]; - dust.velocity *= 0.5f; - Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); - } + if (Main.rand.Next(5) == 0) + { + Vector2 value29 = projectile.velocity.RotatedBy(MathHelper.PiOver2) * ((float)Main.rand.NextDouble() - 0.5f) * projectile.width; + int num813 = Dust.NewDust(vector79 + value29 - Vector2.One * 4f, 8, 8, 31, 0f, 0f, 100, default, 1.5f); + Dust dust = Main.dust[num813]; + dust.velocity *= 0.5f; + Main.dust[num813].velocity.Y = -Math.Abs(Main.dust[num813].velocity.Y); + } - DelegateMethods.v3_1 = new Vector3(0.3f, 0.65f, 0.7f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); + 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; + } + } } if (CalamityWorld.death && !CalamityPlayer.areThereAnyDamnBosses) @@ -1186,8 +1515,8 @@ namespace CalamityMod.Projectiles { if (projectile.hostile) { - if (CalamityPlayer.areThereAnyDamnBosses && affectedByMaliceModeVelocityMultiplier) - projectile.velocity *= MaliceModeProjectileVelocityMultiplier; + if (CalamityPlayer.areThereAnyDamnBosses && affectedByMaliceModeVelocityMultiplier && (CalamityWorld.malice || BossRushEvent.BossRushActive)) + projectile.velocity *= BossRushEvent.BossRushActive ? BossRushProjectileVelocityMultiplier : MaliceModeProjectileVelocityMultiplier; // Reduce Nail damage from Nailheads because they're stupid if (projectile.type == ProjectileID.Nail && Main.expertMode) @@ -1451,9 +1780,9 @@ namespace CalamityMod.Projectiles { if (Main.player[projectile.owner].miscCounter % 30 == 0 && projectile.FinalExtraUpdate()) { - if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileType()] < 5) + if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileType()] < 5) { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), (int)(60 * player.RogueDamage()), 0f, projectile.owner); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), (int)(60 * player.RogueDamage()), 0f, projectile.owner); } } } @@ -1700,6 +2029,9 @@ namespace CalamityMod.Projectiles Player player = Main.player[projectile.owner]; CalamityPlayer modPlayer = player.Calamity(); + if (modPlayer.rottenDogTooth && projectile.Calamity().stealthStrike) + target.AddBuff(BuffType(), RottenDogtooth.ArmorCrunchDebuffTime); + // Super dummies have nearly 10 million max HP (which is used in damage calculations). // This can very easily cause damage numbers that are unrealistic for the weapon. // As a result, they are omitted in this code. diff --git a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs index 0c031c9b1f..27c59a60ee 100644 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs +++ b/Projectiles/DraedonsArsenal/FrequencyManipulatorEnergy.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.height = 8; projectile.friendly = true; projectile.Calamity().rogue = 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 046bedd275..270b2eda5d 100644 --- a/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs +++ b/Projectiles/DraedonsArsenal/FrequencyManipulatorProjectile.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.width = 34; projectile.height = 34; projectile.friendly = true; + projectile.ignoreWater = true; projectile.timeLeft = 180; projectile.penetrate = 4; projectile.extraUpdates = 1; diff --git a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs index b1be1d8490..165fcecad2 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs @@ -4,8 +4,11 @@ using CalamityMod.Items.Weapons.DraedonsArsenal; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -57,7 +60,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { DisplayName.SetDefault("Phaseslayer"); ProjectileID.Sets.TrailingMode[projectile.type] = 2; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 13; } public override void SetDefaults() @@ -167,7 +170,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal // 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.heldProj = projectile.whoAmI; player.itemTime = 2; player.itemAnimation = 2; player.itemRotation = projectile.rotation * projectile.direction; @@ -271,6 +273,28 @@ namespace CalamityMod.Projectiles.DraedonsArsenal } } + 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(rotationAdjusted - oldRotationAdjusted); + + if (deltaAngle < 0.04f) + opacity = 0f; + + 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); + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D bladeTexture = ModContent.GetTexture("CalamityMod/Projectiles/DraedonsArsenal/PhaseslayerBlade"); @@ -280,19 +304,35 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Vector2 bladeOffset = projectile.rotation.ToRotationVector2() * (IsSmall ? 90f : 132f) * projectile.scale; 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); - // TODO: Update this afterimage drawcode to be more cool. - for (int i = 1; i < projectile.oldRot.Length; i++) - { - float angleDelta = MathHelper.Clamp(projectile.rotation - projectile.oldRot[i], -0.26f, 0.26f); - float angle = projectile.rotation + angleDelta; - angle += MathHelper.PiOver2; - Color color = Color.White * (float)Math.Pow(1f - i / (float)projectile.oldRot.Length, 3f); - Rectangle afterimageFrame = IsSmall ? bladeTexture.Frame(1, 3, 0, 2) : bladeTexture.Frame(3, 7, 2, 6); - spriteBatch.Draw(bladeTexture, projectile.Center + bladeOffset - Main.screenPosition, afterimageFrame, color, angle, origin, projectile.scale, SpriteEffects.None, 0f); - } + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]); + GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/SwordSlashTexture")); + + Player player = Main.player[projectile.owner]; + List positions = new List(); + + float swingAngularDirection = Math.Sign(projectile.rotation - projectile.oldRot[1]); + projectile.oldRot[0] += swingAngularDirection * 0.1f; + for (int i = 0; i < projectile.oldPos.Length; i++) + { + if (projectile.oldPos[i] == Vector2.Zero) + continue; + + // Skip over any very points going in the wrong direction, to prevent "nets" from the primitive. + if (i > 1 && Math.Sign(projectile.oldRot[i - 1] - projectile.oldRot[i]) != swingAngularDirection) + continue; + + Vector2 position = projectile.position + projectile.oldRot[i].ToRotationVector2() * (IsSmall ? 90f : 132f) * projectile.scale; + + positions.Add(position); + } + projectile.oldRot[0] -= swingAngularDirection * 0.1f; + + TrailDrawer.Draw(positions, projectile.Size * 0.5f - 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); diff --git a/Projectiles/DraedonsArsenal/SystemBaneLightning.cs b/Projectiles/DraedonsArsenal/SystemBaneLightning.cs index a6afcc6299..20bdea949d 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneLightning.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneLightning.cs @@ -35,7 +35,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.height = 22; projectile.friendly = true; projectile.Calamity().rogue = 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 bdac20c2e8..5379190720 100644 --- a/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs +++ b/Projectiles/DraedonsArsenal/SystemBaneProjectile.cs @@ -30,7 +30,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.width = 36; projectile.height = 36; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 16; projectile.tileCollide = true; diff --git a/Projectiles/Environment/LightningMark.cs b/Projectiles/Environment/LightningMark.cs index a4b81b6491..26aa22600a 100644 --- a/Projectiles/Environment/LightningMark.cs +++ b/Projectiles/Environment/LightningMark.cs @@ -98,9 +98,6 @@ namespace CalamityMod.Projectiles.Environment return true; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; } } diff --git a/Projectiles/Magic/Ancient.cs b/Projectiles/Magic/Ancient.cs index bba51b5e13..04e1483107 100644 --- a/Projectiles/Magic/Ancient.cs +++ b/Projectiles/Magic/Ancient.cs @@ -1,112 +1,127 @@ +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; +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 = 32; - projectile.height = 32; - 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) + 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) { - int numProj = 2; - int randomSpread = Main.rand.Next(3, 19); - float rotation = MathHelper.ToRadians(randomSpread); - if (projectile.owner == Main.myPlayer) - { - for (int i = 0; i < numProj + 1; i++) - { - Vector2 perturbedSpeed = new Vector2(projectile.velocity.X, projectile.velocity.Y).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack * 0.5f, projectile.owner, 0f, 0f); - } - } + projectile.frame++; + projectile.frameCounter = 0; } - if (projectile.timeLeft > 151) + if (projectile.frame >= Main.projFrames[projectile.type]) { - projectile.timeLeft = 151; + projectile.frame = 0; } - if (projectile.ai[0] > 4f) - { - float num296 = 1f; - if (projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - projectile.ai[0] += 1f; - int num297 = 32; - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(2)) - { - dust.noGravity = true; - dust.scale *= 2f; - dust.velocity.X *= 6f; - dust.velocity.Y *= 6f; - } - else - { - dust.scale *= 1.5f; - } - dust.velocity.X *= 3f; - dust.velocity.Y *= 3f; - dust.scale *= num296; - } - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 4f; - dust.velocity.X *= 4f; - dust.velocity.Y *= 4f; - } - else - { - dust.scale *= 2.5f; - } - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - dust.scale *= num296; - } - } - else - { - 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) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + + // 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; + } + } } diff --git a/Projectiles/Magic/Ancient.png b/Projectiles/Magic/Ancient.png index 2f776c6c06..687740685f 100644 Binary files a/Projectiles/Magic/Ancient.png and b/Projectiles/Magic/Ancient.png differ diff --git a/Projectiles/Magic/Ancient2.cs b/Projectiles/Magic/Ancient2.cs index 47bef2fa70..1da2c20e4c 100644 --- a/Projectiles/Magic/Ancient2.cs +++ b/Projectiles/Magic/Ancient2.cs @@ -1,93 +1,122 @@ +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class Ancient2 : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ancient"); - } + public class Ancient2 : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Magic/Ancient"; - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.magic = true; - projectile.penetrate = 4; - projectile.extraUpdates = 12; - projectile.timeLeft = 30; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 6; - } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ancient"); + Main.projFrames[projectile.type] = 6; + } - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.3f, 0.25f, 0f); - if (projectile.timeLeft > 30) + 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); + projectile.frameCounter++; + if (projectile.frameCounter > 3) { - projectile.timeLeft = 30; + projectile.frame++; + projectile.frameCounter = 0; } - if (projectile.ai[0] > 7f) + if (projectile.frame >= Main.projFrames[projectile.type]) { - float num296 = 1f; - if (projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - projectile.ai[0] += 1f; - int num297 = 32; - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(2)) - { - dust.noGravity = true; - dust.scale *= 1.5f; - dust.velocity.X *= 3f; - dust.velocity.Y *= 3f; - } - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - dust.scale *= num296; - } - for (int num298 = 0; num298 < 2; num298++) - { - int num299 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, num297, projectile.velocity.X * 0.2f, projectile.velocity.Y * 0.2f, 100, default, 1f); - Dust dust = Main.dust[num299]; - if (Main.rand.NextBool(3)) - { - dust.noGravity = true; - dust.scale *= 3f; - dust.velocity.X *= 2f; - dust.velocity.Y *= 2f; - } - else - { - dust.scale *= 2f; - } - dust.velocity.X *= 1.2f; - dust.velocity.Y *= 1.2f; - dust.scale *= num296; - } + projectile.frame = 0; } - else - { - projectile.ai[0] += 1f; - } - projectile.rotation += 0.3f * (float)projectile.direction; - } - } + 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; + } + + 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); + + // 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; + } + } } diff --git a/Projectiles/Magic/ApothChloro.cs b/Projectiles/Magic/ApothChloro.cs deleted file mode 100644 index 7a7a88882a..0000000000 --- a/Projectiles/Magic/ApothChloro.cs +++ /dev/null @@ -1,122 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class ApothChloro : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Rays of Annihilation"); - } - - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.alpha = 70; - projectile.timeLeft = 120; - projectile.penetrate = 1; - projectile.hostile = false; - projectile.friendly = true; - projectile.magic = true; - projectile.light = 0.5f; - projectile.extraUpdates = 1; - } - - public override void AI() - { - Lighting.AddLight(projectile.Center, 0.4f, 0.2f, 0.4f); - for (int i = 0; i < 5; i++) - { - Dust dust4 = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, 242, projectile.velocity.X, projectile.velocity.Y, 100, default, 1f)]; - dust4.velocity = Vector2.Zero; - dust4.position -= projectile.velocity / 5f * (float)i; - dust4.noGravity = true; - dust4.scale = 0.8f; - dust4.noLight = true; - } - float num1 = (float)(projectile.position.X - projectile.velocity.X / 10.0 * 9.0); - float num2 = (float)(projectile.position.Y - projectile.velocity.Y / 10.0 * 9.0); - float num3 = (float)Math.Sqrt((double)(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y)); - float num4 = projectile.localAI[0]; - if (num4 == 0f) - { - projectile.localAI[0] = num3; - num4 = num3; - } - if (projectile.alpha > 0) - projectile.alpha = projectile.alpha - 25; - if (projectile.alpha < 0) - projectile.alpha = 0; - float num5 = (float)projectile.position.X; - float num6 = (float)projectile.position.Y; - float num7 = 300f; - bool flag2 = false; - int num8 = 0; - float num9; - if (projectile.ai[1] == 0f) - { - for (int index = 0; index < Main.maxNPCs; ++index) - { - if (Main.npc[index].CanBeChasedBy((object)this, false) && ((double)projectile.ai[1] == 0.0 || (double)projectile.ai[1] == (double)(index + 1))) - { - num1 = (float)Main.npc[index].position.X + (float)(Main.npc[index].width / 2); - num2 = (float)Main.npc[index].position.Y + (float)(Main.npc[index].height / 2); - num9 = Math.Abs((float)projectile.position.X + (float)(projectile.width / 2) - num1) + Math.Abs((float)projectile.position.Y + (float)(projectile.height / 2) - num2); - if ((double)num9 < (double)num7 && Collision.CanHit(new Vector2((float)projectile.position.X + (float)(projectile.width / 2), (float)projectile.position.Y + (float)(projectile.height / 2)), 1, 1, Main.npc[index].position, Main.npc[index].width, Main.npc[index].height)) - { - num7 = num9; - num5 = num1; - num6 = num2; - flag2 = true; - num8 = index; - } - } - } - if (flag2) - projectile.ai[1] = (float)(num8 + 1); - flag2 = false; - } - if (projectile.ai[1] > 0f) - { - int index = (int)((double)projectile.ai[1] - 1.0); - if (Main.npc[index].active && Main.npc[index].CanBeChasedBy((object)this, true) && !Main.npc[index].dontTakeDamage) - { - if ((double)Math.Abs((float)projectile.position.X + (float)(projectile.width / 2) - ((float)Main.npc[index].position.X + (float)(Main.npc[index].width / 2))) + (double)Math.Abs((float)projectile.position.Y + (float)(projectile.height / 2) - ((float)Main.npc[index].position.Y + (float)(Main.npc[index].height / 2))) < 3000.0) - { - flag2 = true; - num5 = (float)Main.npc[index].position.X + (float)(Main.npc[index].width / 2); - num6 = (float)Main.npc[index].position.Y + (float)(Main.npc[index].height / 2); - } - } - else - projectile.ai[1] = 0.0f; - } - if (!projectile.friendly) - flag2 = false; - if (flag2) - { - double num15 = (double)num4; - Vector2 vector2 = new Vector2((float)(projectile.position.X + (double)projectile.width * 0.5), (float)(projectile.position.Y + (double)projectile.height * 0.5)); - num2 = num5 - (float)vector2.X; - num9 = num6 - (float)vector2.Y; - double num10 = Math.Sqrt((double)num2 * (double)num2 + (double)num9 * (double)num9); - float num11 = (float)(num15 / num10); - float num12 = num2 * num11; - float num13 = num9 * num11; - int num14 = 8; - projectile.velocity.X = (float)((projectile.velocity.X * (double)(num14 - 1) + (double)num12) / (double)num14); - projectile.velocity.Y = (float)((projectile.velocity.Y * (double)(num14 - 1) + (double)num13) / (double)num14); - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600, true); - target.AddBuff(ModContent.BuffType(), 600, true); - } - } -} diff --git a/Projectiles/Magic/ApothChloro.png b/Projectiles/Magic/ApothChloro.png deleted file mode 100644 index a17ddc8d5d..0000000000 Binary files a/Projectiles/Magic/ApothChloro.png and /dev/null differ diff --git a/Projectiles/Magic/ApothJaws.cs b/Projectiles/Magic/ApothJaws.cs deleted file mode 100644 index 7d7709240a..0000000000 --- a/Projectiles/Magic/ApothJaws.cs +++ /dev/null @@ -1,79 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using System; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class ApothJaws : ModProjectile - { - private const float degrees = (float)(Math.PI / 180) * 2; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Jaws of Annihilation"); - } - - public override void SetDefaults() - { - projectile.width = 144; - projectile.height = 72; - projectile.alpha = 70; - projectile.timeLeft = 240; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.friendly = true; - projectile.magic = true; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.light = 1.5f; - } - - public override void AI() - { - if (projectile.timeLeft % 8 == 0) - { - double angle = (double)Main.rand.Next(360) * Math.PI / 180; - float offsetX = projectile.position.X + (float)Main.rand.Next((int)projectile.width); - float offsetY = projectile.position.Y + (float)Main.rand.Next((int)projectile.height); - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(offsetX, offsetY, 14 * (float)Math.Cos(angle), 14 * (float)Math.Sin(angle), ModContent.ProjectileType(), projectile.damage, projectile.knockBack / 2, projectile.owner); - } - } - if (projectile.timeLeft < 30) - projectile.alpha = projectile.alpha + 6; - else if (projectile.timeLeft < 210) - { - projectile.velocity.X *= 0.9f; - projectile.velocity.Y *= 0.9f; - } - else if (projectile.timeLeft < 240) - { - if (projectile.ai[1] == 0) - projectile.rotation += 1.3f * degrees; - else - projectile.rotation -= 1.3f * degrees; - } - else if (projectile.timeLeft == 240) - { - if (projectile.ai[1] == 0) - projectile.rotation = projectile.ai[0] - 30 * degrees; - else - { - projectile.rotation = projectile.ai[0] + 30 * degrees + (float)Math.PI; - projectile.spriteDirection = -1; - } - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600, true); - target.AddBuff(ModContent.BuffType(), 600, true); - target.AddBuff(ModContent.BuffType(), 600, true); - target.AddBuff(ModContent.BuffType(), 60, true); - } - } -} diff --git a/Projectiles/Magic/ApothJaws.png b/Projectiles/Magic/ApothJaws.png deleted file mode 100644 index 84d2046947..0000000000 Binary files a/Projectiles/Magic/ApothJaws.png and /dev/null differ diff --git a/Projectiles/Magic/ApothMark.cs b/Projectiles/Magic/ApothMark.cs deleted file mode 100644 index 2129fcbc1e..0000000000 --- a/Projectiles/Magic/ApothMark.cs +++ /dev/null @@ -1,70 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Buffs.StatDebuffs; -using System; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class ApothMark : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Jaws of Annihilation"); - } - - public override void SetDefaults() - { - projectile.width = 123; - projectile.height = 105; - projectile.alpha = 70; - projectile.timeLeft = 240; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.friendly = true; - projectile.magic = true; - projectile.tileCollide = false; - projectile.ignoreWater = true; - projectile.light = 1.5f; - } - - public override void AI() - { - if (projectile.timeLeft < 30) - projectile.alpha = projectile.alpha + 6; - else if (projectile.timeLeft < 210) - { - projectile.velocity.X *= 0.9f; - projectile.velocity.Y *= 0.9f; - } - else if (projectile.timeLeft == 240) - { - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X); - double offsetHyp = Math.Sqrt(48 * 48 + 38 * 38); - double offsetRotation = Math.Atan2(-38, 48) + (double)projectile.rotation; - double offsetX = offsetHyp * Math.Cos(offsetRotation); - double offsetY = offsetHyp * Math.Sin(offsetRotation); - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(projectile.Center.X + (float)offsetX, projectile.Center.Y + (float)offsetY, projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, projectile.rotation, 0f); - } - offsetRotation = Math.Atan2(38, 48) + (double)projectile.rotation; - offsetX = offsetHyp * Math.Cos(offsetRotation); - offsetY = offsetHyp * Math.Sin(offsetRotation); - - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(projectile.position.X + projectile.width / 2 + (float)offsetX, projectile.position.Y + projectile.height / 2 + (float)offsetY, projectile.velocity.X, projectile.velocity.Y, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, projectile.rotation, 1f); - } - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 600, true); - target.AddBuff(ModContent.BuffType(), 600, true); - target.AddBuff(ModContent.BuffType(), 600, true); - target.AddBuff(ModContent.BuffType(), 60, true); - } - } -} diff --git a/Projectiles/Magic/ApothMark.png b/Projectiles/Magic/ApothMark.png deleted file mode 100644 index 41f8b01b7a..0000000000 Binary files a/Projectiles/Magic/ApothMark.png and /dev/null differ diff --git a/Projectiles/Magic/ApotheosisEnergy.cs b/Projectiles/Magic/ApotheosisEnergy.cs new file mode 100644 index 0000000000..30c346c073 --- /dev/null +++ b/Projectiles/Magic/ApotheosisEnergy.cs @@ -0,0 +1,100 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Magic +{ + public class ApotheosisEnergy : ModProjectile + { + internal PrimitiveTrail TrailDrawer = null; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Apotheosis Energy"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 20; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.magic = true; + projectile.penetrate = -1; + projectile.timeLeft = 210; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 1; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.Cyan.ToVector3() * projectile.Opacity); + + // Fade-effects. + if (projectile.timeLeft < 40f) + projectile.Opacity = Utils.InverseLerp(0f, 40f, projectile.timeLeft, true); + else + projectile.alpha = Utils.Clamp(projectile.alpha - 30, 0, 255); + + NPC potentialTarget = projectile.Center.ClosestNPCAt(5900f); + if (potentialTarget != null) + { + float squaredTargetDistance = projectile.DistanceSQ(potentialTarget.Center); + if (squaredTargetDistance > 120f * 120f && squaredTargetDistance < 1000f * 1000f) + projectile.velocity = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(potentialTarget.Center), 0.1f).ToRotationVector2() * projectile.velocity.Length(); + } + } + + internal Color ColorFunction(float completionRatio) + { + Color baseColor = Color.Cyan; + if (completionRatio > 0.66f) + baseColor = Color.Lerp(baseColor, Color.Fuchsia, (completionRatio - 0.66f) / 0.33f); + else + { + float whiteFade = (float)Math.Sin(Utils.InverseLerp(0.1f, 0.56f, completionRatio, true) * MathHelper.Pi + Main.GlobalTime * 10f) * 0.85f; + baseColor = Color.Lerp(baseColor, Color.White, whiteFade); + } + + Color colorToUse = baseColor; + if (completionRatio > 0.5f) + colorToUse = Color.Lerp(baseColor, Color.Transparent, 1f - completionRatio / 0.5f); + return colorToUse * projectile.Opacity; + } + + internal float WidthFunction(float completionRatio) + { + float width; + float maxWidthOutwardness = 6f; + if (completionRatio < 0.2f) + width = (float)Math.Sin(completionRatio / 0.2f * MathHelper.PiOver2) * maxWidthOutwardness + 0.1f; + else + width = MathHelper.Lerp(maxWidthOutwardness, 0f, Utils.InverseLerp(0.2f, 1f, completionRatio, true)); + return width * projectile.Opacity; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + for (int i = 0; i < projectile.oldPos.Length; i++) + { + if (Collision.CheckAABBvAABBCollision(projectile.oldPos[i], projHitbox.Size(), targetHitbox.TopLeft(), projHitbox.Size())) + return true; + } + return false; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction); + + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 85); + return false; + } + } +} diff --git a/Projectiles/Magic/Ancient2.png b/Projectiles/Magic/ApotheosisEnergy.png similarity index 100% rename from Projectiles/Magic/Ancient2.png rename to Projectiles/Magic/ApotheosisEnergy.png diff --git a/Projectiles/Magic/ApotheosisJaw.png b/Projectiles/Magic/ApotheosisJaw.png new file mode 100644 index 0000000000..ccf7b18279 Binary files /dev/null and b/Projectiles/Magic/ApotheosisJaw.png differ diff --git a/Projectiles/Magic/ApotheosisWorm.cs b/Projectiles/Magic/ApotheosisWorm.cs new file mode 100644 index 0000000000..77e904b95b --- /dev/null +++ b/Projectiles/Magic/ApotheosisWorm.cs @@ -0,0 +1,363 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class ApotheosisWorm : ModProjectile + { + internal class Segment + { + // Doing a typical byte seems to cause the thing to flicker when doing super fast fades. + // This is most likely due to under/overflows. + internal short Alpha; + internal float Rotation; + internal Vector2 Center; + internal void WriteTo(BinaryWriter writer) + { + writer.Write(Alpha); + writer.Write(Rotation); + writer.WritePackedVector2(Center); + } + + internal void ReadFrom(BinaryReader reader) + { + Alpha = reader.ReadInt16(); + Rotation = reader.ReadSingle(); + Center = reader.ReadPackedVector2(); + } + + internal Segment(byte alpha, float rotation, Vector2 center) + { + Alpha = alpha; + Rotation = rotation; + Center = center; + } + } + + internal Vector2 PortalPosition; + internal Segment[] Segments = new Segment[80]; + + internal Player Owner => Main.player[projectile.owner]; + internal ref float Time => ref projectile.ai[0]; + internal ref float FlyAcceleration => ref projectile.ai[1]; + internal ref float JawRotation => ref projectile.localAI[1]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("The Devourer of Gods"); + } + + public override void SetDefaults() + { + projectile.width = 108; + projectile.height = 108; + projectile.alpha = 255; + projectile.timeLeft = 300; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 9; + projectile.friendly = true; + projectile.magic = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.netImportant = true; + projectile.light = 1.5f; + } + + // Be VERY careful with the projectile's netcode, and use syncs very sparingly. + // Syncing will use a lot more bytes than usual. + + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < Segments.Length; i++) + { + Segments[i].WriteTo(writer); + } + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < Segments.Length; i++) + { + Segments[i].ReadFrom(reader); + } + } + + public override void AI() + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // Initialization. + if (projectile.localAI[0] == 0f) + { + PortalPosition = projectile.Center + projectile.velocity * 7f; + if (Main.myPlayer == projectile.owner) + InitializeSegments(); + projectile.localAI[0] = 1f; + } + + // Head fade-in effects. + if (projectile.timeLeft <= 75) + projectile.alpha = Utils.Clamp(projectile.alpha + 40, 0, 255); + else if (Time > 15f) + projectile.alpha = Utils.Clamp(projectile.alpha - 40, 0, 255); + + // Update all segments of the devourer every frame. + for (int i = 0; i < Segments.Length; i++) + UpdateSegment(i); + + Time++; + + // Reset the jaw's rotation slowly over time. + JawRotation = MathHelper.Lerp(JawRotation, 0f, 0.08f); + + NPC potentialTarget = projectile.Center.ClosestNPCAt(4200f); + if (potentialTarget != null) + AttackTarget(potentialTarget); + } + + internal void InitializeSegments() + { + Vector2 directionToMouse = (Main.MouseWorld - projectile.Center).SafeNormalize(Vector2.UnitX * Owner.direction); + projectile.rotation = directionToMouse.ToRotation() + MathHelper.PiOver2; + for (int i = 0; i < Segments.Length; i++) + { + Segments[i] = new Segment(255, projectile.rotation, projectile.Center + directionToMouse / Segments.Length * i * 900f); + } + projectile.netUpdate = true; + } + + internal void UpdateSegment(int segmentIndex) + { + float aheadSegmentRotation = segmentIndex > 0 ? Segments[segmentIndex - 1].Rotation : projectile.rotation; + Vector2 aheadSegmentCenter = segmentIndex > 0 ? Segments[segmentIndex - 1].Center : projectile.Center; + Vector2 offsetToAheadSegment = aheadSegmentCenter - Segments[segmentIndex].Center; + + // Individual segment fade effects depending on time. + if (projectile.timeLeft <= 60) + { + int invisibleSegmentIndex = (int)MathHelper.Lerp(0f, Segments.Length, 1f - MathHelper.Clamp(projectile.timeLeft / 60f * 1.4f, 0f, 1f)); + if (segmentIndex < invisibleSegmentIndex) + { + Segments[segmentIndex].Alpha += 31; + if (Segments[segmentIndex].Alpha > 255) + Segments[segmentIndex].Alpha = 255; + } + } + + if (Time <= 90f) + { + int visibleSegmentIndex = (int)MathHelper.Lerp(0f, Segments.Length, Utils.InverseLerp(15f, 70f, Time, true)); + if (segmentIndex < visibleSegmentIndex) + { + Segments[segmentIndex].Alpha -= 17; + if (Segments[segmentIndex].Alpha < 0) + Segments[segmentIndex].Alpha = 0; + } + } + + // This variant of segment attachment incorporates rotation. + // Given the fact that all segments will execute this code is succession, the + // result across the entire worm will exponentially decay over each segment, + // allowing for smooth rotations. This code is what the stardust dragon and mechworm use for their segmenting. + if (aheadSegmentRotation != Segments[segmentIndex].Rotation) + { + float offsetAngle = MathHelper.WrapAngle(aheadSegmentRotation - Segments[segmentIndex].Rotation); + offsetToAheadSegment = offsetToAheadSegment.RotatedBy(offsetAngle * 0.075f); + } + Segments[segmentIndex].Rotation = offsetToAheadSegment.ToRotation() + MathHelper.PiOver2; + if (offsetToAheadSegment != Vector2.Zero) + Segments[segmentIndex].Center = aheadSegmentCenter - offsetToAheadSegment.SafeNormalize(Vector2.Zero) * 70f; + } + + internal void AttackTarget(NPC target) + { + if (Time >= 40f && projectile.alpha == 0 && Main.rand.NextBool(8)) + { + if (Main.myPlayer == projectile.owner) + { + Segment segmentToShootFrom = Segments[Main.rand.Next(Segments.Length)]; + Vector2 shootVelocity = (target.Center - segmentToShootFrom.Center).SafeNormalize(Vector2.UnitY).RotatedByRandom(0.25f) * 18f; + Projectile.NewProjectile(segmentToShootFrom.Center, shootVelocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + } + + if (Main.rand.NextBool(10)) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeMechGaussRifle"), projectile.Center); + } + + float idealFlyAcceleration = 0.18f; + + Vector2 destination = target.Center; + float distanceFromDestination = projectile.Distance(destination); + + // Get a swerve effect if somewhat far from the target. + if (projectile.Distance(destination) > 725f) + { + destination += (Time % 30f / 30f * MathHelper.TwoPi).ToRotationVector2() * 145f; + distanceFromDestination = projectile.Distance(destination); + idealFlyAcceleration *= 2.5f; + } + + // Charge if the target is far away. + if (distanceFromDestination > 1500f && Time > 45f) + idealFlyAcceleration = MathHelper.Min(6f, FlyAcceleration + 1f); + + FlyAcceleration = MathHelper.Lerp(FlyAcceleration, idealFlyAcceleration, 0.3f); + + float directionToTargetOrthogonality = Vector2.Dot(projectile.velocity.SafeNormalize(Vector2.Zero), projectile.SafeDirectionTo(destination)); + + // Fly towards the target if it's far. + if (distanceFromDestination > 320f) + { + float speed = projectile.velocity.Length(); + if (speed < 23f) + speed += 0.08f; + + if (speed > 32f) + speed -= 0.08f; + + // Go faster if the line of sight is aiming closely at the target. + if (directionToTargetOrthogonality < 0.85f && directionToTargetOrthogonality > 0.5f) + speed += 6f; + + // And go slower otherwise so that the devourer can angle towards the target more accurately. + if (directionToTargetOrthogonality < 0.5f && directionToTargetOrthogonality > -0.7f) + speed -= 10f; + + speed = MathHelper.Clamp(speed, 16f, 34f); + + projectile.velocity = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(destination), FlyAcceleration).ToRotationVector2() * speed; + } + + // Open jaws when near the target, and snap when really close. + if (distanceFromDestination < 200f) + JawRotation = MathHelper.Lerp(JawRotation, MathHelper.ToRadians(-34f), 0.4f); + else if (distanceFromDestination < 480f) + JawRotation = MathHelper.Lerp(JawRotation, MathHelper.ToRadians(15f), 0.24f); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 600, true); + target.AddBuff(ModContent.BuffType(), 600, true); + target.AddBuff(ModContent.BuffType(), 600, true); + if (Main.rand.NextBool(30)) + { + target.AddBuff(ModContent.BuffType(), 120, true); + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D headTexture = Main.projectileTexture[projectile.type]; + Vector2 drawPosition = projectile.Center - Main.screenPosition; + Vector2 headTextureOrigin = Main.projectileTexture[projectile.type].Size() * 0.5f; + drawPosition -= headTexture.Size() * projectile.scale * 0.5f; + drawPosition += headTextureOrigin * projectile.scale + new Vector2(0f, 4f + projectile.gfxOffY); + + Texture2D jawTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/ApotheosisJaw"); + Vector2 jawOrigin = jawTexture.Size() * 0.5f; + + // Segment drawing. + Texture2D bodyTexture = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsBodyS"); + Texture2D tailTexture = ModContent.GetTexture("CalamityMod/NPCs/DevourerofGods/DevourerofGodsTailS"); + + // Not white to differentiate itself slightly from regular DoG when fighting Boss Rush. + Color baseColor = Color.Lerp(Color.White, Color.Fuchsia, 0.15f); + + for (int i = 0; i < Segments.Length; i++) + { + bool isTail = i == Segments.Length - 1; + Texture2D segmentTexture = isTail ? tailTexture : bodyTexture; + Vector2 segmentOrigin = segmentTexture.Size() * 0.5f; + spriteBatch.Draw(segmentTexture, Segments[i].Center - Main.screenPosition, null, baseColor * ((255 - Segments[i].Alpha) / 255f), Segments[i].Rotation, segmentOrigin, projectile.scale, SpriteEffects.None, 0f); + } + + // Jaw drawing. + for (int i = -1; i <= 1; i += 2) + { + float jawBaseOffset = 42f; + SpriteEffects jawSpriteEffect = SpriteEffects.None; + if (i == 1) + jawSpriteEffect |= SpriteEffects.FlipHorizontally; + + // X/Y offsets for the jaws depending on the angle of the jaw. + // Has potential to act weird at unexpected angles, but that should never happen naturally. + Vector2 jawPosition = drawPosition; + jawPosition += Vector2.UnitX.RotatedBy(projectile.rotation + JawRotation * i) * i * (jawBaseOffset + (float)Math.Sin(JawRotation) * 24f); + jawPosition -= Vector2.UnitY.RotatedBy(projectile.rotation) * (38f + (float)Math.Sin(JawRotation) * 30f); + + spriteBatch.Draw(jawTexture, jawPosition, null, baseColor * projectile.Opacity, projectile.rotation + JawRotation * i, jawOrigin, projectile.scale, jawSpriteEffect, 0f); + } + + // Portal drawing at the start of the devourer's lifetime. + // This is extremely similar to the portal created when DoG teleports. + if (Time < 60f) + { + float currentFade = Utils.InverseLerp(0f, 8f, Time, true) * Utils.InverseLerp(60f, 52f, Time, true); + currentFade *= (1f + 0.2f * (float)Math.Cos(Main.GlobalTime % 30f * MathHelper.Pi * 3f)) * 0.8f; + + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/StarProj"); + Vector2 drawPos = PortalPosition - Main.screenPosition; + 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(8f, 19f) * projectile.Opacity * currentFade; + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2, origin, scale, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, 0f, origin, scale, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2, origin, scale * 0.8f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, 0f, origin, scale * 0.8f, SpriteEffects.None, 0); + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver2 + Main.GlobalTime * 3f * 0.25f, origin, scale, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, Main.GlobalTime * 3f * 0.25f, origin, scale, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver2 + Main.GlobalTime * 3f * 0.5f, origin, scale * 0.8f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, Main.GlobalTime * 3f * 0.5f, origin, scale * 0.8f, SpriteEffects.None, 0); + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4, origin, scale * 0.6f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f, origin, scale * 0.6f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4, origin, scale * 0.4f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f, origin, scale * 0.4f, SpriteEffects.None, 0); + + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 + Main.GlobalTime * 3f * 0.75f, origin, scale * 0.6f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorA, MathHelper.PiOver4 * 3f + Main.GlobalTime * 3f * 0.75f, origin, scale * 0.6f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 + Main.GlobalTime * 3f, origin, scale * 0.4f, SpriteEffects.None, 0); + spriteBatch.Draw(texture, drawPos, null, colorB, MathHelper.PiOver4 * 3f + Main.GlobalTime * 3f, origin, scale * 0.4f, SpriteEffects.None, 0); + + } + + // Head drawing. + spriteBatch.Draw(headTexture, drawPosition, null, baseColor * projectile.Opacity, projectile.rotation, headTextureOrigin, projectile.scale, spriteEffects, 0f); + return false; + } + + // Manual collision detection that incorporates segments. + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (Collision.CheckAABBvAABBCollision(projectile.position, projHitbox.Size(), targetHitbox.TopLeft(), projHitbox.Size())) + return true; + + for (int i = 0; i < Segments.Length; i++) + { + if (Collision.CheckAABBvAABBCollision(Segments[i].Center - projHitbox.Size() * 0.5f, projHitbox.Size(), targetHitbox.TopLeft(), projHitbox.Size())) + return true; + } + return false; + } + } +} diff --git a/Projectiles/Magic/ApotheosisWorm.png b/Projectiles/Magic/ApotheosisWorm.png new file mode 100644 index 0000000000..31edfc75c7 Binary files /dev/null and b/Projectiles/Magic/ApotheosisWorm.png differ diff --git a/Projectiles/Magic/AstralStarMagic.cs b/Projectiles/Magic/AstralStarMagic.cs index 1ea18c1fd5..bf44d3c778 100644 --- a/Projectiles/Magic/AstralStarMagic.cs +++ b/Projectiles/Magic/AstralStarMagic.cs @@ -31,7 +31,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 50; projectile.penetrate = 1; projectile.tileCollide = false; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/AtlantisSpear.cs b/Projectiles/Magic/AtlantisSpear.cs index 8702e8bb35..417aab221b 100644 --- a/Projectiles/Magic/AtlantisSpear.cs +++ b/Projectiles/Magic/AtlantisSpear.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; - 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 1939696977..7db196bcd0 100644 --- a/Projectiles/Magic/AtlantisSpear2.cs +++ b/Projectiles/Magic/AtlantisSpear2.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Magic projectile.alpha = 255; projectile.penetrate = -1; projectile.tileCollide = false; - 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 23c24fa709..74852ff6a9 100644 --- a/Projectiles/Magic/AuroraAustralis.cs +++ b/Projectiles/Magic/AuroraAustralis.cs @@ -30,6 +30,7 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; + projectile.ignoreWater = true; projectile.timeLeft = 300; projectile.magic = true; projectile.alpha = 255; diff --git a/Projectiles/Magic/BeamStar.cs b/Projectiles/Magic/BeamStar.cs new file mode 100644 index 0000000000..08746a6162 --- /dev/null +++ b/Projectiles/Magic/BeamStar.cs @@ -0,0 +1,96 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class BeamStar : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + 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 = projectile.height = 12; + projectile.friendly = true; + projectile.alpha = 255; + projectile.penetrate = 1; + projectile.extraUpdates = 1; + projectile.timeLeft = 240; + projectile.tileCollide = true; + projectile.magic = true; + } + + public override void AI() + { + Time++; + + if (Time < 45f) + projectile.velocity = projectile.velocity.RotatedBy((projectile.identity % 4 - 2) / 2f * 0.016f) * 1.004f; + else + { + NPC potentialTarget = projectile.Center.ClosestNPCAt(800f, false); + if (potentialTarget != null) + { + 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 + // -pi and pi, which are where a sine's wave restarts anew. + float angularHomeDirection = Math.Sign(Math.Sin(destinationDeltaAngle)); + projectile.velocity = projectile.velocity.RotatedBy(angularHomeDirection * 0.03f); + } + } + + if (Main.rand.NextBool(4)) + { + Dust stardust = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 180, 0f, 0f, 100, default, 1f); + stardust.position = projectile.Center; + stardust.scale += Main.rand.NextFloat(0.5f); + stardust.noGravity = true; + stardust.velocity.Y -= 2f; + } + if (Main.rand.NextBool(6)) + { + Dust stardust = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 176, 0f, 0f, 100, default, 1f); + stardust.position = projectile.Center; + stardust.scale += Main.rand.NextFloat(0.3f, 1.1f); + stardust.noGravity = true; + stardust.velocity *= 0.1f; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + 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); + return false; + } + + public override void Kill(int timeLeft) + { + for (int k = 0; k < 10; k++) + { + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 176, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 180, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); + } + } + } +} diff --git a/Projectiles/Magic/BeamStar.png b/Projectiles/Magic/BeamStar.png new file mode 100644 index 0000000000..741535f961 Binary files /dev/null and b/Projectiles/Magic/BeamStar.png differ diff --git a/Projectiles/Magic/BeastScythe.cs b/Projectiles/Magic/BeastScythe.cs index 1fc04aa42d..7e41d059b2 100644 --- a/Projectiles/Magic/BeastScythe.cs +++ b/Projectiles/Magic/BeastScythe.cs @@ -148,7 +148,7 @@ namespace CalamityMod.Projectiles.Magic } else { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 300); } } diff --git a/Projectiles/Magic/BloodBolt.cs b/Projectiles/Magic/BloodBolt.cs deleted file mode 100644 index 97b930b515..0000000000 --- a/Projectiles/Magic/BloodBolt.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class BloodBolt : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Blood Bolt"); - } - - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.extraUpdates = 100; - projectile.friendly = true; - projectile.timeLeft = 30; - projectile.magic = 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, (int)CalamityDusts.Brimstone, 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/BloodOrb.cs b/Projectiles/Magic/BloodOrb.cs deleted file mode 100644 index dcc16c885e..0000000000 --- a/Projectiles/Magic/BloodOrb.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class BloodOrb : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Blood Orb"); - } - - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.timeLeft = 30; - projectile.magic = true; - } - - public override void AI() - { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); - } - } -} diff --git a/Projectiles/Magic/BloodRay.cs b/Projectiles/Magic/BloodRay.cs index bacadc2ad9..e287b7f77c 100644 --- a/Projectiles/Magic/BloodRay.cs +++ b/Projectiles/Magic/BloodRay.cs @@ -1,13 +1,18 @@ using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { public class BloodRay : ModProjectile { + public const int Lifetime = 150; + public const float MaxExponentialDamageBoost = 4f; + public static readonly float ExponentialDamageBoost = (float)Math.Pow(MaxExponentialDamageBoost, 1f / Lifetime); + public ref float Time => ref projectile.ai[0]; + public ref float InitialDamage => ref projectile.ai[1]; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() { DisplayName.SetDefault("Blood Ray"); @@ -19,31 +24,36 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 100; - projectile.timeLeft = 150; + projectile.timeLeft = Lifetime; } public override void AI() { - projectile.localAI[1] += 1f; - if (projectile.localAI[1] >= 29f && projectile.owner == Main.myPlayer) - { - projectile.localAI[1] = 0f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner, 0f, 0f); - } + // Just doing damage = (int)(damage * scalar) wouldn't work here. + // 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; + } - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 9f) + Time++; + projectile.damage = (int)(InitialDamage * Math.Pow(ExponentialDamageBoost, Time)); + + if (Time >= 12f) { - for (int num447 = 0; num447 < 2; num447++) + for (int i = 0; i < 2; i++) { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1.5f); - Main.dust[num448].position = vector33; - Main.dust[num448].scale = (float)Main.rand.Next(70, 110) * 0.013f; - Main.dust[num448].velocity *= 0.1f; + int dustType = Main.rand.NextBool(4) ? 182 : (int)CalamityDusts.Brimstone; + Vector2 dustSpawnPos = projectile.position - projectile.velocity * i / 2f; + Dust crimtameMagic = Dust.NewDustPerfect(dustSpawnPos, dustType); + crimtameMagic.scale = Main.rand.NextFloat(0.96f, 1.04f) * MathHelper.Lerp(1f, 1.7f, Time / Lifetime); + crimtameMagic.noGravity = true; + crimtameMagic.velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/BlushieStaffProj.cs b/Projectiles/Magic/BlushieStaffProj.cs index 792e04d8ed..e4b2f0fadb 100644 --- a/Projectiles/Magic/BlushieStaffProj.cs +++ b/Projectiles/Magic/BlushieStaffProj.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Magic player.itemAnimation = 2; projectile.ai[0] += 1f; - projectile.damage = (int)((projectile.ai[0] - 120f) * 4.5f); + projectile.damage = (int)(projectile.ai[0] - 120f); // Max damage = 3480 if (projectile.damage >= 100 && Main.myPlayer == projectile.owner) { if (player.statMana <= 0 && player.manaFlower) diff --git a/Projectiles/Magic/Climax2.cs b/Projectiles/Magic/Climax2.cs index daa7fba67b..8832edf931 100644 --- a/Projectiles/Magic/Climax2.cs +++ b/Projectiles/Magic/Climax2.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Magic projectile.width = 38; projectile.height = 38; projectile.friendly = true; - projectile.light = 0.5f; + projectile.ignoreWater = true; + projectile.light = 0.5f; projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 420; diff --git a/Projectiles/Magic/ClimaxBeam.cs b/Projectiles/Magic/ClimaxBeam.cs index 614b2404ae..61bf9854be 100644 --- a/Projectiles/Magic/ClimaxBeam.cs +++ b/Projectiles/Magic/ClimaxBeam.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 90; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/ClimaxProj.cs b/Projectiles/Magic/ClimaxProj.cs index eba8fd68bc..58a5ab7cac 100644 --- a/Projectiles/Magic/ClimaxProj.cs +++ b/Projectiles/Magic/ClimaxProj.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.timeLeft = 150; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/CryoBlast.cs b/Projectiles/Magic/CryoBlast.cs index ef734096b4..e217cfe783 100644 --- a/Projectiles/Magic/CryoBlast.cs +++ b/Projectiles/Magic/CryoBlast.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 3; projectile.timeLeft = 90; projectile.coldDamage = true; + projectile.ignoreWater = true; projectile.alpha = 255; } @@ -121,7 +122,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 360); } } diff --git a/Projectiles/Magic/DustProjectile.cs b/Projectiles/Magic/DustProjectile.cs index 23cab8e791..17035c4fec 100644 --- a/Projectiles/Magic/DustProjectile.cs +++ b/Projectiles/Magic/DustProjectile.cs @@ -1,102 +1,97 @@ +using CalamityMod.DataStructures; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; +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 = 50; - projectile.height = 50; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.tileCollide = false; - projectile.magic = true; - projectile.penetrate = -1; - projectile.extraUpdates = 3; - projectile.timeLeft = 160; - } + 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, (255 - projectile.alpha) * 0.5f / 255f, (255 - projectile.alpha) * 0.4f / 255f, (255 - projectile.alpha) * 0.01f / 255f); - if (projectile.timeLeft > 60) + public override void AI() + { + Lighting.AddLight(projectile.Center, 0.5f, 0.4f, 0.01f); + projectile.frameCounter++; + if (projectile.frameCounter > 6) { - projectile.timeLeft = 60; + projectile.frame++; + projectile.frameCounter = 0; } - if (projectile.ai[0] > 7f) + if (projectile.frame >= Main.projFrames[projectile.type]) { - float num296 = 1f; - if (projectile.ai[0] == 8f) - { - num296 = 0.25f; - } - else if (projectile.ai[0] == 9f) - { - num296 = 0.5f; - } - else if (projectile.ai[0] == 10f) - { - num296 = 0.75f; - } - projectile.ai[0] += 1f; - int num297 = 32; - 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); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 4f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 1.5f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; - } - 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); - if (Main.rand.NextBool(3)) - { - Main.dust[num299].noGravity = true; - Main.dust[num299].scale *= 5f; - Dust expr_DBEF_cp_0 = Main.dust[num299]; - expr_DBEF_cp_0.velocity.X *= 2f; - Dust expr_DC0F_cp_0 = Main.dust[num299]; - expr_DC0F_cp_0.velocity.Y *= 2f; - } - else - { - Main.dust[num299].scale *= 2.5f; - } - Dust expr_DC74_cp_0 = Main.dust[num299]; - expr_DC74_cp_0.velocity.X *= 1.2f; - Dust expr_DC94_cp_0 = Main.dust[num299]; - expr_DC94_cp_0.velocity.Y *= 1.2f; - Main.dust[num299].scale *= num296; - } + projectile.frame = 0; } - else - { - projectile.ai[0] += 1f; - } - projectile.rotation += 0.3f * (float)projectile.direction; - } - } + 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); + } + + public override bool CanDamage() => projectile.timeLeft > 30; + + 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); + + 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/DustProjectile.png b/Projectiles/Magic/DustProjectile.png index 77e7330592..509937c4cd 100644 Binary files a/Projectiles/Magic/DustProjectile.png and b/Projectiles/Magic/DustProjectile.png differ diff --git a/Projectiles/Magic/ElementBolt.cs b/Projectiles/Magic/ElementBolt.cs index 989cb39a51..7f88a1a055 100644 --- a/Projectiles/Magic/ElementBolt.cs +++ b/Projectiles/Magic/ElementBolt.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 30; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/ElementBolt2.cs b/Projectiles/Magic/ElementBolt2.cs index b9c5666b86..85964c68ac 100644 --- a/Projectiles/Magic/ElementBolt2.cs +++ b/Projectiles/Magic/ElementBolt2.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 15; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/ElementOrb.cs b/Projectiles/Magic/ElementOrb.cs index 293d77697e..53a5b58350 100644 --- a/Projectiles/Magic/ElementOrb.cs +++ b/Projectiles/Magic/ElementOrb.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.timeLeft = 30; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/ElementOrb2.cs b/Projectiles/Magic/ElementOrb2.cs index 24aea167b9..d123f573b1 100644 --- a/Projectiles/Magic/ElementOrb2.cs +++ b/Projectiles/Magic/ElementOrb2.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.timeLeft = 30; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/ElementTentacle.cs b/Projectiles/Magic/ElementTentacle.cs index bb39bbd20b..03745d0183 100644 --- a/Projectiles/Magic/ElementTentacle.cs +++ b/Projectiles/Magic/ElementTentacle.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -96,7 +97,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Magic/ElementalRayBeam.cs b/Projectiles/Magic/ElementalRayBeam.cs index c229b093b4..841862f3c8 100644 --- a/Projectiles/Magic/ElementalRayBeam.cs +++ b/Projectiles/Magic/ElementalRayBeam.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -23,7 +24,8 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = 180; - } + projectile.ignoreWater = true; + } public override void AI() { @@ -53,7 +55,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Magic/EternityBook.cs b/Projectiles/Magic/EternityBook.cs index 61b77e0ceb..ab373b7042 100644 --- a/Projectiles/Magic/EternityBook.cs +++ b/Projectiles/Magic/EternityBook.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Magic Time++; // Summon a bunch of cool things the moment the book is created, assuming an NPC is near the mouse position. - if (Time == 1f) + if (Main.myPlayer == projectile.owner && Time == 1f) { NPC target = Main.MouseWorld.ClosestNPCAt(4400f, true, true); diff --git a/Projectiles/Magic/EternityCircle.cs b/Projectiles/Magic/EternityCircle.cs index 7fbc1e6174..c88d994190 100644 --- a/Projectiles/Magic/EternityCircle.cs +++ b/Projectiles/Magic/EternityCircle.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Magic get => (int)projectile.localAI[1]; set => projectile.localAI[1] = value; } - public const float TargetOffsetRadius = 595f; + public const float TargetOffsetRadius = 490f; public const float SinusoidalOffsetAngleIncrement = 0.54f; public static readonly float SinusoidalPositionAngleIncrement = MathHelper.ToRadians(3.5f); public override void SetStaticDefaults() diff --git a/Projectiles/Magic/EternityHex.cs b/Projectiles/Magic/EternityHex.cs index 79813a7cbb..91ca33bd9f 100644 --- a/Projectiles/Magic/EternityHex.cs +++ b/Projectiles/Magic/EternityHex.cs @@ -1,7 +1,10 @@ using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using System; using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -10,6 +13,7 @@ namespace CalamityMod.Projectiles.Magic { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + internal PrimitiveTrail LemniscateDrawer = null; public int TargetNPCIndex { get => (int)projectile.ai[0]; @@ -36,6 +40,8 @@ namespace CalamityMod.Projectiles.Magic public override void SetStaticDefaults() { DisplayName.SetDefault("Eternity"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 63; } public override void SetDefaults() @@ -46,6 +52,7 @@ namespace CalamityMod.Projectiles.Magic projectile.extraUpdates = 1; projectile.alpha = 255; } + public override void AI() { Player player = Main.player[projectile.owner]; @@ -99,13 +106,16 @@ namespace CalamityMod.Projectiles.Magic for (int i = 0; i < 3; i++) { LemniscateAngle += MathHelper.TwoPi / 200f; - DrawLemniscate(target); + DetermineLemniscatePosition(target); } + if (Time < Lifetime * projectile.MaxUpdates) { float effectRate = MathHelper.Lerp(0.4f, 1f, Time / (Lifetime * projectile.MaxUpdates - 40)); float random = Main.rand.NextFloat(); + projectile.Opacity = Utils.InverseLerp(Lifetime * projectile.MaxUpdates, (Lifetime - 60f) * projectile.MaxUpdates, Time, true); + // Spawn a bunch of swirling dust and do damage. if (random <= effectRate) SpawnSwirlingDust(target); @@ -142,6 +152,7 @@ namespace CalamityMod.Projectiles.Magic projectile.Kill(); } } + public void DeathDust() { for (int i = 0; i < 44; i++) @@ -151,7 +162,8 @@ namespace CalamityMod.Projectiles.Magic dust.noGravity = true; } } - public void DrawLemniscate(NPC target) + + public void DetermineLemniscatePosition(NPC target) { // This value causes the lemniscate to smoothen out and look better. float scale = 2f / (3f - (float)Math.Cos(2 * LemniscateAngle)); @@ -160,16 +172,8 @@ namespace CalamityMod.Projectiles.Magic Vector2 lemniscateOffset = scale * new Vector2((float)Math.Cos(LemniscateAngle), (float)Math.Sin(2f * LemniscateAngle) / 2f); projectile.Center = target.Center + lemniscateOffset * outwardMultiplier; - - // This part isn't actually throughout the projectile's lifetime because of extra updates. - float completionValue = Utils.InverseLerp(0f, Lifetime, Time, true); - Color dustColor = Color.Lerp(new Color(245, 112, 218), new Color(28, 13, 118), completionValue); - - Dust dust = Dust.NewDustDirect(projectile.Center, 0, 0, Eternity.DustID, newColor: dustColor); - dust.velocity = Vector2.Zero; - dust.scale = MathHelper.Lerp(0.8f, 1.5f, completionValue); - dust.noGravity = true; } + public void ChooseNewTarget(NPC newTarget) { TargetNPCIndex = newTarget.whoAmI; @@ -180,7 +184,7 @@ namespace CalamityMod.Projectiles.Magic Projectile proj = Main.projectile[i]; if (!proj.active) continue; - if (proj.whoAmI != projectile.whoAmI) + if (proj.owner != projectile.owner) continue; if (proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType()) continue; @@ -189,24 +193,55 @@ namespace CalamityMod.Projectiles.Magic DeathDust(); } } + public void SpawnSwirlingDust(NPC target) { - for (int i = 0; i < 12; i++) + for (int i = 0; i < 3; i++) { float randomAngle = Main.rand.NextFloat() * MathHelper.TwoPi; float outwardnessFactor = Main.rand.NextFloat(); Vector2 spawnPosition = target.Center + randomAngle.ToRotationVector2() * MathHelper.Lerp(70f, EternityCircle.TargetOffsetRadius - 60f, outwardnessFactor); Vector2 velocity = (randomAngle - 3f * MathHelper.Pi / 8f).ToRotationVector2() * (10f + 9f * Main.rand.NextFloat() + 4f * outwardnessFactor); - Dust swirlingDust = Dust.NewDustPerfect(spawnPosition, Eternity.DustID, new Vector2?(velocity), 0, Main.rand.NextBool(3) ? Eternity.BlueColor : Eternity.PinkColor, 1.4f); - swirlingDust.scale = 0.8f; - swirlingDust.fadeIn = 0.95f + outwardnessFactor * 0.3f; + Dust swirlingDust = Dust.NewDustPerfect(spawnPosition, 267, new Vector2?(velocity), 0, Main.rand.NextBool(3) ? Eternity.BlueColor : Eternity.PinkColor, 1.4f); + swirlingDust.scale = 1.2f; + swirlingDust.fadeIn = 0.25f + outwardnessFactor * 0.1f; swirlingDust.noGravity = true; } } + // So that the player can gauge the DPS of this weapon effectively (StrikeNPC alone will not register the DPS to the player. I have to do this myself). public void RegisterDPS(int damage) { Main.player[projectile.owner].addDPS(damage); } - } -} \ No newline at end of file + + public Color PrimitiveColorFunction(float completionRatio) + { + float leftoverTimeScale = (float)Math.Sin(Main.GlobalTime * 4f) * 0.5f + 0.5f; + leftoverTimeScale *= 0.5f; + + Color headColor = Color.Lerp(Color.Black, Color.Magenta, 0.1f); + Color tailColor = Color.Lerp(Color.Magenta, Color.Cyan, completionRatio * 0.5f + leftoverTimeScale); + float opacity = (float)Math.Pow(Utils.InverseLerp(1f, 0.61f, completionRatio, true), 0.4) * projectile.Opacity; + 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) + { + 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/EternityHoming.cs b/Projectiles/Magic/EternityHoming.cs index a208ef02a9..3863480df1 100644 --- a/Projectiles/Magic/EternityHoming.cs +++ b/Projectiles/Magic/EternityHoming.cs @@ -29,36 +29,26 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - NPC target = null; - float distance = 4400f; - for (int index = 0; index < Main.npc.Length; index++) - { - if (Main.npc[index].CanBeChasedBy(null, false)) - { - if (Main.npc[index].boss && Vector2.Distance(projectile.Center, Main.npc[index].Center) <= 4400f) - { - target = Main.npc[index]; - break; - } - if (Vector2.Distance(projectile.Center, Main.npc[index].Center) < distance) - { - distance = Vector2.Distance(projectile.Center, Main.npc[index].Center); - target = Main.npc[index]; - } - } - } + NPC target = projectile.Center.ClosestNPCAt(3000f); if (target != null) projectile.velocity = (projectile.velocity * 7f + projectile.SafeDirectionTo(target.Center) * 10f) / 8f; projectile.ai[0] += 0.18f; float angle = projectile.velocity.ToRotation() + MathHelper.PiOver2; float pulse = (float)Math.Sin(projectile.ai[0]); - float radius = 10f; + float radius = 4f; Vector2 offset = angle.ToRotationVector2() * pulse * radius; - Dust dust = Dust.NewDustPerfect(projectile.Center + offset, Eternity.DustID, Vector2.Zero, 0, Eternity.BlueColor); + + Dust dust = Dust.NewDustPerfect(projectile.Center + offset, 264, Vector2.Zero); + dust.color = Eternity.BlueColor; + dust.scale = 1.4f; + dust.noLight = true; dust.noGravity = true; - dust = Dust.NewDustPerfect(projectile.Center - offset, Eternity.DustID, Vector2.Zero, 0, Eternity.BlueColor); + dust = Dust.NewDustPerfect(projectile.Center - offset, 264, Vector2.Zero); + dust.color = Eternity.PinkColor; + dust.scale = 1.4f; + dust.noLight = true; dust.noGravity = true; } } diff --git a/Projectiles/Magic/EventHorizonStar.cs b/Projectiles/Magic/EventHorizonStar.cs index 68652f95cb..5b030cb318 100644 --- a/Projectiles/Magic/EventHorizonStar.cs +++ b/Projectiles/Magic/EventHorizonStar.cs @@ -87,7 +87,7 @@ namespace CalamityMod.Projectiles.Magic if (projectile.localAI[0] >= 100) { Vector2 center = projectile.Center; - float homingRange = 200f; + float homingRange = 250f; bool homeIn = false; float inertia = 25f; float homingSpeed = 23f; diff --git a/Projectiles/Magic/FabBolt.cs b/Projectiles/Magic/FabBolt.cs index a4176ffc0f..99420e8491 100644 --- a/Projectiles/Magic/FabBolt.cs +++ b/Projectiles/Magic/FabBolt.cs @@ -1,40 +1,114 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { 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() { DisplayName.SetDefault("Bolt"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 23; } public override void SetDefaults() { projectile.width = 4; projectile.height = 4; - projectile.extraUpdates = 100; projectile.friendly = true; - projectile.timeLeft = 45; + projectile.extraUpdates = 2; + projectile.penetrate = 12; + projectile.timeLeft = 90 * projectile.extraUpdates; projectile.magic = true; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 0; } public override void AI() { - if (projectile.timeLeft % 2f == 0f) + if (FadingOut) + { + projectile.Opacity = MathHelper.Lerp(projectile.Opacity, 0f, 0.27f); + if (projectile.Opacity <= 0.05f) + projectile.Kill(); + } + else + projectile.velocity *= 1.004f; + projectile.rotation = projectile.velocity.ToRotation(); + + // Emit light. + Lighting.AddLight(projectile.Center, Vector3.One * projectile.Opacity * 0.45f); + } + + 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); + Color endColor = Color.Lerp(Color.Cyan, Color.HotPink, projectile.identity % 2); + return Color.Lerp(Color.White, endColor, fadeToEnd) * projectile.Opacity * 0.7f; + } + + internal float WidthFunction(float completionRatio) + { + float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.InverseLerp(0f, 0.2f, completionRatio, true), 2D); + return MathHelper.Lerp(0f, 22f, expansionCompletion) * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:TrailStreak"]); + + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/FabstaffStreak")); + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 120, projectile.oldRot); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (!FadingOut && projectile.penetrate < 2) { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 234, 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; - } + FadingOut = true; + projectile.velocity *= 0.1f; + projectile.extraUpdates = 0; + projectile.netUpdate = true; + } } - } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (!FadingOut) + { + FadingOut = true; + projectile.velocity *= 0.1f; + projectile.extraUpdates = 0; + projectile.netUpdate = true; + } + return false; + } + + public override bool CanDamage() + { + if (FadingOut) + return false; + return base.CanDamage(); + } + } } diff --git a/Projectiles/Magic/FabOrb.cs b/Projectiles/Magic/FabOrb.cs deleted file mode 100644 index a1c1c6c48b..0000000000 --- a/Projectiles/Magic/FabOrb.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class FabOrb : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Orb"); - } - - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.timeLeft = 30; - projectile.magic = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 150f, 6f, 6f, 2, ModContent.ProjectileType(), 1D, true); - } - } -} diff --git a/Projectiles/Magic/FabRay.cs b/Projectiles/Magic/FabRay.cs index 384061e7a5..137015fad6 100644 --- a/Projectiles/Magic/FabRay.cs +++ b/Projectiles/Magic/FabRay.cs @@ -1,15 +1,22 @@ using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { public class FabRay : ModProjectile { + internal PrimitiveTrail TrailDrawer; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { DisplayName.SetDefault("Ray"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 54; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; } public override void SetDefaults() @@ -18,9 +25,10 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.penetrate = 20; - projectile.extraUpdates = 100; - projectile.timeLeft = 600; + projectile.ignoreWater = true; + projectile.penetrate = 70; + projectile.extraUpdates = 3; + projectile.timeLeft = 60 * projectile.extraUpdates; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; } @@ -29,24 +37,59 @@ namespace CalamityMod.Projectiles.Magic { Lighting.AddLight(projectile.Center, 0.2f, 0.01f, 0.1f); projectile.ai[0] += 1f; - if (projectile.ai[0] % 6f == 0f && projectile.owner == Main.myPlayer) + projectile.Opacity = Utils.InverseLerp(0f, 10f * projectile.MaxUpdates, projectile.timeLeft, true); + + int shootRate = projectile.npcProj ? 40 : 12; + if (projectile.owner == Main.myPlayer && projectile.ai[0] % shootRate == 0f) { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); + NPC potentialTarget = projectile.Center.ClosestNPCAt(180f, false); + if (potentialTarget != null) + { + Vector2 shootVelocity = projectile.SafeDirectionTo(potentialTarget.Center) * 13f; + Projectile.NewProjectile(projectile.Center - shootVelocity * 2.5f, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + + for (int i = 0; i < projectile.oldPos.Length / 4; i += 3) + { + potentialTarget = projectile.oldPos[i].ClosestNPCAt(280f, false); + if (potentialTarget != null) + { + Vector2 shootVelocity = (potentialTarget.Center - projectile.oldPos[i]).SafeNormalize(Vector2.UnitY) * 13f; + Projectile.NewProjectile(projectile.oldPos[i] - shootVelocity * 2.5f, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + break; + } + } } - if (projectile.ai[0] > 16f && projectile.ai[0] % 2f == 0f) - { - Vector2 source = projectile.position; - int pink = Dust.NewDust(source, 1, 1, 234, 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; - } + // Emit light. + Lighting.AddLight(projectile.Center, Vector3.One * projectile.Opacity * 0.7f); } - public override bool OnTileCollide(Vector2 oldVelocity) + internal Color ColorFunction(float completionRatio) + { + float fadeToEnd = MathHelper.Lerp(0.65f, 1f, (float)Math.Cos(-Main.GlobalTime * 3f) * 0.5f + 0.5f); + float fadeOpacity = Utils.InverseLerp(1f, 0.64f, completionRatio, true) * projectile.Opacity; + Color endColor = Color.Lerp(Color.Cyan, Color.HotPink, (float)Math.Sin(completionRatio * MathHelper.Pi * 1.6f - Main.GlobalTime * 4f) * 0.5f + 0.5f); + return Color.Lerp(Color.White, endColor, fadeToEnd) * fadeOpacity; + } + + internal float WidthFunction(float completionRatio) + { + float expansionCompletion = 1f - (float)Math.Pow(1f - Utils.InverseLerp(0f, 0.3f, completionRatio, true), 2D); + return MathHelper.Lerp(0f, 32f * projectile.Opacity, expansionCompletion); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]); + + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition, 76); + return false; + } + + public override bool OnTileCollide(Vector2 oldVelocity) { projectile.penetrate--; if (projectile.penetrate <= 0) diff --git a/Projectiles/Magic/GhastlySubBlast.cs b/Projectiles/Magic/GhastlySubBlast.cs index be5dd57539..fb02effb27 100644 --- a/Projectiles/Magic/GhastlySubBlast.cs +++ b/Projectiles/Magic/GhastlySubBlast.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.timeLeft = 420; + projectile.ignoreWater = true; + projectile.timeLeft = 420; projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; diff --git a/Projectiles/Magic/HeresyProj.cs b/Projectiles/Magic/HeresyProj.cs new file mode 100644 index 0000000000..89a71ba3fd --- /dev/null +++ b/Projectiles/Magic/HeresyProj.cs @@ -0,0 +1,130 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; + +namespace CalamityMod.Projectiles.Magic +{ + public class HeresyProj : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public float ShootIntensity => MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, 275f, Time, true)); + public ref float Time => ref projectile.ai[0]; + public ref float AttackTimer => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Heresy"); + Main.projFrames[projectile.type] = 8; + } + + public override void SetDefaults() + { + projectile.width = 26; + projectile.height = 32; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + projectile.Center = Owner.Center + Vector2.UnitX * Owner.direction * 18f; + + // If the player is no longer able to hold the book, kill it. + if (!Owner.channel || Owner.noItems || Owner.CCed) + { + projectile.Kill(); + return; + } + + if (AttackTimer >= Main.rand.Next(20, 28) - (int)MathHelper.Lerp(0f, 16f, Utils.InverseLerp(0f, 120f, Time, true))) + ReleaseThings(); + + // Switch frames at a linearly increasing rate to make it look like the player is flipping pages quickly. + projectile.frameCounter++; + if (projectile.frameCounter >= (int)MathHelper.Lerp(10f, 2f, Utils.InverseLerp(0f, 180f, Time, true))) + { + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + projectile.frameCounter = 0; + } + + AdjustPlayerValues(); + projectile.timeLeft = 2; + AttackTimer++; + Time++; + } + + public void ReleaseThings() + { + Main.PlaySound(SoundID.DD2_EtherianPortalSpawnEnemy); + if (Main.myPlayer != projectile.owner) + return; + + // If the owner has sufficient mana, consume it. + // Otherwise, delete the book and don't bother summoning anything. + if (!Owner.CheckMana(Owner.ActiveItem().mana, true, false)) + { + projectile.Kill(); + return; + } + WeightedRandom typeDecider = new WeightedRandom(); + + typeDecider.Add(ModContent.ProjectileType(), 1.5f); + + // Make souls appear more frequently (aka with a higher weight) the more "intense" the shots should be. + typeDecider.Add(ModContent.ProjectileType(), ShootIntensity * 0.75f); + typeDecider.Add(ModContent.ProjectileType(), ShootIntensity * 0.4f); + typeDecider.Add(ModContent.ProjectileType(), ShootIntensity * 0.2f); + + Vector2 spawnPosition = projectile.Top + Main.rand.NextVector2CircularEdge(4f, 4f); + Vector2 shootVelocity = -Vector2.UnitY.RotatedBy(Main.rand.NextFloat(-0.13f, 0.23f) * Owner.direction) * Owner.gravDir; + shootVelocity *= Main.rand.NextFloat(5f, 8); + + if (Owner.velocity.Y < 0f) + shootVelocity.Y += Owner.velocity.Y; + + Projectile.NewProjectile(spawnPosition, shootVelocity, typeDecider.Get(), projectile.damage, projectile.knockBack, projectile.owner, ShootIntensity); + + AttackTimer = 0f; + projectile.netUpdate = true; + } + + public void AdjustPlayerValues() + { + projectile.spriteDirection = projectile.direction = Owner.direction; + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (projectile.direction * projectile.velocity).ToRotation(); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + float glowOutwardness = MathHelper.SmoothStep(0f, 4f, Utils.InverseLerp(90f, 270f, Time, true)); + Texture2D bookTexture = Main.projectileTexture[projectile.type]; + Rectangle frame = bookTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Vector2 drawPosition; + Vector2 origin = frame.Size() * 0.5f; + Color glowColor = Color.Lerp(Color.Pink, Color.Red, (float)Math.Cos(Main.GlobalTime * 5f) * 0.5f + 0.5f); + glowColor.A = 0; + + // Draw an ominous glowing version of the book after a bit of time. + for (int i = 0; i < 8; i++) + { + drawPosition = projectile.Center + (MathHelper.TwoPi * i / 8f + Main.GlobalTime * 4f).ToRotationVector2() * glowOutwardness - Main.screenPosition; + spriteBatch.Draw(bookTexture, drawPosition, frame, projectile.GetAlpha(glowColor), projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + } + + drawPosition = projectile.Center - Main.screenPosition; + spriteBatch.Draw(bookTexture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Magic/HeresyProj.png b/Projectiles/Magic/HeresyProj.png new file mode 100644 index 0000000000..ca66b0eb6f Binary files /dev/null and b/Projectiles/Magic/HeresyProj.png differ diff --git a/Projectiles/Magic/IceBarrageMain.cs b/Projectiles/Magic/IceBarrageMain.cs index b3d059ee00..19bf85a147 100644 --- a/Projectiles/Magic/IceBarrageMain.cs +++ b/Projectiles/Magic/IceBarrageMain.cs @@ -176,8 +176,8 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Magic/IceCluster.cs b/Projectiles/Magic/IceCluster.cs index 1f79ca4adb..ca39a0af34 100644 --- a/Projectiles/Magic/IceCluster.cs +++ b/Projectiles/Magic/IceCluster.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Magic { target.immune[projectile.owner] = 5; - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); Vector2 vector80 = projectile.rotation.ToRotationVector2(); if (projectile.owner == Main.myPlayer) diff --git a/Projectiles/Magic/MagneticBeam.cs b/Projectiles/Magic/MagneticBeam.cs index 0efe5b7ac2..8244fc3197 100644 --- a/Projectiles/Magic/MagneticBeam.cs +++ b/Projectiles/Magic/MagneticBeam.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 90; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/MagneticOrb.cs b/Projectiles/Magic/MagneticOrb.cs index d21ed548f4..924084c01b 100644 --- a/Projectiles/Magic/MagneticOrb.cs +++ b/Projectiles/Magic/MagneticOrb.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 38; projectile.friendly = true; projectile.tileCollide = false; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 120; projectile.magic = true; } diff --git a/Projectiles/Magic/NebulaElementalBeam.cs b/Projectiles/Magic/NebulaElementalBeam.cs new file mode 100644 index 0000000000..86b396809b --- /dev/null +++ b/Projectiles/Magic/NebulaElementalBeam.cs @@ -0,0 +1,66 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class NebulaElementalBeam : BaseLaserbeamProjectile + { + public override float MaxScale => 1.4f; + public override float MaxLaserLength => 1000f; + public override float Lifetime => 30f; + 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"); + + public const float UniversalAngularSpeed = MathHelper.Pi / 400f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 20; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 13; + projectile.tileCollide = false; + projectile.timeLeft = (int)Lifetime; + } + + public override void ExtraBehavior() + { + RotationalSpeed = UniversalAngularSpeed; + // Generate a burst of bubble-like nebula dust. + if (!Main.dedServ && Time == 5f) + { + int totalBubbles = 24; + for (int i = 0; i < totalBubbles; i++) + { + Dust nebulaBubble = Dust.NewDustPerfect(projectile.Center, 242); + nebulaBubble.velocity = Main.rand.NextVector2Circular(6f, 6f); + nebulaBubble.scale = Main.rand.NextFloat(2f, 3f); + nebulaBubble.noGravity = true; + } + } + } + + public override void DetermineScale() => projectile.scale = projectile.timeLeft / Lifetime * MaxScale; + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + DrawBeamWithColor(spriteBatch, new Color(190, 29, 209), projectile.scale); + DrawBeamWithColor(spriteBatch, Color.Lerp(new Color(254, 126, 229), Color.Transparent, 0.35f), projectile.scale * 0.6f); + DrawBeamWithColor(spriteBatch, Color.Lerp(new Color(254, 190, 243), Color.Transparent, 0.35f), projectile.scale * 0.6f); + return false; + } + } +} diff --git a/Projectiles/Magic/NebulaElementalBeam.png b/Projectiles/Magic/NebulaElementalBeam.png new file mode 100644 index 0000000000..15e8775737 Binary files /dev/null and b/Projectiles/Magic/NebulaElementalBeam.png differ diff --git a/Projectiles/Magic/NightBolt.cs b/Projectiles/Magic/NightBolt.cs index d32efdd8b9..b55dd36601 100644 --- a/Projectiles/Magic/NightBolt.cs +++ b/Projectiles/Magic/NightBolt.cs @@ -16,11 +16,12 @@ namespace CalamityMod.Projectiles.Magic { projectile.width = 4; projectile.height = 4; - projectile.extraUpdates = 100; + projectile.extraUpdates = 20; projectile.friendly = true; projectile.timeLeft = 30; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/NightOrb.cs b/Projectiles/Magic/NightOrb.cs index b481855ab5..c637119196 100644 --- a/Projectiles/Magic/NightOrb.cs +++ b/Projectiles/Magic/NightOrb.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Magic projectile.penetrate = -1; projectile.timeLeft = 30; projectile.magic = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/NightsRayBeam.cs b/Projectiles/Magic/NightsRayBeam.cs index 5338b9c857..b9ca198c46 100644 --- a/Projectiles/Magic/NightsRayBeam.cs +++ b/Projectiles/Magic/NightsRayBeam.cs @@ -5,8 +5,13 @@ namespace CalamityMod.Projectiles.Magic { public class NightsRayBeam : ModProjectile { + public ref float Time => ref projectile.ai[0]; + public bool HasFiredSideBeams + { + get => projectile.ai[1] == 1f; + set => projectile.ai[1] = value.ToInt(); + } public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - public override void SetStaticDefaults() { DisplayName.SetDefault("Ray"); @@ -18,31 +23,41 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = 150; } public override void AI() { - projectile.localAI[1] += 1f; - if (projectile.localAI[1] >= 29f && projectile.owner == Main.myPlayer) + if (!HasFiredSideBeams && projectile.owner == Main.myPlayer) { - projectile.localAI[1] = 0f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.6), projectile.knockBack, projectile.owner, 0f, 0f); + NPC potentialTarget = projectile.Center.ClosestNPCAt(5480f, false); + if (potentialTarget != null) + { + Vector2 baseSpawnPositionOffset = Main.rand.NextVector2CircularEdge(40f, 40f); + for (int i = 0; i < 4; i++) + { + Vector2 spawnPosition = potentialTarget.Center + baseSpawnPositionOffset.RotatedBy(MathHelper.TwoPi * i / 4f); + Projectile.NewProjectile(spawnPosition, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.8), projectile.knockBack, projectile.owner); + } + HasFiredSideBeams = true; + projectile.netUpdate = true; + } } - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 9f) + Time++; + if (Time >= 10f) { - for (int num447 = 0; num447 < 3; num447++) + for (int i = 0; i < 2; i++) { - 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; + Vector2 dustSpawnPos = projectile.position - projectile.velocity * i / 2f; + Dust corruptMagic = Dust.NewDustPerfect(dustSpawnPos, 27); + corruptMagic.color = Color.Lerp(Color.Fuchsia, Color.Magenta, Main.rand.NextFloat(0.6f)); + corruptMagic.scale = Main.rand.NextFloat(0.96f, 1.04f); + corruptMagic.noGravity = true; + corruptMagic.velocity *= 0.1f; } } } diff --git a/Projectiles/Magic/PartySparkle.cs b/Projectiles/Magic/PartySparkle.cs new file mode 100644 index 0000000000..58be299f5d --- /dev/null +++ b/Projectiles/Magic/PartySparkle.cs @@ -0,0 +1,120 @@ +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class PartySparkle : ModProjectile + { + public float Time + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + public float ColorSpectrumHue + { + get => projectile.ai[1]; + set => projectile.ai[1] = value; + } + public const int Lifetime = 90; + public const int FadeinTime = 18; + public const int FadeoutTime = 18; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pretty Sparkle"); + } + + public override void SetDefaults() + { + projectile.width = 72; + projectile.height = 72; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.timeLeft = Lifetime; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.scale = 0.001f; + } + + public override void AI() + { + if (Time == 1f) + { + projectile.scale = Main.rand.NextFloat(0.4f, 1.1f); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(72 * projectile.scale)); + ColorSpectrumHue = Main.rand.NextFloat(0f, 0.9999f); + projectile.netUpdate = true; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + Time++; + + projectile.velocity *= 0.96f; + + projectile.rotation = projectile.rotation.AngleLerp(MathHelper.PiOver2, 0.085f); + + ColorSpectrumHue = (ColorSpectrumHue + 0.333f / Lifetime) % 0.999f; // Go 33% across the color spectrum throughout the sparkle's life instead of using a static sprite. + + projectile.Opacity = Utils.InverseLerp(0f, FadeinTime, Time, true) * Utils.InverseLerp(Lifetime, Lifetime - FadeoutTime, Time, true); + projectile.velocity = projectile.velocity.RotatedBy(Math.Sin(Time / 30f) * 0.0125f); + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D sparkleTexture = ModContent.GetTexture(Texture); + + Color sparkleColor = CalamityUtils.MulticolorLerp(ColorSpectrumHue, RainbowPartyCannon.ColorSet) * projectile.Opacity * 0.5f; + sparkleColor.A = 0; + + sparkleColor *= MathHelper.Lerp(1f, 1.5f, Utils.InverseLerp(Lifetime * 0.5f - 15f, Lifetime * 0.5f + 15f, Time, true)); + + Color orthogonalsparkleColor = Color.Lerp(sparkleColor, Color.White, 0.5f) * 0.5f; + + Vector2 origin = sparkleTexture.Size() / 2f; + + Vector2 sparkleScale = new Vector2(0.3f, 1f) * projectile.Opacity * projectile.scale; + Vector2 orthogonalsparkleScale = new Vector2(0.3f, 2f) * projectile.Opacity * projectile.scale; + + spriteBatch.Draw(sparkleTexture, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + null, + sparkleColor, + MathHelper.PiOver2 + projectile.rotation, + origin, + orthogonalsparkleScale, + SpriteEffects.None, + 0f); + spriteBatch.Draw(sparkleTexture, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + null, + sparkleColor, + projectile.rotation, + origin, + sparkleScale, + SpriteEffects.None, + 0f); + spriteBatch.Draw(sparkleTexture, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + null, + orthogonalsparkleColor, + MathHelper.PiOver2 + projectile.rotation, + origin, + orthogonalsparkleScale * 0.6f, + SpriteEffects.None, + 0f); + spriteBatch.Draw(sparkleTexture, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + null, + orthogonalsparkleColor, + projectile.rotation, + origin, + sparkleScale * 0.6f, + SpriteEffects.None, + 0f); + return false; + } + } +} diff --git a/Projectiles/Magic/PartySparkle.png b/Projectiles/Magic/PartySparkle.png new file mode 100644 index 0000000000..0968156e79 Binary files /dev/null and b/Projectiles/Magic/PartySparkle.png differ diff --git a/Projectiles/Magic/PoseidonTyphoon.cs b/Projectiles/Magic/PoseidonTyphoon.cs index 438bc07c38..faa8f40130 100644 --- a/Projectiles/Magic/PoseidonTyphoon.cs +++ b/Projectiles/Magic/PoseidonTyphoon.cs @@ -48,7 +48,6 @@ namespace CalamityMod.Projectiles.Magic } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Magic/RainbowComet.cs b/Projectiles/Magic/RainbowComet.cs new file mode 100644 index 0000000000..3e244cfc67 --- /dev/null +++ b/Projectiles/Magic/RainbowComet.cs @@ -0,0 +1,99 @@ +using CalamityMod.Items.Weapons.Magic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RainbowComet : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public const float FadeinTime = 40f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Comet"); + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 12; + Main.projFrames[projectile.type] = 3; + } + + public override void SetDefaults() + { + projectile.width = 72; + projectile.height = 72; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.magic = true; + projectile.timeLeft = 300; + projectile.usesLocalNPCImmunity = true; + projectile.alpha = 255; + projectile.localNPCHitCooldown = 16; + } + + public override void AI() + { + Time++; + projectile.Opacity = Utils.InverseLerp(0f, 20f, Time, true); + projectile.velocity = projectile.velocity.RotatedBy(Math.Sin(Time / 30f) * 0.0125f); + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + + projectile.frameCounter++; + if (projectile.frameCounter % 4 == 3) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D cometTexture = ModContent.GetTexture(Texture); + spriteBatch.Draw(cometTexture, + projectile.Center + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition, + cometTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame), + Color.White * projectile.Opacity, + projectile.rotation, + cometTexture.Size() * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + return false; + } + public override void Kill(int timeLeft) + { + if (projectile.owner == Main.myPlayer) + { + // Generate pretty sparkles. + for (int i = 0; i < 18; i++) + { + Vector2 velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(9f, 20f); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 1f, projectile.owner); + } + + // And release a bunch of rockets. + for (int i = 0; i < (int)RainbowRocket.PartyCannonExplosionType.Count; i++) + { + Vector2 velocity = -projectile.velocity.SafeNormalize(-Vector2.UnitY); + velocity = velocity.RotatedBy(MathHelper.Lerp(-1.1f, 1.1f, i / (float)(int)RainbowRocket.PartyCannonExplosionType.Count)); + velocity *= Main.rand.NextFloat(7f, 15f); + + Projectile rocket = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage * 3, 1f, projectile.owner); + rocket.ai[1] = i; + } + } + + if (!Main.dedServ) + { + for (int i = 0; i < 80; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, 263); + dust.color = CalamityUtils.MulticolorLerp((Main.rand.NextFloat(0.4f) + Main.GlobalTime * 0.4f) % 0.999f, RainbowPartyCannon.ColorSet); + dust.scale = Main.rand.NextFloat(0.6f, 0.9f); + dust.velocity = Vector2.UnitY.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(12f, 16f); + dust.noGravity = true; + } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire").WithVolume(0.45f), projectile.Center); + } + } + } +} diff --git a/Projectiles/Magic/RainbowComet.png b/Projectiles/Magic/RainbowComet.png new file mode 100644 index 0000000000..b713356be9 Binary files /dev/null and b/Projectiles/Magic/RainbowComet.png differ diff --git a/Projectiles/Magic/RainbowPartyCannonProjectile.cs b/Projectiles/Magic/RainbowPartyCannonProjectile.cs new file mode 100644 index 0000000000..da42c6a936 --- /dev/null +++ b/Projectiles/Magic/RainbowPartyCannonProjectile.cs @@ -0,0 +1,108 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RainbowPartyCannonProjectile : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[0]; + public const float ChargeDelay = 60f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Party Cannon"); + } + + public override void SetDefaults() + { + projectile.width = 92; + projectile.height = 66; + projectile.penetrate = -1; + projectile.magic = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + } + + public override void AI() + { + Item heldItem = Owner.ActiveItem(); + projectile.damage = (int)((heldItem?.damage ?? 0) * Owner.MagicDamage()); + + UpdatePlayerVisuals(Owner.Center); + + bool stillUsingCannon = Owner.channel && !Owner.noItems && !Owner.CCed; + if (!stillUsingCannon) + { + projectile.Kill(); + return; + } + + if (Time > ChargeDelay && Time % heldItem.useTime == 0) + { + ConsumeManaAndFireProjectile(heldItem); + } + else if (Time <= ChargeDelay && !Main.dedServ) + { + if (Main.rand.NextBool(3)) + { + Vector2 velocityDirection = projectile.velocity.RotatedByRandom(0.1f); + Vector2 shotOffset = velocityDirection * projectile.Size * 0.5f; + Dust.NewDustPerfect(projectile.Center + shotOffset, Main.rand.Next(139, 143), velocityDirection * Main.rand.NextFloat(5f, 9f)); + } + } + + Time++; + + // Forces the cannon to disappear immediately if anything goes wrong. + projectile.timeLeft = 2; + } + + public void ConsumeManaAndFireProjectile(Item heldItem) + { + if (Owner.whoAmI != Main.myPlayer) + return; + + if (!Owner.CheckMana(heldItem.mana, true)) + { + projectile.Kill(); + return; + } + + Main.PlaySound(heldItem.UseSound, projectile.Center); + Vector2 spawnPosition = projectile.Center + projectile.velocity * 150f; + + // Shoot farther back if the cannon is shoved into a bunch of tiles. + if (!Collision.CanHitLine(Owner.MountedCenter, 16, 16, spawnPosition, 16, 16)) + spawnPosition = projectile.Center + projectile.velocity * 50f; + + Projectile.NewProjectile(spawnPosition, projectile.velocity.SafeNormalize(Vector2.Zero) * heldItem.shootSpeed, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, Owner.whoAmI); + } + + public void UpdatePlayerVisuals(Vector2 center) + { + // Place the cannon directly into the player's hand at all times. + projectile.Center = center; + + // Set the direction of the cannon if it hasn't been set yet. + if (projectile.velocity == Vector2.Zero || projectile.velocity.Length() != 1f) + projectile.velocity = (Main.MouseWorld - center).SafeNormalize(Vector2.UnitX * projectile.direction); + + projectile.rotation = projectile.velocity.ToRotation(); + projectile.direction = projectile.spriteDirection = (Math.Cos(projectile.rotation) > 0).ToDirectionInt(); + + // The cannon is a holdout projectile. Change the player's channel and direction values to reflect this. + Owner.ChangeDir(projectile.direction); + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + + Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + if (projectile.spriteDirection == -1) + projectile.rotation += MathHelper.Pi; + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Magic/RainbowPartyCannonProjectile.png b/Projectiles/Magic/RainbowPartyCannonProjectile.png new file mode 100644 index 0000000000..59c2f21ef9 Binary files /dev/null and b/Projectiles/Magic/RainbowPartyCannonProjectile.png differ diff --git a/Projectiles/Magic/RainbowRocket.cs b/Projectiles/Magic/RainbowRocket.cs new file mode 100644 index 0000000000..6b2b51ff60 --- /dev/null +++ b/Projectiles/Magic/RainbowRocket.cs @@ -0,0 +1,702 @@ +using CalamityMod.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RainbowRocket : ModProjectile + { + public enum PartyCannonExplosionType + { + Pink = 0, + Orange = 1, + Yellow = 2, + White = 3, + SkyBlue = 4, + Purple = 5, + PalePink = 6, + Count = 7 + } + + internal PrimitiveTrail TrailDrawer = null; + public ref float Time => ref projectile.ai[0]; + public PartyCannonExplosionType RocketType + { + get => (PartyCannonExplosionType)(int)projectile.ai[1]; + set => projectile.ai[1] = (int)value; + } + public const float SwerveAngle = 0.02f; + public const float SwerveAngleOffsetMax = 0.04f; + public const float SwerveTime = 60f; + public const float HomingAcceleration = 0.4f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Rainbow Rocket"); + Main.projFrames[projectile.type] = 3; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.width = 28; + projectile.height = 52; + + projectile.friendly = true; + projectile.penetrate = 1; + projectile.timeLeft = 180; + projectile.magic = true; + } + + #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()); + + projectile.tileCollide = Time > 60f; + + projectile.frameCounter++; + if (projectile.frameCounter % 4 == 3) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + + NPC potentialTarget = projectile.Center.ClosestNPCAt(2300f, true, true); + if (Time < SwerveTime) + DoMovement_IdleSwerveFly(); + else if (potentialTarget != null) + DoMovement_FlyToTarget(potentialTarget); + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + + private void DoMovement_IdleSwerveFly() + { + float swerveAngleOffset = MathHelper.Lerp(-SwerveAngleOffsetMax, SwerveAngleOffsetMax, (float)RocketType / ((float)PartyCannonExplosionType.Count)); + projectile.velocity = projectile.velocity.RotatedBy(swerveAngleOffset + SwerveAngle); + } + + private void DoMovement_FlyToTarget(NPC target) + { + float angleToTarget = projectile.AngleTo(target.Center); + float angleOffset = MathHelper.WrapAngle(angleToTarget - projectile.velocity.ToRotation()); + projectile.velocity = projectile.velocity.RotatedBy(MathHelper.Clamp(angleOffset, -0.2f, 0.2f)); + projectile.velocity = projectile.velocity.SafeNormalize(-Vector2.UnitY) * (projectile.velocity.Length() + HomingAcceleration); + + if (Vector2.Dot(projectile.velocity.SafeNormalize(Vector2.Zero), projectile.SafeDirectionTo(target.Center)) < 0.75f) + projectile.velocity *= 0.75f; + } + #endregion + + #region Draw Effects + + internal Color GetRocketColor() + { + switch (RocketType) + { + case PartyCannonExplosionType.Pink: + return Color.Pink; + case PartyCannonExplosionType.Orange: + return Color.Orange; + case PartyCannonExplosionType.Yellow: + return Color.LightGoldenrodYellow * 0.8f; + case PartyCannonExplosionType.White: + return Color.LightGray; + case PartyCannonExplosionType.SkyBlue: + return Color.LightSkyBlue; + case PartyCannonExplosionType.Purple: + return Color.Magenta; + case PartyCannonExplosionType.PalePink: + return Color.Pink * 0.77f; + } + return Color.White; + } + + internal Color ColorFunction(float completionRatio) + { + Color baseColor = Main.hslToRgb((projectile.identity * 0.33f + completionRatio + Main.GlobalTime * 2f) % 1f, 1f, 0.54f); + return Color.Lerp(GetRocketColor(), baseColor, MathHelper.Clamp(completionRatio * 0.8f, 0f, 1f)) * projectile.Opacity; + } + + internal float WidthFunction(float completionRatio) + { + float width; + float maxWidthOutwardness = 8f; + if (completionRatio < 0.1f) + width = (float)Math.Sin(completionRatio / 0.1f * MathHelper.PiOver2) * maxWidthOutwardness + 0.1f; + else + width = MathHelper.Lerp(maxWidthOutwardness, 0f, Utils.InverseLerp(0.1f, 1f, completionRatio, true)); + return width * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction); + + projectile.oldPos[0] = projectile.position + projectile.velocity.SafeNormalize(Vector2.Zero) * 50f; + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition + projectile.velocity, 80); + + Texture2D rocketTexture = ModContent.GetTexture(Texture); + spriteBatch.Draw(rocketTexture, + projectile.Center - Main.screenPosition, + rocketTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame), + GetRocketColor(), + projectile.rotation, + rocketTexture.Size() * 0.5f, + projectile.scale, + SpriteEffects.None, + 0f); + return false; + } + #endregion + + #region Kill Effects + public override void Kill(int timeLeft) + { + if (projectile.owner == Main.myPlayer) + { + for (int i = 1; i < projectile.oldPos.Length; i++) + { + if (Main.rand.NextBool(3)) + { + float offsetAngle = MathHelper.Lerp(-MathHelper.PiOver4, MathHelper.PiOver4, i / (float)projectile.oldPos.Length); + Vector2 spawnPosition = projectile.oldPos[i] + projectile.Size * 0.5f; + Vector2 spawnVelocity = (projectile.oldPos[i - 1] - projectile.oldPos[i]).SafeNormalize(Vector2.Zero); + spawnVelocity = spawnVelocity.RotatedBy(offsetAngle); + spawnVelocity *= Main.rand.NextFloat(12f, 18f); + Projectile.NewProjectile(spawnPosition, spawnVelocity, ModContent.ProjectileType(), projectile.damage, 2f, projectile.owner); + } + } + } + + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 350); + projectile.Damage(); + + Main.PlaySound(SoundID.Item14, projectile.Center); + + // There's no need to spawn dust from the server. + if (Main.dedServ) + return; + + switch (RocketType) + { + case PartyCannonExplosionType.Pink: + PinkMarkExplosionDust(); + break; + case PartyCannonExplosionType.Orange: + OrangeMarkExplosionDust(); + break; + case PartyCannonExplosionType.Yellow: + YellowMarkExplosionDust(); + break; + case PartyCannonExplosionType.White: + WhiteMarkExplosionDust(); + break; + case PartyCannonExplosionType.SkyBlue: + SkyBlueMarkExplosionDust(); + break; + case PartyCannonExplosionType.Purple: + PurpleMarkExplosionDust(); + break; + case PartyCannonExplosionType.PalePink: + PalePinkMarkExplosionDust(); + break; + } + } + #endregion + + #region Pink Mark + public void PinkMarkExplosionDust() + { + // Spawn the main balloon. + BalloonExplosionDust(projectile.Center, Main.rand.NextFloat(8f, 15f), Color.Yellow); + + // Spawn the two smaller balloons. + float absoluteOffsetAngle = Main.rand.NextFloat(0.4f, 0.7f) * -1f; + Vector2 offset = Vector2.UnitY.RotatedBy(absoluteOffsetAngle) * 120f; + offset += Vector2.UnitX * 40f; + BalloonExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f), Color.DeepPink, absoluteOffsetAngle); + + absoluteOffsetAngle = Main.rand.NextFloat(0.4f, 0.7f); + offset = Vector2.UnitY.RotatedBy(absoluteOffsetAngle) * 120f; + offset -= Vector2.UnitX * 40f; + BalloonExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f), Color.DeepPink, absoluteOffsetAngle); + } + public void BalloonExplosionDust(Vector2 center, float petalBurstSpeed, Color balloonColor, float absoluteOffsetAngle = 0) + { + float explosionOffsetAngle = Main.rand.NextFloat(-0.3f, 0.3f) + absoluteOffsetAngle; + + // Draw the balloon as a petal. + for (float angle = 0f; angle <= MathHelper.TwoPi; angle += MathHelper.ToRadians(4f)) + { + Vector2 initialUnitVector = angle.ToRotationVector2(); + float unitMultiplier = 2f + (1f + (float)Math.Cos(MathHelper.Pi + angle)); // This value is used to "squash" the circle to make it into a petal shape. + Vector2 velocity = initialUnitVector * unitMultiplier; + velocity.X *= 0.5f; + velocity = velocity.SafeNormalize(Vector2.Zero); // Turn the petal velocity into a unit vector again to make future speed calculations easier. + velocity = velocity.RotatedBy(MathHelper.PiOver2); // Flip the petal velocity. It's tilted to the side normally. + velocity = velocity.RotatedBy(explosionOffsetAngle); // Account for the explosion offset angle that was determined at the start. + + Dust dust = Dust.NewDustPerfect(center, 261); + dust.velocity = velocity * petalBurstSpeed; + dust.noGravity = true; + dust.color = balloonColor; + dust.fadeIn = 1.5f; + } + + // Draw the string below the petal, giving it the appearance of a balloon. + StringExplosionDust(center, petalBurstSpeed, explosionOffsetAngle); + } + public void StringExplosionDust(Vector2 center, float petalBurstSpeed, float offsetAngle) + { + int evaluationPoints = 40; + + // When mapped out, these points give a rough string, which when used with a bezier curve, can be smoothened out to make it look like a real string. + Vector2[] bezierControlPoints = new Vector2[] + { + new Vector2(0f, 40f), + new Vector2(20f, 76f), + new Vector2(-16f, 108f), + new Vector2(-20f, 146f), + new Vector2(-14f, 180f), + new Vector2(10f, 214f) + }; + BezierCurve bezierCurve = new BezierCurve(bezierControlPoints); + for (int i = 0; i < evaluationPoints; i++) + { + Dust dust = Dust.NewDustPerfect(center, 261); + dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints).RotatedBy(offsetAngle) + Vector2.UnitY * petalBurstSpeed * 2f; + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.color = Color.White; + dust.fadeIn = 1.5f; + } + } + #endregion + + #region Orange Mark + public void OrangeMarkExplosionDust() + { + // Spawn the main apple. + AppleExplosionDust(projectile.Center, Main.rand.NextFloat(8f, 15f)); + + // Spawn two other apples to the side. + float absoluteOffsetAngle = Main.rand.NextFloat(0.4f, 0.7f) * -1f; + Vector2 offset = Vector2.UnitY.RotatedBy(absoluteOffsetAngle) * 120f; + offset += Vector2.UnitX * 70f; + AppleExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f), absoluteOffsetAngle); + + absoluteOffsetAngle = Main.rand.NextFloat(0.4f, 0.7f); + offset = Vector2.UnitY.RotatedBy(absoluteOffsetAngle) * 120f; + offset -= Vector2.UnitX * 70f; + AppleExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f), absoluteOffsetAngle); + } + public void AppleExplosionDust(Vector2 center, float appleBurstSpeed, float offsetAngle = 0f) + { + for (float angle = 0f; angle <= MathHelper.TwoPi; angle += MathHelper.ToRadians(4f)) + { + Vector2 initialUnitVector = angle.ToRotationVector2(); + float cosineValue = (float)Math.Cos(angle); + + Vector2 velocity = initialUnitVector; + + velocity = velocity.SafeNormalize(Vector2.Zero); // Turn the petal velocity into a unit vector again to make future speed calculations easier. + velocity.X *= 1.333f; + + // Squash the circle to the shape of an apple. + if (Math.Abs(cosineValue) < 0.35f) + { + velocity.Y *= MathHelper.Lerp(0.9f, 1f, Math.Abs(cosineValue) / 0.35f); + + // Squash the upper part slightly more than the lower part. + if (Math.Sign(cosineValue) == 1f) + { + velocity.Y *= 0.85f; + } + } + + velocity = velocity.RotatedBy(offsetAngle); // Account for the explosion offset angle that was determined at the start. + + Dust dust = Dust.NewDustPerfect(center, 261); + dust.velocity = velocity * appleBurstSpeed; + dust.noGravity = true; + dust.color = Color.Orange; + dust.fadeIn = 1.5f; + } + AppleLeafExplosionDust(center + new Vector2(0f, -54).RotatedBy(offsetAngle), offsetAngle); + } + public void AppleLeafExplosionDust(Vector2 center, float offsetAngle) + { + int evaluationPoints = 40; + + // When mapped out, these points give a rough apple stem shape. + Vector2[] bezierControlPoints = new Vector2[] + { + new Vector2(0f, 0f), + new Vector2(-20f, -26f), + new Vector2(-26f, -46f), + new Vector2(-30f, -60f), + new Vector2(-24f, -70f), + new Vector2(-10f, -40f), + new Vector2(0f, 0f), + }; + BezierCurve bezierCurve = new BezierCurve(bezierControlPoints); + for (int i = 0; i < evaluationPoints; i++) + { + Dust dust = Dust.NewDustPerfect(center, 261); + dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints).RotatedBy(offsetAngle); + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.color = Color.Brown; + dust.fadeIn = 1.5f; + } + } + #endregion + + #region Yellow Mark + public void YellowMarkExplosionDust() + { + // Spawn three butterflies. + ButterflyExplosionDust(projectile.Center, Main.rand.NextFloat(8f, 12f)); + + Vector2 offset = Vector2.UnitY.RotatedBy(Main.rand.NextFloat(0.4f, 0.7f) * -1f) * 120f; + offset += Vector2.UnitX * 84f; + ButterflyExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f)); + + offset = Vector2.UnitY.RotatedBy(Main.rand.NextFloat(0.4f, 0.7f)) * 120f; + offset -= Vector2.UnitX * 84f; + ButterflyExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f)); + } + public void ButterflyExplosionDust(Vector2 center, float butterflyBurstSpeed, float offsetAngle = 0f) + { + int petalCount = 4; + // Draw the butterfly as a petal with 4 sides. + for (float angle = 0f; angle <= MathHelper.TwoPi; angle += MathHelper.ToRadians(4f)) + { + Vector2 initialUnitVector = angle.ToRotationVector2(); + float unitMultiplier = 2f + (1f + (float)Math.Cos(angle * petalCount)); // This value is used to "squash" the circle to make it into a petal shape. + Vector2 velocity = initialUnitVector * unitMultiplier; + velocity = velocity.RotatedBy(MathHelper.PiOver4 + MathHelper.PiOver2); // Tilt the vector to make it look like an actual butterfly. + velocity = velocity.RotatedBy(offsetAngle); + velocity *= 0.25f; // Normalization removes the spaces that make the vector petal-like and not circular, so multiplication must be utilized instead. + + Dust dust = Dust.NewDustPerfect(center, 262); + dust.velocity = velocity * butterflyBurstSpeed; + dust.noGravity = true; + dust.color = Color.Pink; + dust.fadeIn = 1.5f; + } + ButterflyAntennaExplosionDust(center + new Vector2(0f, -74f).RotatedBy(offsetAngle), offsetAngle); + } + public void ButterflyAntennaExplosionDust(Vector2 center, float offsetAngle = 0f) + { + int evaluationPoints = 40; + + // When mapped out, these points give a rough apple stem shape. + Vector2[] bezierControlPoints = new Vector2[] + { + new Vector2(0f, 60f), + new Vector2(0f, 30f), + new Vector2(10f, -28f), + new Vector2(20f, -42f), + new Vector2(30f, -48f), + new Vector2(42f, -40f), + new Vector2(50f, -30f), + new Vector2(52f, -24f), + }; + BezierCurve bezierCurve = new BezierCurve(bezierControlPoints); + for (int i = 0; i < evaluationPoints; i++) + { + Dust dust = Dust.NewDustPerfect(center, 263); + dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints).RotatedBy(offsetAngle); + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.color = Color.SkyBlue; + dust.fadeIn = 1.5f; + + dust = Dust.CloneDust(dust); + dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints).RotatedBy(offsetAngle) * new Vector2(-1f, 1f); + } + } + #endregion + + #region White Mark + public void WhiteMarkExplosionDust() + { + // Spawn three diamonds. + DiamondExplosionDust(projectile.Center, Main.rand.NextFloat(8f, 12f)); + + float absoluteOffsetAngle = Main.rand.NextFloat(0.4f, 0.7f); + Vector2 offset = Vector2.UnitY.RotatedBy(absoluteOffsetAngle * -1f) * 120f; + offset += Vector2.UnitX * 84f; + DiamondExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f)); + + absoluteOffsetAngle = Main.rand.NextFloat(0.4f, 0.7f); + offset = Vector2.UnitY.RotatedBy(absoluteOffsetAngle) * 120f; + offset -= Vector2.UnitX * 84f; + DiamondExplosionDust(projectile.Center + offset, Main.rand.NextFloat(6f, 11f)); + } + public void DiamondExplosionDust(Vector2 center, float diamondBurstSpeed, float offsetAngle = 0f) + { + int dustCount = 80; + for (int i = 0; i < dustCount; i++) + { + Vector2 startingVelocity = Vector2.Zero; + Vector2 endingVelocity = Vector2.Zero; + + switch (i / (dustCount / 4)) + { + case 0: + startingVelocity = Vector2.UnitY; + endingVelocity = Vector2.UnitX; + break; + case 1: + startingVelocity = Vector2.UnitX; + endingVelocity = -Vector2.UnitY; + break; + case 2: + startingVelocity = -Vector2.UnitY; + endingVelocity = -Vector2.UnitX; + break; + case 3: + startingVelocity = -Vector2.UnitX; + endingVelocity = Vector2.UnitY; + break; + } + Vector2 velocity = Vector2.Lerp(startingVelocity, endingVelocity, i / (dustCount / 4f) % 1f); + velocity = velocity.RotatedBy(offsetAngle); + velocity *= diamondBurstSpeed; + velocity.X *= 0.667f; + + Dust dust = Dust.NewDustPerfect(center, 263); + dust.position = center; + dust.velocity = velocity; + dust.noGravity = true; + dust.color = Color.LightSteelBlue; + dust.fadeIn = 1.5f; + } + } + #endregion + + #region Sky Blue Mark + public void SkyBlueMarkExplosionDust() + { + RainbowBoltExplosionDust(projectile.Center, Main.rand.NextFloat(-0.2f, 0.2f)); + } + public void RainbowBoltExplosionDust(Vector2 center, float offsetAngle = 0f) + { + // Spawn several clouds. + for (int i = 0; i < 5; i++) + { + CloudExplosionDust(center, offsetAngle); + } + LightningExplosionDust(center, offsetAngle); + } + public void CloudExplosionDust(Vector2 center, float offsetAngle = 0f) + { + center += Main.rand.NextVector2CircularEdge(40f, 40f); + Vector2 offset = Main.rand.NextVector2Square(0.9f, 1.15f); + for (float angle = 0f; angle <= MathHelper.TwoPi; angle += MathHelper.ToRadians(2f)) + { + Vector2 initialUnitVector = angle.ToRotationVector2(); + Vector2 spawnOffset = initialUnitVector.RotatedBy(offsetAngle); + spawnOffset = spawnOffset.RotatedByRandom(0.4f); + spawnOffset *= new Vector2(54f, 36f) * offset; + + spawnOffset -= Vector2.UnitY.RotatedBy(offsetAngle) * 90f; + + Dust dust = Dust.NewDustPerfect(center + spawnOffset, 263); + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.scale = 2.7f; + dust.fadeIn = 1.5f; + } + } + public void LightningExplosionDust(Vector2 center, float offsetAngle = 0f) + { + int evaluationPoints = 65; + + // When mapped out, these points give a rough (but slightly weird) lightning bolt. + Vector2[] controlPoints = new Vector2[] + { + new Vector2(-38f, -64f), + new Vector2(-42f, -44f), + new Vector2(-26f, -28f), + new Vector2(-24f, -10f), + new Vector2(-34f, -4f), + new Vector2(-48f, -10f), + new Vector2(-40f, 12f), + new Vector2(-30f, 30f), + new Vector2(-20f, 48f), + new Vector2(-8f, 28f), + new Vector2(2f, 6f), + new Vector2(-8f, -4f), + new Vector2(4f, -16f), + new Vector2(8f, -36f), + new Vector2(12f, -56f), + new Vector2(-38f, -64f) + }; + for (int i = 0; i < evaluationPoints; i++) + { + int currentIndex = (int)(i / (float)evaluationPoints * controlPoints.Length); + Vector2 currentPosition = controlPoints[currentIndex]; + Vector2 nextPosition = controlPoints[(currentIndex + 1) % controlPoints.Length]; + + Dust dust = Dust.NewDustPerfect(center, 263); + dust.position = center + Vector2.Lerp(currentPosition, nextPosition, i / (float)evaluationPoints * controlPoints.Length % 0.999f).RotatedBy(offsetAngle) * 2f; + dust.position += Vector2.UnitY.RotatedBy(offsetAngle) * 138f; + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.color = Main.hslToRgb(i / (float)evaluationPoints * 3f % 1f, 0.6f, 0.7f); + dust.scale = 1.4f; + dust.fadeIn = 1.5f; + } + + center += Main.rand.NextVector2CircularEdge(120f, 120f); + Vector2 offset = Main.rand.NextVector2Square(0.9f, 1.15f); + for (float angle = 0f; angle <= MathHelper.TwoPi; angle += MathHelper.ToRadians(2f)) + { + Vector2 initialUnitVector = angle.ToRotationVector2(); + Vector2 spawnOffset = initialUnitVector.RotatedBy(offsetAngle); + spawnOffset = spawnOffset.RotatedByRandom(0.4f); + spawnOffset *= new Vector2(130f, 84f) * offset; + + spawnOffset += Vector2.UnitY.RotatedBy(offsetAngle) * 30f; + + Dust dust = Dust.NewDustPerfect(center + spawnOffset, 263); + dust.velocity = Vector2.Zero; + dust.noGravity = true; + dust.scale = 4f; + dust.fadeIn = 1.5f; + } + } + #endregion + + #region Purple Mark + public void PurpleMarkExplosionDust() + { + TwilightStarExplosionDust(projectile.Center, 14f, Color.Magenta); + for (int i = 0; i < 6; i++) + { + float angle = MathHelper.TwoPi * i / 6f; + Vector2 offset = angle.ToRotationVector2() * Main.rand.NextFloat(140f, 180f); + TwilightStarExplosionDust(projectile.Center + offset, 4f, Color.White, Main.rand.NextFloat(-0.2f, 0.2f)); + } + } + public void TwilightStarExplosionDust(Vector2 center, float petalBurstSpeed, Color starColor, float absoluteOffsetAngle = 0f) + { + int pointsOnStar = 6; + for (int i = 0; i < pointsOnStar; i++) + { + float angle = MathHelper.Pi * 1.5f - i * MathHelper.TwoPi / pointsOnStar; + float nextAngle = MathHelper.Pi * 1.5f - (i + 2) * MathHelper.TwoPi / pointsOnStar; + Vector2 start = angle.ToRotationVector2(); + Vector2 end = nextAngle.ToRotationVector2(); + int pointsOnStarSegment = 35; + for (int j = 0; j < pointsOnStarSegment; j++) + { + Dust dust = Dust.NewDustPerfect(center, 263); + dust.scale = 1.8f; + dust.velocity = Vector2.Lerp(start, end, j / (float)pointsOnStarSegment) * petalBurstSpeed; + dust.velocity.X *= 0.7f; + dust.velocity = dust.velocity.RotatedBy(absoluteOffsetAngle); + dust.fadeIn = 1.5f; + dust.color = starColor; + dust.noGravity = true; + } + } + } + #endregion + + #region Pale Pink Mark + public void PalePinkMarkExplosionDust() + { + StarlightMarkExplosionDust(projectile.Center); + StarlightStarExplosionDust(projectile.Center + new Vector2(16f, 36f), 2f); + } + public void StarlightMarkExplosionDust(Vector2 center) + { + int evaluationPoints = 60; + + // When mapped out, these points give a rough swerving stream shape. + Vector2[] bezierControlPoints = new Vector2[] + { + new Vector2(-38f, -58f), + new Vector2(-22f, -34f), + new Vector2(-10f, -22f), + new Vector2(6f, -11f), + new Vector2(13f, 1f), + new Vector2(-20f, 11f), + new Vector2(16f, 11f), + new Vector2(26f, 6f), + new Vector2(24f, -11f), + new Vector2(8f, -28f), + new Vector2(-10f, -39f), + new Vector2(-38f, -58f) + }; + BezierCurve bezierCurve = new BezierCurve(bezierControlPoints); + + for (int i = 0; i < evaluationPoints; i++) + { + Dust dust = Dust.NewDustPerfect(center, 263); + dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints) * new Vector2(3f, 1.7f); + dust.velocity = Vector2.Zero; + dust.color = i >= evaluationPoints / 2 ? Color.Cyan : Color.SkyBlue; + dust.fadeIn = 1.5f; + dust.scale = 1.4f; + dust.noGravity = true; + + dust = Dust.CloneDust(dust); + dust.position = center + bezierCurve.Evaluate(i / (float)evaluationPoints) * new Vector2(1f, -1f) + new Vector2(30f, -12f); + } + } + public void StarlightStarExplosionDust(Vector2 center, float starBurstSpeed) + { + int dustCount = 60; + for (int i = 0; i < dustCount; i++) + { + Vector2 startingVelocity = Vector2.Zero; + Vector2 endingVelocity = Vector2.Zero; + + switch (i / (dustCount / 4)) + { + case 0: + startingVelocity = Vector2.UnitY; + endingVelocity = Vector2.UnitX; + break; + case 1: + startingVelocity = Vector2.UnitX; + endingVelocity = -Vector2.UnitY; + break; + case 2: + startingVelocity = -Vector2.UnitY; + endingVelocity = -Vector2.UnitX; + break; + case 3: + startingVelocity = -Vector2.UnitX; + endingVelocity = Vector2.UnitY; + break; + } + Vector2 velocity = Vector2.Lerp(startingVelocity, endingVelocity, i / (dustCount / 4f) % 1f); + velocity *= starBurstSpeed; + velocity.X *= 0.75f; + + Dust dust = Dust.NewDustPerfect(center, 263); + dust.position = center; + dust.velocity = velocity; + dust.noGravity = true; + dust.color = Color.Purple; + dust.fadeIn = 1.5f; + + dust = Dust.CloneDust(dust); + dust.velocity = dust.velocity.RotatedBy(MathHelper.PiOver4); + dust.color = Color.White; + } + } + #endregion + } +} diff --git a/Projectiles/Magic/RainbowRocket.png b/Projectiles/Magic/RainbowRocket.png new file mode 100644 index 0000000000..7ff99fa614 Binary files /dev/null and b/Projectiles/Magic/RainbowRocket.png differ diff --git a/Projectiles/Magic/RedirectingFire.cs b/Projectiles/Magic/RedirectingFire.cs new file mode 100644 index 0000000000..d738f7a43a --- /dev/null +++ b/Projectiles/Magic/RedirectingFire.cs @@ -0,0 +1,101 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; + +namespace CalamityMod.Projectiles.Magic +{ + public class RedirectingFire : ModProjectile + { + public ref float BurstIntensity => 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 = 18; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + if (Time >= 18f) + { + NPC potentialTarget = projectile.Center.ClosestNPCAt(1100f, false); + if (potentialTarget != null) + HomeInOnTarget(potentialTarget); + + float accelerationFactor = MathHelper.SmoothStep(1.025f, 1.015f, Utils.InverseLerp(6f, 24f, projectile.velocity.Length(), true)); + if (projectile.velocity.Length() < 24f) + projectile.velocity *= accelerationFactor; + } + EmitDust(); + Time++; + } + + public void HomeInOnTarget(NPC target) + { + float oldSpeed = projectile.velocity.Length(); + float delayFactor = Utils.InverseLerp(20f, 35f, Time, true); + float homeSpeed = MathHelper.Lerp(0f, 0.075f, delayFactor); + + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(target.Center) * 16f, homeSpeed); + projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * oldSpeed; + projectile.position += (target.Center - projectile.Center).SafeNormalize(Vector2.Zero) * MathHelper.Lerp(25f, 1f, Utils.InverseLerp(100f, 360f, projectile.Distance(target.Center), true)) * delayFactor; + } + + public Dust CreateDustInstance() + { + int dustType = 264; + + Color brimstoneColor = Color.Lerp(Color.Red, Color.DarkViolet, (float)Math.Sin(projectile.identity * 3f + Time / 12f) * 0.7f + 0.3f); + Color dustColor = Color.Lerp(Color.Orange, Color.Yellow, Main.rand.NextFloat()); + dustColor = Color.Lerp(dustColor, brimstoneColor, (float)Math.Pow(BurstIntensity, 2D)); + + Dust dust = Dust.NewDustPerfect(projectile.Center, dustType); + dust.color = dustColor; + dust.noGravity = true; + dust.noLight = true; + return dust; + } + + public void EmitDust() + { + if (Main.dedServ) + return; + + for (int i = 0; i < 5; i++) + { + Dust dust = CreateDustInstance(); + dust.velocity = (MathHelper.TwoPi * i / 5f).ToRotationVector2(); + dust.position += projectile.velocity; + dust.scale = MathHelper.Lerp(1f, 1.5f, BurstIntensity) * Main.rand.NextFloat(0.7f, 1.3f); + } + } + + public override void Kill(int timeLeft) + { + // Emit some fire sounds. + Main.PlaySound(SoundID.Item34, projectile.Center); + if (Main.dedServ) + return; + + for (int i = 0; i < 15; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(30f, 30f) * BurstIntensity, 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); + ectoplasm.color = Color.Lerp(Color.Orange, Color.Yellow, Main.rand.NextFloat(0.67f)); + ectoplasm.scale = MathHelper.Lerp(1f, 1.6f, BurstIntensity); + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Magic/RedirectingGildedSoul.cs b/Projectiles/Magic/RedirectingGildedSoul.cs new file mode 100644 index 0000000000..d54269ddb3 --- /dev/null +++ b/Projectiles/Magic/RedirectingGildedSoul.cs @@ -0,0 +1,87 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RedirectingGildedSoul : ModProjectile + { + public ref float BurstIntensity => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gilded Soul"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.scale = 0.6f; + projectile.width = projectile.height = 32; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() => RedirectingVengefulSoul.DoSoulAI(projectile, ref Time, 5f); + + public override Color? GetAlpha(Color lightColor) + { + Color baseColor = Color.Lerp(Color.DarkGoldenrod, Color.Gold, projectile.identity % 5f / 5f); + Color color = Color.Lerp(baseColor, Color.White, BurstIntensity * 0.5f + (float)Math.Cos(Main.GlobalTime * 2.7f) * 0.04f); + color.A = 127; + return color * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < projectile.oldPos.Length / 2; j++) + { + Color drawColor = projectile.GetAlpha(lightColor); + drawColor = Color.Lerp(drawColor, Color.White * projectile.Opacity, 2f * j / projectile.oldPos.Length) * (float)Math.Pow(1f - Utils.InverseLerp(0f, projectile.oldPos.Length / 2, j, true), 2D); + Vector2 drawPosition = projectile.oldPos[j] + projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 0.5f - Main.screenPosition; + float rotation = projectile.oldRot[j]; + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + } + + return false; + } + + public override void Kill(int timeLeft) + { + // Play a wraith death sound at max intensity and a dungeon spirit hit sound otherwise. + Main.PlaySound(BurstIntensity >= 1f ? SoundID.NPCDeath52 : SoundID.NPCHit35, projectile.Center); + + // As well as an "extinguished" sound. + Main.PlaySound(SoundID.NPCDeath55, projectile.Center); + + // Make a ghost sound and explode into ectoplasmic energy. + if (Main.dedServ) + return; + + for (int i = 0; i < 45; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(80f, 80f) * (float)Math.Pow(BurstIntensity, 2D), 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = MathHelper.Lerp(1f, 1.6f, BurstIntensity); + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Magic/RedirectingGildedSoul.png b/Projectiles/Magic/RedirectingGildedSoul.png new file mode 100644 index 0000000000..ecffa8c8a3 Binary files /dev/null and b/Projectiles/Magic/RedirectingGildedSoul.png differ diff --git a/Projectiles/Magic/RedirectingLostSoul.cs b/Projectiles/Magic/RedirectingLostSoul.cs new file mode 100644 index 0000000000..d11a8cf8a8 --- /dev/null +++ b/Projectiles/Magic/RedirectingLostSoul.cs @@ -0,0 +1,81 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RedirectingLostSoul : ModProjectile + { + public ref float BurstIntensity => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 32; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() => RedirectingVengefulSoul.DoSoulAI(projectile, ref Time, 1f); + + public override Color? GetAlpha(Color lightColor) + { + Color baseColor = Color.Lerp(Color.DarkRed, Color.DarkViolet, projectile.identity % 5f / 5f * 0.5f); + Color color = Color.Lerp(baseColor, Color.White, BurstIntensity * 0.5f + (float)Math.Cos(Main.GlobalTime * 2.7f) * 0.04f); + color.A = 0; + return color * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + + for (int j = 0; j < projectile.oldPos.Length / 2; j++) + { + float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, projectile.oldPos.Length / 2, j, true), 2D); + Color drawColor = projectile.GetAlpha(lightColor) * fade; + Vector2 drawPosition = projectile.oldPos[j] + projectile.Size * 0.5f - Main.screenPosition; + float rotation = projectile.oldRot[j]; + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + + return false; + } + + public override void Kill(int timeLeft) + { + // Play a wraith death sound at max intensity and a dungeon spirit hit sound otherwise. + Main.PlaySound(BurstIntensity >= 1f ? SoundID.NPCDeath52 : SoundID.NPCHit35, projectile.Center); + + // Make a ghost sound and explode into ectoplasmic energy. + if (Main.dedServ) + return; + + for (int i = 0; i < 45; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(50f, 50f) * BurstIntensity, 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = MathHelper.Lerp(1f, 1.6f, BurstIntensity); + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Magic/RedirectingLostSoul.png b/Projectiles/Magic/RedirectingLostSoul.png new file mode 100644 index 0000000000..f02bca1221 Binary files /dev/null and b/Projectiles/Magic/RedirectingLostSoul.png differ diff --git a/Projectiles/Magic/RedirectingVengefulSoul.cs b/Projectiles/Magic/RedirectingVengefulSoul.cs new file mode 100644 index 0000000000..fd9ce2250c --- /dev/null +++ b/Projectiles/Magic/RedirectingVengefulSoul.cs @@ -0,0 +1,126 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class RedirectingVengefulSoul : ModProjectile + { + public ref float BurstIntensity => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.scale = 0.8f; + projectile.width = projectile.height = 46; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() => DoSoulAI(projectile, ref Time, 2f); + + public static void DoSoulAI(Projectile projectile, ref float time, float soulPower) + { + if (time >= 20f) + { + NPC potentialTarget = projectile.Center.ClosestNPCAt(1250f, false); + if (potentialTarget != null) + HomeInOnTarget(projectile, potentialTarget, time); + + float accelerationFactor = MathHelper.SmoothStep(1.03f, 1.015f, Utils.InverseLerp(6f, 24f, projectile.velocity.Length(), true)); + if (projectile.velocity.Length() < 21f + soulPower * 2f) + projectile.velocity *= accelerationFactor; + } + projectile.Opacity = Utils.InverseLerp(0f, 15f, time, true); + projectile.frameCounter++; + if (projectile.frameCounter % 5f == 4f) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + + projectile.rotation = projectile.velocity.ToRotation(); + projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); + if (projectile.spriteDirection == -1) + projectile.rotation += MathHelper.Pi; + + time++; + } + + public static void HomeInOnTarget(Projectile projectile, NPC target, float time) + { + float oldSpeed = projectile.velocity.Length(); + float delayFactor = Utils.InverseLerp(20f, 35f, time, true); + float homeSpeed = MathHelper.Lerp(0f, 0.075f, delayFactor); + + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(target.Center) * 16f, homeSpeed); + projectile.velocity = (projectile.velocity + projectile.SafeDirectionTo(target.Center) * 3f).SafeNormalize(Vector2.UnitY) * oldSpeed; + } + + public override Color? GetAlpha(Color lightColor) + { + Color baseColor = Color.Lerp(Color.IndianRed, Color.DarkViolet, projectile.identity % 5f / 5f * 0.5f); + Color color = Color.Lerp(baseColor * 1.5f, baseColor, BurstIntensity * 0.5f + (float)Math.Cos(Main.GlobalTime * 2.7f) * 0.04f); + color.A = 0; + return color * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < projectile.oldPos.Length / 2; j++) + { + float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, projectile.oldPos.Length / 2, j, true), 2D); + Color drawColor = Color.Lerp(projectile.GetAlpha(lightColor), Color.White * projectile.Opacity, j / projectile.oldPos.Length) * fade; + Vector2 drawPosition = projectile.oldPos[j] + projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 1.5f - Main.screenPosition; + float rotation = projectile.oldRot[j]; + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + } + + return false; + } + + public override void Kill(int timeLeft) + { + // Play a wraith death sound at max intensity and a dungeon spirit hit sound otherwise. + Main.PlaySound(BurstIntensity >= 1f ? SoundID.NPCDeath52 : SoundID.NPCHit35, projectile.Center); + + // Make a ghost sound and explode into ectoplasmic energy. + if (Main.dedServ) + return; + + for (int i = 0; i < 45; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(100f, 100f) * (float)Math.Pow(BurstIntensity, 2D), 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = MathHelper.Lerp(1.2f, 1.9f, BurstIntensity); + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + + ectoplasm = Dust.NewDustPerfect(projectile.Center, 264); + ectoplasm.velocity = (MathHelper.TwoPi * i / 45f).ToRotationVector2() * 6f; + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = MathHelper.Lerp(1.2f, 1.9f, BurstIntensity); + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Magic/RedirectingVengefulSoul.png b/Projectiles/Magic/RedirectingVengefulSoul.png new file mode 100644 index 0000000000..3e0e4507b7 Binary files /dev/null and b/Projectiles/Magic/RedirectingVengefulSoul.png differ diff --git a/Projectiles/Magic/Shadowbolt.cs b/Projectiles/Magic/Shadowbolt.cs index 77bbc6fea5..2c64a9c432 100644 --- a/Projectiles/Magic/Shadowbolt.cs +++ b/Projectiles/Magic/Shadowbolt.cs @@ -38,7 +38,6 @@ namespace CalamityMod.Projectiles.Magic } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Magic/SlitheringEelBody.png b/Projectiles/Magic/SlitheringEelBody.png new file mode 100644 index 0000000000..0ceb4bf20e Binary files /dev/null and b/Projectiles/Magic/SlitheringEelBody.png differ diff --git a/Projectiles/Magic/SlitheringEelBody2.png b/Projectiles/Magic/SlitheringEelBody2.png new file mode 100644 index 0000000000..9ca8b31166 Binary files /dev/null and b/Projectiles/Magic/SlitheringEelBody2.png differ diff --git a/Projectiles/Magic/SlitheringEelProjectile.cs b/Projectiles/Magic/SlitheringEelProjectile.cs index 3627b8f9d9..52ee1e6edc 100644 --- a/Projectiles/Magic/SlitheringEelProjectile.cs +++ b/Projectiles/Magic/SlitheringEelProjectile.cs @@ -10,10 +10,22 @@ namespace CalamityMod.Projectiles.Magic { public class SlitheringEelProjectile : ModProjectile { + public struct EelSegment + { + public Vector2 CurrentPosition; + public float Rotation; + public EelSegment(Vector2 position, float rotation) + { + CurrentPosition = position; + Rotation = rotation; + } + } + + public EelSegment[] Segments = new EelSegment[10]; + public override void SetStaticDefaults() { DisplayName.SetDefault("Eel"); - Main.projFrames[projectile.type] = 4; ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } @@ -28,67 +40,115 @@ namespace CalamityMod.Projectiles.Magic projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 360; - projectile.alpha = 0; + projectile.Opacity = 0f; } public override void AI() { - if (projectile.frameCounter++ % 8f == 7f) - { - projectile.frame++; - } - if (projectile.frame >= Main.projFrames[projectile.type]) - { - projectile.frame = 0; - } projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); - projectile.rotation = (projectile.spriteDirection * projectile.velocity).ToRotation(); - if (projectile.ai[0] >= 3f) + projectile.rotation = projectile.velocity.ToRotation(); + if (projectile.numHits >= 3f) { projectile.alpha += 5; if (projectile.alpha >= 255) - { projectile.Kill(); - } } + else + projectile.Opacity = MathHelper.Clamp(projectile.Opacity + 0.1f, 0f, 1f); + if (projectile.timeLeft % 80f < 35f && projectile.Distance(Main.MouseWorld) > 70f) { float angleToTarget = projectile.AngleTo(Main.MouseWorld); float angleDifference = MathHelper.WrapAngle(angleToTarget - projectile.velocity.ToRotation()); projectile.velocity = projectile.velocity.RotatedBy(angleDifference / 9f); } + if (projectile.timeLeft % 65f == 64f) - { Projectile.NewProjectile(projectile.Center, Vector2.UnitY * 7f, ModContent.ProjectileType(), projectile.damage / 2, 2f, projectile.owner); + + UpdateSegments(); + } + + public void UpdateSegments() + { + Vector2 aheadPosition = projectile.Center; + float aheadRotation = projectile.rotation; + + // Connect all segments to each-other and calculate their rotations. + for (int i = 0; i < Segments.Length; i++) + { + Vector2 offsetToDestination = aheadPosition - Segments[i].CurrentPosition; + + // This variant of segment attachment incorporates rotation. + // Given the fact that all segments will execute this code is succession, the + // result across the entire worm will exponentially decay over each segment, + // allowing for smooth rotations. This code is what the stardust dragon uses for its segmenting. + if (aheadRotation != projectile.rotation) + { + float offsetAngle = MathHelper.WrapAngle(aheadRotation - projectile.rotation) * 0.03f; + offsetToDestination = offsetToDestination.RotatedBy(offsetAngle); + } + Segments[i].Rotation = (aheadPosition - Segments[i].CurrentPosition).ToRotation(); + Segments[i].CurrentPosition = aheadPosition - offsetToDestination.SafeNormalize(Vector2.UnitY) * 13f; + + // Adjust the ahead positions before interating further. + aheadPosition = Segments[i].CurrentPosition; + aheadRotation = Segments[i].Rotation; } } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], new Color(255, 255, 255, 127), 1); + Texture2D headTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SlitheringEelProjectile"); + Texture2D bodyTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SlitheringEelBody"); + Texture2D bodyTexture2 = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SlitheringEelBody2"); + Texture2D tailTexture = ModContent.GetTexture("CalamityMod/Projectiles/Magic/SlitheringEelTail"); + + Vector2 drawPosition; + lightColor = new Color(255, 255, 255, 127); + for (int i = 0; i < Segments.Length; i++) + { + Texture2D textureToUse = i % 2 == 1 ? bodyTexture2 : bodyTexture; + + // Use the tail texture for the last segment. + if (i == Segments.Length - 1) + textureToUse = tailTexture; + + drawPosition = Segments[i].CurrentPosition - Main.screenPosition; + spriteBatch.Draw(textureToUse, drawPosition, null, projectile.GetAlpha(lightColor), Segments[i].Rotation, textureToUse.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + + drawPosition = projectile.Center - Main.screenPosition; + spriteBatch.Draw(headTexture, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, headTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); return false; } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + for (int i = 0; i < Segments.Length; i++) + { + if (targetHitbox.Intersects(Utils.CenteredRectangle(Segments[i].CurrentPosition, Vector2.One * 12f))) + return true; + } + return null; + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - projectile.ai[0]++; target.AddBuff(BuffID.Venom, 180); target.AddBuff(ModContent.BuffType(), 180); } public override void OnHitPvp(Player target, int damage, bool crit) { - projectile.ai[0]++; target.AddBuff(BuffID.Venom, 180); target.AddBuff(ModContent.BuffType(), 180); } public override void Kill(int timeLeft) { - for (int dust = 0; dust <= 22; dust++) - { + for (int i = 0; i < 23; i++) Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f); - } } } } diff --git a/Projectiles/Magic/SlitheringEelProjectile.png b/Projectiles/Magic/SlitheringEelProjectile.png index f7ccfeee32..fa25c2a990 100644 Binary files a/Projectiles/Magic/SlitheringEelProjectile.png and b/Projectiles/Magic/SlitheringEelProjectile.png differ diff --git a/Projectiles/Magic/SlitheringEelTail.png b/Projectiles/Magic/SlitheringEelTail.png new file mode 100644 index 0000000000..fbdcd3a789 Binary files /dev/null and b/Projectiles/Magic/SlitheringEelTail.png differ diff --git a/Projectiles/Magic/Snowball.cs b/Projectiles/Magic/Snowball.cs index 05998e9994..1a2df63425 100644 --- a/Projectiles/Magic/Snowball.cs +++ b/Projectiles/Magic/Snowball.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 60); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Magic/SolarBeam2.cs b/Projectiles/Magic/SolarBeam2.cs index a20626f7e0..1c0bc2704e 100644 --- a/Projectiles/Magic/SolarBeam2.cs +++ b/Projectiles/Magic/SolarBeam2.cs @@ -33,7 +33,6 @@ namespace CalamityMod.Projectiles.Magic } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Magic/SolarElementalBeam.cs b/Projectiles/Magic/SolarElementalBeam.cs new file mode 100644 index 0000000000..bce85a1d74 --- /dev/null +++ b/Projectiles/Magic/SolarElementalBeam.cs @@ -0,0 +1,80 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SolarElementalBeam : BaseLaserbeamProjectile + { + public override float MaxScale => 1f; + public override float MaxLaserLength => 1000f; + public override float Lifetime => 30f; + 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"); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 20; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 13; + projectile.tileCollide = false; + projectile.timeLeft = (int)Lifetime; + } + + public override void ExtraBehavior() + { + // Generate a star-like burst of solar fire dust. + if (!Main.dedServ && Time == 5f) + { + int starPoints = 8; + for (int i = 0; i < starPoints; i++) + { + float angle = MathHelper.TwoPi * i / starPoints; + for (int j = 0; j < 12; j++) + { + float starSpeed = MathHelper.Lerp(2f, 10f, j / 12f); + Color dustColor = Color.Lerp(Color.White, Color.Yellow, j / 12f); + float dustScale = MathHelper.Lerp(1.6f, 0.85f, j / 12f); + + Dust fire = Dust.NewDustPerfect(projectile.Center, 6); + fire.velocity = angle.ToRotationVector2() * starSpeed; + fire.color = dustColor; + fire.scale = dustScale; + fire.noGravity = true; + } + } + } + } + + public override void DetermineScale() => projectile.scale = projectile.timeLeft / Lifetime * MaxScale; + + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + DrawBeamWithColor(spriteBatch, Color.Lerp(Color.OrangeRed, Color.Transparent, 0.25f), projectile.scale); + DrawBeamWithColor(spriteBatch, Color.Lerp(Color.Yellow * 1.1f, Color.Transparent, 0.25f), projectile.scale * 0.4f); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + int type = ModContent.ProjectileType(); + int boomDamage = (int)(damage * 1.1); + int boom = Projectile.NewProjectile(target.Center, Vector2.Zero, type, boomDamage, knockback, projectile.owner, 0f, Main.rand.NextFloat(0.85f, 2f)); + Main.projectile[boom].Calamity().forceMagic = true; + } + } +} diff --git a/Projectiles/Magic/SolarElementalBeam.png b/Projectiles/Magic/SolarElementalBeam.png new file mode 100644 index 0000000000..15e8775737 Binary files /dev/null and b/Projectiles/Magic/SolarElementalBeam.png differ diff --git a/Projectiles/Magic/SoulPiercerBeam.cs b/Projectiles/Magic/SoulPiercerBeam.cs index 970eb0e6ae..28c5c238ee 100644 --- a/Projectiles/Magic/SoulPiercerBeam.cs +++ b/Projectiles/Magic/SoulPiercerBeam.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 100; projectile.timeLeft = 240; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Magic/SoulPiercerBolt.cs b/Projectiles/Magic/SoulPiercerBolt.cs index 7710c31637..7bf3fa417e 100644 --- a/Projectiles/Magic/SoulPiercerBolt.cs +++ b/Projectiles/Magic/SoulPiercerBolt.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.extraUpdates = 100; projectile.friendly = true; - projectile.timeLeft = 180; + projectile.ignoreWater = true; + projectile.timeLeft = 180; projectile.penetrate = -1; projectile.magic = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Magic/StardustElementalBeam.cs b/Projectiles/Magic/StardustElementalBeam.cs new file mode 100644 index 0000000000..7fe2f9350d --- /dev/null +++ b/Projectiles/Magic/StardustElementalBeam.cs @@ -0,0 +1,85 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class StardustElementalBeam : BaseLaserbeamProjectile + { + public override float MaxScale => 0.85f; + public override float MaxLaserLength => 1000f; + public override float Lifetime => 30f; + 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"); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 20; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = 10; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 13; + projectile.tileCollide = false; + projectile.timeLeft = (int)Lifetime; + } + + public override void ExtraBehavior() + { + // Generate 2 stars from the side. + if (Main.myPlayer == projectile.owner && Time == 5f) + { + int type = ModContent.ProjectileType(); + + int damage = (int)(projectile.damage * 0.75); + for (int i = 0; i < 2; i++) + { + Vector2 starSpeed = projectile.velocity.RotatedBy(MathHelper.PiOver2 * i) * 5f; + Projectile.NewProjectile(projectile.Center, starSpeed, type, damage, projectile.knockBack, projectile.owner); + } + } + } + + public override void DetermineScale() => projectile.scale = projectile.timeLeft / Lifetime * MaxScale; + + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + DrawBeamWithColor(spriteBatch, Color.Lerp(Color.CornflowerBlue * 1.1f, Color.Transparent, 0.3f), projectile.scale); + DrawBeamWithColor(spriteBatch, Color.Lerp(Color.Cyan, Color.Transparent, 0.3f), projectile.scale * 0.5f); + DrawBeamWithColor(spriteBatch, Color.Lerp(Color.White, Color.Transparent, 0.3f), projectile.scale * 0.2f); + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + // Inflict the celled debuff for 3 seconds. + target.AddBuff(BuffID.StardustMinionBleed, 180); + + if (!Main.rand.NextBool(7)) + return; + + float spawnOffsetSpread = Main.rand.NextFloat(MathHelper.ToRadians(36f), MathHelper.ToRadians(64f)); + float baseOffsetAngle = Main.rand.NextFloat(-0.6f, 0.6f); + 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/StardustElementalBeam.png b/Projectiles/Magic/StardustElementalBeam.png new file mode 100644 index 0000000000..15e8775737 Binary files /dev/null and b/Projectiles/Magic/StardustElementalBeam.png differ diff --git a/Projectiles/Magic/TerraBeam.cs b/Projectiles/Magic/TerraBeam.cs index c3ac4dce4b..6c3b4bbba7 100644 --- a/Projectiles/Magic/TerraBeam.cs +++ b/Projectiles/Magic/TerraBeam.cs @@ -1,55 +1,118 @@ +using CalamityMod.Projectiles.BaseProjectiles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Magic { - public class TerraBeam : ModProjectile + public class TerraBeam : BaseLaserbeamProjectile { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override float MaxScale => 1f; + public override float MaxLaserLength => 1200f; + public override float Lifetime => 30f; + 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"); + public ref float ShardCooldown => ref projectile.ai[1]; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { - DisplayName.SetDefault("Bolt"); + DisplayName.SetDefault("Beam"); } public override void SetDefaults() { - projectile.width = 4; - projectile.height = 4; + projectile.width = projectile.height = 20; projectile.friendly = true; projectile.magic = true; + projectile.ignoreWater = true; projectile.penetrate = 10; - projectile.extraUpdates = 100; - projectile.timeLeft = 150; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + projectile.tileCollide = false; + projectile.timeLeft = (int)Lifetime; } - public override void AI() - { - projectile.localAI[1] += 1f; - if (projectile.localAI[1] >= 21f && projectile.owner == Main.myPlayer) - { - projectile.localAI[1] = 0f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), projectile.knockBack, projectile.owner, 0f, 0f); - } - - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 9f) - { - for (int num447 = 0; num447 < 3; num447++) + 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++) { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * ((float)num447 * 0.25f); - int num448 = Dust.NewDust(vector33, 1, 1, 107, 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; - } + float angle = MathHelper.TwoPi * i / starPoints; + for (int j = 0; j < 12; j++) + { + float starSpeed = MathHelper.Lerp(1f, 7f, j / 12f); + Color dustColor = Color.Lerp(Color.White, Color.YellowGreen, j / 12f); + float dustScale = MathHelper.Lerp(1.6f, 0.85f, j / 12f); + + Dust terraMagic = Dust.NewDustPerfect(projectile.Center, 107); + terraMagic.velocity = angle.ToRotationVector2() * starSpeed; + terraMagic.color = dustColor; + terraMagic.scale = dustScale; + terraMagic.noGravity = true; + } + } + + 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; + terraMagic.scale = 1.1f; + terraMagic.noGravity = true; + } } + + if (ShardCooldown > 0f) + ShardCooldown--; } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; + 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) + { + if (ShardCooldown > 0f) + return; + + // The "Center" of the laser is actually the start of it in this context. + // Collision is done separately. This might have a slight offset due to collision + // boxes, but that should be negligible. + float lengthFromStart = projectile.Distance(target.Center); + + int totalShards = (int)MathHelper.Lerp(1, 4, MathHelper.Clamp(lengthFromStart / MaxLaserLength * 1.4f, 0f, 1f)); + int shardType = ModContent.ProjectileType(); + int shardDamage = (int)(damage * 0.6); + for (int i = 0; i < totalShards; i++) + { + int tries = 0; + Vector2 spawnOffset; + do + { + spawnOffset = Main.rand.NextVector2CircularEdge(target.width * 0.5f + 40f, target.height * 0.5f + 40f); + tries++; + } + while (Collision.SolidCollision((target.Center + spawnOffset).ToTileCoordinates().ToVector2(), 4, 4) && tries < 10); + + Projectile.NewProjectile(target.Center + spawnOffset, Main.rand.NextVector2CircularEdge(6f, 6f), shardType, shardDamage, knockback); + } + + ShardCooldown = 3f; + projectile.netUpdate = true; } - } + } } diff --git a/Projectiles/Magic/TerraBolt.cs b/Projectiles/Magic/TerraBolt.cs deleted file mode 100644 index d967c411f7..0000000000 --- a/Projectiles/Magic/TerraBolt.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class TerraBolt : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bolt"); - } - - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.extraUpdates = 100; - projectile.friendly = true; - projectile.timeLeft = 30; - projectile.magic = true; - } - - public override void AI() - { - projectile.localAI[1] += 1f; - if (projectile.localAI[1] >= 29f && projectile.owner == Main.myPlayer) - { - projectile.localAI[1] = 0f; - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)(projectile.damage * 0.7), 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, 107, 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 OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - } - } -} diff --git a/Projectiles/Magic/TerraBolt2.cs b/Projectiles/Magic/TerraBolt2.cs deleted file mode 100644 index 832ab91c3a..0000000000 --- a/Projectiles/Magic/TerraBolt2.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class TerraBolt2 : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bolt"); - } - - public override void SetDefaults() - { - projectile.width = 4; - projectile.height = 4; - projectile.extraUpdates = 100; - projectile.friendly = true; - projectile.timeLeft = 15; - projectile.magic = true; - } - - public override void AI() - { - Vector2 vector33 = projectile.position; - vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 107, 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 OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - } - } -} diff --git a/Projectiles/Magic/TerraOrb.cs b/Projectiles/Magic/TerraOrb.cs deleted file mode 100644 index 2dd2195cb5..0000000000 --- a/Projectiles/Magic/TerraOrb.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class TerraOrb : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bolt"); - } - - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.timeLeft = 30; - projectile.magic = true; - } - - public override void AI() - { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 24f, 5, ModContent.ProjectileType()); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - } - } -} diff --git a/Projectiles/Magic/TerraOrb2.cs b/Projectiles/Magic/TerraOrb2.cs deleted file mode 100644 index cdc14d89a7..0000000000 --- a/Projectiles/Magic/TerraOrb2.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Terraria; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Magic -{ - public class TerraOrb2 : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Bolt"); - } - - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.timeLeft = 30; - projectile.magic = true; - } - - public override void AI() - { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 300f, 6f, 18f, 5, ModContent.ProjectileType()); - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.immune[projectile.owner] = 8; - } - } -} diff --git a/Projectiles/Magic/TerraShard.cs b/Projectiles/Magic/TerraShard.cs new file mode 100644 index 0000000000..cad86ae092 --- /dev/null +++ b/Projectiles/Magic/TerraShard.cs @@ -0,0 +1,35 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Magic +{ + public class TerraShard : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shard"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 20; + projectile.friendly = true; + projectile.timeLeft = 60; + projectile.penetrate = 1; + projectile.magic = true; + projectile.tileCollide = true; + } + + public override void AI() + { + for (int i = 0; i < 4; i++) + { + Dust terraMagic = Dust.NewDustDirect(projectile.Center, 1, 1, 107, 0f, 0f, 0, default, 0.5f); + terraMagic.scale = 0.42f; + terraMagic.velocity *= 0.1f; + } + + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 500f, 15f, 20f); + } + } +} diff --git a/Projectiles/Magic/TerraShard.png b/Projectiles/Magic/TerraShard.png new file mode 100644 index 0000000000..15e8775737 Binary files /dev/null and b/Projectiles/Magic/TerraShard.png differ diff --git a/Projectiles/Magic/TradewindsProjectile.cs b/Projectiles/Magic/TradewindsProjectile.cs index 26ab9a638d..52258a4191 100644 --- a/Projectiles/Magic/TradewindsProjectile.cs +++ b/Projectiles/Magic/TradewindsProjectile.cs @@ -44,7 +44,6 @@ namespace CalamityMod.Projectiles.Magic } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Magic/TridentIcicle.cs b/Projectiles/Magic/TridentIcicle.cs index 07105d3404..65db139c17 100644 --- a/Projectiles/Magic/TridentIcicle.cs +++ b/Projectiles/Magic/TridentIcicle.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Projectiles.Magic public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 480); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 60); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Magic/Vehemence.cs b/Projectiles/Magic/Vehemence.cs index 2b8439f6b7..875d18a6a5 100644 --- a/Projectiles/Magic/Vehemence.cs +++ b/Projectiles/Magic/Vehemence.cs @@ -1,3 +1,6 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -9,6 +12,8 @@ namespace CalamityMod.Projectiles.Magic { public class Vehemence : ModProjectile { + public ref float Time => ref projectile.ai[0]; + public Player Owner => Main.player[projectile.owner]; public override void SetStaticDefaults() { DisplayName.SetDefault("Vehemence"); @@ -18,8 +23,7 @@ namespace CalamityMod.Projectiles.Magic public override void SetDefaults() { - projectile.width = 26; - projectile.height = 26; + projectile.width = projectile.height = 26; projectile.friendly = true; projectile.ignoreWater = true; projectile.penetrate = 1; @@ -31,49 +35,98 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - Lighting.AddLight(projectile.Center, 0.45f, 0f, 0.45f); - for (int num457 = 0; num457 < 2; num457++) + Lighting.AddLight(projectile.Center, Color.DarkRed.ToVector3()); + + if (Time == 0f) + GenerateInitialBurstDust(); + + GenerateHelicalDust(); + Time++; + } + + private void GenerateInitialBurstDust() + { + if (Main.dedServ) + return; + + for (int i = 0; i < 40; i++) { - int num458 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 65, 0f, 0f, 100, default, 2f); - Main.dust[num458].noGravity = true; - Main.dust[num458].velocity *= 0.15f; - Main.dust[num458].velocity += projectile.velocity * 0.1f; + float angle = MathHelper.TwoPi * i / 40f; + + Dust brimstoneMagic = Dust.NewDustPerfect(projectile.Center + projectile.velocity * 7f, 27); + brimstoneMagic.velocity = angle.ToRotationVector2() * 15f; + brimstoneMagic.color = Color.Lerp(Color.Red, Color.MediumPurple, (float)Math.Sin(angle) * 0.5f + 0.5f); + brimstoneMagic.scale = 1.6f; + brimstoneMagic.noGravity = true; + } + } + + private void GenerateHelicalDust() + { + if (Main.dedServ) + return; + + // Helical brimstone dust from the back of the projectile. + for (int i = -1; i <= 1; i += 2) + { + float helixOffset = (float)Math.Sin(Time / 45f * MathHelper.TwoPi) * 11f * i; + Vector2 spawnOffset = new Vector2(helixOffset, -28f).RotatedBy(projectile.rotation); + + Dust brimstoneMagic = Dust.NewDustPerfect(projectile.Center + spawnOffset, (int)CalamityDusts.Brimstone); + brimstoneMagic.velocity = Vector2.Zero; + brimstoneMagic.scale = 1.1f; + brimstoneMagic.noGravity = true; } } public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item74, projectile.position); - for (int j = 0; j <= 25; j++) + if (Main.myPlayer == projectile.owner) { - int num459 = Dust.NewDust(projectile.position, projectile.width, projectile.height, 65, 0f, 0f, 100, default, 1f); - Main.dust[num459].noGravity = true; - Main.dust[num459].velocity *= 0.1f; + int damage = (int)(Vehemenc.VehemenceSkullDamage * Owner.MagicDamage()); + for (int i = 0; i < 18; i++) + Projectile.NewProjectile(projectile.Center, Main.rand.NextVector2Circular(12f, 12f), ModContent.ProjectileType(), damage, projectile.knockBack, projectile.owner); + } + + if (!Main.dedServ) + { + for (int i = 0; i < 20; i++) + { + for (int j = 0; j < 4; j++) + { + Vector2 shootVelocity = projectile.velocity.RotatedBy(MathHelper.Lerp(-0.35f, 0.35f, j / 4f)) * Main.rand.NextFloat(0.75f, 1.1f); + Vector2 spawnPosition = projectile.Center + shootVelocity.SafeNormalize(Vector2.Zero) * 10f; + + Dust blood = Dust.NewDustPerfect(spawnPosition, DustID.Blood); + blood.velocity = shootVelocity; + blood.scale = MathHelper.Lerp(1.7f, 0.85f, i / 20f); + } + } + for (int i = 0; i < 60; i++) + { + Dust brimstoneMagic = Dust.NewDustPerfect(projectile.Center, Main.rand.NextBool(2) ? (int)CalamityDusts.Brimstone : 27); + brimstoneMagic.velocity = Main.rand.NextVector2Circular(18f, 18f); + brimstoneMagic.scale = 1.7f; + brimstoneMagic.noGravity = true; + } } } public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - double lifeAmount = (double)target.life; - double lifeMax = (double)target.lifeMax; - double damageMult = lifeAmount / lifeMax * 7; - damage = (int)Math.Pow(damage, damageMult); - if (damage > 1000000) - { - damage = 1000000; - } + double lifeAmount = target.life; + double lifeMax = target.lifeMax; + double damageExponent = lifeAmount / lifeMax * 7; + damage = (int)Math.Pow(damage, damageExponent); + if (damage > 200000) + damage = 200000; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { if (target.life == target.lifeMax) - { - target.AddBuff(BuffID.ShadowFlame, 12000); - target.AddBuff(BuffID.Ichor, 12000); - target.AddBuff(BuffID.Frostburn, 12000); - target.AddBuff(BuffID.OnFire, 12000); - target.AddBuff(BuffID.Poisoned, 12000); - } + target.AddBuff(ModContent.BuffType(), 18000); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Magic/VehemenceHoldout.cs b/Projectiles/Magic/VehemenceHoldout.cs new file mode 100644 index 0000000000..9052a882ed --- /dev/null +++ b/Projectiles/Magic/VehemenceHoldout.cs @@ -0,0 +1,93 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class VehemenceHoldout : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[0]; + + public const int ChargeTime = 90; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Vehemence"); + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 96; + projectile.friendly = false; + projectile.magic = false; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = ChargeTime + 1; + } + + public override void AI() + { + UpdatePlayerVisuals(); + if (Time == ChargeTime) + ShootBolt(); + else if (Time < ChargeTime) + CreateChargeDust(); + + Time++; + + if (Main.mouseLeftRelease && Time >= 5f && Time < ChargeTime) + projectile.Kill(); + } + + private void UpdatePlayerVisuals() + { + projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + + projectile.rotation = projectile.AngleTo(Main.MouseWorld); + projectile.velocity = projectile.rotation.ToRotationVector2(); + + // Place the projectile directly into the player's hand with an offset at all times. + projectile.Center += projectile.rotation.ToRotationVector2() * 30f; + + projectile.direction = projectile.spriteDirection = (Math.Cos(projectile.rotation) > 0).ToDirectionInt(); + + // The staff is a holdout projectile; change the player's variables to reflect this. + Owner.ChangeDir(projectile.direction); + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = projectile.rotation * projectile.direction; + + projectile.rotation += MathHelper.PiOver4; + if (projectile.spriteDirection == -1) + projectile.rotation += MathHelper.PiOver2; + } + + private void ShootBolt() + { + if (Main.myPlayer != projectile.owner) + return; + + Item heldItem = Owner.ActiveItem(); + Vector2 shootVelocity = (Main.MouseWorld - projectile.Center).SafeNormalize(Vector2.UnitX * projectile.direction) * heldItem.shootSpeed; + Projectile.NewProjectile(projectile.Center, shootVelocity, ModContent.ProjectileType(), (int)(Owner.MagicDamage() * heldItem.damage), heldItem.knockBack, projectile.owner); + } + + private void CreateChargeDust() + { + if (Main.dedServ) + return; + + Vector2 spawnOffset = projectile.velocity * 70f; + for (int i = 0; i < 18; i++) + { + Dust brimstoneMagic = Dust.NewDustPerfect(projectile.Center + spawnOffset + Main.rand.NextVector2CircularEdge(30f, 30f), (int)CalamityDusts.Brimstone); + brimstoneMagic.velocity = (projectile.Center + spawnOffset - brimstoneMagic.position).SafeNormalize(Vector2.Zero) * 2f + Owner.velocity; + brimstoneMagic.scale = 1.2f; + brimstoneMagic.noGravity = true; + } + } + } +} diff --git a/Projectiles/Magic/VehemenceHoldout.png b/Projectiles/Magic/VehemenceHoldout.png new file mode 100644 index 0000000000..382701bacb Binary files /dev/null and b/Projectiles/Magic/VehemenceHoldout.png differ diff --git a/Projectiles/Magic/VehemenceSkull.cs b/Projectiles/Magic/VehemenceSkull.cs new file mode 100644 index 0000000000..a4abfd0030 --- /dev/null +++ b/Projectiles/Magic/VehemenceSkull.cs @@ -0,0 +1,63 @@ +using CalamityMod.Buffs.DamageOverTime; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class VehemenceSkull : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Brimstone Skull"); + Main.projFrames[projectile.type] = 10; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 45; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.alpha = 255; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + projectile.magic = true; + } + + public override void AI() + { + Time++; + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + + if (projectile.ai[0] < 125) // 155 - 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) + { + projectile.alpha -= 30; + if (projectile.alpha < 70) + projectile.alpha = 70; + } + + if (Math.Abs(projectile.velocity.X) > 0.1f) + projectile.spriteDirection = -projectile.direction; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 240); + } +} diff --git a/Projectiles/Magic/VehemenceSkull.png b/Projectiles/Magic/VehemenceSkull.png new file mode 100644 index 0000000000..249fa3f6fe Binary files /dev/null and b/Projectiles/Magic/VehemenceSkull.png differ diff --git a/Projectiles/Magic/VisceraBeam.cs b/Projectiles/Magic/VisceraBeam.cs index 1d682dd116..5dd19647a7 100644 --- a/Projectiles/Magic/VisceraBeam.cs +++ b/Projectiles/Magic/VisceraBeam.cs @@ -40,7 +40,6 @@ namespace CalamityMod.Projectiles.Magic } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Magic/VividBeam.cs b/Projectiles/Magic/VividBeam.cs index 8ea0c6740a..1740cbe949 100644 --- a/Projectiles/Magic/VividBeam.cs +++ b/Projectiles/Magic/VividBeam.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; + projectile.ignoreWater = true; projectile.penetrate = 1; projectile.extraUpdates = 100; projectile.timeLeft = 240; diff --git a/Projectiles/Magic/VividBolt.cs b/Projectiles/Magic/VividBolt.cs index ac6c160afe..c055ab2e39 100644 --- a/Projectiles/Magic/VividBolt.cs +++ b/Projectiles/Magic/VividBolt.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.timeLeft = 30; projectile.magic = true; - projectile.usesLocalNPCImmunity = true; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; } diff --git a/Projectiles/Magic/VividClarityBeam.cs b/Projectiles/Magic/VividClarityBeam.cs index f1c43450f2..8a78bd504c 100644 --- a/Projectiles/Magic/VividClarityBeam.cs +++ b/Projectiles/Magic/VividClarityBeam.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 100; projectile.timeLeft = 300; projectile.usesLocalNPCImmunity = true; @@ -82,7 +83,6 @@ namespace CalamityMod.Projectiles.Magic } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Magic/VividLaser2.cs b/Projectiles/Magic/VividLaser2.cs index 4147656221..f32d60db75 100644 --- a/Projectiles/Magic/VividLaser2.cs +++ b/Projectiles/Magic/VividLaser2.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 10; projectile.friendly = true; projectile.alpha = 255; - projectile.timeLeft = 120; + projectile.ignoreWater = true; + projectile.timeLeft = 120; projectile.penetrate = 1; projectile.magic = true; } diff --git a/Projectiles/Magic/VividOrb.cs b/Projectiles/Magic/VividOrb.cs index 3400fd8d52..51061119a2 100644 --- a/Projectiles/Magic/VividOrb.cs +++ b/Projectiles/Magic/VividOrb.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Magic projectile.magic = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Magic/VortexElementalBeam.cs b/Projectiles/Magic/VortexElementalBeam.cs new file mode 100644 index 0000000000..5a94a1d25a --- /dev/null +++ b/Projectiles/Magic/VortexElementalBeam.cs @@ -0,0 +1,182 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +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 override void SetStaticDefaults() + { + DisplayName.SetDefault("Lightning"); + 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.alpha = 255; + projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.tileCollide = false; + 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; + } + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(AccumulatedXMovementSpeeds); + + public override void ReceiveExtraAI(BinaryReader reader) => AccumulatedXMovementSpeeds = reader.ReadSingle(); + + public override void AI() + { + // 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; + + 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; + + 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); + + 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; + + // 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; + + 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 + 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 + + 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 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; + } + } + } + } +} diff --git a/Projectiles/Magic/VortexElementalBeam.png b/Projectiles/Magic/VortexElementalBeam.png new file mode 100644 index 0000000000..f99e9c57d5 Binary files /dev/null and b/Projectiles/Magic/VortexElementalBeam.png differ diff --git a/Projectiles/Magic/YharimsCrystalBeam.cs b/Projectiles/Magic/YharimsCrystalBeam.cs index 6ad7f332a8..cd10ef85a0 100644 --- a/Projectiles/Magic/YharimsCrystalBeam.cs +++ b/Projectiles/Magic/YharimsCrystalBeam.cs @@ -52,7 +52,7 @@ namespace CalamityMod.Projectiles.Magic // The beam itself still stops on tiles, but its invisible "source" projectile ignores them. projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 5; + projectile.localNPCHitCooldown = 10; } public override void SendExtraAI(BinaryWriter writer) => writer.Write(projectile.localAI[1]); diff --git a/Projectiles/Melee/AegisFlame.cs b/Projectiles/Melee/AegisFlame.cs index 7f1e881df1..43af8f7713 100644 --- a/Projectiles/Melee/AegisFlame.cs +++ b/Projectiles/Melee/AegisFlame.cs @@ -91,13 +91,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Melee/AtaraxiaMain.cs b/Projectiles/Melee/AtaraxiaMain.cs index cb4852d734..eabda15238 100644 --- a/Projectiles/Melee/AtaraxiaMain.cs +++ b/Projectiles/Melee/AtaraxiaMain.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 12; projectile.friendly = true; projectile.melee = 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 0a16d89367..97f72d2132 100644 --- a/Projectiles/Melee/AtaraxiaSide.cs +++ b/Projectiles/Melee/AtaraxiaSide.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 8; projectile.friendly = true; projectile.melee = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.extraUpdates = 2; projectile.timeLeft = 180; } @@ -79,7 +80,7 @@ namespace CalamityMod.Projectiles.Melee { projVec = projVec.RotatedBy(angleVariance); if (projectile.owner == Main.myPlayer) - Projectile.NewProjectile(projectile.Center, projVec, splitID, damage, 1.5f, Main.myPlayer, 0.0f, 0.0f); + Projectile.NewProjectile(projectile.Center, projVec, splitID, damage, 1.5f, Main.myPlayer); } } } diff --git a/Projectiles/Melee/AtaraxiaSplit.cs b/Projectiles/Melee/AtaraxiaSplit.cs index f358d451b1..0771c80dd0 100644 --- a/Projectiles/Melee/AtaraxiaSplit.cs +++ b/Projectiles/Melee/AtaraxiaSplit.cs @@ -16,9 +16,9 @@ namespace CalamityMod.Projectiles.Melee projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 6; - projectile.timeLeft = 50; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 6; + projectile.timeLeft = 25; projectile.tileCollide = false; projectile.ignoreWater = true; projectile.alpha = 0; diff --git a/Projectiles/Melee/BiomeOrb.cs b/Projectiles/Melee/BiomeOrb.cs index ad4d990282..1575ade4b2 100644 --- a/Projectiles/Melee/BiomeOrb.cs +++ b/Projectiles/Melee/BiomeOrb.cs @@ -176,7 +176,7 @@ namespace CalamityMod.Projectiles.Melee } else if (snow) { - target.AddBuff(ModContent.BuffType(), debuffTime / 2); + target.AddBuff(ModContent.BuffType(), debuffTime / 3); } else if (beach) { @@ -192,7 +192,7 @@ namespace CalamityMod.Projectiles.Melee } else if (glow) { - target.AddBuff(ModContent.BuffType(), debuffTime); + target.AddBuff(ModContent.BuffType(), debuffTime / 3); } else if (hell) { diff --git a/Projectiles/Melee/Blood.cs b/Projectiles/Melee/Blood.cs index 2973ab8a00..4e04f7104e 100644 --- a/Projectiles/Melee/Blood.cs +++ b/Projectiles/Melee/Blood.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Melee if (player.moonLeech) return; - int healAmt = projectile.ai[0] == 1f ? 3 : 5; + int healAmt = 2; player.statLife += healAmt; player.HealEffect(healAmt); } diff --git a/Projectiles/Melee/BlueAura.cs b/Projectiles/Melee/BlueAura.cs index 8908e5b14f..51f745879f 100644 --- a/Projectiles/Melee/BlueAura.cs +++ b/Projectiles/Melee/BlueAura.cs @@ -21,6 +21,8 @@ namespace CalamityMod.Projectiles.Melee projectile.tileCollide = false; projectile.penetrate = -1; projectile.timeLeft = 300; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/Brimblast.cs b/Projectiles/Melee/Brimblast.cs index 86c4db0a0e..572b5c03eb 100644 --- a/Projectiles/Melee/Brimblast.cs +++ b/Projectiles/Melee/Brimblast.cs @@ -82,16 +82,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return 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/BrimlanceStandingFire.cs b/Projectiles/Melee/BrimlanceStandingFire.cs index 300ed6c013..7d1bad3b9c 100644 --- a/Projectiles/Melee/BrimlanceStandingFire.cs +++ b/Projectiles/Melee/BrimlanceStandingFire.cs @@ -92,16 +92,9 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return 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(), 180); diff --git a/Projectiles/Melee/ClamCrusherFlail.cs b/Projectiles/Melee/ClamCrusherFlail.cs index 0e22fa0a11..102e48382b 100644 --- a/Projectiles/Melee/ClamCrusherFlail.cs +++ b/Projectiles/Melee/ClamCrusherFlail.cs @@ -176,15 +176,12 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (target.rarity < 2) - { + if (projectile.ai[1] >= 45f && (projectile.ai[0] != 1f || projectile.ai[0] != 2f)) target.AddBuff(ModContent.BuffType(), 120); - } - else if (projectile.ai[1] >= 45f && (projectile.ai[0] != 1f || projectile.ai[0] != 2f)) - { + 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/CosmicDischargeFlail.cs b/Projectiles/Melee/CosmicDischargeFlail.cs index 43fecf2668..91aac35c75 100644 --- a/Projectiles/Melee/CosmicDischargeFlail.cs +++ b/Projectiles/Melee/CosmicDischargeFlail.cs @@ -104,10 +104,7 @@ namespace CalamityMod.Projectiles.Melee Player player = Main.player[projectile.owner]; target.AddBuff(BuffID.Frostburn, 300); target.AddBuff(ModContent.BuffType(), 300); - if (Main.rand.NextBool(3)) - { - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 120); if (projectile.localAI[1] <= 0f && projectile.owner == Main.myPlayer) { Projectile.NewProjectile(target.Center.X, target.Center.Y, 0f, 0f, ModContent.ProjectileType(), projectile.damage, 10f, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); diff --git a/Projectiles/Melee/CosmicShivBall.cs b/Projectiles/Melee/CosmicShivBall.cs index 4ccfc51f70..5c69f79a4d 100644 --- a/Projectiles/Melee/CosmicShivBall.cs +++ b/Projectiles/Melee/CosmicShivBall.cs @@ -91,7 +91,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.NewProjectile(toSpawn, toTarget, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack * 0.5f, projectile.owner); } target.AddBuff(ModContent.BuffType(), 360); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 360); target.AddBuff(ModContent.BuffType(), 360); target.AddBuff(ModContent.BuffType(), 360); target.AddBuff(ModContent.BuffType(), 240); diff --git a/Projectiles/Melee/CosmicShivBlade.cs b/Projectiles/Melee/CosmicShivBlade.cs index 992a80b3d4..1be2131673 100644 --- a/Projectiles/Melee/CosmicShivBlade.cs +++ b/Projectiles/Melee/CosmicShivBlade.cs @@ -1,6 +1,7 @@ using System; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; @@ -73,7 +74,7 @@ namespace CalamityMod.Projectiles.Melee projectile.ai[1] = 5 + Main.rand.Next(-2, 3); target.immune[projectile.owner] = 0; //so that all blades can hit the enemy target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(BuffID.Frostburn, 180); target.AddBuff(ModContent.BuffType(), 180); target.AddBuff(ModContent.BuffType(), 180); target.AddBuff(ModContent.BuffType(), 180); diff --git a/Projectiles/Melee/DNA.cs b/Projectiles/Melee/DNA.cs index 50ea1d1869..5b8ee96f4c 100644 --- a/Projectiles/Melee/DNA.cs +++ b/Projectiles/Melee/DNA.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.tileCollide = false; projectile.melee = true; - aiType = ProjectileID.CrystalVileShardHead; + projectile.ignoreWater = true; + aiType = ProjectileID.CrystalVileShardHead; } public override void AI() diff --git a/Projectiles/Melee/DNA2.cs b/Projectiles/Melee/DNA2.cs index 5b4aadaebd..6c350a5a04 100644 --- a/Projectiles/Melee/DNA2.cs +++ b/Projectiles/Melee/DNA2.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Melee projectile.penetrate = -1; projectile.tileCollide = false; projectile.melee = true; - aiType = ProjectileID.CrystalVileShardShaft; + projectile.ignoreWater = true; + aiType = ProjectileID.CrystalVileShardShaft; } public override void AI() diff --git a/Projectiles/Melee/DarkIceZero.cs b/Projectiles/Melee/DarkIceZero.cs index 4b458f3825..12f6d598ae 100644 --- a/Projectiles/Melee/DarkIceZero.cs +++ b/Projectiles/Melee/DarkIceZero.cs @@ -53,7 +53,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 480); - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 60); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Melee/DemonBlast.cs b/Projectiles/Melee/DemonBlast.cs index 752dac869f..e2288059e5 100644 --- a/Projectiles/Melee/DemonBlast.cs +++ b/Projectiles/Melee/DemonBlast.cs @@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Melee { target.AddBuff(BuffID.ShadowFlame, 300); target.AddBuff(ModContent.BuffType(), 300); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 300); } } } diff --git a/Projectiles/Melee/DevilsSunriseProj.cs b/Projectiles/Melee/DevilsSunriseProj.cs index f3123d482c..6f943b40c1 100644 --- a/Projectiles/Melee/DevilsSunriseProj.cs +++ b/Projectiles/Melee/DevilsSunriseProj.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Projectiles.Melee public class DevilsSunriseProj : ModProjectile { private int red; - private int greenAndBlue = 100; + private const int greenAndBlue = 100; public override void SetStaticDefaults() { diff --git a/Projectiles/Melee/DragonPowFlail.cs b/Projectiles/Melee/DragonPowFlail.cs index 14a731eadc..b65387990b 100644 --- a/Projectiles/Melee/DragonPowFlail.cs +++ b/Projectiles/Melee/DragonPowFlail.cs @@ -138,6 +138,10 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { + // Only perform hit effects after reaching approximately 55% of the way out. + if (Main.player[projectile.owner].WithinRange(target.Center, 475f)) + return; + // Inflicts Daybroken, Abyssal Flames and Holy Flames for 8 seconds on-hit target.AddBuff(BuffID.Daybreak, 480); target.AddBuff(ModContent.BuffType(), 480); @@ -152,6 +156,10 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitPvp(Player target, int damage, bool crit) { + // Only perform hit effects after reaching approximately 55% of the way out. + if (projectile.WithinRange(Main.player[projectile.owner].Center, 475f)) + return; + // Inflicts Abyssal Flames and Holy Flames for 8 seconds on-hit target.AddBuff(ModContent.BuffType(), 480); target.AddBuff(ModContent.BuffType(), 480); diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index cefe9f0692..43dfe695e1 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -174,7 +174,7 @@ namespace CalamityMod.Projectiles.Melee modPlayer.dragonRageHits = 0; } - int proj = Projectile.NewProjectile(position, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); + 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; } } @@ -190,7 +190,7 @@ namespace CalamityMod.Projectiles.Melee 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 / 3, projectile.knockBack / 3f, projectile.owner); + Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 8, projectile.knockBack / 3f, projectile.owner); } } diff --git a/Projectiles/Melee/DragonRageStaff.png b/Projectiles/Melee/DragonRageStaff.png index 4d3ee425bb..38100f5016 100644 Binary files a/Projectiles/Melee/DragonRageStaff.png and b/Projectiles/Melee/DragonRageStaff.png differ diff --git a/Projectiles/Melee/Earth2.cs b/Projectiles/Melee/Earth2.cs index 1f8900f386..5e4ec106df 100644 --- a/Projectiles/Melee/Earth2.cs +++ b/Projectiles/Melee/Earth2.cs @@ -96,7 +96,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 360); } } } diff --git a/Projectiles/Melee/ElementBall.cs b/Projectiles/Melee/ElementBall.cs index 6670412612..b80d498d93 100644 --- a/Projectiles/Melee/ElementBall.cs +++ b/Projectiles/Melee/ElementBall.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -38,7 +39,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/ElementBallShiv.cs b/Projectiles/Melee/ElementBallShiv.cs index cb90258df6..02413d534e 100644 --- a/Projectiles/Melee/ElementBallShiv.cs +++ b/Projectiles/Melee/ElementBallShiv.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee @@ -57,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee { OnHitEffects(target.Center); target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } @@ -66,7 +67,7 @@ namespace CalamityMod.Projectiles.Melee { OnHitEffects(target.Center); target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/EonBeam.cs b/Projectiles/Melee/EonBeam.cs index dcee4fa5a6..b08a44a6ac 100644 --- a/Projectiles/Melee/EonBeam.cs +++ b/Projectiles/Melee/EonBeam.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Melee if (projectile.ai[0] != 1f) //excludes (True) Ark of the Ancients { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/EonBeamV2.cs b/Projectiles/Melee/EonBeamV2.cs index 6caf40d6d7..c947095945 100644 --- a/Projectiles/Melee/EonBeamV2.cs +++ b/Projectiles/Melee/EonBeamV2.cs @@ -71,7 +71,7 @@ namespace CalamityMod.Projectiles.Melee if (projectile.ai[0] != 1f) //excludes True Ark of the Ancients { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/EonBeamV3.cs b/Projectiles/Melee/EonBeamV3.cs index d8c0f9155f..547bab15ee 100644 --- a/Projectiles/Melee/EonBeamV3.cs +++ b/Projectiles/Melee/EonBeamV3.cs @@ -67,7 +67,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/EonBeamV4.cs b/Projectiles/Melee/EonBeamV4.cs index 6b4c00e9a4..80fbfb1412 100644 --- a/Projectiles/Melee/EonBeamV4.cs +++ b/Projectiles/Melee/EonBeamV4.cs @@ -67,7 +67,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/EutrophicScimitarProj.cs b/Projectiles/Melee/EutrophicScimitarProj.cs index 32cde836da..bef03ae0c6 100644 --- a/Projectiles/Melee/EutrophicScimitarProj.cs +++ b/Projectiles/Melee/EutrophicScimitarProj.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 60); } public override void AI() diff --git a/Projectiles/Melee/EutrophicSpark.cs b/Projectiles/Melee/EutrophicSpark.cs index ecfe0b858e..1bc3c24666 100644 --- a/Projectiles/Melee/EutrophicSpark.cs +++ b/Projectiles/Melee/EutrophicSpark.cs @@ -85,13 +85,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Melee/Galaxia.cs b/Projectiles/Melee/Galaxia.cs index 04d7f2715c..c07ae74a12 100644 --- a/Projectiles/Melee/Galaxia.cs +++ b/Projectiles/Melee/Galaxia.cs @@ -151,7 +151,7 @@ namespace CalamityMod.Projectiles.Melee } else if (snow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); player.AddBuff(BuffID.Warmth, 600); Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.IceBolt, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); } @@ -204,7 +204,7 @@ namespace CalamityMod.Projectiles.Melee } else if (glow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); player.AddBuff(BuffID.Spelunker, 600); int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Mushroom, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f); if (proj.WithinBounds(Main.maxProjectiles)) diff --git a/Projectiles/Melee/Galaxia2.cs b/Projectiles/Melee/Galaxia2.cs index 347e187220..576111a1a9 100644 --- a/Projectiles/Melee/Galaxia2.cs +++ b/Projectiles/Melee/Galaxia2.cs @@ -152,7 +152,7 @@ namespace CalamityMod.Projectiles.Melee } else if (snow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); player.AddBuff(BuffID.Warmth, 600); Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.IceBolt, projectile.damage, projectile.knockBack, projectile.owner); } @@ -205,7 +205,7 @@ namespace CalamityMod.Projectiles.Melee } else if (glow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); player.AddBuff(BuffID.Spelunker, 600); int proj = Projectile.NewProjectile(projectile.Center, projectile.velocity, ProjectileID.Mushroom, projectile.damage, projectile.knockBack, projectile.owner); if (proj.WithinBounds(Main.maxProjectiles)) diff --git a/Projectiles/Melee/GreenBall.cs b/Projectiles/Melee/GreenBall.cs index f7c99668db..c3938295f1 100644 --- a/Projectiles/Melee/GreenBall.cs +++ b/Projectiles/Melee/GreenBall.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 20; projectile.friendly = true; projectile.melee = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.alpha = 255; projectile.aiStyle = 14; projectile.timeLeft = 300; @@ -63,7 +64,6 @@ namespace CalamityMod.Projectiles.Melee } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Melee/Iceberg.cs b/Projectiles/Melee/Iceberg.cs index facf53e2fa..ba84846d62 100644 --- a/Projectiles/Melee/Iceberg.cs +++ b/Projectiles/Melee/Iceberg.cs @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Melee { int debuffDuration = 300 - projectile.timeLeft; if (projectile.timeLeft < 270) - target.AddBuff(ModContent.BuffType(), debuffDuration); + target.AddBuff(ModContent.BuffType(), debuffDuration / 3); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/Leech.cs b/Projectiles/Melee/Leech.cs index 9774c32ebe..6bd904b1b7 100644 --- a/Projectiles/Melee/Leech.cs +++ b/Projectiles/Melee/Leech.cs @@ -53,8 +53,8 @@ namespace CalamityMod.Projectiles.Melee return; Player player = Main.player[projectile.owner]; - player.statLife += 5; - player.HealEffect(5); + player.statLife += 2; + player.HealEffect(2); } } } diff --git a/Projectiles/Melee/OmegaBiomeOrb.cs b/Projectiles/Melee/OmegaBiomeOrb.cs index d41ae95281..eb38795df7 100644 --- a/Projectiles/Melee/OmegaBiomeOrb.cs +++ b/Projectiles/Melee/OmegaBiomeOrb.cs @@ -217,7 +217,7 @@ namespace CalamityMod.Projectiles.Melee } else if (snow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); } else if (beach) { @@ -233,7 +233,7 @@ namespace CalamityMod.Projectiles.Melee } else if (glow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); } else if (hell) { diff --git a/Projectiles/Melee/OmnibladeSwing.cs b/Projectiles/Melee/OmnibladeSwing.cs new file mode 100644 index 0000000000..715455b7c9 --- /dev/null +++ b/Projectiles/Melee/OmnibladeSwing.cs @@ -0,0 +1,102 @@ +using CalamityMod.Buffs.StatDebuffs; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class OmnibladeSwing : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Omniblade"); + Main.projFrames[projectile.type] = 6; + } + + 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; + } + + 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(); + } + + // 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); + + // 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; + } + + 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; + + projectile.velocity = newVelocity; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (Main.rand.NextBool(5)) + target.AddBuff(ModContent.BuffType(), 360); + } + + public override void OnHitPvp(Player target, int damage, bool crit) + { + if (Main.rand.NextBool(5)) + target.AddBuff(ModContent.BuffType(), 360); + } + + 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; + } +} diff --git a/Projectiles/Melee/OmnibladeSwing.png b/Projectiles/Melee/OmnibladeSwing.png new file mode 100644 index 0000000000..bb0103db68 Binary files /dev/null and b/Projectiles/Melee/OmnibladeSwing.png differ diff --git a/Projectiles/Melee/PhosphorescentGauntletPunches.cs b/Projectiles/Melee/PhosphorescentGauntletPunches.cs new file mode 100644 index 0000000000..3bb90dba9c --- /dev/null +++ b/Projectiles/Melee/PhosphorescentGauntletPunches.cs @@ -0,0 +1,177 @@ +using CalamityMod.DataStructures; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +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 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 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(); + + 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 ReelBack() + { + Owner.immune = true; + Owner.immuneTime = 15; + + // 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(); + + // 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; + + 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(); + } + } + } + + 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(); + } + } + + internal void HandlePositioning() + { + projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter); + projectile.Center += projectile.velocity.SafeNormalize(Vector2.UnitX * Owner.direction) * 30f; + } + #endregion + + #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 + + #region NPC Hit Collision Logic + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => ReelBack(); + #endregion + } +} diff --git a/Projectiles/Melee/PhosphorescentGauntletPunches.png b/Projectiles/Melee/PhosphorescentGauntletPunches.png new file mode 100644 index 0000000000..ae775bc14a Binary files /dev/null and b/Projectiles/Melee/PhosphorescentGauntletPunches.png differ diff --git a/Projectiles/Melee/PhotonRipperGlowmask.png b/Projectiles/Melee/PhotonRipperGlowmask.png new file mode 100644 index 0000000000..3db63d70e2 Binary files /dev/null and b/Projectiles/Melee/PhotonRipperGlowmask.png differ diff --git a/Projectiles/Melee/PhotonRipperProjectile.cs b/Projectiles/Melee/PhotonRipperProjectile.cs new file mode 100644 index 0000000000..62588db1aa --- /dev/null +++ b/Projectiles/Melee/PhotonRipperProjectile.cs @@ -0,0 +1,220 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class PhotonRipperProjectile : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public const int CrystalShootRate = 5; + public const int ChargeUpTime = 360; + public ref float Time => ref projectile.ai[0]; + public ref float OriginalDamage => ref projectile.ai[1]; + public float ChargeUpPower => MathHelper.Clamp((float)Math.Pow(Time / ChargeUpTime, 1.6D), 0f, 1f); + public override void SetStaticDefaults() => DisplayName.SetDefault("An extraordinarily cost inefficient chainsaw"); // Seriously though Draedon this seems a bit over the top lmfao. + + 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; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 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; + + 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() + { + PlayChainsawSounds(); + DetermineDamage(); + + // 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(); + + if (Time % CrystalShootRate == CrystalShootRate - 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; + + Time++; + } + + 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 damage the moment it's created. + if (Main.myPlayer == projectile.owner && OriginalDamage == 0f) + { + OriginalDamage = projectile.damage; + projectile.netUpdate = true; + } + + // And then do time based damage calculations. This does not execute if the original damage is 0. + if (OriginalDamage != 0f) + projectile.damage = (int)MathHelper.SmoothStep(OriginalDamage * 0.36f, OriginalDamage, ChargeUpPower); + } + + public void DetermineVisuals(Vector2 playerRotatedPosition) + { + float directionAngle = projectile.velocity.ToRotation(); + projectile.rotation = directionAngle; + + int oldDirection = projectile.spriteDirection; + if (oldDirection == -1) + projectile.rotation += MathHelper.Pi; + + 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; + + // 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 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); + + 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)); + + 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); + } + + 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; + + 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); + + 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); + + if (Main.myPlayer != projectile.owner) + return; + + float shootReach = MathHelper.SmoothStep(projectile.width * 1.8f, projectile.width * 5.3f + 16f, ChargeUpPower); + + // Incorporate item shoot speed into the range of the crystals. + shootReach *= Owner.ActiveItem().shootSpeed; + + 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; + + Projectile.NewProjectile(Owner.Center, projectile.velocity, ModContent.ProjectileType(), projectile.damage / 2, 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 _); + } + } +} diff --git a/Projectiles/Melee/PhotonRipperProjectile.png b/Projectiles/Melee/PhotonRipperProjectile.png new file mode 100644 index 0000000000..f0e5ea6ab4 Binary files /dev/null and b/Projectiles/Melee/PhotonRipperProjectile.png differ diff --git a/Projectiles/Melee/PlagueSeeker.cs b/Projectiles/Melee/PlagueSeeker.cs index d3a6063ad6..350b6a36af 100644 --- a/Projectiles/Melee/PlagueSeeker.cs +++ b/Projectiles/Melee/PlagueSeeker.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Melee projectile.width = 4; projectile.height = 4; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.melee = true; projectile.timeLeft = 180; projectile.extraUpdates = 1; diff --git a/Projectiles/Melee/PrismRay.cs b/Projectiles/Melee/PrismRay.cs new file mode 100644 index 0000000000..7d3b81c3bd --- /dev/null +++ b/Projectiles/Melee/PrismRay.cs @@ -0,0 +1,209 @@ +using CalamityMod.Items; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Melee +{ + public class PrismRay : ModProjectile + { + public Vector2 StartingPosition; + public Color RayColor => CalamityUtils.MulticolorLerp(RayHue, CalamityGlobalItem.ExoPalette); + public Color HueDownscaledRayColor => RayColor * 0.66f; + public ref float RayHue => ref projectile.ai[0]; + public ref float Time => ref projectile.localAI[1]; + public const int Lifetime = 30; + public override string Texture => "CalamityMod/Projectiles/StarProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prismatic Light"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 14; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 900; + projectile.friendly = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.melee = true; + } + + public override void AI() + { + DelegateMethods.v3_1 = RayColor.ToVector3() * 0.5f; + Utils.PlotTileLine(StartingPosition, projectile.Center, 8f, DelegateMethods.CastLight); + if (projectile.localAI[0] == 0f) + { + projectile.direction = Main.rand.NextBool(2).ToDirectionInt(); + projectile.localAI[0] = 1f; + } + projectile.rotation = Time / 20f * MathHelper.TwoPi * projectile.direction; + projectile.alpha = Utils.Clamp(projectile.alpha - 18, 0, 255); + if (projectile.alpha == 0) + Lighting.AddLight(projectile.Center, RayColor.ToVector3() * 0.5f); + + for (int i = 0; i < 2; i++) + { + if (Main.rand.NextBool(10)) + { + Dust verticalMagic = Dust.NewDustDirect(projectile.Center, 0, 0, 267, 0f, 0f, 225, RayColor, 1.5f); + verticalMagic.noGravity = true; + verticalMagic.noLight = true; + verticalMagic.scale = projectile.Opacity; + verticalMagic.position = projectile.Center; + verticalMagic.velocity = Vector2.UnitY.RotatedBy(projectile.rotation + MathHelper.TwoPi * i / 2f) * 2.5f; + } + } + if (Main.rand.NextBool(10)) + { + Vector2 dustSpawnPosition = projectile.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(20f, 120f); + Point dustTileCoords = dustSpawnPosition.ToTileCoordinates(); + bool canSpawnDust = true; + if (!WorldGen.InWorld(dustTileCoords.X, dustTileCoords.Y, 0)) + canSpawnDust = false; + + if (canSpawnDust && WorldGen.SolidTile(dustTileCoords.X, dustTileCoords.Y)) + canSpawnDust = false; + + if (canSpawnDust) + { + Dust risingMagic = Dust.NewDustDirect(dustSpawnPosition, 0, 0, 267, 0f, 0f, 127, RayColor, 1f); + risingMagic.noGravity = true; + risingMagic.position = dustSpawnPosition; + risingMagic.velocity = -Vector2.UnitY * Main.rand.NextFloat(1.6f, 7.5f); + risingMagic.fadeIn = Main.rand.NextFloat(1f, 2f); + risingMagic.scale = Main.rand.NextFloat(0.6f, 1.2f); + risingMagic.noLight = true; + + risingMagic = Dust.CloneDust(risingMagic); + risingMagic.scale *= 0.65f; + risingMagic.fadeIn *= 0.65f; + risingMagic.color = new Color(255, 255, 255, 255); + } + } + projectile.scale = projectile.Opacity * 0.5f; + projectile.velocity = Vector2.Zero; + + Time++; + if (Time >= Lifetime) + projectile.Kill(); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + float _ = 0f; + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), StartingPosition, projectile.Center, projectile.scale * 22f, ref _); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Vector2 baseDrawPosition = projectile.Center + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Vector2 origin = frame.Size() / 2f; + Color fadedRayColor = projectile.GetAlpha(lightColor); + Color fullbrightRayColor = HueDownscaledRayColor.MultiplyRGBA(new Color(255, 255, 255, 0)); + + // Draw the stars at the end of the laser. + for (int i = 0; i < 6; i++) + { + Vector2 drawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 6f + Main.GlobalTime * 3f).ToRotationVector2() * projectile.scale * 4f; + spriteBatch.Draw(texture, drawPosition, frame, fullbrightRayColor, projectile.rotation, origin, projectile.scale * 2f, SpriteEffects.None, 0f); + spriteBatch.Draw(texture, drawPosition, frame, fullbrightRayColor, 0f, origin, projectile.scale * 2f, SpriteEffects.None, 0f); + } + + // Draw the shimmering ray itself. + if (projectile.Opacity > 0.3f) + { + Vector2 drawOffset = (StartingPosition - projectile.Center) * 0.5f; + Vector2 scale = new Vector2(1f, drawOffset.Length() * 2f / texture.Height); + float rotation = drawOffset.ToRotation() + MathHelper.PiOver2; + + // This factor causes the opacity to flash rather quickly. + float drawFade = MathHelper.Clamp(MathHelper.Distance(Lifetime * 0.5f, Time) / (Lifetime * 0.667f), 0f, 1f); + + for (int i = 0; i < 3; i++) + { + Vector2 drawPosition = baseDrawPosition; + drawPosition += (MathHelper.TwoPi * i / 3f + Main.GlobalTime * 3f).ToRotationVector2() * projectile.scale * 2.5f; + drawPosition += drawOffset; + + spriteBatch.Draw(texture, drawPosition, frame, fullbrightRayColor * drawFade * 0.8f, rotation, origin, scale, SpriteEffects.None, 0f); + spriteBatch.Draw(texture, drawPosition, frame, fadedRayColor * drawFade * 0.8f, rotation, origin, scale * 0.5f, SpriteEffects.None, 0f); + } + } + return false; + } + + public override void Kill(int timeLeft) + { + CreateKillExplosionBurstDust(Main.rand.Next(7, 13)); + + // Adjust values and do damage before dying. + if (Main.myPlayer != projectile.owner) + return; + + Vector2 oldSize = projectile.Size; + projectile.position = projectile.Center; + projectile.width = projectile.height = 60; + projectile.Center = projectile.position; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + projectile.position = projectile.Center; + projectile.Size = oldSize; + projectile.Center = projectile.position; + } + + public void CreateKillExplosionBurstDust(int dustCount) + { + if (Main.dedServ) + return; + + Vector2 baseExplosionDirection = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * 3f; + Vector2 outwardFireSpeedFactor = new Vector2(2.1f, 2f); + Color brightenedRayColor = RayColor; + brightenedRayColor.A = 255; + + for (float i = 0f; i < dustCount; i++) + { + Dust explosionDust = Dust.NewDustDirect(projectile.Center, 0, 0, 267, 0f, 0f, 0, brightenedRayColor, 1f); + explosionDust.position = projectile.Center; + explosionDust.velocity = baseExplosionDirection.RotatedBy(MathHelper.TwoPi * i / dustCount) * outwardFireSpeedFactor * Main.rand.NextFloat(0.8f, 1.2f); + explosionDust.noGravity = true; + explosionDust.scale = 1.1f; + explosionDust.fadeIn = Main.rand.NextFloat(1.4f, 2.4f); + + explosionDust = Dust.CloneDust(explosionDust); + explosionDust.scale /= 2f; + explosionDust.fadeIn /= 2f; + explosionDust.color = new Color(255, 255, 255, 255); + } + for (float i = 0f; i < dustCount; i++) + { + Dust explosionDust = Dust.NewDustDirect(projectile.Center, 0, 0, 267, 0f, 0f, 0, brightenedRayColor, 1f); + explosionDust.position = projectile.Center; + explosionDust.velocity = baseExplosionDirection.RotatedBy(MathHelper.TwoPi * i / dustCount) * outwardFireSpeedFactor * Main.rand.NextFloat(0.8f, 1.2f); + explosionDust.velocity *= Main.rand.NextFloat() * 0.8f; + explosionDust.noGravity = true; + explosionDust.scale = Main.rand.NextFloat(); + explosionDust.fadeIn = Main.rand.NextFloat(1.4f, 2.4f); + + explosionDust = Dust.CloneDust(explosionDust); + explosionDust.scale /= 2f; + explosionDust.fadeIn /= 2f; + explosionDust.color = new Color(255, 255, 255, 255); + } + } + + public override Color? GetAlpha(Color lightColor) => new Color(projectile.Opacity, projectile.Opacity, projectile.Opacity, 0); + } +} diff --git a/Projectiles/Melee/PrismTooth.cs b/Projectiles/Melee/PrismTooth.cs new file mode 100644 index 0000000000..a7ac09c06d --- /dev/null +++ b/Projectiles/Melee/PrismTooth.cs @@ -0,0 +1,139 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.GameContent.Achievements; +using Terraria.Graphics.Shaders; +using Terraria.ID; +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("Prism Tooth"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 36; + } + + public override void SetDefaults() + { + projectile.scale = 0.6f; + projectile.width = projectile.height = 40; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.extraUpdates = 5; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 4 * projectile.MaxUpdates; + projectile.timeLeft = Lifetime; + projectile.melee = true; + } + + 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; + + // 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; + + // 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, Time, 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); + } + + // Emit light. + Lighting.AddLight(projectile.Center, Vector3.One * 0.7f); + + Time++; + } + + 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; + + // 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; + + WorldGen.KillTile(x, y); + if (Main.netMode == NetmodeID.MultiplayerClient) + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, x, y); + + AchievementsHelper.CurrentlyMining = false; + } + + 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 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; + + 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); + + // 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; + + GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f + generalOffset - Main.screenPosition, 65); + return true; + } + + // Prevent the crystals from utilizing velocity. Their movement is entirely dependant on Center setting. + public override bool ShouldUpdatePosition() => false; + } +} diff --git a/Projectiles/Melee/PrismTooth.png b/Projectiles/Melee/PrismTooth.png new file mode 100644 index 0000000000..3201a55ae9 Binary files /dev/null and b/Projectiles/Melee/PrismTooth.png differ diff --git a/Projectiles/Melee/PrismaticBeam.cs b/Projectiles/Melee/PrismaticBeam.cs index 17ca42534e..eceb62eb13 100644 --- a/Projectiles/Melee/PrismaticBeam.cs +++ b/Projectiles/Melee/PrismaticBeam.cs @@ -297,7 +297,6 @@ 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); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); @@ -309,7 +308,6 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); diff --git a/Projectiles/Melee/PrismaticWave.cs b/Projectiles/Melee/PrismaticWave.cs index c39ee1ab4a..3bb44818ff 100644 --- a/Projectiles/Melee/PrismaticWave.cs +++ b/Projectiles/Melee/PrismaticWave.cs @@ -131,7 +131,6 @@ 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); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); @@ -144,7 +143,6 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.CursedInferno, 120); diff --git a/Projectiles/Melee/Razorwind.cs b/Projectiles/Melee/Razorwind.cs index 3251df881d..e4ec7e0036 100644 --- a/Projectiles/Melee/Razorwind.cs +++ b/Projectiles/Melee/Razorwind.cs @@ -56,16 +56,9 @@ namespace CalamityMod.Projectiles.Melee CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return 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/RedBall.cs b/Projectiles/Melee/RedBall.cs index b3da2a6d7f..a40cf49d18 100644 --- a/Projectiles/Melee/RedBall.cs +++ b/Projectiles/Melee/RedBall.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 20; projectile.friendly = true; projectile.melee = true; + projectile.ignoreWater = true; projectile.alpha = 255; projectile.penetrate = 2; projectile.aiStyle = 14; @@ -63,7 +64,6 @@ namespace CalamityMod.Projectiles.Melee } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Melee/SHIV.cs b/Projectiles/Melee/SHIV.cs index b5cc8bc429..49f3ff6377 100644 --- a/Projectiles/Melee/SHIV.cs +++ b/Projectiles/Melee/SHIV.cs @@ -48,7 +48,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/ScourgeoftheCosmosMini.cs b/Projectiles/Melee/ScourgeoftheCosmosMini.cs index 10173ef279..c9bd03a52c 100644 --- a/Projectiles/Melee/ScourgeoftheCosmosMini.cs +++ b/Projectiles/Melee/ScourgeoftheCosmosMini.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Melee projectile.width = 16; projectile.height = 16; projectile.friendly = true; + projectile.ignoreWater = true; projectile.melee = true; projectile.alpha = 255; projectile.penetrate = 1; diff --git a/Projectiles/Melee/Spark.cs b/Projectiles/Melee/Spark.cs index 31923f89f1..1995da51a1 100644 --- a/Projectiles/Melee/Spark.cs +++ b/Projectiles/Melee/Spark.cs @@ -85,13 +85,6 @@ namespace CalamityMod.Projectiles.Melee } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Melee/SpatialSpear.cs b/Projectiles/Melee/SpatialSpear.cs index a07d9ddc1e..f7552ad38d 100644 --- a/Projectiles/Melee/SpatialSpear.cs +++ b/Projectiles/Melee/SpatialSpear.cs @@ -97,7 +97,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/SpatialSpear2.cs b/Projectiles/Melee/SpatialSpear2.cs index 482296826c..2d47ae8263 100644 --- a/Projectiles/Melee/SpatialSpear2.cs +++ b/Projectiles/Melee/SpatialSpear2.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -85,7 +86,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/SpatialSpear3.cs b/Projectiles/Melee/SpatialSpear3.cs index 3f0bd42707..66d03a51ff 100644 --- a/Projectiles/Melee/SpatialSpear3.cs +++ b/Projectiles/Melee/SpatialSpear3.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -83,7 +84,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/SpatialSpear4.cs b/Projectiles/Melee/SpatialSpear4.cs index 58e0ebde41..184d9b717f 100644 --- a/Projectiles/Melee/SpatialSpear4.cs +++ b/Projectiles/Melee/SpatialSpear4.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { @@ -68,7 +69,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/Spears/SpatialLanceProjectile.cs b/Projectiles/Melee/Spears/SpatialLanceProjectile.cs index 7d0f7317ca..bd0454caaa 100644 --- a/Projectiles/Melee/Spears/SpatialLanceProjectile.cs +++ b/Projectiles/Melee/Spears/SpatialLanceProjectile.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Projectiles.BaseProjectiles; namespace CalamityMod.Projectiles.Melee.Spears @@ -52,7 +53,7 @@ namespace CalamityMod.Projectiles.Melee.Spears public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/SpineOfThanatosBody1.png b/Projectiles/Melee/SpineOfThanatosBody1.png new file mode 100644 index 0000000000..4aae688469 Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosBody1.png differ diff --git a/Projectiles/Melee/SpineOfThanatosBody1Glowmask.png b/Projectiles/Melee/SpineOfThanatosBody1Glowmask.png new file mode 100644 index 0000000000..23eaaf6294 Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosBody1Glowmask.png differ diff --git a/Projectiles/Melee/SpineOfThanatosBody2.png b/Projectiles/Melee/SpineOfThanatosBody2.png new file mode 100644 index 0000000000..17382a5519 Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosBody2.png differ diff --git a/Projectiles/Melee/SpineOfThanatosBody2Glowmask.png b/Projectiles/Melee/SpineOfThanatosBody2Glowmask.png new file mode 100644 index 0000000000..d12dd42818 Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosBody2Glowmask.png differ diff --git a/Projectiles/Melee/SpineOfThanatosProjectile.cs b/Projectiles/Melee/SpineOfThanatosProjectile.cs new file mode 100644 index 0000000000..80a001416c --- /dev/null +++ b/Projectiles/Melee/SpineOfThanatosProjectile.cs @@ -0,0 +1,223 @@ +using CalamityMod.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +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; + + // 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 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; + + // 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); + + 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); + } + + 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(); + } + + 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++; + } + + 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); + + // 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); + + // 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 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; + + 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 - WhipEnd).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; + + 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"); + + 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; + } + + 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; + } + } +} diff --git a/Projectiles/Melee/SpineOfThanatosProjectile.png b/Projectiles/Melee/SpineOfThanatosProjectile.png new file mode 100644 index 0000000000..749cc7be1b Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosProjectile.png differ diff --git a/Projectiles/Melee/SpineOfThanatosProjectileGlowmask.png b/Projectiles/Melee/SpineOfThanatosProjectileGlowmask.png new file mode 100644 index 0000000000..18a7157c07 Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosProjectileGlowmask.png differ diff --git a/Projectiles/Melee/SpineOfThanatosTail.png b/Projectiles/Melee/SpineOfThanatosTail.png new file mode 100644 index 0000000000..2f7adf9370 Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosTail.png differ diff --git a/Projectiles/Melee/SpineOfThanatosTailGlowmask.png b/Projectiles/Melee/SpineOfThanatosTailGlowmask.png new file mode 100644 index 0000000000..7d1ac8f4b8 Binary files /dev/null and b/Projectiles/Melee/SpineOfThanatosTailGlowmask.png differ diff --git a/Projectiles/Melee/SwordsplosionBlue.cs b/Projectiles/Melee/SwordsplosionBlue.cs index f78f4e2712..02c044addd 100644 --- a/Projectiles/Melee/SwordsplosionBlue.cs +++ b/Projectiles/Melee/SwordsplosionBlue.cs @@ -69,7 +69,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/SwordsplosionGreen.cs b/Projectiles/Melee/SwordsplosionGreen.cs index 92c6849d38..3c40836857 100644 --- a/Projectiles/Melee/SwordsplosionGreen.cs +++ b/Projectiles/Melee/SwordsplosionGreen.cs @@ -68,7 +68,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/SwordsplosionPurple.cs b/Projectiles/Melee/SwordsplosionPurple.cs index b55f40c58f..aa200e468a 100644 --- a/Projectiles/Melee/SwordsplosionPurple.cs +++ b/Projectiles/Melee/SwordsplosionPurple.cs @@ -32,7 +32,6 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 0.3f / 255f, (255 - projectile.alpha) * 0.4f / 255f, (255 - projectile.alpha) * 1f / 255f); if (projectile.localAI[1] > 7f) { @@ -70,7 +69,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/SwordsplosionRed.cs b/Projectiles/Melee/SwordsplosionRed.cs index 089781fcef..bf83555e19 100644 --- a/Projectiles/Melee/SwordsplosionRed.cs +++ b/Projectiles/Melee/SwordsplosionRed.cs @@ -69,7 +69,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Melee/TemporalFloeNumberTwo.cs b/Projectiles/Melee/TemporalFloeNumberTwo.cs index a751649abd..93057dbad4 100644 --- a/Projectiles/Melee/TemporalFloeNumberTwo.cs +++ b/Projectiles/Melee/TemporalFloeNumberTwo.cs @@ -69,10 +69,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (Main.rand.NextBool(3)) - { - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 240); } } diff --git a/Projectiles/Melee/TemporalFloeSwordProjectile.cs b/Projectiles/Melee/TemporalFloeSwordProjectile.cs index f3eea114c0..8ead3149d5 100644 --- a/Projectiles/Melee/TemporalFloeSwordProjectile.cs +++ b/Projectiles/Melee/TemporalFloeSwordProjectile.cs @@ -103,10 +103,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - if (Main.rand.NextBool(3)) - { - target.AddBuff(ModContent.BuffType(), 120); - } + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 240); } } diff --git a/Projectiles/Melee/TenebreusTidesWaterSpear.cs b/Projectiles/Melee/TenebreusTidesWaterSpear.cs index 0dedade38f..a917e5c6ea 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSpear.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSpear.cs @@ -32,7 +32,8 @@ namespace CalamityMod.Projectiles.Melee projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; projectile.tileCollide = false; - } + projectile.ignoreWater = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/Projectiles/Melee/TenebreusTidesWaterSword.cs b/Projectiles/Melee/TenebreusTidesWaterSword.cs index 0273c34318..e4caa78fcf 100644 --- a/Projectiles/Melee/TenebreusTidesWaterSword.cs +++ b/Projectiles/Melee/TenebreusTidesWaterSword.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Projectiles.Melee projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; projectile.tileCollide = false; - } + projectile.ignoreWater = true; + } public override void SendExtraAI(BinaryWriter writer) { diff --git a/Projectiles/Melee/TerratomereProjectile.cs b/Projectiles/Melee/TerratomereProjectile.cs index c8c2880e6d..f8588acad5 100644 --- a/Projectiles/Melee/TerratomereProjectile.cs +++ b/Projectiles/Melee/TerratomereProjectile.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Projectiles.Melee public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 30); } public override void Kill(int timeLeft) diff --git a/Projectiles/Melee/ThanatosBoom.cs b/Projectiles/Melee/ThanatosBoom.cs new file mode 100644 index 0000000000..be0d35f9f8 --- /dev/null +++ b/Projectiles/Melee/ThanatosBoom.cs @@ -0,0 +1,55 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Melee +{ + public class ThanatosBoom : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Boom"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 54; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.timeLeft = 45; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 4; + projectile.melee = true; + } + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + CreateExplosionDust(); + projectile.localAI[0] = 1f; + } + } + + public void CreateExplosionDust() + { + if (Main.dedServ) + return; + + for (float speed = 2f; speed <= 6f; speed += 0.7f) + { + float lifePersistance = Main.rand.NextFloat(0.8f, 1.7f); + for (int i = 0; i < 60; i++) + { + Dust energy = Dust.NewDustPerfect(projectile.Center, 267); + energy.velocity = (MathHelper.TwoPi * i / 60f).ToRotationVector2() * speed; + energy.noGravity = true; + energy.color = Main.hslToRgb(Main.rand.NextFloat(), 0.7f, 0.625f); + energy.fadeIn = lifePersistance; + energy.scale = 1.4f; + } + } + } + } +} diff --git a/Projectiles/Melee/TriactisHammerProj.cs b/Projectiles/Melee/TriactisHammerProj.cs index 9667dce296..99d37ebeea 100644 --- a/Projectiles/Melee/TriactisHammerProj.cs +++ b/Projectiles/Melee/TriactisHammerProj.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Melee projectile.width = 160; projectile.height = 160; projectile.friendly = true; + projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = -1; projectile.extraUpdates = 3; diff --git a/Projectiles/Melee/TrueBiomeOrb.cs b/Projectiles/Melee/TrueBiomeOrb.cs index c08ffdd521..5c6135c40b 100644 --- a/Projectiles/Melee/TrueBiomeOrb.cs +++ b/Projectiles/Melee/TrueBiomeOrb.cs @@ -175,7 +175,7 @@ namespace CalamityMod.Projectiles.Melee } else if (snow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); } else if (beach) { @@ -191,7 +191,7 @@ namespace CalamityMod.Projectiles.Melee } else if (glow) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); } else if (hell) { diff --git a/Projectiles/Melee/TrueCausticEdgeProjectile.cs b/Projectiles/Melee/TrueCausticEdgeProjectile.cs index ae85e36f66..fab6461f71 100644 --- a/Projectiles/Melee/TrueCausticEdgeProjectile.cs +++ b/Projectiles/Melee/TrueCausticEdgeProjectile.cs @@ -56,7 +56,6 @@ namespace CalamityMod.Projectiles.Melee } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Melee/UltimusCleaverDust.cs b/Projectiles/Melee/UltimusCleaverDust.cs index 44e337de42..34be378aa3 100644 --- a/Projectiles/Melee/UltimusCleaverDust.cs +++ b/Projectiles/Melee/UltimusCleaverDust.cs @@ -16,7 +16,8 @@ namespace CalamityMod.Projectiles.Melee projectile.width = 6; projectile.height = 12; projectile.friendly = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = 120; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; diff --git a/Projectiles/Melee/ViolenceSlashProjectile.cs b/Projectiles/Melee/ViolenceSlashProjectile.cs new file mode 100644 index 0000000000..90f645103c --- /dev/null +++ b/Projectiles/Melee/ViolenceSlashProjectile.cs @@ -0,0 +1,121 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class ViolenceSlashProjectile : ModProjectile + { + internal PrimitiveTrail SliceAfterimageDrawer = null; + internal Player Owner => Main.player[projectile.owner]; + internal ref float Time => ref projectile.ai[0]; + internal float SwingSine => (float)Math.Sin(MathHelper.TwoPi * Time / 50f); + public override string Texture => "CalamityMod/Items/Weapons/Melee/Violence"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Violence"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 36; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 142; + projectile.aiStyle = -1; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = -1; + projectile.timeLeft = 90000; + projectile.ignoreWater = true; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + projectile.tileCollide = false; + } + + public override void AI() + { + // Fade in. + projectile.Opacity = Utils.InverseLerp(0f, 15f, Time, true); + + if (!Owner.channel) + { + projectile.Kill(); + return; + } + + ManipulatePlayerFields(); + DoMovement(); + + // Create some demonic light at the tip of the spear. + Lighting.AddLight(projectile.Center + (projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * projectile.height * 0.45f, Color.Red.ToVector3() * 0.4f); + Time++; + } + + internal void DoMovement() + { + projectile.Center = Owner.RotatedRelativePoint(Owner.MountedCenter) + (projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * projectile.height * 0.45f; + projectile.rotation = SwingSine * MathHelper.ToRadians(87f); + + if (Main.myPlayer == projectile.owner && !projectile.WithinRange(Main.MouseWorld, projectile.height + 15f)) + { + projectile.velocity = projectile.SafeDirectionTo(Main.MouseWorld); + projectile.netSpam = 0; + projectile.netUpdate = true; + } + + projectile.rotation += projectile.velocity.ToRotation() + MathHelper.PiOver4; + } + + internal void ManipulatePlayerFields() + { + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.ChangeDir((Math.Cos(projectile.rotation - MathHelper.PiOver4) > 0f).ToDirectionInt()); + } + + internal Color PrimitiveColorFunction(float completionRatio) + { + float averageRotation = projectile.oldRot.Average(angle => MathHelper.WrapAngle(angle) + MathHelper.Pi); + float opacity = projectile.Opacity * Utils.InverseLerp(0.75f, 0.45f, completionRatio, true) * 0.5f; + opacity *= Utils.InverseLerp(0.125f, 0.15f, Math.Abs(SwingSine), true); + + float rotationAdjusted = MathHelper.WrapAngle(projectile.rotation) + MathHelper.Pi; + float oldRotationAdjusted = MathHelper.WrapAngle(projectile.oldRot[1]) + MathHelper.Pi; + + return Color.Lerp(Color.Red * 1.1f, Color.DarkRed, Utils.InverseLerp(0f, 0.5f, completionRatio, true)) * opacity; + } + + internal float PrimitiveWidthFunction(float completionRatio) => projectile.height * 0.48f; + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (SliceAfterimageDrawer is null) + SliceAfterimageDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]); + + GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/SwordSlashTexture")); + + Texture2D spearProjectile = Main.projectileTexture[projectile.type]; + + Player player = Main.player[projectile.owner]; + List positions = new List(); + + for (int i = 0; i < 16; i++) + { + Vector2 position = projectile.position + (projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * (PrimitiveWidthFunction(0f) - 30f) * projectile.scale * 0.5f; + float angleOffset = MathHelper.Pi * 0.25f * -Math.Sign(SwingSine) * i / 16f; + position += (projectile.rotation - MathHelper.PiOver4 + MathHelper.PiOver2).ToRotationVector2().RotatedBy(angleOffset) * -SwingSine * i * 12f; + positions.Add(position); + } + + SliceAfterimageDrawer.Draw(positions, projectile.Size * 0.5f - Main.screenPosition, 50); + return true; + } + } +} diff --git a/Projectiles/Melee/ViolenceThrownProjectile.cs b/Projectiles/Melee/ViolenceThrownProjectile.cs new file mode 100644 index 0000000000..0fcf8ac827 --- /dev/null +++ b/Projectiles/Melee/ViolenceThrownProjectile.cs @@ -0,0 +1,161 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Melee +{ + public class ViolenceThrownProjectile : ModProjectile + { + internal PrimitiveTrail StreakDrawer = null; + internal Player Owner => Main.player[projectile.owner]; + internal ref float Time => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Items/Weapons/Melee/Violence"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Violence"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 36; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 142; + projectile.aiStyle = -1; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = -1; + projectile.timeLeft = 90000; + projectile.ignoreWater = true; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + projectile.tileCollide = false; + } + + public override void AI() + { + // Fade in. + projectile.Opacity = Utils.InverseLerp(0f, 15f, Time, true); + + if (Owner.channel) + { + HomeTowardsMouse(); + projectile.rotation += 0.35f / projectile.MaxUpdates; + } + else + { + ReturnToOwner(); + + float idealAngle = projectile.AngleTo(Owner.Center) - MathHelper.PiOver4; + projectile.rotation = projectile.rotation.AngleLerp(idealAngle, 0.1f); + projectile.rotation = projectile.rotation.AngleTowards(idealAngle, 0.25f); + } + ManipulatePlayerFields(); + + // Create some demonic light at the tip of the spear. + Lighting.AddLight(projectile.Center + (projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * projectile.height * 0.45f, Color.Red.ToVector3() * 0.4f); + Time++; + } + + internal void HomeTowardsMouse() + { + if (Main.myPlayer != projectile.owner) + return; + + if (projectile.WithinRange(Main.MouseWorld, projectile.velocity.Length() * 0.7f)) + projectile.Center = Main.MouseWorld; + else + projectile.velocity = (projectile.velocity * 3f + projectile.DirectionTo(Main.MouseWorld) * 19f) / 4f; + projectile.netSpam = 0; + projectile.netUpdate = true; + } + + internal void ReturnToOwner() + { + projectile.Center = Vector2.Lerp(projectile.Center, Owner.Center, 0.02f); + projectile.velocity = projectile.SafeDirectionTo(Owner.Center) * 22f; + if (projectile.Hitbox.Intersects(Owner.Hitbox)) + { + for (int i = 0; i < 75; i++) + { + Dust fire = Dust.NewDustPerfect(Owner.Center, DustID.Fire); + fire.velocity = (MathHelper.TwoPi * i / 75f).ToRotationVector2() * 4f - Vector2.UnitY * 3f; + fire.scale = 1.4f; + fire.noGravity = true; + } + projectile.Kill(); + } + } + + internal void ManipulatePlayerFields() + { + Owner.itemTime = 2; + Owner.itemAnimation = 2; + } + + internal float PrimitiveWidthFunction(float completionRatio) + { + float tipWidthFactor = MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0.01f, 0.04f, completionRatio)); + float bodyWidthFactor = (float)Math.Pow(Utils.InverseLerp(1f, 0.04f, completionRatio), 0.9D); + return (float)Math.Pow(tipWidthFactor * bodyWidthFactor, 0.1D) * 30f; + } + + internal Color PrimitiveColorFunction(float completionRatio) + { + float fadeInterpolant = (float)Math.Cos(Main.GlobalTime * -9f + completionRatio * 6f + projectile.identity * 2f) * 0.5f + 0.5f; + + // Adjust the fade interpolant to be on a different scale via a linear interpolation. + fadeInterpolant = MathHelper.Lerp(0.15f, 0.75f, fadeInterpolant); + Color frontFade = Color.Lerp(new Color(255, 145, 115), new Color(113, 0, 159), fadeInterpolant); + + // Go halfway to a dark red color. + frontFade = Color.Lerp(frontFade, Color.DarkRed, 0.5f); + Color backFade = new Color(255, 145, 115); + + return Color.Lerp(frontFade, backFade, (float)Math.Pow(completionRatio, 1.2D)) * (float)Math.Pow(1f - completionRatio, 1.1D) * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (StreakDrawer is null) + StreakDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]); + + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/FabstaffStreak")); + + Texture2D spearProjectile = Main.projectileTexture[projectile.type]; + + // Not cloning the points causes the below operations to be applied to the original oldPos value by reference + // and thus causes it to be consistently added over and over, which is not intended behavior. + Vector2[] drawPoints = (Vector2[])projectile.oldPos.Clone(); + Vector2 aimAheadDirection = (projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + + if (Owner.channel) + { + drawPoints[0] += aimAheadDirection * -12f; + drawPoints[1] = drawPoints[0] - (projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * Vector2.Distance(drawPoints[0], drawPoints[1]); + } + for (int i = 0; i < drawPoints.Length; i++) + drawPoints[i] -= (projectile.oldRot[i] + MathHelper.PiOver4).ToRotationVector2() * projectile.height * 0.5f; + + if (Time > projectile.oldPos.Length) + StreakDrawer.Draw(drawPoints, projectile.Size * 0.5f - Main.screenPosition, 88); + + Vector2 drawPosition = projectile.Center - Main.screenPosition; + for (int i = 0; i < 6; i++) + { + float rotation = projectile.oldRot[i] - MathHelper.PiOver2; + if (Owner.channel) + rotation += 0.2f; + + Color afterimageColor = Color.Lerp(lightColor, Color.Transparent, 1f - (float)Math.Pow(Utils.InverseLerp(0, 6, i), 1.4D)) * projectile.Opacity; + spriteBatch.Draw(spearProjectile, drawPosition, null, afterimageColor, rotation, spearProjectile.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + + return false; + } + } +} diff --git a/Projectiles/Melee/Waterfall.cs b/Projectiles/Melee/Waterfall.cs index 350ba5e362..cb2887f311 100644 --- a/Projectiles/Melee/Waterfall.cs +++ b/Projectiles/Melee/Waterfall.cs @@ -74,7 +74,6 @@ namespace CalamityMod.Projectiles.Melee } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs index 0dfaea5c07..6668747b03 100644 --- a/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs +++ b/Projectiles/Melee/Yoyos/AirSpinnerYoyo.cs @@ -29,7 +29,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { diff --git a/Projectiles/Melee/Yoyos/AortaYoyo.cs b/Projectiles/Melee/Yoyos/AortaYoyo.cs index e5bfcda50f..6d8a19767e 100644 --- a/Projectiles/Melee/Yoyos/AortaYoyo.cs +++ b/Projectiles/Melee/Yoyos/AortaYoyo.cs @@ -29,7 +29,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { diff --git a/Projectiles/Melee/Yoyos/AzathothYoyo.cs b/Projectiles/Melee/Yoyos/AzathothYoyo.cs index 913f86b2b7..05ab6b164a 100644 --- a/Projectiles/Melee/Yoyos/AzathothYoyo.cs +++ b/Projectiles/Melee/Yoyos/AzathothYoyo.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; } diff --git a/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs b/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs index 4ce0697de8..11c79b1b5c 100644 --- a/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs +++ b/Projectiles/Melee/Yoyos/ChaotrixYoyo.cs @@ -30,7 +30,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; + } public override void AI() { diff --git a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs b/Projectiles/Melee/Yoyos/CnidarianYoyo.cs index bb55dc6ec4..bf2addb6b9 100644 --- a/Projectiles/Melee/Yoyos/CnidarianYoyo.cs +++ b/Projectiles/Melee/Yoyos/CnidarianYoyo.cs @@ -27,6 +27,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; } public override void AI() diff --git a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs index ac553a9faa..e1029e3e4b 100644 --- a/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs +++ b/Projectiles/Melee/Yoyos/GodsGambitYoyo.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; } public override void AI() diff --git a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs index a758375420..201017c0db 100644 --- a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; } diff --git a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs index c8440e1a43..cd4b7f222a 100644 --- a/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs +++ b/Projectiles/Melee/Yoyos/MicrowaveYoyo.cs @@ -38,9 +38,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.localNPCHitCooldown = 20; } public override void SendExtraAI(BinaryWriter writer) => writer.Write(soundCooldown); diff --git a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs index 54f1f2c5d9..06eaece88a 100644 --- a/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/ObliteratorYoyo.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos // Ensures that the main AI only runs once per frame, despite the projectile's multiple updates private int extraUpdateCounter = 0; - private const int UpdatesPerFrame = 3; + private const int UpdatesPerFrame = 2; public override void SetStaticDefaults() { @@ -36,7 +36,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = UpdatesPerFrame; - projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 3 * UpdatesPerFrame; } diff --git a/Projectiles/Melee/Yoyos/OblivionYoyo.cs b/Projectiles/Melee/Yoyos/OblivionYoyo.cs index a0ef4e0d6d..43df6ecdc5 100644 --- a/Projectiles/Melee/Yoyos/OblivionYoyo.cs +++ b/Projectiles/Melee/Yoyos/OblivionYoyo.cs @@ -29,6 +29,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; } public override void AI() diff --git a/Projectiles/Melee/Yoyos/OracleYoyo.cs b/Projectiles/Melee/Yoyos/OracleYoyo.cs index accefa75a7..e23ff9c76e 100644 --- a/Projectiles/Melee/Yoyos/OracleYoyo.cs +++ b/Projectiles/Melee/Yoyos/OracleYoyo.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,11 +11,15 @@ namespace CalamityMod.Projectiles.Melee.Yoyos { public class OracleYoyo : ModProjectile { + public int AuraFrame; + // projectile.localAI[1] is the Aura Charge of the red lightning aura // Minimum value is zero. Maximum value is 200. // The aura turns on and begins damaging enemies at 20 charge. // The yoyo "supercharges" at 50 charge. // Its size caps out at 100 charge. + public ref float AuraCharge => ref projectile.localAI[1]; + private const float MaxCharge = 200f; private const float MinAuraRadius = 20f; private const float SuperchargeThreshold = 50f; @@ -26,7 +31,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos private const int HitsPerOrbVolley = 3; // Ensures that the main AI only runs once per frame, despite the projectile's multiple updates - private int extraUpdateCounter = 0; private const int UpdatesPerFrame = 3; public override void SetStaticDefaults() @@ -40,6 +44,18 @@ namespace CalamityMod.Projectiles.Melee.Yoyos ProjectileID.Sets.TrailingMode[projectile.type] = 1; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(AuraFrame); + writer.Write(AuraCharge); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + AuraFrame = reader.ReadInt32(); + AuraCharge = reader.ReadSingle(); + } + public override void SetDefaults() { projectile.aiStyle = 99; @@ -50,7 +66,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = UpdatesPerFrame; - projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 3 * UpdatesPerFrame; } @@ -61,8 +76,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.Kill(); // Only do stuff once per frame, despite the yoyo's extra updates. - extraUpdateCounter = (extraUpdateCounter + 1) % UpdatesPerFrame; - if (extraUpdateCounter != UpdatesPerFrame - 1) + if (!projectile.FinalExtraUpdate()) return; // Produces golden dust constantly while in flight. This helps light the yoyo. @@ -80,21 +94,21 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Lighting.AddLight(projectile.Center, 0.6f, 0.42f, 0.1f); // The aura discharges over time based on its current charge. - float discharge = MinDischargeRate + DischargeRateScaleFactor * projectile.localAI[1]; + float discharge = MinDischargeRate + DischargeRateScaleFactor * AuraCharge; if (discharge > MaxDischargeRate) discharge = MaxDischargeRate; - projectile.localAI[1] -= discharge; + AuraCharge -= discharge; // Boundary checks on aura charge - if (projectile.localAI[1] < 0f) - projectile.localAI[1] = 0f; - if (projectile.localAI[1] > MaxCharge) - projectile.localAI[1] = MaxCharge; + if (AuraCharge < 0f) + AuraCharge = 0f; + if (AuraCharge > MaxCharge) + AuraCharge = MaxCharge; // If the aura is large enough to be considered "on", draw it, make sound and damage enemies - if (projectile.localAI[1] > MinAuraRadius) + if (AuraCharge > MinAuraRadius) { - float auraRadius = projectile.localAI[1] > MaxAuraRadius ? MaxAuraRadius : projectile.localAI[1]; + float auraRadius = AuraCharge > MaxAuraRadius ? MaxAuraRadius : AuraCharge; DrawRedLightningAura(auraRadius); if (projectile.soundDelay == 0) @@ -103,13 +117,17 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Main.PlaySound(SoundID.Item93, (int)projectile.Center.X, (int)projectile.Center.Y); } - // The aura's direct damage scales with its charge and with melee stats. - float chargeRatio = projectile.localAI[1] / MaxCharge; - int auraDamage = Oracle.AuraBaseDamage + (int)(chargeRatio * (Oracle.AuraMaxDamage - Oracle.AuraBaseDamage)); - DealAuraDamage(auraRadius, auraDamage); + if (AuraFrame % 5 == 4) + { + // The aura's direct damage scales with its charge and with melee stats. + float chargeRatio = AuraCharge / MaxCharge; + int auraDamage = Oracle.AuraBaseDamage + (int)(chargeRatio * (Oracle.AuraMaxDamage - Oracle.AuraBaseDamage)); + DealAuraDamage(auraRadius, auraDamage); + } } else projectile.soundDelay = 2; + AuraFrame++; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -121,10 +139,10 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { // Charge up the red lightning aura with every hit - projectile.localAI[1] += ChargePerHit; + AuraCharge += ChargePerHit; // Fire Auric orbs every few hits while supercharged. - if (projectile.localAI[1] > SuperchargeThreshold && projectile.numHits % HitsPerOrbVolley == 0) + if (AuraCharge > SuperchargeThreshold && projectile.numHits % HitsPerOrbVolley == 0) FireAuricOrbs(); } diff --git a/Projectiles/Melee/Yoyos/PandemicYoyo.cs b/Projectiles/Melee/Yoyos/PandemicYoyo.cs index 8966f1c388..2f1f74570b 100644 --- a/Projectiles/Melee/Yoyos/PandemicYoyo.cs +++ b/Projectiles/Melee/Yoyos/PandemicYoyo.cs @@ -27,6 +27,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; } public override void AI() diff --git a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs index 0d53abad5f..e95d79ae4e 100644 --- a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs +++ b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs @@ -25,7 +25,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } public override void AI() { diff --git a/Projectiles/Melee/Yoyos/RiptideYoyo.cs b/Projectiles/Melee/Yoyos/RiptideYoyo.cs index 569a1d2331..5c53857f7f 100644 --- a/Projectiles/Melee/Yoyos/RiptideYoyo.cs +++ b/Projectiles/Melee/Yoyos/RiptideYoyo.cs @@ -25,6 +25,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.alpha = 150; projectile.penetrate = -1; projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; } public override void AI() diff --git a/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs b/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs index 2814140d07..bd4b4337bb 100644 --- a/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs +++ b/Projectiles/Melee/Yoyos/ShimmersparkYoyo.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; } public override void AI() diff --git a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs b/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs index eaea97cb2c..4d2d4464ff 100644 --- a/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs +++ b/Projectiles/Melee/Yoyos/SolarFlareYoyo.cs @@ -31,7 +31,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; } diff --git a/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs b/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs index 5cfd7e4e36..4ea86694f0 100644 --- a/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs +++ b/Projectiles/Melee/Yoyos/SulphurousGrabberYoyo.cs @@ -35,7 +35,9 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.friendly = true; projectile.melee = true; projectile.penetrate = -1; - } + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } public override void AI() { diff --git a/Projectiles/Melee/Yoyos/VerdantYoyo.cs b/Projectiles/Melee/Yoyos/VerdantYoyo.cs index e610d28d43..758b45ac1c 100644 --- a/Projectiles/Melee/Yoyos/VerdantYoyo.cs +++ b/Projectiles/Melee/Yoyos/VerdantYoyo.cs @@ -29,7 +29,6 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; - projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 9; } diff --git a/Projectiles/Melee/Yoyos/YinYoyo.cs b/Projectiles/Melee/Yoyos/YinYoyo.cs index 24a6695aa1..a6cb99b6ae 100644 --- a/Projectiles/Melee/Yoyos/YinYoyo.cs +++ b/Projectiles/Melee/Yoyos/YinYoyo.cs @@ -26,6 +26,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.melee = true; projectile.penetrate = -1; projectile.MaxUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 20; } public override void AI() diff --git a/Projectiles/Pets/LittleLightProj.cs b/Projectiles/Pets/LittleLightProj.cs new file mode 100644 index 0000000000..93ce8385ea --- /dev/null +++ b/Projectiles/Pets/LittleLightProj.cs @@ -0,0 +1,102 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Pets +{ + public class LittleLightProj : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + + public Color LightColor => new Color(160, 251, 255); + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Little Light"); + Main.projFrames[projectile.type] = 9; + Main.projPet[projectile.type] = true; + ProjectileID.Sets.LightPet[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.friendly = true; + projectile.netImportant = true; + projectile.penetrate = -1; + } + + public override void AI() + { + if (VerifyOwnerIsPresent()) + return; + + HandleFrames(); + DoSpinEffect(); + HoverTowardsOwnersShoulder(); + + // Look in the same direction as the projectile's owner. + projectile.spriteDirection = Owner.direction; + + // Emit light. + // Suspicious Looking Tentacle uses 1.5f as a brightness factor, for reference. + Lighting.AddLight(projectile.Center, LightColor.ToVector3() * 2.5f); + + Time++; + } + + public bool VerifyOwnerIsPresent() + { + // No logic should be run if the player is no longer active in the game. + if (!Owner.active) + { + projectile.Kill(); + return true; + } + + if (Owner.dead) + Owner.Calamity().littleLightPet = false; + if (Owner.Calamity().littleLightPet) + projectile.timeLeft = 2; + + return false; + } + + 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; + else + projectile.rotation = 0f; + } + + public void HoverTowardsOwnersShoulder() + { + Vector2 destination = Owner.Top; + destination.X -= Owner.direction * Owner.width * 1.25f; + destination.Y += Owner.height * 0.25f; + + // Hover in the air a little bit over time so that the pet doesn't seem static. + destination.Y += (float)Math.Sin(MathHelper.TwoPi * Time / 45f) * 5f; + + projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.125f); + if (projectile.WithinRange(destination, 10f)) + projectile.Center = destination; + else + projectile.Center += projectile.SafeDirectionTo(destination) * 4f; + + projectile.Center = destination; + } + } +} diff --git a/Projectiles/Pets/LittleLightProj.png b/Projectiles/Pets/LittleLightProj.png new file mode 100644 index 0000000000..d079096803 Binary files /dev/null and b/Projectiles/Pets/LittleLightProj.png differ diff --git a/Projectiles/Ranged/ArcticArrowProj.cs b/Projectiles/Ranged/ArcticArrowProj.cs index fcafcb16ae..4b4258b268 100644 --- a/Projectiles/Ranged/ArcticArrowProj.cs +++ b/Projectiles/Ranged/ArcticArrowProj.cs @@ -68,7 +68,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Ranged/AstrealArrow.cs b/Projectiles/Ranged/AstrealArrow.cs index 5b8f6ad345..3f2a15f679 100644 --- a/Projectiles/Ranged/AstrealArrow.cs +++ b/Projectiles/Ranged/AstrealArrow.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.width = 18; projectile.height = 18; projectile.alpha = 255; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.ranged = true; projectile.arrow = true; projectile.extraUpdates = 1; diff --git a/Projectiles/Ranged/BlueExoArrow.cs b/Projectiles/Ranged/BlueExoArrow.cs index 0e061d63e2..14357bb61c 100644 --- a/Projectiles/Ranged/BlueExoArrow.cs +++ b/Projectiles/Ranged/BlueExoArrow.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.alpha = 255; projectile.penetrate = 1; - projectile.extraUpdates = 2; + projectile.extraUpdates = 3; projectile.timeLeft = 300; projectile.ranged = true; projectile.arrow = true; diff --git a/Projectiles/Ranged/BouncingShotgunPellet.cs b/Projectiles/Ranged/BouncingShotgunPellet.cs new file mode 100644 index 0000000000..75ab8ea2ff --- /dev/null +++ b/Projectiles/Ranged/BouncingShotgunPellet.cs @@ -0,0 +1,68 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Ranged +{ + public class BouncingShotgunPellet : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Ranged/RealmRavagerBullet"; + private int bounce = 2; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Shotgun Pellet"); + } + + public override void SetDefaults() + { + projectile.width = 4; + projectile.height = 4; + projectile.light = 0.5f; + projectile.alpha = 255; + projectile.ranged = true; + projectile.friendly = true; + projectile.aiStyle = 1; + aiType = ProjectileID.BulletHighVelocity; + projectile.timeLeft = 180; + } + + 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; + Main.PlaySound(SoundID.Item10, projectile.Center); + projectile.damage /= 2; + } + return false; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => Main.PlaySound(SoundID.Item10, projectile.Center); + + public override void OnHitPvp(Player target, int damage, bool crit) => Main.PlaySound(SoundID.Item10, projectile.Center); + + public override void Kill(int timeLeft) + { + 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); + } + for (int d = 0; d < 20; d++) + { + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 0, default, 2.5f); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1.5f); + Main.dust[idx].velocity *= 2f; + Main.dust[idx].noGravity = true; + } + } + } +} diff --git a/Projectiles/Ranged/BrimstoneBallFriendly.cs b/Projectiles/Ranged/BrimstoneBallFriendly.cs index 0f2aa04a00..34b2218740 100644 --- a/Projectiles/Ranged/BrimstoneBallFriendly.cs +++ b/Projectiles/Ranged/BrimstoneBallFriendly.cs @@ -47,7 +47,6 @@ namespace CalamityMod.Projectiles.Ranged } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Ranged/ChargedBlast2.cs b/Projectiles/Ranged/ChargedBlast2.cs index d78d385798..6a57cc9aba 100644 --- a/Projectiles/Ranged/ChargedBlast2.cs +++ b/Projectiles/Ranged/ChargedBlast2.cs @@ -72,7 +72,6 @@ namespace CalamityMod.Projectiles.Ranged } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Ranged/ChargedBlast3.cs b/Projectiles/Ranged/ChargedBlast3.cs index e933a04bfa..80b4c01193 100644 --- a/Projectiles/Ranged/ChargedBlast3.cs +++ b/Projectiles/Ranged/ChargedBlast3.cs @@ -72,7 +72,6 @@ namespace CalamityMod.Projectiles.Ranged } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Ranged/CondemnationArrow.cs b/Projectiles/Ranged/CondemnationArrow.cs new file mode 100644 index 0000000000..ea57b89d1e --- /dev/null +++ b/Projectiles/Ranged/CondemnationArrow.cs @@ -0,0 +1,90 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class CondemnationArrow : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Condemnation Arrow"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 9; + } + + public override void SetDefaults() + { + projectile.width = 26; + projectile.height = 90; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.ranged = true; + projectile.arrow = true; + projectile.extraUpdates = 1; + projectile.timeLeft = 300; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.Violet.ToVector3()); + projectile.Opacity = Utils.InverseLerp(0f, 20f, Time, true); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + Time++; + + // Release side arrows every so often. + if (Main.netMode != NetmodeID.MultiplayerClient && Time % 90f == 89f) + { + for (int i = -1; i <= 1; i += 2) + { + Vector2 shootVelocity = projectile.velocity.RotatedBy(i * 0.036f); + Projectile.NewProjectile(projectile.Center, shootVelocity, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack, projectile.owner); + } + } + } + + public override Color? GetAlpha(Color lightColor) + { + Color c1 = new Color(226, 40, 40, 0); + Color c2 = new Color(205, 0, 194, 0); + Color fadeColor = Color.Lerp(c1, c2, (float)Math.Cos(projectile.identity * 1.41f + Main.GlobalTime * 8f) * 0.5f + 0.5f); + return Color.Lerp(lightColor, fadeColor, 0.5f) * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + + public override void Kill(int timeLeft) + { + // Release a burst of magic dust on death. + if (Main.dedServ) + return; + + for (int i = 0; i < 30; i++) + { + Dust fire = Dust.NewDustPerfect(projectile.Center, 130); + fire.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(0.8f) * new Vector2(4f, 1.25f) * Main.rand.NextFloat(0.9f, 1f); + fire.velocity = fire.velocity.RotatedBy(projectile.rotation - MathHelper.PiOver2); + fire.velocity += projectile.velocity * 0.7f; + + fire.noGravity = true; + fire.color = Color.Lerp(Color.White, Color.Purple, Main.rand.NextFloat()); + fire.scale = Main.rand.NextFloat(1f, 1.1f); + + fire = Dust.CloneDust(fire); + fire.velocity = Main.rand.NextVector2Circular(3f, 3f); + fire.velocity += projectile.velocity * 0.6f; + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); + } +} diff --git a/Projectiles/Ranged/CondemnationArrow.png b/Projectiles/Ranged/CondemnationArrow.png new file mode 100644 index 0000000000..3b2032bb20 Binary files /dev/null and b/Projectiles/Ranged/CondemnationArrow.png differ diff --git a/Projectiles/Ranged/CondemnationArrowHoming.cs b/Projectiles/Ranged/CondemnationArrowHoming.cs new file mode 100644 index 0000000000..14d7acf2b3 --- /dev/null +++ b/Projectiles/Ranged/CondemnationArrowHoming.cs @@ -0,0 +1,78 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class CondemnationArrowHoming : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Ranged/CondemnationArrow"; + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Condemnation Arrow"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 9; + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 45; + projectile.scale = 0.5f; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = true; + projectile.ranged = true; + projectile.arrow = true; + projectile.extraUpdates = 1; + projectile.timeLeft = 300; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.Violet.ToVector3()); + projectile.Opacity = Utils.InverseLerp(0f, 20f, Time, true) * Utils.InverseLerp(0f, 20f, projectile.timeLeft, true); + + NPC potentialTarget = projectile.Center.ClosestNPCAt(1500f, false); + if (potentialTarget != null) + projectile.velocity = (projectile.velocity * 29f + projectile.SafeDirectionTo(potentialTarget.Center) * 21f) / 30f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + Time++; + } + + public override Color? GetAlpha(Color lightColor) + { + Color c1 = new Color(226, 40, 40, 0); + Color c2 = new Color(205, 0, 194, 0); + return Color.Lerp(c1, c2, (float)Math.Cos(projectile.identity * 1.41f + Main.GlobalTime * 8f) * 0.5f + 0.5f) * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + + public override void Kill(int timeLeft) + { + // Release a burst of magic dust on death. + if (Main.dedServ) + return; + + for (int i = 0; i < 10; i++) + { + Dust fire = Dust.NewDustPerfect(projectile.Center, 267); + fire.velocity = Main.rand.NextVector2Circular(2f, 2f); + fire.color = Color.Lerp(Color.Red, Color.Purple, Main.rand.NextFloat()); + fire.scale = Main.rand.NextFloat(1f, 1.1f); + fire.noGravity = true; + } + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); + } +} diff --git a/Projectiles/Ranged/CondemnationHoldout.cs b/Projectiles/Ranged/CondemnationHoldout.cs new file mode 100644 index 0000000000..1ac21ab858 --- /dev/null +++ b/Projectiles/Ranged/CondemnationHoldout.cs @@ -0,0 +1,146 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class CondemnationHoldout : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public bool OwnerCanShoot => Owner.channel && Owner.HasAmmo(Owner.ActiveItem(), true) && !Owner.noItems && !Owner.CCed; + public ref float ChargeUpTime => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Items/Weapons/Ranged/Condemnation"; + public override void SetStaticDefaults() => DisplayName.SetDefault("Condemnation"); + + public override void SetDefaults() + { + projectile.width = 130; + projectile.height = 42; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ranged = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + + Vector2 tipPosition = armPosition + projectile.velocity * projectile.width * 0.5f; + if (ChargeUpTime < 20f) + ReleaseInitialChargeDust(tipPosition); + if (ChargeUpTime == 20f) + ReleaseInitialBurstDust(tipPosition); + + // Release projectiles after done charging. + if (!OwnerCanShoot) + { + projectile.Kill(); + + // If killed prior to the charge being complete, don't bother spawning anything. Just die. + if (ChargeUpTime < 20f) + return; + + int totalProjectilesToShoot = (int)Math.Pow(ChargeUpTime * 0.15f, 0.71) + 1; + if (totalProjectilesToShoot > 32) + totalProjectilesToShoot = 32; + + for (int i = 0; i < totalProjectilesToShoot; i++) + ShootProjectiles(tipPosition, MathHelper.Lerp(0.425f, 1f, i / (float)totalProjectilesToShoot)); + + Main.PlaySound(SoundID.DD2_BallistaTowerShot); + } + + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + ChargeUpTime++; + } + + public void ReleaseInitialBurstDust(Vector2 tipPosition) + { + if (Main.dedServ) + return; + + for (int i = 0; i < 36; i++) + { + Dust chargeMagic = Dust.NewDustPerfect(tipPosition, 267); + chargeMagic.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * 5f + Owner.velocity; + chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); + chargeMagic.color = Color.Violet; + chargeMagic.noGravity = true; + } + } + + public void ReleaseInitialChargeDust(Vector2 tipPosition) + { + if (Main.dedServ) + return; + + for (int i = 0; i < 2; i++) + { + Dust chargeMagic = Dust.NewDustPerfect(tipPosition + Main.rand.NextVector2Circular(20f, 20f), 267); + chargeMagic.velocity = (tipPosition - chargeMagic.position) * 0.1f + Owner.velocity; + chargeMagic.scale = Main.rand.NextFloat(1f, 1.5f); + chargeMagic.color = projectile.GetAlpha(Color.White); + chargeMagic.noGravity = true; + } + } + + public void ShootProjectiles(Vector2 tipPosition, float speedFactor) + { + if (Main.myPlayer != projectile.owner) + return; + + Item heldItem = Owner.ActiveItem(); + int projectileType = ModContent.ProjectileType(); + float shootSpeed = heldItem.shootSpeed * speedFactor * 1.5f; + int damage = (int)(Owner.GetWeaponDamage(heldItem) * 1.45); + float knockback = heldItem.knockBack; + + bool uselessFuckYou = OwnerCanShoot; + Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref damage, ref knockback, false); + projectileType = ModContent.ProjectileType(); + + knockback = Owner.GetWeaponKnockback(heldItem, knockback); + Vector2 shootVelocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * shootSpeed; + + Projectile.NewProjectile(tipPosition, shootVelocity, projectileType, damage, knockback, projectile.owner, 0f, 0f); + } + + public void UpdateProjectileHeldVariables(Vector2 armPosition) + { + if (Main.myPlayer == projectile.owner) + { + float interpolant = Utils.InverseLerp(5f, 25f, projectile.Distance(Main.MouseWorld), true); + Vector2 oldVelocity = projectile.velocity; + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(Main.MouseWorld), interpolant); + if (projectile.velocity != oldVelocity) + { + projectile.netSpam = 0; + projectile.netUpdate = true; + } + } + + projectile.position = armPosition - projectile.Size * 0.5f; + projectile.rotation = projectile.velocity.ToRotation(); + if (projectile.spriteDirection == -1) + projectile.rotation += MathHelper.Pi; + projectile.spriteDirection = projectile.direction; + projectile.timeLeft = 2; + } + + public void ManipulatePlayerVariables() + { + Owner.ChangeDir(projectile.direction); + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Ranged/CorrodedShell.cs b/Projectiles/Ranged/CorrodedShell.cs index 88dd5d207b..55eb1d8d3c 100644 --- a/Projectiles/Ranged/CorrodedShell.cs +++ b/Projectiles/Ranged/CorrodedShell.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ranged = true; projectile.arrow = true; - projectile.penetrate = 6; + projectile.ignoreWater = true; + projectile.penetrate = 6; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; diff --git a/Projectiles/Ranged/DrizzlefishFireball.cs b/Projectiles/Ranged/DrizzlefishFireball.cs index a34ed3f622..886768a044 100644 --- a/Projectiles/Ranged/DrizzlefishFireball.cs +++ b/Projectiles/Ranged/DrizzlefishFireball.cs @@ -60,10 +60,6 @@ namespace CalamityMod.Projectiles.Ranged public override bool OnTileCollide(Vector2 oldVelocity) { - if (projectile.penetrate <= 0) - { - projectile.Kill(); - } projectile.velocity *= 0.98f; return false; } diff --git a/Projectiles/Ranged/EmesisGore.cs b/Projectiles/Ranged/EmesisGore.cs index e31c82702e..5791500a5d 100644 --- a/Projectiles/Ranged/EmesisGore.cs +++ b/Projectiles/Ranged/EmesisGore.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.penetrate = 10; projectile.timeLeft = 600; projectile.ranged = true; - projectile.usesLocalNPCImmunity = true; + projectile.ignoreWater = true; + projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 6; } public override void SendExtraAI(BinaryWriter writer) diff --git a/Projectiles/Ranged/ExoLight.cs b/Projectiles/Ranged/ExoLight.cs index 8978b339e7..9b76732b06 100644 --- a/Projectiles/Ranged/ExoLight.cs +++ b/Projectiles/Ranged/ExoLight.cs @@ -48,6 +48,14 @@ namespace CalamityMod.Projectiles.Ranged OffsetSpeed = Main.rand.NextFloat(MathHelper.ToRadians(2.5f), MathHelper.ToRadians(4f)) * Main.rand.NextBool(2).ToDirectionInt(); projectile.localAI[0] = 1f; } + + // Ensure that the owner projectile index is a valid one. + if (!Main.projectile.IndexInRange((int)projectile.localAI[1])) + { + projectile.Kill(); + return; + } + Projectile owner = Main.projectile[(int)projectile.localAI[1]]; // Ensure the owner is the correct projectile. diff --git a/Projectiles/Ranged/ExoLightBomb.cs b/Projectiles/Ranged/ExoLightBomb.cs index ac6a9d4dbc..65c54e31ff 100644 --- a/Projectiles/Ranged/ExoLightBomb.cs +++ b/Projectiles/Ranged/ExoLightBomb.cs @@ -52,10 +52,12 @@ namespace CalamityMod.Projectiles.Ranged public override void SendExtraAI(BinaryWriter writer) { writer.Write(YDirection); + writer.WriteVector2(Destination); } public override void ReceiveExtraAI(BinaryReader reader) { YDirection = reader.ReadSingle(); + Destination = reader.ReadVector2(); } public override void AI() @@ -66,7 +68,11 @@ namespace CalamityMod.Projectiles.Ranged if (projectile.localAI[0] == 0f) { InitialCenter = projectile.Center; - Destination = Main.MouseWorld; + if (Main.myPlayer == projectile.owner) + { + Destination = Main.MouseWorld; + projectile.netUpdate = true; + } DustType = Main.rand.NextBool(2) ? 107 : 234; if (Main.rand.NextBool(4)) { @@ -74,6 +80,10 @@ namespace CalamityMod.Projectiles.Ranged } projectile.localAI[0] = 1f; } + + if (Destination == Vector2.Zero) + return; + if (Time <= 90f) { projectile.position = Vector2.Lerp(InitialCenter, Destination, Time / 90f); @@ -92,9 +102,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.Center = Destination + ((Time - 90) / 90f * MathHelper.ToRadians(720f) + (YDirection == -1).ToInt() * MathHelper.Pi).ToRotationVector2() * radius; } else if (Time == 180f) - { projectile.Kill(); - } + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; Time++; } @@ -174,7 +183,6 @@ namespace CalamityMod.Projectiles.Ranged { target.AddBuff(ModContent.BuffType(), 30); target.AddBuff(ModContent.BuffType(), 180); - target.AddBuff(ModContent.BuffType(), 90); target.AddBuff(ModContent.BuffType(), 180); target.AddBuff(ModContent.BuffType(), 180); target.AddBuff(BuffID.CursedInferno, 180); diff --git a/Projectiles/Ranged/ExoLightBurst.cs b/Projectiles/Ranged/ExoLightBurst.cs index 8abad44ce5..02a59edf62 100644 --- a/Projectiles/Ranged/ExoLightBurst.cs +++ b/Projectiles/Ranged/ExoLightBurst.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetDefaults() { - projectile.width = projectile.height = 190; + projectile.width = projectile.height = 50; projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; @@ -68,17 +68,15 @@ namespace CalamityMod.Projectiles.Ranged projectile.ModifyHitNPCSticky(4, false); } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - int width = (int)MathHelper.Min(targetHitbox.Width, 150); - int height = (int)MathHelper.Min(targetHitbox.Height, 150); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, width, height); - return null; - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.ExoDebuffs(2f); + if (projectile.width == 50) + { + int width = (int)MathHelper.Min(target.Hitbox.Width, 60); + int height = (int)MathHelper.Min(target.Hitbox.Height, 60); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, width, height); + } + target.ExoDebuffs(2f); } public override void OnHitPvp(Player target, int damage, bool crit) diff --git a/Projectiles/Ranged/ExoMark.cs b/Projectiles/Ranged/ExoMark.cs index c5fc26bde6..b73065b0fe 100644 --- a/Projectiles/Ranged/ExoMark.cs +++ b/Projectiles/Ranged/ExoMark.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.alpha = 255; projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 9; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 9; } public override void AI() diff --git a/Projectiles/Ranged/ExoSpark.cs b/Projectiles/Ranged/ExoSpark.cs index c698b23d06..3e68966afb 100644 --- a/Projectiles/Ranged/ExoSpark.cs +++ b/Projectiles/Ranged/ExoSpark.cs @@ -71,7 +71,6 @@ 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(), 60); target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.CursedInferno, 120); diff --git a/Projectiles/Ranged/ExoTornado.cs b/Projectiles/Ranged/ExoTornado.cs index b3bd669ef0..45f0fa1cff 100644 --- a/Projectiles/Ranged/ExoTornado.cs +++ b/Projectiles/Ranged/ExoTornado.cs @@ -22,9 +22,9 @@ namespace CalamityMod.Projectiles.Ranged projectile.tileCollide = false; projectile.ranged = true; projectile.penetrate = -1; - projectile.timeLeft = 240; //1200 - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.timeLeft = 240; + projectile.usesIDStaticNPCImmunity = true; + projectile.idStaticNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Ranged/FlareBat.cs b/Projectiles/Ranged/FlareBat.cs index c2ace743bd..7eab0f6951 100644 --- a/Projectiles/Ranged/FlareBat.cs +++ b/Projectiles/Ranged/FlareBat.cs @@ -72,7 +72,6 @@ namespace CalamityMod.Projectiles.Ranged } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Ranged/FrostsparkBulletProj.cs b/Projectiles/Ranged/FrostsparkBulletProj.cs index 553da055da..e4d3ae7e9e 100644 --- a/Projectiles/Ranged/FrostsparkBulletProj.cs +++ b/Projectiles/Ranged/FrostsparkBulletProj.cs @@ -65,7 +65,7 @@ namespace CalamityMod.Projectiles.Ranged { target.AddBuff(BuffID.OnFire, 240); target.AddBuff(BuffID.Frostburn, 240); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override void Kill(int timeLeft) diff --git a/Projectiles/Ranged/GreenExoArrow.cs b/Projectiles/Ranged/GreenExoArrow.cs index 2a2ee4d75b..65c54c1fdb 100644 --- a/Projectiles/Ranged/GreenExoArrow.cs +++ b/Projectiles/Ranged/GreenExoArrow.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.alpha = 255; projectile.penetrate = 1; - projectile.extraUpdates = 2; + projectile.extraUpdates = 3; projectile.timeLeft = 300; projectile.ranged = true; projectile.arrow = true; diff --git a/Projectiles/Ranged/IcicleArrowProj.cs b/Projectiles/Ranged/IcicleArrowProj.cs index d64bf468aa..bdf140f83f 100644 --- a/Projectiles/Ranged/IcicleArrowProj.cs +++ b/Projectiles/Ranged/IcicleArrowProj.cs @@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Ranged { 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, ProjectileID.CrystalShard, projectile.damage / 2, 0f, projectile.owner); + Projectile.NewProjectile(projectile.Center.X + SpeedX, projectile.Center.Y + SpeedY, SpeedX, SpeedY, ProjectileID.CrystalShard, projectile.damage / 3, 0f, projectile.owner); } } } diff --git a/Projectiles/Ranged/IcyBulletProj.cs b/Projectiles/Ranged/IcyBulletProj.cs index 26ec484952..d13fe4ba97 100644 --- a/Projectiles/Ranged/IcyBulletProj.cs +++ b/Projectiles/Ranged/IcyBulletProj.cs @@ -49,7 +49,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Ranged/MagnomalyBeam.cs b/Projectiles/Ranged/MagnomalyBeam.cs index d8089d5d66..ea0cc7d318 100644 --- a/Projectiles/Ranged/MagnomalyBeam.cs +++ b/Projectiles/Ranged/MagnomalyBeam.cs @@ -28,7 +28,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.extraUpdates = 5; projectile.timeLeft = 300; projectile.tileCollide = false; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Ranged/MagnomalyRocket.cs b/Projectiles/Ranged/MagnomalyRocket.cs index 7dca67ba5d..286ee8ae84 100644 --- a/Projectiles/Ranged/MagnomalyRocket.cs +++ b/Projectiles/Ranged/MagnomalyRocket.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 300; projectile.ranged = true; projectile.tileCollide = false; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Ranged/MistArrow.cs b/Projectiles/Ranged/MistArrow.cs index a4c846cd12..f61c8a76e9 100644 --- a/Projectiles/Ranged/MistArrow.cs +++ b/Projectiles/Ranged/MistArrow.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 240); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } } } diff --git a/Projectiles/Ranged/Nuke.cs b/Projectiles/Ranged/Nuke.cs index 0396839776..d2e3acd5b9 100644 --- a/Projectiles/Ranged/Nuke.cs +++ b/Projectiles/Ranged/Nuke.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.width = 22; projectile.height = 22; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 125; projectile.ranged = true; } diff --git a/Projectiles/Ranged/OrangeExoArrow.cs b/Projectiles/Ranged/OrangeExoArrow.cs index c1e86b9ed0..37cea96471 100644 --- a/Projectiles/Ranged/OrangeExoArrow.cs +++ b/Projectiles/Ranged/OrangeExoArrow.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.alpha = 255; projectile.penetrate = 1; - projectile.extraUpdates = 2; + projectile.extraUpdates = 3; projectile.timeLeft = 300; projectile.ranged = true; projectile.arrow = true; diff --git a/Projectiles/Ranged/PlanarRipperExplosion.cs b/Projectiles/Ranged/PlanarRipperExplosion.cs index dd04cf3136..835ca461c1 100644 --- a/Projectiles/Ranged/PlanarRipperExplosion.cs +++ b/Projectiles/Ranged/PlanarRipperExplosion.cs @@ -68,7 +68,7 @@ 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.8); + projectile.damage = (int)(projectile.damage * 0.75); } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Ranged/PrismComet.cs b/Projectiles/Ranged/PrismComet.cs new file mode 100644 index 0000000000..5fc4a36842 --- /dev/null +++ b/Projectiles/Ranged/PrismComet.cs @@ -0,0 +1,102 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PrismComet : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Projectiles/Melee/Exocomet"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Comet"); + Main.projFrames[projectile.type] = 5; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.scale = 0.86f; + projectile.width = projectile.height = 12; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.melee = true; + projectile.penetrate = 1; + projectile.alpha = 50; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.LightSeaGreen.ToVector3()); + projectile.frameCounter++; + if (projectile.frameCounter % 6 == 5) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + + projectile.alpha = Utils.Clamp(projectile.alpha - 25, 30, 255); + + if (projectile.alpha < 40) + ReleaseIdleDust(); + + // Home onto any targets after a short amount of time. + if (Time >= 25f) + { + NPC potentialTarget = projectile.Center.ClosestNPCAt(1050f); + if (potentialTarget != null) + projectile.velocity = (projectile.velocity * 12f + projectile.SafeDirectionTo(potentialTarget.Center) * 19f) / 13f; + } + else + projectile.velocity *= 1.05f; + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + Time++; + } + public void ReleaseIdleDust() + { + if (Main.dedServ) + return; + + Dust prismEnergy = Dust.NewDustDirect(projectile.position - projectile.velocity * 4f, 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); + prismEnergy.velocity *= -0.25f; + prismEnergy.velocity -= projectile.velocity * 0.3f; + + prismEnergy = Dust.NewDustDirect(projectile.position - projectile.velocity * 4f, 8, 8, 107, projectile.oldVelocity.X, projectile.oldVelocity.Y, 100, new Color(0, 255, 255), 0.5f); + prismEnergy.velocity *= -0.25f; + prismEnergy.position -= projectile.velocity * 0.5f; + prismEnergy.velocity -= projectile.velocity * 0.3f; + } + + public override bool CanDamage() => Time >= 20f; + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + + public override Color? GetAlpha(Color lightColor) + { + Color color = Color.Honeydew * projectile.Opacity; + color.A = 0; + return color; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Zombie, (int)projectile.position.X, (int)projectile.position.Y, 103, 1f, 0f); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 80); + projectile.Damage(); + + if (Main.myPlayer != projectile.owner) + return; + + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); + } + } +} diff --git a/Projectiles/Ranged/PrismEnergyBullet.cs b/Projectiles/Ranged/PrismEnergyBullet.cs new file mode 100644 index 0000000000..cf1920bd67 --- /dev/null +++ b/Projectiles/Ranged/PrismEnergyBullet.cs @@ -0,0 +1,69 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PrismEnergyBullet : ModProjectile + { + public ref float CurrentLaserLength => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override string Texture => "CalamityMod/Projectiles/LaserProj"; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Prism Rocket"); + + public override void SetDefaults() + { + projectile.scale = 1.7f; + projectile.width = projectile.height = 12; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = 300; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 13; + projectile.extraUpdates = 1; + projectile.ranged = true; + } + + public override void AI() + { + CurrentLaserLength = (int)MathHelper.Lerp(1f, 70f, Utils.InverseLerp(0f, 15f, Time, true) * Utils.InverseLerp(0f, 15f, projectile.timeLeft, true)); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + Time++; + } + + 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) + { + 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); + drawColor = Color.Lerp(drawColor, Color.Yellow, 0.55f); + drawColor = Color.Lerp(drawColor, Color.White, (float)Math.Pow(i / CurrentLaserLength, 3D)); + drawColor.A = 0; + + 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 new file mode 100644 index 0000000000..6ed873f793 --- /dev/null +++ b/Projectiles/Ranged/PrismExplosionLarge.cs @@ -0,0 +1,60 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PrismExplosionLarge : ModProjectile + { + public override void SetStaticDefaults() => DisplayName.SetDefault("Explosion"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 300; + projectile.friendly = true; + projectile.ignoreWater = false; + projectile.tileCollide = false; + projectile.ranged = true; + projectile.penetrate = -1; + projectile.timeLeft = 150; + projectile.extraUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 11; + projectile.scale = 0.35f; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 1.5f); + projectile.frameCounter++; + if (projectile.frameCounter % 8 == 7) + projectile.frame++; + + if (projectile.frame >= 18) + projectile.Kill(); + projectile.scale *= 1.0115f; + projectile.Opacity = Utils.InverseLerp(5f, 36f, projectile.timeLeft, true); + } + + 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); + Vector2 drawPosition = projectile.Center - Main.screenPosition; + Vector2 origin = frame.Size() * 0.5f; + + for (int i = 0; i < 36; i++) + { + Vector2 lightDrawPosition = drawPosition + (MathHelper.TwoPi * i / 36f + Main.GlobalTime * 5f).ToRotationVector2() * projectile.scale * 20f; + Color lightBurstColor = CalamityUtils.MulticolorLerp(projectile.timeLeft / 144f, Items.CalamityGlobalItem.ExoPalette); + lightBurstColor = Color.Lerp(lightBurstColor, Color.White, 0.4f) * projectile.Opacity * 0.04f; + lightBurstColor.A = 0; + spriteBatch.Draw(lightTexture, lightDrawPosition, null, lightBurstColor, 0f, lightTexture.Size() * 0.5f, projectile.scale * 2.5f, SpriteEffects.None, 0f); + } + spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1f, SpriteEffects.None, 0f); + return false; + } + } +} diff --git a/Projectiles/Ranged/PrismExplosionLarge.png b/Projectiles/Ranged/PrismExplosionLarge.png new file mode 100644 index 0000000000..3bbf34853c Binary files /dev/null and b/Projectiles/Ranged/PrismExplosionLarge.png differ diff --git a/Projectiles/Ranged/PrismExplosionSmall.cs b/Projectiles/Ranged/PrismExplosionSmall.cs new file mode 100644 index 0000000000..d1398625c0 --- /dev/null +++ b/Projectiles/Ranged/PrismExplosionSmall.cs @@ -0,0 +1,56 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PrismExplosionSmall : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Explosion"); + Main.projFrames[projectile.type] = 7; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 130; + projectile.friendly = true; + projectile.ignoreWater = false; + projectile.tileCollide = false; + projectile.ranged = true; + projectile.penetrate = -1; + projectile.timeLeft = 150; + projectile.extraUpdates = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 11; + projectile.scale = 0.5f; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 1.15f); + projectile.frameCounter++; + if (projectile.frameCounter % 8 == 7) + projectile.frame++; + + if (projectile.frame >= Main.projFrames[projectile.type]) + projectile.Kill(); + projectile.scale *= 1.0115f; + projectile.Opacity = Utils.InverseLerp(5f, 36f, projectile.timeLeft, true); + } + + 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); + Vector2 drawPosition = projectile.Center - Main.screenPosition; + Vector2 origin = frame.Size() * 0.5f; + + spriteBatch.Draw(texture, drawPosition, frame, Color.White, 0f, origin, 1f, SpriteEffects.None, 0f); + return false; + } + } +} diff --git a/Projectiles/Ranged/PrismExplosionSmall.png b/Projectiles/Ranged/PrismExplosionSmall.png new file mode 100644 index 0000000000..b4c5a29207 Binary files /dev/null and b/Projectiles/Ranged/PrismExplosionSmall.png differ diff --git a/Projectiles/Ranged/PrismMine.cs b/Projectiles/Ranged/PrismMine.cs new file mode 100644 index 0000000000..b2e06f1ef6 --- /dev/null +++ b/Projectiles/Ranged/PrismMine.cs @@ -0,0 +1,110 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class PrismMine : ModProjectile + { + public List MinesToConnectTo = new List(); + public ref float Time => ref projectile.ai[0]; + public const float MineConnectDistanceMax = 850f; + public override void SetStaticDefaults() => DisplayName.SetDefault("Mine"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 40; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.ranged = true; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 7; + projectile.timeLeft = 280; + } + + public override void AI() + { + projectile.velocity *= 0.94f; + Lighting.AddLight(projectile.Center, Color.Cyan.ToVector3()); + + float idealScale = MathHelper.Lerp(0.93f, 1.07f, (float)Math.Sin(MathHelper.TwoPi * projectile.timeLeft / 14f) * 0.5f + 0.5f); + projectile.scale = MathHelper.Lerp(0.15f, idealScale, Utils.InverseLerp(0f, 15f, Time, true) * Utils.InverseLerp(0f, 15f, projectile.timeLeft, true)); + Time++; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + foreach (Projectile mine in LocateOtherMines()) + { + if (projectile.timeLeft <= 12) + break; + + float _ = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, mine.Center, 20f, ref _)) + return true; + } + return base.Colliding(projHitbox, targetHitbox); + } + + public List LocateOtherMines() + { + List mines = new List(); + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile proj = Main.projectile[i]; + if (proj.type != projectile.type || !proj.active || proj.timeLeft <= 12 || i == projectile.whoAmI) + continue; + if (!projectile.WithinRange(proj.Center, MineConnectDistanceMax)) + continue; + + mines.Add(proj); + } + + return mines; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D baseTexture = Main.projectileTexture[projectile.type]; + Texture2D glowTexture = ModContent.GetTexture($"{Texture}Glowmask"); + Texture2D laserTexture = ModContent.GetTexture($"CalamityMod/Projectiles/Ranged/PrismMineArc"); + + void drawLineTo(Vector2 destination, Color laserColor) + { + float rotation = projectile.AngleTo(destination); + float remainingDistance = projectile.Distance(destination) - 30f; + float laserScale = 0.5f; + Rectangle frame = laserTexture.Frame(1, 7, 0, (int)(Main.GlobalTime * 17f + projectile.identity * 3f) % 7); + Vector2 laserOrigin = frame.Size() * 0.5f; + while (remainingDistance > frame.Height * laserScale) + { + Vector2 laserDrawPosition = projectile.Center + projectile.SafeDirectionTo(destination, -Vector2.UnitY) * remainingDistance - Main.screenPosition; + spriteBatch.Draw(laserTexture, laserDrawPosition, frame, laserColor, rotation, laserOrigin, laserScale, SpriteEffects.None, 0f); + remainingDistance -= frame.Height * laserScale; + } + } + + Vector2 origin = baseTexture.Size() * 0.5f; + Vector2 drawPosition = projectile.Center - Main.screenPosition; + + foreach (Projectile mine in LocateOtherMines()) + { + float fade = Utils.InverseLerp(8f, 24f, projectile.timeLeft, true) * Utils.InverseLerp(8f, 24f, mine.timeLeft, true); + drawLineTo(mine.Center, Color.White * fade); + } + + spriteBatch.Draw(baseTexture, drawPosition, null, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + + Rectangle glowFrame = glowTexture.Frame(1, 6, 0, (int)Time / 4 % 6); + Color glowColor = Color.White * 0.5f; + glowColor.A = 0; + spriteBatch.Draw(glowTexture, drawPosition, glowFrame, glowColor, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); + return false; + } + } +} \ No newline at end of file diff --git a/Projectiles/Ranged/PrismMine.png b/Projectiles/Ranged/PrismMine.png new file mode 100644 index 0000000000..f6e0b4a1e3 Binary files /dev/null and b/Projectiles/Ranged/PrismMine.png differ diff --git a/Projectiles/Ranged/PrismMineArc.png b/Projectiles/Ranged/PrismMineArc.png new file mode 100644 index 0000000000..5fa9c7b1b4 Binary files /dev/null and b/Projectiles/Ranged/PrismMineArc.png differ diff --git a/Projectiles/Ranged/PrismMineGlowmask.png b/Projectiles/Ranged/PrismMineGlowmask.png new file mode 100644 index 0000000000..bec3e59194 Binary files /dev/null and b/Projectiles/Ranged/PrismMineGlowmask.png differ diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.cs b/Projectiles/Ranged/PrismaticEnergyBlast.cs new file mode 100644 index 0000000000..073240ffd1 --- /dev/null +++ b/Projectiles/Ranged/PrismaticEnergyBlast.cs @@ -0,0 +1,147 @@ +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + 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 float MaxLaserLength => 2700f; + public override float Lifetime => 50f; + public override Color LaserOverlayColor => Color.White; + public override Color LightCastColor => LaserOverlayColor; + public override Texture2D LaserBeginTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/PrismLaserStart"); + public override Texture2D LaserMiddleTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/PrismLaserMid"); + public override Texture2D LaserEndTexture => ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/PrismLaserEnd"); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Energy Blast"); + Main.projFrames[projectile.type] = 5; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 14; + projectile.friendly = true; + projectile.ranged = true; + projectile.tileCollide = false; + projectile.penetrate = 100; + projectile.extraUpdates = 1; + projectile.timeLeft = 450; + } + + public override bool PreAI() + { + projectile.frameCounter++; + if (projectile.frameCounter % 5 == 4) + projectile.frame++; + + Vector2 laserEnd = projectile.position + projectile.velocity * LaserLength; + if (Collision.SolidCollision(laserEnd, 84, 84)) + CreateExplosion(laserEnd + projectile.Size * 0.5f); + return true; + } + + public void CreateExplosion(Vector2 laserEnd) + { + if (Main.myPlayer != projectile.owner || ExplodedYet || LaserLength <= 60f) + return; + + Projectile.NewProjectile(laserEnd, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); + + if (!ExplodedYet) + { + ExplodedYet = true; + projectile.netUpdate = true; + } + } + + public override float DetermineLaserLength() + { + if (projectile.penetrate == 100) + return DetermineLaserLength_CollideWithTiles(8); + return LaserLength; + } + + public override bool CanDamage() => projectile.penetrate == 100; + + 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) + { + Vector2 laserEnd = projectile.Center + projectile.velocity * LaserLength; + CreateExplosion(laserEnd); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + // Start texture drawing. + Rectangle beginFrame = LaserBeginTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + spriteBatch.Draw(LaserBeginTexture, + projectile.Center - Main.screenPosition, + beginFrame, + Color.White, + projectile.rotation, + beginFrame.Size() / 2f, + projectile.scale, + SpriteEffects.None, + 0f); + + // Prepare things for body drawing. + float laserBodyLength = LaserLength; + laserBodyLength -= (LaserBeginTexture.Height * 0.5f + LaserEndTexture.Height) * projectile.scale / Main.projFrames[projectile.type]; + Vector2 centerOnLaser = projectile.Center; + + // Body drawing. + Rectangle middleFrame = LaserMiddleTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + if (laserBodyLength > 30f) + { + float laserOffset = (LaserMiddleTexture.Height - 10f) * projectile.scale / Main.projFrames[projectile.type]; + float incrementalBodyLength = 0f; + while (incrementalBodyLength + 1f < laserBodyLength) + { + spriteBatch.Draw(LaserMiddleTexture, + centerOnLaser - Main.screenPosition, + middleFrame, + Color.White, + projectile.rotation, + middleFrame.Width * 0.5f * Vector2.UnitX, + projectile.scale, + SpriteEffects.None, + 0f); + incrementalBodyLength += laserOffset; + centerOnLaser += projectile.velocity * laserOffset; + } + } + + // End texture drawing. + Rectangle endFrame = LaserEndTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + Vector2 laserEndCenter = centerOnLaser - Main.screenPosition; + spriteBatch.Draw(LaserEndTexture, + laserEndCenter, + endFrame, + Color.White, + projectile.rotation, + endFrame.Size() * new Vector2(0.5f, 0f), + projectile.scale, + SpriteEffects.None, + 0f); + return false; + } + } +} diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.png b/Projectiles/Ranged/PrismaticEnergyBlast.png new file mode 100644 index 0000000000..8e2d2a871c Binary files /dev/null and b/Projectiles/Ranged/PrismaticEnergyBlast.png differ diff --git a/Projectiles/Ranged/ProBolt.cs b/Projectiles/Ranged/ProBolt.cs index 4ab36211b3..fe28af83db 100644 --- a/Projectiles/Ranged/ProBolt.cs +++ b/Projectiles/Ranged/ProBolt.cs @@ -63,7 +63,6 @@ namespace CalamityMod.Projectiles.Ranged } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Ranged/RainbowBlast.cs b/Projectiles/Ranged/RainbowBlast.cs index 630c2fb00b..a73b369265 100644 --- a/Projectiles/Ranged/RainbowBlast.cs +++ b/Projectiles/Ranged/RainbowBlast.cs @@ -50,7 +50,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); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Ranged/RealmRavagerBullet.cs b/Projectiles/Ranged/RealmRavagerBullet.cs index 8222e92154..6b93f23fdd 100644 --- a/Projectiles/Ranged/RealmRavagerBullet.cs +++ b/Projectiles/Ranged/RealmRavagerBullet.cs @@ -38,23 +38,20 @@ namespace CalamityMod.Projectiles.Ranged public override void Kill(int timeLeft) { - Main.PlaySound(SoundID.Item14, projectile.position); - projectile.position = projectile.Center; - 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); - for (int num193 = 0; num193 < 2; num193++) + Main.PlaySound(SoundID.Item14, projectile.Center); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 32); + for (int d = 0; d < 2; d++) { - Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 1.5f); + Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Smoke, 0f, 0f, 100, default, 1.5f); } - for (int num194 = 0; num194 < 20; num194++) + for (int d = 0; d < 20; d++) { - int num195 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 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, 6, 0f, 0f, 100, default, 1.5f); - Main.dust[num195].velocity *= 2f; - Main.dust[num195].noGravity = true; + int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 0, default, 2.5f); + Main.dust[idx].noGravity = true; + Main.dust[idx].velocity *= 3f; + idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, DustID.Fire, 0f, 0f, 100, default, 1.5f); + Main.dust[idx].velocity *= 2f; + Main.dust[idx].noGravity = true; } projectile.maxPenetrate = -1; projectile.penetrate = -1; diff --git a/Projectiles/Ranged/SeasSearingSecondary.cs b/Projectiles/Ranged/SeasSearingSecondary.cs index 2fb727a23d..3a2c79fd6d 100644 --- a/Projectiles/Ranged/SeasSearingSecondary.cs +++ b/Projectiles/Ranged/SeasSearingSecondary.cs @@ -3,6 +3,7 @@ using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using System; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { @@ -62,7 +63,7 @@ namespace CalamityMod.Projectiles.Ranged public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 360); target.AddBuff(ModContent.BuffType(), 360); } } diff --git a/Projectiles/Ranged/SepticSkewerHarpoon.cs b/Projectiles/Ranged/SepticSkewerHarpoon.cs index cbc39f3c5a..bce2cb5c9d 100644 --- a/Projectiles/Ranged/SepticSkewerHarpoon.cs +++ b/Projectiles/Ranged/SepticSkewerHarpoon.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.penetrate = -1; projectile.alpha = 255; - projectile.ranged = true; + projectile.ignoreWater = true; + projectile.ranged = true; projectile.extraUpdates = 1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 8; diff --git a/Projectiles/Ranged/Shell.cs b/Projectiles/Ranged/Shell.cs index 309ffb3d00..356d2eac5e 100644 --- a/Projectiles/Ranged/Shell.cs +++ b/Projectiles/Ranged/Shell.cs @@ -15,7 +15,8 @@ namespace CalamityMod.Projectiles.Ranged { projectile.width = 34; projectile.height = 18; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.ranged = true; projectile.penetrate = 5; projectile.aiStyle = 1; diff --git a/Projectiles/Ranged/SlimeBolt.cs b/Projectiles/Ranged/SlimeBolt.cs index e28d39bc95..df82641be0 100644 --- a/Projectiles/Ranged/SlimeBolt.cs +++ b/Projectiles/Ranged/SlimeBolt.cs @@ -41,7 +41,6 @@ namespace CalamityMod.Projectiles.Ranged } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Ranged/SurgeDriverHoldout.cs b/Projectiles/Ranged/SurgeDriverHoldout.cs new file mode 100644 index 0000000000..0031b41ef4 --- /dev/null +++ b/Projectiles/Ranged/SurgeDriverHoldout.cs @@ -0,0 +1,100 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + 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; + public ref float ShootCountdown => ref projectile.ai[0]; + public override void SetStaticDefaults() => DisplayName.SetDefault("Storm Driver"); + + public override void SetDefaults() + { + projectile.width = 192; + projectile.height = 52; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.ranged = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + if (!OwnerCanShoot) + projectile.Kill(); + + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + armPosition += projectile.velocity.SafeNormalize(Owner.direction * Vector2.UnitX) * 32f; + armPosition.Y -= 12f; + + UpdateProjectileHeldVariables(armPosition); + ManipulatePlayerVariables(); + + ShootCountdown--; + if (ShootCountdown <= 0f) + { + if (Main.myPlayer == projectile.owner) + { + ShootProjectiles(armPosition); + ShootCountdown = 28f; + projectile.netUpdate = true; + } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), projectile.Center); + } + } + + public void ShootProjectiles(Vector2 armPosition) + { + if (Main.myPlayer != projectile.owner) + return; + + Item heldItem = Owner.ActiveItem(); + int projectileType = ModContent.ProjectileType(); + float shootSpeed = heldItem.shootSpeed * projectile.scale * 0.64f; + int damage = (int)(Owner.GetWeaponDamage(heldItem) * 6.66); + float knockback = heldItem.knockBack; + + bool uselessFuckYou = OwnerCanShoot; + Owner.PickAmmo(heldItem, ref projectileType, ref shootSpeed, ref uselessFuckYou, ref damage, ref knockback, false); + projectileType = ModContent.ProjectileType(); + + knockback = Owner.GetWeaponKnockback(heldItem, knockback); + Vector2 shootDirection = (Main.MouseWorld - projectile.Center).SafeNormalize(-Vector2.UnitY); + Vector2 shootVelocity = shootDirection * shootSpeed; + + // Sync if the shoot direction changes. + if (shootDirection.X != projectile.velocity.X || shootDirection.Y != projectile.velocity.Y) + projectile.netUpdate = true; + + Vector2 gunTip = armPosition + shootDirection * heldItem.scale * 130f; + Projectile.NewProjectile(gunTip, shootVelocity, projectileType, damage, knockback, projectile.owner, 0f, 0f); + + projectile.velocity = shootDirection; + } + + public void UpdateProjectileHeldVariables(Vector2 armPosition) + { + projectile.position = armPosition - projectile.Size * 0.5f; + projectile.rotation = projectile.velocity.ToRotation(); + if (projectile.spriteDirection == -1) + projectile.rotation += MathHelper.Pi; + projectile.spriteDirection = projectile.direction; + projectile.timeLeft = 2; + } + + public void ManipulatePlayerVariables() + { + Owner.ChangeDir(projectile.direction); + Owner.heldProj = projectile.whoAmI; + Owner.itemTime = 2; + Owner.itemAnimation = 2; + Owner.itemRotation = (projectile.velocity * projectile.direction).ToRotation(); + } + } +} diff --git a/Projectiles/Ranged/SurgeDriverHoldout.png b/Projectiles/Ranged/SurgeDriverHoldout.png new file mode 100644 index 0000000000..1d943243d5 Binary files /dev/null and b/Projectiles/Ranged/SurgeDriverHoldout.png differ diff --git a/Projectiles/Ranged/TealExoArrow.cs b/Projectiles/Ranged/TealExoArrow.cs index 907b5599b0..221a71cef2 100644 --- a/Projectiles/Ranged/TealExoArrow.cs +++ b/Projectiles/Ranged/TealExoArrow.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.alpha = 255; projectile.penetrate = -1; - projectile.extraUpdates = 2; + projectile.extraUpdates = 3; projectile.timeLeft = 300; projectile.ranged = true; projectile.usesLocalNPCImmunity = true; @@ -32,30 +32,23 @@ namespace CalamityMod.Projectiles.Ranged public override void AI() { if (projectile.alpha > 0) - { projectile.alpha -= 25; - } if (projectile.alpha < 0) - { projectile.alpha = 0; - } + float num55 = 40f; float num56 = 1.5f; if (projectile.ai[1] == 0f) { projectile.localAI[0] += num56; if (projectile.localAI[0] > num55) - { projectile.localAI[0] = num55; - } } else { projectile.localAI[0] -= num56; if (projectile.localAI[0] <= 0f) - { projectile.Kill(); - } } } diff --git a/Projectiles/Ranged/TerraFireGreen2.cs b/Projectiles/Ranged/TerraFireGreen2.cs index 597569dff2..25d67e9217 100644 --- a/Projectiles/Ranged/TerraFireGreen2.cs +++ b/Projectiles/Ranged/TerraFireGreen2.cs @@ -87,7 +87,6 @@ namespace CalamityMod.Projectiles.Ranged target.AddBuff(BuffID.CursedInferno, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.OnFire, 300); - target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(BuffID.Frostburn, 300); } } diff --git a/Projectiles/Ranged/ThePackMinissile.cs b/Projectiles/Ranged/ThePackMinissile.cs index aa9fe01b38..13726bb8e2 100644 --- a/Projectiles/Ranged/ThePackMinissile.cs +++ b/Projectiles/Ranged/ThePackMinissile.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.ranged = true; projectile.penetrate = 1; projectile.timeLeft = 300; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Ranged/ThePackMissile.cs b/Projectiles/Ranged/ThePackMissile.cs index 7a44f17a03..bf1b72900d 100644 --- a/Projectiles/Ranged/ThePackMissile.cs +++ b/Projectiles/Ranged/ThePackMissile.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ranged = true; projectile.tileCollide = false; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; diff --git a/Projectiles/Rogue/AccretionDisk2.cs b/Projectiles/Rogue/AccretionDisk2.cs index 70279c331e..2df7ba00fa 100644 --- a/Projectiles/Rogue/AccretionDisk2.cs +++ b/Projectiles/Rogue/AccretionDisk2.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 56; projectile.height = 56; projectile.alpha = 120; + projectile.ignoreWater = true; projectile.friendly = true; projectile.tileCollide = false; projectile.penetrate = -1; @@ -46,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } @@ -54,7 +55,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Rogue/AccretionDiskProj.cs b/Projectiles/Rogue/AccretionDiskProj.cs index 7c74a1f1c2..2c796ac029 100644 --- a/Projectiles/Rogue/AccretionDiskProj.cs +++ b/Projectiles/Rogue/AccretionDiskProj.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 56; projectile.height = 56; + projectile.ignoreWater = true; projectile.friendly = true; projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; @@ -178,7 +179,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); if (!projectile.Calamity().stealthStrike) @@ -188,7 +189,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); if (!projectile.Calamity().stealthStrike) diff --git a/Projectiles/Rogue/AcidShrapnel.cs b/Projectiles/Rogue/AcidShrapnel.cs index 45b300d3c7..38983e6a21 100644 --- a/Projectiles/Rogue/AcidShrapnel.cs +++ b/Projectiles/Rogue/AcidShrapnel.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 160; projectile.tileCollide = true; projectile.Calamity().rogue = true; - } + projectile.ignoreWater = true; + } public override void AI() { projectile.ai[0] += 1f; diff --git a/Projectiles/Rogue/AlphaSeeker.cs b/Projectiles/Rogue/AlphaSeeker.cs index 368649cc9b..c28829ac38 100644 --- a/Projectiles/Rogue/AlphaSeeker.cs +++ b/Projectiles/Rogue/AlphaSeeker.cs @@ -28,7 +28,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 8; projectile.height = 8; projectile.friendly = 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 58af22b111..a0ce21a17e 100644 --- a/Projectiles/Rogue/AlphaVirusProjectile.cs +++ b/Projectiles/Rogue/AlphaVirusProjectile.cs @@ -27,7 +27,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = lifetime; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/AntumbraShardProjectile.cs b/Projectiles/Rogue/AntumbraShardProjectile.cs index b31566cd85..8bdbbb4a94 100644 --- a/Projectiles/Rogue/AntumbraShardProjectile.cs +++ b/Projectiles/Rogue/AntumbraShardProjectile.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; diff --git a/Projectiles/Rogue/ApoctolithProj.cs b/Projectiles/Rogue/ApoctolithProj.cs index 0d3efedc9d..9e5a6b3342 100644 --- a/Projectiles/Rogue/ApoctolithProj.cs +++ b/Projectiles/Rogue/ApoctolithProj.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 30; projectile.friendly = true; projectile.Calamity().rogue = true; + projectile.ignoreWater = true; } public override void AI() diff --git a/Projectiles/Rogue/ApoctolithShard.cs b/Projectiles/Rogue/ApoctolithShard.cs index 3e00bda68e..5282d9a24a 100644 --- a/Projectiles/Rogue/ApoctolithShard.cs +++ b/Projectiles/Rogue/ApoctolithShard.cs @@ -17,6 +17,7 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { projectile.friendly = true; + projectile.ignoreWater = true; projectile.width = 13; projectile.height = 13; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/BallisticPoisonBombProj.cs b/Projectiles/Rogue/BallisticPoisonBombProj.cs index d6e9dbf72b..03c15058fb 100644 --- a/Projectiles/Rogue/BallisticPoisonBombProj.cs +++ b/Projectiles/Rogue/BallisticPoisonBombProj.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 200; projectile.tileCollide = false; projectile.Calamity().rogue = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Rogue/BarrelShrapnel.cs b/Projectiles/Rogue/BarrelShrapnel.cs index 779bbb38d2..7f79178e03 100644 --- a/Projectiles/Rogue/BarrelShrapnel.cs +++ b/Projectiles/Rogue/BarrelShrapnel.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 160; projectile.tileCollide = true; projectile.Calamity().rogue = true; - } + projectile.ignoreWater = true; + } public override void AI() { projectile.ai[0] += 1f; diff --git a/Projectiles/Rogue/BlastBarrelProjectile.cs b/Projectiles/Rogue/BlastBarrelProjectile.cs index ef4a4b64ca..2aaa0865be 100644 --- a/Projectiles/Rogue/BlastBarrelProjectile.cs +++ b/Projectiles/Rogue/BlastBarrelProjectile.cs @@ -32,7 +32,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 48; projectile.friendly = true; projectile.penetrate = -1; - projectile.timeLeft = 480; + projectile.ignoreWater = true; + projectile.timeLeft = 480; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/BlazingStarProj.cs b/Projectiles/Rogue/BlazingStarProj.cs index a78454d720..3baee6041b 100644 --- a/Projectiles/Rogue/BlazingStarProj.cs +++ b/Projectiles/Rogue/BlazingStarProj.cs @@ -28,7 +28,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 32; projectile.friendly = true; projectile.tileCollide = 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 693e584020..e0bdbcffb0 100644 --- a/Projectiles/Rogue/BloodsoakedCrashax.cs +++ b/Projectiles/Rogue/BloodsoakedCrashax.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.Rogue { 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; diff --git a/Projectiles/Rogue/BouncingBettyProjectile.cs b/Projectiles/Rogue/BouncingBettyProjectile.cs index 1bab8db5f8..a28e30e317 100644 --- a/Projectiles/Rogue/BouncingBettyProjectile.cs +++ b/Projectiles/Rogue/BouncingBettyProjectile.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 600; projectile.penetrate = 3; projectile.Calamity().rogue = true; - } + projectile.ignoreWater = true; + } private void Explode() { Main.PlaySound(SoundID.Item14, projectile.Center); diff --git a/Projectiles/Rogue/BrackishFlaskProj.cs b/Projectiles/Rogue/BrackishFlaskProj.cs index 23c6cffacd..0a2b552d31 100644 --- a/Projectiles/Rogue/BrackishFlaskProj.cs +++ b/Projectiles/Rogue/BrackishFlaskProj.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 180; aiType = ProjectileID.ThrowingKnife; projectile.Calamity().rogue = true; - } + projectile.ignoreWater = true; + } public override void Kill(int timeLeft) { diff --git a/Projectiles/Rogue/BrackishSpear.cs b/Projectiles/Rogue/BrackishSpear.cs index 26ae0d315a..ddc4d2253f 100644 --- a/Projectiles/Rogue/BrackishSpear.cs +++ b/Projectiles/Rogue/BrackishSpear.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 52; projectile.aiStyle = 4; projectile.friendly = 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/Brimblade2.cs b/Projectiles/Rogue/Brimblade2.cs index c666f56fd1..5d3775b415 100644 --- a/Projectiles/Rogue/Brimblade2.cs +++ b/Projectiles/Rogue/Brimblade2.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 26; projectile.height = 26; projectile.friendly = 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 48d75142e7..59075b32d9 100644 --- a/Projectiles/Rogue/BrimbladeProj.cs +++ b/Projectiles/Rogue/BrimbladeProj.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 26; projectile.height = 26; projectile.friendly = 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 df19353474..316094df18 100644 --- a/Projectiles/Rogue/BurningStrifeProj.cs +++ b/Projectiles/Rogue/BurningStrifeProj.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 14; projectile.height = 14; projectile.timeLeft = 720; - 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 dcfff20946..17b634a6d0 100644 --- a/Projectiles/Rogue/ButcherKnife.cs +++ b/Projectiles/Rogue/ButcherKnife.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 14; projectile.height = 14; projectile.friendly = 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 843675e168..cecdf33481 100644 --- a/Projectiles/Rogue/CarvingFork.cs +++ b/Projectiles/Rogue/CarvingFork.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/CelestialReaperAfterimage.cs b/Projectiles/Rogue/CelestialReaperAfterimage.cs index 47ce05b8f9..b661d820db 100644 --- a/Projectiles/Rogue/CelestialReaperAfterimage.cs +++ b/Projectiles/Rogue/CelestialReaperAfterimage.cs @@ -17,7 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 66; projectile.height = 76; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 51; projectile.tileCollide = false; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/CelestialReaperProjectile.cs b/Projectiles/Rogue/CelestialReaperProjectile.cs index 88c5a20002..65135370c5 100644 --- a/Projectiles/Rogue/CelestialReaperProjectile.cs +++ b/Projectiles/Rogue/CelestialReaperProjectile.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 66; projectile.height = 76; projectile.friendly = 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 8130ff4581..8794a470a3 100644 --- a/Projectiles/Rogue/Celestus2.cs +++ b/Projectiles/Rogue/Celestus2.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 48; projectile.friendly = true; projectile.tileCollide = false; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.extraUpdates = 4; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 40; diff --git a/Projectiles/Rogue/CelestusBoomerang.cs b/Projectiles/Rogue/CelestusBoomerang.cs index 5630f19e93..9dd6075380 100644 --- a/Projectiles/Rogue/CelestusBoomerang.cs +++ b/Projectiles/Rogue/CelestusBoomerang.cs @@ -25,6 +25,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = projectile.height = 94; projectile.friendly = true; projectile.tileCollide = false; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.extraUpdates = 3; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/CobaltKunaiProjectile.cs b/Projectiles/Rogue/CobaltKunaiProjectile.cs index 5fd2c99f57..906baefa81 100644 --- a/Projectiles/Rogue/CobaltKunaiProjectile.cs +++ b/Projectiles/Rogue/CobaltKunaiProjectile.cs @@ -36,7 +36,6 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Rogue/ConsecratedWaterProjectile.cs b/Projectiles/Rogue/ConsecratedWaterProjectile.cs index 1444e17700..e6cd90256e 100644 --- a/Projectiles/Rogue/ConsecratedWaterProjectile.cs +++ b/Projectiles/Rogue/ConsecratedWaterProjectile.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.penetrate = 1; projectile.timeLeft = 200; projectile.tileCollide = true; - projectile.alpha = 0; + projectile.ignoreWater = true; + projectile.alpha = 0; projectile.Calamity().rogue = true; } public override void AI() diff --git a/Projectiles/Rogue/CorpusAvertorClone.cs b/Projectiles/Rogue/CorpusAvertorClone.cs index d901c849b6..89415d34e6 100644 --- a/Projectiles/Rogue/CorpusAvertorClone.cs +++ b/Projectiles/Rogue/CorpusAvertorClone.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 24; projectile.height = 24; + projectile.ignoreWater = true; projectile.friendly = true; projectile.penetrate = 1; projectile.timeLeft = 180; diff --git a/Projectiles/Rogue/CorpusAvertorProj.cs b/Projectiles/Rogue/CorpusAvertorProj.cs index b5efd38631..78a2c22f0b 100644 --- a/Projectiles/Rogue/CorpusAvertorProj.cs +++ b/Projectiles/Rogue/CorpusAvertorProj.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 24; projectile.height = 24; + projectile.ignoreWater = true; projectile.friendly = true; projectile.penetrate = 1; projectile.timeLeft = 300; diff --git a/Projectiles/Rogue/CosmicKunaiProj.cs b/Projectiles/Rogue/CosmicKunaiProj.cs index f37994a8d0..6adceeef0f 100644 --- a/Projectiles/Rogue/CosmicKunaiProj.cs +++ b/Projectiles/Rogue/CosmicKunaiProj.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 24; projectile.friendly = true; projectile.tileCollide = false; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/CraniumSmasherExplosive.cs b/Projectiles/Rogue/CraniumSmasherExplosive.cs index 41d1d816d9..dacf541e0f 100644 --- a/Projectiles/Rogue/CraniumSmasherExplosive.cs +++ b/Projectiles/Rogue/CraniumSmasherExplosive.cs @@ -16,7 +16,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 50; projectile.height = 50; projectile.friendly = 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 25e81d4eb8..71fe67556d 100644 --- a/Projectiles/Rogue/CraniumSmasherProj.cs +++ b/Projectiles/Rogue/CraniumSmasherProj.cs @@ -17,7 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 50; projectile.height = 50; projectile.friendly = true; - projectile.penetrate = 5; + projectile.ignoreWater = true; + projectile.penetrate = 5; projectile.timeLeft = 300; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 15; @@ -46,13 +47,6 @@ namespace CalamityMod.Projectiles.Rogue } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Rogue/CraniumSmasherStealth.cs b/Projectiles/Rogue/CraniumSmasherStealth.cs index 07a193a663..1aa7596445 100644 --- a/Projectiles/Rogue/CraniumSmasherStealth.cs +++ b/Projectiles/Rogue/CraniumSmasherStealth.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 50; projectile.height = 50; projectile.friendly = true; + projectile.ignoreWater = true; projectile.penetrate = 5; projectile.timeLeft = 300; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/Crushax.cs b/Projectiles/Rogue/Crushax.cs index 1381d861d5..26c1194e50 100644 --- a/Projectiles/Rogue/Crushax.cs +++ b/Projectiles/Rogue/Crushax.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 2; projectile.timeLeft = 300; aiType = ProjectileID.ThrowingKnife; @@ -39,7 +40,6 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Rogue/CursedDaggerProj.cs b/Projectiles/Rogue/CursedDaggerProj.cs index 01c6d0244e..bdddc72975 100644 --- a/Projectiles/Rogue/CursedDaggerProj.cs +++ b/Projectiles/Rogue/CursedDaggerProj.cs @@ -72,7 +72,6 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Rogue/DeepWounderProjectile.cs b/Projectiles/Rogue/DeepWounderProjectile.cs index 5d33ebb82b..2b36d2babc 100644 --- a/Projectiles/Rogue/DeepWounderProjectile.cs +++ b/Projectiles/Rogue/DeepWounderProjectile.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = 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 bd36f500e3..844854db19 100644 --- a/Projectiles/Rogue/DeepWounderWater.cs +++ b/Projectiles/Rogue/DeepWounderWater.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 50; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/DesecratedWaterProj.cs b/Projectiles/Rogue/DesecratedWaterProj.cs index 0edd75087c..0120c37d0d 100644 --- a/Projectiles/Rogue/DesecratedWaterProj.cs +++ b/Projectiles/Rogue/DesecratedWaterProj.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 25; projectile.height = 25; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 2; projectile.timeLeft = 300; aiType = ProjectileID.ThrowingKnife; diff --git a/Projectiles/Rogue/DukesDecapitatorBubble.cs b/Projectiles/Rogue/DukesDecapitatorBubble.cs index c884fbd319..77347524df 100644 --- a/Projectiles/Rogue/DukesDecapitatorBubble.cs +++ b/Projectiles/Rogue/DukesDecapitatorBubble.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = 1; projectile.timeLeft = 300; } diff --git a/Projectiles/Rogue/DukesDecapitatorProj.cs b/Projectiles/Rogue/DukesDecapitatorProj.cs index a51f9f2b95..2162902ecd 100644 --- a/Projectiles/Rogue/DukesDecapitatorProj.cs +++ b/Projectiles/Rogue/DukesDecapitatorProj.cs @@ -8,12 +8,9 @@ using CalamityMod.CalPlayer; namespace CalamityMod.Projectiles.Rogue { public class DukesDecapitatorProj : ModProjectile - { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/DukesDecapitator"; - - bool stealthBubbles = false; + { float rotationAmount = 1.5f; - + public override string Texture => "CalamityMod/Items/Weapons/Rogue/DukesDecapitator"; public override void SetStaticDefaults() { DisplayName.SetDefault("Decapitator"); @@ -26,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 20; @@ -42,18 +40,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity *= 0.99f; } projectile.ai[0] += 1f; - if (projectile.ai[0] == 1f && modPlayer.StealthStrikeAvailable()) - { - stealthBubbles = true; - projectile.Calamity().stealthStrike = true; - } if (projectile.ai[0] == 5f) projectile.tileCollide = true; if ((projectile.ai[0] % 15f) == 0f && rotationAmount > 0) { rotationAmount -= 0.05f; - if(stealthBubbles == true && projectile.owner == Main.myPlayer) + 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); diff --git a/Projectiles/Rogue/DuststormInABottleProj.cs b/Projectiles/Rogue/DuststormInABottleProj.cs index 291045926b..f03be7d21f 100644 --- a/Projectiles/Rogue/DuststormInABottleProj.cs +++ b/Projectiles/Rogue/DuststormInABottleProj.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; + projectile.ignoreWater = true; projectile.penetrate = 1; projectile.aiStyle = 2; projectile.timeLeft = 180; diff --git a/Projectiles/Rogue/EclipsesSmol.cs b/Projectiles/Rogue/EclipsesSmol.cs index ece363d5fb..cb05bd132e 100644 --- a/Projectiles/Rogue/EclipsesSmol.cs +++ b/Projectiles/Rogue/EclipsesSmol.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); } public override void Kill(int timeLeft) @@ -36,21 +36,21 @@ namespace CalamityMod.Projectiles.Rogue Main.PlaySound(SoundID.Item14, projectile.Center); for (int i = 0; i < 2; i++) { - int dustInt = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.2f); - Main.dust[dustInt].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[dustInt].scale = 0.5f; - Main.dust[dustInt].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } + int dustInt = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.2f); + Main.dust[dustInt].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[dustInt].scale = 0.5f; + Main.dust[dustInt].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } } for (int j = 0; j < 3; j++) { - int moreDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.7f); - Main.dust[moreDust].noGravity = true; - Main.dust[moreDust].velocity *= 5f; - moreDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1f); - Main.dust[moreDust].velocity *= 2f; + int moreDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1.7f); + Main.dust[moreDust].noGravity = true; + Main.dust[moreDust].velocity *= 5f; + moreDust = Dust.NewDust(projectile.position, projectile.width, projectile.height, 138, 0f, 0f, 100, default, 1f); + Main.dust[moreDust].velocity *= 2f; } } diff --git a/Projectiles/Rogue/EclipsesStealth.cs b/Projectiles/Rogue/EclipsesStealth.cs index 50c08293a2..257317e083 100644 --- a/Projectiles/Rogue/EclipsesStealth.cs +++ b/Projectiles/Rogue/EclipsesStealth.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,13 +8,15 @@ namespace CalamityMod.Projectiles.Rogue { public class EclipsesStealth : ModProjectile { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/EclipsesFall"; + 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; public override void SetStaticDefaults() { - DisplayName.SetDefault("Eclipse's Stealth"); + DisplayName.SetDefault("Eclipse's Fall"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } @@ -34,44 +35,59 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } + // Uses localAI[1] to decide how many frames until the next spear drops. public override void AI() { - if (projectile.timeLeft % 5 == 0) //congrats Pinkie... every 5 ticks + // Behavior when not sticking to anything + if (projectile.ai[0] == 0f) { - if (Main.rand.NextBool(2) && Main.myPlayer == projectile.owner) + // 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); + } + + // Behavior when having impaled a target + else + { + // Eclipse's Fall is guaranteed to impale for 10 seconds, no more, no less + if (!changedTimeLeft) { - float dmgKBMult = Main.rand.NextFloat(0.4f, 0.6f); - int spearAmt = Main.rand.Next(1, 3); //1 to 2 spears - for (int n = 0; n < spearAmt; n++) + 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; + + if (projectile.localAI[1] <= 0f) { - CalamityUtils.ProjectileRain(projectile.Center, 400f, 100f, 500f, 800f, 29f, ModContent.ProjectileType(), (int)(projectile.damage * dmgKBMult), projectile.knockBack * dmgKBMult, projectile.owner); + // 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); } } } - //Behavior when not sticking to anything - if (projectile.ai[0] == 0f) - { - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; - if (Main.rand.NextBool(8)) //dust - { - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 138, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); - } - } - - //Ensures that a spear will last 10 seconds after it hits something - if (projectile.ai[0] == 1f && !changedTimeLeft) - { - projectile.timeLeft = 600; - changedTimeLeft = true; - } - - //Sticky Behaviour + // 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); } diff --git a/Projectiles/Rogue/EquanimityDarkShard.cs b/Projectiles/Rogue/EquanimityDarkShard.cs index f77c90d281..3603af26f3 100644 --- a/Projectiles/Rogue/EquanimityDarkShard.cs +++ b/Projectiles/Rogue/EquanimityDarkShard.cs @@ -17,7 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 14; projectile.friendly = 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 5eebb24db8..bec2451479 100644 --- a/Projectiles/Rogue/EquanimityLightShard.cs +++ b/Projectiles/Rogue/EquanimityLightShard.cs @@ -17,7 +17,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 14; projectile.friendly = 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 2d8b2cefc3..3cfb24208c 100644 --- a/Projectiles/Rogue/EquanimityProj.cs +++ b/Projectiles/Rogue/EquanimityProj.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 28; projectile.height = 36; projectile.friendly = 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 2fd9744884..a9392ef4b6 100644 --- a/Projectiles/Rogue/EradicatorProjectile.cs +++ b/Projectiles/Rogue/EradicatorProjectile.cs @@ -26,12 +26,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = projectile.height = 58; projectile.friendly = true; projectile.tileCollide = false; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.aiStyle = 3; projectile.timeLeft = 180; aiType = ProjectileID.WoodenBoomerang; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.localNPCHitCooldown = 18; projectile.Calamity().rogue = true; } @@ -56,14 +57,20 @@ namespace CalamityMod.Projectiles.Rogue { shootCounter = 0f; Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - Projectile laser = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); + + int laserDamage = (int)(projectile.damage * 0.5); + if (projectile.Calamity().stealthStrike) + laserDamage /= 4; + 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; - laser.localNPCHitCooldown = 20; + + // This projectile has a hefty amount of extra updates, which will influence the hit cooldown. + laser.localNPCHitCooldown = 70; } } diff --git a/Projectiles/Rogue/ExecutionersBladeProj.cs b/Projectiles/Rogue/ExecutionersBladeProj.cs index eb6bda0aef..7215ed3111 100644 --- a/Projectiles/Rogue/ExecutionersBladeProj.cs +++ b/Projectiles/Rogue/ExecutionersBladeProj.cs @@ -36,7 +36,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 64; projectile.friendly = true; projectile.tileCollide = false; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 2; projectile.timeLeft = 240; aiType = ProjectileID.ThrowingKnife; diff --git a/Projectiles/Rogue/ExorcismProj.cs b/Projectiles/Rogue/ExorcismProj.cs index 592ec18ff2..4a59aa156b 100644 --- a/Projectiles/Rogue/ExorcismProj.cs +++ b/Projectiles/Rogue/ExorcismProj.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.alpha = 0; + projectile.ignoreWater = true; + projectile.alpha = 0; projectile.penetrate = 1; projectile.tileCollide = true; projectile.timeLeft = 600; diff --git a/Projectiles/Rogue/ExplosiveSun.cs b/Projectiles/Rogue/ExplosiveSun.cs index b67b6fa54d..44a2f1b27a 100644 --- a/Projectiles/Rogue/ExplosiveSun.cs +++ b/Projectiles/Rogue/ExplosiveSun.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 22; //projectile.aiStyle = 115; projectile.friendly = true; + projectile.ignoreWater = true; projectile.penetrate = 1; projectile.light = 0.5f; projectile.alpha = 50; diff --git a/Projectiles/Rogue/FinalDawnFireSlash.cs b/Projectiles/Rogue/FinalDawnFireSlash.cs index 7e32676763..1189bd149a 100644 --- a/Projectiles/Rogue/FinalDawnFireSlash.cs +++ b/Projectiles/Rogue/FinalDawnFireSlash.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 300; projectile.height = 398; projectile.friendly = false; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.ownerHitCheck = true; diff --git a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs index adf0b97a38..ee41c0781b 100644 --- a/Projectiles/Rogue/FinalDawnHorizontalSlash.cs +++ b/Projectiles/Rogue/FinalDawnHorizontalSlash.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 600; projectile.height = 156; projectile.friendly = false; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.ownerHitCheck = true; diff --git a/Projectiles/Rogue/FinalDawnProjectile.cs b/Projectiles/Rogue/FinalDawnProjectile.cs index c80923555b..cfc94e209e 100644 --- a/Projectiles/Rogue/FinalDawnProjectile.cs +++ b/Projectiles/Rogue/FinalDawnProjectile.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 16; projectile.friendly = false; projectile.Calamity().rogue = true; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.tileCollide = false; //projectile.extraUpdates = 2; diff --git a/Projectiles/Rogue/FinalDawnThrow.cs b/Projectiles/Rogue/FinalDawnThrow.cs index 0487ae533b..40f3d2d823 100644 --- a/Projectiles/Rogue/FinalDawnThrow.cs +++ b/Projectiles/Rogue/FinalDawnThrow.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 80; projectile.friendly = true; projectile.Calamity().rogue = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.light = 0.0f; projectile.extraUpdates = 2; projectile.tileCollide = false; diff --git a/Projectiles/Rogue/FinalDawnThrow2.cs b/Projectiles/Rogue/FinalDawnThrow2.cs index cbe55ebd4e..4efe2a4d1b 100644 --- a/Projectiles/Rogue/FinalDawnThrow2.cs +++ b/Projectiles/Rogue/FinalDawnThrow2.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 200; projectile.friendly = true; projectile.Calamity().rogue = 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 @@ -86,11 +87,9 @@ namespace CalamityMod.Projectiles.Rogue player.heldProj = projectile.whoAmI; player.bodyFrame.Y = player.bodyFrame.Height; player.immuneNoBlink = true; - player.immuneTime = 10; - for (int k = 0; k < player.hurtCooldowns.Length; k++) - { - player.hurtCooldowns[k] = player.immuneTime; - } + player.immuneTime = 6; + for (int k = 0; k < player.hurtCooldowns.Length; k++) + player.hurtCooldowns[k] = player.immuneTime; // This is to make sure the player doesn't get yeeted out of the world, which crashes the game pretty much all of the time bool worldEdge = projectile.Center.X < 1000 || projectile.Center.Y < 1000 || projectile.Center.X > Main.maxTilesX * 16 - 1000 || projectile.Center.Y > Main.maxTilesY * 16 - 1000; diff --git a/Projectiles/Rogue/FlameScytheProjectile.cs b/Projectiles/Rogue/FlameScytheProjectile.cs index 9d7e347dd6..be8a2ab3ab 100644 --- a/Projectiles/Rogue/FlameScytheProjectile.cs +++ b/Projectiles/Rogue/FlameScytheProjectile.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.aiStyle = 3; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/Fork.cs b/Projectiles/Rogue/Fork.cs index fde3849f1d..9d1c8bb67a 100644 --- a/Projectiles/Rogue/Fork.cs +++ b/Projectiles/Rogue/Fork.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/FrostyFlareProj.cs b/Projectiles/Rogue/FrostyFlareProj.cs index 6fa06346ae..ed6ef31c27 100644 --- a/Projectiles/Rogue/FrostyFlareProj.cs +++ b/Projectiles/Rogue/FrostyFlareProj.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); target.immune[projectile.owner] = 0; projectile.ai[0] = 1f; projectile.ai[1] = target.whoAmI; @@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override bool CanDamage() => projectile.ai[0] == 0f; diff --git a/Projectiles/Rogue/FrostyFlareStealth.cs b/Projectiles/Rogue/FrostyFlareStealth.cs index c0d7d932bf..d9b2bf1334 100644 --- a/Projectiles/Rogue/FrostyFlareStealth.cs +++ b/Projectiles/Rogue/FrostyFlareStealth.cs @@ -98,7 +98,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); target.immune[projectile.owner] = 0; projectile.ai[0] = 1f; projectile.ai[1] = target.whoAmI; @@ -133,7 +133,7 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Frostburn, 300); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override bool CanDamage() => projectile.ai[0] == 0f; diff --git a/Projectiles/Rogue/GacruxianProj.cs b/Projectiles/Rogue/GacruxianProj.cs index 9e159b9f21..43158e4955 100644 --- a/Projectiles/Rogue/GacruxianProj.cs +++ b/Projectiles/Rogue/GacruxianProj.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/GelDartProjectile.cs b/Projectiles/Rogue/GelDartProjectile.cs index 618f947cd2..6ee65ee71f 100644 --- a/Projectiles/Rogue/GelDartProjectile.cs +++ b/Projectiles/Rogue/GelDartProjectile.cs @@ -66,7 +66,6 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Rogue/GhoulishGougerBoomerang.cs b/Projectiles/Rogue/GhoulishGougerBoomerang.cs index c348bbf5cd..5a821088da 100644 --- a/Projectiles/Rogue/GhoulishGougerBoomerang.cs +++ b/Projectiles/Rogue/GhoulishGougerBoomerang.cs @@ -137,9 +137,9 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.numHits > 0) return; - int numSouls = 3; + int numSouls = 8; int projID = ModContent.ProjectileType(); - int soulDamage = (int)(projectile.damage * 0.85f); + int soulDamage = projectile.damage; float soulKB = 0f; float speed = 6f; Vector2 velocity = Main.rand.NextVector2CircularEdge(speed, speed); @@ -149,7 +149,7 @@ namespace CalamityMod.Projectiles.Rogue float ai1 = Main.rand.NextFloat() + 0.5f; Projectile.NewProjectile(projectile.Center, velocity, projID, soulDamage, soulKB, projectile.owner, 0f, ai1); - // Rotate direction for the next pair of souls. + // Rotate direction for the next soul velocity = velocity.RotatedBy(MathHelper.TwoPi / numSouls); } } diff --git a/Projectiles/Rogue/GodsParanoiaDart.cs b/Projectiles/Rogue/GodsParanoiaDart.cs index 16274da52a..e7092419f6 100644 --- a/Projectiles/Rogue/GodsParanoiaDart.cs +++ b/Projectiles/Rogue/GodsParanoiaDart.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 10; projectile.height = 10; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.Calamity().rogue = true; projectile.penetrate = 1; projectile.tileCollide = false; @@ -43,11 +44,13 @@ namespace CalamityMod.Projectiles.Rogue projectile.velocity.Y = 12f; } - int num822 = Dust.NewDust(projectile.position, projectile.width, projectile.height, Main.rand.NextBool(3) ? 56 : 242, 0f, 0f, 0, default, 1f); - Dust dust = Main.dust[num822]; - dust.velocity *= 0.1f; - Main.dust[num822].scale = 1.3f; - Main.dust[num822].noGravity = true; + if (Main.rand.NextBool(3)) + { + Dust flame = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, Main.rand.NextBool(3) ? 56 : 242, 0f, 0f, 0, default, 1f); + flame.velocity *= 0.1f; + flame.scale = 1.3f; + flame.noGravity = true; + } } public override void Kill(int timeLeft) @@ -62,18 +65,17 @@ namespace CalamityMod.Projectiles.Rogue projectile.localNPCHitCooldown = -1; projectile.damage /= 2; projectile.Damage(); - for (int num621 = 0; num621 < 3; num621++) + for (int i = 0; i < 2; i++) { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, Main.rand.NextBool(3) ? 56 : 242, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; + Dust flame = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, Main.rand.NextBool(3) ? 56 : 242, 0f, 0f, 100, default, 2f); + flame.velocity *= 3f; + if (Main.rand.NextBool(2)) + flame.scale = 0.5f; + if (Main.rand.NextBool(2)) { - Main.dust[num622].scale = 0.5f; - } - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale *= 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + flame.scale *= 0.5f; + flame.fadeIn = Main.rand.NextFloat(1f, 2f); } } } diff --git a/Projectiles/Rogue/GodsParanoiaProj.cs b/Projectiles/Rogue/GodsParanoiaProj.cs index 5aa8c1db79..21811f8cb8 100644 --- a/Projectiles/Rogue/GodsParanoiaProj.cs +++ b/Projectiles/Rogue/GodsParanoiaProj.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 15; projectile.height = 15; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.penetrate = -1; @@ -40,26 +41,19 @@ namespace CalamityMod.Projectiles.Rogue Lighting.AddLight(projectile.Center, 0.35f, 0f, 0.25f); if (Main.rand.NextBool(2)) { - int num137 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), 1, 1, Main.rand.NextBool(3) ? 56 : 242, 0f, 0f, 0, default, 0.5f); - Main.dust[num137].alpha = projectile.alpha; - Main.dust[num137].velocity *= 0f; - Main.dust[num137].noGravity = true; + Dust flame = Dust.NewDustDirect(projectile.position, 1, 1, Main.rand.NextBool(3) ? 56 : 242, 0f, 0f, 0, default, 0.5f); + flame.alpha = projectile.alpha; + flame.velocity = Vector2.Zero; + flame.noGravity = true; } projectile.StickyProjAI(50); if (projectile.ai[0] == 1f) { - if (projectile.Calamity().stealthStrike) - { - kunaiStabbing += 2; - } - else - { - kunaiStabbing++; - } - if (kunaiStabbing >= 20) - { + 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); diff --git a/Projectiles/Rogue/GreenDonkeyKongReference.cs b/Projectiles/Rogue/GreenDonkeyKongReference.cs index 506554a2ee..eddc4eb933 100644 --- a/Projectiles/Rogue/GreenDonkeyKongReference.cs +++ b/Projectiles/Rogue/GreenDonkeyKongReference.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 48; projectile.height = 48; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 480; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; diff --git a/Projectiles/Rogue/HellsSunProj.cs b/Projectiles/Rogue/HellsSunProj.cs index 932cf47367..181ed3c8e5 100644 --- a/Projectiles/Rogue/HellsSunProj.cs +++ b/Projectiles/Rogue/HellsSunProj.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.Calamity().rogue = true; projectile.tileCollide = false; - projectile.penetrate = 20; + projectile.ignoreWater = true; + projectile.penetrate = 20; projectile.timeLeft = 1200; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/HypothermiaChunk.cs b/Projectiles/Rogue/HypothermiaChunk.cs index c7f38364e6..4c10079e84 100644 --- a/Projectiles/Rogue/HypothermiaChunk.cs +++ b/Projectiles/Rogue/HypothermiaChunk.cs @@ -6,14 +6,14 @@ using Microsoft.Xna.Framework.Graphics; namespace CalamityMod.Projectiles.Rogue { - public class HypothermiaChunk : ModProjectile + public class HypothermiaChunk : ModProjectile { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Ice Chunk"); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Ice Chunk"); ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } + } public override void SetDefaults() { @@ -22,7 +22,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.penetrate = 1; projectile.timeLeft = 80; - projectile.extraUpdates = 3; + projectile.extraUpdates = 4; projectile.ignoreWater = true; projectile.Calamity().rogue = true; projectile.tileCollide = false; @@ -58,18 +58,24 @@ namespace CalamityMod.Projectiles.Rogue } if (projectile.owner == Main.myPlayer) { - for (int i = 0; i < Main.rand.Next(1,4); i++) - { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int shard = Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.33f), projectile.knockBack * 0.75f, Main.myPlayer, Main.rand.Next(4), 1f); - } - } + int numSplits = Main.rand.NextBool() ? 4 : 3; + int type = ModContent.ProjectileType(); + int shardDamage = (int)(projectile.damage * 0.5f); + float shardKB = projectile.knockBack * 0.75f; + + for (int i = 0; i < numSplits; ++i) + { + Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); + int texID = Main.rand.Next(4); + Projectile.NewProjectile(projectile.Center, velocity, type, shardDamage, shardKB, Main.myPlayer, texID, 1f); + } + } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 300); - } + } public override void OnHitPvp(Player target, int damage, bool crit) { diff --git a/Projectiles/Rogue/HypothermiaShard.cs b/Projectiles/Rogue/HypothermiaShard.cs index 8c9b3d1ae5..14c1f328a1 100644 --- a/Projectiles/Rogue/HypothermiaShard.cs +++ b/Projectiles/Rogue/HypothermiaShard.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Projectiles.Rogue { public class HypothermiaShard : ModProjectile { - private float counter = 0f; + private float counter = 0f; public override void SetStaticDefaults() { DisplayName.SetDefault("Ice Shard"); @@ -20,11 +20,12 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 6; projectile.scale = 1f; projectile.friendly = true; + projectile.ignoreWater = true; projectile.alpha = 50; projectile.penetrate = 1; projectile.timeLeft = 600; projectile.Calamity().rogue = true; - projectile.extraUpdates = 3; + projectile.extraUpdates = 3; } public override void AI() @@ -54,14 +55,14 @@ namespace CalamityMod.Projectiles.Rogue 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; } @@ -99,8 +100,8 @@ namespace CalamityMod.Projectiles.Rogue { texture = ModContent.GetTexture("CalamityMod/Projectiles/Rogue/HypothermiaShard4"); } - 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; + 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/Rogue/IcebreakerHammer.cs b/Projectiles/Rogue/IcebreakerHammer.cs index 643741d056..d9a2a00b04 100644 --- a/Projectiles/Rogue/IcebreakerHammer.cs +++ b/Projectiles/Rogue/IcebreakerHammer.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 30; projectile.height = 30; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.Calamity().rogue = true; projectile.penetrate = -1; projectile.aiStyle = 3; @@ -72,7 +73,7 @@ namespace CalamityMod.Projectiles.Rogue if (nPC.active && !nPC.dontTakeDamage && !nPC.buffImmune[buffType] && Vector2.Distance(projectile.Center, nPC.Center) <= radius) { if (nPC.FindBuffIndex(buffType) == -1) - nPC.AddBuff(buffType, 90, false); + nPC.AddBuff(buffType, 60, false); } } } @@ -102,7 +103,7 @@ namespace CalamityMod.Projectiles.Rogue 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, 90, false); + player.AddBuff(buffType, 60, false); } } } diff --git a/Projectiles/Rogue/IchorSpearProj.cs b/Projectiles/Rogue/IchorSpearProj.cs index b9e463760a..36897eb7d5 100644 --- a/Projectiles/Rogue/IchorSpearProj.cs +++ b/Projectiles/Rogue/IchorSpearProj.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/InfernalFireball.cs b/Projectiles/Rogue/InfernalFireball.cs index 2ba3020708..3159eb2ac5 100644 --- a/Projectiles/Rogue/InfernalFireball.cs +++ b/Projectiles/Rogue/InfernalFireball.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 34; projectile.height = 34; projectile.friendly = true; + projectile.ignoreWater = true; projectile.alpha = 255; projectile.penetrate = 1; projectile.timeLeft = 180; diff --git a/Projectiles/Rogue/InfernalFireballEruption.cs b/Projectiles/Rogue/InfernalFireballEruption.cs index 66f929e739..41d3b35b1e 100644 --- a/Projectiles/Rogue/InfernalFireballEruption.cs +++ b/Projectiles/Rogue/InfernalFireballEruption.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 34; projectile.height = 34; projectile.friendly = true; - projectile.alpha = 255; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; projectile.timeLeft = 3600; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/InfernalSpearProjectile.cs b/Projectiles/Rogue/InfernalSpearProjectile.cs index 002290f245..384775759b 100644 --- a/Projectiles/Rogue/InfernalSpearProjectile.cs +++ b/Projectiles/Rogue/InfernalSpearProjectile.cs @@ -26,7 +26,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 62; projectile.height = 62; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 300; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/JawsProjectile.cs b/Projectiles/Rogue/JawsProjectile.cs index 9b795b46c3..55f7a707ff 100644 --- a/Projectiles/Rogue/JawsProjectile.cs +++ b/Projectiles/Rogue/JawsProjectile.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = 600; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/KelvinCatalystBoomerang.cs b/Projectiles/Rogue/KelvinCatalystBoomerang.cs index d02285fe61..b3db6fa438 100644 --- a/Projectiles/Rogue/KelvinCatalystBoomerang.cs +++ b/Projectiles/Rogue/KelvinCatalystBoomerang.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.extraUpdates = 1; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/Knife.cs b/Projectiles/Rogue/Knife.cs index 98e777439d..d150b12b1e 100644 --- a/Projectiles/Rogue/Knife.cs +++ b/Projectiles/Rogue/Knife.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/LeonidCometBig.cs b/Projectiles/Rogue/LeonidCometBig.cs index 85c4725484..806da402db 100644 --- a/Projectiles/Rogue/LeonidCometBig.cs +++ b/Projectiles/Rogue/LeonidCometBig.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 42; projectile.aiStyle = 1; projectile.friendly = true; + projectile.ignoreWater = true; projectile.Calamity().rogue = true; projectile.tileCollide = false; projectile.extraUpdates = 2; diff --git a/Projectiles/Rogue/LeonidCometSmall.cs b/Projectiles/Rogue/LeonidCometSmall.cs index aa7879816c..3296513a2a 100644 --- a/Projectiles/Rogue/LeonidCometSmall.cs +++ b/Projectiles/Rogue/LeonidCometSmall.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 28; projectile.height = 28; projectile.friendly = true; - projectile.Calamity().rogue = true; + projectile.ignoreWater = true; + projectile.Calamity().rogue = true; projectile.penetrate = 1; projectile.timeLeft = 300; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/LeonidProgenitorBombshell.cs b/Projectiles/Rogue/LeonidProgenitorBombshell.cs index 6249c0917f..e90c929175 100644 --- a/Projectiles/Rogue/LeonidProgenitorBombshell.cs +++ b/Projectiles/Rogue/LeonidProgenitorBombshell.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 32; projectile.height = 32; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 180; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/LostSoulFriendly.cs b/Projectiles/Rogue/LostSoulFriendly.cs index 832e395016..f63beb3aeb 100644 --- a/Projectiles/Rogue/LostSoulFriendly.cs +++ b/Projectiles/Rogue/LostSoulFriendly.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.alpha = 150; } - public override bool? CanHitNPC(NPC target) => projectile.timeLeft < 210 && target.CanBeChasedBy(projectile); + public override bool? CanHitNPC(NPC target) => (projectile.timeLeft < 210 || projectile.ai[0] == 2f) && target.CanBeChasedBy(projectile); public override void AI() { @@ -45,7 +45,7 @@ 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) + if (projectile.ai[0] != 1f && (projectile.timeLeft < 210 || projectile.ai[0] == 2f)) CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); } diff --git a/Projectiles/Rogue/LuminousShard.cs b/Projectiles/Rogue/LuminousShard.cs index 13ae3aa831..a11ed1bb26 100644 --- a/Projectiles/Rogue/LuminousShard.cs +++ b/Projectiles/Rogue/LuminousShard.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 18; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 120; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/LuminousStrikerProj.cs b/Projectiles/Rogue/LuminousStrikerProj.cs index 0a396d1d7c..424654f468 100644 --- a/Projectiles/Rogue/LuminousStrikerProj.cs +++ b/Projectiles/Rogue/LuminousStrikerProj.cs @@ -24,17 +24,16 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 120; projectile.Calamity().rogue = true; } public override void AI() { - CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); - if (projectile.ai[0] == 0f && modPlayer.StealthStrikeAvailable()) + if (projectile.ai[0] == 0f && projectile.Calamity().stealthStrike) { - projectile.Calamity().stealthStrike = true; projectile.timeLeft = 600; projectile.ai[0] = 1f; } diff --git a/Projectiles/Rogue/LunarKunaiProj.cs b/Projectiles/Rogue/LunarKunaiProj.cs index 2907f37f46..91f93e8086 100644 --- a/Projectiles/Rogue/LunarKunaiProj.cs +++ b/Projectiles/Rogue/LunarKunaiProj.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 14; projectile.height = 14; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/LuxorsGiftRogue.cs b/Projectiles/Rogue/LuxorsGiftRogue.cs index 643f209599..f783897502 100644 --- a/Projectiles/Rogue/LuxorsGiftRogue.cs +++ b/Projectiles/Rogue/LuxorsGiftRogue.cs @@ -92,7 +92,6 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Rogue/MangroveChakramProjectile.cs b/Projectiles/Rogue/MangroveChakramProjectile.cs index 97f9ca39ff..db5b73d2c1 100644 --- a/Projectiles/Rogue/MangroveChakramProjectile.cs +++ b/Projectiles/Rogue/MangroveChakramProjectile.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = true; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.aiStyle = 3; projectile.timeLeft = 600; diff --git a/Projectiles/Rogue/MoltenAmputatorProj.cs b/Projectiles/Rogue/MoltenAmputatorProj.cs index 9774d0e32a..aee58752e0 100644 --- a/Projectiles/Rogue/MoltenAmputatorProj.cs +++ b/Projectiles/Rogue/MoltenAmputatorProj.cs @@ -26,7 +26,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 74; projectile.friendly = true; projectile.tileCollide = false; - 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 70ae338723..91ed97f076 100644 --- a/Projectiles/Rogue/MoltenBlobThrown.cs +++ b/Projectiles/Rogue/MoltenBlobThrown.cs @@ -57,12 +57,9 @@ namespace CalamityMod.Projectiles.Rogue return true; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - return 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/MythrilKnifeProjectile.cs b/Projectiles/Rogue/MythrilKnifeProjectile.cs index be56115935..e5b7103e3e 100644 --- a/Projectiles/Rogue/MythrilKnifeProjectile.cs +++ b/Projectiles/Rogue/MythrilKnifeProjectile.cs @@ -38,7 +38,6 @@ namespace CalamityMod.Projectiles.Rogue } else { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Rogue/NightsGazeProjectile.cs b/Projectiles/Rogue/NightsGazeProjectile.cs index 78cd78dca9..401e5d904a 100644 --- a/Projectiles/Rogue/NightsGazeProjectile.cs +++ b/Projectiles/Rogue/NightsGazeProjectile.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = 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 596befdf11..a01662ee66 100644 --- a/Projectiles/Rogue/NightsGazeSpark.cs +++ b/Projectiles/Rogue/NightsGazeSpark.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 6; projectile.height = 6; projectile.friendly = 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 f21d7243fd..c9e67b2132 100644 --- a/Projectiles/Rogue/NightsGazeStar.cs +++ b/Projectiles/Rogue/NightsGazeStar.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = 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/NychthemeronProjectile.cs b/Projectiles/Rogue/NychthemeronProjectile.cs index 4706283b72..c9af0188a7 100644 --- a/Projectiles/Rogue/NychthemeronProjectile.cs +++ b/Projectiles/Rogue/NychthemeronProjectile.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 10; projectile.height = 10; projectile.friendly = true; - projectile.penetrate = 4; + projectile.ignoreWater = true; + projectile.penetrate = 4; projectile.timeLeft = lifetime; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/PhantasmalRuinGhost.cs b/Projectiles/Rogue/PhantasmalRuinGhost.cs index 0d0507e03a..ca47d2927a 100644 --- a/Projectiles/Rogue/PhantasmalRuinGhost.cs +++ b/Projectiles/Rogue/PhantasmalRuinGhost.cs @@ -18,7 +18,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = 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 d78a61c7cc..764da0c0ad 100644 --- a/Projectiles/Rogue/PhantasmalRuinProj.cs +++ b/Projectiles/Rogue/PhantasmalRuinProj.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 30; projectile.height = 30; projectile.friendly = 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 ca4365eeeb..352fdb98ea 100644 --- a/Projectiles/Rogue/PhantasmalSoul.cs +++ b/Projectiles/Rogue/PhantasmalSoul.cs @@ -14,8 +14,6 @@ namespace CalamityMod.Projectiles.Rogue private const int NoHitFrames = 10; private const int NoDrawFrames = 5; - public override string Texture => "CalamityMod/Projectiles/Melee/GhastlySoulSmall"; - public override void SetStaticDefaults() { DisplayName.SetDefault("Phantasmal Soul"); @@ -26,8 +24,7 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - projectile.width = 30; - projectile.height = 30; + projectile.width = projectile.height = 36; projectile.alpha = 100; projectile.friendly = true; projectile.ignoreWater = true; diff --git a/Projectiles/Rogue/PhantasmalSoul.png b/Projectiles/Rogue/PhantasmalSoul.png new file mode 100644 index 0000000000..fe77251e7c Binary files /dev/null and b/Projectiles/Rogue/PhantasmalSoul.png differ diff --git a/Projectiles/Rogue/PhantomLanceProj.cs b/Projectiles/Rogue/PhantomLanceProj.cs index 8a1b9afaea..d0ffe55ddc 100644 --- a/Projectiles/Rogue/PhantomLanceProj.cs +++ b/Projectiles/Rogue/PhantomLanceProj.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 300; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/PrismRocket.cs b/Projectiles/Rogue/PrismRocket.cs new file mode 100644 index 0000000000..482518b704 --- /dev/null +++ b/Projectiles/Rogue/PrismRocket.cs @@ -0,0 +1,72 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class PrismRocket : ModProjectile + { + public float ExponentialAccelerationFactor => projectile.Calamity().stealthStrike ? 1.027f : 1.015f; + public float MaxHomingSpeed => projectile.Calamity().stealthStrike ? 26f : 21f; + public const int Lifetime = 150; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prism Rocket"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.friendly = true; + projectile.melee = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.timeLeft = Lifetime; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 9; + projectile.Calamity().rogue = true; + } + + 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; + + if (!projectile.WithinRange(target.Center, 30f)) + { + 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() + { + if (Main.dedServ) + return; + + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center - (projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * 10f, 261); + dust.color = Color.Cyan; + dust.velocity = Main.rand.NextVector2Unit(); + dust.scale = Main.rand.NextFloat(0.75f, 1.05f); + dust.noGravity = true; + } + } + } +} diff --git a/Projectiles/Rogue/PrismRocket.png b/Projectiles/Rogue/PrismRocket.png new file mode 100644 index 0000000000..dd035814fc Binary files /dev/null and b/Projectiles/Rogue/PrismRocket.png differ diff --git a/Projectiles/Rogue/PrismShurikenBlade.cs b/Projectiles/Rogue/PrismShurikenBlade.cs new file mode 100644 index 0000000000..696565eed0 --- /dev/null +++ b/Projectiles/Rogue/PrismShurikenBlade.cs @@ -0,0 +1,54 @@ +using Terraria; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria.ID; + +namespace CalamityMod.Projectiles.Rogue +{ + public class PrismShurikenBlade : ModProjectile + { + public override void SetStaticDefaults() => DisplayName.SetDefault("Blade"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 22; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.Calamity().rogue = true; + projectile.extraUpdates = 1; + projectile.timeLeft = 360; + } + + public override void AI() + { + CalamityGlobalProjectile.HomeInOnNPC(projectile, false, 850f, 14.5f, 35f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + + public override void Kill(int timeLeft) + { + if (Main.dedServ) + return; + + for (int i = 0; i < 25; i++) + { + Vector2 circularOffsetDirection = (MathHelper.TwoPi * i / 25f).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; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + } +} diff --git a/Projectiles/Rogue/PrismShurikenBlade.png b/Projectiles/Rogue/PrismShurikenBlade.png new file mode 100644 index 0000000000..dd035814fc Binary files /dev/null and b/Projectiles/Rogue/PrismShurikenBlade.png differ diff --git a/Projectiles/Rogue/Prismalline2.cs b/Projectiles/Rogue/Prismalline2.cs index dd83a7449c..888783e3d7 100644 --- a/Projectiles/Rogue/Prismalline2.cs +++ b/Projectiles/Rogue/Prismalline2.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = 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 f7837120e8..34669dcb54 100644 --- a/Projectiles/Rogue/Prismalline3.cs +++ b/Projectiles/Rogue/Prismalline3.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 180; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/PrismallineProj.cs b/Projectiles/Rogue/PrismallineProj.cs index c2b011a4b9..99854af771 100644 --- a/Projectiles/Rogue/PrismallineProj.cs +++ b/Projectiles/Rogue/PrismallineProj.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 113; projectile.timeLeft = 180; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/Quasar2.cs b/Projectiles/Rogue/Quasar2.cs index 3c961eadd8..02951b4af3 100644 --- a/Projectiles/Rogue/Quasar2.cs +++ b/Projectiles/Rogue/Quasar2.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 24; projectile.height = 24; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/QuasarKnife.cs b/Projectiles/Rogue/QuasarKnife.cs index e70fd7aac8..0bdf26a5c0 100644 --- a/Projectiles/Rogue/QuasarKnife.cs +++ b/Projectiles/Rogue/QuasarKnife.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 24; projectile.height = 24; projectile.friendly = true; - projectile.penetrate = 4; + projectile.ignoreWater = true; + projectile.penetrate = 4; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/RadiantStar2.cs b/Projectiles/Rogue/RadiantStar2.cs index b796f966e3..427d04dfd6 100644 --- a/Projectiles/Rogue/RadiantStar2.cs +++ b/Projectiles/Rogue/RadiantStar2.cs @@ -26,7 +26,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 24; projectile.height = 24; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/RadiantStarKnife.cs b/Projectiles/Rogue/RadiantStarKnife.cs index f6b3245958..9bc04e7e11 100644 --- a/Projectiles/Rogue/RadiantStarKnife.cs +++ b/Projectiles/Rogue/RadiantStarKnife.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 24; projectile.height = 24; projectile.friendly = true; - projectile.penetrate = 4; + projectile.ignoreWater = true; + projectile.penetrate = 4; projectile.timeLeft = 300; projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/ReaperProjectile.cs b/Projectiles/Rogue/ReaperProjectile.cs index e7598efdab..9a4f67deb9 100644 --- a/Projectiles/Rogue/ReaperProjectile.cs +++ b/Projectiles/Rogue/ReaperProjectile.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 70; projectile.friendly = true; projectile.tileCollide = false; - 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/RefractionRotorGlowmask.png b/Projectiles/Rogue/RefractionRotorGlowmask.png new file mode 100644 index 0000000000..0cdffe82c6 Binary files /dev/null and b/Projectiles/Rogue/RefractionRotorGlowmask.png differ diff --git a/Projectiles/Rogue/RefractionRotorProjectile.cs b/Projectiles/Rogue/RefractionRotorProjectile.cs new file mode 100644 index 0000000000..e87801c161 --- /dev/null +++ b/Projectiles/Rogue/RefractionRotorProjectile.cs @@ -0,0 +1,115 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class RefractionRotorProjectile : ModProjectile + { + public const int EnergyShotCount = 6; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/RefractionRotor"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Prism Shuriken"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 16; + } + + public override void SetDefaults() + { + projectile.width = 142; + projectile.height = 126; + projectile.friendly = true; + projectile.penetrate = 10; + projectile.timeLeft = 300; + projectile.alpha = 255; + projectile.tileCollide = false; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Calamity().rogue = true; + } + + public override void AI() + { + projectile.alpha = Utils.Clamp(projectile.alpha - 18, 0, 255); + projectile.rotation += projectile.velocity.Length() * Math.Sign(projectile.velocity.X) * 0.036f; + } + + public override bool CanDamage() => projectile.alpha <= 128; + + 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) + { + // 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 < 80; i++) + { + Dust rainbowBurst = Dust.NewDustPerfect(projectile.Center, 267); + rainbowBurst.color = Main.hslToRgb(i / 80f, 0.9f, 0.6f); + rainbowBurst.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(3f, 5.5f); + rainbowBurst.scale = Main.rand.NextFloat(1.4f, 2.4f); + rainbowBurst.fadeIn = Main.rand.NextFloat(0.8f, 1.6f); + rainbowBurst.noGravity = true; + } + + if (!projectile.Calamity().stealthStrike) + { + int goreType = mod.GetGoreSlot("Gores/PrismShurikenBlade"); + for (int i = 0; i < 6; i++) + { + Vector2 shootDirection = (MathHelper.TwoPi * i / 6f + projectile.rotation + MathHelper.PiOver2).ToRotationVector2(); + Vector2 spawnPosition = projectile.Center + projectile.Size * 0.5f * projectile.scale * shootDirection * 0.85f; + if (!WorldGen.SolidTile((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16)) + Gore.NewGorePerfect(spawnPosition, projectile.velocity * 0.5f + shootDirection * 7f, goreType, projectile.scale); + } + } + } + + int shootType = ModContent.ProjectileType(); + if (Main.myPlayer != projectile.owner) + return; + + // Release a circle of damaging blades if this projectile is a stealth strike. + if (projectile.Calamity().stealthStrike) + { + int bladeType = ModContent.ProjectileType(); + for (int i = 0; i < 6; i++) + { + Vector2 shootDirection = (MathHelper.TwoPi * i / 6f + projectile.rotation + MathHelper.PiOver2).ToRotationVector2(); + Vector2 spawnPosition = projectile.Center + projectile.Size * 0.5f * projectile.scale * shootDirection * 0.85f; + Projectile.NewProjectile(spawnPosition, projectile.velocity * 0.5f + shootDirection * 7f, bladeType, projectile.damage, projectile.knockBack, projectile.owner); + } + } + + if (CalamityUtils.CountProjectiles(shootType) > 24) + return; + + int energyDamage = (int)(projectile.damage * 0.66); + float baseDirectionRotation = Main.rand.NextFloat(MathHelper.TwoPi); + for (int i = 0; i < EnergyShotCount; i++) + { + 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) + { + 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 6610c60468..63af8ba324 100644 --- a/Projectiles/Rogue/RegulusEnergy.cs +++ b/Projectiles/Rogue/RegulusEnergy.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue { projectile.width = 8; projectile.height = 8; - projectile.friendly = true; + projectile.ignoreWater = true; + projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/SacrificeProjectile.cs b/Projectiles/Rogue/SacrificeProjectile.cs new file mode 100644 index 0000000000..e86e784981 --- /dev/null +++ b/Projectiles/Rogue/SacrificeProjectile.cs @@ -0,0 +1,113 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class SacrificeProjectile : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public bool StickingToAnything => projectile.ai[0] == 1f; + public bool ReturningToOwner => projectile.ai[0] == 2f; + public bool AbleToHealOwner = true; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Sacrifice"; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sacrifice"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 68; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = -1; + projectile.timeLeft = 600; + projectile.Calamity().rogue = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(AbleToHealOwner); + + public override void ReceiveExtraAI(BinaryReader reader) => AbleToHealOwner = reader.ReadBoolean(); + + + public override void AI() + { + if (ReturningToOwner) + { + projectile.timeLeft = 2; + projectile.velocity = projectile.SafeDirectionTo(Owner.Center) * 24f; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.Pi + MathHelper.PiOver4; + + // Heal the player and disappear when touching them. + if (projectile.Hitbox.Intersects(Owner.Hitbox)) + { + if (!Owner.moonLeech && AbleToHealOwner) + { + int healAmount = projectile.Calamity().stealthStrike ? 50 : 4; + + Owner.HealEffect(healAmount); + Owner.statLife += healAmount; + if (Owner.statLife > Owner.statLifeMax2) + Owner.statLife = Owner.statLifeMax2; + } + + projectile.Kill(); + } + } + else if (!StickingToAnything) + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + else if (!Main.dedServ && projectile.timeLeft % 40f == 39f) + { + for (int i = 0; i < 60; i++) + { + Dust blood = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(50f, 50f), 267); + blood.velocity = Main.rand.NextVector2Circular(3f, 3f); + blood.noGravity = true; + blood.color = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.25f, 1f)); + blood.scale = Main.rand.NextFloat(1f, 1.4f); + } + } + + if (StickingToAnything && projectile.timeLeft > 90) + projectile.timeLeft = 90; + projectile.StickyProjAI(50); + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + projectile.ModifyHitNPCSticky(15, true); + projectile.velocity *= 0.5f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + Collision.HitTiles(projectile.position + projectile.velocity, projectile.velocity, projectile.width, projectile.height); + Main.PlaySound(SoundID.Dig, projectile.position); + projectile.Kill(); + return false; + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dust = Dust.NewDust(projectile.Center, 1, 1, 5, 0, 0, 0, default, 1.5f); + Main.dust[dust].noGravity = true; + } + } + } +} diff --git a/Projectiles/Rogue/SandslasherProj.cs b/Projectiles/Rogue/SandslasherProj.cs index c56740ffb1..4869517c5f 100644 --- a/Projectiles/Rogue/SandslasherProj.cs +++ b/Projectiles/Rogue/SandslasherProj.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 40; projectile.height = 40; projectile.friendly = true; - projectile.penetrate = 3; + projectile.ignoreWater = true; + projectile.penetrate = 3; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 16; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/ScarletDevilBullet.cs b/Projectiles/Rogue/ScarletDevilBullet.cs index 84663dc8f2..dd5420ca52 100644 --- a/Projectiles/Rogue/ScarletDevilBullet.cs +++ b/Projectiles/Rogue/ScarletDevilBullet.cs @@ -18,7 +18,6 @@ namespace CalamityMod.Projectiles.Rogue projectile.timeLeft = 140; projectile.tileCollide = false; projectile.ignoreWater = true; - projectile.Calamity().rogue = true; } public override void AI() @@ -67,5 +66,12 @@ namespace CalamityMod.Projectiles.Rogue { return new Color(250, 250, 250); } + + public override bool CanDamage() + { + if (projectile.Calamity().stealthStrike && projectile.ai[0] < 60f) + return false; + return base.CanDamage(); + } } } diff --git a/Projectiles/Rogue/ScarletDevilProjectile.cs b/Projectiles/Rogue/ScarletDevilProjectile.cs index 9fd3ba7221..12af7ff5c2 100644 --- a/Projectiles/Rogue/ScarletDevilProjectile.cs +++ b/Projectiles/Rogue/ScarletDevilProjectile.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; @@ -10,21 +11,25 @@ namespace CalamityMod.Projectiles.Rogue { public class ScarletDevilProjectile : ModProjectile { + internal PrimitiveTrail TrailDrawer; + public ref float ShootTimer => ref projectile.ai[0]; public override string Texture => "CalamityMod/Items/Weapons/Rogue/ScarletDevil"; public override void SetStaticDefaults() { DisplayName.SetDefault("Spear the Gungnir"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 45; ProjectileID.Sets.TrailingMode[projectile.type] = 0; } public override void SetDefaults() { - projectile.width = 116; - projectile.height = 116; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 45; + projectile.width = 92; + projectile.height = 92; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.tileCollide = false; projectile.timeLeft = 300; projectile.extraUpdates = 1; @@ -33,29 +38,72 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { - CalamityPlayer modPlayer = Main.player[projectile.owner].Calamity(); Lighting.AddLight(projectile.Center, 0.55f, 0.25f, 0f); - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 0.785f; - Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 130, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.85f); - projectile.ai[0] += 1f; - if (projectile.ai[0] == 1f && modPlayer.StealthStrikeAvailable()) + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + + if (!Main.dedServ) { - projectile.Calamity().stealthStrike = true; + for (int i = 0; i < (projectile.Calamity().stealthStrike && Main.rand.NextBool(2) ? 2 : 1); i++) + Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 130, projectile.velocity.X * 0.25f, projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.85f); } - if ((projectile.ai[0] %= 5f) == 0f) + + ShootTimer++; + + if (!projectile.Calamity().stealthStrike && projectile.oldPos.Length != 6) + projectile.oldPos = new Vector2[6]; + + if ((ShootTimer %= 5f) == 0f && !projectile.Calamity().stealthStrike) { - int numProj = 2; - float rotation = MathHelper.ToRadians(15); if (projectile.owner == Main.myPlayer) + GenerateSideBullets(2, MathHelper.ToRadians(15f)); + } + } + + internal void GenerateSideBullets(int totalBullets, float rotationalOffset) + { + for (int i = 0; i < totalBullets; i++) + { + Vector2 perturbedSpeed = new Vector2(-projectile.velocity.X / 3, -projectile.velocity.Y / 3).RotatedBy(MathHelper.Lerp(-rotationalOffset, rotationalOffset, i / (totalBullets - 1))); + for (int j = 0; j < 2; j++) { - for (int i = 0; i < numProj; i++) + Projectile.NewProjectile(projectile.Center, perturbedSpeed, ModContent.ProjectileType(), (int)(projectile.damage * 0.03), 0f, projectile.owner, 0f, 0f); + perturbedSpeed *= 1.05f; + } + } + } + + internal void SpawnOnStealthStrikeBullets() + { + float starSpeed = 25f; + + // Spawn a circle of fast bullets. + for (int i = 0; i < 40; i++) + { + Vector2 shootVelocity = (MathHelper.TwoPi * i / 40f).ToRotationVector2() * starSpeed; + int bullet = Projectile.NewProjectile(projectile.Center + shootVelocity, shootVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.01), 0f, projectile.owner); + if (Main.projectile.IndexInRange(bullet)) + Main.projectile[bullet].Calamity().stealthStrike = true; + } + + // Spawn a pair of stars, one slow, one fast. + int pointsOnStar = 6; + for (int k = 0; k < 2; k++) + { + for (int i = 0; i < pointsOnStar; i++) + { + float angle = MathHelper.Pi * 1.5f - i * MathHelper.TwoPi / pointsOnStar; + float nextAngle = MathHelper.Pi * 1.5f - (i + 3) % pointsOnStar * MathHelper.TwoPi / pointsOnStar; + if (k == 1) + nextAngle = MathHelper.Pi * 1.5f - (i + 2) * MathHelper.TwoPi / pointsOnStar; + Vector2 start = angle.ToRotationVector2(); + Vector2 end = nextAngle.ToRotationVector2(); + int pointsOnStarSegment = 18; + for (int j = 0; j < pointsOnStarSegment; j++) { - Vector2 perturbedSpeed = new Vector2(-projectile.velocity.X / 3, -projectile.velocity.Y / 3).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); - for (int j = 0; j < 2; j++) - { - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedSpeed.X, perturbedSpeed.Y, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.03), 0f, projectile.owner, 0f, 0f); - perturbedSpeed *= 1.05f; - } + Vector2 shootVelocity = Vector2.Lerp(start, end, j / (float)pointsOnStarSegment) * starSpeed; + int bullet = Projectile.NewProjectile(projectile.Center + shootVelocity, shootVelocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.01), 0f, projectile.owner); + if (Main.projectile.IndexInRange(bullet)) + Main.projectile[bullet].Calamity().stealthStrike = true; } } } @@ -73,38 +121,78 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 150; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.0075), 0f, projectile.owner, 0f, 0f); - - if (!projectile.Calamity().stealthStrike || Main.player[projectile.owner].moonLeech) + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 150); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.0075), 0f, projectile.owner); + if (!projectile.Calamity().stealthStrike) return; - Main.player[projectile.owner].statLife += 50; - Main.player[projectile.owner].HealEffect(50); + if (!Main.player[projectile.owner].moonLeech) + { + // Give on-heal effects from stealth strikes. + Main.player[projectile.owner].statLife += 120; + Main.player[projectile.owner].HealEffect(120); + } + + // And spawn a bloom of bullets. + SpawnOnStealthStrikeBullets(); } public override void OnHitPvp(Player target, int damage, bool crit) { - projectile.position = projectile.Center; - projectile.width = projectile.height = 150; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), (int)((double)projectile.damage * 0.0075), 0f, projectile.owner, 0f, 0f); - - if (!projectile.Calamity().stealthStrike) + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 150); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.0075), 0f, projectile.owner); + if (!projectile.Calamity().stealthStrike) return; - Main.player[projectile.owner].statLife += 50; - Main.player[projectile.owner].HealEffect(50); + // Give on-heal effects from stealth strikes. + Main.player[projectile.owner].statLife += 120; + Main.player[projectile.owner].HealEffect(120); + + // And spawn a bloom of bullets. + SpawnOnStealthStrikeBullets(); + } + + internal float WidthFunction(float completionRatio) + { + float widthRatio = Utils.InverseLerp(0f, 0.1f, completionRatio, true); + float baseWidth = MathHelper.Lerp(0f, 110f, widthRatio) * MathHelper.Clamp(1f - (float)Math.Pow(completionRatio, 0.4D), 0.37f, 1f); + return baseWidth; + } + + internal Color ColorFunction(float completionRatio) + { + float colorFade = 1f - Utils.InverseLerp(0.6f, 0.98f, completionRatio, true); + Color baseColor = CalamityUtils.MulticolorLerp((float)Math.Pow(completionRatio, 1D / 2D), Color.White, Color.DarkRed, Color.Wheat, Color.IndianRed) * MathHelper.Lerp(0f, 1.4f, colorFade); + return Color.Lerp(baseColor, Color.DarkRed, (float)Math.Pow(completionRatio, 3D)); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], new Color(100, 100, 100), 1); - return true; + if (!projectile.Calamity().stealthStrike) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], new Color(100, 100, 100)); + return true; + } + else + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"]); + + GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/ScarletDevilStreak")); + TrailDrawer.Draw(projectile.oldPos, projectile.Size * 0.5f - Main.screenPosition + projectile.velocity.SafeNormalize(Vector2.Zero) * 86f, 60); + + Texture2D spearTexture = ModContent.GetTexture(Texture); + + for (int i = 0; i < 7; i++) + { + Color drawColor = Color.Lerp(lightColor, Color.White, 0.8f) * 0.2f; + drawColor.A = 0; + + Vector2 drawOffset = (i / 7f * MathHelper.TwoPi).ToRotationVector2() * 2f; + spriteBatch.Draw(spearTexture, projectile.Center - Main.screenPosition + drawOffset, null, drawColor, projectile.rotation, spearTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + return false; } } } diff --git a/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs b/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs index 11999af4dd..59359ee3ca 100644 --- a/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs +++ b/Projectiles/Rogue/ScourgeoftheSeasProjectile.cs @@ -24,7 +24,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 26; projectile.height = 26; projectile.friendly = true; - projectile.aiStyle = 113; + projectile.ignoreWater = true; + projectile.aiStyle = 113; aiType = ProjectileID.BoneJavelin; projectile.penetrate = 1; projectile.extraUpdates = 1; diff --git a/Projectiles/Rogue/ShatteredSunKnife.cs b/Projectiles/Rogue/ShatteredSunKnife.cs index a3e59a3372..692ef944a6 100644 --- a/Projectiles/Rogue/ShatteredSunKnife.cs +++ b/Projectiles/Rogue/ShatteredSunKnife.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 56; projectile.height = 56; projectile.friendly = true; - projectile.penetrate = 4; + projectile.ignoreWater = true; + projectile.penetrate = 4; projectile.timeLeft = 300; projectile.alpha = 255; projectile.tileCollide = false; diff --git a/Projectiles/Rogue/ShinobiBladeProjectile.cs b/Projectiles/Rogue/ShinobiBladeProjectile.cs index 1104b9bb3d..9e43321131 100644 --- a/Projectiles/Rogue/ShinobiBladeProjectile.cs +++ b/Projectiles/Rogue/ShinobiBladeProjectile.cs @@ -20,8 +20,7 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - projectile.width = 10; - projectile.height = 10; + projectile.width = projectile.height = 16; projectile.friendly = true; projectile.penetrate = 1; projectile.timeLeft = 300; @@ -31,7 +30,7 @@ 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) + MathHelper.ToRadians(45) * projectile.direction; + projectile.rotation = projectile.velocity.ToRotation() + (projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.PiOver2 * projectile.spriteDirection; if (Main.rand.NextBool(5)) { diff --git a/Projectiles/Rogue/SpearofDestinyProjectile.cs b/Projectiles/Rogue/SpearofDestinyProjectile.cs index 7d12acb713..3bc92202ed 100644 --- a/Projectiles/Rogue/SpearofDestinyProjectile.cs +++ b/Projectiles/Rogue/SpearofDestinyProjectile.cs @@ -25,7 +25,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.penetrate = 2; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/SpearofPaleolithProj.cs b/Projectiles/Rogue/SpearofPaleolithProj.cs index 834978cbc2..8fa14e0290 100644 --- a/Projectiles/Rogue/SpearofPaleolithProj.cs +++ b/Projectiles/Rogue/SpearofPaleolithProj.cs @@ -26,7 +26,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.aiStyle = 113; projectile.timeLeft = 600; aiType = ProjectileID.BoneJavelin; diff --git a/Projectiles/Rogue/SphereBladed.cs b/Projectiles/Rogue/SphereBladed.cs index 6660a15e0d..fb62eab57a 100644 --- a/Projectiles/Rogue/SphereBladed.cs +++ b/Projectiles/Rogue/SphereBladed.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 20; projectile.friendly = true; projectile.tileCollide = 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 0852bd4354..d7d2d5ef8d 100644 --- a/Projectiles/Rogue/SphereBlue.cs +++ b/Projectiles/Rogue/SphereBlue.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 300; projectile.tileCollide = false; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/SphereSpiked.cs b/Projectiles/Rogue/SphereSpiked.cs index ad669775fe..4bab34e09a 100644 --- a/Projectiles/Rogue/SphereSpiked.cs +++ b/Projectiles/Rogue/SphereSpiked.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 20; projectile.friendly = true; projectile.penetrate = -1; - 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 f89f43608a..e3d5a194d2 100644 --- a/Projectiles/Rogue/SphereYellow.cs +++ b/Projectiles/Rogue/SphereYellow.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.aiStyle = 3; projectile.timeLeft = 300; aiType = ProjectileID.WoodenBoomerang; diff --git a/Projectiles/Rogue/StellarKnifeProj.cs b/Projectiles/Rogue/StellarKnifeProj.cs index 33953839c6..94459d1cfe 100644 --- a/Projectiles/Rogue/StellarKnifeProj.cs +++ b/Projectiles/Rogue/StellarKnifeProj.cs @@ -26,7 +26,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 32; projectile.height = 34; projectile.friendly = true; - projectile.penetrate = 1; + projectile.ignoreWater = true; + projectile.penetrate = 1; projectile.timeLeft = 600; projectile.tileCollide = true; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/StormfrontRazorProjectile.cs b/Projectiles/Rogue/StormfrontRazorProjectile.cs index e35c8ed7af..3e6bdb3e98 100644 --- a/Projectiles/Rogue/StormfrontRazorProjectile.cs +++ b/Projectiles/Rogue/StormfrontRazorProjectile.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = 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 a218cac68e..b78b5d5a14 100644 --- a/Projectiles/Rogue/Stormfrontspark.cs +++ b/Projectiles/Rogue/Stormfrontspark.cs @@ -15,7 +15,8 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { projectile.friendly = true; - projectile.width = 6; + projectile.ignoreWater = true; + projectile.width = 6; projectile.height = 12; projectile.timeLeft = 240; projectile.penetrate = -1; @@ -54,13 +55,6 @@ namespace CalamityMod.Projectiles.Rogue } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Rogue/SylvanSlashAttack.cs b/Projectiles/Rogue/SylvanSlashAttack.cs index 50591f5f95..12186cdbdf 100644 --- a/Projectiles/Rogue/SylvanSlashAttack.cs +++ b/Projectiles/Rogue/SylvanSlashAttack.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 68; projectile.height = 68; projectile.friendly = true; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.tileCollide = false; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/TalonLargeProj.cs b/Projectiles/Rogue/TalonLargeProj.cs index 0c3e3943ea..1de7c63a9b 100644 --- a/Projectiles/Rogue/TalonLargeProj.cs +++ b/Projectiles/Rogue/TalonLargeProj.cs @@ -20,7 +20,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 20; projectile.height = 20; projectile.friendly = true; - projectile.penetrate = 10; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.tileCollide = false; projectile.timeLeft = 180; projectile.Calamity().rogue = true; diff --git a/Projectiles/Rogue/TalonSmallProj.cs b/Projectiles/Rogue/TalonSmallProj.cs index e08e5ce3ad..9287484d4f 100644 --- a/Projectiles/Rogue/TalonSmallProj.cs +++ b/Projectiles/Rogue/TalonSmallProj.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.timeLeft = 600; + projectile.ignoreWater = true; + projectile.timeLeft = 600; projectile.Calamity().rogue = true; SineFrequency = 0.15f; diff --git a/Projectiles/Rogue/TarragonThrowingDartProjectile.cs b/Projectiles/Rogue/TarragonThrowingDartProjectile.cs index a24403ae50..6407eb637f 100644 --- a/Projectiles/Rogue/TarragonThrowingDartProjectile.cs +++ b/Projectiles/Rogue/TarragonThrowingDartProjectile.cs @@ -22,7 +22,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 12; projectile.height = 12; projectile.friendly = 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 555472dc94..40cf6c04ae 100644 --- a/Projectiles/Rogue/TerraDiskProjectile.cs +++ b/Projectiles/Rogue/TerraDiskProjectile.cs @@ -25,6 +25,7 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { projectile.width = projectile.height = 46; + projectile.ignoreWater = true; projectile.friendly = true; projectile.tileCollide = false; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/TerraDiskProjectile2.cs b/Projectiles/Rogue/TerraDiskProjectile2.cs index d6299d53d4..a87f3ff0c8 100644 --- a/Projectiles/Rogue/TerraDiskProjectile2.cs +++ b/Projectiles/Rogue/TerraDiskProjectile2.cs @@ -21,6 +21,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 40; projectile.height = 40; projectile.alpha = 75; + projectile.ignoreWater = true; projectile.friendly = true; projectile.tileCollide = false; projectile.penetrate = -1; diff --git a/Projectiles/Rogue/TheAtomSplitterDuplicate.cs b/Projectiles/Rogue/TheAtomSplitterDuplicate.cs new file mode 100644 index 0000000000..0dfc874940 --- /dev/null +++ b/Projectiles/Rogue/TheAtomSplitterDuplicate.cs @@ -0,0 +1,61 @@ +using CalamityMod.Items; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class TheAtomSplitterDuplicate : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public ref float Lifetime => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Atom Splitter"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.scale = 0.66f; + projectile.width = projectile.height = (int)(124f * projectile.scale); + projectile.friendly = true; + projectile.penetrate = 3; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 16; + projectile.timeLeft = 900; + projectile.extraUpdates = 1; + projectile.Calamity().rogue = true; + } + + public override void AI() + { + // Accelerate until at a certain speed. + if (projectile.velocity.Length() < 20f) + projectile.velocity *= 1.02f; + + projectile.Opacity = CalamityUtils.Convert01To010(Time / Lifetime) * 0.6f; + if (Time >= Lifetime) + projectile.Kill(); + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + Time++; + } + + public override bool CanDamage() => projectile.alpha < 180; + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (Time <= 1f) + return false; + + Color drawColor = CalamityUtils.MulticolorLerp((Time / 35f + projectile.identity / 4f) % 1f, CalamityGlobalItem.ExoPalette); + drawColor.A = 0; + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], drawColor); + return false; + } + } +} diff --git a/Projectiles/Rogue/TheAtomSplitterDuplicate.png b/Projectiles/Rogue/TheAtomSplitterDuplicate.png new file mode 100644 index 0000000000..e6f4b2d8f3 Binary files /dev/null and b/Projectiles/Rogue/TheAtomSplitterDuplicate.png differ diff --git a/Projectiles/Rogue/TheAtomSplitterProjectile.cs b/Projectiles/Rogue/TheAtomSplitterProjectile.cs new file mode 100644 index 0000000000..abc384ed25 --- /dev/null +++ b/Projectiles/Rogue/TheAtomSplitterProjectile.cs @@ -0,0 +1,166 @@ +using CalamityMod.Items; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class TheAtomSplitterProjectile : ModProjectile + { + public ref float HitTargetIndex => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + + public override string Texture => "CalamityMod/Items/Weapons/Rogue/TheAtomSplitter"; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Atom Splitter"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 124; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.penetrate = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.timeLeft = 300; + projectile.Calamity().rogue = true; + } + + public override void SendExtraAI(BinaryWriter writer) + { + // timeLeft is not synced by default. However, it is changed during an operation that is only + // performed from one client's perspective, therefore it must be synced in this context. + writer.Write(projectile.timeLeft); + writer.Write((byte)projectile.alpha); + writer.Write(projectile.scale); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.timeLeft = reader.ReadInt32(); + projectile.alpha = reader.ReadByte(); + projectile.scale = reader.ReadSingle(); + } + + public override void AI() + { + // Accelerate until at a certain speed. + if (projectile.velocity.Length() < 20f) + projectile.velocity *= 1.02f; + + if (projectile.alpha < 10) + EmitDustFromTip(); + + // Stick to the target for a while and release a bunch of duplicates. + if (Main.npc.IndexInRange((int)HitTargetIndex) && Main.npc[(int)HitTargetIndex].active) + { + if (projectile.alpha < 255) + projectile.alpha = Utils.Clamp(projectile.alpha + 30, 0, 255); + + int shootRate = projectile.Calamity().stealthStrike ? 2 : 4; + if (projectile.timeLeft % shootRate == shootRate - 1) + { + FireDuplicateAtTarget(Main.npc[(int)HitTargetIndex], projectile.Calamity().stealthStrike ? 305f : 200f); + if (projectile.Calamity().stealthStrike) + FireExtraDuplicatesAtTarget(Main.npc[(int)HitTargetIndex]); + } + } + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + Time++; + } + + public void EmitDustFromTip() + { + if (Main.dedServ) + return; + + float dustVelocityArcOffset = 1.5f + (float)Math.Sin(MathHelper.TwoPi * projectile.timeLeft / 35f) * 0.25f; + + float colorInterpolant = (float)Math.Cos(MathHelper.TwoPi * projectile.timeLeft / 75f) * 0.5f + 0.5f; + Color dustColor = CalamityUtils.MulticolorLerp(colorInterpolant, CalamityGlobalItem.ExoPalette); + Vector2 currentDirection = projectile.velocity.SafeNormalize(-Vector2.UnitY); + Vector2 tipPosition = projectile.Center + currentDirection * (projectile.height * 0.67f - 3f); + tipPosition += Main.rand.NextVector2CircularEdge(0.35f, 0.35f); + + for (float direction = -1f; direction <= 1f; direction += 2f) + { + Dust prismaticEnergy = Dust.NewDustPerfect(tipPosition, 267); + prismaticEnergy.velocity = currentDirection.RotatedBy(direction * dustVelocityArcOffset) * -7f + projectile.velocity; + prismaticEnergy.scale = 1.2f; + prismaticEnergy.color = dustColor; + prismaticEnergy.noGravity = true; + + prismaticEnergy = Dust.CloneDust(prismaticEnergy); + prismaticEnergy.scale *= 0.6f; + } + } + + public void FireDuplicateAtTarget(NPC target, float baseOutwardness) + { + if (Main.myPlayer != projectile.owner) + return; + + Vector2 spawnPosition = target.Center + Main.rand.NextVector2CircularEdge(baseOutwardness, baseOutwardness) * Main.rand.NextFloat(0.9f, 1.15f); + Vector2 shootVelocity = (target.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(12f, 14f); + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, baseOutwardness / 9f); + } + + public void FireExtraDuplicatesAtTarget(NPC target) + { + if (Main.myPlayer != projectile.owner) + return; + + Vector2 spawnPosition = target.Center + Vector2.UnitY * Main.rand.NextBool(2).ToDirectionInt() * Main.rand.NextFloat(200f, 270f); + spawnPosition.X += Main.rand.NextFloatDirection() * target.width * 0.45f; + + Vector2 shootVelocity = Vector2.UnitY * (target.Center.Y - spawnPosition.Y > 0f).ToDirectionInt() * Main.rand.NextFloat(14f, 16.5f); + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 24f); + } + + public void ReleaseHitDust(Vector2 spawnPosition) + { + if (Main.dedServ) + return; + + int dustCount = projectile.Calamity().stealthStrike ? 60 : 40; + Vector2 baseDustVelocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * 1.4f; + Vector2 outwardFireSpeedFactor = new Vector2(2.1f, 2f); + + for (float i = 0f; i < dustCount; i++) + { + Color dustColor = CalamityUtils.MulticolorLerp(Main.rand.NextFloat(), CalamityGlobalItem.ExoPalette); + Dust explosionDust = Dust.NewDustDirect(spawnPosition, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); + explosionDust.position = spawnPosition; + explosionDust.velocity = baseDustVelocity.RotatedBy(MathHelper.TwoPi * i / dustCount) * outwardFireSpeedFactor * Main.rand.NextFloat(0.8f, 1.2f); + explosionDust.velocity += projectile.velocity * Main.rand.NextFloat(0.6f, 0.85f); + if (projectile.Calamity().stealthStrike) + explosionDust.velocity *= 1.6f; + + explosionDust.noGravity = true; + explosionDust.scale = 1.1f; + explosionDust.fadeIn = Main.rand.NextFloat(1.4f, 2.4f); + + Dust.CloneDust(explosionDust).velocity *= Main.rand.NextFloat(0.8f); + + explosionDust = Dust.CloneDust(explosionDust); + explosionDust.scale /= 2f; + explosionDust.fadeIn /= 2f; + explosionDust.color = new Color(255, 255, 255, 255); + } + } + + public override bool CanDamage() => projectile.alpha < 80; + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + ReleaseHitDust(target.Center - projectile.velocity * 3f); + HitTargetIndex = target.whoAmI; + projectile.timeLeft = projectile.Calamity().stealthStrike ? 100 : 60; + projectile.netUpdate = true; + } + } +} diff --git a/Projectiles/Rogue/TheSyringeCinder.cs b/Projectiles/Rogue/TheSyringeCinder.cs index b7218845ce..40df8407c9 100644 --- a/Projectiles/Rogue/TheSyringeCinder.cs +++ b/Projectiles/Rogue/TheSyringeCinder.cs @@ -114,10 +114,6 @@ namespace CalamityMod.Projectiles.Rogue public override bool OnTileCollide(Vector2 oldVelocity) { projectile.ai[1] = 1f; - if (projectile.penetrate == 0) - { - projectile.Kill(); - } return false; } diff --git a/Projectiles/Rogue/TimeBoltKnife.cs b/Projectiles/Rogue/TimeBoltKnife.cs index 24c5e5f11a..0d9804ebc2 100644 --- a/Projectiles/Rogue/TimeBoltKnife.cs +++ b/Projectiles/Rogue/TimeBoltKnife.cs @@ -28,7 +28,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 28; projectile.height = 28; projectile.friendly = true; - projectile.penetrate = penetrationAmt; + projectile.ignoreWater = true; + projectile.penetrate = penetrationAmt; projectile.timeLeft = 600; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; @@ -309,7 +310,7 @@ namespace CalamityMod.Projectiles.Rogue if (npc.active && !npc.dontTakeDamage && !npc.buffImmune[buffType] && Vector2.Distance(projectile.Center, npc.Center) <= radius) { if (npc.FindBuffIndex(buffType) == -1) - npc.AddBuff(buffType, 90, false); + npc.AddBuff(buffType, 60, false); } } } diff --git a/Projectiles/Rogue/TitaniumShurikenProjectile.cs b/Projectiles/Rogue/TitaniumShurikenProjectile.cs index e62b061cec..0fcbacdff2 100644 --- a/Projectiles/Rogue/TitaniumShurikenProjectile.cs +++ b/Projectiles/Rogue/TitaniumShurikenProjectile.cs @@ -117,7 +117,6 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.Calamity().stealthStrike) { - projectile.ai[0] += 0.1f; if (projectile.velocity.X != oldVelocity.X) { projectile.velocity.X = -oldVelocity.X; diff --git a/Projectiles/Rogue/TotalityFire.cs b/Projectiles/Rogue/TotalityFire.cs index 5b3d1bf60a..d1ff48b432 100644 --- a/Projectiles/Rogue/TotalityFire.cs +++ b/Projectiles/Rogue/TotalityFire.cs @@ -29,7 +29,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = -1; projectile.Calamity().rogue = true; - } + projectile.ignoreWater = true; + } public override void AI() { diff --git a/Projectiles/Rogue/ToxicantTwisterDust.cs b/Projectiles/Rogue/ToxicantTwisterDust.cs index c7de0adf9d..ad348aa335 100644 --- a/Projectiles/Rogue/ToxicantTwisterDust.cs +++ b/Projectiles/Rogue/ToxicantTwisterDust.cs @@ -19,7 +19,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 6; projectile.friendly = true; projectile.tileCollide = 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 a24c5b6eaa..b14aac28e3 100644 --- a/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs +++ b/Projectiles/Rogue/ToxicantTwisterTwoPointZero.cs @@ -26,7 +26,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 46; projectile.friendly = true; projectile.tileCollide = false; - projectile.penetrate = -1; + projectile.ignoreWater = true; + projectile.penetrate = -1; projectile.timeLeft = lifeTime; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Rogue/ValariBoomerang.cs b/Projectiles/Rogue/ValariBoomerang.cs index 5dbc617b03..b32e793ced 100644 --- a/Projectiles/Rogue/ValariBoomerang.cs +++ b/Projectiles/Rogue/ValariBoomerang.cs @@ -28,7 +28,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 40; projectile.penetrate = -1; projectile.timeLeft = 360; - projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.tileCollide = false; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 15; projectile.coldDamage = true; @@ -149,8 +150,7 @@ namespace CalamityMod.Projectiles.Rogue OnHitEffects(); target.AddBuff(BuffID.Frostburn, 240); target.AddBuff(ModContent.BuffType(), 240); - if (Main.rand.NextBool(5)) - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 60); } public override void OnHitPvp(Player target, int damage, bool crit) @@ -158,8 +158,7 @@ namespace CalamityMod.Projectiles.Rogue OnHitEffects(); target.AddBuff(BuffID.Frostburn, 240); target.AddBuff(ModContent.BuffType(), 240); - if (Main.rand.NextBool(5)) - target.AddBuff(ModContent.BuffType(), 60); + target.AddBuff(ModContent.BuffType(), 60); } public override bool OnTileCollide(Vector2 oldVelocity) diff --git a/Projectiles/Rogue/ValedictionBoomerang.cs b/Projectiles/Rogue/ValedictionBoomerang.cs index bf409fdeda..444c608735 100644 --- a/Projectiles/Rogue/ValedictionBoomerang.cs +++ b/Projectiles/Rogue/ValedictionBoomerang.cs @@ -24,6 +24,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = projectile.height = 70; projectile.friendly = true; projectile.tileCollide = false; + projectile.ignoreWater = true; projectile.penetrate = -1; projectile.extraUpdates = 3; projectile.usesLocalNPCImmunity = true; diff --git a/Projectiles/Typeless/CirrusBolt.cs b/Projectiles/Summon/AngelBolt.cs similarity index 55% rename from Projectiles/Typeless/CirrusBolt.cs rename to Projectiles/Summon/AngelBolt.cs index a5480db6c2..dce9e63033 100644 --- a/Projectiles/Typeless/CirrusBolt.cs +++ b/Projectiles/Summon/AngelBolt.cs @@ -1,15 +1,19 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Typeless +namespace CalamityMod.Projectiles.Summon { - public class CirrusBolt : ModProjectile + public class AngelBolt : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { DisplayName.SetDefault("Bolt"); + ProjectileID.Sets.MinionShot[projectile.type] = true; } public override void SetDefaults() @@ -19,8 +23,9 @@ namespace CalamityMod.Projectiles.Typeless projectile.extraUpdates = 100; projectile.friendly = true; projectile.timeLeft = 45; - projectile.magic = true; - projectile.npcProj = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.ignoreWater = true; } public override void AI() @@ -29,7 +34,7 @@ namespace CalamityMod.Projectiles.Typeless { Vector2 vector33 = projectile.position; vector33 -= projectile.velocity * 0.25f; - int num448 = Dust.NewDust(vector33, 1, 1, 234, 0f, 0f, 0, default, 1.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; @@ -37,5 +42,9 @@ namespace CalamityMod.Projectiles.Typeless Main.dust[num448].velocity *= 0.1f; } } + + 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); } } diff --git a/Projectiles/Summon/AngelOrb.cs b/Projectiles/Summon/AngelOrb.cs new file mode 100644 index 0000000000..feae94e766 --- /dev/null +++ b/Projectiles/Summon/AngelOrb.cs @@ -0,0 +1,42 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class AngelOrb : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Orb"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.timeLeft = 30; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + + public override void AI() + { + CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 150f, 6f, 6f, 2, ModContent.ProjectileType(), 1D, true); + } + + 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); + } +} diff --git a/Projectiles/Typeless/CirrusRay.cs b/Projectiles/Summon/AngelRay.cs similarity index 67% rename from Projectiles/Typeless/CirrusRay.cs rename to Projectiles/Summon/AngelRay.cs index 9ade156435..a01c7fe624 100644 --- a/Projectiles/Typeless/CirrusRay.cs +++ b/Projectiles/Summon/AngelRay.cs @@ -1,15 +1,19 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Typeless +namespace CalamityMod.Projectiles.Summon { - public class CirrusRay : ModProjectile + public class AngelRay : ModProjectile { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetStaticDefaults() { DisplayName.SetDefault("Ray"); + ProjectileID.Sets.MinionShot[projectile.type] = true; } public override void SetDefaults() @@ -17,14 +21,15 @@ namespace CalamityMod.Projectiles.Typeless projectile.width = 4; projectile.height = 4; projectile.friendly = true; - projectile.magic = true; - projectile.penetrate = 5; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.ignoreWater = true; + projectile.penetrate = 10; projectile.extraUpdates = 100; - projectile.timeLeft = 300; + projectile.timeLeft = 600; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; - projectile.npcProj = true; - } + } public override void AI() { @@ -32,13 +37,13 @@ namespace CalamityMod.Projectiles.Typeless projectile.ai[0] += 1f; if (projectile.ai[0] % 6f == 0f && 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); } if (projectile.ai[0] > 16f && projectile.ai[0] % 2f == 0f) { Vector2 source = projectile.position; - int pink = Dust.NewDust(source, 1, 1, 234, 0f, 0f, 0, default, 1.25f); + 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; @@ -67,5 +72,9 @@ namespace CalamityMod.Projectiles.Typeless } return false; } + + 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); } } diff --git a/Projectiles/Summon/AngelicAllianceArchangel.cs b/Projectiles/Summon/AngelicAllianceArchangel.cs new file mode 100644 index 0000000000..1540e0903b --- /dev/null +++ b/Projectiles/Summon/AngelicAllianceArchangel.cs @@ -0,0 +1,168 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class AngelicAllianceArchangel : ModProjectile + { + private int lifeSpan = 900; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Archangel"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 60; + projectile.height = 68; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.extraUpdates = 1; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(lifeSpan); + + public override void ReceiveExtraAI(BinaryReader reader) => lifeSpan = reader.ReadInt32(); + + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + + if (!modPlayer.divineBless || player.dead || !player.active) + { + lifeSpan = 0; + } + + // Initialization and dust + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + for (int i = 0; i < 10; i++) + { + Dust.NewDust(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + } + 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; + } + + // Rotate around the player + double deg = projectile.ai[1]; + double rad = deg * (Math.PI / 180); + double dist = 300; + 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; + + if (!projectile.FinalExtraUpdate()) + return; + + lifeSpan--; + if (lifeSpan <= 0) + { + projectile.alpha += 30; + if (projectile.alpha >= 255) + { + projectile.Kill(); + return; + } + } + + // 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); + + // 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, type, projectile.damage, projectile.knockBack, projectile.owner); + } + projectile.ai[0] = 0f; + projectile.netUpdate = true; + } + } + 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 + projectile.frameCounter++; + if (projectile.frameCounter > 7) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Texture2D texture = Main.projectileTexture[projectile.type]; + int frameHeight = texture.Height / Main.projFrames[projectile.type]; + int frameY = frameHeight * projectile.frame; + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameY, 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 CanDamage() => false; + } +} diff --git a/Projectiles/Summon/AngelicAllianceArchangel.png b/Projectiles/Summon/AngelicAllianceArchangel.png new file mode 100644 index 0000000000..664d3841f7 Binary files /dev/null and b/Projectiles/Summon/AngelicAllianceArchangel.png differ diff --git a/Projectiles/Summon/AstrageldonSummon.cs b/Projectiles/Summon/AstrageldonSummon.cs index ed3133c78e..07996c0071 100644 --- a/Projectiles/Summon/AstrageldonSummon.cs +++ b/Projectiles/Summon/AstrageldonSummon.cs @@ -221,14 +221,7 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { diff --git a/Projectiles/Summon/AureusBomber.cs b/Projectiles/Summon/AureusBomber.cs index 3be260cc68..d2a4885906 100644 --- a/Projectiles/Summon/AureusBomber.cs +++ b/Projectiles/Summon/AureusBomber.cs @@ -262,12 +262,9 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - return 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 7a46e4f780..fa9e73016c 100644 --- a/Projectiles/Summon/BabyBloodCrawler.cs +++ b/Projectiles/Summon/BabyBloodCrawler.cs @@ -100,16 +100,9 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return 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; diff --git a/Projectiles/Summon/BrimstoneDartSummon.cs b/Projectiles/Summon/BrimstoneDartSummon.cs new file mode 100644 index 0000000000..4c234ceeba --- /dev/null +++ b/Projectiles/Summon/BrimstoneDartSummon.cs @@ -0,0 +1,80 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class BrimstoneDartSummon : ModProjectile + { + 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.TrailCacheLength[projectile.type] = 2; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.penetrate = 1; + projectile.timeLeft = 120; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + } + + public override void AI() + { + if (projectile.velocity.Length() < 21f) + projectile.velocity *= 1.02f; + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + + 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); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void Kill(int timeLeft) + { + if (Main.dedServ) + return; + + for (int i = 0; i < 15; i++) + { + Dust brimstone = Dust.NewDustPerfect(projectile.Center, 267); + brimstone.velocity = projectile.velocity.RotatedByRandom(0.26f) * Main.rand.NextFloat(0.3f, 0.8f); + brimstone.scale = Main.rand.NextFloat(1.5f, 1.85f); + brimstone.color = Color.DarkRed; + brimstone.noGravity = true; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + lightColor.R = (byte)(255 * projectile.Opacity); + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Summon/Cinder.cs b/Projectiles/Summon/Cinder.cs index 60325cd923..11c74f713b 100644 --- a/Projectiles/Summon/Cinder.cs +++ b/Projectiles/Summon/Cinder.cs @@ -89,13 +89,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CorroslimeMinion.cs b/Projectiles/Summon/CorroslimeMinion.cs index 1a634da6ab..3b1c0b2dce 100644 --- a/Projectiles/Summon/CorroslimeMinion.cs +++ b/Projectiles/Summon/CorroslimeMinion.cs @@ -97,13 +97,6 @@ namespace CalamityMod.Projectiles.Summon return false; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CorruptionSlimeGodMinion.cs b/Projectiles/Summon/CorruptionSlimeGodMinion.cs index 8048b833d3..ada310e94e 100644 --- a/Projectiles/Summon/CorruptionSlimeGodMinion.cs +++ b/Projectiles/Summon/CorruptionSlimeGodMinion.cs @@ -91,13 +91,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CrimslimeMinion.cs b/Projectiles/Summon/CrimslimeMinion.cs index 97de782c29..c08d48f1bc 100644 --- a/Projectiles/Summon/CrimslimeMinion.cs +++ b/Projectiles/Summon/CrimslimeMinion.cs @@ -97,13 +97,6 @@ namespace CalamityMod.Projectiles.Summon return false; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/CrimsonSlimeGodMinion.cs b/Projectiles/Summon/CrimsonSlimeGodMinion.cs index fac39b6bf0..f3b9591cd3 100644 --- a/Projectiles/Summon/CrimsonSlimeGodMinion.cs +++ b/Projectiles/Summon/CrimsonSlimeGodMinion.cs @@ -91,13 +91,6 @@ namespace CalamityMod.Projectiles.Summon } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/DaedalusGolem.cs b/Projectiles/Summon/DaedalusGolem.cs new file mode 100644 index 0000000000..ef481613a1 --- /dev/null +++ b/Projectiles/Summon/DaedalusGolem.cs @@ -0,0 +1,318 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.World.Generation; + +namespace CalamityMod.Projectiles.Summon +{ + public class DaedalusGolem : ModProjectile + { + public int AttackTimer; + public bool UsingChargedLaserAttack; + public const int ChargedPelletAttackTime = 30; + public const int ChargedLaserAttackTime = 120; + public const float Gravity = 0.35f; + public bool Stuck => StuckWalkThroughWallsTimer >= 40f || Collision.SolidCollision(projectile.Center, 2, 2); + public Vector2 ArmPosition => projectile.Center + new Vector2(projectile.spriteDirection == 1 ? -4f : 32f, 0f); + public Player Owner => Main.player[projectile.owner]; + public ref float StuckWalkThroughWallsTimer => ref projectile.ai[0]; + public ref float StuckJumpSpeed => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Daedalus Golem"); + Main.projFrames[projectile.type] = 18; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 28; + projectile.height = 58; + projectile.netImportant = true; + projectile.friendly = true; + projectile.minionSlots = 1; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.minion = true; + projectile.tileCollide = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(AttackTimer); + writer.Write(UsingChargedLaserAttack); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + AttackTimer = reader.ReadInt32(); + UsingChargedLaserAttack = reader.ReadBoolean(); + } + + #region AI + public override void AI() + { + Main.projFrames[projectile.type] = 16; + bool isCorrectProjectile = projectile.type == ModContent.ProjectileType(); + Owner.AddBuff(ModContent.BuffType(), 3600); + if (isCorrectProjectile) + { + if (Owner.dead) + Owner.Calamity().daedalusGolem = false; + + if (Owner.Calamity().daedalusGolem) + projectile.timeLeft = 2; + } + + AdjustMinionDamage(); + + // Fall down. + if (projectile.velocity.Y < 15f) + projectile.velocity.Y += Gravity; + + Vector2 destination; + NPC potentialTarget = projectile.Center.MinionHoming(900f, Owner); + if (potentialTarget is null) + destination = Owner.Center + Vector2.UnitX * (80f + (projectile.identity * 28f) % 560f); + else + destination = potentialTarget.Center + Vector2.UnitX * (130f + (projectile.identity * 28f) % 560f); + + // 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. + try + { + Vector2 upwardCheck = destination - Vector2.UnitY * 2400f; + upwardCheck.Y = Utils.Clamp(upwardCheck.Y, 0f, Main.maxTilesY * 16f - 100f); + WorldUtils.Find(upwardCheck.ToTileCoordinates(), Searches.Chain(new Searches.Down(200), new Conditions.IsSolid()), out Point loweredPoint); + destination = loweredPoint.ToWorldCoordinates(); + } + catch (NullReferenceException) { } + + 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; + } + + if (AttackTimer >= (UsingChargedLaserAttack ? ChargedLaserAttackTime : ChargedPelletAttackTime)) + { + AttackTimer = 0; + projectile.netUpdate = true; + } + + if (MathHelper.Distance(potentialTarget.Center.X, projectile.Center.X) > 30f) + projectile.spriteDirection = (potentialTarget.Center.X - projectile.Center.X < 0).ToDirectionInt(); + + if (UsingChargedLaserAttack) + { + if (AttackTimer >= 45 && AttackTimer < ChargedLaserAttackTime / 2 && !Main.dedServ) + { + Vector2 drawOffset = Main.rand.NextVector2CircularEdge(12f, 12f); + Dust light = Dust.NewDustPerfect(ArmPosition + drawOffset, 261); + light.velocity = drawOffset.SafeNormalize(Vector2.Zero) * -2.5f; + light.color = Color.Lerp(Color.HotPink, Color.LightPink, Main.rand.NextFloat()); + light.scale = Main.rand.NextFloat(1.2f, 1.45f); + light.noGravity = true; + } + else if (AttackTimer >= ChargedLaserAttackTime / 2 && AttackTimer <= ChargedLaserAttackTime / 2 + 60 && AttackTimer % 10 == 9) + { + Main.PlaySound(SoundID.Item122, ArmPosition); + if (Main.myPlayer == projectile.owner) + { + Vector2 initialVelocity = projectile.SafeDirectionTo(potentialTarget.Center) * 2f; + if (Main.rand.NextBool(2)) + initialVelocity = initialVelocity.RotatedByRandom(0.4f); + float initialAngle = initialVelocity.ToRotation(); + Projectile.NewProjectile(ArmPosition, initialVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, initialAngle, Main.rand.Next(100)); + } + } + } + else if (!UsingChargedLaserAttack && AttackTimer == ChargedPelletAttackTime / 2 && Main.myPlayer == projectile.owner) + { + Vector2 initialVelocity = projectile.SafeDirectionTo(potentialTarget.Center + potentialTarget.velocity * 15f) * 19f; + Projectile.NewProjectile(ArmPosition, initialVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + } + else if (potentialTarget is null && AttackTimer != 0) + { + AttackTimer = 0; + projectile.netUpdate = true; + } + } + + public void AdjustMinionDamage() + { + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.localAI[0] += 1f; + } + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int newDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + Owner.MinionDamage()); + projectile.damage = newDamage; + } + } + + public bool MoveToDestination(Vector2 destination) + { + Tile tileBelow = CalamityUtils.ParanoidTileRetrieval((int)(projectile.Bottom.X / 16), (int)(projectile.Bottom.Y / 16) + 1); + + // Float to the destination if stuck. + if (Stuck) + { + StuckJumpSpeed = 0f; + projectile.tileCollide = false; + + if (projectile.DistanceSQ(destination - Vector2.UnitY * 16f) > 10f * 10f) + projectile.velocity = projectile.SafeDirectionTo(destination - Vector2.UnitY * 16f) * 6f; + else + StuckWalkThroughWallsTimer = 0; + + StuckWalkThroughWallsTimer -= 4; + return false; + } + + projectile.tileCollide = true; + // Don't bother moving any more if super close to the destination. + // Just slow down and face the player. + if (Math.Abs(projectile.Center.X - destination.X) < 55 + Math.Abs(projectile.velocity.X)) + { + StuckJumpSpeed = 0f; + projectile.velocity.X *= 0.8f; + return true; + } + + int currentWalkDirection = Math.Sign(projectile.velocity.X); + int tilesSearchedAhead = 0; + + Tile tileBelowAhead; + + do + { + tileBelowAhead = CalamityUtils.ParanoidTileRetrieval((int)(projectile.Bottom.X / 16) + currentWalkDirection, (int)(projectile.Bottom.Y / 16) + 1); + + if (tileBelowAhead.IsTileSolidGround()) + break; + + tilesSearchedAhead++; + } + while (tilesSearchedAhead < 4); + + int directionToWalk = Math.Sign(destination.X - projectile.Center.X); + float idealWalkSpeed = 10f * directionToWalk; + float walkAcceleration = directionToWalk != currentWalkDirection ? 0.325f : 0.2f; + projectile.velocity.X = MathHelper.Lerp(projectile.velocity.X, idealWalkSpeed, walkAcceleration); + + // Jump if there's a gap or a wall. + if (tileBelow.IsTileSolidGround() || Collision.SolidCollision(projectile.Center, 10, 10)) + { + if (Math.Abs(projectile.oldPosition.X - projectile.position.X) < 2f || + Collision.SolidCollision(projectile.Center, 2, 2) || + !Collision.CanHitLine(projectile.position, projectile.width, projectile.height, Owner.position, Owner.width, Owner.height)) + { + projectile.velocity.Y = -12f - StuckJumpSpeed; + projectile.netSpam -= 10; + StuckJumpSpeed += 3.5f; + StuckJumpSpeed = Utils.Clamp(StuckJumpSpeed, 0f, 14f); + + StuckWalkThroughWallsTimer += 10f; + + projectile.netUpdate = true; + } + else if (tilesSearchedAhead > 0) + { + projectile.velocity.X = 7f; + + projectile.velocity.Y = -(5f + tilesSearchedAhead * 2f); + projectile.netSpam -= 10; + projectile.netUpdate = true; + } + else + { + StuckJumpSpeed = 0f; + StuckWalkThroughWallsTimer -= 5f; + } + } + + projectile.spriteDirection = (Owner.Center.X - projectile.Center.X < 0).ToDirectionInt(); + return false; + } + #endregion + + // Prevent on-tile collision death. + public override bool OnTileCollide(Vector2 oldVelocity) => 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 void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + int startingWalkFrame = 6; + int endingWalkFrame = 10; + + int startingPelletFrame = 1; + int endingPelletFrame = 4; + + int startingBeamFrame = 11; + int endingBeamFrame = 15; + + // Walking frames. Moves more quickly the faster the walk. + projectile.frameCounter++; + Tile tileBelow = CalamityUtils.ParanoidTileRetrieval((int)(projectile.Bottom.X / 16), (int)(projectile.Bottom.Y / 16) + 1); + + if (Stuck) + { + projectile.frame = 5; + } + else if (AttackTimer > 0) + { + if (UsingChargedLaserAttack) + projectile.frame = (int)MathHelper.Lerp(startingBeamFrame, endingBeamFrame + 1, Utils.InverseLerp(0f, ChargedLaserAttackTime, AttackTimer, true)); + 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; + } +} diff --git a/Projectiles/Summon/DaedalusGolem.png b/Projectiles/Summon/DaedalusGolem.png new file mode 100644 index 0000000000..56ae471ca9 Binary files /dev/null and b/Projectiles/Summon/DaedalusGolem.png differ diff --git a/Projectiles/Summon/DaedalusLightning.cs b/Projectiles/Summon/DaedalusLightning.cs new file mode 100644 index 0000000000..056a522d17 --- /dev/null +++ b/Projectiles/Summon/DaedalusLightning.cs @@ -0,0 +1,150 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; +namespace CalamityMod.Projectiles.Summon +{ + 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 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; + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.minion = true; + projectile.alpha = 255; + projectile.penetrate = 2; + projectile.ignoreWater = true; + projectile.tileCollide = false; + 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; + } + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(AccumulatedXMovementSpeeds); + writer.Write(BranchingIteration); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + 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++; + + 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; + + 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(); + + // 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; + + // 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; + } + + // If the above checks were all passed, redefine the base direction of the lightning. + if (canChangeLightningDirection) + newBaseDirection = potentialBaseDirection; + + 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; + } + #endregion + } +} diff --git a/Projectiles/Summon/DaedalusLightning.png b/Projectiles/Summon/DaedalusLightning.png new file mode 100644 index 0000000000..f99e9c57d5 Binary files /dev/null and b/Projectiles/Summon/DaedalusLightning.png differ diff --git a/Projectiles/Summon/DaedalusPellet.cs b/Projectiles/Summon/DaedalusPellet.cs new file mode 100644 index 0000000000..99d908f1dd --- /dev/null +++ b/Projectiles/Summon/DaedalusPellet.cs @@ -0,0 +1,65 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class DaedalusPellet : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Pellet"); + Main.projFrames[projectile.type] = 3; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 5; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.minion = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.penetrate = 1; + projectile.timeLeft = 600; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -2; + } + + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + if (projectile.frame >= 3) + { + projectile.frame = 0; + } + projectile.frameCounter = 0; + } + if (projectile.ai[0] == 0f) + { + projectile.ai[0] = 1f; + Main.PlaySound(SoundID.DD2_SkyDragonsFuryShot, projectile.Center); + } + projectile.alpha = Utils.Clamp(projectile.alpha - 50, 0, 255); + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(255, 255, 255, projectile.alpha); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + } +} diff --git a/Projectiles/Summon/DaedalusPellet.png b/Projectiles/Summon/DaedalusPellet.png new file mode 100644 index 0000000000..b057abe312 Binary files /dev/null and b/Projectiles/Summon/DaedalusPellet.png differ diff --git a/Projectiles/Summon/DazzlingStabber.cs b/Projectiles/Summon/DazzlingStabber.cs index 62b6114e16..99c39730e1 100644 --- a/Projectiles/Summon/DazzlingStabber.cs +++ b/Projectiles/Summon/DazzlingStabber.cs @@ -100,18 +100,14 @@ namespace CalamityMod.Projectiles.Summon return; } - // Don't do anything if very close to the target. - if (projectile.WithinRange(target.Center, 60f)) - return; - // Reset the velocity to fly upward if there is very little motion to ensure // that the summon does not get stuck. - if (projectile.velocity.Length() < 1.6f) - projectile.velocity = Vector2.UnitY * 5f; + if (projectile.velocity.Length() < 3f) + projectile.velocity = Vector2.UnitY * -12f; // If close to the target, slow down dramatically. if (projectile.velocity.Length() > 5f && projectile.WithinRange(target.Center, 90f)) - projectile.velocity *= 0.8f; + projectile.velocity *= 0.93f; // Otherwise, if not close, speed up dramatically. else if (projectile.velocity.Length() < 40f) @@ -120,7 +116,8 @@ namespace CalamityMod.Projectiles.Summon float angularTurnSpeed = 0.35f; float angleToTargetCoords = projectile.AngleTo(target.Center); - projectile.velocity = projectile.velocity.ToRotation().AngleTowards(angleToTargetCoords, angularTurnSpeed).ToRotationVector2() * projectile.velocity.Length(); + if (!projectile.WithinRange(target.Center, 200f)) + projectile.velocity = projectile.velocity.ToRotation().AngleTowards(angleToTargetCoords, angularTurnSpeed).ToRotationVector2() * projectile.velocity.Length(); // If not super close to the target but the target is very much in the line of sight of the summon, charge. if (!projectile.WithinRange(target.Center, 75f) && Vector2.Dot(projectile.SafeDirectionTo(target.Center), projectile.velocity.SafeNormalize(Vector2.Zero)) > 0.85f) diff --git a/Projectiles/Summon/DeathstareBeam.cs b/Projectiles/Summon/DeathstareBeam.cs new file mode 100644 index 0000000000..e9804eb637 --- /dev/null +++ b/Projectiles/Summon/DeathstareBeam.cs @@ -0,0 +1,54 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class DeathstareBeam : ModProjectile + { + public ref float OwnerUUID => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + projectile.ignoreWater = true; + projectile.timeLeft = 10; + } + 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; + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D beamTexture = Main.projectileTexture[projectile.type]; + Vector2 drawPosition = projectile.Center + Vector2.UnitY * projectile.gfxOffY - Main.screenPosition; + Vector2 drawScale = new Vector2(0.55f, projectile.velocity.Length() / beamTexture.Height * 20f); + Color color = Color.White * 2.1f * projectile.Opacity; + + if (Math.Abs(projectile.rotation - MathHelper.PiOver2) > 0.008f) + spriteBatch.Draw(beamTexture, drawPosition, null, color, projectile.rotation, beamTexture.Frame().Bottom(), drawScale, SpriteEffects.None, 0f); + return false; + } + } +} diff --git a/Projectiles/Summon/DeathstareBeam.png b/Projectiles/Summon/DeathstareBeam.png new file mode 100644 index 0000000000..a47f130bae Binary files /dev/null and b/Projectiles/Summon/DeathstareBeam.png differ diff --git a/Projectiles/Summon/DeathstareEyePupil.png b/Projectiles/Summon/DeathstareEyePupil.png new file mode 100644 index 0000000000..ea9db1fb5d Binary files /dev/null and b/Projectiles/Summon/DeathstareEyePupil.png differ diff --git a/Projectiles/Summon/DeathstareEyeball.cs b/Projectiles/Summon/DeathstareEyeball.cs new file mode 100644 index 0000000000..3845740cb1 --- /dev/null +++ b/Projectiles/Summon/DeathstareEyeball.cs @@ -0,0 +1,181 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + 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; + public const int BeamFireRate = 60; + public Player Owner => Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[1]; + public ref float PupilAngle => ref projectile.localAI[0]; + public ref float PupilOutwardness => ref projectile.localAI[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eyeball"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.NeedsUUID[projectile.type] = true; + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + } + + #region AI + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.Blue.ToVector3()); + + bool isCorrectMinion = projectile.type == ModContent.ProjectileType(); + CalamityPlayer modPlayer = Owner.Calamity(); + Owner.AddBuff(ModContent.BuffType(), 3600); + + // Ensure that the projectile executing this code is a valid one. + if (isCorrectMinion) + { + if (Owner.dead) + modPlayer.deathstareEyeball = false; + if (modPlayer.deathstareEyeball) + projectile.timeLeft = 2; + } + + Vector2 destination = Owner.Center + Vector2.UnitY * (Owner.gfxOffY - 110f); + if (Owner.gravDir == -1f) + destination.Y += 220f; + + // Very quickly fly towards above (or below if gravity is reversed) the player. + projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.36f); + + projectile.position = projectile.position.Floor(); + projectile.rotation = (projectile.position.X - projectile.oldPosition.X) * 0.07f + Owner.velocity.X * 0.2f; + projectile.rotation = Utils.Clamp(projectile.rotation, -0.4f, 0.4f); + + if (projectile.localAI[0] == 0f) + { + Initialize(Owner); + projectile.localAI[0] = 1f; + } + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + Owner.MinionDamage()); + projectile.damage = trueDamage; + } + + NPC potentialTarget = projectile.Center.MinionHoming(720f, Owner); + + if (potentialTarget is null) + DoHoveringAI(); + else + DoAttackingAI(potentialTarget); + + projectile.frame = (int)(Time / 5) % 4; + + Time++; + } + + 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 + { + float idealOutwardness = MathHelper.Clamp(Owner.velocity.Length() * 0.5f, 0f, 5f); + float idealAngle = Owner.velocity.ToRotation(); + + 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); + Main.projectile[beam].Damage(); + } + PupilScale = 1.5f; + } + + // 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 + { + PupilScale = MathHelper.Lerp(PupilScale, 1f, 0.175f); + PupilAngle = PupilAngle.AngleTowards(projectile.AngleTo(target.Center), MathHelper.ToRadians(15f)); + } + } + + public void Initialize(Player player) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + + if (!Main.dedServ) + return; + + for (int i = 0; i < 25; i++) + { + Dust dust = Dust.NewDustDirect(projectile.position, 52, 52, DustID.Blood); + dust.noGravity = true; + dust.scale = Main.rand.NextFloat(1.2f, 1.5f); + } + } + + #endregion + + 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; + SpriteEffects spriteEffects = Owner.gravDir == 1 ? SpriteEffects.None : SpriteEffects.FlipVertically; + spriteBatch.Draw(eyeTexture, projectile.Center - Main.screenPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + + // Pupil drawing. + Texture2D pupilTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/DeathstareEyePupil"); + Vector2 pupilDrawPosition = projectile.Center - Main.screenPosition + PupilAngle.ToRotationVector2() * PupilOutwardness; + 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; + } +} diff --git a/Projectiles/Summon/DeathstareEyeball.png b/Projectiles/Summon/DeathstareEyeball.png new file mode 100644 index 0000000000..6825c3c664 Binary files /dev/null and b/Projectiles/Summon/DeathstareEyeball.png differ diff --git a/Projectiles/Summon/ElementalAxeMinion.cs b/Projectiles/Summon/ElementalAxeMinion.cs index d9600a6b7d..cb5dd7e234 100644 --- a/Projectiles/Summon/ElementalAxeMinion.cs +++ b/Projectiles/Summon/ElementalAxeMinion.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Summon/EndoCooperBody.cs b/Projectiles/Summon/EndoCooperBody.cs index 14a7a88eba..c9a37b48fc 100644 --- a/Projectiles/Summon/EndoCooperBody.cs +++ b/Projectiles/Summon/EndoCooperBody.cs @@ -352,8 +352,8 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 180); } diff --git a/Projectiles/Summon/EndoCooperLimbs.cs b/Projectiles/Summon/EndoCooperLimbs.cs index d288f47dca..3e95b267c3 100644 --- a/Projectiles/Summon/EndoCooperLimbs.cs +++ b/Projectiles/Summon/EndoCooperLimbs.cs @@ -150,8 +150,8 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 180); } diff --git a/Projectiles/Summon/EndoFire.cs b/Projectiles/Summon/EndoFire.cs index 9e6f9ecb9a..d88bab58f6 100644 --- a/Projectiles/Summon/EndoFire.cs +++ b/Projectiles/Summon/EndoFire.cs @@ -105,8 +105,8 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 180); } } diff --git a/Projectiles/Summon/EndoIceShard.cs b/Projectiles/Summon/EndoIceShard.cs index 87327db404..023186e28b 100644 --- a/Projectiles/Summon/EndoIceShard.cs +++ b/Projectiles/Summon/EndoIceShard.cs @@ -130,8 +130,8 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { - target.AddBuff(ModContent.BuffType(), 90); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 30); + target.AddBuff(ModContent.BuffType(), 60); target.AddBuff(BuffID.Frostburn, 180); } } diff --git a/Projectiles/Summon/EyeOfNightCell.cs b/Projectiles/Summon/EyeOfNightCell.cs new file mode 100644 index 0000000000..9c67226c3c --- /dev/null +++ b/Projectiles/Summon/EyeOfNightCell.cs @@ -0,0 +1,54 @@ +using CalamityMod.Dusts; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class EyeOfNightCell : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cell"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.friendly = true; + projectile.width = projectile.height = 10; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 180; + projectile.extraUpdates = 1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 19; + } + + public override void AI() + { + if (!Main.dedServ && projectile.velocity.Length() > 5f) + Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.SulfurousSeaAcid).noGravity = true; + + projectile.StickyProjAI(360); + } + public override void Kill(int timeLeft) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 60); + projectile.Damage(); + + if (!Main.dedServ) + for (int i = 0; i < 10; i++) + Dust.NewDustDirect(projectile.position, 36, 36, (int)CalamityDusts.SulfurousSeaAcid).noGravity = true; + } + + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) => projectile.ModifyHitNPCSticky(10, false); + + public override void OnHitNPC(NPC target, int damage, float knockback, 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/Summon/EyeOfNightCell.png b/Projectiles/Summon/EyeOfNightCell.png new file mode 100644 index 0000000000..99bc8669bf Binary files /dev/null and b/Projectiles/Summon/EyeOfNightCell.png differ diff --git a/Projectiles/Summon/EyeOfNightSummon.cs b/Projectiles/Summon/EyeOfNightSummon.cs new file mode 100644 index 0000000000..6af7ff3d56 --- /dev/null +++ b/Projectiles/Summon/EyeOfNightSummon.cs @@ -0,0 +1,136 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class EyeOfNightSummon : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float HoverTime => ref projectile.ai[0]; + + public const int ShootRate = 60; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Eye of Night"); + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + 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.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 19; + } + + public override void AI() + { + ProvidePlayerMinionBuffs(); + DynamicallyUpdateDamage(); + GenerateVisuals(); + NPC potentialTarget = projectile.Center.MinionHoming(750f, Owner); + if (potentialTarget is null) + FlyNearOwner(); + else + AttackTarget(potentialTarget); + } + + 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; + + if (Owner.dead) + Owner.Calamity().eyeOfNight = false; + if (Owner.Calamity().eyeOfNight) + projectile.timeLeft = 2; + } + + internal void DynamicallyUpdateDamage() + { + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.localAI[0] = 1f; + } + if (Owner.MinionDamage() == projectile.Calamity().spawnedPlayerMinionDamageValue) + return; + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * Owner.MinionDamage()); + projectile.damage = trueDamage; + } + + internal void GenerateVisuals() + { + // The 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.075f; + } + + internal void FlyNearOwner() + { + Vector2 destination = Owner.Top - Vector2.UnitY * 45f + (projectile.identity * 0.9f).ToRotationVector2() * 16f; + Vector2 idealVelocity = projectile.SafeDirectionTo(destination) * MathHelper.Lerp(2.3f, 8f, Utils.InverseLerp(16f, 160f, projectile.Distance(destination))); + if (projectile.velocity.Length() < 0.4f) + projectile.velocity = Vector2.UnitY.RotatedBy(Main.rand.NextFloat(0.5f, 1.1f) * Main.rand.NextBool(2).ToDirectionInt()) * -3.6f; + else if (!projectile.WithinRange(destination, 20f)) + projectile.velocity = projectile.velocity * 0.9f + idealVelocity * 0.1f; + + if (!projectile.WithinRange(Owner.Center, 1800f)) + { + projectile.Center = Owner.Center; + projectile.velocity = -Vector2.UnitY * 4f; + projectile.netUpdate = true; + } + + // Slow down a bit over time. + projectile.velocity *= 0.985f; + } + + internal void AttackTarget(NPC target) + { + if (Main.myPlayer == projectile.owner && HoverTime % 30 == 29) + { + Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(target.Center) * 8f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + HoverTime++; + } + + Vector2 destination = target.Center; + Vector2 destinationOffset = Vector2.Max(target.Size * 1.2f, Vector2.One * 90f).RotatedBy(projectile.identity * 0.96f + HoverTime / 15f); + + // Make the offset pulsate over time. + destinationOffset *= MathHelper.Lerp(0.7f, 1.3f, (float)Math.Cos(projectile.identity * 1.11f + HoverTime / 14f) * 0.5f + 0.5f); + + destinationOffset.Y += (float)Math.Sin(projectile.identity * 1.16f + HoverTime / 15f + MathHelper.PiOver2) * MathHelper.Min(target.height * 0.8f, 70f); + + destination += destinationOffset; + + // Fly towards the destination faster the farther the eye already is to it. + float flySpeed = MathHelper.Lerp(5f, 15f, Utils.InverseLerp(40f, 250f, projectile.Distance(destination), true)); + + if (projectile.WithinRange(destination, 24f + target.velocity.Length() * 2f)) + HoverTime++; + + projectile.velocity = (destination - projectile.Center).SafeNormalize(Vector2.Zero) * flySpeed; + } + } +} \ No newline at end of file diff --git a/Projectiles/Summon/EyeOfNightSummon.png b/Projectiles/Summon/EyeOfNightSummon.png new file mode 100644 index 0000000000..7caaf49286 Binary files /dev/null and b/Projectiles/Summon/EyeOfNightSummon.png differ diff --git a/Projectiles/Summon/FleshBallMinion.cs b/Projectiles/Summon/FleshBallMinion.cs new file mode 100644 index 0000000000..57dab5bbee --- /dev/null +++ b/Projectiles/Summon/FleshBallMinion.cs @@ -0,0 +1,164 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +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 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.tileCollide = false; + projectile.minion = true; + } + + public override void AI() + { + ProvidePlayerMinionBuffs(); + DetermineFrames(); + GenerateVisuals(); + + HopTimer++; + SufferFromSeparationAnxiety(); + NPC potentialTarget = projectile.Center.MinionHoming(950f, Owner); + if (potentialTarget is null) + GoNearOwner(); + else + AttackTarget(potentialTarget); + EnforceGravity(); + } + + 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; + + 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 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; + + 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; + } + + 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; + + 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; + } + } + + 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); + + // Release a bunch of blood. + if (Main.myPlayer == projectile.owner) + { + for (int i = 0; i < Main.rand.Next(1, 4 + 1); 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); + if (Main.projectile.IndexInRange(blood)) + { + Main.projectile[blood].Calamity().forceMinion = true; + Main.projectile[blood].penetrate = 1; + } + } + } + + // 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; + } + + 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/FleshBallMinion.png b/Projectiles/Summon/FleshBallMinion.png new file mode 100644 index 0000000000..955f105050 Binary files /dev/null and b/Projectiles/Summon/FleshBallMinion.png differ diff --git a/Projectiles/Summon/FlowersOfMortalityCore.png b/Projectiles/Summon/FlowersOfMortalityCore.png new file mode 100644 index 0000000000..8e10fb5b09 Binary files /dev/null and b/Projectiles/Summon/FlowersOfMortalityCore.png differ diff --git a/Projectiles/Summon/FlowersOfMortalityPetal.cs b/Projectiles/Summon/FlowersOfMortalityPetal.cs new file mode 100644 index 0000000000..b743c1018e --- /dev/null +++ b/Projectiles/Summon/FlowersOfMortalityPetal.cs @@ -0,0 +1,106 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class FlowersOfMortalityPetal : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float OffsetAngle => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public float Hue => OffsetAngle % MathHelper.TwoPi / MathHelper.TwoPi % 1f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Elemental Petal"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + 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 = 0.5f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 4; + } + + public override void AI() + { + bool isCorrectMinion = projectile.type == ModContent.ProjectileType(); + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + player.AddBuff(ModContent.BuffType(), 3600); + if (isCorrectMinion) + { + if (player.dead) + modPlayer.flowersOfMortality = false; + if (modPlayer.flowersOfMortality) + projectile.timeLeft = 2; + } + + SetProjectileDamage(); + + Time++; + NPC potentialTarget = projectile.Center.MinionHoming(1050f, Owner, false); + if (Time % 25 == 24 && Main.myPlayer == projectile.owner && potentialTarget != null) + { + Vector2 shootVelocity = projectile.SafeDirectionTo(potentialTarget.Center) * 10f; + Projectile.NewProjectile(projectile.Center, shootVelocity, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack, projectile.owner); + } + projectile.Center = player.Center + OffsetAngle.ToRotationVector2() * (150f + (float)Math.Sin(Time * 0.08f) * 15f); + projectile.rotation += MathHelper.ToRadians(7f); + OffsetAngle += MathHelper.ToRadians(6f); + } + + public void SetProjectileDamage() + { + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + for (int i = 0; i < 36; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, 261); + dust.noGravity = true; + dust.color = Main.hslToRgb(Main.rand.NextFloat(), 1f, 0.5f); + dust.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 7f); + } + projectile.localAI[0] += 1f; + } + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + Owner.MinionDamage()); + projectile.damage = trueDamage; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D petalTexture = Main.projectileTexture[projectile.type]; + Texture2D coreTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/FlowersOfMortalityCore"); + Color drawColor = Main.hslToRgb(Hue, 0.95f, 0.5f) * 2.3f; + + Vector2 drawPosition = projectile.Center - Main.screenPosition; + spriteBatch.Draw(petalTexture, drawPosition, null, projectile.GetAlpha(drawColor), projectile.rotation, petalTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + spriteBatch.Draw(coreTexture, drawPosition, null, projectile.GetAlpha(lightColor), 0f, coreTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + + return false; + } + } +} diff --git a/Projectiles/Summon/FlowersOfMortalityPetal.png b/Projectiles/Summon/FlowersOfMortalityPetal.png new file mode 100644 index 0000000000..a32bdc4d1e Binary files /dev/null and b/Projectiles/Summon/FlowersOfMortalityPetal.png differ diff --git a/Projectiles/Summon/GammaHead.cs b/Projectiles/Summon/GammaHead.cs index 726153072c..d989b40b4b 100644 --- a/Projectiles/Summon/GammaHead.cs +++ b/Projectiles/Summon/GammaHead.cs @@ -142,7 +142,7 @@ namespace CalamityMod.Projectiles.Summon projectile.frame %= Main.projFrames[projectile.type]; Vector2 spawnPosition = projectile.Center; - float shootSpeed = MathHelper.Lerp(8f, 20f, Utils.InverseLerp(90f, 850f, target.Distance(spawnPosition), true)); + float shootSpeed = MathHelper.Lerp(8f, 29f, Utils.InverseLerp(90f, 850f, target.Distance(spawnPosition), true)); Vector2 shootVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(spawnPosition, target.Center, GammaCanister.Gravity, shootSpeed, projectile.SafeDirectionTo(target.Center)); float fireAngle = shootVelocity.ToRotation(); diff --git a/Projectiles/Summon/GhostlyMine.cs b/Projectiles/Summon/GhostlyMine.cs index 36a671fddb..1a4ab6437e 100644 --- a/Projectiles/Summon/GhostlyMine.cs +++ b/Projectiles/Summon/GhostlyMine.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Projectiles.Summon double dist = 550; 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; //1f + projectile.ai[1] += 1f; if (spawnDust) { for (int num621 = 0; num621 < 10; num621++) diff --git a/Projectiles/Summon/GiantIbanRobotOfDoom.cs b/Projectiles/Summon/GiantIbanRobotOfDoom.cs index 3ae46abad2..0d3bbca0cf 100644 --- a/Projectiles/Summon/GiantIbanRobotOfDoom.cs +++ b/Projectiles/Summon/GiantIbanRobotOfDoom.cs @@ -50,9 +50,9 @@ namespace CalamityMod.Projectiles.Summon /// This cooldown is set in /// public int LaserCooldown = 0; - public const int LaserBaseDamage = 21000; - public const int RegicideBaseDamageSmall = 9487; - public const int RegicideBaseDamageLarge = 26000; + public const int LaserBaseDamage = 4200; + public const int RegicideBaseDamageSmall = 1897; + public const int RegicideBaseDamageLarge = 5200; public override void SetStaticDefaults() { diff --git a/Projectiles/Summon/HauntedDishes.cs b/Projectiles/Summon/HauntedDishes.cs index be6cdc1ad3..b1608eb3f9 100644 --- a/Projectiles/Summon/HauntedDishes.cs +++ b/Projectiles/Summon/HauntedDishes.cs @@ -590,12 +590,9 @@ namespace CalamityMod.Projectiles.Summon return true; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - return false; - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; - public override void Kill(int timeLeft) + 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; diff --git a/Projectiles/Summon/HermitCrabMinion.cs b/Projectiles/Summon/HermitCrabMinion.cs index 58aa77bc25..b9501c9d4a 100644 --- a/Projectiles/Summon/HermitCrabMinion.cs +++ b/Projectiles/Summon/HermitCrabMinion.cs @@ -369,13 +369,6 @@ namespace CalamityMod.Projectiles.Summon return true; } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Summon/LostSoulGiant.cs b/Projectiles/Summon/LostSoulGiant.cs new file mode 100644 index 0000000000..b7caaff612 --- /dev/null +++ b/Projectiles/Summon/LostSoulGiant.cs @@ -0,0 +1,110 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class LostSoulGiant : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.scale = 0.8f; + projectile.width = projectile.height = 52; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() => DoSoulAI(projectile, ref Time); + + public static void DoSoulAI(Projectile projectile, ref float time) + { + if (time >= 15f) + { + NPC potentialTarget = projectile.Center.ClosestNPCAt(1800f, false); + if (potentialTarget != null) + HomeInOnTarget(projectile, potentialTarget); + } + + projectile.Opacity = Utils.InverseLerp(0f, 15f, time, true); + projectile.frameCounter++; + if (projectile.frameCounter % 5f == 4f) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + + projectile.rotation = projectile.velocity.ToRotation(); + projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); + if (projectile.spriteDirection == -1) + projectile.rotation += MathHelper.Pi; + + time++; + } + + public static void HomeInOnTarget(Projectile projectile, NPC target) + { + float speed = MathHelper.Lerp(11f, 21f, (float)Math.Sin(projectile.identity % 7f / 7f * MathHelper.TwoPi) * 0.5f + 0.5f); + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(target.Center) * speed, 0.075f); + } + + public override Color? GetAlpha(Color lightColor) + { + Color baseColor = Color.Lerp(Color.IndianRed, Color.DarkViolet, projectile.identity % 5f / 5f * 0.5f); + Color color = Color.Lerp(baseColor * 1.5f, baseColor, (float)Math.Cos(Main.GlobalTime * 2.7f) * 0.04f + 0.45f); + color.A = 0; + return color * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < projectile.oldPos.Length / 2; j++) + { + float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, projectile.oldPos.Length / 2, j, true), 2D); + Color drawColor = Color.Lerp(projectile.GetAlpha(lightColor), Color.White * projectile.Opacity, j / projectile.oldPos.Length) * fade; + Vector2 drawPosition = projectile.oldPos[j] + projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 1.5f - Main.screenPosition; + float rotation = projectile.oldRot[j]; + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + } + + return false; + } + + public override void Kill(int timeLeft) + { + // Play a wraith death sound. + Main.PlaySound(SoundID.NPCDeath52, projectile.Center); + + if (Main.dedServ) + return; + + for (int i = 0; i < 45; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(60f, 60f), 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(2f, 2f); + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = 1.45f; + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Summon/LostSoulGiant.png b/Projectiles/Summon/LostSoulGiant.png new file mode 100644 index 0000000000..3e0e4507b7 Binary files /dev/null and b/Projectiles/Summon/LostSoulGiant.png differ diff --git a/Projectiles/Summon/LostSoulGold.cs b/Projectiles/Summon/LostSoulGold.cs new file mode 100644 index 0000000000..bd21a7662f --- /dev/null +++ b/Projectiles/Summon/LostSoulGold.cs @@ -0,0 +1,81 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class LostSoulGold : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gold Soul"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 38; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() => LostSoulGiant.DoSoulAI(projectile, ref Time); + + public override Color? GetAlpha(Color lightColor) + { + Color baseColor = Color.Lerp(Color.DarkGoldenrod, Color.Gold, projectile.identity % 5f / 5f); + Color color = Color.Lerp(baseColor, Color.White, (float)Math.Cos(Main.GlobalTime * 2.7f) * 0.04f + 0.5f); + color.A = 127; + return color * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < projectile.oldPos.Length / 2; j++) + { + float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, projectile.oldPos.Length / 2, j, true), 2D); + Color drawColor = Color.Lerp(projectile.GetAlpha(lightColor), Color.White * projectile.Opacity, j / projectile.oldPos.Length) * fade; + Vector2 drawPosition = projectile.oldPos[j] + projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 0.8f - Main.screenPosition; + float rotation = projectile.oldRot[j]; + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + } + + return false; + } + + public override void Kill(int timeLeft) + { + // Play a wraith death sound. + Main.PlaySound(SoundID.NPCDeath52, projectile.Center); + + if (Main.dedServ) + return; + + for (int i = 0; i < 45; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(42f, 42f), 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(1.75f, 1.75f); + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = 1.45f; + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Summon/LostSoulGold.png b/Projectiles/Summon/LostSoulGold.png new file mode 100644 index 0000000000..ecffa8c8a3 Binary files /dev/null and b/Projectiles/Summon/LostSoulGold.png differ diff --git a/Projectiles/Summon/LostSoulLarge.cs b/Projectiles/Summon/LostSoulLarge.cs new file mode 100644 index 0000000000..204733a066 --- /dev/null +++ b/Projectiles/Summon/LostSoulLarge.cs @@ -0,0 +1,82 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class LostSoulLarge : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.scale = 0.75f; + projectile.width = projectile.height = 46; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() => LostSoulGiant.DoSoulAI(projectile, ref Time); + + public override Color? GetAlpha(Color lightColor) + { + Color baseColor = Color.Lerp(Color.Orange, Color.IndianRed, projectile.identity % 5f / 5f * 0.5f); + Color color = Color.Lerp(baseColor * 1.5f, baseColor, (float)Math.Cos(Main.GlobalTime * 2.7f) * 0.04f + 0.45f); + color.A = 0; + return color * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < projectile.oldPos.Length / 2; j++) + { + float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, projectile.oldPos.Length / 2, j, true), 2D); + Color drawColor = Color.Lerp(projectile.GetAlpha(lightColor), Color.White * projectile.Opacity, j / projectile.oldPos.Length) * fade; + Vector2 drawPosition = projectile.oldPos[j] + projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 1.25f - Main.screenPosition; + float rotation = projectile.oldRot[j]; + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + } + + return false; + } + + public override void Kill(int timeLeft) + { + // Play a wraith death sound. + Main.PlaySound(SoundID.NPCDeath52, projectile.Center); + + if (Main.dedServ) + return; + + for (int i = 0; i < 45; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(42f, 42f), 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(1.75f, 1.75f); + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = 1.45f; + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Summon/LostSoulLarge.png b/Projectiles/Summon/LostSoulLarge.png new file mode 100644 index 0000000000..06675010ab Binary files /dev/null and b/Projectiles/Summon/LostSoulLarge.png differ diff --git a/Projectiles/Summon/LostSoulSmall.cs b/Projectiles/Summon/LostSoulSmall.cs new file mode 100644 index 0000000000..0bc2e93403 --- /dev/null +++ b/Projectiles/Summon/LostSoulSmall.cs @@ -0,0 +1,81 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class LostSoulSmall : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Soul"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 38; + projectile.friendly = true; + projectile.penetrate = 1; + projectile.tileCollide = false; + projectile.magic = true; + projectile.ignoreWater = true; + } + + public override void AI() => LostSoulGiant.DoSoulAI(projectile, ref Time); + + public override Color? GetAlpha(Color lightColor) + { + Color baseColor = Color.Lerp(Color.Orange, Color.IndianRed, projectile.identity % 5f / 5f * 0.425f); + Color color = Color.Lerp(baseColor * 1.5f, baseColor, (float)Math.Cos(Main.GlobalTime * 2.7f) * 0.04f + 0.45f); + color.A = 0; + return color * projectile.Opacity; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects direction = projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Texture2D texture = Main.projectileTexture[projectile.type]; + Rectangle frame = texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + for (int i = 0; i < 4; i++) + { + for (int j = 0; j < projectile.oldPos.Length / 2; j++) + { + float fade = (float)Math.Pow(1f - Utils.InverseLerp(0f, projectile.oldPos.Length / 2, j, true), 2D); + Color drawColor = Color.Lerp(projectile.GetAlpha(lightColor), Color.White * projectile.Opacity, j / projectile.oldPos.Length) * fade; + Vector2 drawPosition = projectile.oldPos[j] + projectile.Size * 0.5f + (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 0.8f - Main.screenPosition; + float rotation = projectile.oldRot[j]; + + spriteBatch.Draw(texture, drawPosition, frame, drawColor, rotation, frame.Size() * 0.5f, projectile.scale, direction, 0f); + } + } + + return false; + } + + public override void Kill(int timeLeft) + { + // Play a wraith death sound. + Main.PlaySound(SoundID.NPCDeath52, projectile.Center); + + if (Main.dedServ) + return; + + for (int i = 0; i < 45; i++) + { + Dust ectoplasm = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(42f, 42f), 264); + ectoplasm.velocity = Main.rand.NextVector2Circular(1.75f, 1.75f); + ectoplasm.color = projectile.GetAlpha(Color.White); + ectoplasm.scale = 1.45f; + ectoplasm.noGravity = true; + ectoplasm.noLight = true; + } + } + } +} diff --git a/Projectiles/Summon/LostSoulSmall.png b/Projectiles/Summon/LostSoulSmall.png new file mode 100644 index 0000000000..f02bca1221 Binary files /dev/null and b/Projectiles/Summon/LostSoulSmall.png differ diff --git a/Projectiles/Summon/MagicAxe.cs b/Projectiles/Summon/MagicAxe.cs index fe68c143f5..7ce569fd1b 100644 --- a/Projectiles/Summon/MagicAxe.cs +++ b/Projectiles/Summon/MagicAxe.cs @@ -67,7 +67,7 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Summon public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), 120); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(BuffID.Frostburn, 120); target.AddBuff(ModContent.BuffType(), 120); target.AddBuff(ModContent.BuffType(), 120); } diff --git a/Projectiles/Summon/MidnightSunUFO.cs b/Projectiles/Summon/MidnightSunUFO.cs index e80e6b43e0..12c6f6f0ae 100644 --- a/Projectiles/Summon/MidnightSunUFO.cs +++ b/Projectiles/Summon/MidnightSunUFO.cs @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Summon Vector2 destination = potentialTarget.Center - new Vector2((float)Math.Cos(angle) * potentialTarget.width * 0.65f, 250f); projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.SafeDirectionTo(destination) * 24f, 0.03f); - if (projectile.ai[0] % 3f == 2f && potentialTarget.Top.Y > projectile.Bottom.Y) + if (projectile.ai[0] % 4f == 3f && potentialTarget.Top.Y > projectile.Bottom.Y) { Vector2 laserVelocity = projectile.SafeDirectionTo(potentialTarget.Center, Vector2.UnitY).RotatedByRandom(0.15f) * 25f; Projectile.NewProjectile(projectile.Bottom, laserVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); diff --git a/Projectiles/Summon/MiniGuardianAttack.cs b/Projectiles/Summon/MiniGuardianAttack.cs index 4a33a82d44..ad025c0a84 100644 --- a/Projectiles/Summon/MiniGuardianAttack.cs +++ b/Projectiles/Summon/MiniGuardianAttack.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -21,7 +22,7 @@ namespace CalamityMod.Projectiles.Summon (CalamityWorld.downedDoG ? 75f : 0f) + (CalamityWorld.downedYharon ? 75f : 0f) + (modPlayer.profanedCrystalBuffs ? 420f : 0f)); - projectile.damage = baseDamage == 0 ? 0 : (int)(baseDamage * player.MinionDamage()); + projectile.damage = baseDamage == 0 ? 0 : (int)(baseDamage * player.MinionDamage() * 0.7f); ai = type; if (baseDamage >= 420f) { @@ -98,8 +99,8 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; int num17 = 100; Vector2 vector3 = projectile.Center; - float num18 = Main.player[projectile.owner].Center.X - vector3.X; - float num19 = Main.player[projectile.owner].Center.Y - vector3.Y; + float num18 = player.Center.X - vector3.X; + float num19 = player.Center.Y - vector3.Y; num19 += (float)Main.rand.Next(-10, 21); num18 += (float)Main.rand.Next(-10, 21); num18 += (float)(60 * -(float)Main.player[projectile.owner].direction); @@ -107,8 +108,8 @@ namespace CalamityMod.Projectiles.Summon float num20 = (float)Math.Sqrt((double)(num18 * num18 + num19 * num19)); float num21 = 18f; - if (num20 < (float)num17 && Main.player[projectile.owner].velocity.Y == 0f && - projectile.position.Y + (float)projectile.height <= Main.player[projectile.owner].position.Y + (float)Main.player[projectile.owner].height && + if (num20 < (float)num17 && 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; @@ -119,8 +120,7 @@ namespace CalamityMod.Projectiles.Summon } if (num20 > 2000f) { - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.position = player.position; projectile.netUpdate = true; } if (num20 < 50f) @@ -148,34 +148,34 @@ namespace CalamityMod.Projectiles.Summon if (projectile.velocity.X < num18) { - projectile.velocity.X = projectile.velocity.X + num16; + projectile.velocity.X += num16; if (num16 > 0.05f && projectile.velocity.X < 0f) { - projectile.velocity.X = projectile.velocity.X + num16; + projectile.velocity.X += num16; } } if (projectile.velocity.X > num18) { - projectile.velocity.X = projectile.velocity.X - num16; + projectile.velocity.X -= num16; if (num16 > 0.05f && projectile.velocity.X > 0f) { - projectile.velocity.X = projectile.velocity.X - num16; + projectile.velocity.X -= num16; } } if (projectile.velocity.Y < num19) { - projectile.velocity.Y = projectile.velocity.Y + num16; + projectile.velocity.Y += num16; if (num16 > 0.05f && projectile.velocity.Y < 0f) { - projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; + projectile.velocity.Y += num16 * 2f; } } if (projectile.velocity.Y > num19) { - projectile.velocity.Y = projectile.velocity.Y - num16; + projectile.velocity.Y -= num16; if (num16 > 0.05f && projectile.velocity.Y > 0f) { - projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; + projectile.velocity.Y -= num16 * 2f; } } break; @@ -246,6 +246,7 @@ namespace CalamityMod.Projectiles.Summon projectile.active = false; return; } + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 3000f; @@ -253,9 +254,9 @@ namespace CalamityMod.Projectiles.Summon NPC ownerMinionAttackTargetNPC2 = projectile.OwnerMinionAttackTargetNPC; if (ownerMinionAttackTargetNPC2 != null && ownerMinionAttackTargetNPC2.CanBeChasedBy(projectile, false)) { - float num539 = ownerMinionAttackTargetNPC2.position.X + (float)(ownerMinionAttackTargetNPC2.width / 2); - float num540 = ownerMinionAttackTargetNPC2.position.Y + (float)(ownerMinionAttackTargetNPC2.height / 2); - float num541 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num539) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num540); + float num539 = ownerMinionAttackTargetNPC2.Center.X; + float num540 = ownerMinionAttackTargetNPC2.Center.Y; + float num541 = Math.Abs(projectile.Center.X - num539) + Math.Abs(projectile.Center.Y - num540); if (num541 < num537) { num537 = num541; @@ -271,9 +272,9 @@ namespace CalamityMod.Projectiles.Summon { if (Main.npc[num542].CanBeChasedBy(projectile, false)) { - float num543 = Main.npc[num542].position.X + (float)(Main.npc[num542].width / 2); - float num544 = Main.npc[num542].position.Y + (float)(Main.npc[num542].height / 2); - float num545 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num543) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num544); + float num543 = Main.npc[num542].Center.X; + float num544 = Main.npc[num542].Center.Y; + float num545 = Math.Abs(projectile.Center.X - num543) + Math.Abs(projectile.Center.Y - num544); if (num545 < num537) { num537 = num545; @@ -325,5 +326,17 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + 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); + } } } diff --git a/Projectiles/Summon/MiniGuardianDefense.cs b/Projectiles/Summon/MiniGuardianDefense.cs index a5854c42a5..c52bf43fbb 100644 --- a/Projectiles/Summon/MiniGuardianDefense.cs +++ b/Projectiles/Summon/MiniGuardianDefense.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -96,17 +97,17 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; int num17 = 100; Vector2 vector3 = projectile.Center; - float num18 = Main.player[projectile.owner].Center.X - vector3.X; - float num19 = Main.player[projectile.owner].Center.Y - vector3.Y; + float num18 = player.Center.X - vector3.X; + float num19 = player.Center.Y - vector3.Y; num19 += (float)Main.rand.Next(-10, 21); num18 += (float)Main.rand.Next(-10, 21); - num18 += (float)(60 * -(float)Main.player[projectile.owner].direction); + num18 += (float)(60 * -(float)player.direction); num19 -= 60f; float num20 = (float)Math.Sqrt((double)(num18 * num18 + num19 * num19)); float num21 = 18f; - if (num20 < (float)num17 && Main.player[projectile.owner].velocity.Y == 0f && - projectile.position.Y + (float)projectile.height <= Main.player[projectile.owner].position.Y + (float)Main.player[projectile.owner].height && + if (num20 < (float)num17 && 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; @@ -117,8 +118,7 @@ namespace CalamityMod.Projectiles.Summon } if (num20 > 2000f) { - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.position = player.position; projectile.netUpdate = true; } if (num20 < 50f) @@ -146,34 +146,34 @@ namespace CalamityMod.Projectiles.Summon if (projectile.velocity.X < num18) { - projectile.velocity.X = projectile.velocity.X + num16; + projectile.velocity.X += num16; if (num16 > 0.05f && projectile.velocity.X < 0f) { - projectile.velocity.X = projectile.velocity.X + num16; + projectile.velocity.X += num16; } } if (projectile.velocity.X > num18) { - projectile.velocity.X = projectile.velocity.X - num16; + projectile.velocity.X -= num16; if (num16 > 0.05f && projectile.velocity.X > 0f) { - projectile.velocity.X = projectile.velocity.X - num16; + projectile.velocity.X -= num16; } } if (projectile.velocity.Y < num19) { - projectile.velocity.Y = projectile.velocity.Y + num16; + projectile.velocity.Y += num16; if (num16 > 0.05f && projectile.velocity.Y < 0f) { - projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; + projectile.velocity.Y += num16 * 2f; } } if (projectile.velocity.Y > num19) { - projectile.velocity.Y = projectile.velocity.Y - num16; + projectile.velocity.Y -= num16; if (num16 > 0.05f && projectile.velocity.Y > 0f) { - projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; + projectile.velocity.Y -= num16 * 2f; } } break; @@ -244,6 +244,7 @@ namespace CalamityMod.Projectiles.Summon projectile.active = false; return; } + projectile.MinionAntiClump(); float num535 = projectile.position.X; float num536 = projectile.position.Y; float num537 = 3000f; @@ -251,9 +252,9 @@ namespace CalamityMod.Projectiles.Summon NPC ownerMinionAttackTargetNPC2 = projectile.OwnerMinionAttackTargetNPC; if (ownerMinionAttackTargetNPC2 != null && ownerMinionAttackTargetNPC2.CanBeChasedBy(projectile, false)) { - float num539 = ownerMinionAttackTargetNPC2.position.X + (float)(ownerMinionAttackTargetNPC2.width / 2); - float num540 = ownerMinionAttackTargetNPC2.position.Y + (float)(ownerMinionAttackTargetNPC2.height / 2); - float num541 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num539) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num540); + float num539 = ownerMinionAttackTargetNPC2.Center.X; + float num540 = ownerMinionAttackTargetNPC2.Center.Y; + float num541 = Math.Abs(projectile.Center.X - num539) + Math.Abs(projectile.Center.Y - num540); if (num541 < num537) { num537 = num541; @@ -269,9 +270,9 @@ namespace CalamityMod.Projectiles.Summon { if (Main.npc[num542].CanBeChasedBy(projectile, false)) { - float num543 = Main.npc[num542].position.X + (float)(Main.npc[num542].width / 2); - float num544 = Main.npc[num542].position.Y + (float)(Main.npc[num542].height / 2); - float num545 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num543) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num544); + float num543 = Main.npc[num542].Center.X; + float num544 = Main.npc[num542].Center.Y; + float num545 = Math.Abs(projectile.Center.X - num543) + Math.Abs(projectile.Center.Y - num544); if (num545 < num537) { num537 = num545; @@ -321,5 +322,17 @@ namespace CalamityMod.Projectiles.Summon projectile.frame = 0; } } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + 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); + } } } diff --git a/Projectiles/Summon/MiniGuardianHealer.cs b/Projectiles/Summon/MiniGuardianHealer.cs index 1ab9ca526e..35577702b1 100644 --- a/Projectiles/Summon/MiniGuardianHealer.cs +++ b/Projectiles/Summon/MiniGuardianHealer.cs @@ -57,13 +57,14 @@ namespace CalamityMod.Projectiles.Summon projectile.active = false; return; } + projectile.MinionAntiClump(); Player projOwner = Main.player[projectile.owner]; float num16 = 0.5f; projectile.tileCollide = false; int num17 = 100; - Vector2 vector3 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); - float num18 = projOwner.position.X + (float)(projOwner.width / 2) - vector3.X; - float num19 = projOwner.position.Y + (float)(projOwner.height / 2) - vector3.Y; + Vector2 vector3 = projectile.Center; + float num18 = projOwner.Center.X - vector3.X; + float num19 = projOwner.Center.Y - vector3.Y; num19 += (float)Main.rand.Next(-10, 21); num18 += (float)Main.rand.Next(-10, 21); num18 += (float)(60 * -(float)projOwner.direction); @@ -83,8 +84,7 @@ namespace CalamityMod.Projectiles.Summon } if (num20 > 2000f) { - projectile.position.X = Main.player[projectile.owner].Center.X - (float)(projectile.width / 2); - projectile.position.Y = Main.player[projectile.owner].Center.Y - (float)(projectile.height / 2); + projectile.position = projOwner.position; projectile.netUpdate = true; } if (num20 < 50f) @@ -112,46 +112,46 @@ namespace CalamityMod.Projectiles.Summon if (projectile.velocity.X < num18) { - projectile.velocity.X = projectile.velocity.X + num16; + projectile.velocity.X += num16; if (num16 > 0.05f && projectile.velocity.X < 0f) { - projectile.velocity.X = projectile.velocity.X + num16; + projectile.velocity.X += num16; } } if (projectile.velocity.X > num18) { - projectile.velocity.X = projectile.velocity.X - num16; + projectile.velocity.X -= num16; if (num16 > 0.05f && projectile.velocity.X > 0f) { - projectile.velocity.X = projectile.velocity.X - num16; + projectile.velocity.X -= num16; } } if (projectile.velocity.Y < num19) { - projectile.velocity.Y = projectile.velocity.Y + num16; + projectile.velocity.Y += num16; if (num16 > 0.05f && projectile.velocity.Y < 0f) { - projectile.velocity.Y = projectile.velocity.Y + num16 * 2f; + projectile.velocity.Y += num16 * 2f; } } if (projectile.velocity.Y > num19) { - projectile.velocity.Y = projectile.velocity.Y - num16; + projectile.velocity.Y -= num16; if (num16 > 0.05f && projectile.velocity.Y > 0f) { - projectile.velocity.Y = projectile.velocity.Y - num16 * 2f; + projectile.velocity.Y -= num16 * 2f; } } - if ((double)projectile.velocity.X > 0.25) + if (projectile.velocity.X > 0.25f) { projectile.direction = -1; } - else if ((double)projectile.velocity.X < -0.25) + else if (projectile.velocity.X < -0.25f) { projectile.direction = 1; } - if ((double)Math.Abs(projectile.velocity.X) > 0.2) + if (Math.Abs(projectile.velocity.X) > 0.2f) { projectile.spriteDirection = -projectile.direction; } diff --git a/Projectiles/Summon/MortalityBeam.cs b/Projectiles/Summon/MortalityBeam.cs new file mode 100644 index 0000000000..622f0b5b14 --- /dev/null +++ b/Projectiles/Summon/MortalityBeam.cs @@ -0,0 +1,79 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class MortalityBeam : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Beam"); + ProjectileID.Sets.TrailCacheLength[projectile.type] = 10; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 20; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = true; + projectile.minionSlots = 0f; + projectile.minion = true; + projectile.penetrate = 1; + projectile.timeLeft = 180; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.White.ToVector3()); + if (!Main.dedServ) + { + for (int i = -1; i <= 1; i += 2) + { + float offset = (float)Math.Sin(Time / 45f * MathHelper.TwoPi) * 10f * i; + Vector2 rotatedOffset = new Vector2(offset, 2f).RotatedBy(projectile.velocity.ToRotation() + MathHelper.PiOver2); + + Dust rainbowDust = Dust.NewDustPerfect(projectile.Center + rotatedOffset, 261); + rainbowDust.color = Main.hslToRgb(Main.rand.NextFloat(), 0.9f, 0.5f); + rainbowDust.velocity = Vector2.Zero; + rainbowDust.scale = 1.5f; + rainbowDust.noGravity = true; + } + } + + Time++; + NPC potentialTarget = projectile.Center.MinionHoming(1000f, Main.player[projectile.owner], false); + if (potentialTarget != null) + projectile.velocity = (projectile.velocity * 5f + projectile.SafeDirectionTo(potentialTarget.Center) * 13f) / 6f; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void Kill(int timeLeft) + { + if (Main.myPlayer == projectile.owner) + { + float redHue = Main.rgbToHsl(Color.Red).X; + float greenHue = Main.rgbToHsl(Color.SeaGreen).X; + float blueHue = Main.rgbToHsl(Color.Blue).X; + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2CircularEdge(10f, 10f); + Projectile bolt = Projectile.NewProjectileDirect(spawnPosition, Main.rand.NextVector2CircularEdge(9f, 9f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + bolt.localAI[0] = Utils.SelectRandom(Main.rand, redHue, greenHue, blueHue); + } + } + } +} diff --git a/Projectiles/Summon/MortalityBeam.png b/Projectiles/Summon/MortalityBeam.png new file mode 100644 index 0000000000..3c8f498e7b Binary files /dev/null and b/Projectiles/Summon/MortalityBeam.png differ diff --git a/Projectiles/Summon/MortalityBolt.cs b/Projectiles/Summon/MortalityBolt.cs new file mode 100644 index 0000000000..d0083cbc4e --- /dev/null +++ b/Projectiles/Summon/MortalityBolt.cs @@ -0,0 +1,66 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class MortalityBolt : ModProjectile + { + public Color ProjectileColor => Main.hslToRgb(projectile.localAI[0], 1f, 0.5f); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Bolt"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 20; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.minionSlots = 0f; + projectile.minion = true; + projectile.penetrate = 1; + projectile.timeLeft = 180; + } + + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.White.ToVector3()); + if (!Main.dedServ) + { + for (int i = 0; i < 4; i++) + { + Dust rainbowDust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(5f, 5f), 261); + rainbowDust.color = ProjectileColor; + rainbowDust.velocity += projectile.velocity; + rainbowDust.noGravity = true; + } + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + target.AddBuff(ModContent.BuffType(), 180); + } + + public override void Kill(int timeLeft) + { + if (!Main.dedServ) + { + for (int i = 0; i < 15; i++) + { + Dust rainbowDust = Dust.NewDustDirect(projectile.Center + Main.rand.NextVector2Circular(5f, 5f), 40, 40, 261); + rainbowDust.color = ProjectileColor; + rainbowDust.noGravity = true; + } + } + } + } +} diff --git a/Projectiles/Summon/MortalityBolt.png b/Projectiles/Summon/MortalityBolt.png new file mode 100644 index 0000000000..3c8f498e7b Binary files /dev/null and b/Projectiles/Summon/MortalityBolt.png differ diff --git a/Projectiles/Summon/PerditionBeacon.cs b/Projectiles/Summon/PerditionBeacon.cs new file mode 100644 index 0000000000..fdd5ec89b8 --- /dev/null +++ b/Projectiles/Summon/PerditionBeacon.cs @@ -0,0 +1,173 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; + +namespace CalamityMod.Projectiles.Summon +{ + public class PerditionBeacon : ModProjectile + { + public ref float AttackTime => ref projectile.ai[0]; + public ref float AttackTimer => ref projectile.ai[1]; + public ref float DownwardCrossFade => ref projectile.localAI[1]; + public Player Owner => Main.player[projectile.owner]; + + // Only attack targets if one is explicitly defined. Don't default to a closest target. + public NPC Target => Owner.HasMinionAttackTargetNPC ? Main.npc[Owner.MinionAttackTargetNPC] : null; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Perdition Beacon"); + Main.projFrames[projectile.type] = 16; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 48; + projectile.height = 90; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.sentry = true; + projectile.light = 1f; + projectile.timeLeft = Projectile.SentryLifeTime; + projectile.penetrate = -1; + projectile.alpha = 255; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + + if (projectile.localAI[0] == 0f) + { + DoInitializationEffects(); + projectile.localAI[0] = 1f; + } + + // Dynamically adjust damage of the minion. + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int newDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * player.MinionDamage()); + projectile.damage = newDamage; + } + + // Fade in. + projectile.alpha = Utils.Clamp(projectile.alpha - 8, 0, 255); + + HandleFrames(); + FollowOwner(); + ProvidePlayerMinionBuffs(); + if (Target != null && projectile.WithinRange(Target.Center, 2200f)) + { + AttackTarget(); + DownwardCrossFade = MathHelper.Clamp(DownwardCrossFade + 0.025f, 0f, 1f); + AttackTime++; + } + else + { + DownwardCrossFade = MathHelper.Clamp(DownwardCrossFade - 0.025f, 0f, 1f); + AttackTime = 0f; + } + + AttackTime++; + } + + internal void DoInitializationEffects() + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + + // Release a burst of fire dust on spawn. + if (Main.dedServ) + return; + + for (int i = 0; i < 55; i++) + { + Dust fire = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(35f, 35f), 267); + fire.velocity = Vector2.Lerp(fire.velocity, Vector2.UnitY * -Main.rand.NextFloat(3.5f, 6f), 0.5f); + fire.color = Color.Lerp(Color.Orange, Color.Red, Main.rand.NextFloat(0f, 0.67f)); + fire.scale = Main.rand.NextFloat(1.2f, 1.5f); + fire.noGravity = true; + } + } + + 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; + + if (Owner.dead) + Owner.Calamity().perditionBeacon = false; + if (Owner.Calamity().perditionBeacon) + projectile.timeLeft = 2; + } + + internal void HandleFrames() + { + projectile.frameCounter++; + if (projectile.frameCounter % 5 == 4) + projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; + } + + internal void FollowOwner() + { + Vector2 destination = Owner.Top - Vector2.UnitY * MathHelper.Lerp(20f, 40f, (float)Math.Cos(projectile.timeLeft / 24f) * 0.5f + 0.5f); + projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.025f); + projectile.Center += (destination - projectile.Center).SafeNormalize(Vector2.Zero) * 3f; + + if (projectile.WithinRange(destination, 5f) || !projectile.WithinRange(destination, 2200f)) + projectile.Center = destination; + } + + internal void AttackTarget() + { + // Release cinders around the target. + Dust cinder = Dust.NewDustPerfect(Target.Center + Main.rand.NextVector2Circular(800f, 800f), DustID.Fire); + cinder.velocity = Vector2.UnitY * -Main.rand.NextFloat(3f, 7f); + cinder.scale = 1f + cinder.velocity.Length() * 0.17f; + cinder.noGravity = true; + + int shootRate = (int)MathHelper.Lerp(24f, 3f, Utils.InverseLerp(0f, 300f, AttackTime, true)); + AttackTimer++; + + if (AttackTimer < shootRate || Main.myPlayer != projectile.owner) + return; + + AttackTimer = 0f; + projectile.netUpdate = true; + + WeightedRandom rng = new WeightedRandom(projectile.identity * 2167 + (int)(Main.GlobalTime * 20)); + rng.Add(ModContent.ProjectileType(), 0.5f); + rng.Add(ModContent.ProjectileType(), 0.6f); + rng.Add(ModContent.ProjectileType(), 0.8f); + rng.Add(ModContent.ProjectileType(), 1f); + + Vector2 spawnPosition = Target.Center + Vector2.UnitY.RotatedByRandom(0.27f) * 1150f; + Vector2 shootVelocity = (Target.Center - spawnPosition).SafeNormalize(-Vector2.UnitY).RotatedByRandom(0.09f) * Main.rand.NextFloat(19f, 31f); + Projectile.NewProjectile(spawnPosition, shootVelocity, rng.Get(), projectile.damage, projectile.knockBack, projectile.owner); + } + + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (Target is null) + return; + + Texture2D crossTexture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/PerditionCross"); + + Vector2 drawPosition = Target.Bottom - Main.screenPosition; + drawPosition.Y -= 12f; + Color drawColor = Color.White * DownwardCrossFade; + spriteBatch.Draw(crossTexture, drawPosition, null, drawColor, projectile.rotation, crossTexture.Size() * 0.5f, projectile.scale * 0.85f, SpriteEffects.None, 0f); + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Summon/PerditionBeacon.png b/Projectiles/Summon/PerditionBeacon.png new file mode 100644 index 0000000000..daa5e3f58f Binary files /dev/null and b/Projectiles/Summon/PerditionBeacon.png differ diff --git a/Projectiles/Summon/PerditionCross.png b/Projectiles/Summon/PerditionCross.png new file mode 100644 index 0000000000..e7441f8d10 Binary files /dev/null and b/Projectiles/Summon/PerditionCross.png differ diff --git a/Projectiles/Summon/PolypLauncherProjectile.cs b/Projectiles/Summon/PolypLauncherProjectile.cs new file mode 100644 index 0000000000..fc0eeee785 --- /dev/null +++ b/Projectiles/Summon/PolypLauncherProjectile.cs @@ -0,0 +1,80 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class PolypLauncherProjectile : ModProjectile + { + public const float Gravity = 0.4f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Polyp Chunk"); + ProjectileID.Sets.SentryShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 18; + projectile.height = 18; + projectile.friendly = true; + projectile.tileCollide = true; + projectile.ignoreWater = true; + projectile.timeLeft = 300; + projectile.alpha = 255; + projectile.minion = true; + projectile.minionSlots = 0f; + } + + public override void AI() + { + if (projectile.velocity.Y <= 10f) + { + projectile.velocity.Y += Gravity; + } + projectile.ai[0]++; + if (projectile.ai[0] < 10) + { + 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; + } + + 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); + + //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/PolypLauncherProjectile.png b/Projectiles/Summon/PolypLauncherProjectile.png new file mode 100644 index 0000000000..d4fb7e3171 Binary files /dev/null and b/Projectiles/Summon/PolypLauncherProjectile.png differ diff --git a/Projectiles/Summon/PolypLauncherSentry.cs b/Projectiles/Summon/PolypLauncherSentry.cs new file mode 100644 index 0000000000..88b104c1c1 --- /dev/null +++ b/Projectiles/Summon/PolypLauncherSentry.cs @@ -0,0 +1,99 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class PolypLauncherSentry : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Polyp Launcher"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 42; + projectile.height = 25; + projectile.ignoreWater = true; + projectile.tileCollide = true; + projectile.sentry = true; + projectile.timeLeft = Projectile.SentryLifeTime; + projectile.penetrate = -1; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.localAI[0] += 1f; + } + if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int damage2 = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = damage2; + } + + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type]) + { + projectile.frame = 0; + } + + projectile.velocity.Y += 0.5f; + if (projectile.velocity.Y > 10f) + { + projectile.velocity.Y = 10f; + } + + projectile.StickToTiles(false, false); + + 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); + + 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)); + + float shootSpeed = 16f; + float gravity = -PolypLauncherProjectile.Gravity; + float distance = Vector2.Distance(spawnPosition, potentialTarget.Center); + float angle = 0.25f * (float)Math.Asin(MathHelper.Clamp(gravity * distance * 1.5f / (float)Math.Pow(shootSpeed, 2), -1f, 1f)); + + 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; + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) => false; + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Summon/PolypLauncherSentry.png b/Projectiles/Summon/PolypLauncherSentry.png new file mode 100644 index 0000000000..605f9b0719 Binary files /dev/null and b/Projectiles/Summon/PolypLauncherSentry.png differ diff --git a/Projectiles/Summon/PolypLauncherShrapnel.cs b/Projectiles/Summon/PolypLauncherShrapnel.cs new file mode 100644 index 0000000000..69dff708fe --- /dev/null +++ b/Projectiles/Summon/PolypLauncherShrapnel.cs @@ -0,0 +1,65 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + 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; + projectile.ignoreWater = true; + projectile.timeLeft = 120; + 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 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) + { + //Changes the texture of the projectile + Texture2D texture = Main.projectileTexture[projectile.type]; + if (projectile.ai[0] == 1f) + { + texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/PolypLauncherShrapnel2"); + } + if (projectile.ai[0] == 2f) + { + 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; + } + } +} diff --git a/Projectiles/Summon/PolypLauncherShrapnel.png b/Projectiles/Summon/PolypLauncherShrapnel.png new file mode 100644 index 0000000000..94fe76c650 Binary files /dev/null and b/Projectiles/Summon/PolypLauncherShrapnel.png differ diff --git a/Projectiles/Summon/PolypLauncherShrapnel2.png b/Projectiles/Summon/PolypLauncherShrapnel2.png new file mode 100644 index 0000000000..08c20fef73 Binary files /dev/null and b/Projectiles/Summon/PolypLauncherShrapnel2.png differ diff --git a/Projectiles/Summon/PolypLauncherShrapnel3.png b/Projectiles/Summon/PolypLauncherShrapnel3.png new file mode 100644 index 0000000000..b4ca87e39c Binary files /dev/null and b/Projectiles/Summon/PolypLauncherShrapnel3.png differ diff --git a/Projectiles/Summon/SageNeedle.cs b/Projectiles/Summon/SageNeedle.cs new file mode 100644 index 0000000000..76f51d3629 --- /dev/null +++ b/Projectiles/Summon/SageNeedle.cs @@ -0,0 +1,75 @@ +using CalamityMod.Buffs.DamageOverTime; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class SageNeedle : ModProjectile + { + public const int OnDeathHealValue = 1; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sage Needle"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 150; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + } + + public override void AI() + { + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.ToRadians(48f); + + // Don't collide with tiles unless the needle is falling. + projectile.tileCollide = projectile.velocity.Y > 0f; + if (projectile.velocity.Y < 12f) + projectile.velocity.Y += 0.16f; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + int totalSageSpirits = Main.player[projectile.owner].ownedProjectileCounts[ModContent.ProjectileType()]; + + // A slightly-smoothened curve that's a little less potent than a linear curve. + // Has the potential to eventually surpass a linear curve, but this is infeasible, only happening + // at around 344 allocated slots. + float averageDamageMultiplier = (float)(Math.Pow(totalSageSpirits, 0.73D) + Math.Pow(totalSageSpirits, 1.1D)) * 0.5f; + + // 1 slot provides 40 DoT. + // 2 slots provide 76 DoT. + // 3 slots provide 111 DoT. + // 4 slots provide 146 DoT. + // 5 slots provide 182 DoT. + int sagePoisonDamage = (int)(40 * averageDamageMultiplier); + sagePoisonDamage = CalamityUtils.DamageSoftCap(sagePoisonDamage, 270); + + target.AddBuff(ModContent.BuffType(), 300); + target.Calamity().sagePoisonDamage = sagePoisonDamage; + } + + public override void Kill(int timeLeft) + { + if (Main.dedServ) + return; + + for (int i = 0; i < 6; i++) + { + Dust redGrass = Dust.NewDustDirect(projectile.position + projectile.velocity, projectile.width, projectile.height, DustID.Grass, projectile.velocity.X * 0.1f, projectile.velocity.Y * 0.1f); + redGrass.velocity = Utils.NextVector2Unit(Main.rand) * Main.rand.NextFloat(1f, 3f); + redGrass.noGravity = true; + redGrass.color = Color.Lerp(Color.IndianRed, Color.MediumVioletRed, Main.rand.NextFloat()); + } + } + } +} diff --git a/Projectiles/Summon/SageNeedle.png b/Projectiles/Summon/SageNeedle.png new file mode 100644 index 0000000000..539aaa7384 Binary files /dev/null and b/Projectiles/Summon/SageNeedle.png differ diff --git a/Projectiles/Summon/SageSpirit.cs b/Projectiles/Summon/SageSpirit.cs new file mode 100644 index 0000000000..105c02e434 --- /dev/null +++ b/Projectiles/Summon/SageSpirit.cs @@ -0,0 +1,197 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +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; + + 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 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 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); + + // 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; + } + + 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; + } + + 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 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; + } + + 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; + } + + projectile.position.Y += (float)Math.Cos(GeneralTime / 60f * MathHelper.TwoPi + projectile.identity * 1.1f) * 0.5f; + + 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); + + PlayerFlyTime = MathHelper.Clamp(PlayerFlyTime + 0.03f, 0f, 1f); + } + + 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); + + // 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.56f, 0.56f, 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; + } +} diff --git a/Projectiles/Summon/SageSpirit.png b/Projectiles/Summon/SageSpirit.png new file mode 100644 index 0000000000..6bd3337fd9 Binary files /dev/null and b/Projectiles/Summon/SageSpirit.png differ diff --git a/Projectiles/Summon/SeekerSummonProj.cs b/Projectiles/Summon/SeekerSummonProj.cs new file mode 100644 index 0000000000..7805fd543a --- /dev/null +++ b/Projectiles/Summon/SeekerSummonProj.cs @@ -0,0 +1,150 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +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 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.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 8; + projectile.alpha = 255; + } + + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + DoInitializationEffects(); + projectile.localAI[0] = 1f; + } + + 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++; + } + + 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; + } + } + + 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; + + 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 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); + + 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; + } + + 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); + + projectile.velocity *= 0.9f; + if (Time % 16f == 15f) + { + float shootSpeed = 14f; + 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; + } + } +} diff --git a/Projectiles/Summon/SeekerSummonProj.png b/Projectiles/Summon/SeekerSummonProj.png new file mode 100644 index 0000000000..bd3a5924ca Binary files /dev/null and b/Projectiles/Summon/SeekerSummonProj.png differ diff --git a/Projectiles/Summon/Shellfish.cs b/Projectiles/Summon/Shellfish.cs index 31a96b7b64..597c02229e 100644 --- a/Projectiles/Summon/Shellfish.cs +++ b/Projectiles/Summon/Shellfish.cs @@ -347,7 +347,7 @@ namespace CalamityMod.Projectiles.Summon { NPC npc = Main.npc[npcIndex]; //covers most edge cases like voodoo dolls - if (npc.active && !npc.dontTakeDamage && npc.defense < 9999 && + 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)) { diff --git a/Projectiles/Summon/SlimePuppet.cs b/Projectiles/Summon/SlimePuppet.cs new file mode 100644 index 0000000000..2141fdc467 --- /dev/null +++ b/Projectiles/Summon/SlimePuppet.cs @@ -0,0 +1,118 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class SlimePuppet : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Slime Puppet"); + ProjectileID.Sets.MinionSacrificable[projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 1; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.width = 60; + projectile.height = 60; + projectile.netImportant = true; + projectile.friendly = true; + projectile.minionSlots = 0; + projectile.timeLeft = 300; + projectile.penetrate = 1; + projectile.minion = true; + projectile.tileCollide = false; + } + + public override void AI() + { + ResetDamage(); + + // Prevent clumping of other slime puppets near this one. + projectile.MinionAntiClump(); + + NPC potentialTarget = projectile.Center.MinionHoming(800f, Owner); + + if (potentialTarget is null) + { + // Movement above the player, depending on the index of the projectile in the Main.projectile array. + float destinationAngularOffset = (float)Math.Sin(projectile.identity / 6f % 6f * MathHelper.Pi) * MathHelper.Pi / 10f; + Vector2 destination = Owner.Center - Vector2.UnitY.RotatedBy(destinationAngularOffset) * 160f; + + if (projectile.DistanceSQ(destination) > 18f * 18f) + projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(destination) * 9f) / 21f; + } + else + { + float nudgedVelocityDirection = projectile.velocity.ToRotation().AngleTowards(projectile.AngleTo(potentialTarget.Center), 0.078f); + projectile.velocity = nudgedVelocityDirection.ToRotationVector2() * MathHelper.Lerp(projectile.velocity.Length(), 16f, 0.25f); + if (projectile.WithinRange(potentialTarget.Center, 120f)) + projectile.Center += projectile.SafeDirectionTo(potentialTarget.Center) * 3f; + } + if (projectile.ai[0] > 0f) + { + projectile.rotation += MathHelper.ToRadians(projectile.velocity.Length() / 4f) * Math.Sign(projectile.velocity.X); + projectile.ai[0]--; + } + else if (potentialTarget != null) + projectile.rotation = projectile.velocity.ToRotation(); + + if (Vector2.Dot(projectile.oldVelocity.SafeNormalize(Vector2.Zero), projectile.velocity.SafeNormalize(Vector2.Zero)) < 0.87) + projectile.ai[0] = 50f; + } + + public void ResetDamage() + { + // Initialize minion damage values the moment the projectile is spawned. + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + projectile.localAI[0] = 1f; + } + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * Owner.MinionDamage()); + projectile.damage = trueDamage; + } + } + + public override void Kill(int timeLeft) + { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 100); + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.Damage(); + Main.PlaySound(SoundID.NPCDeath1, projectile.Center); + + if (!Main.dedServ) + { + for (int i = 0; i < 20; i++) + { + Vector2 spawnOffset = Main.rand.NextVector2Unit() * Main.rand.NextFloat(4f, 36f); + Dust slime = Dust.NewDustPerfect(projectile.Center + spawnOffset, 243); + slime.velocity = spawnOffset.RotatedBy(MathHelper.PiOver2 * Main.rand.NextBool(2).ToDirectionInt()) * 0.16f; + slime.scale = 1.2f; + } + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) => false; + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor); + return false; + } + } +} diff --git a/Projectiles/Summon/SlimePuppet.png b/Projectiles/Summon/SlimePuppet.png new file mode 100644 index 0000000000..25eb7cc27f Binary files /dev/null and b/Projectiles/Summon/SlimePuppet.png differ diff --git a/Projectiles/Summon/SquirrelSquireAcorn.cs b/Projectiles/Summon/SquirrelSquireAcorn.cs index 8e312d4e7f..3b2f88f4d1 100644 --- a/Projectiles/Summon/SquirrelSquireAcorn.cs +++ b/Projectiles/Summon/SquirrelSquireAcorn.cs @@ -1,11 +1,12 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; -using Microsoft.Xna.Framework; + namespace CalamityMod.Projectiles.Summon { public class SquirrelSquireAcorn : ModProjectile { + public const float Gravity = 0.5f; public override void SetStaticDefaults() { DisplayName.SetDefault("Acorn"); @@ -20,22 +21,18 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; projectile.penetrate = 2; projectile.timeLeft = 180; - projectile.aiStyle = 1; } public override void AI() { - projectile.velocity.X *= 0.9995f; - projectile.velocity.Y = projectile.velocity.Y + 0.01f; - projectile.rotation += MathHelper.ToRadians(180) * projectile.direction; + projectile.velocity.Y += Gravity; + projectile.rotation += (projectile.velocity.X > 0f).ToDirectionInt() * 0.3f; } public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) - { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 7, projectile.oldVelocity.X * 0.5f, projectile.oldVelocity.Y * 0.5f); - } } } } diff --git a/Projectiles/Summon/SquirrelSquireMinion.cs b/Projectiles/Summon/SquirrelSquireMinion.cs index 5b141c3a20..221729e014 100644 --- a/Projectiles/Summon/SquirrelSquireMinion.cs +++ b/Projectiles/Summon/SquirrelSquireMinion.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.Summon; using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using System; +using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -10,7 +11,15 @@ namespace CalamityMod.Projectiles.Summon { public class SquirrelSquireMinion : ModProjectile { - public float dust = 0f; + public int StuckTimer; + public bool TryingToGetCloseToOwner + { + get => projectile.ai[0] == 1f; + set => projectile.ai[0] = value.ToInt(); + } + public ref float AttackTimer => ref projectile.ai[1]; + public bool OnSolidGround => projectile.velocity.Y == 0f && WorldGen.SolidTile((int) projectile.Center.X / 16, (int) projectile.Bottom.Y / 16 + 2); + public Player Owner => Main.player[projectile.owner]; public override void SetStaticDefaults() { @@ -22,7 +31,7 @@ namespace CalamityMod.Projectiles.Summon public override void SetDefaults() { - projectile.width = 64; + projectile.width = 34; projectile.height = 64; projectile.netImportant = true; projectile.friendly = true; @@ -35,498 +44,178 @@ namespace CalamityMod.Projectiles.Summon projectile.minion = true; } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(StuckTimer); + + public override void ReceiveExtraAI(BinaryReader reader) => StuckTimer = reader.ReadInt32(); + public override void AI() { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); - CalamityGlobalProjectile modProj = projectile.Calamity(); - if (dust == 0f) + if (projectile.localAI[0] == 0f) { - modProj.spawnedPlayerMinionDamageValue = player.MinionDamage(); - modProj.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 dusty = Dust.NewDust(source + dustVel, 0, 0, 7, dustVel.X * 1.1f, dustVel.Y * 1.1f, 100, default, 1.4f); - Main.dust[dusty].noGravity = true; - Main.dust[dusty].noLight = true; - Main.dust[dusty].velocity = dustVel; - } - dust += 1f; + DoInitializationEffects(); + projectile.localAI[0] = 1f; } - if (player.MinionDamage() != modProj.spawnedPlayerMinionDamageValue) + + // Re-adjust damage as needed. + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { - int damage2 = (int)((float)modProj.spawnedPlayerMinionProjectileDamageValue / - modProj.spawnedPlayerMinionDamageValue * - player.MinionDamage()); - projectile.damage = damage2; + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * Owner.MinionDamage()); + projectile.damage = trueDamage; } - bool projTypeCheck = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (projTypeCheck) + + projectile.frameCounter++; + + VerifyIdentity(); + if (!projectile.WithinRange(Owner.Center, 1000f) || TryingToGetCloseToOwner || Collision.SolidCollision(projectile.position + Vector2.One * 4f, projectile.width - 8, projectile.height - 8)) { - if (player.dead) + // Once far off, don't go back to normal until 350 pixels away from the owner or less. + TryingToGetCloseToOwner = !projectile.WithinRange(Owner.Center, 350f) && !Collision.SolidCollision(projectile.position, projectile.width, projectile.height); + + ReturnToOwner(); + if (!projectile.WithinRange(Owner.Center, 2000f)) { - modPlayer.squirrel = false; + projectile.Center = Owner.Center; + projectile.netUpdate = true; } - if (modPlayer.squirrel) - { + projectile.tileCollide = false; + return; + } + + NPC potentialTarget = projectile.Center.MinionHoming(800f, Owner, false); + if (potentialTarget is null) + FollowOwner(); + else + AttackTarget(potentialTarget); + + projectile.rotation = 0f; + projectile.tileCollide = true; + } + + public void DoInitializationEffects() + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + + int dustQuantity = 36; + for (int d = 0; d < dustQuantity; d++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, 7); + dust.scale = 1.4f; + dust.velocity = (MathHelper.TwoPi * d / dustQuantity).ToRotationVector2() * 4f; + dust.noGravity = true; + dust.noLight = true; + } + } + + public void VerifyIdentity() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (projectile.type == ModContent.ProjectileType()) + { + if (Owner.dead) + Owner.Calamity().squirrel = false; + if (Owner.Calamity().squirrel) projectile.timeLeft = 2; + } + } + + public void ReturnToOwner() + { + projectile.frame = 12 + projectile.frameCounter / 8 % 4; + projectile.velocity = projectile.velocity.MoveTowards(projectile.SafeDirectionTo(Owner.Top) * 8f, 0.8f); + projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); + projectile.rotation = projectile.velocity.X * 0.025f; + } + + public void AttemptToJumpToDestination(Vector2 destination) + { + if (OnSolidGround) + { + float jumpSpeed = MathHelper.Lerp(6f, 13f, Utils.InverseLerp(100f, 250f, MathHelper.Distance(projectile.Center.X, destination.X), true)); + projectile.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(projectile.Center, Owner.Center, 0.4f, jumpSpeed); + projectile.spriteDirection = (projectile.velocity.X > 0f).ToDirectionInt(); + projectile.netUpdate = true; + projectile.frame = 4; + } + else + { + if (projectile.frameCounter % 5 == 4 && projectile.frame < 7) + projectile.frame++; + } + } + + public void FollowOwner() + { + projectile.rotation = 0f; + + // Slow down and just idly vibe if close enough to the owner. + float horizontalDistanceFromOwner = MathHelper.Distance(projectile.Center.X, Owner.Center.X); + float verticalDistanceFromOwner = MathHelper.Distance(projectile.Center.Y, Owner.Center.Y); + if (horizontalDistanceFromOwner < 100f && verticalDistanceFromOwner < 450f) + { + projectile.velocity.X *= 0.94f; + if (OnSolidGround) + { + projectile.frame = projectile.frameCounter / 5 % 4; + projectile.velocity *= 0.9f; + } + StuckTimer = 0; + } + + // Otherwise try to catch up with them on foot. + else + { + AttemptToJumpToDestination(Owner.Center); + // Determine if there's something in the way of this minion and its owner. + if (!Collision.CanHit(projectile.position, projectile.width, projectile.height, Owner.Center, 2, 2) || MathHelper.Distance(projectile.position.X, projectile.oldPosition.X) < 1f) + { + StuckTimer++; + + // If stuck for a sufficiently long time fly to the owner again. + if (StuckTimer > 180) + { + TryingToGetCloseToOwner = true; + StuckTimer = 0; + projectile.netUpdate = true; + } + } + else if (StuckTimer > 0) + StuckTimer--; + } + + // Enforce gravity. + projectile.velocity.Y = MathHelper.Clamp(projectile.velocity.Y + 0.4f, -12f, 12f); + } + + public void AttackTarget(NPC target) + { + float horizontalDistanceFromTarget = MathHelper.Distance(projectile.Center.X, target.Center.X); + + if (horizontalDistanceFromTarget > 350f) + AttemptToJumpToDestination(target.Center); + else if (OnSolidGround) + { + projectile.velocity.X *= 0.94f; + if (OnSolidGround) + { + projectile.frame = projectile.frameCounter / 5 % 4; + projectile.velocity *= 0.9f; + } + AttackTimer++; + + // Pelt the target with acorns. + projectile.frame = 8 + (int)(AttackTimer / 6.4) % 4; + if (Main.myPlayer == projectile.owner && AttackTimer % 30f == 27f) + { + projectile.spriteDirection = (target.Center.X > projectile.Center.X).ToDirectionInt(); + Vector2 acornSpawnPosition = projectile.Center + new Vector2(projectile.spriteDirection * 6f, 10f); + float acornShootSpeed = 14f; + Vector2 acornShootVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(acornSpawnPosition, target.Center + target.velocity * 25f, SquirrelSquireAcorn.Gravity, acornShootSpeed); + Projectile.NewProjectile(acornSpawnPosition, acornShootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); } } - bool leftofPlayer = false; - bool rightofPlayer = false; - bool flag3 = false; - bool flag4 = false; - if (projectile.lavaWet) - { - projectile.ai[0] = 1f; - projectile.ai[1] = 0f; - } - float minionOffset = 40f * (projectile.minionPos + 1f) * player.direction; - if (player.Center.X < projectile.Center.X - 10f + minionOffset) - leftofPlayer = true; - else if (player.Center.X > projectile.Center.X + 10f + minionOffset) - rightofPlayer = true; - - if (projectile.ai[1] == 0f) - { - float playerDist = (player.Center - projectile.Center).Length(); - if (playerDist > 1000f) - { - projectile.ai[0] = 1f; - } - if (playerDist > 2000f) //teleport to player if too far - { - projectile.position = player.position; - projectile.netUpdate = true; - } - } - if (projectile.ai[0] != 0f) //flying back to the player - { - projectile.tileCollide = false; - float npcDetectRange = 800f; - bool npcFound = false; - int targetIndex = -1; - for (int index = 0; index < Main.maxNPCs; ++index) - { - NPC npc = Main.npc[index]; - if (npc.CanBeChasedBy(projectile, false)) - { - float npcDist = Vector2.Distance(npc.Center, player.Center); - if (npcDist < npcDetectRange) - { - if (Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height)) - targetIndex = index; - npcFound = true; - break; - } - } - } - - //return to normal if npc found - if (npcFound && targetIndex >= 0) - projectile.ai[0] = 0f; - - Vector2 homeBase = player.Center - projectile.Center; - homeBase.X -= 40f * player.direction; - if (!npcFound) - homeBase.X -= 40f * projectile.minionPos * player.direction; - homeBase.Y -= 60f; - float playerDist = homeBase.Length(); - float speed = playerDist; - float acceleration = 0.4f; - - //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.position, projectile.width, projectile.height)) - { - projectile.ai[0] = 0f; - if (projectile.velocity.Y < -6f) - projectile.velocity.Y = -6f; - } - if (playerDist > 2000f) - { - projectile.position = player.position; - projectile.netUpdate = true; - } - if (playerDist < 50f) - { - if (Math.Abs(projectile.velocity.X) > 2f || Math.Abs(projectile.velocity.Y) > 2f) - { - projectile.velocity *= 0.99f; - } - acceleration = 0.01f; - } - else - { - if (playerDist < 100f) - { - acceleration = 0.1f; - } - if (playerDist > 300f) - { - acceleration = 1f; - } - playerDist = speed / playerDist; - homeBase *= playerDist; - } - if (projectile.velocity.X < homeBase.X) - { - projectile.velocity.X += acceleration; - if (acceleration > 0.05f && projectile.velocity.X < 0f) - { - projectile.velocity.X += acceleration; - } - } - if (projectile.velocity.X > homeBase.X) - { - projectile.velocity.X -= acceleration; - if (acceleration > 0.05f && projectile.velocity.X > 0f) - { - projectile.velocity.X -= acceleration; - } - } - if (projectile.velocity.Y < homeBase.Y) - { - projectile.velocity.Y += acceleration; - if (acceleration > 0.05f && projectile.velocity.Y < 0f) - { - projectile.velocity.Y += acceleration * 2f; - } - } - if (projectile.velocity.Y > homeBase.Y) - { - projectile.velocity.Y -= acceleration; - if (acceleration > 0.05f && projectile.velocity.Y > 0f) - { - projectile.velocity.Y -= acceleration * 2f; - } - } - if (projectile.frame < 12 || projectile.frame == 16) - { - projectile.frame = 12; - } - else - { - projectile.frameCounter++; - if (projectile.frameCounter > 3) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 16) - { - projectile.frame = 13; - } - } - if (projectile.velocity.X > 0.5f) - projectile.spriteDirection = 1; - else if (projectile.velocity.X < -0.5f) - projectile.spriteDirection = -1; - } - else - { - float minionOffset2 = (float)(40 * projectile.minionPos); - float attackCooldown = 30f; - float directionCooldown = 60f; - --projectile.localAI[0]; - if (projectile.localAI[0] < 0f) - projectile.localAI[0] = 0f; - if (projectile.ai[1] > 0f) - { - --projectile.ai[1]; - } - else - { - Vector2 targetPos = projectile.position; - float range = 100000f; - float maxDist = range; - int targetIndex = -1; - NPC target = projectile.OwnerMinionAttackTargetNPC; - if (target != null && target.CanBeChasedBy(projectile, false)) - { - float npcDist = Vector2.Distance(target.Center, projectile.Center); - if (npcDist < range) - { - if (targetIndex == -1 && npcDist <= maxDist) - { - maxDist = npcDist; - targetPos = target.Center; - } - if (Collision.CanHit(projectile.Center, projectile.width, projectile.height, target.Center, target.width, target.height)) - { - range = npcDist; - targetPos = target.Center; - targetIndex = target.whoAmI; - } - } - } - if (targetIndex == -1) - { - 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 (npcDist < range) - { - if (targetIndex == -1 && npcDist <= maxDist) - { - maxDist = npcDist; - targetPos = npc.Center; - } - if (Collision.CanHit(projectile.Center, projectile.width, projectile.height, npc.Center, npc.width, npc.height)) - { - range = npcDist; - targetPos = npc.Center; - targetIndex = index; - } - } - } - } - } - if (targetIndex == -1 && maxDist < range) - range = maxDist; - float num13 = 400f; - if ((double)projectile.position.Y > Main.worldSurface * 16D) - num13 = 200f; - if (range < num13 + minionOffset2 && targetIndex == -1) - { - float xDist = targetPos.X - projectile.Center.X; - if (xDist < -5f) - { - leftofPlayer = true; - rightofPlayer = false; - } - else if (xDist > 5f) - { - rightofPlayer = true; - leftofPlayer = false; - } - } - else if (targetIndex >= 0 && range < 800f + minionOffset2) - { - projectile.localAI[0] = directionCooldown; - float xDist = targetPos.X - projectile.Center.X; - if (Math.Abs(xDist) > 300f) - { - if (xDist < -50f) - { - leftofPlayer = true; - rightofPlayer = false; - } - else if (xDist > 50f) - { - rightofPlayer = true; - leftofPlayer = false; - } - } - else if (projectile.owner == Main.myPlayer) - { - projectile.ai[1] = attackCooldown; - float speed = 12f; - Vector2 source = projectile.Center - Vector2.UnitY * 8f; - Vector2 projVel = targetPos - source; - projVel.X += Main.rand.NextFloat(-10f, 10f); - projVel.Y += Main.rand.NextFloat(-10f, 10f) - Math.Abs(projVel.X) * Main.rand.NextFloat(0.0001f, 0.01f); - projVel.Normalize(); - projVel *= speed; - int damage = projectile.damage; - int projType = ModContent.ProjectileType(); - int index = Projectile.NewProjectile(source, projVel, projType, damage, projectile.knockBack, projectile.owner); - if (projVel.X < 0f) - projectile.direction = projectile.spriteDirection = -1; - else if (projVel.X > 0f) - projectile.direction = projectile.spriteDirection = 1; - projectile.netUpdate = true; - } - } - } - if (projectile.ai[1] != 0f) //If on attack cooldown - { - leftofPlayer = false; - rightofPlayer = false; - } - else if (projectile.localAI[0] == 0f) - projectile.direction = projectile.spriteDirection = player.direction; - projectile.tileCollide = true; - float num18 = 0.2f; - float num19 = 6f; - 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 (leftofPlayer) - { - if (projectile.velocity.X > -3.5f) - projectile.velocity.X -= num18; - else - projectile.velocity.X -= num18 * 0.25f; - } - else if (rightofPlayer) - { - 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 (leftofPlayer | rightofPlayer) - { - int i = (int)projectile.Center.X / 16; - int j = (int)projectile.Center.Y / 16; - if (leftofPlayer) - --i; - if (rightofPlayer) - ++i; - if (WorldGen.SolidTile(i + (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 && (projectile.velocity.X < 0f || projectile.velocity.X > 0f)) - { - int i = (int)projectile.Center.X / 16; - int j = (int)projectile.Center.Y / 16 + 1; - if (leftofPlayer) - --i; - if (rightofPlayer) - ++i; - WorldGen.SolidTile(i, j); - } - if (flag4) - { - int i = (int)projectile.Center.X / 16; - int j = (int)projectile.Center.Y / 16 + 1; - if (WorldGen.SolidTile(i, j) || Main.tile[i, j].halfBrick() || (int)Main.tile[i, j].slope() > 0) - { - try - { - int i2 = (int)projectile.Center.X / 16; - int j2 = (int)projectile.Center.Y / 16; - if (leftofPlayer) - --i2; - if (rightofPlayer) - ++i2; - i2 += (int)projectile.velocity.X; - if (!WorldGen.SolidTile(i2, j2 - 1) && !WorldGen.SolidTile(i2, j2 - 2)) - projectile.velocity.Y = -5.1f; - else if (!WorldGen.SolidTile(i2, j2 - 2)) - projectile.velocity.Y = -7.1f; - else if (WorldGen.SolidTile(i2, j2 - 5)) - projectile.velocity.Y = -11.1f; - else if (WorldGen.SolidTile(i2, j2 - 4)) - projectile.velocity.Y = -10.1f; - else - projectile.velocity.Y = -9.1f; - } - catch - { - projectile.velocity.Y = -9.1f; - } - } - } - } - if (projectile.velocity.X > num19) - projectile.velocity.X = num19; - if (projectile.velocity.X < -num19) - projectile.velocity.X = -num19; - if (projectile.velocity.X < -0.05f) - projectile.direction = projectile.spriteDirection = -1; - if (projectile.velocity.X > 0.05f) - projectile.direction = projectile.spriteDirection = 1; - if (projectile.ai[1] > 0f) - { - if (projectile.localAI[1] == 0f) - { - projectile.localAI[1] = 1f; - projectile.frame = 8; - } - if (projectile.frame >= 8 && projectile.frame <= 11) - { - projectile.frameCounter++; - if (projectile.frameCounter > 8) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame == 11) - projectile.frame = 8; - } - } - 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 >= 4) - { - projectile.frame = 0; - } - } - else if (Math.Abs(projectile.velocity.X) > 0.8f) - { - 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 = 4; - if (projectile.frame >= 8) - projectile.frame = 4; - } - else - { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame >= 4) - { - projectile.frame = 0; - } - } - } - else if (projectile.velocity.Y < 0f) - { - projectile.frameCounter = 0; - projectile.frame = 16; - } - else if (projectile.velocity.Y > 0f) - { - projectile.frameCounter = 0; - projectile.frame = 16; - } - projectile.velocity.Y += 0.4f; - if (projectile.velocity.Y > 10f) - projectile.velocity.Y = 10f; - Vector2 velocity = projectile.velocity; - } - } + projectile.velocity.Y = MathHelper.Clamp(projectile.velocity.Y + 0.4f, -12f, 12f); + } public override bool CanDamage() => false; diff --git a/Projectiles/Summon/UniverseSplitterField.cs b/Projectiles/Summon/UniverseSplitterField.cs new file mode 100644 index 0000000000..56fc408f48 --- /dev/null +++ b/Projectiles/Summon/UniverseSplitterField.cs @@ -0,0 +1,159 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Audio; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class UniverseSplitterField : ModProjectile + { + public float Timer + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + public float DustRadius = 0f; + public const float DustChargeTime = 30f; + public const float DustMinRadius = 0f; + public const float DustMaxRadius = 90f; + public const int SpiralPrecision = 25; + public const int SpiralRings = 5; + public const int TimeLeft = 720; + + public const float SmallBeamAngleMax = MathHelper.TwoPi / 15f; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Field"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 200; + projectile.alpha = 255; + projectile.friendly = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.ignoreWater = true; + projectile.timeLeft = TimeLeft; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(DustRadius); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + DustRadius = reader.ReadSingle(); + } + + public override void AI() + { + Timer++; + if (Timer < DustChargeTime) + { + DustRadius = MathHelper.Lerp(DustMinRadius, DustMaxRadius, Timer / DustChargeTime); + } + else + { + DustRadius = DustMaxRadius + (float)Math.Sin(Timer / 50f) * 16f; + } + if (!Main.dedServ) + { + GenerateIdleDust(); + } + SpawnLasers(); + } + + public void GenerateIdleDust() + { + // Generate a dust ring that pulsates + for (int i = 0; i < 80; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + (i / 80f * MathHelper.TwoPi).ToRotationVector2() * DustRadius, 247); + dust.velocity = Vector2.Zero; + dust.scale = 1.2f; + dust.noGravity = true; + } + + // Spirals that spin around + for (int i = 0; i < SpiralPrecision; i++) + { + for (int direction = -1; direction <= 1; direction += 2) + { + for (int j = 0; j < SpiralRings; j++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + + Vector2.UnitY.RotatedBy(Timer / SpiralPrecision * direction).RotatedBy(j / (float)SpiralRings * MathHelper.TwoPi).RotatedBy(i / (float)SpiralPrecision * MathHelper.TwoPi / SpiralRings * direction) * + DustRadius * i / SpiralPrecision, 261); + dust.velocity = Vector2.Zero; + dust.scale = 0.7f; + dust.noGravity = true; + } + } + } + + // Outward expansion of dust + bool firingGiantLaserBeam = Timer > TimeLeft - UniverseSplitterHugeBeam.TimeLeft; + for (int i = 0; i < (firingGiantLaserBeam ? 30 : 16); i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, 247); + dust.velocity = Main.rand.NextVector2Circular(8f, 8f) * (firingGiantLaserBeam ? 1.6f : 1f); + dust.noGravity = true; + dust.scale = 1.25f; + } + + // Energy dust that appears before the giant beam does and remains + if (Timer > TimeLeft - UniverseSplitterHugeBeam.TimeLeft - 120f) + { + float outwardCircleRadius = MathHelper.Lerp(0f, DustRadius * 1.2f, MathHelper.Clamp((Timer - (TimeLeft - UniverseSplitterHugeBeam.TimeLeft - 120f)) / 40f, 0f, 1f)); + for (int i = 0; i < 95; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + (i / 95f * MathHelper.TwoPi).ToRotationVector2() * outwardCircleRadius, 247); + dust.scale = 1.2f; + dust.noGravity = true; + dust.velocity = Main.rand.NextBool(7) ? projectile.DirectionFrom(dust.position) * 6f : Vector2.Zero; + } + } + } + + public void SpawnLasers() + { + // Create small beams sometimes + if (Timer > 120f && + Timer < TimeLeft - UniverseSplitterHugeBeam.TimeLeft && + Timer % 60f == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBolt"), projectile.Center); + if (Main.myPlayer == projectile.owner) + { + Vector2 offset = new Vector2(Main.rand.NextFloat(-800f, 800f), -1460f); + Projectile.NewProjectile(projectile.Center + offset, + -Vector2.Normalize(offset), + ModContent.ProjectileType(), + projectile.damage, + projectile.knockBack, + projectile.owner, + (-Vector2.Normalize(offset)).ToRotation()); + } + } + // Summon a giant beam + if (Timer == TimeLeft - UniverseSplitterHugeBeam.TimeLeft && Main.myPlayer == projectile.owner) + { + Main.PlaySound(SoundID.Zombie, projectile.Center, 104); + Projectile.NewProjectile(projectile.Center + Vector2.UnitY * -UniverseSplitterHugeBeam.MaximumLength / 2f, + Vector2.UnitY, + ModContent.ProjectileType(), + projectile.damage, + projectile.knockBack, + projectile.owner, + 0f); + } + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Summon/UniverseSplitterField.png b/Projectiles/Summon/UniverseSplitterField.png new file mode 100644 index 0000000000..c8fba012d0 Binary files /dev/null and b/Projectiles/Summon/UniverseSplitterField.png differ diff --git a/Projectiles/Summon/UniverseSplitterHugeBeam.cs b/Projectiles/Summon/UniverseSplitterHugeBeam.cs new file mode 100644 index 0000000000..5a211b41f3 --- /dev/null +++ b/Projectiles/Summon/UniverseSplitterHugeBeam.cs @@ -0,0 +1,201 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.Enums; +using Terraria.ModLoader; +using CalamityMod.Buffs.DamageOverTime; +using Terraria.GameContent.Events; + +namespace CalamityMod.Projectiles.Summon +{ + public class UniverseSplitterHugeBeam : ModProjectile + { + // Pretty self explanatory + public const int TotalFadeoutTime = 25; + public const int TimeLeft = 180; + public const float MaximumLength = 3000f; + // How fat the laser is + public const float LaserSize = 1.45f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Universe Splitter Ray"); + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = TimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + } + + // Netcode for sending and receiving shit + // localAI[0] is the timer, localAI[1] is the laser length + + 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() + { + projectile.velocity = (projectile.velocity.ToRotation() + projectile.ai[0]).ToRotationVector2(); + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + + projectile.localAI[0]++; + + // Fadein/out. The timeleft varies, so this must be done manually. + if (projectile.localAI[0] < TotalFadeoutTime) + { + projectile.scale = MathHelper.Lerp(0.01f, LaserSize, projectile.localAI[0] / TotalFadeoutTime); + } + + if (projectile.timeLeft < TotalFadeoutTime) + { + projectile.scale = MathHelper.Lerp(LaserSize, 0f, 1f - (projectile.timeLeft / (float)TotalFadeoutTime)); + } + + Vector2 samplingPoint = projectile.Center; + + float[] samples = new float[3]; + + float determinedLength = 0f; + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, MaximumLength + 72f, samples); + for (int i = 0; i < samples.Length; i++) + { + determinedLength += samples[i]; + } + determinedLength /= samples.Length; + + determinedLength = MathHelper.Clamp(determinedLength, MaximumLength * 0.3f, MaximumLength); + + float lerpDelta = 0.5f; + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta); + if (projectile.localAI[0] < 30f) + { + projectile.localAI[1] = MathHelper.Lerp(72f, projectile.localAI[1], projectile.localAI[0] / 30f); + } + Vector2 beamEndPosition = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f); + if (projectile.localAI[0] >= 30f && + projectile.localAI[0] <= 35f) + { + if (projectile.localAI[0] == 30f) + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), projectile.Center); + for (int i = 0; i < 75; i++) + { + Dust dust = Dust.NewDustPerfect(beamEndPosition, 269); + dust.velocity = Main.rand.NextVector2Circular(16f, 11f); + dust.velocity = dust.velocity.SafeNormalize(Vector2.UnitY) * new Vector2(5f, 3.5f); + dust.scale = Main.rand.NextFloat(1.2f, 1.5f); + dust.noGravity = true; + + dust = Dust.NewDustPerfect(beamEndPosition, 269); + dust.velocity = (i / 75f * MathHelper.TwoPi).ToRotationVector2().RotatedByRandom(0.2f) * new Vector2(16f, 11f) * 1.3f; + dust.scale = Main.rand.NextFloat(1.4f, 1.75f); + dust.noGravity = true; + } + } + + if (projectile.localAI[0] > TimeLeft - 50f) + { + float light = 1f; + if (projectile.localAI[0] < TimeLeft - 30f) + { + light = MathHelper.Lerp(0f, 1f, (projectile.localAI[0] - (TimeLeft - 30f)) / 30f); + } + MoonlordDeathDrama.RequestLight(light, beamEndPosition); + } + + // Draw acid green light across the laser + DelegateMethods.v3_1 = new Vector3(0.62f, 0.94f, 0.38f); + 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 laserTailTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UniverseSplitterHugeBeamEnd"); + Texture2D laserBodyTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UniverseSplitterHugeBeamMid"); + float laserLength = projectile.localAI[1]; + Color drawColor = new Color(1f, 1f, 1f) * 0.9f; + + // Laser body logic + + laserLength -= laserTailTexture.Height / 2 * projectile.scale; + Vector2 centerDelta = projectile.Center - 76f * projectile.velocity * projectile.scale; + centerDelta += projectile.velocity * projectile.scale * laserTailTexture.Height / 2f; + if (laserLength > 0f) + { + float laserLengthDelta = 0f; + Rectangle sourceRectangle = new Rectangle(0, 76 * (projectile.timeLeft / 3 % 5), laserBodyTexture.Width, 76); + while (laserLengthDelta + 1f < laserLength) + { + if (laserLength - laserLengthDelta < sourceRectangle.Height) + { + sourceRectangle.Height = (int)(laserLength - laserLengthDelta); + } + Main.spriteBatch.Draw(laserBodyTexture, centerDelta - Main.screenPosition, new Rectangle?(sourceRectangle), drawColor, projectile.rotation, new Vector2(sourceRectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + laserLengthDelta += sourceRectangle.Height * projectile.scale; + centerDelta += projectile.velocity * sourceRectangle.Height * projectile.scale; + sourceRectangle.Y += (int)(76 * projectile.scale); + if (sourceRectangle.Y + sourceRectangle.Height > laserBodyTexture.Height) + { + sourceRectangle.Y = 0; + } + } + } + + // Laser tail logic + centerDelta += projectile.velocity * projectile.scale * 38f; + Rectangle tailFrameRectangle = new Rectangle(0, 76 * (projectile.timeLeft / 3 % 5), laserTailTexture.Width, 76); + Main.spriteBatch.Draw(laserTailTexture, centerDelta - Main.screenPosition, tailFrameRectangle, drawColor, projectile.rotation, new Vector2(148f, 76f) / 2f, projectile.scale, SpriteEffects.None, 0f); + + return false; + } + + public override bool ShouldUpdatePosition() => false; + + public override void CutTiles() + { + DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; + Vector2 unit = projectile.velocity; + Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float value = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * (projectile.localAI[1] + 76f), 22f * projectile.scale, ref value)) + { + return true; + } + return false; + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Electrified, 300); + target.AddBuff(ModContent.BuffType(), 45 * 60); + } + } +} diff --git a/Projectiles/Summon/UniverseSplitterHugeBeam.png b/Projectiles/Summon/UniverseSplitterHugeBeam.png new file mode 100644 index 0000000000..58ba72804a Binary files /dev/null and b/Projectiles/Summon/UniverseSplitterHugeBeam.png differ diff --git a/Projectiles/Summon/UniverseSplitterSmallBeam.cs b/Projectiles/Summon/UniverseSplitterSmallBeam.cs new file mode 100644 index 0000000000..02d9aad775 --- /dev/null +++ b/Projectiles/Summon/UniverseSplitterSmallBeam.cs @@ -0,0 +1,185 @@ +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.Enums; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class UniverseSplitterSmallBeam : ModProjectile + { + // Pretty self explanatory + public const int FadeinTime = 25; + public const int MovementTime = 60; + public const int TimeLeft = 120; + public const float TotalSweeps = 4f; + public const float MaximumLength = 3000f; + // How fat the laser is + public const float LaserSize = 1.2f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Universe Splitter Ray"); + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.friendly = true; + projectile.magic = true; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.timeLeft = TimeLeft; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 6; + } + + // Netcode for sending and receiving shit + // localAI[0] is the timer, localAI[1] is the laser length + + 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 static float CosineInterpolation(float start, float end, float time) + { + float cosineTime = (1f - (float)Math.Cos(MathHelper.Pi * time)) * 0.5f; + return start * (1 - cosineTime) + end * cosineTime; + } + + public override bool ShouldUpdatePosition() => false; + + public override void AI() + { + if (projectile.localAI[0] <= MovementTime) + { + projectile.velocity = (projectile.ai[0] + (float)Math.Cos(projectile.localAI[0] / MovementTime * TotalSweeps) * + CosineInterpolation(1f, 0f, projectile.localAI[0] / MovementTime) * UniverseSplitterField.SmallBeamAngleMax).ToRotationVector2(); + } + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + + projectile.localAI[0] += 1f; + + // Fadein/out. The timeleft varies, so this must be done manually. + if (projectile.localAI[0] < FadeinTime) + { + projectile.scale = MathHelper.Lerp(0.01f, LaserSize, projectile.localAI[0] / FadeinTime); + } + if (projectile.localAI[0] > MovementTime && + projectile.localAI[0] <= MovementTime + 10f) + { + projectile.scale = MathHelper.Lerp(LaserSize, 3.25f, (projectile.localAI[0] - MovementTime) / 10f); + } + if (projectile.localAI[0] > TimeLeft - 15f) + { + projectile.scale = MathHelper.Lerp(3.25f, 0.01f, (projectile.localAI[0] - (TimeLeft - 15f)) / 15f); + } + + Vector2 samplingPoint = projectile.Center; + + float[] samples = new float[3]; + + float determinedLength = 0f; + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, MaximumLength, samples); + for (int i = 0; i < samples.Length; i++) + { + determinedLength += samples[i]; + } + determinedLength /= samples.Length; + + determinedLength = MathHelper.Clamp(determinedLength, MaximumLength * 0.5f, MaximumLength); + + float lerpDelta = 0.5f; + projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta); + Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f); + + // Draw white light across the laser + DelegateMethods.v3_1 = Color.White.ToVector3(); + 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 laserTailTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UniverseSplitterSmallBeamBegin"); + Texture2D laserBodyTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UniverseSplitterSmallBeamMid"); + Texture2D laserHeadTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/UniverseSplitterSmallBeamEnd"); + float laserLength = projectile.localAI[1]; + Color drawColor = new Color(1f, 1f, 1f) * 0.9f; + + // Laser tail logic + + Main.spriteBatch.Draw(laserTailTexture, projectile.Center - Main.screenPosition, null, drawColor, projectile.rotation, laserTailTexture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); + + // Laser body logic + + laserLength -= (laserTailTexture.Height / 2 + laserHeadTexture.Height) * projectile.scale; + Vector2 centerDelta = projectile.Center; + centerDelta += projectile.velocity * projectile.scale * (float)laserTailTexture.Height / 2f; + if (laserLength > 0f) + { + float laserLengthDelta = 0f; + Rectangle sourceRectangle = new Rectangle(0, 14 * (projectile.timeLeft / 3 % 5), laserBodyTexture.Width, 16); + while (laserLengthDelta + 1f < laserLength) + { + if (laserLength - laserLengthDelta < sourceRectangle.Height) + { + sourceRectangle.Height = (int)(laserLength - laserLengthDelta); + } + Main.spriteBatch.Draw(laserBodyTexture, centerDelta - Main.screenPosition, new Rectangle?(sourceRectangle), drawColor, projectile.rotation, new Vector2(sourceRectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); + laserLengthDelta += sourceRectangle.Height * projectile.scale; + centerDelta += projectile.velocity * sourceRectangle.Height * projectile.scale; + sourceRectangle.Y += 14; + if (sourceRectangle.Y + sourceRectangle.Height > laserBodyTexture.Height) + { + sourceRectangle.Y = 0; + } + } + } + + // Laser head logic + + Main.spriteBatch.Draw(laserHeadTexture, centerDelta - Main.screenPosition, null, drawColor, projectile.rotation, laserHeadTexture.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], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + if (projHitbox.Intersects(targetHitbox)) + { + return true; + } + float value = 0f; + if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref value)) + { + return true; + } + return false; + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(BuffID.Electrified, 300); + } + } +} diff --git a/Projectiles/Summon/UniverseSplitterSmallBeam.png b/Projectiles/Summon/UniverseSplitterSmallBeam.png new file mode 100644 index 0000000000..50902dedaf Binary files /dev/null and b/Projectiles/Summon/UniverseSplitterSmallBeam.png differ diff --git a/Projectiles/Summon/VileFeederSummon.cs b/Projectiles/Summon/VileFeederSummon.cs index b29d50f33c..262a8ed0e9 100644 --- a/Projectiles/Summon/VileFeederSummon.cs +++ b/Projectiles/Summon/VileFeederSummon.cs @@ -184,7 +184,7 @@ namespace CalamityMod.Projectiles.Summon { NPC npc = Main.npc[npcIndex]; //covers most edge cases like voodoo dolls - if (npc.active && !npc.dontTakeDamage && npc.defense < 9999 && + 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)) { diff --git a/Projectiles/Summon/ViridVanguardBlade.cs b/Projectiles/Summon/ViridVanguardBlade.cs new file mode 100644 index 0000000000..df19971af4 --- /dev/null +++ b/Projectiles/Summon/ViridVanguardBlade.cs @@ -0,0 +1,198 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class ViridVanguardBlade : ModProjectile + { + public bool AltTexture = false; + + public int RemainingSlices = 0; + public int PostSliceDeathTimer; + public float RedirectAngle; + public float FiringTime = 0f; + public Vector2 IdealPosition; + public float Angle + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Vanguard Blade"); + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 7; + } + + public override void SetDefaults() + { + projectile.width = 60; + projectile.height = 156; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 1.5f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 14; + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(RedirectAngle); + writer.Write(FiringTime); + writer.Write(AltTexture); + } + public override void ReceiveExtraAI(BinaryReader reader) + { + RedirectAngle = reader.ReadSingle(); + FiringTime = reader.ReadSingle(); + AltTexture = reader.ReadBoolean(); + } + public override void AI() + { + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + projectile.spriteDirection = AltTexture.ToDirectionInt(); + if (projectile.localAI[0] == 0f) + { + 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 / + projectile.Calamity().spawnedPlayerMinionDamageValue * + player.MinionDamage()); + projectile.damage = trueDamage; + } + bool isProperProjectile = projectile.type == ModContent.ProjectileType(); + player.AddBuff(ModContent.BuffType(), 3600); + if (isProperProjectile) + { + if (player.dead) + { + modPlayer.viridVanguard = false; + } + if (modPlayer.viridVanguard) + { + projectile.timeLeft = 2; + } + } + + if (FiringTime <= 0f) + { + projectile.ai[1]++; + float outwardPosition = 320f; + outwardPosition += (float)Math.Sin(Angle) * 200f; + projectile.Center = player.Center + Angle.ToRotationVector2().RotatedBy((float)Math.Cos(Angle) * MathHelper.PiOver4 + AltTexture.ToInt() * MathHelper.Pi) * outwardPosition; + projectile.rotation = player.AngleTo(projectile.Center) + MathHelper.PiOver4; + Angle += MathHelper.ToRadians(4f); + } + else + { + projectile.spriteDirection = 1; + if (FiringTime >= 239f) + { + RemainingSlices = projectile.penetrate = 3; + IdealPosition = player.Center - Vector2.UnitY.RotatedBy(RedirectAngle) * 550f; + } + else if (FiringTime > 120f) + { + projectile.Center = Vector2.Lerp(projectile.Center, IdealPosition, 1f / 40f); + projectile.rotation = projectile.rotation.AngleLerp(RedirectAngle + MathHelper.ToRadians(82f), 1f / 60f); + } + else if (FiringTime > 80f) + { + projectile.Center = IdealPosition; + projectile.rotation = projectile.rotation.AngleLerp(projectile.AngleTo(Main.MouseWorld) + MathHelper.ToRadians(82f), 1f / 20f); + } + else if (FiringTime == 80f) + { + PostSliceDeathTimer = 80; + projectile.velocity = projectile.SafeDirectionTo(Main.MouseWorld) * 30f; + } + else if (FiringTime == 1f) + { + if (RemainingSlices <= 0) + { + projectile.Kill(); + } + else if (RemainingSlices <= 2) + { + projectile.velocity *= -1; + FiringTime = 20f; + } + } + FiringTime--; + } + + if (RemainingSlices > 0) + PostSliceDeathTimer--; + if (PostSliceDeathTimer == 1) + projectile.Kill(); + + if (projectile.localAI[1] > 0) + { + projectile.alpha = (int)MathHelper.Lerp(255, 0, 1f - projectile.localAI[1] / 80f); + projectile.localAI[1]--; + } + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + if (RemainingSlices > 0) + { + FiringTime = 10f; + RemainingSlices--; + } + } + public override void Kill(int timeLeft) + { + for (int j = 0; j < 40; j++) + { + Dust dust = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 66); + dust.velocity = Vector2.UnitY * Main.rand.NextFloat(3f, 5.5f) * Main.rand.NextBool(2).ToDirectionInt(); + dust.noGravity = true; + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = ModContent.GetTexture("CalamityMod/Projectiles/Summon/ViridVanguardBlade" + (AltTexture ? "" : "Alt")); + + Rectangle rectangle = new Rectangle(0, 0, texture.Width, texture.Height); + + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + if (CalamityConfig.Instance.Afterimages && FiringTime > 0f && FiringTime < 80f) + { + for (int i = 0; i < projectile.oldPos.Length; i++) + { + Vector2 drawPos = projectile.oldPos[i] + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + Color color = Color.Lerp(Color.White, Color.DarkOliveGreen, i / (float)projectile.oldPos.Length) * + ((projectile.oldPos.Length - i) / (float)projectile.oldPos.Length); + float scale = MathHelper.Lerp(projectile.scale * 1f, projectile.scale * 0.5f, i / (float)projectile.oldPos.Length); + Main.spriteBatch.Draw(texture, drawPos, new Rectangle?(rectangle), color, + projectile.rotation, + rectangle.Size() / 2f, scale, spriteEffects, 0f); + } + } + Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Rectangle?(rectangle), Color.White, + projectile.rotation, + rectangle.Size() / 2f, 1f, spriteEffects, 0f); + return false; + } + } +} diff --git a/Projectiles/Summon/ViridVanguardBlade.png b/Projectiles/Summon/ViridVanguardBlade.png new file mode 100644 index 0000000000..400382aa1c Binary files /dev/null and b/Projectiles/Summon/ViridVanguardBlade.png differ diff --git a/Projectiles/Summon/ViridVanguardBladeAlt.png b/Projectiles/Summon/ViridVanguardBladeAlt.png new file mode 100644 index 0000000000..127ec26b1c Binary files /dev/null and b/Projectiles/Summon/ViridVanguardBladeAlt.png differ diff --git a/Projectiles/Summon/WitherBlossom.cs b/Projectiles/Summon/WitherBlossom.cs new file mode 100644 index 0000000000..94bf3ee576 --- /dev/null +++ b/Projectiles/Summon/WitherBlossom.cs @@ -0,0 +1,87 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class WitherBlossom : ModProjectile + { + public Player Owner => Main.player[projectile.owner]; + public ref float OffsetAngle => ref projectile.ai[0]; + public ref float Time => ref projectile.ai[1]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wither Blossom"); + 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 = 0.5f; + projectile.timeLeft = 90000; + projectile.penetrate = -1; + projectile.tileCollide = false; + projectile.minion = true; + } + + public override void AI() + { + bool isCorrectMinion = projectile.type == ModContent.ProjectileType(); + Player player = Main.player[projectile.owner]; + CalamityPlayer modPlayer = player.Calamity(); + player.AddBuff(ModContent.BuffType(), 3600); + if (isCorrectMinion) + { + if (player.dead) + modPlayer.witherBlossom = false; + if (modPlayer.witherBlossom) + projectile.timeLeft = 2; + } + + SetProjectileDamage(); + + Time++; + NPC potentialTarget = projectile.Center.MinionHoming(950f, Owner); + if (Time % 50 == 49 && Main.myPlayer == projectile.owner && potentialTarget != null) + { + Vector2 shootVelocity = projectile.SafeDirectionTo(potentialTarget.Center).RotatedByRandom(0.25f) * 8f; + Projectile.NewProjectile(projectile.Center, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + projectile.Center = player.Center + OffsetAngle.ToRotationVector2() * 150f; + projectile.rotation += MathHelper.ToRadians(5f); + OffsetAngle += MathHelper.ToRadians(4f); + } + + public void SetProjectileDamage() + { + if (projectile.localAI[0] == 0f) + { + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + for (int i = 0; i < 36; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, 179); + dust.noGravity = true; + dust.velocity = Main.rand.NextVector2Unit() * Main.rand.NextFloat(2f, 7f); + } + projectile.localAI[0] += 1f; + } + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + { + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / + projectile.Calamity().spawnedPlayerMinionDamageValue * + Owner.MinionDamage()); + projectile.damage = trueDamage; + } + } + + public override bool CanDamage() => false; + } +} diff --git a/Projectiles/Summon/WitherBlossom.png b/Projectiles/Summon/WitherBlossom.png new file mode 100644 index 0000000000..a0ba831dd4 Binary files /dev/null and b/Projectiles/Summon/WitherBlossom.png differ diff --git a/Projectiles/Summon/WitherBolt.cs b/Projectiles/Summon/WitherBolt.cs new file mode 100644 index 0000000000..fed98e329a --- /dev/null +++ b/Projectiles/Summon/WitherBolt.cs @@ -0,0 +1,97 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using CalamityMod.Projectiles.Melee; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Summon +{ + public class WitherBolt : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wither Bolt"); + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 25; + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.scale = 0.8f; + projectile.width = projectile.height = (int)(72 * projectile.scale); + projectile.friendly = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 180; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.penetrate = 2; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + } + public override void AI() + { + Lighting.AddLight(projectile.Center, Color.DarkGreen.ToVector3() * 1.25f); + float oldSpeed = projectile.velocity.Length(); + + NPC potentialTarget = projectile.Center.MinionHoming(800f, Main.player[projectile.owner]); + if (potentialTarget != null) + projectile.velocity = (projectile.velocity * 3f + projectile.SafeDirectionTo(potentialTarget.Center) * oldSpeed) / 4f; + projectile.velocity = projectile.velocity.SafeNormalize(Vector2.UnitY) * oldSpeed * 1.01f; + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + target.AddBuff(ModContent.BuffType(), 180); + projectile.Opacity = MathHelper.Lerp(projectile.Opacity, 0f, 0.25f); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D boltTexture = Main.projectileTexture[projectile.type]; + for (int i = 0; i < projectile.oldPos.Length; i++) + { + float completionRatio = i / (float)projectile.oldPos.Length; + Color drawColor = Color.Lerp(lightColor, Color.Olive, 0.6f); + drawColor = Color.Lerp(drawColor, Color.Black, completionRatio); + drawColor = Color.Lerp(drawColor, Color.Transparent, completionRatio); + + Vector2 drawPosition = projectile.oldPos[i] + projectile.Size * 0.5f - Main.screenPosition; + spriteBatch.Draw(boltTexture, drawPosition, null, projectile.GetAlpha(drawColor), projectile.oldRot[i], boltTexture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + return false; + } + + public override void Kill(int timeLeft) + { + if (!Main.dedServ) + { + for (int i = 0; i < projectile.oldPos.Length / 2; i++) + { + for (int j = 0; j < 2; j++) + { + Dust plague = Dust.NewDustDirect(projectile.oldPos[i], projectile.width / 2, projectile.height / 2, 107); + plague.velocity = (projectile.oldRot[i] - MathHelper.PiOver2).ToRotationVector2() * 4.5f + Main.rand.NextVector2Circular(2f, 2f); + plague.color = Color.Olive; + plague.noGravity = true; + } + } + } + + if (Main.myPlayer == projectile.owner) + { + for (int i = 0; i < 2; i++) + { + Vector2 spawnPosition = projectile.Center + Main.rand.NextVector2CircularEdge(8f, 8f); + int seeker = Projectile.NewProjectile(spawnPosition, Main.rand.NextVector2Circular(12f, 12f), ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + Main.projectile[seeker].Calamity().forceMinion = true; + } + } + } + } +} diff --git a/Projectiles/Summon/WitherBolt.png b/Projectiles/Summon/WitherBolt.png new file mode 100644 index 0000000000..0968156e79 Binary files /dev/null and b/Projectiles/Summon/WitherBolt.png differ diff --git a/Projectiles/Typeless/AllianceTriangle.cs b/Projectiles/Typeless/AllianceTriangle.cs new file mode 100644 index 0000000000..15547cb5fc --- /dev/null +++ b/Projectiles/Typeless/AllianceTriangle.cs @@ -0,0 +1,61 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class AllianceTriangle : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Alliance Triangle"); + } + + public override void SetDefaults() + { + projectile.width = 154; + projectile.height = 134; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.friendly = true; + projectile.penetrate = -1; + projectile.alpha = 254; + } + + public override void AI() + { + Player player = Main.player[projectile.owner]; + 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; + } + + 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 bool CanDamage() => false; + } +} diff --git a/Projectiles/Typeless/AllianceTriangle.png b/Projectiles/Typeless/AllianceTriangle.png new file mode 100644 index 0000000000..66f397a1f3 Binary files /dev/null and b/Projectiles/Typeless/AllianceTriangle.png differ diff --git a/Projectiles/Typeless/BobbitHead.cs b/Projectiles/Typeless/BobbitHead.cs index 9853d2c331..7ac1093342 100644 --- a/Projectiles/Typeless/BobbitHead.cs +++ b/Projectiles/Typeless/BobbitHead.cs @@ -9,6 +9,10 @@ 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"); @@ -38,10 +42,7 @@ namespace CalamityMod.Projectiles.Typeless } // Amethyst Hook is 300, Static Hook is 600, 16f = 1 tile - public override float GrappleRange() - { - return 640f; //40 tiles - } + public override float GrappleRange() => GrappleRangInTiles * 16f; public override void NumGrappleHooks(Player player, ref int numHooks) { @@ -51,12 +52,12 @@ namespace CalamityMod.Projectiles.Typeless // default is 11, Lunar is 24 public override void GrappleRetreatSpeed(Player player, ref float speed) { - speed = 28f; + speed = ReelbackSpeed; } public override void GrapplePullSpeed(Player player, ref float speed) { - speed = 24; + speed = PullSpeed; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Typeless/ChaosGeyser.cs b/Projectiles/Typeless/ChaosGeyser.cs index a1d57edc28..1fe2138a9a 100644 --- a/Projectiles/Typeless/ChaosGeyser.cs +++ b/Projectiles/Typeless/ChaosGeyser.cs @@ -102,16 +102,9 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return 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/CirrusOrb.cs b/Projectiles/Typeless/CirrusOrb.cs deleted file mode 100644 index 13bcddbfdc..0000000000 --- a/Projectiles/Typeless/CirrusOrb.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Typeless -{ - public class CirrusOrb : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Orb"); - } - - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 14; - projectile.friendly = true; - projectile.alpha = 255; - projectile.penetrate = -1; - projectile.timeLeft = 30; - projectile.magic = true; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.npcProj = true; - } - - public override void AI() - { - CalamityGlobalProjectile.MagnetSphereHitscan(projectile, 150f, 6f, 6f, 2, ModContent.ProjectileType()); - } - } -} diff --git a/Projectiles/Typeless/DarkIce.cs b/Projectiles/Typeless/DarkIce.cs index 8c278ec58d..beeadbbc90 100644 --- a/Projectiles/Typeless/DarkIce.cs +++ b/Projectiles/Typeless/DarkIce.cs @@ -51,13 +51,13 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Frostburn, 480); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Frostburn, 480); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override Color? GetAlpha(Color lightColor) diff --git a/Projectiles/Typeless/GodSlayerShrapnel.cs b/Projectiles/Typeless/GodSlayerShrapnel.cs index 050445914c..2323a36ea4 100644 --- a/Projectiles/Typeless/GodSlayerShrapnel.cs +++ b/Projectiles/Typeless/GodSlayerShrapnel.cs @@ -85,13 +85,6 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Typeless/HolyEruption.cs b/Projectiles/Typeless/HolyEruption.cs index 15ff0edadf..f4af993411 100644 --- a/Projectiles/Typeless/HolyEruption.cs +++ b/Projectiles/Typeless/HolyEruption.cs @@ -82,16 +82,9 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return 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(), 300); } diff --git a/Projectiles/Typeless/StandingFire.cs b/Projectiles/Typeless/StandingFire.cs index 7070969989..506625c457 100644 --- a/Projectiles/Typeless/StandingFire.cs +++ b/Projectiles/Typeless/StandingFire.cs @@ -89,16 +89,9 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return 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/TarraEnergy.cs b/Projectiles/Typeless/TarraEnergy.cs index da23fa7c71..19236f4bfc 100644 --- a/Projectiles/Typeless/TarraEnergy.cs +++ b/Projectiles/Typeless/TarraEnergy.cs @@ -13,29 +13,26 @@ namespace CalamityMod.Projectiles.Typeless public override void SetStaticDefaults() { - DisplayName.SetDefault("Round"); - ProjectileID.Sets.TrailCacheLength[projectile.type] = 3; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; + DisplayName.SetDefault("Tarra Energy"); } public override void SetDefaults() { - projectile.width = 8; - projectile.height = 8; - projectile.aiStyle = 1; + projectile.width = 4; + projectile.height = 4; projectile.friendly = true; projectile.penetrate = 1; - projectile.alpha = 255; - projectile.timeLeft = 120; + projectile.timeLeft = 200; projectile.extraUpdates = 1; - aiType = ProjectileID.Bullet; } + 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 = 5; + int cap = 2; int oldDamage = damage; if (projectileCount > cap) { @@ -45,40 +42,24 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Vector2 drawOrigin = new Vector2(Main.projectileTexture[projectile.type].Width * 0.5f, projectile.height * 0.5f); - for (int k = 0; k < projectile.oldPos.Length; k++) - { - Vector2 drawPos = projectile.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, projectile.gfxOffY); - Color color = projectile.GetAlpha(lightColor) * ((float)(projectile.oldPos.Length - k) / (float)projectile.oldPos.Length); - spriteBatch.Draw(Main.projectileTexture[projectile.type], drawPos, null, color, projectile.rotation, drawOrigin, projectile.scale, SpriteEffects.None, 0f); - } - return 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; + } - public override bool PreAI() - { - 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; - } - float num138 = (float)Math.Sqrt((double)(projectile.velocity.X * projectile.velocity.X + projectile.velocity.Y * projectile.velocity.Y)); - float num139 = projectile.localAI[0]; - if (num139 == 0f) - { - projectile.localAI[0] = num138; - } - return false; - } + if (projectile.timeLeft < 170) + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 600f, 9f, 20f); + } } } diff --git a/Projectiles/Typeless/TeslaAura.cs b/Projectiles/Typeless/TeslaAura.cs index 52dfd8e461..88df1972ad 100644 --- a/Projectiles/Typeless/TeslaAura.cs +++ b/Projectiles/Typeless/TeslaAura.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(BuffID.Electrified, 180); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); if (target.knockBackResist <= 0f) return; @@ -93,7 +93,7 @@ namespace CalamityMod.Projectiles.Typeless public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(BuffID.Electrified, 180); - target.AddBuff(ModContent.BuffType(), 120); + target.AddBuff(ModContent.BuffType(), 60); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Typeless/XerocFire.cs b/Projectiles/Typeless/XerocFire.cs index f3d8d7e5f1..4cb5481bcc 100644 --- a/Projectiles/Typeless/XerocFire.cs +++ b/Projectiles/Typeless/XerocFire.cs @@ -82,13 +82,6 @@ namespace CalamityMod.Projectiles.Typeless } } - public override bool OnTileCollide(Vector2 oldVelocity) - { - if (projectile.penetrate == 0) - { - projectile.Kill(); - } - return false; - } - } + public override bool OnTileCollide(Vector2 oldVelocity) => false; + } } diff --git a/Projectiles/Typeless/XerocStar.cs b/Projectiles/Typeless/XerocStar.cs index 46b806eee5..081c24808b 100644 --- a/Projectiles/Typeless/XerocStar.cs +++ b/Projectiles/Typeless/XerocStar.cs @@ -21,7 +21,8 @@ namespace CalamityMod.Projectiles.Typeless projectile.friendly = true; projectile.penetrate = 1; projectile.tileCollide = false; - projectile.timeLeft = 300; + projectile.ignoreWater = true; + projectile.timeLeft = 300; } public override void AI() diff --git a/Projectiles/Typeless/YanmeisKnifeSlash.cs b/Projectiles/Typeless/YanmeisKnifeSlash.cs index 395cc272fe..346fbfc9d2 100644 --- a/Projectiles/Typeless/YanmeisKnifeSlash.cs +++ b/Projectiles/Typeless/YanmeisKnifeSlash.cs @@ -4,6 +4,7 @@ using CalamityMod.Events; using CalamityMod.NPCs.AstrumDeus; using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Thanatos; using Microsoft.Xna.Framework; using System; using Terraria; @@ -20,7 +21,11 @@ namespace CalamityMod.Projectiles.Typeless 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() + && npc.type != ModContent.NPCType() + && npc.type != ModContent.NPCType(); if (validBoss) return true; bool bossMinion = CalamityLists.bossMinionList.Contains(npc.type); diff --git a/Skies/StormWeaverFlashSky.cs b/Skies/StormWeaverFlashSky.cs new file mode 100644 index 0000000000..6481e2987d --- /dev/null +++ b/Skies/StormWeaverFlashSky.cs @@ -0,0 +1,56 @@ +using CalamityMod.NPCs.StormWeaver; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; + +namespace CalamityMod.Skies +{ + public class StormWeaverFlashSky : CustomSky + { + public int StormWeaverHeadIndex = -1; + + public override void Update(GameTime gameTime) + { + int weaverType = ModContent.NPCType(); + if (StormWeaverHeadIndex >= 0 && Main.npc[StormWeaverHeadIndex].active && Main.npc[StormWeaverHeadIndex].type == weaverType) + return; + + StormWeaverHeadIndex = -1; + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && Main.npc[i].type == weaverType) + { + StormWeaverHeadIndex = i; + break; + } + } + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (maxDepth < float.MaxValue || !Main.npc.IndexInRange(StormWeaverHeadIndex)) + return; + + // Draw lightning in the background based on Main.magicPixel. + // It is a long, white vertical strip that exists for some reason. + // This lightning effect is achieved by expanding this to fit the entire background and then drawing it as a distinct element. + float lightningFlashPower = (Main.npc[StormWeaverHeadIndex].modNPC as StormWeaverHeadNaked).lightning; + Vector2 scale = new Vector2(Main.screenWidth * 1.1f / Main.magicPixel.Width, Main.screenHeight * 1.1f / Main.magicPixel.Height); + Vector2 screenCenter = new Vector2(Main.screenWidth, Main.screenHeight) * 0.5f; + Color drawColor = Color.White * MathHelper.Lerp(0f, 0.88f, lightningFlashPower); + + for (int i = 0; i < 2; i++) + spriteBatch.Draw(Main.magicPixel, screenCenter, null, drawColor, 0f, Main.magicPixel.Size() * 0.5f, scale, SpriteEffects.None, 0f); + } + + public override void Reset() { } + + public override void Activate(Vector2 position, params object[] args) { } + + public override void Deactivate(params object[] args) { } + + public override bool IsActive() => StormWeaverHeadIndex != -1 && !Main.gameMenu; + } +} diff --git a/Sounds/Custom/AngelicAllianceActivation.cs b/Sounds/Custom/AngelicAllianceActivation.cs new file mode 100644 index 0000000000..2df6ffa472 --- /dev/null +++ b/Sounds/Custom/AngelicAllianceActivation.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class AngelicAllianceActivation : 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/AngelicAllianceActivation.ogg b/Sounds/Custom/AngelicAllianceActivation.ogg new file mode 100644 index 0000000000..db9575fa65 Binary files /dev/null and b/Sounds/Custom/AngelicAllianceActivation.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PBGAttackSwitch1.cs b/Sounds/Custom/PlagueSounds/PBGAttackSwitch1.cs new file mode 100644 index 0000000000..ba5b5437dc --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PBGAttackSwitch1.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PBGAttackSwitch1 : 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/PlagueSounds/PBGAttackSwitch1.ogg b/Sounds/Custom/PlagueSounds/PBGAttackSwitch1.ogg new file mode 100644 index 0000000000..69a654c63c Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PBGAttackSwitch1.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PBGAttackSwitch2.cs b/Sounds/Custom/PlagueSounds/PBGAttackSwitch2.cs new file mode 100644 index 0000000000..d5413dea03 --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PBGAttackSwitch2.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PBGAttackSwitch2 : 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/PlagueSounds/PBGAttackSwitch2.ogg b/Sounds/Custom/PlagueSounds/PBGAttackSwitch2.ogg new file mode 100644 index 0000000000..54cb0b0662 Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PBGAttackSwitch2.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PBGBarrageLaunch.cs b/Sounds/Custom/PlagueSounds/PBGBarrageLaunch.cs new file mode 100644 index 0000000000..f02f87dad1 --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PBGBarrageLaunch.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PBGBarrageLaunch : 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/PlagueSounds/PBGBarrageLaunch.ogg b/Sounds/Custom/PlagueSounds/PBGBarrageLaunch.ogg new file mode 100644 index 0000000000..02e72e7388 Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PBGBarrageLaunch.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PBGDash.cs b/Sounds/Custom/PlagueSounds/PBGDash.cs new file mode 100644 index 0000000000..04e5d76618 --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PBGDash.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PBGDash : 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/PlagueSounds/PBGDash.ogg b/Sounds/Custom/PlagueSounds/PBGDash.ogg new file mode 100644 index 0000000000..d16923cd0b Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PBGDash.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PBGNukeWarning.cs b/Sounds/Custom/PlagueSounds/PBGNukeWarning.cs new file mode 100644 index 0000000000..05487222f3 --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PBGNukeWarning.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PBGNukeWarning : 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/PlagueSounds/PBGNukeWarning.ogg b/Sounds/Custom/PlagueSounds/PBGNukeWarning.ogg new file mode 100644 index 0000000000..9e0fc4077a Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PBGNukeWarning.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PlagueBoom1.cs b/Sounds/Custom/PlagueSounds/PlagueBoom1.cs new file mode 100644 index 0000000000..5b9254ea8b --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PlagueBoom1.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PlagueBoom1 : 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/PlagueSounds/PlagueBoom1.ogg b/Sounds/Custom/PlagueSounds/PlagueBoom1.ogg new file mode 100644 index 0000000000..71f1ef82f9 Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PlagueBoom1.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PlagueBoom2.cs b/Sounds/Custom/PlagueSounds/PlagueBoom2.cs new file mode 100644 index 0000000000..9a864fe308 --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PlagueBoom2.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PlagueBoom2 : 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/PlagueSounds/PlagueBoom2.ogg b/Sounds/Custom/PlagueSounds/PlagueBoom2.ogg new file mode 100644 index 0000000000..f74b47d4d5 Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PlagueBoom2.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PlagueBoom3.cs b/Sounds/Custom/PlagueSounds/PlagueBoom3.cs new file mode 100644 index 0000000000..b13ab47ede --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PlagueBoom3.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PlagueBoom3 : 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/PlagueSounds/PlagueBoom3.ogg b/Sounds/Custom/PlagueSounds/PlagueBoom3.ogg new file mode 100644 index 0000000000..b2bb1c78db Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PlagueBoom3.ogg differ diff --git a/Sounds/Custom/PlagueSounds/PlagueBoom4.cs b/Sounds/Custom/PlagueSounds/PlagueBoom4.cs new file mode 100644 index 0000000000..5bb6a468ad --- /dev/null +++ b/Sounds/Custom/PlagueSounds/PlagueBoom4.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.PlagueSounds +{ + public class PlagueBoom4 : 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/PlagueSounds/PlagueBoom4.ogg b/Sounds/Custom/PlagueSounds/PlagueBoom4.ogg new file mode 100644 index 0000000000..4064c083da Binary files /dev/null and b/Sounds/Custom/PlagueSounds/PlagueBoom4.ogg differ diff --git a/Sounds/Custom/SupremeCalamitasSpawn.cs b/Sounds/Custom/SupremeCalamitasSpawn.cs new file mode 100644 index 0000000000..48a6293bae --- /dev/null +++ b/Sounds/Custom/SupremeCalamitasSpawn.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class SupremeCalamitasSpawn : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume * 1.2f; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/SupremeCalamitasSpawn.ogg b/Sounds/Custom/SupremeCalamitasSpawn.ogg new file mode 100644 index 0000000000..eaf7921f2e Binary files /dev/null and b/Sounds/Custom/SupremeCalamitasSpawn.ogg differ diff --git a/Sounds/Custom/ThanatosVent.cs b/Sounds/Custom/ThanatosVent.cs new file mode 100644 index 0000000000..0f1a0799d7 --- /dev/null +++ b/Sounds/Custom/ThanatosVent.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class ThanatosVent : 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/ThanatosVent.ogg b/Sounds/Custom/ThanatosVent.ogg new file mode 100644 index 0000000000..df12e263a2 Binary files /dev/null and b/Sounds/Custom/ThanatosVent.ogg differ diff --git a/Sounds/Custom/YharonFire.cs b/Sounds/Custom/YharonFire.cs new file mode 100644 index 0000000000..41c010f6b6 --- /dev/null +++ b/Sounds/Custom/YharonFire.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom +{ + public class YharonFire : 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/YharonFire.ogg b/Sounds/Custom/YharonFire.ogg new file mode 100644 index 0000000000..e1684f2f2f Binary files /dev/null and b/Sounds/Custom/YharonFire.ogg differ diff --git a/Tiles/Astral/AstralBeacon.cs b/Tiles/Astral/AstralBeacon.cs index d96b508ddd..70285acf2c 100644 --- a/Tiles/Astral/AstralBeacon.cs +++ b/Tiles/Astral/AstralBeacon.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Tiles.Astral ritualSpawnPosition += new Vector2(0f, -24f); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/AstralBeaconUse"), ritualSpawnPosition); - Projectile.NewProjectile(ritualSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + Projectile.NewProjectile(ritualSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, 0f, usingStarcore.ToInt()); if (!usingStarcore) Main.LocalPlayer.ConsumeItem(ModContent.ItemType(), true); diff --git a/Tiles/SCalAltar.cs b/Tiles/SCalAltar.cs new file mode 100644 index 0000000000..74239da3d5 --- /dev/null +++ b/Tiles/SCalAltar.cs @@ -0,0 +1,112 @@ +using CalamityMod.Events; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables; +using CalamityMod.Items.SummonItems; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles +{ + public class SCalAltar : ModTile + { + public const int Width = 4; + public const int Height = 3; + public override void SetDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSpelunker[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style2x2); + TileObjectData.newTile.Width = 4; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.Origin = new Point16(1, 2); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + TileObjectData.newTile.DrawYOffset = 2; + TileObjectData.newTile.StyleHorizontal = true; + TileObjectData.newTile.LavaDeath = false; + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("Altar"); + AddMapEntry(new Color(43, 19, 42), name); + disableSmartCursor = true; + } + + public override bool CanExplode(int i, int j) => false; + + public override bool CreateDust(int i, int j, ref int type) + { + // Fire dust. + type = 6; + return true; + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, Width * 16, Height * 16, ModContent.ItemType()); + } + + public override bool NewRightClick(int i, int j) + { + Tile tile = Main.tile[i, j]; + + int left = i - tile.frameX / 18; + int top = j - tile.frameY / 18; + + if (!Main.LocalPlayer.HasItem(ModContent.ItemType()) && + !Main.LocalPlayer.HasItem(ModContent.ItemType())) + { + return true; + } + + if (NPC.AnyNPCs(ModContent.NPCType()) || BossRushEvent.BossRushActive) + return true; + + if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) > 0) + return true; + + bool usingSpecialItem = Main.LocalPlayer.HasItem(ModContent.ItemType()); + + Vector2 ritualSpawnPosition = new Vector2(left + Width / 2, top).ToWorldCoordinates(); + ritualSpawnPosition += new Vector2(-10f, -24f); + + Main.PlaySound(SoundID.DD2_EtherianPortalOpen, ritualSpawnPosition); + Projectile.NewProjectile(ritualSpawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, Main.myPlayer); + + if (!usingSpecialItem) + Main.LocalPlayer.ConsumeItem(ModContent.ItemType(), true); + + return true; + } + + public override void MouseOver(int i, int j) + { + if (Main.LocalPlayer.HasItem(ModContent.ItemType())) + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + else + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + + Main.LocalPlayer.noThrow = 2; + Main.LocalPlayer.showItemIcon = true; + } + + public override void MouseOverFar(int i, int j) + { + if (Main.LocalPlayer.HasItem(ModContent.ItemType())) + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + else + Main.LocalPlayer.showItemIcon2 = ModContent.ItemType(); + + Main.LocalPlayer.noThrow = 2; + Main.LocalPlayer.showItemIcon = true; + } + } +} diff --git a/Tiles/SCalAltar.png b/Tiles/SCalAltar.png new file mode 100644 index 0000000000..430144741e Binary files /dev/null and b/Tiles/SCalAltar.png differ diff --git a/TrailGeneration/PrimitiveTrail.cs b/TrailGeneration/PrimitiveTrail.cs index 707c0e8845..789f726bf6 100644 --- a/TrailGeneration/PrimitiveTrail.cs +++ b/TrailGeneration/PrimitiveTrail.cs @@ -42,9 +42,6 @@ namespace CalamityMod public MiscShaderData SpecialShader; public TrailPointRetrievalFunction TrailPointFunction; - public DynamicIndexBuffer IndexBuffer = null; - public DynamicVertexBuffer VertexBuffer = null; - public delegate List TrailPointRetrievalFunction(IEnumerable originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable originalRotations = null); public PrimitiveTrail(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, TrailPointRetrievalFunction pointFunction = null, MiscShaderData specialShader = null) @@ -201,10 +198,6 @@ namespace CalamityMod vertices[i * 2 + 1] = new VertexPosition2DColor(currentPosition + sideDirection * widthAtVertex, vertexColor, rightCurrentTextureCoord); } - if (VertexBuffer is null || vertices.Length != VertexBuffer.VertexCount) - VertexBuffer = new DynamicVertexBuffer(Main.instance.GraphicsDevice, typeof(VertexPosition2DColor), vertices.Length, BufferUsage.WriteOnly); - VertexBuffer.SetData(vertices); - return vertices.ToArray(); } @@ -230,10 +223,6 @@ namespace CalamityMod indices[startingTriangleIndex + 5] = (short)(connectToIndex + 3); } - if (IndexBuffer is null || indices.Length != IndexBuffer.IndexCount) - IndexBuffer = new DynamicIndexBuffer(Main.instance.GraphicsDevice, typeof(short), indices.Length, BufferUsage.WriteOnly); - IndexBuffer.SetData(indices); - return indices; } @@ -243,13 +232,17 @@ namespace CalamityMod List trailPoints = TrailPointFunction(originalPositions, generalOffset, totalTrailPoints, originalRotations); // A trail with only one point or less has nothing to connect to, and therefore, can't make a trail. - if (originalPositions.Count() <= 2 || trailPoints.Count <= 2) + if (trailPoints.Count <= 2) return; - // If the trail point has any NaN positions, don't draw anything. + // If the trail points have any NaN positions, don't draw anything. if (trailPoints.Any(point => point.HasNaNs())) return; + // If the trail points are all equal, don't draw anything. + if (trailPoints.All(point => point == trailPoints[0])) + return; + UpdateBaseEffect(out Matrix projection, out Matrix view); VertexPosition2DColor[] vertices = GetVerticesFromTrailPoints(trailPoints); @@ -268,10 +261,7 @@ namespace CalamityMod else BaseEffect.CurrentTechnique.Passes[0].Apply(); - Main.instance.GraphicsDevice.Indices = IndexBuffer; - Main.instance.GraphicsDevice.SetVertexBuffer(VertexBuffer); - Main.instance.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, triangleIndices.Length / 3); - + Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, triangleIndices, 0, triangleIndices.Length / 3); Main.pixelShader.CurrentTechnique.Passes[0].Apply(); } } diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index f17f26db62..5c5cdae84a 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -6,6 +6,7 @@ using CalamityMod.NPCs.Calamitas; using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.GreatSandShark; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.Perforator; @@ -102,11 +103,6 @@ namespace CalamityMod.UI OneToMany[NPCID.BrainofCthulhu] = BoC; OneToMany[NPCID.Creeper] = BoC; - int[] PerfWorm = new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }; - OneToMany[ModContent.NPCType()] = PerfWorm; - OneToMany[ModContent.NPCType()] = PerfWorm; - OneToMany[ModContent.NPCType()] = PerfWorm; - int[] Skele = new int[] { NPCID.SkeletronHead, NPCID.SkeletronHand }; OneToMany[NPCID.SkeletronHead] = Skele; OneToMany[NPCID.SkeletronHand] = Skele; @@ -139,11 +135,9 @@ namespace CalamityMod.UI OneToMany[NPCID.MoonLordHand] = MoonLord; OneToMany[NPCID.MoonLordCore] = MoonLord; - int[] Void = new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }; + int[] Void = new int[] { ModContent.NPCType(), ModContent.NPCType() }; OneToMany[ModContent.NPCType()] = Void; OneToMany[ModContent.NPCType()] = Void; - OneToMany[ModContent.NPCType()] = Void; - OneToMany[ModContent.NPCType()] = Void; int[] Rav = new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }; @@ -194,8 +188,11 @@ namespace CalamityMod.UI ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), - ModContent.NPCType() - }; + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType() + }; } private static void SetupMinibossHPBarList() @@ -387,10 +384,10 @@ namespace CalamityMod.UI break; } - // Sort out the eater of worlds or medium perf worm splitting into multiple segments and multiple of them being heads - if (type == NPCID.EaterofWorldsHead || type == ModContent.NPCType()) + // Sort out the eater of worlds splitting into multiple segments and multiple of them being heads + if (type == NPCID.EaterofWorldsHead) { - if (Main.npc[id].type == NPCID.EaterofWorldsHead || Main.npc[id].type == ModContent.NPCType()) + if (Main.npc[id].type == NPCID.EaterofWorldsHead) { hasBar = true; } @@ -467,6 +464,9 @@ namespace CalamityMod.UI private bool _inCombo = false; private int _comboStartHealth; private int _damageCountdown; + public int EnrageTimer; + public int AttachedNPCType = -1; + private NPC _npc { get @@ -530,6 +530,7 @@ namespace CalamityMod.UI _npcLocation = id; _maxHealth = Main.npc[id].lifeMax; + AttachedNPCType = Main.npc[id].type; if (OneToMany.ContainsKey(Main.npc[id].type)) { @@ -560,7 +561,10 @@ namespace CalamityMod.UI dead = true; int life = _npc.life; - if (life < 0 || !_npc.active || _npc.lifeMax < 800) + + // NPCs appear to be able to occasionally be replaced by a new NPC faster than the bar can register the death of the last NPC. + // To midigate this, a special type check is put in place to catch unusual NPCs occupying the space of a would-be dead bar. + if (life < 0 || !_npc.active || _npc.lifeMax < 100 || _npc.type != AttachedNPCType) dead = true; if (_oneToMany) @@ -588,6 +592,7 @@ namespace CalamityMod.UI return; int currentLife = _npc.life; + bool enraged = _npc.active && _npc.Calamity().CurrentlyEnraged; // Calculate current life based all types that are available and considered part of one boss if (_oneToMany) @@ -603,6 +608,9 @@ namespace CalamityMod.UI (Main.npc[i].type == NPCID.MoonLordCore && Main.npc[i].ai[0] == 2f)) continue; + if (Main.npc[i].Calamity().CurrentlyEnraged) + enraged = true; + currentLife += Main.npc[i].life; maxLife += Main.npc[i].lifeMax; } @@ -613,6 +621,9 @@ namespace CalamityMod.UI } } + // Make the enrage counter go up/down based on whether the boss is enraged or not. + EnrageTimer = Utils.Clamp(EnrageTimer + enraged.ToDirectionInt(), 0, 75); + // Damage countdown if (_damageCountdown > 0) { @@ -682,9 +693,7 @@ namespace CalamityMod.UI default: break; case SpecialType2.Ceaseless: - int count = NPC.CountNPCS(ModContent.NPCType()) + - NPC.CountNPCS(ModContent.NPCType()) + - NPC.CountNPCS(ModContent.NPCType()); + int count = NPC.CountNPCS(ModContent.NPCType()); _specialData2[0] = count; break; case SpecialType2.Ravage: @@ -742,17 +751,29 @@ namespace CalamityMod.UI sb.Draw(BossMainHPBar, new Rectangle(x, y + MainBarYOffset, mainBarWidth, 15), Color.White); // DRAW WHITE(ISH) LINE - sb.Draw(BossSeperatorBar, new Rectangle(x, y + SepBarYOffset, BarMaxWidth, 6), new Color(240, 240, 255)); + Color separatorColor = Color.Lerp(new Color(240, 240, 255), Color.Red * 0.5f, EnrageTimer / 75f); + sb.Draw(BossSeperatorBar, new Rectangle(x, y + SepBarYOffset, BarMaxWidth, 6), separatorColor); // DRAW TEXT string percentHealthText = (percentHealth * 100).ToString("N1") + "%"; if (_prevLife == _maxHealth) percentHealthText = "100%"; Vector2 textSize = HPBarFont.MeasureString(percentHealthText); + DrawBorderStringEightWay(sb, HPBarFont, percentHealthText, new Vector2(x, y + 22 - textSize.Y), OrangeColour, OrangeBorderColour * 0.25f); string name = _npc.FullName; Vector2 nameSize = Main.fontMouseText.MeasureString(name); + if (EnrageTimer > 0) + { + float pulse = (float)Math.Sin(Main.GlobalTime * 4.5f) * 0.5f + 0.5f; + float outwardness = EnrageTimer / 75f * 1.5f + pulse * 2f; + for (int i = 0; i < 4; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * outwardness; + DrawBorderStringEightWay(sb, Main.fontMouseText, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y) + drawOffset, Color.Red * 0.6f, Color.Black * 0.2f); + } + } DrawBorderStringEightWay(sb, Main.fontMouseText, name, new Vector2(x + BarMaxWidth - nameSize.X, y + 23 - nameSize.Y), Color.White, Color.Black * 0.2f); // TODO -- Make small text health a toggle in ModConfig. diff --git a/UI/RipperUI.cs b/UI/RipperUI.cs index aaa160648b..77531b44e3 100644 --- a/UI/RipperUI.cs +++ b/UI/RipperUI.cs @@ -258,7 +258,8 @@ namespace CalamityMod.UI if (rageHover && !adrenHover) { // Add hover text if the mouse is over Rage bar - Main.LocalPlayer.mouseInterface = true; + if (!CalamityConfig.Instance.MeterPosLock) + Main.LocalPlayer.mouseInterface = true; string rageStr = MakeRipperPercentString(modPlayer.rage, modPlayer.rageMax); Main.instance.MouseText($"Rage: {rageStr}"); @@ -273,7 +274,8 @@ namespace CalamityMod.UI else if (adrenHover) { // Add hover text if the mouse is over the bar - Main.LocalPlayer.mouseInterface = true; + if (!CalamityConfig.Instance.MeterPosLock) + Main.LocalPlayer.mouseInterface = true; string adrenStr = MakeRipperPercentString(modPlayer.adrenaline, modPlayer.adrenalineMax); Main.instance.MouseText($"Adrenaline: {adrenStr}"); diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 56bb0a45cb..120f2af03a 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -1048,7 +1048,7 @@ namespace CalamityMod }); RecipeGroup.RegisterGroup("AnyIceBlock", group); - group = new RecipeGroup(() => "Any Snow Block", new int[] + group = new RecipeGroup(() => "Any Snow Block", new int[] { ItemID.SnowBlock, ModContent.ItemType() @@ -1063,6 +1063,33 @@ namespace CalamityMod }); RecipeGroup.RegisterGroup("SiltGroup", group); + group = new RecipeGroup(() => "Any Hallowed Helmet", new int[] + { + ItemID.HallowedHelmet, + ItemID.HallowedHeadgear, + ItemID.HallowedMask/*, + ItemID.HallowedHood, + ItemID.AncientHallowedHelmet, + ItemID.AncientHallowedHeadgear, + ItemID.AncientHallowedMask, + ItemID.AncientHallowedHood*/ + }); + RecipeGroup.RegisterGroup("AnyHallowedHelmet", group); + + /*group = new RecipeGroup(() => "Any Hallowed Platemail", new int[] + { + ItemID.HallowedPlateMail, + ItemID.AncientHallowedPlateMail + }); + RecipeGroup.RegisterGroup("AnyHallowedPlatemail", group); + + group = new RecipeGroup(() => "Any Hallowed Greaves", new int[] + { + ItemID.HallowedGreaves, + ItemID.AncientHallowedGreaves + }); + RecipeGroup.RegisterGroup("AnyHallowedGreaves", group);*/ + group = new RecipeGroup(() => "Any Hardmode Anvil", new int[] { ItemID.MythrilAnvil, @@ -1130,43 +1157,43 @@ namespace CalamityMod group = new RecipeGroup(() => "Any Wings", new int[] { - ItemID.DemonWings, - ItemID.AngelWings, - ItemID.RedsWings, - ItemID.ButterflyWings, - ItemID.FairyWings, - ItemID.HarpyWings, - ItemID.BoneWings, - ItemID.FlameWings, - ItemID.FrozenWings, - ItemID.GhostWings, - ItemID.SteampunkWings, - ItemID.LeafWings, - ItemID.BatWings, - ItemID.BeeWings, - ItemID.DTownsWings, - ItemID.WillsWings, - ItemID.CrownosWings, - ItemID.CenxsWings, - ItemID.TatteredFairyWings, - ItemID.SpookyWings, - ItemID.Hoverboard, - ItemID.FestiveWings, - ItemID.BeetleWings, - ItemID.FinWings, - ItemID.FishronWings, - ItemID.MothronWings, - ItemID.WingsSolar, - ItemID.WingsVortex, - ItemID.WingsNebula, - ItemID.WingsStardust, - ItemID.Yoraiz0rWings, - ItemID.JimsWings, - ItemID.SkiphsWings, - ItemID.LokisWings, - ItemID.BetsyWings, - ItemID.ArkhalisWings, - ItemID.LeinforsWings, + ItemID.DemonWings, + ItemID.AngelWings, + ItemID.RedsWings, + ItemID.ButterflyWings, + ItemID.FairyWings, + ItemID.HarpyWings, + ItemID.BoneWings, + ItemID.FlameWings, + ItemID.FrozenWings, + ItemID.GhostWings, + ItemID.SteampunkWings, + ItemID.LeafWings, + ItemID.BatWings, + ItemID.BeeWings, + ItemID.DTownsWings, + ItemID.WillsWings, + ItemID.CrownosWings, + ItemID.CenxsWings, + ItemID.TatteredFairyWings, + ItemID.SpookyWings, + ItemID.Hoverboard, + ItemID.FestiveWings, + ItemID.BeetleWings, + ItemID.FinWings, + ItemID.FishronWings, + ItemID.MothronWings, + ItemID.WingsSolar, + ItemID.WingsVortex, + ItemID.WingsNebula, + ItemID.WingsStardust, + ItemID.Yoraiz0rWings, + ItemID.JimsWings, + ItemID.SkiphsWings, + ItemID.LokisWings, + ItemID.BetsyWings, + ItemID.ArkhalisWings, + ItemID.LeinforsWings, ItemID.BejeweledValkyrieWing, /* ItemID.GhostarsWings, @@ -1177,14 +1204,14 @@ namespace CalamityMod ItemID.RainbowWings, ItemID.LongRainbowTrailWings, */ - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType(), - ModContent.ItemType() + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType(), + ModContent.ItemType() }); RecipeGroup.RegisterGroup("WingsGroup", group); } diff --git a/Utilities/CollisionUtils.cs b/Utilities/CollisionUtils.cs new file mode 100644 index 0000000000..2ba78d6163 --- /dev/null +++ b/Utilities/CollisionUtils.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +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; + + // 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 _); + } + } +} diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index f095b873b8..697e5f7931 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -4,8 +4,10 @@ using System; using System.Reflection; using System.Text; using Terraria; +using Terraria.DataStructures; using Terraria.Graphics.Shaders; using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod { @@ -437,5 +439,29 @@ namespace CalamityMod spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); } + + public static void DrawAuroras(Player player, float auroraCount, float opacity, Color color) + { + float time = Main.GlobalTime % 3f / 3f; + Texture2D auroraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AuroraTexture"); + for (int i = 0; i < auroraCount; i++) + { + float incrementOffsetAngle = MathHelper.TwoPi * i / auroraCount; + float xOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f) * 20f; + float yOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f + MathHelper.ToRadians(60f)) * 6f; + float rotation = (float)Math.Sin(incrementOffsetAngle) * MathHelper.Pi / 12f; + Vector2 offset = new Vector2(xOffset, yOffset - 14f); + DrawData drawData = new DrawData(auroraTexture, + player.Top + offset - Main.screenPosition, + null, + color * opacity, + rotation + MathHelper.PiOver2, + auroraTexture.Size() * 0.5f, + 0.135f, + SpriteEffects.None, + 1); + Main.playerDrawData.Add(drawData); + } + } } } diff --git a/Utilities/MathematicalUtils.cs b/Utilities/MathematicalUtils.cs index 05680c8b33..797a623508 100644 --- a/Utilities/MathematicalUtils.cs +++ b/Utilities/MathematicalUtils.cs @@ -20,6 +20,14 @@ namespace CalamityMod /// The second vector. public static float AngleBetween(this Vector2 v1, Vector2 v2) => (float)Math.Acos(Vector2.Dot(v1.SafeNormalize(Vector2.Zero), v2.SafeNormalize(Vector2.Zero))); + // NOTE: A similar function to this one exists in 1.4, but it is not the same underlying function. Check Turn01ToCyclic010 in Utils.cs to see the effect. + + /// + /// Converts a 0-1 bound to a 0-1-0 bump. This function automatically clamps the value to the necessary 0-1 range. + /// + /// The value to convert. + public static float Convert01To010(float value) => (float)Math.Sin(MathHelper.Pi * MathHelper.Clamp(value, 0f, 1f)); + /// /// Uses a rewritten horizontal range formula to determine the direction to fire a projectile in order for it to hit a destination. Falls back on a certain value if no such direction can exist. If no fallback is provided, a clamp is used. /// @@ -61,5 +69,16 @@ namespace CalamityMod int num4 = Math.Max(0, Math.Min(tileRectangle.Bottom, Main.maxTilesY)); return new Rectangle(num, num2, num3 - num, num4 - num2); } + + // REMOVE THIS IN CALAMITY 1.4, it's a 1.4 Utils.cs function. + // Due to its temporary state, this method will not receive an XML documentation comment. + public static Vector2 MoveTowards(this Vector2 currentPosition, Vector2 targetPosition, float maxAmountAllowedToMove) + { + Vector2 v = targetPosition - currentPosition; + if (v.Length() < maxAmountAllowedToMove) + return targetPosition; + + return currentPosition + v.SafeNormalize(Vector2.Zero) * maxAmountAllowedToMove; + } } } diff --git a/Utilities/MiscUtils.cs b/Utilities/MiscUtils.cs index 4f8815c2a0..12b400734c 100644 --- a/Utilities/MiscUtils.cs +++ b/Utilities/MiscUtils.cs @@ -10,6 +10,7 @@ using System.Text; using Terraria; using Terraria.ID; using Terraria.Localization; +using Terraria.ModLoader; namespace CalamityMod { @@ -144,7 +145,7 @@ namespace CalamityMod (sfx.Volume, sfx.Pan) = CalculateSoundStats(soundPos, ambient); } - public static void StartRain(bool torrentialTear = false) + public static void StartRain(bool torrentialTear = false, bool maxSeverity = false) { int num = 86400; int num2 = num / 24; @@ -193,7 +194,7 @@ namespace CalamityMod Main.rainTime = (int)(Main.rainTime * num3); Main.raining = true; if (torrentialTear) - TorrentialTear.AdjustRainSeverity(false); + TorrentialTear.AdjustRainSeverity(maxSeverity); CalamityNetcode.SyncWorld(); } @@ -221,34 +222,58 @@ namespace CalamityMod /// /// The spot to spawn the explosion clouds /// Number of times it loops to spawn gores - public static void ExplosionGores(Vector2 goreSource, int goreAmt) + public static void ExplosionGores(Vector2 goreSource, int goreAmt, bool thanatos = false, Vector2 thanatosVelocity = default) { Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) { float velocityMult = 0.33f; - if (goreIndex < (int)(goreAmt / 3)) + if (goreIndex < (goreAmt / 3)) { velocityMult = 0.66f; } - if (goreIndex >= (int)((2 * goreAmt) / 3)) + if (goreIndex >= (2 * goreAmt / 3)) { velocityMult = 1f; } - int smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + Mod mod = ModContent.GetInstance(); + int type = thanatos ? Main.rand.Next(mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle1"), mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle3") + 1) : Main.rand.Next(61, 64); + int smoke = Gore.NewGore(source, default, type, 1f); Gore gore = Main.gore[smoke]; + if (thanatos) + { + gore.velocity = thanatosVelocity * -0.5f; + } gore.velocity *= velocityMult; gore.velocity.X += 1f; gore.velocity.Y += 1f; - smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + type = thanatos ? Main.rand.Next(mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle1"), mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle3") + 1) : Main.rand.Next(61, 64); + smoke = Gore.NewGore(source, default, type, 1f); + gore = Main.gore[smoke]; + if (thanatos) + { + gore.velocity = thanatosVelocity * -0.5f; + } gore.velocity *= velocityMult; gore.velocity.X -= 1f; gore.velocity.Y += 1f; - smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + type = thanatos ? Main.rand.Next(mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle1"), mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle3") + 1) : Main.rand.Next(61, 64); + smoke = Gore.NewGore(source, default, type, 1f); + gore = Main.gore[smoke]; + if (thanatos) + { + gore.velocity = thanatosVelocity * -0.5f; + } gore.velocity *= velocityMult; gore.velocity.X += 1f; gore.velocity.Y -= 1f; - smoke = Gore.NewGore(source, default, Main.rand.Next(61, 64), 1f); + type = thanatos ? Main.rand.Next(mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle1"), mod.GetGoreSlot("Gores/Thanatos/ThanatosVentParticle3") + 1) : Main.rand.Next(61, 64); + smoke = Gore.NewGore(source, default, type, 1f); + gore = Main.gore[smoke]; + if (thanatos) + { + gore.velocity = thanatosVelocity * -0.5f; + } gore.velocity *= velocityMult; gore.velocity.X -= 1f; gore.velocity.Y -= 1f; diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index 762d6e8149..794f7ce459 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -12,10 +12,12 @@ using CalamityMod.NPCs.CeaselessVoid; using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.PlaguebringerGoliath; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.Polterghast; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; @@ -109,6 +111,9 @@ namespace CalamityMod { 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 }) }, + // She resists the cold because of her ice-related abilities. { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.iceEnemyImmunities) }, @@ -130,6 +135,11 @@ namespace CalamityMod { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, + { 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) }, @@ -141,8 +151,6 @@ namespace CalamityMod { 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[] { }) }, @@ -188,6 +196,16 @@ namespace CalamityMod { 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.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.sulphurEnemyImmunities) }, @@ -255,10 +273,6 @@ namespace CalamityMod { 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(false, CalamityMod.abyssEnemyImmunities) }, diff --git a/Utilities/NPCStats.cs b/Utilities/NPCStats.cs index 62a579bd7a..5709e12e23 100644 --- a/Utilities/NPCStats.cs +++ b/Utilities/NPCStats.cs @@ -1,4 +1,5 @@ using CalamityMod.NPCs; +using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AquaticScourge; using CalamityMod.NPCs.AstrumAureus; using CalamityMod.NPCs.AstrumDeus; @@ -10,6 +11,7 @@ using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.HiveMind; using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; @@ -280,7 +282,14 @@ namespace CalamityMod { 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 @@ -490,8 +499,6 @@ namespace CalamityMod { ModContent.NPCType(), new int[] { 150, 300, 330, 348, 450 } }, { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 360 } }, - { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 360 } }, - { ModContent.NPCType(), new int[] { 120, 240, 264, 278, 360 } }, { ModContent.NPCType(), new int[] { 140, 280, 308, 324, 420 } }, { ModContent.NPCType(), new int[] { 100, 160, 192, 208, 300 } }, @@ -535,7 +542,14 @@ namespace CalamityMod { ModContent.NPCType(), new int[] { 100, 200, 220, 232, 300 } }, { ModContent.NPCType(), new int[] { 220, 440, 462, 476, 540 } }, - { ModContent.NPCType(), new int[] { 350, 560, 592, 608, 768 } } + { ModContent.NPCType(), new int[] { 350, 560, 592, 608, 768 } }, + + { 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[]> @@ -558,7 +572,7 @@ namespace CalamityMod { 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[] { 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 @@ -788,7 +802,18 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 600, 632, 648, 948 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 600, 632, 648, 948 } }, - { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } } + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 500, 752, 788, 808, 1182 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + + { 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 } } }; } diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 2000f81f3e..ce03012763 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -471,13 +471,14 @@ namespace CalamityMod target.AddBuff(BuffID.CursedInferno, (int)(120 * multiplier)); target.AddBuff(BuffType(), (int)(30 * multiplier)); target.AddBuff(BuffType(), (int)(120 * multiplier)); - target.AddBuff(BuffType(), (int)(60 * multiplier)); target.AddBuff(BuffType(), (int)(120 * multiplier)); target.AddBuff(BuffType(), (int)(120 * multiplier)); target.AddBuff(BuffID.Frostburn, (int)(120 * multiplier)); target.AddBuff(BuffID.OnFire, (int)(120 * 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. /// diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 6daaa91ba2..42b6fcaac2 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -144,7 +144,6 @@ namespace CalamityMod { target.AddBuff(BuffType(), (int)(30 * multiplier)); target.AddBuff(BuffType(), (int)(120 * multiplier)); - target.AddBuff(BuffType(), (int)(60 * multiplier)); target.AddBuff(BuffType(), (int)(120 * multiplier)); target.AddBuff(BuffType(), (int)(120 * multiplier)); target.AddBuff(BuffID.CursedInferno, (int)(120 * multiplier)); diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index b1fb0e3b10..b13a4c3b1a 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -21,6 +21,11 @@ namespace CalamityMod 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 void KillAllHostileProjectiles() { for (int x = 0; x < Main.maxProjectiles; x++) diff --git a/Utilities/TileUtils.cs b/Utilities/TileUtils.cs index e499f8d696..a383821d66 100644 --- a/Utilities/TileUtils.cs +++ b/Utilities/TileUtils.cs @@ -458,5 +458,11 @@ namespace CalamityMod 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]); } } diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 13102e2345..68e69f4409 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -53,37 +53,37 @@ namespace CalamityMod.World public static int Reforges; public static Dictionary ScreenShakeSpots = new Dictionary(); - //Boss Rush + // Boss Rush public static int bossRushHostileProjKillCounter = 0; - //Death Mode natural boss spawns - public static int bossSpawnCountdown = 0; //Death Mode natural boss spawn countdown - public static int bossType = 0; //Death Mode natural boss spawn type - public static int deathBossSpawnCooldown = 0; //Cooldown between Death Mode natural boss spawns + // Death Mode natural boss spawns + public static int bossSpawnCountdown = 0; // Death Mode natural boss spawn countdown + public static int bossType = 0; // Death Mode natural boss spawn type + public static int deathBossSpawnCooldown = 0; // Cooldown between Death Mode natural boss spawns - //Modes - public static bool demonMode = false; //Spawn rate boost - public static bool onionMode = false; //Extra accessory from Moon Lord - public static bool revenge = false; //Revengeance Mode - public static bool death = false; //Death Mode - public static bool armageddon = false; //Armageddon Mode - public static bool ironHeart = false; //Iron Heart Mode + // Modes + public static bool demonMode = false; // Spawn rate boost + public static bool onionMode = false; // Extra accessory from Moon Lord + public static bool revenge = false; // Revengeance Mode + public static bool death = false; // Death Mode + public static bool armageddon = false; // Armageddon Mode + public static bool ironHeart = false; // Iron Heart Mode public static bool malice = false; // Malice Mode, enrages all bosses and makes them drop good shit // New Temple Altar public static int newAltarX = 0; public static int newAltarY = 0; - //Evil Islands + // Evil Islands public static int fehX = 0; public static int fehY = 0; - //Brimstone Crag + // Brimstone Crag public static int fuhX = 0; public static int fuhY = 0; public static int calamityTiles = 0; - //Abyss & Sulphur + // Abyss & Sulphur public static int numAbyssIslands = 0; public static int[] AbyssIslandX = new int[20]; public static int[] AbyssIslandY = new int[20]; @@ -110,14 +110,14 @@ namespace CalamityMod.World } } - //Astral + // Astral public static int astralTiles = 0; - //Sunken Sea + // Sunken Sea public static int sunkenSeaTiles = 0; public static Rectangle SunkenSeaLocation = Rectangle.Empty; - //Shrines + // Shrines public static int[] SChestX = new int[10]; public static int[] SChestY = new int[10]; public static bool roxShrinePlaced = false; @@ -181,6 +181,7 @@ namespace CalamityMod.World public static bool downedBumble = false; public static bool downedYharon = false; public static bool downedSCal = false; + public static bool downedAdultEidolonWyrm = false; public static bool downedGSS = false; public static bool downedCLAM = false; public static bool downedCLAMHardMode = false; @@ -196,9 +197,8 @@ namespace CalamityMod.World public override void Initialize() { if (CalamityConfig.Instance.NerfExpertPillars) - { NPC.LunarShieldPowerExpert = 100; - } + CalamityGlobalNPC.holyBoss = -1; CalamityGlobalNPC.doughnutBoss = -1; CalamityGlobalNPC.voidBoss = -1; @@ -216,6 +216,11 @@ namespace CalamityMod.World CalamityGlobalNPC.fireEye = -1; CalamityGlobalNPC.brimstoneElemental = -1; CalamityGlobalNPC.signus = -1; + CalamityGlobalNPC.draedonExoMechPrime = -1; + CalamityGlobalNPC.draedonExoMechTwinGreen = -1; + CalamityGlobalNPC.draedonExoMechTwinRed = -1; + CalamityGlobalNPC.draedonExoMechWorm = -1; + CalamityGlobalNPC.adultEidolonWyrmHead = -1; BossRushEvent.BossRushStage = 0; DoGSecondStageCountdown = 0; ArmoredDiggerSpawnCooldown = 0; @@ -276,6 +281,7 @@ namespace CalamityMod.World downedSentinel3 = false; downedYharon = false; downedSCal = false; + downedAdultEidolonWyrm = false; downedCLAM = false; downedCLAMHardMode = false; downedBumble = false; @@ -344,6 +350,8 @@ namespace CalamityMod.World downed.Add("yharon"); if (downedSCal) downed.Add("supremeCalamitas"); + if (downedAdultEidolonWyrm) + downed.Add("adultEidolonWyrm"); if (downedBumble) downed.Add("bumblebirb"); if (downedCrabulon) @@ -501,6 +509,7 @@ namespace CalamityMod.World downedSecondSentinels = downed.Contains("secondSentinels"); downedYharon = downed.Contains("yharon"); downedSCal = downed.Contains("supremeCalamitas"); + downedAdultEidolonWyrm = downed.Contains("adultEidolonWyrm"); downedBumble = downed.Contains("bumblebirb"); downedCrabulon = downed.Contains("crabulon"); downedBetsy = downed.Contains("betsy"); @@ -682,6 +691,8 @@ namespace CalamityMod.World BitsByte flags11 = reader.ReadByte(); malice = flags11[0]; + HasGeneratedLuminitePlanetoids = flags11[1]; + downedAdultEidolonWyrm = flags11[2]; } else { @@ -788,13 +799,18 @@ namespace CalamityMod.World flags10[0] = anglerName; flags10[1] = clothierName; flags10[2] = encounteredOldDuke; - flags10[3] = malice; - flags10[4] = HasGeneratedLuminitePlanetoids; + flags10[3] = false; + flags10[4] = false; flags10[5] = false; flags10[6] = false; flags10[7] = false; - writer.Write(flags); + BitsByte flags11 = new BitsByte(); + flags11[0] = malice; + flags11[1] = HasGeneratedLuminitePlanetoids; + flags11[2] = downedAdultEidolonWyrm; + + writer.Write(flags); writer.Write(flags2); writer.Write(flags3); writer.Write(flags4); @@ -804,6 +820,7 @@ namespace CalamityMod.World writer.Write(flags8); writer.Write(flags9); writer.Write(flags10); + writer.Write(flags11); writer.Write(abyssChasmBottom); writer.Write(acidRainPoints); writer.Write(Reforges); @@ -909,13 +926,18 @@ namespace CalamityMod.World anglerName = flags10[0]; clothierName = flags10[1]; encounteredOldDuke = flags10[2]; - malice = flags10[3]; - HasGeneratedLuminitePlanetoids = flags10[4]; + _ = flags10[3]; + _ = flags10[4]; _ = flags10[5]; _ = flags10[6]; _ = flags10[7]; - abyssChasmBottom = reader.ReadInt32(); + BitsByte flags11 = reader.ReadByte(); + malice = flags11[0]; + HasGeneratedLuminitePlanetoids = flags11[1]; + downedAdultEidolonWyrm = flags11[2]; + + abyssChasmBottom = reader.ReadInt32(); acidRainPoints = reader.ReadInt32(); Reforges = reader.ReadInt32(); MoneyStolenByBandit = reader.ReadInt32(); @@ -1609,9 +1631,16 @@ namespace CalamityMod.World if (modPlayer.ZoneAbyss) { - if (player.chaosState) + if (player.chaosState && !player.dead) { - if (!NPC.AnyNPCs(ModContent.NPCType()) && Main.netMode != NetmodeID.MultiplayerClient) + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } + + if (!adultWyrmAlive && Main.netMode != NetmodeID.MultiplayerClient) NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); } } diff --git a/World/WorldGenerationMethods.cs b/World/WorldGenerationMethods.cs index 6b767a7003..48f76bfa7e 100644 --- a/World/WorldGenerationMethods.cs +++ b/World/WorldGenerationMethods.cs @@ -1102,7 +1102,6 @@ namespace CalamityMod.World Tile tile = Main.tile[x, y]; int type = tile.type; int wallType = tile.wall; - Mod mod = ModContent.GetInstance(); if (WorldGen.InWorld(x, y, 1)) {