diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index 74dee5be64..27930975d3 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -295,6 +295,9 @@ namespace CalamityMod.Balancing #region Ceaseless Void: Dark Energies // 50% resist to true melee. NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), ResistTrueMelee(0.5f))); + + // 40% resist to Stellar Torus Staff. + NPCSpecificBalancingChanges.Add(new NPCBalancingChange(NPCType(), new ProjectileResistBalancingRule(0.6f, ProjectileType()))); #endregion #region Storm Weaver @@ -390,6 +393,9 @@ namespace CalamityMod.Balancing // 65% resist to true melee. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(ResistTrueMelee(0.35f)))); + // 65% resist to Stellar Torus Staff. + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); + // 65% resist to The Enforcer's projectiles. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.35f, ProjectileType())))); @@ -453,6 +459,9 @@ namespace CalamityMod.Balancing // 25% resist to Zenith. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileID.FinalFractal)))); + // 20% resist to Ariane's aura (Lilies of Finality). + NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); + // 20% resist to Blood Boiler. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.ThanatosIDs, Do(new ProjectileResistBalancingRule(0.8f, ProjectileType())))); diff --git a/BiomeManagers/AbyssLayer1Biome.cs b/BiomeManagers/AbyssLayer1Biome.cs index 170ad5e76f..a3b73e8f4b 100644 --- a/BiomeManagers/AbyssLayer1Biome.cs +++ b/BiomeManagers/AbyssLayer1Biome.cs @@ -42,7 +42,7 @@ namespace CalamityMod.BiomeManagers if (Main.remixWorld) return !player.lavaWet && !player.honeyWet && abyssPosX && playerYTileCoords < abyssStartHeight; - return !player.lavaWet && !player.honeyWet && abyssPosX && playerYTileCoords >= abyssStartHeight && playerYTileCoords <= Main.maxTilesY - 200; + return !player.lavaWet && !player.honeyWet && abyssPosX && playerYTileCoords >= abyssStartHeight && playerYTileCoords <= Main.UnderworldLayer; } // Temporarily use sulphur for now diff --git a/BiomeManagers/AbyssLayer2Biome.cs b/BiomeManagers/AbyssLayer2Biome.cs index 8256c4175d..cf20c66664 100644 --- a/BiomeManagers/AbyssLayer2Biome.cs +++ b/BiomeManagers/AbyssLayer2Biome.cs @@ -32,7 +32,7 @@ namespace CalamityMod.BiomeManagers if (Main.remixWorld) { return AbyssLayer1Biome.MeetsBaseAbyssRequirement(player, out int playerYTileCoords) && BiomeTileCounterSystem.Layer2Tiles >= 200 && - playerYTileCoords <= SulphurousSea.YStart - (int)((Main.maxTilesY - 200) * 0.2f) && playerYTileCoords > SulphurousSea.YStart - (int)((Main.maxTilesY - 200) * 0.4f); + playerYTileCoords <= SulphurousSea.YStart - (int)(Main.UnderworldLayer * 0.2f) && playerYTileCoords > SulphurousSea.YStart - (int)(Main.UnderworldLayer * 0.4f); } return AbyssLayer1Biome.MeetsBaseAbyssRequirement(player, out int playerYTileCoords2) && BiomeTileCounterSystem.Layer2Tiles >= 200 && diff --git a/BiomeManagers/AbyssLayer3Biome.cs b/BiomeManagers/AbyssLayer3Biome.cs index 536a17d861..5fa549ef5b 100644 --- a/BiomeManagers/AbyssLayer3Biome.cs +++ b/BiomeManagers/AbyssLayer3Biome.cs @@ -32,7 +32,7 @@ namespace CalamityMod.BiomeManagers if (Main.remixWorld) { return AbyssLayer1Biome.MeetsBaseAbyssRequirement(player, out int playerYTileCoords) && BiomeTileCounterSystem.Layer3Tiles >= 200 && - playerYTileCoords <= SulphurousSea.YStart - (int)((Main.maxTilesY - 200) * 0.4f) && playerYTileCoords > SulphurousSea.YStart - (int)((Main.maxTilesY - 200) * 0.6f); + playerYTileCoords <= SulphurousSea.YStart - (int)(Main.UnderworldLayer * 0.4f) && playerYTileCoords > SulphurousSea.YStart - (int)(Main.UnderworldLayer * 0.6f); } return AbyssLayer1Biome.MeetsBaseAbyssRequirement(player, out int playerYTileCoords2) && BiomeTileCounterSystem.Layer3Tiles >= 200 && diff --git a/BiomeManagers/AbyssLayer4Biome.cs b/BiomeManagers/AbyssLayer4Biome.cs index 3bc3bceff3..de29933f2d 100644 --- a/BiomeManagers/AbyssLayer4Biome.cs +++ b/BiomeManagers/AbyssLayer4Biome.cs @@ -32,7 +32,7 @@ namespace CalamityMod.BiomeManagers if (Main.remixWorld) { return AbyssLayer1Biome.MeetsBaseAbyssRequirement(player, out int playerYTileCoords) && BiomeTileCounterSystem.Layer4Tiles >= 200 && - playerYTileCoords <= SulphurousSea.YStart - (int)((Main.maxTilesY - 200) * 0.6f); + playerYTileCoords <= SulphurousSea.YStart - (int)(Main.UnderworldLayer * 0.6f); } return AbyssLayer1Biome.MeetsBaseAbyssRequirement(player, out int playerYTileCoords2) && BiomeTileCounterSystem.Layer4Tiles >= 200 && diff --git a/BiomeManagers/SulphurousSeaBiome.cs b/BiomeManagers/SulphurousSeaBiome.cs index 1ebe6d8c85..fb170f3449 100644 --- a/BiomeManagers/SulphurousSeaBiome.cs +++ b/BiomeManagers/SulphurousSeaBiome.cs @@ -71,7 +71,7 @@ namespace CalamityMod.BiomeManagers } if (Main.remixWorld) - return (BiomeTileCounterSystem.SulphurTiles >= 300 || (point.Y > SulphurousSea.YStart && point.Y < Main.maxTilesY - 200 && sulphurPosX && !WeakReferenceSupport.InAnySubworld())) && !player.Calamity().ZoneAbyss; + return (BiomeTileCounterSystem.SulphurTiles >= 300 || (point.Y > SulphurousSea.YStart && point.Y < Main.UnderworldLayer && sulphurPosX && !WeakReferenceSupport.InAnySubworld())) && !player.Calamity().ZoneAbyss; return (BiomeTileCounterSystem.SulphurTiles >= 300 || (point.Y < (Main.rockLayer - Main.maxTilesY / 13) && sulphurPosX && !WeakReferenceSupport.InAnySubworld())) && !player.Calamity().ZoneAbyss; } diff --git a/Buffs/Summon/LiliesOfFinalityBuff.cs b/Buffs/Summon/LiliesOfFinalityBuff.cs new file mode 100644 index 0000000000..77fe068705 --- /dev/null +++ b/Buffs/Summon/LiliesOfFinalityBuff.cs @@ -0,0 +1,31 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class LiliesOfFinalityBuff : ModBuff + { + public override void SetStaticDefaults() + { + 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.LiliesOfFinalityBool = true; + + if (!modPlayer.LiliesOfFinalityBool) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + player.buffTime[buffIndex] = 18000; + } + } +} diff --git a/Buffs/Summon/LiliesOfFinalityBuff.png b/Buffs/Summon/LiliesOfFinalityBuff.png new file mode 100644 index 0000000000..8099f3addf Binary files /dev/null and b/Buffs/Summon/LiliesOfFinalityBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 1fd51622f6..2c7a04bd58 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1079,6 +1079,7 @@ namespace CalamityMod.CalPlayer public bool celestialDragons = false; public bool KalandraMirror = false; public bool StellarTorus = false; + public bool LiliesOfFinalityBool = false; #endregion #region Biome @@ -2121,6 +2122,7 @@ namespace CalamityMod.CalPlayer celestialDragons = false; KalandraMirror = false; StellarTorus = false; + LiliesOfFinalityBool = false; disableVoodooSpawns = false; disablePerfCystSpawns = false; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 815da71528..8ca0fe63e2 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -551,7 +551,7 @@ namespace CalamityMod.CalPlayer #region Adrenaline // This is how much Adrenaline will be changed by this frame. float adrenalineDiff = 0; - bool wofAndNotHell = Main.wofNPCIndex >= 0 && Player.position.Y < (float)((Main.maxTilesY - 200) * 16); + bool wofAndNotHell = Main.wofNPCIndex >= 0 && Player.position.Y < (float)(Main.UnderworldLayer * 16); // If Adrenaline Mode is currently active, you smoothly lose all adrenaline over the duration. if (adrenalineModeActive) @@ -3119,7 +3119,7 @@ namespace CalamityMod.CalPlayer for (int i = 0; i < Main.maxNPCs; ++i) { NPC npc = Main.npc[i]; - if (!npc.active || npc.friendly || npc.damage <= 0 || npc.dontTakeDamage) + if (!npc.active || npc.friendly || npc.dontTakeDamage) continue; if (Vector2.Distance(Player.Center, npc.Center) <= range) diff --git a/CalamityLists.cs b/CalamityLists.cs index c00c19e251..5b9a91ece8 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -2065,6 +2065,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), @@ -2566,6 +2567,7 @@ namespace CalamityMod { NPCID.EyeofCthulhu, 450000 }, // 30 seconds { NPCID.ServantofCthulhu, 6000 }, + { NPCType(), 12000 }, { NPCID.EaterofWorldsHead, 10000 }, // 30 seconds + immunity timer at start { NPCID.EaterofWorldsBody, 10000 }, diff --git a/DataStructures/NPCStats.cs b/DataStructures/NPCStats.cs index d04671566e..b2bf7ddc3e 100644 --- a/DataStructures/NPCStats.cs +++ b/DataStructures/NPCStats.cs @@ -295,6 +295,7 @@ namespace CalamityMod EnemyStats.ContactDamageValues = new SortedDictionary { { NPCID.KingSlime, new int[] { 40, 64, 80, 96, 120 } }, + { ModContent.NPCType(), new int[] { 30, 44, 60, 76, 90 } }, { ModContent.NPCType(), new int[] { 45, 66, 88, 110, 132 } }, { ModContent.NPCType(), new int[] { 24, 32, 40, 48, 72 } }, @@ -310,6 +311,7 @@ namespace CalamityMod 50, // 60 in phase 2, 70 in phase 3 72 } }, // Vanilla: 108 in phase 2; Rev+: 86 in phase 2, 101 in phase 3 { NPCID.ServantofCthulhu, new int[] { 18, 24, 30, 36, 54 } }, + { ModContent.NPCType(), new int[] { 20, 26, 34, 42, 60 } }, // In phase 2: 26, 34, 44, 55, 78 { ModContent.NPCType(), new int[] { 40, 64, 80, 96, 120 } }, { ModContent.NPCType(), new int[] { 25, 50, 62, 74, 75 } }, @@ -562,6 +564,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 26, 44, 60, 76, 108 } }, { new Tuple(NPCID.EyeofCthulhu, ProjectileID.BloodNautilusShot), new int[] { 26, 44, 60, 76, 108 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.BloodShot), new int[] { 26, 36, 44, 52, 84 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 72, 96 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 32, 48, 60, 72, 96 } }, diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index f9d9776e39..35572bfefe 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -150,7 +150,8 @@ namespace CalamityMod.Events DownedBossSystem.startedBossRushAtLeastOnce = true; }, permittedNPCs: new int[] { NPCID.BlueSlime, NPCID.YellowSlime, NPCID.PurpleSlime, NPCID.RedSlime, NPCID.GreenSlime, NPCID.RedSlime, - NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType() }), + NPCID.IceSlime, NPCID.UmbrellaSlime, NPCID.Pinky, NPCID.SlimeSpiked, NPCID.RainbowSlime, ModContent.NPCType(), + ModContent.NPCType(), ModContent.NPCType() }), new Boss(ModContent.NPCType(), spawnContext: type => { @@ -160,7 +161,7 @@ namespace CalamityMod.Events }, permittedNPCs: new int[] { ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType(), ModContent.NPCType() }), - new Boss(NPCID.EyeofCthulhu, TimeChangeContext.Night, permittedNPCs: NPCID.ServantofCthulhu), + new Boss(NPCID.EyeofCthulhu, TimeChangeContext.Night, permittedNPCs: new int[] { NPCID.ServantofCthulhu, ModContent.NPCType() }), new Boss(ModContent.NPCType(), TimeChangeContext.Day, type => { diff --git a/Items/Armor/Auric/AuricTeslaSpaceHelmet.cs b/Items/Armor/Auric/AuricTeslaSpaceHelmet.cs index 7db314a488..326f4ff154 100644 --- a/Items/Armor/Auric/AuricTeslaSpaceHelmet.cs +++ b/Items/Armor/Auric/AuricTeslaSpaceHelmet.cs @@ -62,10 +62,10 @@ namespace CalamityMod.Items.Armor.Auric } if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 1) { - var damage = (int)player.GetTotalDamage().ApplyTo(800); + var damage = (int)player.GetTotalDamage().ApplyTo(750); var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, -20f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = 800; + Main.projectile[p].originalDamage = 750; } } } diff --git a/Items/Armor/Silva/SilvaHeadSummon.cs b/Items/Armor/Silva/SilvaHeadSummon.cs index e38fc5b498..8bf039d395 100644 --- a/Items/Armor/Silva/SilvaHeadSummon.cs +++ b/Items/Armor/Silva/SilvaHeadSummon.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Armor.Silva var p = Projectile.NewProjectile(source, player.Center.X, player.Center.Y, 0f, -1f, ModContent.ProjectileType(), damage, 0f, Main.myPlayer, -20f, 0f); if (Main.projectile.IndexInRange(p)) - Main.projectile[p].originalDamage = baseDamage; + Main.projectile[p].originalDamage = 600; } } player.GetDamage() += 0.65f; diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 34b784213a..bb4f41f15f 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -93,6 +93,8 @@ namespace CalamityMod.Items private void ApplyRarityColor(Item item, TooltipLine nameLine) { #region Uniquely Colored Developer Items + if (item.type == ModContent.ItemType()) + nameLine.OverrideColor = Color.Lerp(Color.Red, Color.White, (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f); if (item.type == ModContent.ItemType()) nameLine.OverrideColor = new Color(Main.DiscoR, 100, 255); if (item.type == ModContent.ItemType()) @@ -259,6 +261,10 @@ namespace CalamityMod.Items // Numerous random tooltip edits which don't fit into another category #region Various Tooltip Edits + // Lilies of Finality 512 edit + if (item.type == ModContent.ItemType()) + EditTooltipByName("Damage", (line) => line.Text = LiliesOfFinality.TheNumber + " summon damage"); + // Master Mode items also drop in Revengeance // Only affects vanilla and Calamity items if (item.master && (item.type < ItemID.Count || item.ModItem?.Mod is CalamityMod)) diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index ae14e8d561..94aeb88015 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -162,6 +162,7 @@ namespace CalamityMod.Items { ItemID.MonkStaffT1, Do(TrueMeleeNoSpeed, DamageExact(83)) }, // Sleepy Octopod { ItemID.MonkStaffT2, Do(AutoReuse, TrueMelee, DamageExact(90)) }, // Ghastly Glaive { ItemID.MonkStaffT3, Do(DamageExact(225)) }, // Sky Dragon's Fury + { ItemID.MoonlordTurretStaff, Do(DamageExact(50), UseExact(15)) }, //Lunar Portal Staff { ItemID.Muramasa, Do(CritDelta(+20)) }, { ItemID.MushroomSpear, Do(AutoReuse, TrueMelee, UseRatio(0.8f), DamageExact(100)) }, { ItemID.Musket, Do(PointBlank, DamageExact(22)) }, @@ -487,7 +488,6 @@ namespace CalamityMod.Items { ItemID.FireWhip, autoReuse }, // Firecracker { ItemID.FlinxStaff, Do(AutoReuse, UseExact(35)) }, { ItemID.MaceWhip, autoReuse }, // Morning Star - { ItemID.MoonlordTurretStaff, Do(UseExact(15)) }, // Lunar Portal Staff { ItemID.OpticStaff, Do(AutoReuse, UseExact(25)) }, { ItemID.PirateStaff, Do(AutoReuse, UseExact(25)) }, { ItemID.QueenSpiderStaff, Do(UseExact(25)) }, diff --git a/Items/DraedonMisc/CodebreakerBase.cs b/Items/DraedonMisc/CodebreakerBase.cs index 6828c8116d..ed098bacda 100644 --- a/Items/DraedonMisc/CodebreakerBase.cs +++ b/Items/DraedonMisc/CodebreakerBase.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.DraedonMisc Item.autoReuse = true; Item.consumable = true; Item.maxStack = 9999; - Item.rare = ItemRarityID.Orange; + Item.rare = ItemRarityID.Green; Item.createTile = ModContent.TileType(); } diff --git a/Items/Weapons/Magic/ApoctosisArray.cs b/Items/Weapons/Magic/ApoctosisArray.cs index c9d2ea366a..9a36352c58 100644 --- a/Items/Weapons/Magic/ApoctosisArray.cs +++ b/Items/Weapons/Magic/ApoctosisArray.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.autoReuse = true; Item.noMelee = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 8f; } diff --git a/Items/Weapons/Magic/AsteroidStaff.cs b/Items/Weapons/Magic/AsteroidStaff.cs index edda3824ab..8030537957 100644 --- a/Items/Weapons/Magic/AsteroidStaff.cs +++ b/Items/Weapons/Magic/AsteroidStaff.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.shootSpeed = 20f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) diff --git a/Items/Weapons/Magic/Effervescence.cs b/Items/Weapons/Magic/Effervescence.cs index ebe92a4ca6..0655353c90 100644 --- a/Items/Weapons/Magic/Effervescence.cs +++ b/Items/Weapons/Magic/Effervescence.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.noMelee = true; Item.knockBack = 3.75f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item95; Item.autoReuse = true; Item.shootSpeed = 13f; diff --git a/Items/Weapons/Magic/Genisis.cs b/Items/Weapons/Magic/Genisis.cs index 23f289de80..3ee459c89d 100644 --- a/Items/Weapons/Magic/Genisis.cs +++ b/Items/Weapons/Magic/Genisis.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.noMelee = true; Item.knockBack = 1.5f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item33; Item.autoReuse = true; Item.shootSpeed = 6f; diff --git a/Items/Weapons/Magic/NuclearFury.cs b/Items/Weapons/Magic/NuclearFury.cs index 7654e1aef5..58c487b422 100644 --- a/Items/Weapons/Magic/NuclearFury.cs +++ b/Items/Weapons/Magic/NuclearFury.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.noMelee = true; Item.knockBack = 5f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item84; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Melee/BalefulHarvester.cs b/Items/Weapons/Melee/BalefulHarvester.cs index e402c60293..3a2e1a0f1f 100644 --- a/Items/Weapons/Melee/BalefulHarvester.cs +++ b/Items/Weapons/Melee/BalefulHarvester.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 74; Item.height = 86; - Item.damage = 135; + Item.damage = 105; Item.DamageType = DamageClass.Melee; Item.useAnimation = 22; Item.useStyle = ItemUseStyleID.Swing; @@ -30,14 +30,14 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) { int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ProjectileID.FlamingJack; - CalamityPlayer.HorsemansBladeOnHit(player, target.whoAmI, (int)(Item.damage * 0.8f), Item.knockBack * 0.5f, 0, type); + CalamityPlayer.HorsemansBladeOnHit(player, target.whoAmI, (int)(Item.damage * 1.5f), Item.knockBack * 0.5f, 0, type); target.AddBuff(BuffID.OnFire3, 300); } public override void OnHitPvp(Player player, Player target, Player.HurtInfo hurtInfo) { int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ProjectileID.FlamingJack; - CalamityPlayer.HorsemansBladeOnHit(player, -1, (int)(Item.damage * 0.8f), Item.knockBack * 0.5f, 0, type); + CalamityPlayer.HorsemansBladeOnHit(player, -1, (int)(Item.damage * 1.5f), Item.knockBack * 0.5f, 0, type); target.AddBuff(BuffID.OnFire3, 300); } diff --git a/Items/Weapons/Melee/BladecrestOathsword.cs b/Items/Weapons/Melee/BladecrestOathsword.cs index aaa0ce4558..42d78b91b8 100644 --- a/Items/Weapons/Melee/BladecrestOathsword.cs +++ b/Items/Weapons/Melee/BladecrestOathsword.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 56; Item.height = 56; - Item.damage = 15; + Item.damage = 17; Item.DamageType = DamageClass.Melee; Item.useAnimation = 21; Item.useTime = 21; diff --git a/Items/Weapons/Melee/Devastation.cs b/Items/Weapons/Melee/Devastation.cs index 8bf1c82397..fd2bd9b783 100644 --- a/Items/Weapons/Melee/Devastation.cs +++ b/Items/Weapons/Melee/Devastation.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; } diff --git a/Items/Weapons/Melee/GreatswordofJudgement.cs b/Items/Weapons/Melee/GreatswordofJudgement.cs index f1eaf63cee..d5280ca620 100644 --- a/Items/Weapons/Melee/GreatswordofJudgement.cs +++ b/Items/Weapons/Melee/GreatswordofJudgement.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 10f; } diff --git a/Items/Weapons/Melee/PlagueKeeper.cs b/Items/Weapons/Melee/PlagueKeeper.cs index d6c14cb50d..ee8bb04e67 100644 --- a/Items/Weapons/Melee/PlagueKeeper.cs +++ b/Items/Weapons/Melee/PlagueKeeper.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 9f; } diff --git a/Items/Weapons/Melee/RemsRevenge.cs b/Items/Weapons/Melee/RemsRevenge.cs index a7da3f6a38..771809ab49 100644 --- a/Items/Weapons/Melee/RemsRevenge.cs +++ b/Items/Weapons/Melee/RemsRevenge.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.noUseGraphic = true; Item.knockBack = 10f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.channel = true; diff --git a/Items/Weapons/Melee/SolsticeClaymore.cs b/Items/Weapons/Melee/SolsticeClaymore.cs index 5a812a7d35..78da4f3d8b 100644 --- a/Items/Weapons/Melee/SolsticeClaymore.cs +++ b/Items/Weapons/Melee/SolsticeClaymore.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 16f; } diff --git a/Items/Weapons/Melee/StellarContempt.cs b/Items/Weapons/Melee/StellarContempt.cs index 6821102e8b..60ecff7d2a 100644 --- a/Items/Weapons/Melee/StellarContempt.cs +++ b/Items/Weapons/Melee/StellarContempt.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = Speed; diff --git a/Items/Weapons/Melee/StellarStriker.cs b/Items/Weapons/Melee/StellarStriker.cs index 355ea81026..029e933744 100644 --- a/Items/Weapons/Melee/StellarStriker.cs +++ b/Items/Weapons/Melee/StellarStriker.cs @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shootSpeed = 12f; } diff --git a/Items/Weapons/Ranged/ClockworkBow.cs b/Items/Weapons/Ranged/ClockworkBow.cs index ba4259cee8..030befb118 100644 --- a/Items/Weapons/Ranged/ClockworkBow.cs +++ b/Items/Weapons/Ranged/ClockworkBow.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.channel = true; Item.knockBack = 4.25f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.noUseGraphic = true; Item.UseSound = SoundID.Item20; Item.autoReuse = true; diff --git a/Items/Weapons/Ranged/Disseminator.cs b/Items/Weapons/Ranged/Disseminator.cs index 2a838ad1a4..6d4ef83266 100644 --- a/Items/Weapons/Ranged/Disseminator.cs +++ b/Items/Weapons/Ranged/Disseminator.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.knockBack = 4.5f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item38; Item.autoReuse = true; Item.shootSpeed = 13f; diff --git a/Items/Weapons/Ranged/OnyxChainBlaster.cs b/Items/Weapons/Ranged/OnyxChainBlaster.cs index 6f99fd4ebe..fab760e370 100644 --- a/Items/Weapons/Ranged/OnyxChainBlaster.cs +++ b/Items/Weapons/Ranged/OnyxChainBlaster.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.knockBack = 4.5f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item36; Item.autoReuse = true; Item.shoot = ProjectileID.BlackBolt; diff --git a/Items/Weapons/Ranged/Starfleet.cs b/Items/Weapons/Ranged/Starfleet.cs index 3c5bf121b4..f4910478c6 100644 --- a/Items/Weapons/Ranged/Starfleet.cs +++ b/Items/Weapons/Ranged/Starfleet.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.noMelee = true; Item.knockBack = 15f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item92; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Rogue/CelestialReaper.cs b/Items/Weapons/Rogue/CelestialReaper.cs index cc669d76ea..3acabf80a2 100644 --- a/Items/Weapons/Rogue/CelestialReaper.cs +++ b/Items/Weapons/Rogue/CelestialReaper.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.noUseGraphic = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 6f; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item71; Item.autoReuse = true; Item.value = CalamityGlobalItem.Rarity10BuyPrice; diff --git a/Items/Weapons/Rogue/CosmicKunai.cs b/Items/Weapons/Rogue/CosmicKunai.cs index 502fccea74..1bab5234b9 100644 --- a/Items/Weapons/Rogue/CosmicKunai.cs +++ b/Items/Weapons/Rogue/CosmicKunai.cs @@ -33,14 +33,15 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 2f; + public override float StealthDamageMultiplier => 1.5f; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable() && stealth.WithinBounds(Main.maxProjectiles)) + if (player.Calamity().StealthStrikeAvailable()) { Main.projectile[stealth].Calamity().stealthStrike = true; + Main.projectile[stealth].penetrate = 3; SoundEngine.PlaySound(SoundID.Item73, player.Center); for (float i = 0; i < 5; i++) { diff --git a/Items/Weapons/Rogue/LunarKunai.cs b/Items/Weapons/Rogue/LunarKunai.cs index 0a587c4b46..a39f6910b3 100644 --- a/Items/Weapons/Rogue/LunarKunai.cs +++ b/Items/Weapons/Rogue/LunarKunai.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.UseSound = SoundID.Item39; Item.autoReuse = true; Item.value = Item.sellPrice(copper: 24); - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 22f; Item.DamageType = RogueDamageClass.Instance; diff --git a/Items/Weapons/Summon/EndoHydraStaff.cs b/Items/Weapons/Summon/EndoHydraStaff.cs index 760841c7a4..163f44253a 100644 --- a/Items/Weapons/Summon/EndoHydraStaff.cs +++ b/Items/Weapons/Summon/EndoHydraStaff.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.UseSound = SoundID.Item60; Item.DamageType = DamageClass.Summon; Item.mana = 10; - Item.damage = 230; + Item.damage = 232; Item.knockBack = 3f; Item.autoReuse = true; Item.useTime = Item.useAnimation = 10; diff --git a/Items/Weapons/Summon/LiliesOfFinality.cs b/Items/Weapons/Summon/LiliesOfFinality.cs new file mode 100644 index 0000000000..07bb650e25 --- /dev/null +++ b/Items/Weapons/Summon/LiliesOfFinality.cs @@ -0,0 +1,85 @@ +using CalamityMod.Projectiles.Summon; +using CalamityMod.Rarities; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class LiliesOfFinality : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Weapons.Summon"; + + #region Other Stats + + public static float MaxEnemyDistanceDetection = 2000f; + public static int CommonDustID = 114; + + public static float Elster_DistanceFromTarget = 280f; + public static float Elster_TargettingFlySpeed = 35f; + public static float Elster_BulletProjectileSpeed = 20f; + public static int Elster_BulletMaxUpdates = 2; + + public static float Ariane_BoltFireRate = 60f; + public static float Ariane_TargettingFlySpeed = 20f; + public static float Ariane_BoltProjectileSpeed = 25f; + public static int Ariane_BoltTimeHoming = 600; + public static float Ariane_MinTurnRate = 0.05f; + public static float Ariane_MaxTurnRate = 0.2f; + public static int Ariane_AoESize = 1050; + public static float Ariane_AoEDMGMultiplier = 0.4f; + + // Do not change this number, ever. - Fabsol + public const int TheNumber = 512; + + #endregion + + public override void SetDefaults() + { + Item.damage = TheNumber; + Item.DamageType = DamageClass.Summon; + Item.shoot = ProjectileType(); + Item.knockBack = 5f; + + Item.mana = 10; + Item.useTime = Item.useAnimation = 15; + Item.width = 36; + Item.height = 50; + Item.noMelee = true; + Item.value = CalamityGlobalItem.Rarity15BuyPrice; + Item.rare = RarityType(); + Item.useStyle = ItemUseStyleID.HoldUp; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0; + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.maxMinions - player.slotsMinions >= 2) + { + Projectile.NewProjectileDirect(source, Main.MouseWorld, new Vector2(-1f, -1f) * 3f, type, damage, knockback, player.whoAmI); + Projectile.NewProjectileDirect(source, Main.MouseWorld, new Vector2(1f, -1f) * 3f, ProjectileType(), damage, knockback, player.whoAmI); + + if (Main.dedServ) + return false; + + int dustAmount = Main.rand.Next(30, 40 + 1); + for (int i = 0; i < dustAmount; i++) + { + float angle = MathHelper.TwoPi / dustAmount * i; + Vector2 dustVelocity = angle.ToRotationVector2() * Main.rand.NextFloat(3f, 6f); + Dust spawnDust = Dust.NewDustPerfect( + Main.MouseWorld, + CommonDustID, + dustVelocity, + Scale: Main.rand.NextFloat(1.2f, 1.5f)); + spawnDust.noGravity = true; + } + } + return false; + } + } +} diff --git a/Items/Weapons/Summon/LiliesOfFinality.png b/Items/Weapons/Summon/LiliesOfFinality.png new file mode 100644 index 0000000000..db6394b847 Binary files /dev/null and b/Items/Weapons/Summon/LiliesOfFinality.png differ diff --git a/Items/Weapons/Summon/StellarTorusStaff.cs b/Items/Weapons/Summon/StellarTorusStaff.cs index 420962f614..342ba5cbfd 100644 --- a/Items/Weapons/Summon/StellarTorusStaff.cs +++ b/Items/Weapons/Summon/StellarTorusStaff.cs @@ -25,8 +25,8 @@ namespace CalamityMod.Items.Weapons.Summon { Item.width = 42; Item.height = 42; - Item.damage = 185; - Item.useTime = Item.useAnimation = 30; + Item.damage = 142; + Item.useTime = Item.useAnimation = 20; Item.knockBack = 4f; Item.mana = 10; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Summon/TacticalPlagueEngine.cs b/Items/Weapons/Summon/TacticalPlagueEngine.cs index c23940663f..dcbdc083d2 100644 --- a/Items/Weapons/Summon/TacticalPlagueEngine.cs +++ b/Items/Weapons/Summon/TacticalPlagueEngine.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Summon Item.noMelee = true; Item.knockBack = 0.5f; Item.value = CalamityGlobalItem.Rarity10BuyPrice; - Item.rare = ItemRarityID.Red; + Item.rare = ItemRarityID.Purple; Item.UseSound = SoundID.Item14; Item.autoReuse = true; Item.DamageType = DamageClass.Summon; diff --git a/Localization/en-US/Mods.CalamityMod.Buffs.hjson b/Localization/en-US/Mods.CalamityMod.Buffs.hjson index 1637c19d8c..5820646ef8 100644 --- a/Localization/en-US/Mods.CalamityMod.Buffs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Buffs.hjson @@ -1520,3 +1520,8 @@ YoungDukeBuff: { DisplayName: Young Duke Buff Description: Mods.CalamityMod.Buffs.YoungDukeBuff.Description } + +LiliesOfFinalityBuff: { + DisplayName: Finality + Description: Remember our promise +} diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 506e144946..7a24b451e5 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -204,7 +204,7 @@ CosmicKunai: { Tooltip: ''' Fires a rapid stream of short-range kunai - Stealth strikes make kunai travel farther and spawn 5 homing Cosmic Scythes + Stealth strikes make kunai pierce foes, travel farther, and spawn 5 homing scythes ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson index f783b344e0..30f9e3af79 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Summon.hjson @@ -830,3 +830,13 @@ HarvestStaff: { 'No thoughts behind those eyes' ''' } + +LiliesOfFinality: { + DisplayName: Lilies of Finality + Tooltip: + ''' + Requires 2 minion slots to use + Can only be summoned once + 'Wake up' + ''' +} diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index ac66d8c600..4858b374c1 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -146,6 +146,7 @@ AeroSlime.DisplayName: Aero Slime ArmoredDiggerHead.DisplayName: Armored Digger MechanizedSerpent: Mechanized Serpent AuroraSpirit.DisplayName: Aurora Spirit +BloodlettingServant.DisplayName: Bloodletting Servant BloomSlime.DisplayName: Bloom Slime Bohldohr.DisplayName: Bohldohr Cnidrion.DisplayName: Cnidrion @@ -167,7 +168,9 @@ Frogfish.DisplayName: Frogfish Horse.DisplayName: Earth Elemental IceClasper.DisplayName: Ice Clasper ImpiousImmolator.DisplayName: Impious Immolator -KingSlimeJewel.DisplayName: Crown Jewel +KingSlimeJewel.DisplayName: Ruby Jewel +KingSlimeJewel2.DisplayName: Sapphire Jewel +KingSlimeJewel3.DisplayName: Emerald Jewel MantisShrimp.DisplayName: Mantis Shrimp OverloadedSoldier.DisplayName: Overloaded Soldier PerennialSlime.DisplayName: Perennial Slime diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson index 801b6485e7..5266da53fd 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Summon.hjson @@ -325,3 +325,9 @@ HopeShredderArrow.DisplayName: Hope Shredder Arrow HopeShredderArrowSplit.DisplayName: Hope Shredder Split Arrow HarvestStaffMinion.DisplayName: Harvest Staff Minion HarvestStaffSentry.DisplayName: Harvest Staff Sentry +LiliesOfFinalityAoE.DisplayName: Bioresonance Aura +LiliesOfFinalityAriane.DisplayName: Ariane +LiliesOfFinalityBullet.DisplayName: Einhorn Bullet +LiliesOfFinalityBolt.DisplayName: Bioresonance Bolt +LiliesOfFinalityElster.DisplayName: Elster +LiliesOfEternityBullet.DisplayName: Lilies Of Eternity Bullet diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 9678fc6f50..6cc3b3116a 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -293,7 +293,9 @@ namespace CalamityMod // Enemies EnemyRedirect(NPCType(), "Hive (enemy)"); - EnemyRedirect(NPCType(), "Crown Jewel (enemy)"); + EnemyRedirect(NPCType(), "Ruby Jewel (enemy)"); + EnemyRedirect(NPCType(), "Sapphire Jewel (enemy)"); + EnemyRedirect(NPCType(), "Emerald Jewel (enemy)"); EnemyRedirect(NPCType(), "Tooth Ball (Old Duke)"); EnemyRedirect(NPCType(), "Enchantment"); EnemyRedirect(NPCType(), "%3F%3F%3F"); diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index 04b2afeb47..934a7bd519 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -199,7 +199,7 @@ namespace CalamityMod.NPCs.Abyss if (NPC.position.Y > Main.worldSurface * 16.0) NPC.velocity.Y += 3f; - if (NPC.position.Y > (Main.maxTilesY - 200) * 16.0) + if (NPC.position.Y > Main.UnderworldLayer * 16.0) { for (int a = 0; a < Main.maxNPCs; a++) { diff --git a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs index a1e091f945..b1086e7143 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/AquaticScourgeAI.cs @@ -100,7 +100,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs // Check for the flipped Abyss if (Main.remixWorld) { - notOcean = player.position.Y < (Main.maxTilesY - 200) * 0.8f || player.position.Y > Main.maxTilesY - 200 || + notOcean = player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer || (player.position.X > 7680f && player.position.X < (Main.maxTilesX * 16 - 7680)); } diff --git a/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs b/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs index 967703231a..08ee0cf57f 100644 --- a/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs +++ b/NPCs/CalamityAIs/CalamityBossAIs/OldDukeAI.cs @@ -254,7 +254,7 @@ namespace CalamityMod.NPCs.CalamityAIs.CalamityBossAIs if (Main.remixWorld) { enrage = !bossRush && - (player.position.Y < (Main.maxTilesY - 200) * 0.8f || player.position.Y > Main.maxTilesY - 200 || + (player.position.Y < Main.UnderworldLayer * 0.8f || player.position.Y > Main.UnderworldLayer || (player.position.X > 8000f && player.position.X < (Main.maxTilesX * 16 - 8000))); } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 927e6d3e9a..51e49f0908 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -6392,6 +6392,9 @@ namespace CalamityMod.NPCs if (Main.LocalPlayer.Calamity().trippy || (npc.type == NPCID.KingSlime && CalamityWorld.LegendaryMode && CalamityWorld.revenge)) return new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB, Main.DiscoR); + if (npc.type == NPCID.KingSlime && Main.masterMode && CalamityWorld.revenge) + return NPC.AnyNPCs(ModContent.NPCType()) ? Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f) : null; + if (npc.type == NPCID.QueenBee && Main.zenithWorld) { if (npc.life / (float)npc.lifeMax < 0.5f) diff --git a/NPCs/HiveMind/HiveBlob2.cs b/NPCs/HiveMind/HiveBlob2.cs index e52ba4db4e..1d704aa619 100644 --- a/NPCs/HiveMind/HiveBlob2.cs +++ b/NPCs/HiveMind/HiveBlob2.cs @@ -15,6 +15,7 @@ namespace CalamityMod.NPCs.HiveMind public class HiveBlob2 : ModNPC { public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.HiveBlob.DisplayName"); + public override string Texture => "CalamityMod/NPCs/HiveMind/HiveBlob"; public override void SetStaticDefaults() { diff --git a/NPCs/HiveMind/HiveBlob2.png b/NPCs/HiveMind/HiveBlob2.png deleted file mode 100644 index 7f8536971e..0000000000 Binary files a/NPCs/HiveMind/HiveBlob2.png and /dev/null differ diff --git a/NPCs/NormalNPCs/ArmoredDiggerHead.cs b/NPCs/NormalNPCs/ArmoredDiggerHead.cs index f15eb25ae2..448082010e 100644 --- a/NPCs/NormalNPCs/ArmoredDiggerHead.cs +++ b/NPCs/NormalNPCs/ArmoredDiggerHead.cs @@ -201,7 +201,7 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.velocity.Y = NPC.velocity.Y + 1f; maxChaseSpeed *= 2f; } - if ((double)NPC.position.Y > (double)((Main.maxTilesY - 200) * 16)) + if ((double)NPC.position.Y > (double)(Main.UnderworldLayer * 16)) { for (int a = 0; a < Main.maxNPCs; a++) { diff --git a/NPCs/NormalNPCs/AuroraSpirit.cs b/NPCs/NormalNPCs/AuroraSpirit.cs index 85480340c5..8052c470be 100644 --- a/NPCs/NormalNPCs/AuroraSpirit.cs +++ b/NPCs/NormalNPCs/AuroraSpirit.cs @@ -109,7 +109,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override void AI() { - Lighting.AddLight((int)((NPC.position.X + (float)(NPC.width / 2)) / 16f), (int)((NPC.position.Y + (float)(NPC.height / 2)) / 16f), 0.02f, 0.7f, 0.7f); + Lighting.AddLight(NPC.Center, 0.02f, 0.7f, 0.7f); } public override void HitEffect(NPC.HitInfo hit) diff --git a/NPCs/NormalNPCs/BloodlettingServant.cs b/NPCs/NormalNPCs/BloodlettingServant.cs new file mode 100644 index 0000000000..b6216cbea5 --- /dev/null +++ b/NPCs/NormalNPCs/BloodlettingServant.cs @@ -0,0 +1,203 @@ +using System; +using CalamityMod.Events; +using CalamityMod.NPCs.VanillaNPCAIOverrides.RegularEnemies; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.NormalNPCs +{ + public class BloodlettingServant : ModNPC + { + public override void SetStaticDefaults() + { + Main.npcFrameCount[NPC.type] = 4; + NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; + NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); + } + + public override void SetDefaults() + { + NPC.aiStyle = -1; + AIType = -1; + NPC.GetNPCDamage(); + NPC.width = 30; + NPC.height = 32; + if (Main.tenthAnniversaryWorld) + NPC.scale *= 0.5f; + if (Main.getGoodWorld) + NPC.scale *= 1.1f; + + NPC.defense = 5; + + NPC.lifeMax = 96; + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); + + NPC.knockBackResist = 0f; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.HitSound = SoundID.NPCHit1; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.Calamity().VulnerableToCold = true; + NPC.Calamity().VulnerableToHeat = true; + NPC.Calamity().VulnerableToSickness = true; + } + + public override void AI() + { + NPC.TargetClosest(); + Player target = Main.player[NPC.target]; + + Vector2 lookAt = target.Center - NPC.Center; + if (lookAt.X > 0f) + { + NPC.spriteDirection = 1; + NPC.rotation = (float)Math.Atan2(lookAt.Y, lookAt.X); + } + if (lookAt.X < 0f) + { + NPC.spriteDirection = -1; + NPC.rotation = (float)Math.Atan2(lookAt.Y, lookAt.X) + MathHelper.Pi; + } + + Lighting.AddLight(NPC.Center, 0.8f, 0f, 0f); + + bool phase2 = NPC.life < NPC.lifeMax * 0.5; + float enrageScale = 1f + NPC.ai[2]; + float enrageScaleMaxSpeedBonus = 2f * enrageScale; + float maxSpeedX = (phase2 ? (CalamityWorld.death ? 10f : 8f) : (CalamityWorld.death ? 8f : 6f)) + enrageScaleMaxSpeedBonus; + float maxSpeedY = (phase2 ? (CalamityWorld.death ? 8f : 6f) : (CalamityWorld.death ? 4f : 3f)) + enrageScaleMaxSpeedBonus; + float xAccel = maxSpeedX * 0.01f; + float xAccelBoost1 = maxSpeedX * 0.01f; + float xAccelBoost2 = maxSpeedX * 0.0075f; + float yAccel = maxSpeedY * 0.01f; + float yAccelBoost1 = maxSpeedY * 0.01f; + float yAccelBoost2 = maxSpeedY * 0.0075f; + + if (target.dead) + { + NPC.velocity.Y -= 0.04f; + + if (NPC.timeLeft > 10) + NPC.timeLeft = 10; + } + else + DemonEyeAI.DemonEyeBatMovement(NPC, maxSpeedX, maxSpeedY, xAccel, xAccelBoost1, xAccelBoost2, yAccel, yAccelBoost1, yAccelBoost2); + + if (phase2) + NPC.damage = (int)Math.Round(NPC.defDamage * 1.3); + else + NPC.damage = NPC.defDamage; + + if (!target.dead) + NPC.ai[3] += enrageScale; + + float projectileShootGateValue = CalamityWorld.death ? 180f : 270f; + if (Main.getGoodWorld) + projectileShootGateValue *= 0.5f; + + bool shootProjectile = Collision.CanHitLine(NPC.Center, 1, 1, target.Center, 1, 1) && Vector2.Distance(NPC.Center, target.Center) > 240f; + if (NPC.ai[3] >= projectileShootGateValue && shootProjectile) + { + NPC.ai[3] = 0f; + float projectileSpeed = CalamityWorld.death ? 16f : 12f; + Vector2 projectileVelocity = NPC.SafeDirectionTo(target.Center) * projectileSpeed; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int projType = ProjectileID.BloodShot; + int projDamage = NPC.GetProjectileDamage(projType); + int proj = Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + projectileVelocity.SafeNormalize(Vector2.UnitY) * 10f, projectileVelocity, projType, projDamage, 0f, Main.myPlayer); + Main.projectile[proj].timeLeft = 600; + } + + NPC.netUpdate = true; + } + + if (Main.rand.NextBool(20)) + { + Vector2 dustSpawnTopLeft = new Vector2(NPC.position.X, NPC.position.Y + NPC.height * 0.25f); + Dust blood = Dust.NewDustDirect(dustSpawnTopLeft, NPC.width, NPC.height / 2, DustID.Blood, NPC.velocity.X, 2f, 0, new Color(128, 0, 0, 255 - NPC.alpha), 1f); + blood.velocity.X *= 0.5f; + blood.velocity.Y *= 0.1f; + } + + float pushVelocity = 0.2f * enrageScale; + for (int i = 0; i < Main.maxNPCs; i++) + { + if (Main.npc[i].active) + { + if (i != NPC.whoAmI && Main.npc[i].type == NPC.type) + { + if (Vector2.Distance(NPC.Center, Main.npc[i].Center) < 48f * NPC.scale) + { + if (NPC.position.X < Main.npc[i].position.X) + NPC.velocity.X -= pushVelocity; + else + NPC.velocity.X += pushVelocity; + + if (NPC.position.Y < Main.npc[i].position.Y) + NPC.velocity.Y -= pushVelocity; + else + NPC.velocity.Y += pushVelocity; + } + } + } + } + } + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += 1D; + if (NPC.frameCounter >= 8D) + NPC.frame.Y = frameHeight; + else + NPC.frame.Y = 0; + + if (NPC.frameCounter >= 16D) + { + NPC.frame.Y = 0; + NPC.frameCounter = 0D; + } + if (NPC.life < NPC.lifeMax * 0.5) + NPC.frame.Y += frameHeight * 2; + } + + public override Color? GetAlpha(Color drawColor) => new Color(128, 0, 0, 255 - NPC.alpha); + + public override void HitEffect(NPC.HitInfo hit) + { + if (NPC.life > 0) + { + for (int i = 0; i < hit.Damage / (double)NPC.lifeMax * 100; i++) + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f); + + if (NPC.life < NPC.lifeMax * 0.5f && NPC.localAI[0] == 0f) + { + NPC.localAI[0] = 1f; + for (int i = 0; i < 50; i++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 2f * hit.HitDirection, -2f); + Main.dust[dust].scale = Main.rand.NextFloat(1.6f, 2.4f); + Main.dust[dust].velocity *= Main.rand.NextFloat(1.6f, 2.4f); + Main.dust[dust].color = new Color(128, 0, 0, 255 - NPC.alpha); + } + } + } + else + { + for (int i = 0; i < 100; i++) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 2f * hit.HitDirection, -2f); + Main.dust[dust].scale = Main.rand.NextFloat(1.6f, 2.4f); + Main.dust[dust].velocity *= Main.rand.NextFloat(1.6f, 2.4f); + Main.dust[dust].color = new Color(128, 0, 0, 255 - NPC.alpha); + } + } + } + } +} diff --git a/NPCs/NormalNPCs/BloodlettingServant.png b/NPCs/NormalNPCs/BloodlettingServant.png new file mode 100644 index 0000000000..0ce0338808 Binary files /dev/null and b/NPCs/NormalNPCs/BloodlettingServant.png differ diff --git a/NPCs/NormalNPCs/KingSlimeJewel.cs b/NPCs/NormalNPCs/KingSlimeJewel.cs index b4f6b4739a..1ed5bfcc29 100644 --- a/NPCs/NormalNPCs/KingSlimeJewel.cs +++ b/NPCs/NormalNPCs/KingSlimeJewel.cs @@ -60,15 +60,17 @@ namespace CalamityMod.NPCs.NormalNPCs return; } + Lighting.AddLight(NPC.Center, 0.8f, 0f, 0f); + // Float around the player NPC.rotation = NPC.velocity.X / 15f; - NPC.TargetClosest(true); + NPC.TargetClosest(); float velocity = 5f; float acceleration = 0.1f; - if (NPC.position.Y > Main.player[NPC.target].position.Y - 350f) + if (NPC.position.Y > Main.player[NPC.target].position.Y - 400f) { if (NPC.velocity.Y > 0f) NPC.velocity.Y *= 0.98f; @@ -116,7 +118,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.ai[0] = 0f; - Vector2 npcPos = new Vector2(NPC.Center.X, NPC.Center.Y); + Vector2 npcPos = NPC.Center; float xDist = Main.player[NPC.target].Center.X - npcPos.X; float yDist = Main.player[NPC.target].Center.Y - npcPos.Y; Vector2 projVector = new Vector2(xDist, yDist); @@ -128,8 +130,6 @@ namespace CalamityMod.NPCs.NormalNPCs projLength = speed / projLength; projVector.X *= projLength; projVector.Y *= projLength; - npcPos.X += projVector.X * 2f; - npcPos.Y += projVector.Y * 2f; for (int dusty = 0; dusty < 10; dusty++) { @@ -163,14 +163,16 @@ namespace CalamityMod.NPCs.NormalNPCs else Projectile.NewProjectile(NPC.GetSource_FromAI(), npcPos, projVector, type, damage, 0f, Main.myPlayer); } + + NPC.netUpdate = true; } } public override Color? GetAlpha(Color drawColor) { - Color initialColor = Color.DarkRed; + Color initialColor = new Color(150, 0, 0); Color newColor = initialColor; - Color finalColor = Color.White; + Color finalColor = new Color(255, 125, 125); float colorTelegraphGateValue = (BossRushEvent.BossRushActive ? BoltShootGateValue_BossRush : CalamityWorld.death ? BoltShootGateValue_Death : BoltShootGateValue) - LightTelegraphDuration; if (NPC.ai[0] > colorTelegraphGateValue) newColor = Color.Lerp(initialColor, finalColor, (NPC.ai[0] - colorTelegraphGateValue) / LightTelegraphDuration); @@ -183,31 +185,35 @@ namespace CalamityMod.NPCs.NormalNPCs public override void HitEffect(NPC.HitInfo hit) { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, hit.HitDirection, -1f, 0, default, 1f); + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, hit.HitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + if (NPC.life <= 0) { - NPC.position.X = NPC.position.X + (NPC.width / 2); - NPC.position.Y = NPC.position.Y + (NPC.height / 2); - NPC.width = 45; - NPC.height = 45; + NPC.position = NPC.Center; + NPC.width = NPC.height = 45; NPC.position.X = NPC.position.X - (NPC.width / 2); NPC.position.Y = NPC.position.Y - (NPC.height / 2); + for (int i = 0; i < 2; i++) { - int rubyDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); + int rubyDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); Main.dust[rubyDust].velocity *= 3f; + Main.dust[rubyDust].noGravity = true; if (Main.rand.NextBool()) { Main.dust[rubyDust].scale = 0.5f; Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; } } + for (int j = 0; j < 10; j++) { - int rubyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 3f); + int rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 3f); Main.dust[rubyDust2].noGravity = true; Main.dust[rubyDust2].velocity *= 5f; - rubyDust2 = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); + rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemRuby, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust2].noGravity = true; Main.dust[rubyDust2].velocity *= 2f; } } diff --git a/NPCs/NormalNPCs/KingSlimeJewel.png b/NPCs/NormalNPCs/KingSlimeJewel.png index 326c657ab4..906567e7a7 100644 Binary files a/NPCs/NormalNPCs/KingSlimeJewel.png and b/NPCs/NormalNPCs/KingSlimeJewel.png differ diff --git a/NPCs/NormalNPCs/KingSlimeJewel2.cs b/NPCs/NormalNPCs/KingSlimeJewel2.cs new file mode 100644 index 0000000000..3025c9cb90 --- /dev/null +++ b/NPCs/NormalNPCs/KingSlimeJewel2.cs @@ -0,0 +1,191 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Events; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.NormalNPCs +{ + public class KingSlimeJewel2 : ModNPC + { + public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; + + private const int BuffDustGateValue = 60; + private const float LightTelegraphDuration = 45f; + + public override void SetStaticDefaults() + { + NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; + NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); + } + + public override void SetDefaults() + { + NPC.aiStyle = -1; + AIType = -1; + NPC.damage = 10; + NPC.width = 22; + NPC.height = 22; + NPC.defense = 5; + NPC.DR_NERD(0.05f); + + NPC.lifeMax = 105; + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); + + NPC.knockBackResist = 0.9f; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.HitSound = SoundID.NPCHit5; + NPC.DeathSound = SoundID.NPCDeath15; + NPC.Calamity().VulnerableToSickness = false; + } + + public override void AI() + { + // Setting this in SetDefaults will disable expert mode scaling, so put it here instead + NPC.damage = 0; + + // Despawn + if (!CalamityPlayer.areThereAnyDamnBosses) + { + NPC.life = 0; + NPC.HitEffect(); + NPC.active = false; + NPC.netUpdate = true; + return; + } + + Lighting.AddLight(NPC.Center, 0f, 0f, 0.8f); + + // Float around the player + NPC.rotation = NPC.velocity.X / 15f; + + NPC.TargetClosest(); + + float velocity = 5f; + float acceleration = 0.1f; + + if (NPC.position.Y > Main.player[NPC.target].position.Y - 300f) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > velocity) + NPC.velocity.Y = velocity; + } + else if (NPC.position.Y < Main.player[NPC.target].position.Y - 400f) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y += acceleration; + + if (NPC.velocity.Y < -velocity) + NPC.velocity.Y = -velocity; + } + + if (NPC.Center.X > Main.player[NPC.target].Center.X + 300f) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X -= acceleration; + + if (NPC.velocity.X > 8f) + NPC.velocity.X = 8f; + } + if (NPC.Center.X < Main.player[NPC.target].Center.X - 300f) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X += acceleration; + + if (NPC.velocity.X < -8f) + NPC.velocity.X = -8f; + } + + // Emit buff dust + NPC.ai[0] += 1f; + if (NPC.ai[0] >= BuffDustGateValue) + { + NPC.ai[0] = 0f; + + for (int dusty = 0; dusty < 10; dusty++) + { + Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + int sapphire = Dust.NewDust(NPC.Center, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); + Main.dust[sapphire].velocity = dustVel * Main.rand.NextFloat(1f, 2f); + Main.dust[sapphire].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[sapphire].scale = 0.5f; + Main.dust[sapphire].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + NPC.netUpdate = true; + } + } + + public override Color? GetAlpha(Color drawColor) + { + Color initialColor = new Color(0, 0, 150); + Color newColor = initialColor; + Color finalColor = new Color(125, 125, 255); + float colorTelegraphGateValue = BuffDustGateValue - LightTelegraphDuration; + if (NPC.ai[0] > colorTelegraphGateValue) + newColor = Color.Lerp(initialColor, finalColor, (NPC.ai[0] - colorTelegraphGateValue) / LightTelegraphDuration); + newColor.A = (byte)(255 * NPC.Opacity); + + return newColor; + } + + public override bool CheckActive() => false; + + public override void HitEffect(NPC.HitInfo hit) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, hit.HitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + + if (NPC.life <= 0) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = 45; + NPC.position.X = NPC.position.X - (NPC.width / 2); + NPC.position.Y = NPC.position.Y - (NPC.height / 2); + + for (int i = 0; i < 2; i++) + { + int rubyDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust].noGravity = true; + Main.dust[rubyDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[rubyDust].scale = 0.5f; + Main.dust[rubyDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 10; j++) + { + int rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 3f); + Main.dust[rubyDust2].noGravity = true; + Main.dust[rubyDust2].velocity *= 5f; + rubyDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemSapphire, 0f, 0f, 100, default, 2f); + Main.dust[rubyDust2].noGravity = true; + Main.dust[rubyDust2].velocity *= 2f; + } + } + } + } +} diff --git a/NPCs/NormalNPCs/KingSlimeJewel3.cs b/NPCs/NormalNPCs/KingSlimeJewel3.cs new file mode 100644 index 0000000000..b783e7870a --- /dev/null +++ b/NPCs/NormalNPCs/KingSlimeJewel3.cs @@ -0,0 +1,271 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Events; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.NormalNPCs +{ + public class KingSlimeJewel3 : ModNPC + { + public override string Texture => "CalamityMod/NPCs/NormalNPCs/KingSlimeJewel"; + + private const int ChargePhaseGateValue = 90; + private const int ChargeGateValue = 60; + private const int ChargeGateValue_Death = 40; + private const float LightTelegraphDuration = 30f; + + public override void SetStaticDefaults() + { + NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers() { Hide = true }; + NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); + } + + public override void SetDefaults() + { + NPC.aiStyle = -1; + AIType = -1; + NPC.GetNPCDamage(); + NPC.width = 22; + NPC.height = 22; + NPC.defense = 15; + NPC.DR_NERD(0.15f); + + NPC.lifeMax = 175; + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); + + NPC.knockBackResist = 0.7f; + NPC.noGravity = true; + NPC.noTileCollide = true; + NPC.HitSound = SoundID.NPCHit5; + NPC.DeathSound = SoundID.NPCDeath15; + NPC.Calamity().VulnerableToSickness = false; + } + + public override void AI() + { + // Despawn + if (!CalamityPlayer.areThereAnyDamnBosses) + { + NPC.life = 0; + NPC.HitEffect(); + NPC.active = false; + NPC.netUpdate = true; + return; + } + + Lighting.AddLight(NPC.Center, 0f, 0.8f, 0f); + + if (NPC.target < 0 || NPC.target == Main.maxPlayers || Main.player[NPC.target].dead) + NPC.TargetClosest(); + + if (NPC.ai[3] == 1f) + { + NPC.knockBackResist = 0f; + + if (NPC.ai[0] == 0f) + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.velocity *= CalamityWorld.death ? 0.94f : 0.96f; + + NPC.ai[1] += 1f; + + float anglularSpeed = NPC.ai[1] / (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue); + anglularSpeed = 0.1f + anglularSpeed * 0.4f; + NPC.rotation += anglularSpeed * NPC.direction; + + if (NPC.ai[1] >= (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue)) + { + for (int dusty = 0; dusty < 10; dusty++) + { + Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + int emerald = Dust.NewDust(NPC.Center, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emerald].velocity = dustVel * Main.rand.NextFloat(1f, 2f); + Main.dust[emerald].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[emerald].scale = 0.5f; + Main.dust[emerald].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + SoundEngine.PlaySound(SoundID.Item38, NPC.Center); + + NPC.ai[0] = 1f; + NPC.ai[1] = 0f; + NPC.netUpdate = true; + } + } + else if (NPC.ai[0] == 1f) + { + // Set damage + NPC.damage = NPC.defDamage; + + float chargeSpeed = CalamityWorld.death ? 24f : 16f; + NPC.velocity = NPC.SafeDirectionTo(Main.player[NPC.target].Center + Main.player[NPC.target].velocity * 20f, -Vector2.UnitY) * chargeSpeed; + NPC.rotation = NPC.velocity.ToRotation() + MathHelper.PiOver2; + + NPC.ai[0] = 2f; + NPC.ai[1] = 0f; + + NPC.netSpam = 0; + NPC.netUpdate = true; + } + else if (NPC.ai[0] == 2f) + { + // Set damage + NPC.damage = NPC.defDamage; + + NPC.ai[1] += 1f; + if (NPC.ai[1] >= (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue)) + { + // Avoid cheap bullshit + NPC.damage = 0; + + for (int dusty = 0; dusty < 10; dusty++) + { + Vector2 dustVel = Main.rand.NextVector2CircularEdge(5f, 5f); + int emerald = Dust.NewDust(NPC.Center, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emerald].velocity = dustVel * Main.rand.NextFloat(1f, 2f); + Main.dust[emerald].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[emerald].scale = 0.5f; + Main.dust[emerald].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + SoundEngine.PlaySound(SoundID.Item8, NPC.Center); + + NPC.ai[0] = 0f; + NPC.ai[1] = 0f; + NPC.ai[3] = 0f; + NPC.netUpdate = true; + + NPC.velocity = Vector2.Zero; + } + } + } + else + { + // Avoid cheap bullshit + NPC.damage = 0; + + NPC.knockBackResist = 0.7f; + + NPC.rotation = NPC.velocity.X / 15f; + + float velocity = 5f; + float acceleration = 0.2f; + + if (NPC.position.Y > Main.player[NPC.target].position.Y - 200f) + { + if (NPC.velocity.Y > 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y -= acceleration; + + if (NPC.velocity.Y > velocity) + NPC.velocity.Y = velocity; + } + else if (NPC.position.Y < Main.player[NPC.target].position.Y - 300f) + { + if (NPC.velocity.Y < 0f) + NPC.velocity.Y *= 0.98f; + + NPC.velocity.Y += acceleration; + + if (NPC.velocity.Y < -velocity) + NPC.velocity.Y = -velocity; + } + + if (NPC.Center.X > Main.player[NPC.target].Center.X + 200f) + { + if (NPC.velocity.X > 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X -= acceleration; + + if (NPC.velocity.X > 8f) + NPC.velocity.X = 8f; + } + if (NPC.Center.X < Main.player[NPC.target].Center.X - 200f) + { + if (NPC.velocity.X < 0f) + NPC.velocity.X *= 0.98f; + + NPC.velocity.X += acceleration; + + if (NPC.velocity.X < -8f) + NPC.velocity.X = -8f; + } + + NPC.ai[2] += 1f; + if (NPC.ai[2] >= ChargePhaseGateValue) + { + NPC.ai[2] = 0f; + NPC.ai[3] = 1f; + NPC.netUpdate = true; + } + } + } + + public override Color? GetAlpha(Color drawColor) + { + Color initialColor = new Color(0, 150, 0); + Color newColor = initialColor; + Color finalColor = new Color(125, 255, 125); + float colorTelegraphGateValue = (CalamityWorld.death ? ChargeGateValue_Death : ChargeGateValue) - LightTelegraphDuration; + if (NPC.ai[1] > colorTelegraphGateValue) + newColor = Color.Lerp(initialColor, finalColor, (NPC.ai[1] - colorTelegraphGateValue) / LightTelegraphDuration); + newColor.A = (byte)(255 * NPC.Opacity); + + return newColor; + } + + public override bool CheckActive() => false; + + public override void HitEffect(NPC.HitInfo hit) + { + int dust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, hit.HitDirection, -1f, 0, default, 1f); + Main.dust[dust].noGravity = true; + + if (NPC.life <= 0) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = 45; + NPC.position.X = NPC.position.X - (NPC.width / 2); + NPC.position.Y = NPC.position.Y - (NPC.height / 2); + + for (int i = 0; i < 2; i++) + { + int emeraldDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emeraldDust].noGravity = true; + Main.dust[emeraldDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[emeraldDust].scale = 0.5f; + Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 10; j++) + { + int emeraldDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 3f); + Main.dust[emeraldDust2].noGravity = true; + Main.dust[emeraldDust2].velocity *= 5f; + emeraldDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emeraldDust2].noGravity = true; + Main.dust[emeraldDust2].velocity *= 2f; + } + } + } + } +} diff --git a/NPCs/StormWeaver/StormWeaverBody.cs b/NPCs/StormWeaver/StormWeaverBody.cs index aa04081067..b09a9fc2a5 100644 --- a/NPCs/StormWeaver/StormWeaverBody.cs +++ b/NPCs/StormWeaver/StormWeaverBody.cs @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.StormWeaver global.unbreakableDR = true; NPC.chaseable = false; NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; + NPC.DeathSound = StormWeaverHead.DeathSound; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); @@ -136,7 +136,6 @@ namespace CalamityMod.NPCs.StormWeaver global.unbreakableDR = false; NPC.chaseable = true; NPC.HitSound = SoundID.NPCHit13; - NPC.DeathSound = SoundID.NPCDeath13; NPC.frame = new Rectangle(0, 0, 54, 52); } } diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index da887174c3..d82b2d4e5e 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -51,6 +51,9 @@ namespace CalamityMod.NPCs.StormWeaver private const float BoltAngleSpread = 280; private bool tail = false; + public static readonly SoundStyle ArmorShedSound = new("CalamityMod/Sounds/Custom/WeaverArmorShed"); + public static readonly SoundStyle DeathSound = new("CalamityMod/Sounds/NPCKilled/WeaverDeath"); + // Lightning flash variables public float lightning = 0f; private float lightningDecay = 1f; @@ -98,7 +101,7 @@ namespace CalamityMod.NPCs.StormWeaver global.unbreakableDR = true; NPC.chaseable = false; NPC.HitSound = SoundID.NPCHit4; - NPC.DeathSound = SoundID.NPCDeath14; + NPC.DeathSound = DeathSound; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); @@ -202,7 +205,7 @@ namespace CalamityMod.NPCs.StormWeaver if (Main.netMode != NetmodeID.Server) Gore.NewGore(NPC.GetSource_FromAI(), NPC.position, NPC.velocity, Mod.Find("SWArmorHead1").Type, NPC.scale); - SoundEngine.PlaySound(SoundID.NPCDeath14, NPC.Center); + SoundEngine.PlaySound(ArmorShedSound, NPC.Center); CalamityGlobalNPC global = NPC.Calamity(); NPC.defense = 20; @@ -210,7 +213,6 @@ namespace CalamityMod.NPCs.StormWeaver global.unbreakableDR = false; NPC.chaseable = true; NPC.HitSound = SoundID.NPCHit13; - NPC.DeathSound = SoundID.NPCDeath13; NPC.frame = new Rectangle(0, 0, 62, 86); } } diff --git a/NPCs/StormWeaver/StormWeaverTail.cs b/NPCs/StormWeaver/StormWeaverTail.cs index c92a9af2cf..06fbced28e 100644 --- a/NPCs/StormWeaver/StormWeaverTail.cs +++ b/NPCs/StormWeaver/StormWeaverTail.cs @@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.StormWeaver // Phase one settings NPC.takenDamageMultiplier = 2f; NPC.HitSound = SoundID.NPCHit53; - NPC.DeathSound = SoundID.NPCDeath14; + NPC.DeathSound = StormWeaverHead.DeathSound; double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; NPC.lifeMax += (int)(NPC.lifeMax * HPBoost); @@ -140,7 +140,6 @@ namespace CalamityMod.NPCs.StormWeaver global.DR = 0.4f; NPC.takenDamageMultiplier = 1f; NPC.HitSound = SoundID.NPCHit13; - NPC.DeathSound = SoundID.NPCDeath13; NPC.frame = new Rectangle(0, 0, 42, 68); } } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs index b7cc1787cf..91882982c8 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/BrainOfCthulhuAI.cs @@ -198,12 +198,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!despawn) { Vector2 brainCenter = npc.Center; - float targetXDist = Main.player[npc.target].Center.X - brainCenter.X; - float targetYDist = Main.player[npc.target].Center.Y - brainCenter.Y; + Vector2 destination = Main.player[npc.target].Center + (masterMode ? Main.player[npc.target].velocity * 20f : Vector2.Zero); + float targetXDist = destination.X - brainCenter.X; + float targetYDist = destination.Y - brainCenter.Y; float targetDistance = (float)Math.Sqrt(targetXDist * targetXDist + targetYDist * targetYDist); float velocityScale = death ? 6f : 4.5f; float velocityBoost = velocityScale * (1f - lifeRatio); - float nonChargeSpeed = 18f + velocityBoost + 3f * enrageScale; + float nonChargeSpeed = (masterMode ? 24f : 18f) + velocityBoost + 3f * enrageScale; if (Main.getGoodWorld) nonChargeSpeed *= 1.15f; @@ -213,6 +214,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float minInertia = death ? 60f : 75f; float maxInertia = death ? 80f : 100f; + if (masterMode) + { + minInertia -= 10f; + maxInertia -= 10f; + } + float inertia = MathHelper.Lerp(minInertia, maxInertia, lifeRatio); npc.velocity.X = (npc.velocity.X * inertia + targetXDist) / (inertia + 1f); npc.velocity.Y = (npc.velocity.Y * inertia + targetYDist) / (inertia + 1f); @@ -259,7 +266,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses SoundEngine.PlaySound(SoundID.ForceRoarPitched, npc.Center); // Velocity - npc.velocity = (Main.player[npc.target].Center + (bossRush ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; + npc.velocity = (Main.player[npc.target].Center + (masterMode ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center).SafeNormalize(Vector2.UnitY) * chargeVelocity; if (Main.getGoodWorld) npc.velocity *= 1.15f; } @@ -406,6 +413,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses spread = death ? 30 : 20; } + if (masterMode) + { + numProj += 3; + spread += 10; + } + float rotation = MathHelper.ToRadians(spread); for (int j = 0; j < numProj; j++) { @@ -444,6 +457,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses spread = death ? 15 : 10; } + if (masterMode) + { + numProj += 4; + spread += 15; + } + float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { @@ -673,7 +692,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float targetXDistPhase1 = Main.player[npc.target].Center.X - brainCenterPhase1.X; float targetYDistPhase1 = Main.player[npc.target].Center.Y - brainCenterPhase1.Y; float targetDistancePhase1 = (float)Math.Sqrt(targetXDistPhase1 * targetXDistPhase1 + targetYDistPhase1 * targetYDistPhase1); - float maxMoveVelocity = (death ? 2f : 1.5f) + velocityScale; + float maxMoveVelocity = (death ? (masterMode ? 4f : 2f) : (masterMode ? 3f : 1.5f)) + velocityScale; if (Main.getGoodWorld) maxMoveVelocity *= 2f; @@ -698,7 +717,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!despawn) npc.localAI[1] += (death ? 2f : 1f) + velocityScale; - if (npc.localAI[1] >= 360f) + if (npc.localAI[1] >= (masterMode ? 540f : 360f)) { // Teleport location npc.localAI[1] = 0f; @@ -855,7 +874,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float brainXDist = Main.npc[NPC.crimsonBoss].Center.X - creeperCenter.X; float brainYDist = Main.npc[NPC.crimsonBoss].Center.Y - creeperCenter.Y; float brainDistance = (float)Math.Sqrt(brainXDist * brainXDist + brainYDist * brainYDist); - float velocity = (death ? 12f : 8f) + chargeAggressionScale; + float velocity = (death ? (masterMode ? 16f : 12f) : (masterMode ? 12f : 8f)) + chargeAggressionScale; velocity += 2f * enrageScale; // Max distance from Brain @@ -905,9 +924,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - float chargeVelocity = (death ? 9f : 6f) + chargeAggressionScale; + float chargeVelocity = (death ? (masterMode ? 12f : 9f) : (masterMode ? 9f : 6f)) + chargeAggressionScale; chargeVelocity += 2f * enrageScale; - Vector2 targetDirection = Main.player[npc.target].Center - npc.Center; + Vector2 destination = Main.player[npc.target].Center + (masterMode ? Main.player[npc.target].velocity * 20f : Vector2.Zero); + Vector2 targetDirection = destination - npc.Center; targetDirection = targetDirection.SafeNormalize(Vector2.UnitY); if (Main.getGoodWorld) { @@ -922,7 +942,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Return to Brain after a set time - float chargeDistance = masterMode ? 700f : 600f; + float chargeDistance = masterMode ? 900f : 600f; float returnToBrainGateValue = chargeDistance / chargeVelocity; npc.ai[1] += 1f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs index cbde6907ff..01730b578d 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EaterOfWorldsAI.cs @@ -12,6 +12,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { public static class EaterOfWorldsAI { + private const int TotalMasterModeWorms = 4; + public static bool BuffedEaterofWorldsAI(NPC npc, Mod mod) { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); @@ -38,9 +40,6 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles && npc.type == NPCID.EaterofWorldsHead) npc.TargetClosest(); - // Fade in. - npc.Opacity = MathHelper.Clamp(npc.Opacity + 0.08f, 0f, 1f); - bool enrage = true; int targetTileX = (int)Main.player[npc.target].Center.X / 16; int targetTileY = (int)Main.player[npc.target].Center.Y / 16; @@ -68,7 +67,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float segmentCount = NPC.CountNPCS(NPCID.EaterofWorldsBody); // Percent body segments remaining - float lifeRatio = segmentCount / totalSegments; + float lifeRatio = MathHelper.Clamp(segmentCount / totalSegments, 0f, 1f); // 10 seconds of resistance to prevent spawn killing if (calamityGlobalNPC.newAI[1] < 600f && bossRush) @@ -85,6 +84,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Boost velocity by 50% phase bool phase4 = lifeRatio < (masterMode ? 0.5f : 0.2f); + // Go fucking crazy in Master Mode + bool phase5 = lifeRatio < 0.15f && masterMode; + bool phase6 = lifeRatio < 0.05f && masterMode; + // Fire projectiles if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -163,8 +166,29 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // A head sets the length variable (npc.ai[2]) and then sets its next segment to a freshly spawned body. if (npc.type == NPCID.EaterofWorldsHead) { + // Amount of segments to spawn. + int segmentSpawnAmount = (int)(masterMode ? (totalSegments / TotalMasterModeWorms) : totalSegments); + + // Spawn additional worms of reduced length in Master Mode. + if (masterMode) + { + Vector2 additionalWormSpawnLocation = new Vector2(spawnX, spawnY); + int randomXLimit = 80; + int randomYLimit = 80; + for (int i = 1; i < TotalMasterModeWorms; i++) + { + additionalWormSpawnLocation += new Vector2((Main.rand.Next(randomXLimit + 1) + randomXLimit) * (Main.rand.NextBool() ? -1f : 1f), Main.rand.Next(randomYLimit + 1) + randomYLimit); + int wormHead = NPC.NewNPC(npc.GetSource_FromAI(), (int)additionalWormSpawnLocation.X, (int)additionalWormSpawnLocation.Y, NPCID.EaterofWorldsHead, npc.whoAmI + segmentSpawnAmount * i + 1); + Main.npc[wormHead].ai[2] = segmentSpawnAmount; + Main.npc[wormHead].ai[0] = NPC.NewNPC(Main.npc[wormHead].GetSource_FromAI(), (int)additionalWormSpawnLocation.X, (int)additionalWormSpawnLocation.Y, NPCID.EaterofWorldsBody, Main.npc[wormHead].whoAmI); + Main.npc[(int)Main.npc[wormHead].ai[0]].ai[1] = Main.npc[wormHead].whoAmI; + Main.npc[(int)Main.npc[wormHead].ai[0]].ai[2] = Main.npc[wormHead].ai[2] - 1f; + Main.npc[wormHead].netUpdate = true; + } + } + // Set head's "length beyond this point" to be the total length of the worm. - npc.ai[2] = totalSegments; + npc.ai[2] = segmentSpawnAmount; // Body spawn npc.ai[0] = NPC.NewNPC(npc.GetSource_FromAI(), spawnX, spawnY, NPCID.EaterofWorldsBody, npc.whoAmI); @@ -300,7 +324,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses noFlyZone -= (int)(enrageScale * 200f); if (masterMode) - noFlyZone -= 200; + noFlyZone -= phase5 ? 400 : 200; if (noFlyZone < 100) noFlyZone = 100; @@ -331,7 +355,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float segmentVelocity = 12f + velocityBoost; float segmentAcceleration = 0.15f + accelerationBoost; - if (phase4) + if (phase6) + { + segmentVelocity += 6f * (enrageScale + 1f); + segmentAcceleration += 0.3f * (enrageScale + 1f); + } + else if (phase5) + { + segmentVelocity += 4f * (enrageScale + 1f); + segmentAcceleration += 0.2f * (enrageScale + 1f); + } + else if (phase4) { segmentVelocity += 2f * (enrageScale + 1f); segmentAcceleration += 0.1f * (enrageScale + 1f); @@ -355,8 +389,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } Vector2 segmentDirection = npc.Center; - float targetPosX = Main.player[npc.target].Center.X; - float targetPosY = Main.player[npc.target].Center.Y; + Vector2 destination = Main.player[npc.target].Center + (phase6 ? Main.player[npc.target].velocity * 20f : Vector2.Zero); + float targetPosX = destination.X; + float targetPosY = destination.Y; targetPosX = (int)(targetPosX / 16f) * 16; targetPosY = (int)(targetPosY / 16f) * 16; @@ -497,14 +532,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses while (segmentAmt > 0 && segmentAmt < Main.maxNPCs && Main.npc[segmentAmt].active && Main.npc[segmentAmt].aiStyle == npc.aiStyle) { - int arg_2853_0 = (int)Main.npc[segmentAmt].ai[0]; + int attachedSegments = (int)Main.npc[segmentAmt].ai[0]; Main.npc[segmentAmt].active = false; npc.life = 0; if (Main.netMode == NetmodeID.Server) NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, segmentAmt, 0f, 0f, 0f, 0, 0, 0); - segmentAmt = arg_2853_0; + segmentAmt = attachedSegments; } if (Main.netMode == NetmodeID.Server) @@ -1208,8 +1243,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static int GetEaterOfWorldsSegmentsCountRevDeath() { return CalamityWorld.LegendaryMode ? 100 : - (CalamityWorld.death || BossRushEvent.BossRushActive) ? ((Main.masterMode || BossRushEvent.BossRushActive) ? 62 : 57) : - ((Main.masterMode || BossRushEvent.BossRushActive) ? 67 : 62); + (CalamityWorld.death || BossRushEvent.BossRushActive) ? ((Main.masterMode || BossRushEvent.BossRushActive) ? 60 : 57) : + ((Main.masterMode || BossRushEvent.BossRushActive) ? 68 : 62); } public static int GetEaterOfWorldsSegmentsCountVanilla() diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs index 5e7306e588..16bc0e3123 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/EyeOfCthulhuAI.cs @@ -1,5 +1,6 @@ using System; using CalamityMod.Events; +using CalamityMod.NPCs.NormalNPCs; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -152,7 +153,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses hoverAcceleration += 0.08f; } - float attackSwitchTimer = 180f - (death ? 180f * (1f - lifeRatio) : 0f); + float attackSwitchTimer = (masterMode ? 120f : 180f) - (death ? 180f * (1f - lifeRatio) : 0f); bool timeToCharge = npc.ai[2] >= attackSwitchTimer; Vector2 hoverDestination = Main.player[npc.target].Center - Vector2.UnitY * 400f; Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * (hoverSpeed + (timeToCharge ? ((npc.ai[2] - attackSwitchTimer) * 0.01f) : 0f)); @@ -172,7 +173,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!Main.player[npc.target].dead) npc.ai[3] += 1f; - float servantSpawnGateValue = death ? 20f : 40f; + float servantSpawnGateValue = death ? (masterMode ? 10f : 20f) : (masterMode ? 25f : 40f); if (Main.getGoodWorld) servantSpawnGateValue *= 0.8f; @@ -242,13 +243,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = npc.defDamage; - int chargeDelay = 90; + int chargeDelay = masterMode ? 70 : 90; if (death) chargeDelay -= (int)Math.Round(40f * (1f - lifeRatio)); if (Main.getGoodWorld) chargeDelay -= 30; - float slowDownGateValue = chargeDelay * (death ? 0.75f : 0.65f); + float slowDownGateValue = chargeDelay * (death ? (masterMode ? 0.9f : 0.75f) : (masterMode ? 0.8f : 0.65f)); npc.ai[2] += 1f; if (npc.ai[2] >= slowDownGateValue) @@ -260,7 +261,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (decelerationScalar < 0f) decelerationScalar = 0f; - npc.velocity *= (MathHelper.Lerp(0.92f, 0.96f, decelerationScalar)); + npc.velocity *= (MathHelper.Lerp(masterMode ? 0.76f : 0.92f, masterMode ? 0.88f : 0.96f, decelerationScalar)); if (Main.getGoodWorld) npc.velocity *= 0.99f; @@ -338,14 +339,24 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] += phaseChangeRate; if (npc.ai[1] % servantSpawnGateValue == 0f) { - Vector2 servantSpawnVelocity = Main.rand.NextVector2CircularEdge(5.65f, 5.65f); + float servantVelocity = masterMode ? 11.3f : 5.65f; + Vector2 servantSpawnVelocity = Main.rand.NextVector2CircularEdge(servantVelocity, servantVelocity); if (Main.getGoodWorld) servantSpawnVelocity *= 3f; Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; if (Main.netMode != NetmodeID.MultiplayerClient) { - int servantSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu, 0, 0f, 0f, enrageScale); + int spawnType = NPCID.ServantofCthulhu; + if (masterMode) + { + int maxBloodServants = 2; + bool spawnBloodServant = NPC.CountNPCS(ModContent.NPCType()) < maxBloodServants; + if (spawnBloodServant) + spawnType = ModContent.NPCType(); + } + + int servantSpawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, spawnType, 0, 0f, 0f, enrageScale); Main.npc[servantSpawn].velocity.X = servantSpawnVelocity.X; Main.npc[servantSpawn].velocity.Y = servantSpawnVelocity.Y; @@ -461,13 +472,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses hoverAcceleration += 0.1f; } - float phaseLimit = 200f - (death ? 150f * (phase2LifeRatio - lifeRatio) : 0f); + float phaseLimit = (masterMode ? 160f : 200f) - (death ? 150f * (phase2LifeRatio - lifeRatio) : 0f); bool timeToCharge = npc.ai[2] >= phaseLimit; Vector2 idealHoverVelocity = npc.SafeDirectionTo(hoverDestination) * (hoverSpeed + (timeToCharge ? ((npc.ai[2] - phaseLimit) * 0.01f) : 0f)); npc.SimpleFlyMovement(idealHoverVelocity, hoverAcceleration + (timeToCharge ? ((npc.ai[2] - phaseLimit) * 0.001f) : 0f)); npc.ai[2] += 1f; - float projectileGateValue = (lifeRatio < 0.5f && death) ? 50f : 80f; + float projectileGateValue = (lifeRatio < 0.5f && death) ? (masterMode ? 40f : 50f) : (masterMode ? 60f : 80f); if (npc.ai[2] % projectileGateValue == 0f && shootProjectile) { Vector2 projectileVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity * 2f; @@ -475,8 +486,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { int type = ProjectileID.BloodNautilusShot; - int numProj = 3; - int spread = 10; + int numProj = masterMode ? Main.rand.Next(4, 6) : 3; + int spread = masterMode ? numProj * 3 : 10; float rotation = MathHelper.ToRadians(spread); for (int i = 0; i < numProj; i++) { @@ -530,11 +541,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Set damage npc.damage = setDamage; - int phase2ChargeDelay = 80; + int phase2ChargeDelay = masterMode ? 60 : 80; if (death) phase2ChargeDelay -= (int)Math.Round(35f * (phase2LifeRatio - lifeRatio)); - float slowDownGateValue = phase2ChargeDelay * (death ? 0.85f : 0.75f); + float slowDownGateValue = phase2ChargeDelay * (death ? (masterMode ? 0.95f : 0.85f) : (masterMode ? 0.9f : 0.75f)); npc.ai[2] += 1f; if (npc.ai[2] >= slowDownGateValue) @@ -546,7 +557,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (decelerationScalar < 0f) decelerationScalar = 0f; - npc.velocity *= (MathHelper.Lerp(0.9f, 0.95f, decelerationScalar)); + npc.velocity *= (MathHelper.Lerp(masterMode ? 0.6f : 0.9f, masterMode ? 0.7f : 0.95f, decelerationScalar)); if (npc.velocity.X > -0.1 && npc.velocity.X < 0.1) npc.velocity.X = 0f; if (npc.velocity.Y > -0.1 && npc.velocity.Y < 0.1) @@ -611,10 +622,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float targetVelocity = Math.Abs(Main.player[npc.target].velocity.X) + Math.Abs(Main.player[npc.target].velocity.Y) / 4f; targetVelocity += 10f - targetVelocity; - if (targetVelocity < 5f) - targetVelocity = 5f; - if (targetVelocity > 15f) - targetVelocity = 15f; + if (targetVelocity < (masterMode ? 2f : 5f)) + targetVelocity = (masterMode ? 2f : 5f); + if (targetVelocity > (masterMode ? 6f : 15f)) + targetVelocity = (masterMode ? 6f : 15f); if (npc.ai[2] == -1f) { @@ -733,6 +744,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float accelerationBoost = death ? 0.425f * (phase3LifeRatio - lifeRatio) : 0.125f * (phase3LifeRatio - lifeRatio); float hoverSpeed = 8f + speedBoost; float hoverAcceleration = 0.25f + accelerationBoost; + hoverSpeed += enrageScale * 4f; + hoverAcceleration += enrageScale * 0.125f; Vector2 eyeLineUpChargeDirection = npc.Center; float lineUpChargeTargetX = Main.player[npc.target].Center.X - eyeLineUpChargeDirection.X; @@ -762,8 +775,31 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 servantSpawnVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY) * servantAndProjectileVelocity; Vector2 servantSpawnCenter = npc.Center + servantSpawnVelocity.SafeNormalize(Vector2.UnitY) * ProjectileOffset; - int maxServants = death ? (finalPhaseDeath ? 1 : penultimatePhaseDeath ? 2 : 3) : (finalPhaseRev ? 2 : 4); - bool spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; + int spawnType = NPCID.ServantofCthulhu; + bool spawnServant = false; + float enrageScaleToPass = enrageScale; + if (masterMode) + { + int maxBloodServants = 2; + bool spawnBloodServant = NPC.CountNPCS(ModContent.NPCType()) < maxBloodServants; + if (spawnBloodServant) + { + spawnType = ModContent.NPCType(); + spawnServant = true; + enrageScaleToPass += 0.5f; + } + else + { + int maxServants = death ? 1 : 2; + spawnServant = (penultimatePhaseDeath || finalPhaseRev) ? false : NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; + } + } + else + { + int maxServants = death ? (finalPhaseDeath ? 1 : penultimatePhaseDeath ? 2 : 3) : (finalPhaseRev ? 2 : 4); + spawnServant = NPC.CountNPCS(NPCID.ServantofCthulhu) < maxServants; + } + if (spawnServant) SoundEngine.PlaySound(SoundID.NPCDeath13, servantSpawnCenter); @@ -771,7 +807,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { if (spawnServant) { - int eye = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, NPCID.ServantofCthulhu, 0, 0f, 0f, enrageScale); + int eye = NPC.NewNPC(npc.GetSource_FromAI(), (int)servantSpawnCenter.X, (int)servantSpawnCenter.Y, spawnType, 0, 0f, 0f, enrageScaleToPass); Main.npc[eye].velocity.X = servantSpawnVelocity.X; Main.npc[eye].velocity.Y = servantSpawnVelocity.Y; @@ -839,9 +875,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } npc.TargetClosest(); - calamityGlobalNPC.newAI[0] += 1f; + calamityGlobalNPC.newAI[0] += ((masterMode && calamityGlobalNPC.newAI[0] % 2f != 0f) ? Main.rand.Next(2) + 1f : 1f); if (calamityGlobalNPC.newAI[0] > 3f) - calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[0] = masterMode ? Main.rand.Next(2) : 0f; npc.SyncExtraAI(); } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs index 9471ffab87..81e179c8bd 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/KingSlimeAI.cs @@ -50,18 +50,40 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Spawn Crystal phase bool phase3 = lifeRatio < 0.5f; - // Check if the crystal is alive + // Check if the crystals are alive bool crystalAlive = true; + bool blueCrystalAlive = false; + bool greenCrystalAlive = true; if (phase3) + { crystalAlive = NPC.AnyNPCs(ModContent.NPCType()); + if (masterMode) + { + blueCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); + greenCrystalAlive = NPC.AnyNPCs(ModContent.NPCType()); + } + } + + // Sapphire Crystal buffs + int setDamage = npc.defDamage; + npc.defense = npc.defDefense; + if (blueCrystalAlive) + { + setDamage = (int)Math.Round(setDamage * 1.5); + npc.defense *= 2; + } + + // Dust color when the blue crystal is alive + Color dustColor = Color.Lerp(new Color(0, 0, 150, npc.alpha), new Color(125, 125, 255, npc.alpha), (float)Math.Sin(Main.GlobalTimeWrappedHourly) / 2f + 0.5f); // Spawn crystal in phase 2 if (phase3 && npc.Calamity().newAI[0] == 0f) { npc.Calamity().newAI[0] = 1f; npc.SyncExtraAI(); - Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2); - for (int i = 0; i < 20; i++) + Vector2 vector = npc.Center + new Vector2(-40f, -(float)npc.height / 2) * npc.scale; + int totalDustPerCrystalSpawn = 20; + for (int i = 0; i < totalDustPerCrystalSpawn; i++) { int rubyDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemRuby, 0f, 0f, 100, default, 2f); Main.dust[rubyDust].velocity *= 2f; @@ -73,10 +95,44 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - SoundEngine.PlaySound(SoundID.Item38, npc.Center); + if (masterMode) + { + for (int i = 0; i < totalDustPerCrystalSpawn; i++) + { + int sapphireDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemSapphire, 0f, 0f, 100, default, 2f); + Main.dust[sapphireDust].velocity *= 2f; + Main.dust[sapphireDust].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[sapphireDust].scale = 0.5f; + Main.dust[sapphireDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + + for (int i = 0; i < totalDustPerCrystalSpawn; i++) + { + int emeraldDust = Dust.NewDust(vector, npc.width / 2, npc.height / 2, DustID.GemEmerald, 0f, 0f, 100, default, 2f); + Main.dust[emeraldDust].velocity *= 2f; + Main.dust[emeraldDust].noGravity = true; + if (Main.rand.NextBool()) + { + Main.dust[emeraldDust].scale = 0.5f; + Main.dust[emeraldDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f; + } + } + } + + SoundEngine.PlaySound(SoundID.Item38, vector); if (Main.netMode != NetmodeID.MultiplayerClient) + { NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + if (masterMode) + { + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + NPC.NewNPC(npc.GetSource_FromAI(), (int)vector.X, (int)vector.Y, ModContent.NPCType()); + } + } } // Set up health value for spawning slimes @@ -154,7 +210,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Get closer to activating teleport if (npc.ai[2] < teleportGateValue) { - if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > 320f) + if (!Collision.CanHitLine(npc.Center, 0, 0, Main.player[npc.target].Center, 0, 0) || Math.Abs(npc.Top.Y - Main.player[npc.target].Bottom.Y) > (masterMode ? 160f : 320f)) npc.ai[2] += death ? 3f : 2f; else npc.ai[2] += 1f; @@ -168,7 +224,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses teleporting = true; npc.aiAction = 1; + float teleportRate = crystalAlive ? 1f : 2f; + if (masterMode) + teleportRate *= 2f; + npc.ai[0] += teleportRate; teleportScale = MathHelper.Clamp((60f - npc.ai[0]) / 60f, 0f, 1f); teleportScale = 0.5f + teleportScale * 0.5f; @@ -199,9 +259,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { for (int i = 0; i < 10; i++) { - int slimeDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); + int slimeDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, blueCrystalAlive ? DustID.GemSapphire : DustID.TintableDust, npc.velocity.X, npc.velocity.Y, blueCrystalAlive ? 100 : 150, blueCrystalAlive ? dustColor : new Color(78, 136, 255, 80), 2f); Main.dust[slimeDust].noGravity = true; - Main.dust[slimeDust].velocity *= 0.5f; + Main.dust[slimeDust].velocity *= blueCrystalAlive ? 0f : 0.5f; } } } @@ -214,7 +274,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses teleporting = true; npc.aiAction = 0; + float teleportRate = crystalAlive ? 1f : 2f; + if (masterMode) + teleportRate *= 2f; + npc.ai[0] += teleportRate; teleportScale = MathHelper.Clamp(npc.ai[0] / 30f, 0f, 1f); teleportScale = 0.5f + teleportScale * 0.5f; @@ -238,9 +302,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses for (int j = 0; j < 10; j++) { - int slimyDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 150, new Color(78, 136, 255, 80), 2f); + int slimyDust = Dust.NewDust(npc.position + Vector2.UnitX * -20f, npc.width + 40, npc.height, blueCrystalAlive ? DustID.GemSapphire : DustID.TintableDust, npc.velocity.X, npc.velocity.Y, blueCrystalAlive ? 100 : 150, blueCrystalAlive ? dustColor : new Color(78, 136, 255, 80), 2f); Main.dust[slimyDust].noGravity = true; - Main.dust[slimyDust].velocity *= 2f; + Main.dust[slimyDust].velocity *= blueCrystalAlive ? 0f : 2f; } } @@ -262,7 +326,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (npc.ai[0] >= 0f) { // Set damage - npc.damage = npc.defDamage; + npc.damage = setDamage; npc.netUpdate = true; npc.TargetClosest(); @@ -280,12 +344,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 2f; float bossRushJumpSpeedMult = 1.5f; - float yVelocityMult = 1.2f; // Jump type if (npc.ai[1] == 3f) { - npc.velocity.Y = -13f * speedMult; + npc.velocity.Y = -10f * speedMult; npc.velocity.X += (phase2 ? (death ? 5.5f : 4.5f) : 3.5f) * npc.direction; npc.ai[0] = -100f; npc.ai[1] = 0f; @@ -308,14 +371,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] += 1f; } - if (masterMode) + if (!greenCrystalAlive) { - npc.velocity.X *= 1.4f; - npc.velocity.Y *= 1.2f; + npc.velocity.X *= 1.2f; + npc.velocity.Y *= 0.6f; } - if (!crystalAlive) - npc.velocity.Y *= yVelocityMult; + if (masterMode) + npc.velocity.X *= 1.4f; if (bossRush) npc.velocity.X *= bossRushJumpSpeedMult; @@ -332,9 +395,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { float jumpVelocityLimit = crystalAlive ? 3f : 4.5f; if (masterMode) - jumpVelocityLimit += 1f; + jumpVelocityLimit += 3f; if (Main.getGoodWorld) - jumpVelocityLimit = 6f; + jumpVelocityLimit = 8f; if ((npc.direction == 1 && npc.velocity.X < jumpVelocityLimit) || (npc.direction == -1 && npc.velocity.X > -jumpVelocityLimit)) { @@ -342,13 +405,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { npc.velocity.X += (bossRush ? 0.4f : death ? 0.25f : 0.2f) * npc.direction; if (masterMode) - npc.velocity.X += 0.2f * npc.direction; + npc.velocity.X += 0.3f * npc.direction; } else { npc.velocity.X *= bossRush ? 0.9f : death ? 0.92f : 0.93f; if (masterMode) - npc.velocity.X *= 0.95f; + npc.velocity.X *= 0.9f; } } @@ -363,10 +426,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } - // Spawn dust - int idleSlimeDust = Dust.NewDust(npc.position, npc.width, npc.height, DustID.TintableDust, npc.velocity.X, npc.velocity.Y, 255, new Color(0, 80, 255, 80), npc.scale * 1.2f); + int idleSlimeDust = Dust.NewDust(npc.position, npc.width, npc.height, blueCrystalAlive ? DustID.GemSapphire : DustID.TintableDust, npc.velocity.X, npc.velocity.Y, blueCrystalAlive ? 100 : 255, blueCrystalAlive ? dustColor : new Color(0, 80, 255, 80), npc.scale * 1.2f); Main.dust[idleSlimeDust].noGravity = true; - Main.dust[idleSlimeDust].velocity *= 0.5f; + Main.dust[idleSlimeDust].velocity *= blueCrystalAlive ? 0f : 0.5f; if (npc.life <= 0) return false; @@ -843,7 +905,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses public static void GetPlaceToTeleportTo(NPC npc) { npc.TargetClosest(false); - Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(Vector2.Zero) * 800f; + float distanceAhead = 640f; + Vector2 randomDefault = Main.rand.NextBool() ? Vector2.UnitX : -Vector2.UnitX; + Vector2 vectorAimedAheadOfTarget = Main.player[npc.target].Center + new Vector2((float)Math.Round(Main.player[npc.target].velocity.X), 0f).SafeNormalize(randomDefault) * distanceAhead; Point predictiveTeleportPoint = vectorAimedAheadOfTarget.ToTileCoordinates(); int randomPredictiveTeleportOffset = 5; int teleportTries = 0; @@ -858,7 +922,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses bool canTeleportToTile = true; if (canTeleportToTile && Main.tile[teleportTileX, teleportTileY].LiquidType == LiquidID.Lava) canTeleportToTile = false; - if (canTeleportToTile && !Collision.CanHitLine(npc.Center, 0, 0, vectorAimedAheadOfTarget, 0, 0)) + if (canTeleportToTile && !Collision.CanHitLine(npc.Center, 0, 0, predictiveTeleportPoint.ToVector2() * 16, 0, 0)) canTeleportToTile = false; if (canTeleportToTile) @@ -867,7 +931,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[2] = teleportTileY * 16 + 16; break; } + else + predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; } + else + predictiveTeleportPoint.X += predictiveTeleportPoint.X < 0f ? 1 : -1; } // Default teleport if the above conditions aren't met in 100 iterations diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs index 7ad5cc5df0..36e4852aca 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/PlanteraAI.cs @@ -132,7 +132,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float chargeDeceleration = bossRush ? 0.85f : phase4 ? 0.92f : phase3 ? 0.95f : 0.96f; // Enrage if target is on the surface - if (!bossRush && (surface || Main.player[npc.target].position.Y > ((Main.maxTilesY - 200) * 16))) + if (!bossRush && (surface || Main.player[npc.target].position.Y > Main.UnderworldLayer * 16)) { enrage = true; velocity += 8f; @@ -792,7 +792,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (masterMode && Main.netMode != NetmodeID.MultiplayerClient) { - float sporeSpeed = Main.masterMode ? 12f : 10f; + float sporeSpeed = 12f; Vector2 sporeVelocity = projectileVelocity * sporeSpeed; int spore = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, NPCID.Spore); Main.npc[spore].velocity.X = sporeVelocity.X; @@ -897,7 +897,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses despawn = true; // Enrage if Plantera's target is on the surface - if (!enrage && ((Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16.0 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > ((Main.maxTilesY - 200) * 16)) | despawn)) + if (!enrage && ((Main.player[Main.npc[NPC.plantBoss].target].position.Y < Main.worldSurface * 16.0 || Main.player[Main.npc[NPC.plantBoss].target].position.Y > Main.UnderworldLayer * 16) | despawn)) { npc.localAI[0] -= 4f; enrage = true; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs index 018cac6431..7256b8b40c 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs @@ -65,7 +65,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float lifeRatio = npc.life / (float)npc.lifeMax; // Bee spawn limit - int beeLimit = 15; + int beeLimit = masterMode ? 9 : 15; // Queen Bee Bee count int totalBees = 0; @@ -85,6 +85,34 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } } + // Hornet spawn limit + int hornetLimit = 3; + bool hornetLimitReached = false; + + // Only run this when necessary + if (masterMode) + { + // Queen Bee Hornet count + int totalHornets = 0; + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC hornet = Main.npc[i]; + bool isQueenBeeHornet = hornet.ai[3] == 1f; + if (hornet.active && (hornet.type == NPCID.LittleHornetHoney || hornet.type == NPCID.HornetHoney || hornet.type == NPCID.BigHornetHoney) && isQueenBeeHornet) + { + int hornetCountIncrement = hornet.type == NPCID.BigHornetHoney ? 3 : hornet.type == NPCID.HornetHoney ? 2 : 1; + totalHornets += hornetCountIncrement; + if (totalHornets >= hornetLimit) + { + hornetLimitReached = true; + break; + } + } + } + } + else + hornetLimitReached = true; + // Phases // Become more aggressive and start firing double stingers (triple in death mode) phase @@ -181,7 +209,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses int phase; int maxRandom = phase4 ? 5 : 4; do phase = Main.rand.Next(maxRandom); - while (phase == npc.ai[1] || phase == 1 || (phase == 2 && phase4)); + while (phase == npc.ai[1] || phase == 1 || (phase == 2 && phase4) || (masterMode && phase6 && phase == 3)); bool charging = phase == 0; @@ -252,7 +280,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (death) chargeDistanceY += MathHelper.Lerp(0f, 100f, 1f - lifeRatio); if (masterMode) - chargeDistanceY *= 1.5f; + chargeDistanceY *= 2f; float distanceFromTargetX = Math.Abs(npc.Center.X - Main.player[npc.target].Center.X); float distanceFromTargetY = Math.Abs(npc.Center.Y - Main.player[npc.target].Center.Y); @@ -292,6 +320,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float chargeAccelerationX = (phase4 ? 0.9f : phase2 ? 0.7f : 0.5f) + 0.5f * enrageScale; float chargeAccelerationY = (phase4 ? 0.45f : phase2 ? 0.35f : 0.25f) + 0.25f * enrageScale; + if (masterMode) + { + chargeVelocityX += 2f; + chargeVelocityY += 4f; + chargeAccelerationX += 0.15f; + chargeAccelerationY += 0.3f; + } + // Velocity calculations if (npc.Center.Y < Main.player[npc.target].Center.Y - chargeDistanceY) npc.velocity.Y += chargeAccelerationY; @@ -361,7 +397,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses shouldCharge = true; } if (enrageScale > 0f && shouldCharge) - npc.velocity *= MathHelper.Lerp(0.3f, 1f, 1f - enrageScale / maxEnrageScale); + npc.velocity *= MathHelper.Lerp(0.3f, masterMode ? 0.8f : 1f, 1f - enrageScale / maxEnrageScale); // Keep moving if (npc.ai[2] != 1f) @@ -402,8 +438,38 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else spawnType = NPCID.Hellbat; } + else if (masterMode) + { + int random = hornetLimitReached ? 0 : beeLimitReached ? Main.rand.Next(6, 12) : Main.rand.Next(12); + switch (random) + { + default: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; - if (!beeLimitReached) + case 6: + case 7: + case 8: + spawnType = NPCID.LittleHornetHoney; + break; + + case 9: + case 10: + spawnType = NPCID.HornetHoney; + break; + + case 11: + spawnType = NPCID.BigHornetHoney; + break; + } + } + + if (!beeLimitReached || !hornetLimitReached) { int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)npc.Center.X, (int)npc.Center.Y, spawnType); Vector2 beeVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); @@ -480,8 +546,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (masterMode) { - beeAttackAccel *= 1.4f; - beeAttackSpeed *= 1.2f; + beeAttackAccel *= 2f; + beeAttackSpeed *= 1.5f; } bool canHitTarget = Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height); @@ -491,7 +557,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Go to bee spawn phase calamityGlobalNPC.newAI[0] += 1f; - if ((Vector2.Distance(npc.Center, hoverDestination) < 400f && canHitTarget) || calamityGlobalNPC.newAI[0] >= 180f) + if ((Vector2.Distance(npc.Center, hoverDestination) < 400f && canHitTarget) || calamityGlobalNPC.newAI[0] >= (masterMode ? 90f : 180f)) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -518,8 +584,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (masterMode) { - beeAttackHoverAccel *= 1.4f; - beeAttackHoverSpeed *= 1.2f; + beeAttackHoverAccel *= 2f; + beeAttackHoverSpeed *= 1.5f; } Vector2 beeSpawnLocation = new Vector2(npc.Center.X + (Main.rand.Next(20) * npc.direction), npc.position.Y + npc.height * 0.8f); @@ -550,7 +616,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses } // Spawn bees - if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && spawnBee && !beeLimitReached) + if (Collision.CanHit(beeSpawnLocation, 1, 1, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height) && spawnBee && (!beeLimitReached || !hornetLimitReached)) { if (!phase3 || Main.zenithWorld) SoundEngine.PlaySound(SoundID.NPCHit1, beeSpawnLocation); @@ -559,7 +625,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (Main.netMode != NetmodeID.MultiplayerClient) { - if (phase3 && !Main.zenithWorld) + if (phase3) { Projectile.NewProjectile(npc.GetSource_FromAI(), beeSpawnLocation, (Main.player[npc.target].Center - beeSpawnLocation).SafeNormalize(Vector2.UnitY), ProjectileID.BeeHive, 0, 0f, Main.myPlayer, 0f, 0f, 1f); } @@ -573,6 +639,36 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else spawnType = NPCID.Hellbat; } + else if (masterMode) + { + int random = hornetLimitReached ? 0 : beeLimitReached ? Main.rand.Next(6, 12) : Main.rand.Next(12); + switch (random) + { + default: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + + case 6: + case 7: + case 8: + spawnType = NPCID.LittleHornetHoney; + break; + + case 9: + case 10: + spawnType = NPCID.HornetHoney; + break; + + case 11: + spawnType = NPCID.BigHornetHoney; + break; + } + } int spawn = NPC.NewNPC(npc.GetSource_FromAI(), (int)beeSpawnLocation.X, (int)beeSpawnLocation.Y, spawnType); Vector2 beeVelocity = (Main.player[npc.target].Center - npc.Center).SafeNormalize(Vector2.UnitY); @@ -601,7 +697,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Go to a random phase float numSpawns = phase3 ? (masterMode ? 1f : 2f) : (masterMode ? 3f : 5f); - if (npc.ai[2] > numSpawns || beeLimitReached) + if (npc.ai[2] > numSpawns || (beeLimitReached && hornetLimitReached)) { npc.ai[0] = -1f; npc.ai[1] = 2f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index 911ce5acbd..f5407f5719 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -29,11 +29,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float lifeRatio = npc.life / (float)npc.lifeMax; // Phases - float phase2LifeRatio = 0.85f; - float phase3LifeRatio = 0.7f; + float phase2LifeRatio = masterMode ? 1f : 0.85f; + float phase3LifeRatio = masterMode ? 0.9f : 0.7f; float respawnHandsLifeRatio = 0.5f; - float phase4LifeRatio = 0.3f; - float phase5LifeRatio = 0.1f; + float phase4LifeRatio = masterMode ? 0.4f : 0.3f; + float phase5LifeRatio = masterMode ? 0.2f : 0.1f; // Begin firing spreads of skulls phase bool phase2 = lifeRatio < phase2LifeRatio; @@ -450,7 +450,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float headYTopSpeed = headYAcceleration * 100f; float headXAcceleration = (Main.getGoodWorld ? 0.21f : masterMode ? 0.16f : 0.08f) + (death ? 0.08f * (1f - lifeRatio) : 0f); float headXTopSpeed = headXAcceleration * 100f; - float deceleration = Main.getGoodWorld ? 0.83f : Main.masterMode ? 0.86f : Main.expertMode ? 0.89f : 0.92f; + float deceleration = Main.getGoodWorld ? 0.83f : masterMode ? 0.86f : 0.89f; if (bossRush) { @@ -904,7 +904,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses float velocityMultiplier = MathHelper.Lerp(death ? 0.6f : 0.7f, 1f, skeletronLifeRatio); float velocityIncrement = MathHelper.Lerp(0.2f, death ? 0.4f : 0.3f, 1f - skeletronLifeRatio); float handSwipeVelocity = MathHelper.Lerp(16f, death ? 24f : 20f, 1f - skeletronLifeRatio); - float deceleration = Main.getGoodWorld ? 0.78f : Main.masterMode ? 0.82f : Main.expertMode ? 0.86f : 0.9f; + float deceleration = Main.getGoodWorld ? 0.78f : masterMode ? 0.82f : 0.86f; float handSwipeDuration = HandSwipeDistance / handSwipeVelocity; float slapGateValue = HandSlapGateValue; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs index 270d56a7e3..f671b5b13d 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/TwinsAI.cs @@ -1523,7 +1523,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { // Boost speed if too far from target if (spazmatismFlamethrowerTargetDist > flamethrowerDistance) - spazmatismFlamethrowerMaxSpeed += MathHelper.Lerp(0f, Main.masterMode ? 10f : 6.6f, MathHelper.Clamp((spazmatismFlamethrowerTargetDist - flamethrowerDistance) / 1000f, 0f, 1f)); + spazmatismFlamethrowerMaxSpeed += MathHelper.Lerp(0f, masterMode ? 10f : 6.6f, MathHelper.Clamp((spazmatismFlamethrowerTargetDist - flamethrowerDistance) / 1000f, 0f, 1f)); if (Main.getGoodWorld) { diff --git a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs index f9476e1bbd..f6668516ba 100644 --- a/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs +++ b/NPCs/VanillaNPCAIOverrides/RegularEnemies/RevengeanceAndDeathAI.cs @@ -3570,6 +3570,12 @@ PrepareToShoot: if (Main.player[npc.target].position.Y - npc.position.Y < 80f && npc.velocity.Y > 0f) npc.velocity.Y *= 0.97f; } + + if (npc.ai[3] == 1f) + { + maxVelocity += npc.ai[2] * 1.5f; + acceleration += npc.ai[2] * 0.01f; + } } else if (npc.type == NPCID.MossHornet) { @@ -3963,7 +3969,7 @@ PrepareToShoot: if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.ai[1] += (npc.type == NPCID.MossHornet ? 2f : 1f); + npc.ai[1] += (npc.type == NPCID.MossHornet ? 2f : 1f) + npc.ai[2]; if (npc.justHit) npc.ai[1] = 0f; @@ -3972,6 +3978,7 @@ PrepareToShoot: if (targetData.Type != 0 && Collision.CanHit(npc, targetData)) { float projSpeed = (CalamityWorld.death || Main.hardMode) ? 5f : 8f; + projSpeed += npc.ai[2] * ((CalamityWorld.death || Main.hardMode) ? 2f : 4f); Vector2 projSpawnPosition = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height / 2); float projTargetXDist = targetData.Center.X - projSpawnPosition.X; float projTargetYDist = targetData.Center.Y - projSpawnPosition.Y; @@ -3981,7 +3988,7 @@ PrepareToShoot: projTargetDistance = projSpeed / projTargetDistance; projTargetXDist *= projTargetDistance; projTargetYDist *= projTargetDistance; - int projDamage = (int)(10f * npc.scale); + int projDamage = (int)((npc.ai[3] == 1f ? 15f : 10f) * npc.scale); if (npc.type == NPCID.MossHornet) projDamage = (int)(30f * npc.scale); @@ -7427,7 +7434,7 @@ PrepareToShoot: if (npc.ai[3] == 0f) { npc.position.X += 8f; - if (npc.position.Y / 16f > Main.maxTilesY - 200f) + if (npc.position.Y / 16f > Main.UnderworldLayer) { npc.ai[3] = 3f; } diff --git a/Particles/ArianeFakeDust.cs b/Particles/ArianeFakeDust.cs new file mode 100644 index 0000000000..471a4462e1 --- /dev/null +++ b/Particles/ArianeFakeDust.cs @@ -0,0 +1,55 @@ +using System; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class ArianeFakeDust : Particle + { + public override string Texture => "CalamityMod/Particles/FakeDust"; + public override bool UseAdditiveBlend => true; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + + private Projectile Projectile; + private Vector2 RelativePosition; + private float Spin; + private float Opacity; + private bool Big; + + public ArianeFakeDust(Projectile proj, Vector2 relativePosition, Vector2 velocity, Color color, float scale, int lifeTime, float rotationSpeed = 1f, bool bigSize = false) + { + Projectile = proj; + RelativePosition = relativePosition; + Velocity = velocity; + Color = color; + Scale = scale; + Lifetime = lifeTime; + Rotation = Main.rand.NextFloat(MathHelper.TwoPi); + Spin = rotationSpeed; + Big = bigSize; + Variant = Main.rand.Next(3); + } + + public override void Update() + { + if (Projectile != null && Projectile.active && Projectile.type == ModContent.ProjectileType()) + Position = Projectile.Center + RelativePosition; + + Velocity *= 0.95f; + Scale *= 0.98f; + Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f); + Opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi); + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D dustTexture = Big ? ModContent.Request("CalamityMod/Particles/FakeDustBig").Value : ModContent.Request(Texture).Value; + Rectangle frame = new Rectangle(0, (Big ? 8 : 6) * Variant, (Big ? 8 : 6), (Big ? 8 : 6)); + spriteBatch.Draw(dustTexture, Position - Main.screenPosition, frame, Color * Opacity, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0); + } + } +} diff --git a/Particles/LiliesOfFinalityHeartParticle.cs b/Particles/LiliesOfFinalityHeartParticle.cs new file mode 100644 index 0000000000..eedd9b7e8a --- /dev/null +++ b/Particles/LiliesOfFinalityHeartParticle.cs @@ -0,0 +1,39 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Particles +{ + public class LiliesOfFinalityHeartParticle : Particle + { + public override string Texture => "CalamityMod/Particles/LiliesOfFinalityHeartParticle"; + public override bool UseCustomDraw => true; + public override bool SetLifetime => true; + + public LiliesOfFinalityHeartParticle(Vector2 position, Vector2 velocity, int lifeTime, float scale = 1f) + { + Position = position; + Velocity = velocity; + Lifetime = lifeTime; + Scale = scale; + Rotation = velocity.ToRotation() + MathHelper.PiOver2; + Color = Color.White; + } + + public override void Update() + { + Velocity *= 0.96f; + Scale *= 0.97f; + } + + public override void CustomDraw(SpriteBatch spriteBatch) + { + Texture2D emoteTexture = ModContent.Request(Texture).Value; + Vector2 origin = emoteTexture.Size() * 0.5f; + float opacity = 1f - MathF.Pow(LifetimeCompletion, 4f); + spriteBatch.Draw(emoteTexture, Position - Main.screenPosition, null, Color * opacity * 0.7f, Rotation, origin, Scale, SpriteEffects.None, 0); + } + } +} diff --git a/Particles/LiliesOfFinalityHeartParticle.png b/Particles/LiliesOfFinalityHeartParticle.png new file mode 100644 index 0000000000..be555e9901 Binary files /dev/null and b/Particles/LiliesOfFinalityHeartParticle.png differ diff --git a/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs new file mode 100644 index 0000000000..dd00178653 --- /dev/null +++ b/Projectiles/BaseProjectiles/BaseGunHoldoutProjectile.cs @@ -0,0 +1,250 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Localization; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.BaseProjectiles +{ + /// + /// An abstract class dedicated to ease the making of gun-like holdouts, regarding of the weapon class.
+ /// All the AI code goes to .
+ /// Sets the texture, localization and SetDefaults automatically.
+ /// You also have convenient properties for offsets, arm visuals and the tip of the gun.
+ /// You must name your holdout's class the name of the item's class plus "Holdout" at the end, you'll get errors otherwise. + ///
+ public abstract class BaseGunHoldoutProjectile : ModProjectile, ILocalizedModType + { + #region Overridable Properties + + /// + /// The ID of the item that this holdout belongs to. + /// + public abstract int AssociatedItemID { get; } + + /// + /// The position of the gun tip, used for spawning the holdout's shots.
+ /// Override if it isn't aligned properly. For example: when the tip is a bit upwards. + ///
+ public virtual Vector2 GunTipPosition => Projectile.Center + Vector2.UnitX.RotatedBy(Projectile.rotation) * Projectile.width * 0.5f; + + /// + /// How fast returns back to .
+ /// In consequence, this is how fast the holdout goes back to its position.
+ /// Defaults to 0.3f. + ///
+ public virtual float RecoilResolveSpeed => 0.3f; + + /// + /// The distance of the holdout to the arm.
+ /// Used to properly position the weapon to be held on the player's arms. + ///
+ public virtual float MaxOffsetLengthFromArm { get; } + + /// + /// The offset in the X-axis of the holdout when the player's pointing upwards. + /// + public virtual float OffsetXUpwards { get; } + + /// + /// The offset in the X-axis of the holdout when the player's pointing downwards. + /// + public virtual float OffsetXDownwards { get; } + + /// + /// The base offset on the Y-axis of the holdout.
+ /// Used to align the holdout when pointing horizontally. + ///
+ public virtual float BaseOffsetY { get; } + + /// + /// The offset in the Y-axis of the holdout when the player's pointing upwards. + /// + public virtual float OffsetYUpwards { get; } + + /// + /// The offset in the Y-axis of the holdout when the player's pointing downwards. + /// + public virtual float OffsetYDownwards { get; } + + #endregion + + #region Properties + + /// + /// The owner of this holdout.
+ /// It's set on . + ///
+ public Player Owner { get; private set; } + + /// + /// The item that the player's holding, correspondent to .
+ /// It's set on . + ///
+ public Item HeldItem { get; private set; } + + /// + /// Whether the holdout will have its set 2 constantly.
+ /// Used when you want to keep it alive for a bit longer after it should despawn.
+ /// Defaults to . + ///
+ public bool KeepRefreshingLifetime { get; set; } = true; + + /// + /// The current offset length from the arm of the holdout.
+ /// Used to make recoil effects by setting this to a lower value than . + ///
+ public float OffsetLengthFromArm { get; set; } + + /// + /// Extra rotation added to the front arm if you want to make it be held cooler or more naturally.
+ /// Direction is already taken care of, so you don't need to multiply anything. + ///
+ public float ExtraFrontArmRotation { get; set; } + + /// + /// Extra rotation added to the back arm if you want to make it be held cooler or more naturally.
+ /// Direction is already taken care of, so you don't need to multiply anything. + ///
+ public float ExtraBackArmRotation { get; set; } + + /// + /// The visual stretch of the owner's front arm.
+ /// Defaults to . + ///
+ public Player.CompositeArmStretchAmount FrontArmStretch { get; set; } = Player.CompositeArmStretchAmount.Full; + + /// + /// The visual stretch of the owner's back arm.
+ /// Defaults to . + ///
+ public Player.CompositeArmStretchAmount BackArmStretch { get; set; } = Player.CompositeArmStretchAmount.Full; + + private Type AssociatedItemType => ItemLoader.GetItem(AssociatedItemID).GetType(); + + #endregion + + #region Overridden Members + + // Gets the display name of the associated item. + public override LocalizedText DisplayName => CalamityUtils.GetItemName(AssociatedItemID); + + // Gets the texture of the associated item. + public override string Texture => (AssociatedItemType.Namespace + "." + AssociatedItemType.Name).Replace('.', '/'); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = Request(Texture).Width(); + Projectile.tileCollide = false; + Projectile.netImportant = true; + } + + public override void OnSpawn(IEntitySource source) + { + Owner = Main.player[Projectile.owner]; + OffsetLengthFromArm = MaxOffsetLengthFromArm; + HeldItem = Owner.ActiveItem(); + Projectile.velocity = Owner.Calamity().mouseWorld - Owner.RotatedRelativePoint(Owner.MountedCenter); + } + + public override bool ShouldUpdatePosition() => false; + + public override bool? CanDamage() => false; + + #endregion + + #region AI + + public override void AI() + { + KillHoldoutLogic(); + ManageHoldout(); + HoldoutAI(); + } + + /// + /// Here goes the code for when the holdout needs to despawn.
+ /// Defaults to despawning when the owner isn't holding or isn't using the correspondent weapon. + ///
+ public virtual void KillHoldoutLogic() + { + if (Owner.CantUseHoldout() || HeldItem.type != AssociatedItemID) + { + Projectile.netUpdate = true; + Projectile.Kill(); + } + } + + /// + /// Does all the needed code for a holdout to work. + /// + public virtual void ManageHoldout() + { + // The center of the player, taking into account if they have a mount or not. + Vector2 armPosition = Owner.RotatedRelativePoint(Owner.MountedCenter, true); + + // The vector between the player and the mouse, used for pointing the holdout. + Vector2 ownerToMouse = Owner.Calamity().mouseWorld - armPosition; + + // The direction this holdout's pointing at. + float holdoutDirection = Projectile.velocity.ToRotation(); + + // A range from -1 to 1 for when the holdout is pointing downards of upwards, respectively. + // Used for the offsets. + float proximityLookingUpwards = Vector2.Dot(ownerToMouse.SafeNormalize(Vector2.Zero), -Vector2.UnitY); + + int direction = MathF.Sign(ownerToMouse.X); + + Vector2 lengthOffset = Projectile.rotation.ToRotationVector2() * OffsetLengthFromArm; + Vector2 armOffset = new Vector2(Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? OffsetXUpwards : OffsetXDownwards) * direction, BaseOffsetY + Utils.Remap(MathF.Abs(proximityLookingUpwards), 0f, 1f, 0f, proximityLookingUpwards > 0f ? OffsetYUpwards : OffsetYDownwards)); + Projectile.Center = armPosition + lengthOffset + armOffset; + Projectile.velocity = holdoutDirection.AngleTowards(ownerToMouse.ToRotation(), 0.2f).ToRotationVector2(); + Projectile.rotation = holdoutDirection; + + Projectile.spriteDirection = direction; + Owner.ChangeDir(direction); + + Owner.heldProj = Projectile.whoAmI; + Owner.itemTime = Owner.itemAnimation = 2; + Owner.itemRotation = (Projectile.velocity * Projectile.direction).ToRotation(); + + // -Pi/2 because the arms rotation starts with arms pointing down. + float armRotation = Projectile.rotation - MathHelper.PiOver2; + Owner.SetCompositeArmFront(true, FrontArmStretch, armRotation + ExtraFrontArmRotation * direction); + Owner.SetCompositeArmBack(true, BackArmStretch, armRotation + ExtraBackArmRotation * direction); + + if (KeepRefreshingLifetime) + Projectile.timeLeft = 2; + + if (OffsetLengthFromArm != MaxOffsetLengthFromArm) + OffsetLengthFromArm = MathHelper.Lerp(OffsetLengthFromArm, MaxOffsetLengthFromArm, RecoilResolveSpeed); + } + + /// + /// Where all the actual AI goes to. + /// + public abstract void HoldoutAI(); + + #endregion + + #region Drawing + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + float drawRotation = Projectile.rotation + (Projectile.spriteDirection == -1 ? MathHelper.Pi : 0f); + Vector2 rotationPoint = texture.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(lightColor), drawRotation, rotationPoint, Projectile.scale, flipSprite); + + return false; + } + + #endregion + } +} diff --git a/Projectiles/BaseProjectiles/BaseMinionProjectile.cs b/Projectiles/BaseProjectiles/BaseMinionProjectile.cs index 6d6b44df0f..39dfaebd12 100644 --- a/Projectiles/BaseProjectiles/BaseMinionProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseMinionProjectile.cs @@ -224,14 +224,14 @@ namespace CalamityMod.Projectiles.BaseProjectiles { Owner = Main.player[Projectile.owner]; ModdedOwner = Owner.Calamity(); - Target = Owner.Center.MinionHoming(AdaptiveEnemyDistanceDetection, Owner, !PreHardmodeMinionTileVision || CalamityPlayer.areThereAnyDamnBosses); + Target = Owner.Center.MinionHoming(AdaptiveEnemyDistanceDetection, Owner, !PreHardmodeMinionTileVision || (CalamityPlayer.areThereAnyDamnBosses && !Grounded)); // When minions are grounded, they are affected by tiles, meaning they have a much limited movement. // Pre-Hardmode minions are affected the most since they can't see through walls. // In consequence, some targets that may seem valid, aren't detected due to this. // If the minion hasn't detected any targets with the center being the player, we give them a second chance with the center being the minion itself. // If there are bosses on the world, we don't do this check because if there wasn't any targets with tile X-Ray, this won't do anything. - if (Grounded && Target is null && PreHardmodeMinionTileVision && !CalamityPlayer.areThereAnyDamnBosses) + if (Grounded && Target is null && PreHardmodeMinionTileVision) Target = Projectile.Center.MinionHoming(AdaptiveEnemyDistanceDetection, Owner, false); } @@ -300,74 +300,13 @@ namespace CalamityMod.Projectiles.BaseProjectiles public bool IsTileBetweenTargetAndMinionVertically(bool platformCheckDownwards = false) => IsTileBetweenTwoVectorsVertically(Target.Center, Projectile.Center, platformCheckDownwards); - /// - /// Checks if the minion has a tile in front of him, at their left or right. - /// - /// The extra distance it'll check at the left, not all minions are perfectly sized 1 tile, so you'll need to tweak this. Defaults to 0. - /// The extra distance it'll check at the right, not all minions are perfectly sized 1 tile, so you'll need to tweak this. Defaults to 0. - /// if there's a tile at the left or right, otherwise - public bool IsMinionFacingTile(int leftFluff = 0, int rightFluff = 0) + public bool IsMinionFacingTile() { - Point topLeft = CalamityUtils.ToSafeTileCoordinates(Projectile.TopLeft); - Point bottomLeft = CalamityUtils.ToSafeTileCoordinates(Projectile.BottomLeft); - for (int coordY = topLeft.Y; coordY < bottomLeft.Y; coordY++) - { - if (Main.tile[topLeft.X - leftFluff, coordY].IsTileSolid()) - return true; - } - - Point topRight = CalamityUtils.ToSafeTileCoordinates(Projectile.TopRight); - Point bottomRight = CalamityUtils.ToSafeTileCoordinates(Projectile.BottomRight); - for (int coordY = topRight.Y; coordY <= bottomRight.Y; coordY++) - { - if (Main.tile[topRight.X + rightFluff, coordY].IsTileSolid()) - return true; - } - - return false; - } - - /// - /// Checks whether the minion is standing on a tile or not. - /// - /// if the minion's standing on a tile, otherwise - public bool IsMinionStandingOnTile() - { - Point minionPointLeft = CalamityUtils.ToSafeTileCoordinates(Projectile.BottomLeft); - Point minionPointRight = CalamityUtils.ToSafeTileCoordinates(Projectile.BottomRight); - for (int coordX = minionPointLeft.X; coordX <= minionPointRight.X; coordX++) - { - if (Main.tile[coordX, minionPointLeft.Y].IsTileSolidGround()) - return true; - } - - return false; - } - - /// - /// Checks whether the minion is inside a tile or not.
- /// It checks if there's tiles in the diagonals of the minion's hitbox. - ///
- /// if there's a tile inside the minion, otherwise - public bool IsMinionInsideTile() - { - Point topLeft = CalamityUtils.ToSafeTileCoordinates(Projectile.TopLeft); - Point bottomRight = CalamityUtils.ToSafeTileCoordinates(Projectile.BottomRight); - for (int coordX = topLeft.X; coordX <= bottomRight.X; coordX++) - { - if (Main.tile[coordX, (int)Utils.Remap(coordX, topLeft.X, bottomRight.X, topLeft.Y, bottomRight.Y)].IsTileSolid()) - return true; - } - - Point topRight = CalamityUtils.ToSafeTileCoordinates(Projectile.TopRight); - Point bottomLeft = CalamityUtils.ToSafeTileCoordinates(Projectile.BottomLeft); - for (int coordX = bottomLeft.X; coordX >= topRight.X; coordX--) - { - if (Main.tile[coordX, (int)Utils.Remap(coordX, bottomLeft.X, topRight.X, bottomLeft.Y, bottomRight.Y)].IsTileSolid()) - return true; - } - - return false; + Rectangle inflatedMinionHitbox = Projectile.getRect(); + inflatedMinionHitbox.Inflate(1, 0); + bool stuckOnLeftTile = Main.tile[new Vector2(inflatedMinionHitbox.X, inflatedMinionHitbox.Y + inflatedMinionHitbox.Height - 17).ToSafeTileCoordinates()].IsTileSolid(); + bool stuckOnRightTile = Main.tile[new Vector2(inflatedMinionHitbox.X + inflatedMinionHitbox.Width, inflatedMinionHitbox.Y + inflatedMinionHitbox.Height - 17).ToSafeTileCoordinates()].IsTileSolid(); + return stuckOnLeftTile || stuckOnRightTile; } #endregion diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index d95894e2db..f6c49cc03d 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -10,6 +10,7 @@ using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.NPCs; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; @@ -4507,6 +4508,40 @@ namespace CalamityMod.Projectiles for (int i = 0; i < availableAmountOfNPCsToSpawnUpToSlot; i++) { int beeType = Main.rand.Next(NPCID.Bee, NPCID.BeeSmall + 1); + if (Main.zenithWorld) + { + beeType = Main.rand.NextBool(3) ? ModContent.NPCType() : ModContent.NPCType(); + } + else if (Main.masterMode || BossRushEvent.BossRushActive) + { + switch (Main.rand.Next(12)) + { + default: + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + + case 6: + case 7: + case 8: + beeType = NPCID.LittleHornetHoney; + break; + + case 9: + case 10: + beeType = NPCID.HornetHoney; + break; + + case 11: + beeType = NPCID.BigHornetHoney; + break; + } + } + int beeSpawn = NPC.NewNPC(projectile.GetSource_FromThis(), (int)projectile.Center.X, (int)projectile.Center.Y, beeType, 1); Main.npc[beeSpawn].velocity.X = (float)Main.rand.Next(-200, 201) * 0.002f; Main.npc[beeSpawn].velocity.Y = (float)Main.rand.Next(-200, 201) * 0.002f; diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs index a4aea7ee0f..1b90b5bb90 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserProj.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserProj.cs @@ -16,6 +16,11 @@ namespace CalamityMod.Projectiles.DraedonsArsenal private SlotId gatlingLaserLoopID; private bool fireLasers = false; + public override void SetStaticDefaults() + { + Main.projFrames[Projectile.type] = 4; + } + public override void SetDefaults() { Projectile.width = 24; @@ -29,6 +34,15 @@ namespace CalamityMod.Projectiles.DraedonsArsenal public override void AI() { + Projectile.frameCounter++; + if (Projectile.frameCounter >= 13) + { + Projectile.frameCounter = 10; + Projectile.frame++; + if (Projectile.frame >= Main.projFrames[Projectile.type]) + Projectile.frame = 0; + } + if (SoundEngine.TryGetActiveSound(gatlingLaserLoopID, out var ShootingSound) && ShootingSound.IsPlaying) ShootingSound.Position = Projectile.Center; Player player = Main.player[Projectile.owner]; diff --git a/Projectiles/DraedonsArsenal/GatlingLaserProj.png b/Projectiles/DraedonsArsenal/GatlingLaserProj.png index f5138b81bf..c4b477bdc8 100644 Binary files a/Projectiles/DraedonsArsenal/GatlingLaserProj.png and b/Projectiles/DraedonsArsenal/GatlingLaserProj.png differ diff --git a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs b/Projectiles/DraedonsArsenal/GatlingLaserShot.cs index aae0a0d746..2813959508 100644 --- a/Projectiles/DraedonsArsenal/GatlingLaserShot.cs +++ b/Projectiles/DraedonsArsenal/GatlingLaserShot.cs @@ -33,12 +33,12 @@ namespace CalamityMod.Projectiles.DraedonsArsenal { Time++; Lighting.AddLight(Projectile.Center, 0.2f, 0f, 0f); - if (Projectile.timeLeft % 11 == 0 && Time > 12 && Time < 460) + if (Projectile.timeLeft % 11 == 0 && Time > 15 && Time < 460) { SparkParticle spark = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 6, 1.7f, Color.Red); GeneralParticleHandler.SpawnParticle(spark); } - if (Projectile.timeLeft % 4 == 0 && Time > 12 && Time < 460) + if (Projectile.timeLeft % 4 == 0 && Time > 15 && Time < 460) { SparkParticle spark2 = new SparkParticle(Projectile.Center, Projectile.velocity * 0.01f, false, 6, 0.4f, Color.White); GeneralParticleHandler.SpawnParticle(spark2); diff --git a/Projectiles/Rogue/CosmicKunaiProj.cs b/Projectiles/Rogue/CosmicKunaiProj.cs index e29ec0ccf2..acd7af3131 100644 --- a/Projectiles/Rogue/CosmicKunaiProj.cs +++ b/Projectiles/Rogue/CosmicKunaiProj.cs @@ -17,6 +17,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.ignoreWater = true; Projectile.penetrate = 1; Projectile.DamageType = RogueDamageClass.Instance; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() diff --git a/Projectiles/Rogue/CosmicScythe.cs b/Projectiles/Rogue/CosmicScythe.cs index 8134c1fa7b..41d1a8092b 100644 --- a/Projectiles/Rogue/CosmicScythe.cs +++ b/Projectiles/Rogue/CosmicScythe.cs @@ -32,6 +32,8 @@ namespace CalamityMod.Projectiles.Rogue Projectile.penetrate = 5; Projectile.DamageType = RogueDamageClass.Instance; Projectile.extraUpdates = 1; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; } public override void AI() diff --git a/Projectiles/Summon/LiliesOfEternityBullet.cs b/Projectiles/Summon/LiliesOfEternityBullet.cs new file mode 100644 index 0000000000..5cbe15d4d7 --- /dev/null +++ b/Projectiles/Summon/LiliesOfEternityBullet.cs @@ -0,0 +1,69 @@ +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class LiliesOfEternityBullet : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 8; + } + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 16; + Projectile.timeLeft = 300; + Projectile.penetrate = -1; + Projectile.localNPCHitCooldown = -1; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + } + + public override void AI() + { + if (Main.dedServ) + return; + + Dust trailDust = Dust.NewDustPerfect( + Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), + 64, + Projectile.velocity * Main.rand.NextFloat(0.01f, 0.05f), + Scale: Main.rand.NextFloat(1f, 1.2f)); + trailDust.noGravity = true; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Projectile.velocity = Vector2.Zero; + Projectile.timeLeft = 10; + } + + private float PrimitiveWidthFunction(float completionRatio) + { + float trailPoint = 0.1f; + return completionRatio > trailPoint ? Utils.Remap(completionRatio, trailPoint, 1f, 12f, 0f) : Utils.Remap(completionRatio, trailPoint, 0f, 12f, 0f); + } + + private Color PrimitiveColorFunction(float completionRatio) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); + } + } +} diff --git a/Projectiles/Summon/LiliesOfFinalityAoE.cs b/Projectiles/Summon/LiliesOfFinalityAoE.cs new file mode 100644 index 0000000000..8ea6e54e24 --- /dev/null +++ b/Projectiles/Summon/LiliesOfFinalityAoE.cs @@ -0,0 +1,107 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; + +namespace CalamityMod.Projectiles.Summon +{ + public class LiliesOfFinalityAoE : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + private ref float ArianeID => ref Projectile.ai[0]; + + private ref float Timer => ref Projectile.ai[1]; + + private Projectile Ariane; + + private const int TimeToFullScale = 120; + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = Ariane_AoESize; + Projectile.localNPCHitCooldown = 30; + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + Projectile.netImportant = true; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width / 2f, targetHitbox); + + public override void AI() + { + if (Ariane != null && Ariane.active && Ariane.owner == Projectile.owner && Ariane.type == ModContent.ProjectileType() && Ariane.ModProjectile().State == LiliesOfFinalityAriane.AIState.Attack) + Projectile.timeLeft = 2; + + Projectile.Center = Ariane.Center; + + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (!Main.dedServ) + { + float currentScale = Utils.Remap(Timer, 0f, TimeToFullScale, 0f, Projectile.width / 2f); + + int circleDustAmount = (int)Utils.Remap(Timer, 0f, TimeToFullScale, 5f, 40f) + Main.rand.Next(20); + for (int i = 0; i < circleDustAmount; i++) + { + if (Main.rand.NextBool(20)) + { + float angle = MathHelper.TwoPi / circleDustAmount * i; + Vector2 position = angle.ToRotationVector2() * (currentScale + Main.rand.NextFloat(10f)); + + Particle fakeDust = new ArianeFakeDust( + Projectile, + position + Main.rand.NextVector2Circular(15f, 15f), + Vector2.Zero, + Color.Red, + Main.rand.NextFloat(1.5f, 2.5f), + 120); + GeneralParticleHandler.SpawnParticle(fakeDust); + } + } + + int eyeDustAmount = (int)Utils.Remap(Timer, 0f, TimeToFullScale, 0f, 20f); + for (int i = 0; i < eyeDustAmount; i++) + { + if (Main.rand.NextBool(15)) + { + float interpolator = Main.rand.NextFloat(); + float maxOffsetX = Utils.Remap(Timer, 0f, TimeToFullScale, 0f, 450f); + float maxOffsetY = Utils.Remap(Timer, 0f, TimeToFullScale, 0f, 200f); + Vector2 xPosition = Vector2.UnitX * MathHelper.Lerp(-maxOffsetX, maxOffsetX, interpolator); + Vector2 yPosition = Vector2.UnitY * MathHelper.Lerp(0f, maxOffsetY, MathF.Pow(CalamityUtils.Convert01To010(interpolator), 0.7f)) * Main.rand.NextBool().ToDirectionInt(); + + Particle fakeDust = new ArianeFakeDust( + Projectile, + xPosition + yPosition + Main.rand.NextVector2Circular(15f, 15f), + Vector2.Zero, + Color.Crimson * 0.8f, + Main.rand.NextFloat(2f, 2.5f), + 120); + GeneralParticleHandler.SpawnParticle(fakeDust); + } + } + + Dust insideDust = Dust.NewDustPerfect( + Projectile.Center + Main.rand.NextVector2Circular(currentScale, currentScale), + CommonDustID, + Main.rand.NextVector2Circular(3f, 3f), + Scale: Main.rand.NextFloat(0.8f, 1.2f)); + insideDust.noGravity = true; + } + + Timer++; + } + + public override void OnSpawn(IEntitySource source) => Ariane = Main.projectile[(int)ArianeID]; + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.SourceDamage *= Ariane_AoEDMGMultiplier; + } +} diff --git a/Projectiles/Summon/LiliesOfFinalityAriane.cs b/Projectiles/Summon/LiliesOfFinalityAriane.cs new file mode 100644 index 0000000000..0431a9fc09 --- /dev/null +++ b/Projectiles/Summon/LiliesOfFinalityAriane.cs @@ -0,0 +1,381 @@ +using System.IO; +using CalamityMod.Buffs.Summon; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using static System.MathF; +using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Summon +{ + public class LiliesOfFinalityAriane : BaseMinionProjectile + { + #region Members + + public enum AIState { Idle, ReturnToOwner, Attack } + public AIState State + { + get => (AIState)Projectile.ai[0]; + set + { + Projectile.ai[0] = (float)value; + + // The minion'll be able to walk on tiles when they're not in a flying state. + Projectile.tileCollide = value == AIState.Idle; + + // Because some states mess with the rotation, we reset it so it doesn't cause visual issues on the states that don't deal with rotation. + Projectile.rotation = 0f; + + // When the minion goes into its attack state, it spawns a lingering AoE. + if (value == AIState.Attack && Main.myPlayer == Projectile.owner) + Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ProjectileType(), Projectile.damage, 0f, Projectile.owner, Projectile.whoAmI); + + Timer = 0f; + + NetUpdate(); + } + } + + public enum AnimationState { Still, Walk, Fly } + public AnimationState Animation + { + get => (AnimationState)Projectile.ai[1]; + set + { + Projectile.ai[1] = (float)value; + + switch (value) + { + case AnimationState.Still: + Projectile.width = 32; + FrameAmount = 1; + break; + + case AnimationState.Walk: + Projectile.width = 32; + FrameAmount = 9; + break; + + case AnimationState.Fly: + Projectile.width = 56; + FrameAmount = 8; + break; + } + + // If the animation state is being set to the same thing every frame, don't reset the animation. + // Or if the current frame of animation is outside the amount of frames that the next animation will have, reset it. + if (Animation != value || Projectile.frame + 1 > FrameAmount) + { + Projectile.frame = 0; + Projectile.frameCounter = 0; + } + } + } + + private ref float Timer => ref Projectile.ai[2]; + + /// + /// The amount of animation frames there is in the current animation. + /// + private int FrameAmount = 1; + + private Projectile Elster; + + #endregion + + #region Overridden Members + + public override int AssociatedProjectileTypeID => ProjectileType(); + public override int AssociatedBuffTypeID => BuffType(); + public override ref bool AssociatedMinionBool => ref ModdedOwner.LiliesOfFinalityBool; + public override float EnemyDistanceDetection => MaxEnemyDistanceDetection; + public override int AnimationFrames => 18; + public override bool Grounded => true; + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 66; + base.SetDefaults(); + } + + public override void CheckMinionExistence() + { + Projectile.timeLeft = 2; + if (Elster is null || !Elster.active || Elster.owner != Projectile.owner || Elster.type != ProjectileType()) + Projectile.Kill(); + } + + public override void OnSpawn(IEntitySource source) + { + for (int i = 0; i < Main.maxProjectiles; i++) + { + Projectile p = Main.projectile[i]; + if (p == null || !p.active || p.owner != Projectile.owner || p.type != ProjectileType()) + continue; + Elster = p; + break; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) => false; + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + // If the projectile's above the player, it can fall through platforms to reach the player. + if (State == AIState.Idle) + fallThrough = Projectile.Bottom.Y < Owner.Top.Y; + return true; + } + + public override bool? CanDamage() => false; + + #endregion + + #region AI + + public override void MinionAI() + { + switch (State) + { + case AIState.Idle: + IdleState(); + break; + case AIState.ReturnToOwner: + ReturnToOwnerState(); + break; + case AIState.Attack: + AttackState(); + break; + } + + Timer++; + + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (Main.dedServ) + return; + + if (Elster.ModProjectile().State == LiliesOfFinalityElster.AIState.ReturnToOwner || Elster.ModProjectile().State == LiliesOfFinalityElster.AIState.AttackFlying) + { + Dust connectionArianeElster = Dust.NewDustPerfect( + Vector2.Lerp(Projectile.Center, Elster.Center, Main.rand.NextFloat()) + Main.rand.NextVector2Circular(5f, 5f), + CommonDustID, + Vector2.Zero, + Scale: Main.rand.NextFloat(0.8f, 1f)); + connectionArianeElster.noGravity = true; + } + } + + private void IdleState() + { + if (Timer > 15f) + { + if (Target is not null) + { + State = AIState.Attack; + return; + } + + if (IsTileBetweenOwnerAndMinionVertically() || !Collision.CanHitLine(Projectile.Center, 1, 1, Owner.Center, 1, 1) || !Projectile.WithinRange(Owner.Center, 960f)) + { + State = AIState.ReturnToOwner; + return; + } + + if (!Projectile.getRect().Intersects(Elster.getRect())) + { + int walkDirection = Sign(Elster.Center.X - Projectile.Center.X); + float maxSpeed = Utils.Remap(Abs(Elster.Center.X - Projectile.Center.X), 160f, 0f, 6f, 0f); + Projectile.velocity.X += 0.08f * walkDirection; + if (Abs(Projectile.velocity.X) > maxSpeed) + Projectile.velocity.X = maxSpeed * walkDirection; + } + else + { + Projectile.velocity.X *= 0.8f; + Projectile.spriteDirection = Sign(Elster.Center.X - Projectile.Center.X); + Elster.spriteDirection = Sign(Projectile.Center.X - Elster.Center.X); + + if (!Main.dedServ && Main.rand.NextBool(100)) + { + Vector2 emoteDirection = -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver2 * 0.7f); + Particle heart = new LiliesOfFinalityHeartParticle((Main.rand.NextBool() ? Projectile.Center : Elster.Center) + emoteDirection * 15f, emoteDirection * Main.rand.NextFloat(1f, 2f), Main.rand.Next(30, 45), Main.rand.NextFloat(0.6f, 1f)); + GeneralParticleHandler.SpawnParticle(heart); + } + } + } + + DoGravity(); + Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); + Projectile.spriteDirection = Sign(Projectile.velocity.X); + Animation = Abs(Projectile.velocity.X) < 0.04f || IsMinionFacingTile() ? AnimationState.Still : AnimationState.Walk; + } + + private void ReturnToOwnerState() + { + if (Target is not null) + { + State = AIState.Attack; + return; + } + + if (!IsTileBetweenOwnerAndMinionVertically() && Collision.CanHitLine(Projectile.Center, 1, 1, Owner.Center, 1, 1) && Projectile.WithinRange(Owner.Center, 960f)) + { + State = AIState.Idle; + Projectile.velocity.Y = 5f * Sign(Projectile.velocity.Y); + return; + } + + FlyTowardsPlace(Owner.velocity.Length() + 6f, Owner.Center, Sign(Projectile.velocity.X)); + Animation = AnimationState.Fly; + } + + private void AttackState() + { + if (Target is not null) + { + Vector2 targetSpot = Elster.Center + new Vector2(-100f * Projectile.spriteDirection, -60f); + if (!Projectile.WithinRange(targetSpot, 8f)) + FlyTowardsPlace(Ariane_TargettingFlySpeed, targetSpot, Sign(Target.Center.X - Projectile.Center.X)); + else + Projectile.velocity *= 0.8f; + + if (Timer >= Ariane_BoltFireRate) + ShootBolt(); + + Animation = AnimationState.Fly; + } + else + State = AIState.Idle; + } + + private void ShootBolt() + { + if (Main.myPlayer != Projectile.owner) + return; + + Vector2 shootDirection = Projectile.SafeDirectionTo(Target.Center).RotatedByRandom(MathHelper.PiOver4); + + Projectile.NewProjectileDirect( + Projectile.GetSource_FromThis(), + Projectile.Center, + shootDirection * Ariane_BoltProjectileSpeed, + ProjectileType(), + Projectile.damage, + Projectile.knockBack, + Projectile.owner); + + Timer = 0f; + NetUpdate(); + + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (Main.dedServ) + return; + + Vector2 visualBoltSpawn = Projectile.Center + shootDirection * Projectile.Size.Length() / 2f; + + for (int i = 0; i < 10; i++) + { + Dust shootDust = Dust.NewDustPerfect( + visualBoltSpawn + (Vector2.UnitY * MathHelper.Lerp(-8f, 8f, Main.rand.NextFloat())).RotatedBy(visualBoltSpawn.ToRotation()), + CommonDustID, + shootDirection * Main.rand.NextFloat(3f, 6f), + Scale: Main.rand.NextFloat(0.6f, 0.8f)); + shootDust.noGravity = true; + } + + Particle outerRing = new DirectionalPulseRing( + visualBoltSpawn, + Vector2.Zero, + Color.Red, + new Vector2(0.4f, 1f), + shootDirection.ToRotation(), + 0.05f, + 0.3f, + 20); + + Particle innerRing = new DirectionalPulseRing( + visualBoltSpawn, + Vector2.Zero, + Color.Fuchsia, + new Vector2(0.5f, 1f), + shootDirection.ToRotation(), + 0.05f, + 0.15f, + 20); + + GeneralParticleHandler.SpawnParticle(outerRing); + GeneralParticleHandler.SpawnParticle(innerRing); + + SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/SCalSounds/BrimstoneHellblastSound") { Pitch = 0.4f }, Projectile.Center); + } + + private void FlyTowardsPlace(float speed, Vector2 place, int spriteDirection) + { + Projectile.velocity = (Projectile.velocity * 20f + Projectile.SafeDirectionTo(place) * speed) / 21f; + Projectile.spriteDirection = spriteDirection; + } + + private void NetUpdate() + { + Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; + } + + #endregion + + #region Syncing + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(FrameAmount); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + FrameAmount = reader.ReadInt32(); + } + + #endregion + + #region Drawing & Animation + + public override void DoAnimation() + { + if (Animation == AnimationState.Still) + return; + + FramesUntilNextAnimationFrame = Animation == AnimationState.Walk ? (int)Utils.Remap(Abs(Projectile.velocity.X), 0f, 6f, 8f, 4f) : 5; + + Projectile.frameCounter++; + if (Projectile.frameCounter >= FramesUntilNextAnimationFrame) + { + Projectile.frameCounter = 0; + Projectile.frame = (Projectile.frame + 1) % FrameAmount; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Request(Texture).Value; + Texture2D glowTexture = Request(GlowTexture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(3, 9, (int)Animation, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, flipSprite); + Main.EntitySpriteDraw(glowTexture, drawPosition, frame, Color.White, Projectile.rotation, origin, Projectile.scale, flipSprite); + + return false; + } + + #endregion + } +} diff --git a/Projectiles/Summon/LiliesOfFinalityAriane.png b/Projectiles/Summon/LiliesOfFinalityAriane.png new file mode 100644 index 0000000000..d871072e08 Binary files /dev/null and b/Projectiles/Summon/LiliesOfFinalityAriane.png differ diff --git a/Projectiles/Summon/LiliesOfFinalityAriane_Glow.png b/Projectiles/Summon/LiliesOfFinalityAriane_Glow.png new file mode 100644 index 0000000000..888890cdc0 Binary files /dev/null and b/Projectiles/Summon/LiliesOfFinalityAriane_Glow.png differ diff --git a/Projectiles/Summon/LiliesOfFinalityBolt.cs b/Projectiles/Summon/LiliesOfFinalityBolt.cs new file mode 100644 index 0000000000..a51698a541 --- /dev/null +++ b/Projectiles/Summon/LiliesOfFinalityBolt.cs @@ -0,0 +1,134 @@ +using System; +using CalamityMod.Graphics.Primitives; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; + +namespace CalamityMod.Projectiles.Summon +{ + public class LiliesOfFinalityBolt : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + private ref float RandomColorOffset => ref Projectile.localAI[0]; + + private const int TimeBeforeHoming = 10; + private const int TimeDying = 15; + + private SlotId LoopingSound; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 6; + } + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 16; + Projectile.timeLeft = TimeBeforeHoming + Ariane_BoltTimeHoming + TimeDying; + Projectile.localNPCHitCooldown = -1; + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.usesLocalNPCImmunity = true; + } + + public override void AI() + { + NPC target = Projectile.Center.MinionHoming(MaxEnemyDistanceDetection, Main.player[Projectile.owner]); + if (target is not null && Projectile.timeLeft > TimeDying && Projectile.timeLeft < Ariane_BoltTimeHoming) + { + float turnRate = Utils.Remap(Projectile.timeLeft, Ariane_BoltTimeHoming, TimeDying, Ariane_MinTurnRate, Ariane_MaxTurnRate); + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(target.Center).ToRotation(), turnRate).ToRotationVector2() * Ariane_BoltProjectileSpeed; + } + + // When the projectile's abut to die, it'll stop in place and spawn some dust to cover the shader suddenly cutting off. + if (Projectile.timeLeft < TimeDying - 1) + { + Projectile.velocity = Vector2.Zero; + + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (!Main.dedServ) + { + for (int i = 0; i < 2; i++) + { + Dust fadingDust = Dust.NewDustDirect( + Projectile.position, + Projectile.width, + Projectile.height, + CommonDustID, + Scale: Main.rand.NextFloat(0.8f, 1.2f)); + fadingDust.noGravity = true; + } + } + } + + Projectile.rotation = Projectile.velocity.ToRotation(); + + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (Main.dedServ) + return; + + if (Main.rand.NextBool()) + { + Dust trailDust = Dust.NewDustPerfect( + Projectile.Center + Main.rand.NextVector2Circular(10f, 10f), + CommonDustID, + Projectile.velocity * Main.rand.NextFloat(0.01f, 0.05f), + Scale: Main.rand.NextFloat(0.4f, 0.6f)); + trailDust.noGravity = true; + } + + if (SoundEngine.TryGetActiveSound(LoopingSound, out var sound) && sound.IsPlaying) + sound.Position = Projectile.Center; + } + + public override void OnSpawn(IEntitySource source) + { + // Since we don't want all the projectiles on screen to cycle through the same colors at the same time, we set an initial offset to the color. + RandomColorOffset = Main.rand.NextFloat(100f); + + LoopingSound = SoundEngine.PlaySound(new SoundStyle("CalamityMod/Sounds/Custom/ArianeShot") with { Volume = 0.2f }, Projectile.Center); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Since we don't want the trail to instantly disappear on hit, we'll make reduce its time alive to near death. + Projectile.timeLeft = TimeDying; + + SoundEngine.PlaySound(SoundID.Item70 with { Volume = 0.5f, Pitch = 0.4f }, Projectile.Center); + if (SoundEngine.TryGetActiveSound(LoopingSound, out var sound)) + sound.Stop(); + } + + private float WidthFunction(float completionRatio) => MathHelper.Lerp(0f, 32f, MathF.Pow(completionRatio, 1f / 2.5f)); + + private Color ColorFunction(float completionRatio) + { + float offsetTime = Main.GlobalTimeWrappedHourly + RandomColorOffset; + float fadeToEnd = MathHelper.Lerp(0.65f, 1f, (float)Math.Cos(-offsetTime * 3f) * 0.5f + 0.5f); + float fadeOpacity = Utils.GetLerpValue(1f, 0.64f, completionRatio, true) * Projectile.Opacity; + Color endColor = Color.Lerp(Color.Fuchsia, Color.Red, (float)Math.Sin(completionRatio * MathHelper.Pi * 1.6f - offsetTime * 4f) * 0.5f + 0.5f); + return Color.Lerp(Color.White, endColor, fadeToEnd) * fadeOpacity; + } + + public override bool PreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, pixelate: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32); + return false; + } + } +} diff --git a/Projectiles/Summon/LiliesOfFinalityBullet.cs b/Projectiles/Summon/LiliesOfFinalityBullet.cs new file mode 100644 index 0000000000..7dd9798613 --- /dev/null +++ b/Projectiles/Summon/LiliesOfFinalityBullet.cs @@ -0,0 +1,73 @@ +using CalamityMod.Graphics.Primitives; +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class LiliesOfFinalityBullet : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer + { + public new string LocalizationCategory => "Projectiles.Summon"; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.MinionShot[Type] = true; + ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 8; + } + + public override void SetDefaults() + { + Projectile.DamageType = DamageClass.Summon; + Projectile.width = Projectile.height = 16; + Projectile.timeLeft = 300; + Projectile.localNPCHitCooldown = -1; + Projectile.penetrate = -1; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.MaxUpdates = LiliesOfFinality.Elster_BulletMaxUpdates; + Projectile.usesLocalNPCImmunity = true; + } + + public override void AI() + { + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (Main.dedServ) + return; + + Dust trailDust = Dust.NewDustPerfect( + Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), + 64, + Projectile.velocity * Main.rand.NextFloat(0.01f, 0.05f), + Scale: Main.rand.NextFloat(1f, 1.2f)); + trailDust.noGravity = true; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Since we don't want the trail to instantly disappear on hit, we'll make it stop and reduce its time alive to near death. + Projectile.velocity = Vector2.Zero; + Projectile.timeLeft = 10; + } + + private float PrimitiveWidthFunction(float completionRatio) + { + float trailPoint = 0.1f; + return completionRatio > trailPoint ? Utils.Remap(completionRatio, trailPoint, 1f, 16f, 0f) : Utils.Remap(completionRatio, trailPoint, 0f, 16f, 0f); + } + + private Color PrimitiveColorFunction(float completionRatio) => Color.Lerp(Color.DarkGoldenrod, Color.LightGoldenrodYellow, completionRatio); + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, pixelate: true, shader: GameShaders.Misc["CalamityMod:TrailStreak"])); + } + } +} diff --git a/Projectiles/Summon/LiliesOfFinalityElster.cs b/Projectiles/Summon/LiliesOfFinalityElster.cs new file mode 100644 index 0000000000..a4c74f164d --- /dev/null +++ b/Projectiles/Summon/LiliesOfFinalityElster.cs @@ -0,0 +1,400 @@ +using System.IO; +using CalamityMod.Buffs.Summon; +using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using static System.MathF; +using static CalamityMod.Items.Weapons.Summon.LiliesOfFinality; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Projectiles.Summon +{ + public class LiliesOfFinalityElster : BaseMinionProjectile + { + #region Members + + public enum AIState { Idle, ReturnToOwner, AttackOnGround, AttackFlying } + public AIState State + { + get => (AIState)Projectile.ai[0]; + set + { + Projectile.ai[0] = (float)value; + + // Just in case it doesn't reset properly. + HasShotOnce = false; + + // The minion'll be able to walk on tiles when they're not in a flying state. + Projectile.tileCollide = value == AIState.Idle || value == AIState.AttackOnGround; + + // Because some states mess with the rotation, we reset it so it doesn't cause visual issues on the states that don't deal with rotation. + Projectile.rotation = 0f; + + NetUpdate(); + } + } + + public enum AnimationState { Still, Walk, Fly, Shoot, FlyShoot } + public AnimationState Animation + { + get => (AnimationState)Projectile.ai[1]; + set + { + Projectile.ai[1] = (float)value; + + switch (value) + { + case AnimationState.Still: + Projectile.width = 32; + Projectile.frame = 0; + FrameAmount = 1; + break; + + case AnimationState.Walk: + Projectile.width = 32; + FrameAmount = 9; + break; + + case AnimationState.Fly: + Projectile.width = 36; + FrameAmount = 4; + break; + + case AnimationState.Shoot: + case AnimationState.FlyShoot: + Projectile.width = 56; + FrameAmount = 7; + break; + } + + // If the animation state is being set to the same thing every frame, don't reset the animation. + // Or if the current frame of animation is outside the amount of frames that the next animation will have, reset it. + if (Animation != value || Projectile.frame + 1 > FrameAmount) + { + Projectile.frame = 0; + Projectile.frameCounter = 0; + } + } + } + + private ref float Timer => ref Projectile.ai[2]; + + /// + /// Because the fire rate is animation frame dependent, it can stay on the same animation for multiple ticks.
+ /// We use this bool to only fire once in that span of time. + ///
+ private bool HasShotOnce; + + /// + /// The amount of animation frames there is in the current animation. + /// + private int FrameAmount = 1; + + #endregion + + #region Overridden Members + + public override int AssociatedProjectileTypeID => ProjectileType(); + public override int AssociatedBuffTypeID => BuffType(); + public override ref bool AssociatedMinionBool => ref ModdedOwner.LiliesOfFinalityBool; + public override float EnemyDistanceDetection => MaxEnemyDistanceDetection; + public override int AnimationFrames => 28; + public override bool Grounded => true; + + public override void SetDefaults() + { + Projectile.width = 32; + Projectile.height = 56; + base.SetDefaults(); + } + + public override void CheckMinionExistence() + { + base.CheckMinionExistence(); + if (Timer > 10f && Main.player[Projectile.owner].ownedProjectileCounts[ProjectileType()] == 0) + Projectile.Kill(); + } + + public override bool OnTileCollide(Vector2 oldVelocity) => false; + + public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac) + { + // If the projectile's above the player, it can fall through platforms to reach the player. + if (State == AIState.Idle) + fallThrough = Projectile.Bottom.Y < Owner.Top.Y; + return true; + } + + public override bool? CanDamage() => false; + + #endregion + + #region AI + + public override void MinionAI() + { + switch (State) + { + case AIState.Idle: + IdleState(); + break; + case AIState.ReturnToOwner: + ReturnToOwnerState(); + break; + case AIState.AttackOnGround: + AttackOnGroundState(); + break; + case AIState.AttackFlying: + AttackFlyingState(); + break; + } + + Timer++; + } + + private void IdleState() + { + if (Timer > 15f) + { + if (Target is not null) + { + State = AIState.AttackOnGround; + return; + } + + if (IsTileBetweenOwnerAndMinionVertically() || !Collision.CanHitLine(Projectile.Center, 1, 1, Owner.Center, 1, 1) || !Projectile.WithinRange(Owner.Center, 960f)) + { + State = AIState.ReturnToOwner; + return; + } + + Vector2 idlePosition = Owner.Center - Vector2.UnitX * 60f * Owner.direction; + if (!Projectile.WithinRange(idlePosition, 8f)) + { + int walkDirection = Sign(idlePosition.X - Projectile.Center.X); + float maxSpeed = Utils.Remap(Abs(idlePosition.X - Projectile.Center.X), 160f, 0f, 6f, 0f); + Projectile.velocity.X += 0.08f * walkDirection; + if (Abs(Projectile.velocity.X) > maxSpeed) + Projectile.velocity.X = maxSpeed * walkDirection; + } + else + Projectile.velocity.X = 0f; + } + + DoGravity(); + Collision.StepUp(ref Projectile.position, ref Projectile.velocity, Projectile.width, Projectile.height, ref Projectile.stepSpeed, ref Projectile.gfxOffY); + Projectile.spriteDirection = Sign(Projectile.velocity.X); + Animation = Abs(Projectile.velocity.X) < 0.04f || IsMinionFacingTile() ? AnimationState.Still : AnimationState.Walk; + } + + private void ReturnToOwnerState() + { + if (Target is not null) + { + State = AIState.AttackOnGround; + return; + } + + if (!IsTileBetweenOwnerAndMinionVertically() && Collision.CanHitLine(Projectile.Center, 1, 1, Owner.Center, 1, 1) && Projectile.WithinRange(Owner.Center, 960f)) + { + State = AIState.Idle; + + // Does a little hop to confirm the minion reaches the desired height. + Projectile.velocity.Y = 5f * Sign(Projectile.velocity.Y); + + return; + } + + FlyTowardsPlace(Owner.velocity.Length() + 6f, Owner.Center, Sign(Projectile.velocity.X), AnimationState.Fly); + Projectile.rotation = MathHelper.ToRadians(Projectile.velocity.Length()) * Sign(Projectile.velocity.X); + ElevationDust(false); + } + + private void AttackOnGroundState() + { + if (Target is not null) + { + if (Projectile.Center.Y > Target.Bottom.Y || Projectile.Center.Y < Target.Top.Y) + { + State = AIState.AttackFlying; + return; + } + + // If the frame of the animation is the shooting one (and hasn't shot once yet): shoot. + if (Projectile.frame == 2 && !HasShotOnce) + ShootBullet(); + + // Reset the bool for the next shot. + if (Projectile.frame != 2 && HasShotOnce) + HasShotOnce = false; + + DoGravity(); + Projectile.velocity.X = 0f; + Projectile.spriteDirection = Sign(Target.Center.X - Projectile.Center.X); + Animation = AnimationState.Shoot; + } + else + State = AIState.Idle; + } + + private void AttackFlyingState() + { + if (Target is not null) + { + Vector2 targetSpot = Target.Center - Vector2.UnitX * (Elster_DistanceFromTarget + Target.width / 2f) * Sign(Target.Center.X - Projectile.Center.X); + if (!Projectile.WithinRange(targetSpot, 5f)) + FlyTowardsPlace(Elster_TargettingFlySpeed, targetSpot, Sign(Target.Center.X - Projectile.Center.X), AnimationState.FlyShoot); + else + Projectile.velocity *= 0.8f; + + // If the frame of the animation is the shooting one (and hasn't shot once yet): shoot. + if (Projectile.frame == 2 && !HasShotOnce) + ShootBullet(); + + // Reset the bool for the next shot. + if (Projectile.frame != 2 && HasShotOnce) + HasShotOnce = false; + + ElevationDust(true); + } + else + State = AIState.Idle; + } + + private void FlyTowardsPlace(float speed, Vector2 place, int spriteDirection, AnimationState spriteAnimation) + { + Projectile.velocity = (Projectile.velocity * 20f + Projectile.SafeDirectionTo(place) * speed) / 21f; + Projectile.spriteDirection = spriteDirection; + Animation = spriteAnimation; + } + + private void ShootBullet() + { + if (Main.myPlayer != Projectile.owner) + return; + + Vector2 bulletSpawnPosition = Projectile.Center - Vector2.UnitX * 15f * Projectile.spriteDirection; + Vector2 bulletVelocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(bulletSpawnPosition, Target, Elster_BulletProjectileSpeed, Elster_BulletMaxUpdates); + + Projectile.NewProjectileDirect( + Projectile.GetSource_FromThis(), + bulletSpawnPosition, + //Vector2.UnitX * Elster_BulletProjectileSpeed * Projectile.spriteDirection, + bulletVelocity, + ProjectileType(), + (int)(Projectile.damage * 1.2f), + Projectile.knockBack, + Projectile.owner); + + HasShotOnce = true; + NetUpdate(); + + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (Main.dedServ) + return; + + Particle shootRing = new DirectionalPulseRing( + Projectile.Center + Vector2.UnitX * Projectile.width / 2f * Projectile.spriteDirection, + Vector2.Zero, + Color.Goldenrod, + new Vector2(0.5f, 1f), + 0f, + 0.05f, + 0.25f, + 7); + GeneralParticleHandler.SpawnParticle(shootRing); + + SoundEngine.PlaySound(new("CalamityMod/Sounds/Custom/ElsterShot", 4) { Volume = 0.3f }, Projectile.Center); + } + + private void ElevationDust(bool shootingState) + { + // If on a dedicated server, don't bother running the visuals and sounds to save resources. + if (Main.dedServ) + return; + + Vector2 leftLeg = shootingState ? Projectile.BottomLeft + Vector2.UnitX * (Projectile.spriteDirection == -1 ? 28f : 10f) : Projectile.BottomLeft; + Vector2 rightLeg = shootingState ? Projectile.BottomRight - Vector2.UnitX * (Projectile.spriteDirection == -1 ? 10f : 28f) : Projectile.BottomRight; + + if (Main.rand.NextBool()) + { + float interpolant = Main.rand.NextFloat(); + Dust elevationDust = Dust.NewDustPerfect( + Vector2.Lerp(leftLeg, rightLeg, interpolant), + CommonDustID, + Vector2.UnitY.RotatedByRandom(MathHelper.Lerp(-MathHelper.ToRadians(15f), MathHelper.ToRadians(15f), interpolant) * Main.rand.NextFloat(8f, 12f)), + Scale: Main.rand.NextFloat(1f, 1.2f)); + elevationDust.noGravity = true; + } + + if (Main.rand.NextBool(4)) + { + float interpolant = Main.rand.NextFloat(); + Dust elevationDust = Dust.NewDustPerfect( + Vector2.Lerp(leftLeg, rightLeg, interpolant), + CommonDustID, + -Vector2.UnitY * Main.rand.NextFloat(3f, 6f), + Scale: Main.rand.NextFloat(1f, 1.2f)); + elevationDust.noGravity = true; + } + } + + private void NetUpdate() + { + Projectile.netUpdate = true; + if (Projectile.netSpam >= 10) + Projectile.netSpam = 9; + } + + #endregion + + #region Syncing + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(HasShotOnce); + writer.Write(FrameAmount); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + HasShotOnce = reader.ReadBoolean(); + FrameAmount = reader.ReadInt32(); + } + + #endregion + + #region Drawing & Animation + + public override void DoAnimation() + { + if (Animation == AnimationState.Still) + return; + + FramesUntilNextAnimationFrame = Animation == AnimationState.Walk ? (int)Utils.Remap(Abs(Projectile.velocity.X), 0f, 6f, 8f, 4f) : 5; + + Projectile.frameCounter++; + if (Projectile.frameCounter >= FramesUntilNextAnimationFrame) + { + Projectile.frameCounter = 0; + Projectile.frame = (Projectile.frame + 1) % FrameAmount; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Request(Texture).Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + Rectangle frame = texture.Frame(5, 9, (int)Animation, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + SpriteEffects flipSprite = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, flipSprite); + return false; + } + + #endregion + } +} diff --git a/Projectiles/Summon/LiliesOfFinalityElster.png b/Projectiles/Summon/LiliesOfFinalityElster.png new file mode 100644 index 0000000000..8362fcc9d4 Binary files /dev/null and b/Projectiles/Summon/LiliesOfFinalityElster.png differ diff --git a/Sounds/Custom/ArianeShot.ogg b/Sounds/Custom/ArianeShot.ogg new file mode 100644 index 0000000000..494d289eb7 Binary files /dev/null and b/Sounds/Custom/ArianeShot.ogg differ diff --git a/Sounds/Custom/ElsterShot1.ogg b/Sounds/Custom/ElsterShot1.ogg new file mode 100644 index 0000000000..941a38a1f8 Binary files /dev/null and b/Sounds/Custom/ElsterShot1.ogg differ diff --git a/Sounds/Custom/ElsterShot2.ogg b/Sounds/Custom/ElsterShot2.ogg new file mode 100644 index 0000000000..a76e5efd3e Binary files /dev/null and b/Sounds/Custom/ElsterShot2.ogg differ diff --git a/Sounds/Custom/ElsterShot3.ogg b/Sounds/Custom/ElsterShot3.ogg new file mode 100644 index 0000000000..c565d66f0c Binary files /dev/null and b/Sounds/Custom/ElsterShot3.ogg differ diff --git a/Sounds/Custom/ElsterShot4.ogg b/Sounds/Custom/ElsterShot4.ogg new file mode 100644 index 0000000000..d56a080ab8 Binary files /dev/null and b/Sounds/Custom/ElsterShot4.ogg differ diff --git a/Sounds/Custom/LiliesOfFinalityTileHitSound.ogg b/Sounds/Custom/LiliesOfFinalityTileHitSound.ogg new file mode 100644 index 0000000000..f3046fe665 Binary files /dev/null and b/Sounds/Custom/LiliesOfFinalityTileHitSound.ogg differ diff --git a/Sounds/Custom/WeaverArmorShed.ogg b/Sounds/Custom/WeaverArmorShed.ogg new file mode 100644 index 0000000000..da875bed53 Binary files /dev/null and b/Sounds/Custom/WeaverArmorShed.ogg differ diff --git a/Sounds/NPCKilled/WeaverDeath.ogg b/Sounds/NPCKilled/WeaverDeath.ogg new file mode 100644 index 0000000000..5884f22aed Binary files /dev/null and b/Sounds/NPCKilled/WeaverDeath.ogg differ diff --git a/Systems/WorldMiscUpdateSystem.cs b/Systems/WorldMiscUpdateSystem.cs index 5d3ecf9f98..05c4a3c2d5 100644 --- a/Systems/WorldMiscUpdateSystem.cs +++ b/Systems/WorldMiscUpdateSystem.cs @@ -8,7 +8,9 @@ using CalamityMod.NPCs.PrimordialWyrm; using CalamityMod.Projectiles.Boss; using CalamityMod.Tiles; using CalamityMod.Tiles.Abyss; +using CalamityMod.Tiles.Crags; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.Walls; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -18,6 +20,7 @@ using Terraria.ID; using Terraria.ModLoader; using Terraria.WorldBuilding; using static CalamityMod.World.CalamityWorld; +using static Terraria.ModLoader.ModContent; namespace CalamityMod.Systems { @@ -312,6 +315,78 @@ namespace CalamityMod.Systems } } } + + if (growthTile.LiquidAmount == 0 && y > Main.UnderworldLayer) + { + bool isCragsTile = tileType == TileType() || + tileType == TileType() || + tileType == TileType() || + tileType == TileType() || + tileType == TileType(); + + int wallType = Main.tile[x, y2].WallType; + bool isCragHouseWall = wallType == WallType() || + wallType == WallType() || + wallType == WallType() || + wallType == WallType(); + + if (isCragsTile && isCragHouseWall && Main.tile[x, y2].LiquidAmount == 0) + { + // Lilies of Finality post-Yharon. + if (WorldGen.genRand.NextBool(20) && DownedBossSystem.downedYharon) + { + ushort tileTypeToPlace = (ushort)TileType(); + int tileTypeToPlaceThickness = 3; + bool placeLilies = true; + + // Do not change this number, ever. - Fabsol + int minDistanceFromOtherLilies = 66; + + for (int k = x - minDistanceFromOtherLilies; k < x + minDistanceFromOtherLilies; k += 2) + { + for (int m = y - minDistanceFromOtherLilies; m < y + minDistanceFromOtherLilies; m += 2) + { + if (k > tileTypeToPlaceThickness && k < Main.maxTilesX - tileTypeToPlaceThickness && m > tileTypeToPlaceThickness && m < Main.maxTilesY - tileTypeToPlaceThickness && Main.tile[k, m].HasTile && Main.tile[k, m].TileType == tileTypeToPlace) + { + placeLilies = false; + break; + } + } + } + + if (placeLilies) + { + if (x < tileTypeToPlaceThickness || x > Main.maxTilesX - tileTypeToPlaceThickness || y2 < tileTypeToPlaceThickness || y2 > Main.maxTilesY - tileTypeToPlaceThickness) + return; + + bool placeTile = true; + for (int i2 = x - 1; i2 < x + 2; i2++) + { + for (int j3 = y2 - 2; j3 < y2 + 1; j3++) + { + if (Main.tile[i2, j3] == null) + return; + + if (Main.tile[i2, j3].HasTile) + placeTile = false; + } + + if (Main.tile[i2, y2 + 1] == null) + return; + + if (!WorldGen.SolidTile2(i2, y2 + 1)) + placeTile = false; + } + + if (placeTile) + { + WorldGen.PlaceObject(x, y2, tileTypeToPlace, true); + NetMessage.SendObjectPlacement(-1, x, y2, tileTypeToPlace, 0, 0, -1, -1); + } + } + } + } + } } } l++; diff --git a/Tiles/Crags/LiliesOfFinalityTile.cs b/Tiles/Crags/LiliesOfFinalityTile.cs new file mode 100644 index 0000000000..c244d351c1 --- /dev/null +++ b/Tiles/Crags/LiliesOfFinalityTile.cs @@ -0,0 +1,33 @@ +using CalamityMod.Items.Weapons.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.Crags +{ + public class LiliesOfFinalityTile : ModTile + { + public override void SetStaticDefaults() + { + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileSpelunker[Type] = true; + Main.tileLighted[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 }; + + TileObjectData.addTile(Type); + + AddMapEntry(Color.White, CalamityUtils.GetItemName()); + TileID.Sets.DisableSmartCursor[Type] = true; + RegisterItemDrop(ModContent.ItemType()); + FlexibleTileWand.RubblePlacementLarge.AddVariations(ModContent.ItemType(), Type, 0); + HitSound = new("CalamityMod/Sounds/Custom/LiliesOfFinalityTileHitSound"); + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) => r = g = b = 0.5f; + } +} diff --git a/Tiles/Crags/LiliesOfFinalityTile.png b/Tiles/Crags/LiliesOfFinalityTile.png new file mode 100644 index 0000000000..7c7c13f169 Binary files /dev/null and b/Tiles/Crags/LiliesOfFinalityTile.png differ diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index f5658e4ded..c66dbc74d2 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -169,6 +169,8 @@ namespace CalamityMod EnemyStats.DebuffImmunities = new SortedDictionary> { { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, + { ModContent.NPCType(), immuneToEverything }, { NPCID.Deerclops, ice }, diff --git a/World/Abyss.cs b/World/Abyss.cs index 61a1ed027b..f70e99299c 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -569,7 +569,7 @@ namespace CalamityMod.World //ambient tiles and pots for (int abyssIndex = abyssMinX + 5; abyssIndex < abyssMaxX - 5; abyssIndex++) { - for (int abyssIndex2 = 0; abyssIndex2 < (Main.remixWorld ? rockLayer : Main.maxTilesY - 200); abyssIndex2++) + for (int abyssIndex2 = 0; abyssIndex2 < (Main.remixWorld ? rockLayer : Main.UnderworldLayer); abyssIndex2++) { Tile tileToGrowVineOn = Main.tile[abyssIndex, abyssIndex2]; @@ -578,7 +578,7 @@ namespace CalamityMod.World Tile tile = Main.tile[abyssIndex, abyssIndex2 + 1]; //above the 4th layer - if (abyssIndex2 < (Main.remixWorld ? rockLayer : Main.maxTilesY - 200) && WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1)) + if (abyssIndex2 < (Main.remixWorld ? rockLayer : Main.UnderworldLayer) && WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1)) { //sulphur shale stuff if (tile.TileType == ModContent.TileType()) @@ -743,7 +743,7 @@ namespace CalamityMod.World } //sulphur pots - else if (tile.TileType == ModContent.TileType() && abyssIndex2 < (Main.remixWorld ? Main.maxTilesY - 200 : (int)Main.worldSurface)) + else if (tile.TileType == ModContent.TileType() && abyssIndex2 < (Main.remixWorld ? Main.UnderworldLayer : (int)Main.worldSurface)) { if (WorldGen.genRand.NextBool(3)) { diff --git a/World/BrimstoneCrag.cs b/World/BrimstoneCrag.cs index 0424f926e7..10573d76b6 100644 --- a/World/BrimstoneCrag.cs +++ b/World/BrimstoneCrag.cs @@ -43,7 +43,7 @@ namespace CalamityMod.World //clear literally everything in the area the biome will generate in for (int x = biomeStart; x <= biomeEdge; x++) { - for (int y = Main.maxTilesY - 200; y < Main.maxTilesY - 2; y++) + for (int y = Main.UnderworldLayer; y < Main.maxTilesY - 2; y++) { Tile tile = Main.tile[x, y]; tile.ClearEverything(); @@ -96,7 +96,7 @@ namespace CalamityMod.World //place ceiling of slag across the top of the biome for (int x = biomeStart; x <= biomeEdge; x++) { - for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 192; y++) + for (int y = Main.UnderworldLayer; y <= Main.maxTilesY - 192; y++) { if (WorldGen.genRand.NextBool(25)) { @@ -271,7 +271,7 @@ namespace CalamityMod.World //lava clean up again for (int x = biomeStart; x <= biomeEdge; x++) { - for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 5; y++) + for (int y = Main.UnderworldLayer; y <= Main.maxTilesY - 5; y++) { Tile tile = Main.tile[x, y]; Tile tileAbove = Main.tile[x, y - 1]; @@ -317,7 +317,7 @@ namespace CalamityMod.World //spread grass on all scorched remains with no lava above them for (int x = biomeStart; x <= biomeEdge; x++) { - for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 110; y++) + for (int y = Main.UnderworldLayer; y <= Main.maxTilesY - 110; y++) { Tile tile = Main.tile[x, y]; Tile tileUp = Main.tile[x, y - 1]; @@ -331,7 +331,7 @@ namespace CalamityMod.World for (int x = biomeStart; x <= biomeEdge; x++) { - for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 5; y++) + for (int y = Main.UnderworldLayer; y <= Main.maxTilesY - 5; y++) { Tile tile = Main.tile[x, y]; Tile tileUp = Main.tile[x, y - 1]; @@ -364,7 +364,7 @@ namespace CalamityMod.World for (int x = biomeStart; x <= biomeEdge; x++) { - for (int y = Main.maxTilesY - 200; y <= Main.maxTilesY - 5; y++) + for (int y = Main.UnderworldLayer; y <= Main.maxTilesY - 5; y++) { Tile tile = Main.tile[x, y]; diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index c1c86a8b41..f26257c70e 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -100,7 +100,7 @@ namespace CalamityMod.World do { - int underworldTop = Main.maxTilesY - 200; + int underworldTop = Main.UnderworldLayer; int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.1f), (int)(Main.maxTilesX * 0.9f)); int placementPositionY = WorldGen.genRand.Next(underworldTop - 550, underworldTop - 50); @@ -179,7 +179,7 @@ namespace CalamityMod.World do { - int underworldTop = Main.maxTilesY - 200; + int underworldTop = Main.UnderworldLayer; int placementPositionX = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.15f), (int)(Main.maxTilesX * 0.85f)); int placementPositionY = WorldGen.genRand.Next(underworldTop - 400, underworldTop - 50); @@ -254,7 +254,7 @@ namespace CalamityMod.World do { - int underworldTop = Main.maxTilesY - 200; + int underworldTop = Main.UnderworldLayer; //gen opposite to the brimstone crags int placementPositionX = (Main.dungeonX > Main.maxTilesX / 2) ? WorldGen.genRand.Next((int)(Main.maxTilesX / 12), (int)(Main.maxTilesX / 9)) : WorldGen.genRand.Next((int)(Main.maxTilesX * 0.82), (int)(Main.maxTilesX * 0.925)); int placementPositionY = WorldGen.genRand.Next(Main.maxTilesY - 150, Main.maxTilesY - 125); @@ -351,7 +351,7 @@ namespace CalamityMod.World int sunkenSeaY = 0; //copied the desert position code from the sunken sea's generation so the lab always generates within the sunken sea properly - for (int y = Main.maxTilesY - 200; y >= Main.worldSurface; y--) + for (int y = Main.UnderworldLayer; y >= Main.worldSurface; y--) { if (Main.tile[placementPositionX, y].WallType == ModContent.WallType() || Main.tile[placementPositionX, y].WallType == ModContent.WallType()) @@ -425,7 +425,7 @@ namespace CalamityMod.World do { - int underworldTop = Main.maxTilesY - 200; + int underworldTop = Main.UnderworldLayer; int placementPositionX = WorldGen.genRand.Next(120, Main.maxTilesX - 120); int placementPositionY = WorldGen.genRand.Next((int)Main.worldSurface + 160, underworldTop - HellVerticalAvoidance); @@ -508,7 +508,7 @@ namespace CalamityMod.World do { - int underworldTop = Main.maxTilesY - 200; + int underworldTop = Main.UnderworldLayer; int placementPositionX = WorldGen.genRand.Next(120, Main.maxTilesX - 120); int placementPositionY = WorldGen.genRand.Next((int)Main.worldSurface + 160, underworldTop - HellVerticalAvoidance); diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs index d40c79071f..cb1e3dd3ea 100644 --- a/World/MiscWorldgenRoutines.cs +++ b/World/MiscWorldgenRoutines.cs @@ -427,7 +427,7 @@ namespace CalamityMod.World #region Smart Gem Gen public static void SmartGemGen() { - double oneThirdOfUnderground = (Main.maxTilesY - 200 - Main.worldSurface) / 3D; + double oneThirdOfUnderground = (Main.UnderworldLayer - Main.worldSurface) / 3D; double verticalStartFactor_Layer1 = Main.worldSurface; double verticalStartFactor_Layer2 = verticalStartFactor_Layer1 + oneThirdOfUnderground; double verticalStartFactor_Layer3 = verticalStartFactor_Layer1 + oneThirdOfUnderground * 2D; diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index 57dd771a87..f020932486 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -130,7 +130,7 @@ namespace CalamityMod.World get { if (Main.remixWorld) - return (int)((Main.maxTilesY - 200) * 0.2f); + return (int)(Main.UnderworldLayer * 0.2f); float depthFactor = Main.maxTilesX switch { @@ -235,7 +235,7 @@ namespace CalamityMod.World xCheckPosition += Abyss.AtLeftSideOfWorld.ToDirectionInt(); } while (CalamityUtils.ParanoidTileRetrieval(determinedPoint.X, determinedPoint.Y).TileType == TileID.Ebonstone); - YStart = Main.remixWorld ? (int)((Main.maxTilesY - 200) * 0.8f) : determinedPoint.Y; + YStart = Main.remixWorld ? (int)(Main.UnderworldLayer * 0.8f) : determinedPoint.Y; } public static void GenerateSandBlock() @@ -976,7 +976,7 @@ namespace CalamityMod.World for (int i = 0; i < BiomeWidth; i++) { int x = GetActualX(i); - for (int y = YStart - 140; y < (Main.remixWorld ? (Main.maxTilesY - 200) : Main.rockLayer); y++) + for (int y = YStart - 140; y < (Main.remixWorld ? Main.UnderworldLayer : Main.rockLayer); y++) { Tile tile = Main.tile[x, y]; Tile tileUp = Main.tile[x, y - 1]; diff --git a/World/UndergroundShrines.cs b/World/UndergroundShrines.cs index 56e2d98ce4..d109e2340b 100644 --- a/World/UndergroundShrines.cs +++ b/World/UndergroundShrines.cs @@ -357,7 +357,7 @@ namespace CalamityMod.World for (int y = placementPoint.Y; y < placementPoint.Y + schematicSize.Y; y++) { Tile tile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (ShouldAvoidLocation(new Point(x, y))) + if (ShouldAvoidLocation(new Point(x, y), false)) canGenerateInLocation = false; //The granite geode is supposed to fully float in free air. No tile replacements diff --git a/World/VernalPass.cs b/World/VernalPass.cs index 302a9ea44f..f1c6aa9875 100644 --- a/World/VernalPass.cs +++ b/World/VernalPass.cs @@ -18,13 +18,37 @@ namespace CalamityMod.World var schematic = TileMaps[mapKey]; int placementPositionX = WorldGen.genRand.Next(GenVars.tLeft, GenVars.tRight); - int placementPositionY = GenVars.tTop < Main.rockLayer - 10 ? GenVars.tBottom + 120 : GenVars.tTop - 120; + + //initialPlacementPositionY is the exact same variable as placementPositionY, but it is used to store the original starting position of the vernal pass + //this is to prevent any cases of infinite looping in the loop below when the vernal pass y-position is increased/decreased to move away from the temple and find a valid position + int initialPlacementPositionY = GenVars.tTop < Main.maxTilesY / 2 ? GenVars.tBottom + 150 : GenVars.tTop - 150; + int placementPositionY = GenVars.tTop < Main.maxTilesY / 2 ? GenVars.tBottom + 150 : GenVars.tTop - 150; + + //attempt to find a valid position for the biome to place in + bool foundValidPosition = false; + int attempts = 0; + + //continously place up/down until it is far enough from the temple to not destroy it + while (!foundValidPosition && attempts++ < 100000) + { + while (!NoTempleNearby(placementPositionX, placementPositionY)) + { + //increase the actual y-position the vernal pass will place at based on the starting location, if the jungle temple is too close to the initial starting location + placementPositionY += (initialPlacementPositionY < (Main.maxTilesX / 2) ? -10 : 10); + } + if (NoTempleNearby(placementPositionX, placementPositionY)) + { + foundValidPosition = true; + } + } + Point placementPoint = new Point(placementPositionX, placementPositionY); Vector2 schematicSize = new Vector2(schematic.GetLength(0), schematic.GetLength(1)); SchematicAnchor anchorType = SchematicAnchor.Center; bool firstItem = false; + PlaceSchematic(mapKey, placementPoint, anchorType, ref firstItem, new Action(FillVernalPassChests)); // Add the Vernal Pass as a protected structure. @@ -65,5 +89,22 @@ namespace CalamityMod.World chest.item[i].stack = contents[i].Stack; } } + + //determine if theres no snow blocks nearby so the biome doesnt place in the snow biome + public static bool NoTempleNearby(int X, int Y) + { + for (int i = X - 140; i < X + 140; i++) + { + for (int j = Y - 140; j < Y + 140; j++) + { + if (Main.tile[i, j].HasTile && Main.tile[i, j].TileType == TileID.LihzahrdBrick) + { + return false; + } + } + } + + return true; + } } } diff --git a/en-US.hjson b/en-US.hjson deleted file mode 100644 index b06ff7286d..0000000000 --- a/en-US.hjson +++ /dev/null @@ -1 +0,0 @@ -Mods.CalamityMod.Projectiles.CosmicShivAura.DisplayName: Cosmic Shiv Aura diff --git a/icon.png b/icon.png index 88d6a402f6..bcc6cce92b 100644 Binary files a/icon.png and b/icon.png differ diff --git a/icon_workshop.png b/icon_workshop.png index 5ede327664..df0f63ecf2 100644 Binary files a/icon_workshop.png and b/icon_workshop.png differ