diff --git a/Buffs/CalamityGlobalBuff.cs b/Buffs/CalamityGlobalBuff.cs index 0fae2bfeae..179849f6eb 100644 --- a/Buffs/CalamityGlobalBuff.cs +++ b/Buffs/CalamityGlobalBuff.cs @@ -114,15 +114,15 @@ namespace CalamityMod.Buffs break; case BuffID.BeetleMight1: - tip = "Melee damage and speed increase by 5%"; + tip = "Melee damage increased by 10%"; break; case BuffID.BeetleMight2: - tip = "Melee damage and speed increase by 10%"; + tip = "Melee damage increased by 20%"; break; case BuffID.BeetleMight3: - tip = "Melee damage and speed increase by 15%"; + tip = "Melee damage increased by 30%"; break; case BuffID.BeetleEndurance1: diff --git a/Buffs/Potions/ProfanedRageBuff.cs b/Buffs/Potions/ProfanedRageBuff.cs index 883e131a87..fa93c8b202 100644 --- a/Buffs/Potions/ProfanedRageBuff.cs +++ b/Buffs/Potions/ProfanedRageBuff.cs @@ -8,7 +8,7 @@ namespace CalamityMod.Buffs.Potions public override void SetDefaults() { DisplayName.SetDefault("Profaned Rage"); - Description.SetDefault("Increased crit chance, increased movement and flight speed, and you gain more rage when damaged"); + Description.SetDefault("Increased crit chance, movement and flight speed"); Main.debuff[Type] = false; Main.pvpBuff[Type] = true; Main.buffNoSave[Type] = false; diff --git a/Buffs/Summon/VoidConcentrationBuff.cs b/Buffs/Summon/VoidConcentrationBuff.cs new file mode 100644 index 0000000000..a83a737d5f --- /dev/null +++ b/Buffs/Summon/VoidConcentrationBuff.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + class VoidConcentrationBuff : ModBuff + { + public override void SetDefaults() + { + DisplayName.SetDefault("Concentrated Void"); + Description.SetDefault("The infinite void yearns for more..."); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + //Main.persistentBuff[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer mp = player.Calamity(); + int count = player.ownedProjectileCounts[ModContent.ProjectileType()]; + player.minionDamage += 0.05f; //5% + player.armorPenetration += 10; + if (!mp.voidAuraDamage && count == 0) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + { + player.buffTime[buffIndex] = 18000; + } + } + } +} diff --git a/Buffs/Summon/VoidConcentrationBuff.png b/Buffs/Summon/VoidConcentrationBuff.png new file mode 100644 index 0000000000..0aff2acf15 Binary files /dev/null and b/Buffs/Summon/VoidConcentrationBuff.png differ diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index f7350ef710..d889014361 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -42,6 +42,7 @@ using CalamityMod.NPCs.SulphurousSea; using CalamityMod.NPCs.SunkenSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; +using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Projectiles.Enemy; @@ -52,6 +53,7 @@ using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; +using CalamityMod.Skies; using CalamityMod.Tiles; using CalamityMod.UI; using CalamityMod.World; @@ -72,6 +74,8 @@ using Terraria.Localization; using Terraria.ModLoader; using Terraria.ModLoader.IO; +using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; + namespace CalamityMod.CalPlayer { public partial class CalamityPlayer : ModPlayer @@ -590,6 +594,8 @@ namespace CalamityMod.CalPlayer public int roverDriveTimer = 0; public int roverFrameCounter = 0; public int roverFrame = 0; + public int voidFrameCounter = 0; + public int voidFrame = 0; public bool rottenDogTooth = false; public bool angelicAlliance = false; public int angelicActivate = -1; @@ -923,6 +929,8 @@ namespace CalamityMod.CalPlayer public bool plaguebringerMK2 = false; public bool igneousExaltation = false; public bool coldDivinity = false; + public bool voidAura = false; + public bool voidAuraDamage = false; public bool youngDuke = false; public bool virili = false; public bool frostBlossom = false; @@ -1051,6 +1059,10 @@ namespace CalamityMod.CalPlayer public bool lecherousOrbEnchant = false; #endregion Calamitas Enchant Effects + #region Draw Effects + public FireParticleSet ProvidenceBurnEffectDrawer = new FireParticleSet(-1, int.MaxValue, Color.Yellow, Color.Red * 1.2f, 10f, 0.65f); + #endregion Draw Effects + #endregion #region SavingAndLoading @@ -1153,7 +1165,8 @@ namespace CalamityMod.CalPlayer return new TagCompound { { "boost", boost }, - { "rage", rage }, // Used to be "stress". Newer saves will never write "stress". + { "rage", rage }, + { "stress", rage * 10000f }, { "adrenaline", adrenaline }, { "aquaticBoostPower", aquaticBoost }, { "sCalDeathCount", sCalDeathCount }, @@ -1227,10 +1240,10 @@ namespace CalamityMod.CalPlayer newCalamitasInventory = boost.Contains("newCalamitasInventory"); GivenBrimstoneLocus = boost.Contains("GivenBrimstoneLocus"); - // Load rage from "stress" if this is an older save. Otherwise load it from "rage", its new name. - if (tag.ContainsKey("stress")) - rage = tag.GetInt("stress"); - else + // Load rage if it's there, which it will be for any players saved with 1.5. + // Older players have "stress" instead, which will be ignored. This is intentional. + // Stress ranged from 0 to 10,000. Rage ranges from 0.0 to 1.0. + if (tag.ContainsKey("rage")) rage = tag.GetFloat("rage"); adrenaline = tag.GetFloat("adrenaline"); @@ -1991,6 +2004,8 @@ namespace CalamityMod.CalPlayer plaguebringerMK2 = false; igneousExaltation = false; coldDivinity = false; + voidAura = false; + voidAuraDamage = false; radiantResolution = false; virili = false; frostBlossom = false; @@ -3672,10 +3687,6 @@ namespace CalamityMod.CalPlayer { meleeSpeedMult += 0.05f; } - if (graxDefense) - { - meleeSpeedMult += 0.1f; - } if (yPower) { meleeSpeedMult += 0.05f; @@ -3782,8 +3793,7 @@ namespace CalamityMod.CalPlayer } if (player.beetleOffense && player.beetleOrbs > 0) { - player.meleeDamage -= 0.05f * player.beetleOrbs; - meleeSpeedMult -= 0.05f * player.beetleOrbs; + meleeSpeedMult -= 0.1f * player.beetleOrbs; } if (CalamityConfig.Instance.Proficiency) { @@ -3868,6 +3878,14 @@ namespace CalamityMod.CalPlayer } roverFrameCounter++; + int frames = 4; + if (voidFrameCounter >= 6) + { + voidFrameCounter = 0; + voidFrame = voidFrame == frames - 1 ? 0 : voidFrame + 1; + } + voidFrameCounter++; + for (int i = 0; i < player.dye.Length; i++) { if (player.dye[i].type == ModContent.ItemType()) @@ -7010,12 +7028,16 @@ namespace CalamityMod.CalPlayer float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; int p = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * 0.065), knockBack * 0.5f, player.whoAmI); + if (p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().forceTypeless = true; //in case melee/rogue variants bug out + + // Handle AI edge-cases. if (item.type == ModContent.ItemType()) - { Main.projectile[p].ai[1] = 1f; - } + if (item.type == ModContent.ItemType()) + Main.projectile[p].ai[0] = -1f; + if (StealthStrikeAvailable()) { int knifeCount = 15; diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index e62115cd7d..21e8f60e60 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -4,8 +4,8 @@ using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.NPCs; using CalamityMod.Projectiles.Summon; -using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -17,6 +17,8 @@ using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; +using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; + namespace CalamityMod.CalPlayer { public class CalamityPlayerDrawEffects : ModPlayer @@ -71,8 +73,14 @@ namespace CalamityMod.CalPlayer { if (drawInfo.shadow != 0f) return; + Player drawPlayer = drawInfo.drawPlayer; CalamityPlayer modPlayer = drawPlayer.Calamity(); + + modPlayer.ProvidenceBurnEffectDrawer.DrawSet(drawPlayer.Bottom - Vector2.UnitY * 10f); + modPlayer.ProvidenceBurnEffectDrawer.SpawnAreaCompactness = 18f; + modPlayer.ProvidenceBurnEffectDrawer.RelativePower = 0.4f; + if (modPlayer.sirenIce) { Texture2D texture = ModContent.GetTexture("CalamityMod/ExtraTextures/IceShield"); @@ -405,6 +413,25 @@ namespace CalamityMod.CalPlayer } }); + public static readonly PlayerLayer ConcentratedVoidAura = new PlayerLayer("CalamityMod", "VoidAura", PlayerLayer.Skin, drawInfo => + { + Player drawPlayer = drawInfo.drawPlayer; + CalamityPlayer modPlayer = drawPlayer.Calamity(); + if (modPlayer.voidAura || modPlayer.voidAuraDamage) + { + Texture2D tex = ModContent.GetTexture("CalamityMod/ExtraTextures/VoidConcentrationAura"); + Vector2 drawPos = drawPlayer.Center - Main.screenPosition + new Vector2(0f, drawPlayer.gfxOffY); + drawPos.Y -= 9; + SpriteEffects spriteEffects = drawPlayer.direction != -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; //intentionally inverse due to giving more space for the player model without faffing about with the specific positioning + Rectangle frame = tex.Frame(1, 4, 0, modPlayer.voidFrame); + Vector2 origin = new Vector2(tex.Width / 2f, tex.Height / 2f / 4f); + float scale = 1.75f; + + DrawData data = new DrawData(tex, drawPos, frame, Color.White * 0.4f, 0f, origin, scale, spriteEffects, 0); + Main.playerDrawData.Add(data); + } + }); + public static readonly PlayerLayer RoverDriveShield = new PlayerLayer("CalamityMod", "RoverDrive", PlayerLayer.Skin, drawInfo => { Player drawPlayer = drawInfo.drawPlayer; @@ -644,6 +671,7 @@ namespace CalamityMod.CalPlayer list.Insert(drawTheStupidSign, ForbiddenCircletSign); } list.Add(ColdDivinityOverlay); + list.Add(ConcentratedVoidAura); list.Add(RoverDriveShield); list.Add(StratusSphereDrawing); list.Add(ProfanedMoonlightDyeEffects); diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index e5221f2e72..8802ca57bd 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -772,8 +772,8 @@ namespace CalamityMod.CalPlayer if (modPlayer.regenator) { - player.lifeRegenTime += 8; - player.lifeRegen += 16; + player.lifeRegenTime += 6; + player.lifeRegen += 12; } if (modPlayer.handWarmer && modPlayer.eskimoSet) { diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index a7f76432d3..b851449bab 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -17,6 +17,7 @@ using CalamityMod.Items.Potions; using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.Astral; @@ -45,6 +46,8 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; + namespace CalamityMod.CalPlayer { public class CalamityPlayerMiscEffects @@ -139,48 +142,6 @@ namespace CalamityMod.CalPlayer #region Revengeance Effects private static void RevengeanceModeMiscEffects(Player player, CalamityPlayer modPlayer, Mod mod) { - if (CalamityGlobalNPC.holyBoss != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBoss].active) - { - if (Main.myPlayer == Main.npc[CalamityGlobalNPC.holyBoss].target) - { - float x = Vector2.Distance(Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center, Main.npc[CalamityGlobalNPC.holyBoss].Center); - float aiState = Main.npc[CalamityGlobalNPC.holyBoss].ai[0]; - float aiTimer = Main.npc[CalamityGlobalNPC.holyBoss].ai[3]; - - float baseDistance = 2800f; - float shorterFlameCocoonDistance = (CalamityWorld.death || CalamityWorld.malice || !Main.dayTime) ? 600f : CalamityWorld.revenge ? 400f : Main.expertMode ? 200f : 0f; - float shorterSpearCocoonDistance = (CalamityWorld.death || CalamityWorld.malice || !Main.dayTime) ? 1000f : CalamityWorld.revenge ? 650f : Main.expertMode ? 300f : 0f; - float shorterDistance = aiState == 2f ? shorterFlameCocoonDistance : shorterSpearCocoonDistance; - - bool guardianAlive = false; - if (CalamityGlobalNPC.holyBossAttacker != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBossAttacker].active) - guardianAlive = true; - } - if (CalamityGlobalNPC.holyBossDefender != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBossDefender].active) - guardianAlive = true; - } - if (CalamityGlobalNPC.holyBossHealer != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBossHealer].active) - guardianAlive = true; - } - - float maxDistance = guardianAlive ? baseDistance : (aiState == 2f || aiState == 5f) ? baseDistance - MathHelper.Lerp(0f, shorterDistance, MathHelper.Clamp(aiTimer / 120f, 0f, 1f)) : baseDistance; - float drawDarknessDistance = maxDistance - 400f; - float intensityScalar = MathHelper.Lerp(0f, 0.9f, MathHelper.Clamp((x - drawDarknessDistance) / 400f, 0f, 1f)); - - if (!Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Calamity().ZoneAbyss && !Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].headcovered) - ScreenObstruction.screenObstruction = MathHelper.Lerp(ScreenObstruction.screenObstruction, 1f, intensityScalar); - } - } - } - if (CalamityWorld.revenge || CalamityWorld.malice) { // This effect is way too annoying during the fight so I disabled it - Fab @@ -654,6 +615,35 @@ namespace CalamityMod.CalPlayer } } + // Update the Providence Burn effect drawer if applicable. + float providenceBurnIntensity = 0f; + if (Main.npc.IndexInRange(CalamityGlobalNPC.holyBoss) && Main.npc[CalamityGlobalNPC.holyBoss].active) + providenceBurnIntensity = (Main.npc[CalamityGlobalNPC.holyBoss].modNPC as ProvidenceBoss).CalculateBurnIntensity(); + modPlayer.ProvidenceBurnEffectDrawer.ParticleSpawnRate = int.MaxValue; + + // If the burn intensity is great enough, cause the player to ignite into flames. + if (providenceBurnIntensity > 0.45f) + modPlayer.ProvidenceBurnEffectDrawer.ParticleSpawnRate = 1; + + // Otherwise, if the intensity is too weak, but still presernt, cause the player to release holy cinders. + else if (providenceBurnIntensity > 0f) + { + int cinderCount = (int)MathHelper.Lerp(1f, 4f, Utils.InverseLerp(0f, 0.45f, providenceBurnIntensity, true)); + for (int i = 0; i < cinderCount; i++) + { + if (!Main.rand.NextBool(3)) + continue; + + Dust holyCinder = Dust.NewDustDirect(player.position, player.width, player.head, (int)CalamityDusts.ProfanedFire); + holyCinder.velocity = Main.rand.NextVector2Circular(3.5f, 3.5f); + holyCinder.velocity.Y -= Main.rand.NextFloat(1f, 3f); + holyCinder.scale = Main.rand.NextFloat(1.15f, 1.45f); + holyCinder.noGravity = true; + } + } + + modPlayer.ProvidenceBurnEffectDrawer.Update(); + // Immunity to most debuffs if (modPlayer.invincible) { @@ -691,10 +681,10 @@ namespace CalamityMod.CalPlayer } } - //extra DoT in the lava of the crags + // Extra DoT in the lava of the crags. Negated by Abaddon. if (player.lavaWet) { - if (modPlayer.ZoneCalamity) + if (modPlayer.ZoneCalamity && !modPlayer.abaddon) player.AddBuff(ModContent.BuffType(), 2, false); } else @@ -3390,7 +3380,7 @@ namespace CalamityMod.CalPlayer player.AddBuff(ModContent.BuffType(), 3600, true); if (player.ownedProjectileCounts[ModContent.ProjectileType()] < 2) - Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(232f * player.MinionDamage()), 2f, Main.myPlayer, 0f, 0f); + Projectile.NewProjectile(player.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(AngryChickenStaff.Damage * player.MinionDamage()), 2f, Main.myPlayer, 0f, 0f); } } diff --git a/CalamityLists.cs b/CalamityLists.cs index bbea353b68..edf83f6757 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -406,6 +406,7 @@ namespace CalamityMod ProjectileID.LaserMachinegun, ProjectileID.ChargedBlasterCannon, ProjectileID.MedusaHead, + ProjectileType(), ProjectileType(), ProjectileType(), @@ -415,6 +416,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), @@ -425,14 +427,20 @@ namespace CalamityMod ProjectileType(), ProjectileType(), - ProjectileType(), ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType(), + //Some hostile boss projectiles ProjectileType(), ProjectileType(), @@ -1909,7 +1917,7 @@ namespace CalamityMod ProjectileType(), ProjectileType(), ProjectileType(), - ProjectileType(), + ProjectileType(), ProjectileType(), ProjectileType(), ProjectileType(), @@ -2538,7 +2546,7 @@ namespace CalamityMod NPCType(), NPCType(), NPCType(), - NPCType() + NPCType() }; bossMinionList = new List() diff --git a/CalamityMod.cs b/CalamityMod.cs index 0b2d9a2f57..f6b684a6ec 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -1425,49 +1425,6 @@ namespace CalamityMod { // Apply the calculated darkness value for the local player. CalamityPlayer modPlayer = Main.LocalPlayer.Calamity(); - if (CalamityGlobalNPC.holyBoss != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBoss].active) - { - if (Main.myPlayer == Main.npc[CalamityGlobalNPC.holyBoss].target) - { - float x = Vector2.Distance(Main.player[Main.npc[CalamityGlobalNPC.holyBoss].target].Center, Main.npc[CalamityGlobalNPC.holyBoss].Center); - float aiState = Main.npc[CalamityGlobalNPC.holyBoss].ai[0]; - float aiTimer = Main.npc[CalamityGlobalNPC.holyBoss].ai[3]; - - float baseDistance = 2800f; - float shorterFlameCocoonDistance = (CalamityWorld.death || CalamityWorld.malice || !Main.dayTime) ? 600f : CalamityWorld.revenge ? 400f : Main.expertMode ? 200f : 0f; - float shorterSpearCocoonDistance = (CalamityWorld.death || CalamityWorld.malice || !Main.dayTime) ? 1000f : CalamityWorld.revenge ? 650f : Main.expertMode ? 300f : 0f; - float shorterDistance = aiState == 2f ? shorterFlameCocoonDistance : shorterSpearCocoonDistance; - - bool guardianAlive = false; - if (CalamityGlobalNPC.holyBossAttacker != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBossAttacker].active) - guardianAlive = true; - } - if (CalamityGlobalNPC.holyBossDefender != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBossDefender].active) - guardianAlive = true; - } - if (CalamityGlobalNPC.holyBossHealer != -1) - { - if (Main.npc[CalamityGlobalNPC.holyBossHealer].active) - guardianAlive = true; - } - - float maxDistance = guardianAlive ? baseDistance : (aiState == 2f || aiState == 5f) ? baseDistance - MathHelper.Lerp(0f, shorterDistance, MathHelper.Clamp(aiTimer / 120f, 0f, 1f)) : baseDistance; - float drawDarknessDistance = maxDistance - 400f; - float intensityScalar = MathHelper.Lerp(0f, 0.9f, MathHelper.Clamp((x - drawDarknessDistance) / 400f, 0f, 1f)); - scale -= intensityScalar; - - // Return to prevent running other darkness code - return; - } - } - } - float darkRatio = MathHelper.Clamp(modPlayer.caveDarkness, 0f, 1f); if (modPlayer.ZoneAbyss) diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index c54b44e022..455d0d846a 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -1,4 +1,5 @@ using CalamityMod.Events; +using CalamityMod.Items; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.Providence; @@ -110,6 +111,10 @@ namespace CalamityMod if (Main.netMode != NetmodeID.MultiplayerClient) NPC.NewNPC(x, y, ModContent.NPCType()); break; + case CalamityModMessageType.DeleteAllSuperDummies: + if (Main.netMode != NetmodeID.MultiplayerClient) + SuperDummy.DeleteDummies(); + break; case CalamityModMessageType.ServersideSpawnOldDuke: byte playerIndex2 = reader.ReadByte(); CalamityUtils.SpawnOldDuke(playerIndex2); @@ -277,7 +282,8 @@ namespace CalamityMod // Syncs for specific bosses or entities SyncCalamityNPCAIArray, - SpawnSuperDummy, // TODO -- super dummies STILL don't work in multiplayer + SpawnSuperDummy, + DeleteAllSuperDummies, ServersideSpawnOldDuke, DoGCountdownSync, // TODO -- this gets written in about six thousand places which all need to be individually evaluated ArmoredDiggerCountdownSync, // TODO -- remove this mechanic entirely diff --git a/Effects/BordernadoFire.xnb b/Effects/BordernadoFire.xnb index 2d0ac3b0dc..7dff3c4fba 100644 Binary files a/Effects/BordernadoFire.xnb and b/Effects/BordernadoFire.xnb differ diff --git a/Effects/Dyes/AstralBlueDyeShader.fx b/Effects/Dyes/AstralBlueDyeShader.fx new file mode 100644 index 0000000000..3373d2db78 --- /dev/null +++ b/Effects/Dyes/AstralBlueDyeShader.fx @@ -0,0 +1,29 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + float interval = cos(uTime * 7 + coords.x * 4) / 2 + 0.5; + float4 returnColor = float4(lerp(uColor, uSecondaryColor, interval), 1); // Fade between two colors depending on the time and x position on the texture in a 0-1 cosine linear interpolation. The color can vary. + return returnColor * color; // And multiply by the original color to give it a blend effect. +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/AstralOrangeDyeShader.fx b/Effects/Dyes/AstralOrangeDyeShader.fx new file mode 100644 index 0000000000..d818ed01a9 --- /dev/null +++ b/Effects/Dyes/AstralOrangeDyeShader.fx @@ -0,0 +1,31 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float interval = (cos((uTime - 0.5) * 17 + frameY * 8) / 2 + 0.5); + float4 returnColor = float4(lerp(uColor, uSecondaryColor, interval), 1); // One again, use a cosine lerp based on position and time, but this time, with the Y position. + + return returnColor * color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/AstralSwirlDyeShader.fx b/Effects/Dyes/AstralSwirlDyeShader.fx new file mode 100644 index 0000000000..47674dfa44 --- /dev/null +++ b/Effects/Dyes/AstralSwirlDyeShader.fx @@ -0,0 +1,55 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float2 RotatedBy(float2 xy, float theta) +{ + return float2(xy.x * cos(theta) + xy.y * sin(theta), xy.x * sin(theta) - xy.y * cos(theta)); +} + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float interval = (cos(uTime * 2.2 + frameY * coords.x * 1.55) * 0.5 + 0.5) * 0.6 + 0.2; // A complex function that works based on the X and Y coords with a 0.2-0.8 range. + float brightness = 1.35; + float3 returnColor = uColor; + // Rotate the colors around and adjust the brightness. + for (int i = 0; i < 4; i++) + { + float2 positionAt = float2(interval, 1 - interval); + positionAt = (RotatedBy(float2(cos(uTime * 1.7 + i / 4 * 6.283), cos(uTime * 1.9 + i / 4 * 6.283)), uTime + i / 4 * 6.283) * 0.5 + 0.5) - positionAt; + float dist = distance(coords, positionAt); + if (dist < 0.35) + { + float inverseDistanceRatio = 1 - dist / 0.35; + returnColor = lerp(uColor, uSecondaryColor, inverseDistanceRatio); + brightness = lerp(1.35, 1.7, inverseDistanceRatio); + } + } + + if (frameY > 0.5) + { + returnColor = lerp(returnColor, uSecondaryColor, (frameY - 0.5) * 3); + } + + return float4(returnColor, 1) * color * brightness; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/BloodflareDyeShader.fx b/Effects/Dyes/BloodflareDyeShader.fx new file mode 100644 index 0000000000..8feb36ca88 --- /dev/null +++ b/Effects/Dyes/BloodflareDyeShader.fx @@ -0,0 +1,44 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float4 pixelBelow = tex2D(uImage0, coords); + float4 noiseColor = tex2D(uImage1, float2(coords.x, frac(frameY - uTime * 0.67)) * 0.5) * 1.5; + float verticalFlowMovement = (sin(coords.x * 14.71 + frameY * 13.5 - uTime * 5.6) * 0.5 + 0.5) * noiseColor.r; + if (pixelBelow.a == 0 && frameY < 0.96) + coords.y = saturate(coords.y + verticalFlowMovement / uSourceRect.w / 17); + float4 color = tex2D(uImage0, coords); + + // Prepare the dark outlines. + float outlineFade = pow(1 - (color.r + color.g + color.b) / 3, 2); + color = lerp(color, float4(uColor, 1), outlineFade) * color.a; + + // Prepare the bright in-lines. + color = lerp(color, float4(uSecondaryColor, 1), saturate(1 - outlineFade) * 0.8) * color.a; + + // Handle red fades based on noise. + color = lerp(color, float4(1, 0, 0, 1), pow(noiseColor.r, 3) * 0.3 + verticalFlowMovement * 0.3 + 0.16) * color.a; + + return color * (1 + (1 - outlineFade) * 0.25); +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/BloodflareDyeShader.xnb b/Effects/Dyes/BloodflareDyeShader.xnb new file mode 100644 index 0000000000..534222798e Binary files /dev/null and b/Effects/Dyes/BloodflareDyeShader.xnb differ diff --git a/Effects/Dyes/CalamitousDyeShader.fx b/Effects/Dyes/CalamitousDyeShader.fx new file mode 100644 index 0000000000..8b1c719929 --- /dev/null +++ b/Effects/Dyes/CalamitousDyeShader.fx @@ -0,0 +1,43 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float4 noiseColor = tex2D(uImage1, float2(coords.x, frameY)); + float4 color = tex2D(uImage0, coords); + float3 blendColor = lerp(uColor, uSecondaryColor, sqrt(frameY)); + float blendFactor = (cos(uTime * 9 + coords.x * 18) * 0.5 + 0.5) * 0.5; + + // Allow the fade to pulse upward based on how far up the pixel is. + blendFactor += (cos(uTime * -13 - frameY * 7.1)) * 0.5; + float brightness = blendFactor * 0.35 + noiseColor.r * 0.35; + + // Cause the effects to taper off at the bottom of the sprite. + if (frameY < 0.2) + { + brightness *= frameY / 0.2; + blendFactor *= frameY / 0.2; + } + float4 colorBlendMultiplier = lerp(float4(blendColor, 1), float4(1, 1, 1, 1), saturate(pow(blendFactor * 1.5, 2))); + return (lerp(color, float4(blendColor, 1), blendFactor * 0.5 + 0.2) * color.a) * colorBlendMultiplier * (1 + brightness); +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/CalamitousDyeShader.xnb b/Effects/Dyes/CalamitousDyeShader.xnb new file mode 100644 index 0000000000..4287b463b7 Binary files /dev/null and b/Effects/Dyes/CalamitousDyeShader.xnb differ diff --git a/Effects/Dyes/CeaselessDyeShader.fx b/Effects/Dyes/CeaselessDyeShader.fx new file mode 100644 index 0000000000..c0041ee41d --- /dev/null +++ b/Effects/Dyes/CeaselessDyeShader.fx @@ -0,0 +1,37 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float randomness(float2 uv) +{ + float noise = (frac(sin(dot(uv, float2(12.9898, 78.233) * 2.0)) * 43758.5453)); + return noise; +} + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + coords.x += randomness(uTime + frameY).x * 0.09 * (1 - frameY); // Add an X offset based on a noise function, giving a moon lord void-esque shader effect. + float4 color = tex2D(uImage0, coords); + float4 returnColor = color * 0.1; + returnColor.a = color.a; + return returnColor; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/CosmicFlameShader.fx b/Effects/Dyes/CosmicFlameShader.fx new file mode 100644 index 0000000000..c1dee78a4f --- /dev/null +++ b/Effects/Dyes/CosmicFlameShader.fx @@ -0,0 +1,49 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float2 swirlOffset = float2(sin(uTime * 0.96 + 1.754) * 0.31, sin(uTime * 0.96) * 0.16) * uSaturation; + float4 color = tex2D(uImage0, coords); + float4 noiseColor = tex2D(uImage1, frac(float2(coords.x, frameY + uTime * 0.36) + swirlOffset - uWorldPosition * 0.0006) * 0.26); + float4 flameColor = tex2D(uImage1, frac(float2(coords.x, frameY + uTime * 0.44)) * 0.1); + float brightnessFactor = noiseColor.r * 2; + + float normalizedDistanceFromCenter = distance(float2(coords.x, frameY), float2(0.5, 0.5)) * 2; + + // Cause "ring" fades based on distance. + float fadeToNormal = 1 - saturate((normalizedDistanceFromCenter - 0.67) / 0.3); + + // Cause noise-based stars to appear all across the sprite. + float3 starColor = lerp(uColor * 1.1, uSecondaryColor, sin(brightnessFactor * 6.283) * 0.5 + 0.5); + + // Prepare a dull, bluish-greyish background across the sprite for contrast. + color = lerp(color, float4(43 / 255.0, 58 / 255.0, 92 / 255.0, 1) * color.a, fadeToNormal * 0.45); + + // Fade to the secondary color based on the flame color map. This helps the overall result more vibrant. + color = lerp(color, float4(uSecondaryColor, 1) * color.a, flameColor.r * 0.5); + + // And create stars based on a noise texture that rise upward. + color = lerp(color, float4(starColor, 1) * color.a, fadeToNormal * pow(brightnessFactor, 6) * 0.15); + return color * (1 + brightnessFactor); +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/CosmicFlameShader.xnb b/Effects/Dyes/CosmicFlameShader.xnb new file mode 100644 index 0000000000..a526ff1430 Binary files /dev/null and b/Effects/Dyes/CosmicFlameShader.xnb differ diff --git a/Effects/Dyes/CryonicDyeShader.fx b/Effects/Dyes/CryonicDyeShader.fx new file mode 100644 index 0000000000..3a108d42f8 --- /dev/null +++ b/Effects/Dyes/CryonicDyeShader.fx @@ -0,0 +1,42 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float4 noiseColor = tex2D(uImage1, float2(frac(coords.x + uTime * 0.1), frameY)); + float4 color = tex2D(uImage0, coords); + + // Cause sharp brightness increases based on a perlin noise map. + // This causes icy, crystaline structures to appear. + float brightness = pow((noiseColor.r + noiseColor.g + noiseColor.b) / 3, 3) * 3; + float normalizedDistanceFromCenter = distance(float2(coords.x, frameY), float2(0.5, 0.5)) * 2; + + // Cause "ring" fades based on distance. + float fadeToSecondaryColor = pow(sin(uTime * -1.56 + normalizedDistanceFromCenter * 3.141), 6); + + // This fades out at the ends of the sprite. + if (normalizedDistanceFromCenter > 0.7) + fadeToSecondaryColor *= saturate(1 - (normalizedDistanceFromCenter - 0.7) / 0.2); + float4 endFadeColor = lerp(float4(uColor, 1), float4(uSecondaryColor, 1), 0.5); + return (lerp(color, endFadeColor, 0.3 + fadeToSecondaryColor * 0.6) * color.a) * (1 + brightness); +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/CryonicDyeShader.xnb b/Effects/Dyes/CryonicDyeShader.xnb new file mode 100644 index 0000000000..93b9009e6a Binary files /dev/null and b/Effects/Dyes/CryonicDyeShader.xnb differ diff --git a/Effects/Dyes/DefiledFlameDyeShader.fx b/Effects/Dyes/DefiledFlameDyeShader.fx new file mode 100644 index 0000000000..8d7f5639b6 --- /dev/null +++ b/Effects/Dyes/DefiledFlameDyeShader.fx @@ -0,0 +1,44 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +static float Variance = 0.4f; +static float MinBrightness = 1.5f; +static float MaxBrightness = 2.5f; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + + float4 noiseColor = tex2D(uImage1, coords); + + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float interval = cos(uTime * 7 + frameY * 6) * 0.5 + 0.5; + + float brightness = pow((interval + sin(uTime + coords.x * uTime * frameY * cos(uTime)) * 0.5 + 0.5) * 0.5, 2); // Force the brightness to rise to 1 more quickly + brightness = brightness * (MaxBrightness - MinBrightness) + MinBrightness; // And bring it to a specified range + + float4 colorMap = float4(lerp(uColor, uSecondaryColor, interval) + noiseColor.rgb * 0.4, 1); + colorMap.rgb *= brightness; + colorMap.rgb = colorMap.rgb - colorMap.rgb % Variance; // Slice the return color map to make pixels appear less varied and more extreme + + return colorMap * color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/DragonSoulDyeShader.fx b/Effects/Dyes/DragonSoulDyeShader.fx new file mode 100644 index 0000000000..80cb2729fd --- /dev/null +++ b/Effects/Dyes/DragonSoulDyeShader.fx @@ -0,0 +1,41 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +static float3 colors[4] = +{ + float3(195, 50, 37) / 255.0, + float3(252, 155, 0) / 255.0, + float3(255, 235, 195) / 255.0, + float3(252, 155, 0) / 255.0 +}; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float interval = (cos(coords.x * 6.283 + uTime * 3.141) * 2 + sin(uTime * 7 + frameY * 6)) * 0.125 + 0.5; + interval *= 2; // Exaggerate the interval. + float4 returnColor = float4(lerp(colors[floor(interval) % 4], colors[floor(interval + 1) % 4], interval % 1), 1); // But clamp it to a 0-1 range. + + return returnColor * color * 1.95; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/ElementalDyeShader.fx b/Effects/Dyes/ElementalDyeShader.fx new file mode 100644 index 0000000000..0303576ddb --- /dev/null +++ b/Effects/Dyes/ElementalDyeShader.fx @@ -0,0 +1,44 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; + + float time = (sin(uTime + coords.x * cos(uTime + 3.141 * coords.x) + 1.5707 * frameY) * 0.5 + 0.5) * 6; + float timeFloored = floor(time); + + float3 colors[6] = + { + float3(241, 149, 49), // Solar + float3(88, 201, 169), // Vortex + float3(102, 200, 249), // Stardust + float3(226, 76, 239) * 0.7, // Nebula + float3(102, 200, 249), // Stardust + float3(88, 201, 169) // Vortex + }; + + // Use a multi-lerp to fade between colors and then base them on a trig-based time step. + color.rgb *= lerp(colors[timeFloored] / 255.0, colors[(timeFloored + 1) % 6] / 255.0, time / 6) * 1.6; + return color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/EndothermicDyeShader.fx b/Effects/Dyes/EndothermicDyeShader.fx new file mode 100644 index 0000000000..75de6d38ef --- /dev/null +++ b/Effects/Dyes/EndothermicDyeShader.fx @@ -0,0 +1,33 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + + // Saturate basically clamps to a 0-1 range. Basically, the further away from the center the closer the color becomes to the secondary color. + float3 idealColor = lerp(uColor, uSecondaryColor, saturate(distance(float2(coords.x, frameY), (0.5, 0.5)))); + float4 color = tex2D(uImage0, coords); + float luminosity = (color.r + color.g + color.b) / 3; + color.rgb = luminosity * idealColor * 1.3; // Average out the colors. + return color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/NightmareDyeShader.fx b/Effects/Dyes/NightmareDyeShader.fx new file mode 100644 index 0000000000..8d14568a57 --- /dev/null +++ b/Effects/Dyes/NightmareDyeShader.fx @@ -0,0 +1,36 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float3 idealColor = uColor; + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float depth = sin(uTime * 3 + coords.x * 2) * 0.05; + if (frameY < 0.425 + depth) + { + idealColor = lerp(uColor, uSecondaryColor, 1 - frameY / (0.425 + depth)); + } + float4 color = tex2D(uImage0, coords); + float luminosity = (color.r + color.g + color.b) / 3; + color.rgb = luminosity * idealColor * 1.6; // Average out the colors. + return color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/PhantoplasmDyeShader.fx b/Effects/Dyes/PhantoplasmDyeShader.fx new file mode 100644 index 0000000000..02a09722ae --- /dev/null +++ b/Effects/Dyes/PhantoplasmDyeShader.fx @@ -0,0 +1,42 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float4 noiseColor = tex2D(uImage1, float2(coords.x, frac(frameY + uTime * 0.7))); + float4 color = tex2D(uImage0, coords); + float normalizedDistanceFromCenter = distance(float2(coords.x, frameY), float2(0.5, 0.5)) * 2; + + // Cause "ring" pulses based on distance. + float fadeToSecondaryColor = pow(sin(uTime * -2.56 + normalizedDistanceFromCenter * 2), 4); + + // This fades out at the ends of the sprite. + if (normalizedDistanceFromCenter > 0.7) + fadeToSecondaryColor *= saturate(1 - (normalizedDistanceFromCenter - 0.7) / 0.37 + sin(coords.x * coords.y * 12) * 0.1); + float4 endFadeColor = float4(lerp(uColor, uSecondaryColor, fadeToSecondaryColor * 0.74 + noiseColor.g * 0.13), 1); + + float4 blendedColor = (color + endFadeColor) * 0.5 - 0.05; + blendedColor *= 1.4; + blendedColor.a = 1; + return blendedColor * color.a * (1 + lerp(0.07, 0.3, fadeToSecondaryColor) + noiseColor.g * 0.1); +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/PhantoplasmDyeShader.xnb b/Effects/Dyes/PhantoplasmDyeShader.xnb new file mode 100644 index 0000000000..d1d075c350 Binary files /dev/null and b/Effects/Dyes/PhantoplasmDyeShader.xnb differ diff --git a/Effects/Dyes/ProfanedFlameDyeShader.fx b/Effects/Dyes/ProfanedFlameDyeShader.fx new file mode 100644 index 0000000000..f1964bc244 --- /dev/null +++ b/Effects/Dyes/ProfanedFlameDyeShader.fx @@ -0,0 +1,44 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + float4 color = tex2D(uImage0, coords); + + // Read the fade map as a streak. + float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.x * 0.18 + cos(uTime * 0.9) * 0.021), frac(frameY * 0.32 + uTime * 0.2))); + fadeMapColor.r *= pow(coords.x, 0.2); + + float opacity = lerp(1.05, 1.95, fadeMapColor.r); + opacity *= fadeMapColor.r + 1; + opacity *= lerp(0.4, 1.1, fadeMapColor.r); + + float3 transformColor = lerp(uColor, uSecondaryColor, fadeMapColor.r); + float orangeFade = 1 - saturate((frameY - 0.08) / 0.74); + opacity += (1 - orangeFade) * 0.6; + + transformColor = lerp(transformColor, float3(206 / 255, 116 / 255, 59 / 255), orangeFade); + color.rgb = lerp(color.rgb, transformColor, fadeMapColor.r); + opacity *= color.a; + return color * opacity; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/ProfanedFlameDyeShader.xnb b/Effects/Dyes/ProfanedFlameDyeShader.xnb new file mode 100644 index 0000000000..8121fa4bfa Binary files /dev/null and b/Effects/Dyes/ProfanedFlameDyeShader.xnb differ diff --git a/Effects/Dyes/ProfanedMoonlightDye.fx b/Effects/Dyes/ProfanedMoonlightDye.fx new file mode 100644 index 0000000000..70dc4c8cb9 --- /dev/null +++ b/Effects/Dyes/ProfanedMoonlightDye.fx @@ -0,0 +1,28 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 returnColor = tex2D(uImage0, coords); + returnColor.rgb *= uColor * ((cos(uTime) * 0.5 + 0.5) * 0.3 + 1.3); + return returnColor; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/ReaverDyeShader.fx b/Effects/Dyes/ReaverDyeShader.fx new file mode 100644 index 0000000000..283a3267b2 --- /dev/null +++ b/Effects/Dyes/ReaverDyeShader.fx @@ -0,0 +1,34 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + float luminosity = (color.r + color.g + color.b) / 3; + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + + float yMultiplier = sqrt(frameY) * (sin(frameY * 2 + uTime * 1.4) + 1) * 0.5; + + color.rgb *= ((coords.x * uColor * (1 - yMultiplier) * 1.4) + ((1 - coords.x) * uSecondaryColor * yMultiplier * 1.7)) * luminosity * 2.1; + color.rgb *= clamp(1.6 * saturate(distance((0.5, 0.5), coords)), 0.8, 1.6); // Intensify the colors based on how far they are from the center of the sprite. + return color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/ShadowspecDyeShader.fx b/Effects/Dyes/ShadowspecDyeShader.fx new file mode 100644 index 0000000000..dfa0d8c88b --- /dev/null +++ b/Effects/Dyes/ShadowspecDyeShader.fx @@ -0,0 +1,47 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +float2 RotatedBy(float theta, float x, float y) +{ + return float2(x * cos(theta) + y * sin(theta), x * sin(theta) - y * cos(theta)); +} +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float sineTime = sin(uTime); // Saved so that I don't have the compute this multiple times. Shaders have a limited number of mathematical instructions you can use - 64. + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + + float2 modifiedCoords = coords; + float4 color = tex2D(uImage0, coords); + + modifiedCoords = RotatedBy(uTime + 0.4 * sineTime, modifiedCoords.y, modifiedCoords.x); + float4 noiseColor = tex2D(uImage1, modifiedCoords); + + float xMultiplier = cos(coords.x * 2.3 + uTime) + 1; + float yMultiplier = sin(frameY * 2 + uTime * 1.4) + 1; + + float interpolationValue = saturate(xMultiplier * yMultiplier) * 0.7 + 0.3; // Range of 0-1. Depends on the current coordinates and the time. + + color.rgb *= 0.2 + pow(noiseColor.rgb, 3); // Squash the color to the upper and lower bounds and add a bit of lightness to it. + color.rgb *= lerp(uColor, uSecondaryColor, interpolationValue); // Blend with the secondary color. + color.rgb *= 1.7 + (sineTime * 0.5 + 1.5) * interpolationValue; // Range of 1.7 to 3.7, can cause certain spots to become very bright. + return color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/Dyes/StratusDyeShader.fx b/Effects/Dyes/StratusDyeShader.fx new file mode 100644 index 0000000000..db0b8f5dfe --- /dev/null +++ b/Effects/Dyes/StratusDyeShader.fx @@ -0,0 +1,45 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; + +static float xAdditiveMax = 0.035; +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float4 color = tex2D(uImage0, coords); + float sineTime = sin(uTime); // Saved so that I don't have the compute this multiple times. Shaders have a limited number of mathematical instructions you can use - 64. + float frameY = (coords.y * uImageSize0.y - uSourceRect.y) / uSourceRect.w; // Gets a 0-1 representation of the y position on a given frame, with 0 being the top, and 1 being the bottom. + + float2 modifiedCoords = coords; + modifiedCoords.x += cos(uTime + frameY) * 0.5 + 0.5; // Cause the effect to sway around a bit with time. + + float4 noiseColor = tex2D(uImage1, frac(modifiedCoords)); + + float xMultiplier = cos(coords.x * 2.3 + uTime * 1.15) + 0.5; + float yMultiplier = (sin(frameY * 2 + uTime * 1.4) + 1) * 0.5; + + color.rgb *= lerp(uColor, uSecondaryColor, saturate(xMultiplier * yMultiplier * 1.6)); + if (noiseColor.r > 0.55 + sineTime * 0.025) + { + color.rgb *= 1.6; // Sometimes give light "patches" depending on the swaying noise image. + } + color.rgb *= 1.6 + (sineTime * 0.5 + 1.5) * ((frameY + coords.x) - 1) * 2; // Brighten the shader over time. + return color; +} +technique Technique1 +{ + pass DyePass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/FabstaffStreak.xnb b/Effects/FabstaffStreak.xnb index 45b95d5d3f..9bf2e57eaa 100644 Binary files a/Effects/FabstaffStreak.xnb and b/Effects/FabstaffStreak.xnb differ diff --git a/Effects/FadedUVMapStreak.xnb b/Effects/FadedUVMapStreak.xnb index fbc7a110ec..0ccc66632f 100644 Binary files a/Effects/FadedUVMapStreak.xnb and b/Effects/FadedUVMapStreak.xnb differ diff --git a/Effects/FadingSolidTrail.xnb b/Effects/FadingSolidTrail.xnb index 0d83a614e8..1f44e50a54 100644 Binary files a/Effects/FadingSolidTrail.xnb and b/Effects/FadingSolidTrail.xnb differ diff --git a/Effects/PhaseslayerRipShader.xnb b/Effects/PhaseslayerRipShader.xnb index 02b74566ba..e51ba52a94 100644 Binary files a/Effects/PhaseslayerRipShader.xnb and b/Effects/PhaseslayerRipShader.xnb differ diff --git a/Effects/PrismCrystalStreak.xnb b/Effects/PrismCrystalStreak.xnb index 43f330f1f6..b0aed6e0a2 100644 Binary files a/Effects/PrismCrystalStreak.xnb and b/Effects/PrismCrystalStreak.xnb differ diff --git a/Effects/SCalMouseShader.xnb b/Effects/SCalMouseShader.xnb index a6f0b32b7f..4c8990de6b 100644 Binary files a/Effects/SCalMouseShader.xnb and b/Effects/SCalMouseShader.xnb differ diff --git a/Effects/ScarletDevilStreak.xnb b/Effects/ScarletDevilStreak.xnb index b68ab8631d..20fda783a8 100644 Binary files a/Effects/ScarletDevilStreak.xnb and b/Effects/ScarletDevilStreak.xnb differ diff --git a/Effects/SupremeShieldShader.xnb b/Effects/SupremeShieldShader.xnb index 63dcfed3e6..5a46acbb23 100644 Binary files a/Effects/SupremeShieldShader.xnb and b/Effects/SupremeShieldShader.xnb differ diff --git a/Events/AcidRainEvent.cs b/Events/AcidRainEvent.cs index c5b5a8489a..89c80067e8 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -1,5 +1,6 @@ using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.OldDuke; +using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; using System; @@ -176,6 +177,100 @@ namespace CalamityMod.Events BroadcastEventText("Mods.CalamityMod.AcidRainStart"); // A toxic downpour falls over the wasteland seas! } + /// + /// Handles updating the entire invasion, including more misc operations, such as summoning OD's tornado. + /// + public static void Update() + { + CalamityWorld.timeSinceAcidRainKill++; + CalamityWorld.timeSinceAcidStarted++; + + // If enough time has passed, and no enemy has been killed, end the invasion early. + // The player almost certainly does not want to deal with it. + if (CalamityWorld.timeSinceAcidRainKill >= AcidRainEvent.InvasionNoKillPersistTime) + { + CalamityWorld.acidRainPoints = 0; + CalamityWorld.triedToSummonOldDuke = false; + AcidRainEvent.UpdateInvasion(false); + } + if (!CalamityWorld.startAcidicDownpour) + { + int sulphSeaWidth = SulphurousSea.BiomeWidth; + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + // A variable named "player" already exists above, which retrieves the player who is closest to the map center. + Player player2 = Main.player[playerIndex]; + if (player2.active) + { + // An artificial biome can be made, and therefore, the event could be started by an artificial biome. + // While fighting the event in an artificial biome is not bad, having it be started by a patch of Sulphurous Sand + // would definitely be strange. + // Because of this, this code is executed based on if the player is in the sea (based on tile count) AND position relative to the naturally generated sea. + bool inNaturalSeaPosition = (player2.Center.X <= (sulphSeaWidth + 60f) * 16f && CalamityWorld.abyssSide) || (player2.Center.X >= (Main.maxTilesX - (sulphSeaWidth + 60f)) * 16f && !CalamityWorld.abyssSide); + if (inNaturalSeaPosition && player2.Calamity().ZoneSulphur) + { + // Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea) + // You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!! + CalamityWorld.startAcidicDownpour = true; + CalamityNetcode.SyncWorld(); + break; + } + } + } + } + + // Stop the rain if the Old Duke is present for visibility during the fight. + if (Main.raining && NPC.AnyNPCs(ModContent.NPCType())) + { + Main.raining = false; + CalamityNetcode.SyncWorld(); + } + + // If the rain stops for whatever reason, end the invasion. + // This is primarily done for compatibility, so that if another mod wants to manipulate the weather, + // they can without having to deal with endless rain. + if (!Main.raining && !NPC.AnyNPCs(ModContent.NPCType()) && CalamityWorld.timeSinceAcidStarted > 20) + { + CalamityWorld.acidRainPoints = 0; + CalamityWorld.triedToSummonOldDuke = false; + UpdateInvasion(false); + } + else if (CalamityWorld.timeSinceAcidStarted < 20) + { + Main.raining = true; + Main.cloudBGActive = 1f; + Main.numCloudsTemp = Main.cloudLimit; + Main.numClouds = Main.numCloudsTemp; + Main.windSpeedTemp = 0.72f; + Main.windSpeedSet = Main.windSpeedTemp; + Main.weatherCounter = 60 * 60 * 10; // 10 minutes of rain. Remember, once the rain goes away, so does the invasion. + Main.rainTime = Main.weatherCounter; + Main.maxRaining = 0.89f; + } + + // Summon Old Duke tornado post-Polter as needed + if (CalamityWorld.downedPolterghast && CalamityWorld.acidRainPoints == 1) + { + if (!NPC.AnyNPCs(ModContent.NPCType()) && + CalamityUtils.CountProjectiles(ModContent.ProjectileType()) <= 0) + { + if (CalamityWorld.triedToSummonOldDuke) + { + CalamityWorld.acidRainPoints = 0; + CalamityWorld.triedToSummonOldDuke = false; + UpdateInvasion(false); + } + else + { + int playerClosestToAbyss = Player.FindClosest(new Vector2(CalamityWorld.abyssSide ? 0 : Main.maxTilesX * 16, (int)Main.worldSurface), 0, 0); + Player closestToAbyss = Main.player[playerClosestToAbyss]; + if (Main.netMode != NetmodeID.MultiplayerClient && Math.Abs(closestToAbyss.Center.X - (CalamityWorld.abyssSide ? 0 : Main.maxTilesX * 16)) <= 12000f) + Projectile.NewProjectile(closestToAbyss.Center + Vector2.UnitY * 160f, Vector2.Zero, ModContent.ProjectileType(), 120, 8f, Main.myPlayer); + } + } + } + } + /// /// Updates the invasion, checking to see if it has ended. /// @@ -236,7 +331,56 @@ namespace CalamityMod.Events } } - internal static void OnEnemyKill(NPC npc) + public static void TryToStartEventNaturally() + { + // Attempt to start the acid rain at the 4:29AM. + // This does not happen if a player has the Broken Water Filter in use. + bool increasedEventChance = !CalamityWorld.downedEoCAcidRain || (!CalamityWorld.downedAquaticScourgeAcidRain && CalamityWorld.downedAquaticScourge) || (!CalamityWorld.downedBoomerDuke && CalamityWorld.downedPolterghast); + if (Main.time == 32399 && !Main.dayTime && Main.rand.NextBool(increasedEventChance ? 3 : 300)) + { + bool shouldNotStartEvent = false; + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + if (!Main.player[playerIndex].active) + continue; + if (Main.player[playerIndex].Calamity().noStupidNaturalARSpawns) + { + shouldNotStartEvent = true; + break; + } + } + if (!shouldNotStartEvent) + { + TryStartEvent(); + CalamityNetcode.SyncWorld(); + } + } + + // Attempt to force an Acid Rain immediately after the EoC is dead when someone wanders to the sea. + if (NPC.downedBoss1 && !CalamityWorld.downedEoCAcidRain && !CalamityWorld.forcedRainAlready) + { + for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) + { + if (Main.player[playerIndex].active && Main.player[playerIndex].Calamity().ZoneSulphur) + { + CalamityWorld.forcedRainAlready = true; + TryStartEvent(); + CalamityNetcode.SyncWorld(); + } + } + } + + if (CalamityWorld.forceRainTimer == 1) + { + TryStartEvent(); + CalamityNetcode.SyncWorld(); + } + + if (CalamityWorld.forceRainTimer > 0) + CalamityWorld.forceRainTimer--; + } + + public static void OnEnemyKill(NPC npc) { Dictionary possibleEnemies = PossibleEnemiesPreHM; diff --git a/Events/BossRushEvent.cs b/Events/BossRushEvent.cs index 01219088da..4cc0ba29ad 100644 --- a/Events/BossRushEvent.cs +++ b/Events/BossRushEvent.cs @@ -301,10 +301,25 @@ namespace CalamityMod.Events { if (!BossRushActive) return; + // Prevent Moon Lord from spawning naturally if (NPC.MoonLordCountdown > 0) - { NPC.MoonLordCountdown = 0; + + // Handle projectile clearing. + if (CalamityWorld.bossRushHostileProjKillCounter > 0) + { + CalamityWorld.bossRushHostileProjKillCounter--; + if (CalamityWorld.bossRushHostileProjKillCounter == 1) + CalamityUtils.KillAllHostileProjectiles(); + + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.BRHostileProjKillSync); + netMessage.Write(CalamityWorld.bossRushHostileProjKillCounter); + netMessage.Send(); + } } } @@ -352,13 +367,11 @@ namespace CalamityMod.Events // Change time as necessary. if (Bosses[BossRushStage].ToChangeTimeTo != TimeChangeContext.None) - CalamityWorld.ChangeTime(Bosses[BossRushStage].ToChangeTimeTo == TimeChangeContext.Day); + CalamityUtils.ChangeTime(Bosses[BossRushStage].ToChangeTimeTo == TimeChangeContext.Day); // Play the typical boss roar sound. if (!Bosses[BossRushStage].UsesSpecialSound) - { Main.PlaySound(SoundID.Roar, Main.player[ClosestPlayerToWorldCenter].position, 0); - } // And spawn the boss. Bosses[BossRushStage].SpawnContext.Invoke(CurrentlyFoughtBoss); @@ -406,6 +419,7 @@ namespace CalamityMod.Events netMessage.Send(); } } + #endregion #region On Boss Kill diff --git a/ExtraTextures/CalamitasCinder.png b/ExtraTextures/CalamitasCinder.png new file mode 100644 index 0000000000..191dd23b73 Binary files /dev/null and b/ExtraTextures/CalamitasCinder.png differ diff --git a/ExtraTextures/Lasers/AresDeathBeamEnd.png b/ExtraTextures/Lasers/AresDeathBeamEnd.png new file mode 100644 index 0000000000..9cbcb08262 Binary files /dev/null and b/ExtraTextures/Lasers/AresDeathBeamEnd.png differ diff --git a/ExtraTextures/Lasers/AresDeathBeamMiddle.png b/ExtraTextures/Lasers/AresDeathBeamMiddle.png new file mode 100644 index 0000000000..89d3b3e7f6 Binary files /dev/null and b/ExtraTextures/Lasers/AresDeathBeamMiddle.png differ diff --git a/ExtraTextures/Lasers/AresLaserBeamEnd.png b/ExtraTextures/Lasers/AresLaserBeamEnd.png new file mode 100644 index 0000000000..ced00be385 Binary files /dev/null and b/ExtraTextures/Lasers/AresLaserBeamEnd.png differ diff --git a/ExtraTextures/Lasers/AresLaserBeamMiddle.png b/ExtraTextures/Lasers/AresLaserBeamMiddle.png new file mode 100644 index 0000000000..f00c5f0c33 Binary files /dev/null and b/ExtraTextures/Lasers/AresLaserBeamMiddle.png differ diff --git a/ExtraTextures/VoidConcentrationAura.png b/ExtraTextures/VoidConcentrationAura.png new file mode 100644 index 0000000000..2b5d2fb66c Binary files /dev/null and b/ExtraTextures/VoidConcentrationAura.png differ diff --git a/Gores/Ares/AresArm_Gore1.png b/Gores/Ares/AresArm_Gore1.png new file mode 100644 index 0000000000..7aa6065a49 Binary files /dev/null and b/Gores/Ares/AresArm_Gore1.png differ diff --git a/Gores/Ares/AresArm_Gore2.png b/Gores/Ares/AresArm_Gore2.png new file mode 100644 index 0000000000..60a6c919de Binary files /dev/null and b/Gores/Ares/AresArm_Gore2.png differ diff --git a/Gores/Ares/AresArm_Gore3.png b/Gores/Ares/AresArm_Gore3.png new file mode 100644 index 0000000000..2fbe603cdc Binary files /dev/null and b/Gores/Ares/AresArm_Gore3.png differ diff --git a/Gores/Ares/AresBody1.png b/Gores/Ares/AresBody1.png new file mode 100644 index 0000000000..35c229b25e Binary files /dev/null and b/Gores/Ares/AresBody1.png differ diff --git a/Gores/Ares/AresBody2.png b/Gores/Ares/AresBody2.png new file mode 100644 index 0000000000..391c777385 Binary files /dev/null and b/Gores/Ares/AresBody2.png differ diff --git a/Gores/Ares/AresBody3.png b/Gores/Ares/AresBody3.png new file mode 100644 index 0000000000..03788a2d76 Binary files /dev/null and b/Gores/Ares/AresBody3.png differ diff --git a/Gores/Ares/AresBody4.png b/Gores/Ares/AresBody4.png new file mode 100644 index 0000000000..42f09bf434 Binary files /dev/null and b/Gores/Ares/AresBody4.png differ diff --git a/Gores/Ares/AresBody5.png b/Gores/Ares/AresBody5.png new file mode 100644 index 0000000000..e18eb5a29a Binary files /dev/null and b/Gores/Ares/AresBody5.png differ diff --git a/Gores/Ares/AresBody6.png b/Gores/Ares/AresBody6.png new file mode 100644 index 0000000000..f699679217 Binary files /dev/null and b/Gores/Ares/AresBody6.png differ diff --git a/Gores/Ares/AresBody7.png b/Gores/Ares/AresBody7.png new file mode 100644 index 0000000000..e9a8d20201 Binary files /dev/null and b/Gores/Ares/AresBody7.png differ diff --git a/Gores/Ares/AresGaussNuke1.png b/Gores/Ares/AresGaussNuke1.png new file mode 100644 index 0000000000..0a1bbb2327 Binary files /dev/null and b/Gores/Ares/AresGaussNuke1.png differ diff --git a/Gores/Ares/AresGaussNuke2.png b/Gores/Ares/AresGaussNuke2.png new file mode 100644 index 0000000000..9e45c93b48 Binary files /dev/null and b/Gores/Ares/AresGaussNuke2.png differ diff --git a/Gores/Ares/AresGaussNuke3.png b/Gores/Ares/AresGaussNuke3.png new file mode 100644 index 0000000000..7b2207d68e Binary files /dev/null and b/Gores/Ares/AresGaussNuke3.png differ diff --git a/Gores/Ares/AresHandBase1.png b/Gores/Ares/AresHandBase1.png new file mode 100644 index 0000000000..4000a1234c Binary files /dev/null and b/Gores/Ares/AresHandBase1.png differ diff --git a/Gores/Ares/AresHandBase2.png b/Gores/Ares/AresHandBase2.png new file mode 100644 index 0000000000..d1dcda125e Binary files /dev/null and b/Gores/Ares/AresHandBase2.png differ diff --git a/Gores/Ares/AresHandBase3.png b/Gores/Ares/AresHandBase3.png new file mode 100644 index 0000000000..4f111bc03e Binary files /dev/null and b/Gores/Ares/AresHandBase3.png differ diff --git a/Gores/Ares/AresLaserCannon1.png b/Gores/Ares/AresLaserCannon1.png new file mode 100644 index 0000000000..075c4fed61 Binary files /dev/null and b/Gores/Ares/AresLaserCannon1.png differ diff --git a/Gores/Ares/AresLaserCannon2.png b/Gores/Ares/AresLaserCannon2.png new file mode 100644 index 0000000000..e94d2e3bf0 Binary files /dev/null and b/Gores/Ares/AresLaserCannon2.png differ diff --git a/Gores/Ares/AresPlasmaFlamethrower1.png b/Gores/Ares/AresPlasmaFlamethrower1.png new file mode 100644 index 0000000000..ae954eedbb Binary files /dev/null and b/Gores/Ares/AresPlasmaFlamethrower1.png differ diff --git a/Gores/Ares/AresPlasmaFlamethrower2.png b/Gores/Ares/AresPlasmaFlamethrower2.png new file mode 100644 index 0000000000..1a4228a1d3 Binary files /dev/null and b/Gores/Ares/AresPlasmaFlamethrower2.png differ diff --git a/Gores/Ares/AresTeslaCannon1.png b/Gores/Ares/AresTeslaCannon1.png new file mode 100644 index 0000000000..e6b92d27da Binary files /dev/null and b/Gores/Ares/AresTeslaCannon1.png differ diff --git a/Gores/Ares/AresTeslaCannon2.png b/Gores/Ares/AresTeslaCannon2.png new file mode 100644 index 0000000000..9b54ff4391 Binary files /dev/null and b/Gores/Ares/AresTeslaCannon2.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker.png deleted file mode 100644 index 2754ddfc96..0000000000 Binary files a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker.png and /dev/null differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2.png deleted file mode 100644 index 5c18ad17c9..0000000000 Binary files a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2.png and /dev/null differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3.png deleted file mode 100644 index d6fbc15b0e..0000000000 Binary files a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3.png and /dev/null differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore1.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore1.png new file mode 100644 index 0000000000..4009972a78 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore1.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore2.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore2.png new file mode 100644 index 0000000000..52719a2fe3 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore2.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore3.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore3.png new file mode 100644 index 0000000000..60e920cd32 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore3.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore4.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore4.png new file mode 100644 index 0000000000..3e9bf7b6b2 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore4.png differ diff --git a/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore5.png b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore5.png new file mode 100644 index 0000000000..e7d3579972 Binary files /dev/null and b/Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore5.png differ diff --git a/Gores/SupremeCalamitas/BrimstoneHeart_Gore1.png b/Gores/SupremeCalamitas/BrimstoneHeart_Gore1.png new file mode 100644 index 0000000000..491063f204 Binary files /dev/null and b/Gores/SupremeCalamitas/BrimstoneHeart_Gore1.png differ diff --git a/Gores/SupremeCalamitas/BrimstoneHeart_Gore2.png b/Gores/SupremeCalamitas/BrimstoneHeart_Gore2.png new file mode 100644 index 0000000000..cb35235480 Binary files /dev/null and b/Gores/SupremeCalamitas/BrimstoneHeart_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherArm_Gore.png b/Gores/SupremeCalamitas/SepulcherArm_Gore.png new file mode 100644 index 0000000000..fb7678cb5e Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherArm_Gore.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore1.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore1.png new file mode 100644 index 0000000000..cc91d0b99b Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore2.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore2.png new file mode 100644 index 0000000000..8d735724fc Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore3.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore3.png new file mode 100644 index 0000000000..3f01d98028 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore3.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore4.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore4.png new file mode 100644 index 0000000000..75e2bb2043 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore4.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore5.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore5.png new file mode 100644 index 0000000000..206ff5884f Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore5.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore6.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore6.png new file mode 100644 index 0000000000..1503860b0e Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore6.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore7.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore7.png new file mode 100644 index 0000000000..7f91f058e8 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore7.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore8.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore8.png new file mode 100644 index 0000000000..08f213b100 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore8.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody1_Gore9.png b/Gores/SupremeCalamitas/SepulcherBody1_Gore9.png new file mode 100644 index 0000000000..5909b57a8f Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody1_Gore9.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore1.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore1.png new file mode 100644 index 0000000000..66ad61c1c4 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore2.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore2.png new file mode 100644 index 0000000000..a0afe9c2c6 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore3.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore3.png new file mode 100644 index 0000000000..c51e0c6e39 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore3.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore4.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore4.png new file mode 100644 index 0000000000..27c13b1f12 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore4.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore5.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore5.png new file mode 100644 index 0000000000..56369887b4 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore5.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore6.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore6.png new file mode 100644 index 0000000000..a558507804 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore6.png differ diff --git a/Gores/SupremeCalamitas/SepulcherBody2_Gore7.png b/Gores/SupremeCalamitas/SepulcherBody2_Gore7.png new file mode 100644 index 0000000000..840e976c65 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherBody2_Gore7.png differ diff --git a/Gores/SupremeCalamitas/SepulcherForearm_Gore1.png b/Gores/SupremeCalamitas/SepulcherForearm_Gore1.png new file mode 100644 index 0000000000..8aebfc14ea Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherForearm_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherForearm_Gore2.png b/Gores/SupremeCalamitas/SepulcherForearm_Gore2.png new file mode 100644 index 0000000000..6272a4257c Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherForearm_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHand_Gore1.png b/Gores/SupremeCalamitas/SepulcherHand_Gore1.png new file mode 100644 index 0000000000..1481801d09 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHand_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHand_Gore2.png b/Gores/SupremeCalamitas/SepulcherHand_Gore2.png new file mode 100644 index 0000000000..e0534c6502 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHand_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore1.png b/Gores/SupremeCalamitas/SepulcherHead_Gore1.png new file mode 100644 index 0000000000..955bb07c3e Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore2.png b/Gores/SupremeCalamitas/SepulcherHead_Gore2.png new file mode 100644 index 0000000000..9615453c81 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore2.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore3.png b/Gores/SupremeCalamitas/SepulcherHead_Gore3.png new file mode 100644 index 0000000000..52ada3c123 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore3.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore4.png b/Gores/SupremeCalamitas/SepulcherHead_Gore4.png new file mode 100644 index 0000000000..7b37e0a607 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore4.png differ diff --git a/Gores/SupremeCalamitas/SepulcherHead_Gore5.png b/Gores/SupremeCalamitas/SepulcherHead_Gore5.png new file mode 100644 index 0000000000..d8f20446d2 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherHead_Gore5.png differ diff --git a/Gores/SupremeCalamitas/SepulcherTail_Gore1.png b/Gores/SupremeCalamitas/SepulcherTail_Gore1.png new file mode 100644 index 0000000000..40ca1472d8 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherTail_Gore1.png differ diff --git a/Gores/SupremeCalamitas/SepulcherTail_Gore2.png b/Gores/SupremeCalamitas/SepulcherTail_Gore2.png new file mode 100644 index 0000000000..81a900a180 Binary files /dev/null and b/Gores/SupremeCalamitas/SepulcherTail_Gore2.png differ diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index b6f71e300f..a1759e54c6 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -107,218 +107,316 @@ namespace CalamityMod.ILEditing aLabDoorOpen = ModContent.TileType(); aLabDoorClosed = ModContent.TileType(); - ApplyLifeBytesChanges(); - AdjustChlorophyteBullets(); - RemoveAerialBaneDamageBoost(); - AdjustDamageVariance(); - RemoveExpertHardmodeScaling(); - IncreaseChlorophyteSpreadChance(); - ReduceTileBoostedRunSpeeds(); - ReduceWingHoverVelocities(); - RemoveRNGFromBlackBelt(); - ApplyBossZenDuringSlimeRain(); - PreventDungeonAbyssInteraction(); - BlockLivingTreesNearOcean(); - LabDoorFixes(); - AlterTownNPCSpawnRate(); - DisableDemonAltarGeneration(); - DisableTeleportersDuringBossFights(); - FixSplittingWormBannerDrops(); - IncorporateMinionExplodingCountdown(); - UseCoolFireCursorEffect(); - MakeMouseHoverItemsSupportAnimations(); - IncorporateEnchantmentInAffix(); + On.Terraria.Main.InitLifeBytes += BossRushLifeBytes; + IL.Terraria.Projectile.AI_001 += AdjustChlorophyteBullets; + IL.Terraria.Projectile.Damage += RemoveAerialBaneDamageBoost; + IL.Terraria.Main.DamageVar += AdjustDamageVariance; + IL.Terraria.NPC.scaleStats += RemoveExpertHardmodeScaling; + IL.Terraria.WorldGen.hardUpdateWorld += AdjustChlorophyteSpawnRate; + IL.Terraria.WorldGen.Chlorophyte += AdjustChlorophyteSpawnLimits; + IL.Terraria.Player.Update += ReduceTileBoostedRunSpeeds; + IL.Terraria.Player.Update += ReduceWingHoverVelocities; + IL.Terraria.Player.Hurt += RemoveRNGFromBlackBelt; + On.Terraria.NPC.SlimeRainSpawns += PreventBossSlimeRainSpawns; + IL.Terraria.WorldGen.MakeDungeon += PreventDungeonHorizontalCollisions; + IL.Terraria.WorldGen.DungeonHalls += PreventDungeonHallCollisions; + IL.Terraria.WorldGen.GrowLivingTree += BlockLivingTreesNearOcean; + IL.Terraria.NPC.NPCLoot += FixSplittingWormBannerDrops; + On.Terraria.WorldGen.OpenDoor += OpenDoor_LabDoorOverride; + On.Terraria.WorldGen.CloseDoor += CloseDoor_LabDoorOverride; + IL.Terraria.Main.UpdateTime += PermitNighttimeTownNPCSpawning; + On.Terraria.Main.UpdateTime_SpawnTownNPCs += AlterTownNPCSpawnRate; + On.Terraria.WorldGen.SmashAltar += PreventSmashAltarCode; + On.Terraria.Wiring.Teleport += DisableTeleporters; + On.Terraria.Projectile.NewProjectile_float_float_float_float_int_int_float_int_float_float += IncorporateMinionExplodingCountdown; + On.Terraria.Main.DrawCursor += UseCoolFireCursorEffect; + IL.Terraria.Main.DrawInterface_40_InteractItemIcon += MakeMouseHoverItemsSupportAnimations; + On.Terraria.Item.AffixName += IncorporateEnchantmentInAffix; } /// - /// Currently mostly useless, but clears static variables. + /// Unloads all IL Editing changes in the mod. /// internal static void Unload() { VanillaSpawnTownNPCs = null; labDoorOpen = labDoorClosed = aLabDoorOpen = aLabDoorClosed = -1; + + On.Terraria.Main.InitLifeBytes -= BossRushLifeBytes; + IL.Terraria.Projectile.AI_001 -= AdjustChlorophyteBullets; + IL.Terraria.Projectile.Damage -= RemoveAerialBaneDamageBoost; + IL.Terraria.Main.DamageVar -= AdjustDamageVariance; + IL.Terraria.NPC.scaleStats -= RemoveExpertHardmodeScaling; + IL.Terraria.WorldGen.hardUpdateWorld -= AdjustChlorophyteSpawnRate; + IL.Terraria.WorldGen.Chlorophyte -= AdjustChlorophyteSpawnLimits; + IL.Terraria.Player.Update -= ReduceTileBoostedRunSpeeds; + IL.Terraria.Player.Update -= ReduceWingHoverVelocities; + IL.Terraria.Player.Hurt -= RemoveRNGFromBlackBelt; + On.Terraria.NPC.SlimeRainSpawns -= PreventBossSlimeRainSpawns; + IL.Terraria.WorldGen.MakeDungeon -= PreventDungeonHorizontalCollisions; + IL.Terraria.WorldGen.DungeonHalls -= PreventDungeonHallCollisions; + IL.Terraria.WorldGen.GrowLivingTree -= BlockLivingTreesNearOcean; + IL.Terraria.NPC.NPCLoot -= FixSplittingWormBannerDrops; + On.Terraria.WorldGen.OpenDoor -= OpenDoor_LabDoorOverride; + On.Terraria.WorldGen.CloseDoor -= CloseDoor_LabDoorOverride; + IL.Terraria.Main.UpdateTime -= PermitNighttimeTownNPCSpawning; + On.Terraria.Main.UpdateTime_SpawnTownNPCs -= AlterTownNPCSpawnRate; + On.Terraria.WorldGen.SmashAltar -= PreventSmashAltarCode; + On.Terraria.Wiring.Teleport -= DisableTeleporters; + On.Terraria.Projectile.NewProjectile_float_float_float_float_int_int_float_int_float_float -= IncorporateMinionExplodingCountdown; + On.Terraria.Main.DrawCursor -= UseCoolFireCursorEffect; + IL.Terraria.Main.DrawInterface_40_InteractItemIcon -= MakeMouseHoverItemsSupportAnimations; + On.Terraria.Item.AffixName -= IncorporateEnchantmentInAffix; } #region IL Editing Routines - private static void ApplyLifeBytesChanges() => On.Terraria.Main.InitLifeBytes += BossRushLifeBytes; - private static void AdjustChlorophyteBullets() + private static void AdjustChlorophyteBullets(ILContext il) { - // Reduce dust from 10 to 5 and homing range. - IL.Terraria.Projectile.AI_001 += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(207)); // The ID of Chlorophyte Bullets. - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(10)); // The number of dust spawned by the bullet. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, 5); // Decrease dust to 5. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(300f)); // The 300 unit distance required to home in. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 150f); // Reduce homing range by 50%. - }; - } - - private static void RemoveAerialBaneDamageBoost() - { - IL.Terraria.Projectile.Damage += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(710)); // The ID of Aerial Bane projectiles. - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(1.5f)); // The damage multiplier. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 1f); // Multiplying by 1 means no damage bonus. - }; - } - - private static void AdjustDamageVariance() - { - // Change the damage variance from +-15% to +-5%. - IL.Terraria.Main.DamageVar += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(-15)); // The -15% lower bound of the variance. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, -5); // Increase to -5%. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(16)); // The +15% upper bound of the variance. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, 6); // Decrease to +5%. - }; - } - - private static void RemoveExpertHardmodeScaling() - { - // Completely disable the weak enemy scaling that occurs when Hardmode is active in Expert Mode. - IL.Terraria.NPC.scaleStats += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(1000)); // The less than 1000 HP check in order for the scaling to take place. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4_M1); // Replace the 1000 with -1, no NPC can have less than -1 HP on spawn, so it fails to run. - }; - } - - private static void IncreaseChlorophyteSpreadChance() - { - // Change the Chlorophyte spawn rate. - IL.Terraria.WorldGen.hardUpdateWorld += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(300)); // 1 in 300 genRand call used to generate Chlorophyte in mud tiles near jungle grass. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, 150); // Increase the chance to 1 in 150. - }; - - // Change the Chlorophyte spawn limits. - IL.Terraria.WorldGen.Chlorophyte += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(40)); // Find the 40 Chlorophyte tile limit. This limit is checked within a 71x71-tile square, with the reference tile as the center. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, 60); // Increase the limit to 60. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(130)); // Find the 130 Chlorophyte tile limit. This limit is checked within a 171x171-tile square, with the reference tile as the center. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4, 200); // Increase the limit to 200. - }; - } - - private static void ReduceTileBoostedRunSpeeds() - { - // Reduce the run speed boost while running on Asphalt, Frozen Slime Blocks and Ice Blocks. - IL.Terraria.Player.Update += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR8(1.6)); // Movement speed cap (removed in 1.4). - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R8, 3D); // Increase it to some higher amount. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(1.6f)); // Movement speed cap (removed in 1.4). - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 3f); // Increase it to some higher amount. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(3.5f)); // The max run speed multiplier for Asphalt. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 1.75f); // Reduce by 1.75. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f)); // The max run speed multiplier for Frozen Slime Blocks. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 1f); // Reduce boost to 0. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f)); // The max run speed multiplier for Ice Blocks. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 1f); // Reduce boost to 0. - }; - } - - private static void ReduceWingHoverVelocities() - { - // Reduce wing hover horizontal velocities. Hoverboard is fine because both stats are at 10. - IL.Terraria.Player.Update += (il) => - { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(6.25f)); // The accRunSpeed variable is set to this specific value before hover adjustments occur. - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(12f)); // The accRunSpeed for Vortex Booster and Nebula Mantle. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(12f)); // The runAcceleration for Vortex Booster and Nebula Mantle. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(12f)); // The accRunSpeed for Betsy Wings. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. - - cursor.GotoNext(MoveType.Before, i => i.MatchLdcR4(12f)); // The runAcceleration for Betsy Wings. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. - }; - } - - private static void RemoveRNGFromBlackBelt() - { - // Change the random chance of the Black Belt to 100%, but don't let it work if Calamity's cooldown is active. - IL.Terraria.Player.Hurt += (il) => + // Reduce dust from 10 to 5 and homing range. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(ProjectileID.ChlorophyteBullet))) { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(10)); // 1 in 10 Main.rand call for Black Belt activation. - cursor.Remove(); - cursor.Emit(OpCodes.Ldc_I4_1); // Replace with Main.rand.Next(1), aka 100% chance. + WriteFailToLog("chlorophyte bullet behavior", "Could not locate the bullet ID."); + return; + } + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(10))) // The number of dust spawned by the bullet. + { + WriteFailToLog("chlorophyte bullet behavior", "Could not locate the dust quantity."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4, 5); // Decrease dust to 5. - // Move forwards past the Main.rand.Next call now that it has been edited. - cursor.GotoNext(MoveType.After, i => i.MatchCallvirt("Next")); - - // Load the player itself onto the stack so that it becomes an argument for the following delegate. - cursor.Emit(OpCodes.Ldarg_0); - - // Emit a delegate which places the player's Calamity dodge cooldown onto the stack. - cursor.EmitDelegate>((Player p) => p.Calamity().dodgeCooldownTimer); - - // Bitwise OR the "RNG result" (always zero) with the dodge cooldown. This will only return zero if both values were zero. - // The code path which calls NinjaDodge can ONLY occur if the result of this operation is zero, - // because it is now the value checked by the immediately following branch-if-true. - cursor.Emit(OpCodes.Or); - - // Move forwards past the NinjaDodge call. We need to set the dodge cooldown here. - cursor.GotoNext(MoveType.After, i => i.MatchCall("NinjaDodge")); - - // Load the player itself onto the stack so that it becomes an argument for the following delegate. - cursor.Emit(OpCodes.Ldarg_0); - - // Emit a delegate which sets the player's Calamity dodge cooldown and sends a sync packet appropriately. - cursor.EmitDelegate>((Player p) => - { - CalamityPlayer calPlayer = p.Calamity(); - calPlayer.dodgeCooldownTimer = CalamityPlayer.BeltDodgeCooldown; - if (Main.netMode == NetmodeID.MultiplayerClient) - calPlayer.SyncDodgeCooldown(false); - }); - }; + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(300f))) // The 300 unit distance required to home in. + { + WriteFailToLog("chlorophyte bullet behavior", "Could not locate the homing range."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 150f); // Reduce homing range by 50%. } - private static void ApplyBossZenDuringSlimeRain() => On.Terraria.NPC.SlimeRainSpawns += PreventBossSlimeRainSpawns; + private static void RemoveAerialBaneDamageBoost(ILContext il) + { + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(ProjectileID.DD2BetsyArrow))) // The ID of Aerial Bane projectiles. + { + WriteFailToLog("aerial bane damage boost reduction", "Could not locate the arrow ID."); + return; + } + if (cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.5f))) // The damage multiplier. + { + WriteFailToLog("aerial bane damage boost reduction", "Could not locate the damage multiplier."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 1f); // Multiplying by 1 means no damage bonus. + } + + private static void AdjustDamageVariance(ILContext il) + { + // Change the damage variance from +-15% to +-5%. + var cursor = new ILCursor(il); + if (cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(-15))) // The -15% lower bound of the variance. + { + WriteFailToLog("general damage variance reduction", "Could not locate the lower bound."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4, -5); // Increase to -5%. + + if (cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(16))) // The 15% upper bound of the variance. + { + WriteFailToLog("general damage variance reduction", "Could not locate the upper bound."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4, 6); // Decrease to +5%. + } + + private static void RemoveExpertHardmodeScaling(ILContext il) + { + // Completely disable the weak enemy scaling that occurs when Hardmode is active in Expert Mode. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(1000))) // The less than 1000 HP check in order for the scaling to take place. + { + WriteFailToLog("expert hardmode scaling removal", "Could not locate the HP check."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4_M1); // Replace the 1000 with -1, no NPC can have less than -1 HP on spawn, so it fails to run. + } + + private static void AdjustChlorophyteSpawnRate(ILContext il) + { + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(300))) // 1 in 300 genRand call used to generate Chlorophyte in mud tiles near jungle grass. + { + WriteFailToLog("chlorophyte spread rate adjustment", "Could not locate the update chance."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4, 150); // Increase the chance to 1 in 150. + } + + private static void AdjustChlorophyteSpawnLimits(ILContext il) + { + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(40))) // Find the 40 Chlorophyte tile limit. This limit is checked within a 71x71-tile square, with the reference tile as the center. + { + WriteFailToLog("chlorophyte spread limit adjustment", "Could not locate the lower limit."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4, 60); // Increase the limit to 60. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(130))) // Find the 130 Chlorophyte tile limit. This limit is checked within a 171x171-tile square, with the reference tile as the center. + { + WriteFailToLog("chlorophyte spread limit adjustment", "Could not locate the upper limit."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4, 200); // Increase the limit to 200. + } + + private static void ReduceTileBoostedRunSpeeds(ILContext il) + { + // Reduce the run speed boost while running on Asphalt, Frozen Slime Blocks and Ice Blocks. + + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR8(1.6))) // Movement speed cap (removed in 1.4). + { + WriteFailToLog("run speed adjustment", "Could not locate the movement speed limit."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R8, 3D); // Increase it to some higher amount. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR8(1.6f))) // Movement speed cap (removed in 1.4). + { + WriteFailToLog("run speed adjustment", "Could not locate the movement speed limit."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 3f); // Increase it to some higher amount. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(3.5f))) // The max run speed multiplier for Asphalt. + { + WriteFailToLog("run speed adjustment", "Could not locate the asphalt movement speed limit."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 1.75f); // Reduce by 1.75. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f))) // The max run speed multiplier for Frozen Slime Blocks. + { + WriteFailToLog("run speed adjustment", "Could not locate the frozen slime block movement speed limit."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 1f); // Reduce boost to 0. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(1.25f))) // The max run speed multiplier for Ice Blocks. + { + WriteFailToLog("run speed adjustment", "Could not locate the ice block movement speed limit."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 1f); // Reduce boost to 0. + } + + private static void ReduceWingHoverVelocities(ILContext il) + { + // Reduce wing hover horizontal velocities. Hoverboard is fine because both stats are at 10. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(6.25f))) // The accRunSpeed variable is set to this specific value before hover adjustments occur. + { + WriteFailToLog("wing hover speed reduction", "Could not locate the base speed variable."); + return; + } + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(12f))) // The accRunSpeed for Vortex Booster and Nebula Mantle. + { + WriteFailToLog("wing hover speed reduction", "Could not locate the vortex booster/nebula mantle speed variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(12f))) // The runAcceleration for Vortex Booster and Nebula Mantle. + { + WriteFailToLog("wing hover speed reduction", "Could not locate the vortex booster/nebula mantle speed variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(12f))) // The accRunSpeed for Betsy Wings. + { + WriteFailToLog("wing hover speed reduction", "Could not locate the betsy's wings speed variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(12f))) // The runAcceleration for Betsy Wings. + { + WriteFailToLog("wing hover speed reduction", "Could not locate the betsy's wings speed variable."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_R4, 10.8f); // Reduce by 10%. + } + + private static void RemoveRNGFromBlackBelt(ILContext il) + { + // Change the random chance of the Black Belt to 100%, but don't let it work if Calamity's cooldown is active. + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(10))) // 1 in 10 Main.rand call for Black Belt activation. + { + WriteFailToLog("black belt dodge guarantee", "Could not locate the dodge chance."); + return; + } + cursor.Remove(); + cursor.Emit(OpCodes.Ldc_I4_1); // Replace with Main.rand.Next(1), aka 100% chance. + + // Move forwards past the Main.rand.Next call now that it has been edited. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCallvirt("Next"))) + { + WriteFailToLog("black belt dodge guarantee", "Could not locate the Random.Next call."); + return; + } + + // Load the player itself onto the stack so that it becomes an argument for the following delegate. + cursor.Emit(OpCodes.Ldarg_0); + + // Emit a delegate which places the player's Calamity dodge cooldown onto the stack. + cursor.EmitDelegate>((Player p) => p.Calamity().dodgeCooldownTimer); + + // Bitwise OR the "RNG result" (always zero) with the dodge cooldown. This will only return zero if both values were zero. + // The code path which calls NinjaDodge can ONLY occur if the result of this operation is zero, + // because it is now the value checked by the immediately following branch-if-true. + cursor.Emit(OpCodes.Or); + + // Move forwards past the NinjaDodge call. We need to set the dodge cooldown here. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall("NinjaDodge"))) + { + WriteFailToLog("black belt dodge guarantee", "Could not locate the Player.NinjaDodge call."); + return; + } + + // Load the player itself onto the stack so that it becomes an argument for the following delegate. + cursor.Emit(OpCodes.Ldarg_0); + + // Emit a delegate which sets the player's Calamity dodge cooldown and sends a sync packet appropriately. + cursor.EmitDelegate>((Player p) => + { + CalamityPlayer calPlayer = p.Calamity(); + calPlayer.dodgeCooldownTimer = CalamityPlayer.BeltDodgeCooldown; + if (Main.netMode == NetmodeID.MultiplayerClient) + calPlayer.SyncDodgeCooldown(false); + }); + } private static void ReplacePharaohSetInPyramids() { @@ -326,191 +424,179 @@ namespace CalamityMod.ILEditing IL.Terraria.NPC.scaleStats += (il) => { var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(848)); // The ID of the Pharaoh's Mask. + cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(848)); // The ID of the Pharaoh's Mask. cursor.Remove(); cursor.Emit(OpCodes.Ldc_I4, 1240); // Replace the Mask with a Ruby Hook, in 1.4 I will replace this with an Amber Hook so it makes more sense. // Note: There is no need to replace the other Pharaoh piece, due to how the vanilla code works. }; } - private static void PreventDungeonAbyssInteraction() + private static void PreventDungeonHallCollisions(ILContext il) + { + // Prevent the Dungeon's halls from getting anywhere near the Abyss. + var cursor = new ILCursor(il); + + // Forcefully clamp the X position of the new hall end. + // This prevents a hall, and as a result, the dungeon, from ever impeding on the Abyss/Sulph Sea. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(6))) + { + WriteFailToLog("dungeon hall abyss collision fix", "Could not locate the hall horizontal position."); + return; + } + + cursor.Emit(OpCodes.Ldloc, 6); + cursor.EmitDelegate>(unclampedValue => + { + unclampedValue.X = MathHelper.Clamp(unclampedValue.X, SulphurousSea.BiomeWidth + 25, Main.maxTilesX - SulphurousSea.BiomeWidth - 25); + return unclampedValue; + }); + cursor.Emit(OpCodes.Stloc, 6); + } + + private static void PreventDungeonHorizontalCollisions(ILContext il) { // Prevent the Dungeon from appearing near the Sulph sea. - IL.Terraria.WorldGen.MakeDungeon += il => + var cursor = new ILCursor(il); + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStsfld("dungeonY"))) { - var cursor = new ILCursor(il); - cursor.GotoNext(MoveType.After, i => i.MatchStsfld("dungeonY")); + WriteFailToLog("dungeon hall abyss collision fix", "Could not locate the dungeon's vertical position."); + return; + } - cursor.EmitDelegate(() => - { - WorldGen.dungeonX = Utils.Clamp(WorldGen.dungeonX, SulphurousSea.BiomeWidth + 100, Main.maxTilesX - SulphurousSea.BiomeWidth - 100); - - // Adjust the Y position of the dungeon to accomodate for the X shift. - WorldUtils.Find(new Point(WorldGen.dungeonX, WorldGen.dungeonY), Searches.Chain(new Searches.Down(9001), new Conditions.IsSolid()), out Point result); - WorldGen.dungeonY = result.Y - 10; - }); - }; - - // And prevent its halls from getting anywhere near the Abyss. - IL.Terraria.WorldGen.DungeonHalls += il => + cursor.EmitDelegate(() => { - var cursor = new ILCursor(il); + WorldGen.dungeonX = Utils.Clamp(WorldGen.dungeonX, SulphurousSea.BiomeWidth + 100, Main.maxTilesX - SulphurousSea.BiomeWidth - 100); - // Forcefully clamp the X position of the new hall end. - // This prevents a hall, and as a result, the dungeon, from ever impeding on the Abyss/Sulph Sea. - cursor.GotoNext(MoveType.After, i => i.MatchStloc(6)); - - cursor.Emit(OpCodes.Ldloc, 6); - cursor.EmitDelegate>(unclampedValue => - { - unclampedValue.X = MathHelper.Clamp(unclampedValue.X, SulphurousSea.BiomeWidth + 25, Main.maxTilesX - SulphurousSea.BiomeWidth - 25); - return unclampedValue; - }); - cursor.Emit(OpCodes.Stloc, 6); - }; + // Adjust the Y position of the dungeon to accomodate for the X shift. + WorldUtils.Find(new Point(WorldGen.dungeonX, WorldGen.dungeonY), Searches.Chain(new Searches.Down(9001), new Conditions.IsSolid()), out Point result); + WorldGen.dungeonY = result.Y - 10; + }); } - private static void BlockLivingTreesNearOcean() + private static void BlockLivingTreesNearOcean(ILContext il) { - IL.Terraria.WorldGen.GrowLivingTree += (il) => - { - var cursor = new ILCursor(il); - cursor.Emit(OpCodes.Ldarg_0); - cursor.EmitDelegate>(x => Utils.Clamp(x, 560, Main.maxTilesX - 560)); - cursor.Emit(OpCodes.Starg, 0); - }; + var cursor = new ILCursor(il); + cursor.Emit(OpCodes.Ldarg_0); + cursor.EmitDelegate>(x => Utils.Clamp(x, 560, Main.maxTilesX - 560)); + cursor.Emit(OpCodes.Starg, 0); } - private static void LabDoorFixes() + private static void PermitNighttimeTownNPCSpawning(ILContext il) { - On.Terraria.WorldGen.OpenDoor += OpenDoor_LabDoorOverride; - On.Terraria.WorldGen.CloseDoor += CloseDoor_LabDoorOverride; + // Don't do town NPC spawning at the end (which lies after a !Main.dayTime return). + // Do it at the beginning, without the arbitrary time restriction. + var cursor = new ILCursor(il); + cursor.EmitDelegate(() => + { + // A cached delegate is used here instead of direct reflection for performance reasons + // since UpdateTime is called every frame. + if (Main.dayTime || CalamityConfig.Instance.CanTownNPCsSpawnAtNight) + VanillaSpawnTownNPCs(); + }); + + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt
("UpdateTime_SpawnTownNPCs"))) + { + CalamityMod.Instance.Logger.Warn("Town NPC spawn editing code failed."); + return; + } + + cursor.Emit(OpCodes.Ret); } - private static void AlterTownNPCSpawnRate() + private static void AlterTownNPCSpawnRate(On.Terraria.Main.orig_UpdateTime_SpawnTownNPCs orig) { - IL.Terraria.Main.UpdateTime += (il) => - { - // Don't do town NPC spawning at the end (after a !Main.dayTime return). - // Do it at the beginning in spite of time. - - var cursor = new ILCursor(il); - cursor.EmitDelegate(() => - { - // A cached delegate is used here instead of direct reflection for performance reasons - // since UpdateTime is called every frame. - if (Main.dayTime || CalamityConfig.Instance.CanTownNPCsSpawnAtNight) - VanillaSpawnTownNPCs(); - }); - - if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt
("UpdateTime_SpawnTownNPCs"))) - { - CalamityMod.Instance.Logger.Warn("Town NPC spawn editing code failed."); - return; - } - - cursor.Emit(OpCodes.Ret); - }; - - On.Terraria.Main.UpdateTime_SpawnTownNPCs += (orig) => - { - int oldWorldRate = Main.worldRate; - Main.worldRate *= CalamityConfig.Instance.TownNPCSpawnRateMultiplier; - orig(); - Main.worldRate = oldWorldRate; - }; + int oldWorldRate = Main.worldRate; + Main.worldRate *= CalamityConfig.Instance.TownNPCSpawnRateMultiplier; + orig(); + Main.worldRate = oldWorldRate; } - private static void DisableDemonAltarGeneration() => On.Terraria.WorldGen.SmashAltar += PreventSmashAltarCode; - - private static void DisableTeleportersDuringBossFights() => On.Terraria.Wiring.Teleport += DisableTeleporters; - - private static void FixSplittingWormBannerDrops() + private static void FixSplittingWormBannerDrops(ILContext il) { - IL.Terraria.NPC.NPCLoot += (il) => + var cursor = new ILCursor(il); + + // Locate the area after all the banner logic by using a nearby constant type. + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(23))) { - var cursor = new ILCursor(il); + WriteFailToLog("splitting worm banner spam fix", "Could not locate the first hooking constant."); + return; + } + if (!cursor.TryGotoPrev(MoveType.Before, i => i.MatchLdarg(0))) + { + WriteFailToLog("splitting worm banner spam fix", "Could not locate the second hooking constant."); + return; + } - // Locate the area after all the banner logic by using a nearby constant type. - cursor.GotoNext(MoveType.Before, i => i.MatchLdcI4(23)); - cursor.GotoPrev(MoveType.Before, i => i.MatchLdarg(0)); + ILLabel afterBannerLogic = cursor.DefineLabel(); - ILLabel afterBannerLogic = cursor.DefineLabel(); + // Set this area after as a place to return to later. + cursor.MarkLabel(afterBannerLogic); - // Set this area after as a place to return to later. - cursor.MarkLabel(afterBannerLogic); + // Go to the beginning of the banner drop logic. + cursor.Goto(0); + if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdsfld("killCount"))) + { + WriteFailToLog("splitting worm banner spam fix", "Could not locate the NPC kill count."); + return; + } - // Go to the beginning of the banner drop logic. - cursor.Goto(0); - cursor.GotoNext(MoveType.Before, i => i.MatchLdsfld("killCount")); + // Load the NPC caller onto the stack. + cursor.Emit(OpCodes.Ldarg_0); + cursor.EmitDelegate>(npc => CalamityGlobalNPCLoot.SplittingWormLootBlockWrapper(npc, CalamityMod.Instance)); - // Load the NPC caller onto the stack. - cursor.Emit(OpCodes.Ldarg_0); - cursor.EmitDelegate>(npc => CalamityGlobalNPCLoot.SplittingWormLootBlockWrapper(npc, CalamityMod.Instance)); - - // Emit 0 (false) onto the stack. - cursor.Emit(OpCodes.Ldc_I4_0); - - // If the block is equal to false (indicating the drop logic should stop), skip all the ahead banner drop logic. - cursor.Emit(OpCodes.Beq, afterBannerLogic); - }; + // If the block is false (indicating the drop logic should stop), skip all the ahead banner drop logic. + cursor.Emit(OpCodes.Brfalse, afterBannerLogic); } - private static void IncorporateMinionExplodingCountdown() - { - On.Terraria.Projectile.NewProjectile_float_float_float_float_int_int_float_int_float_float += (orig, x, y, xSpeed, ySpeed, type, damage, knockback, owner, ai0, ai1) => - { - // This is unfortunately not something that can be done via SetDefaults since owner is set - // after that method is called. Doing it directly when the projectile is spawned appears to be the only reasonable way. - int proj = orig(x, y, xSpeed, ySpeed, type, damage, knockback, owner, ai0, ai1); - Projectile projectile = Main.projectile[proj]; - if (projectile.minion) - { - Player player = Main.player[projectile.owner]; - CalamityPlayerMiscEffects.EnchantHeldItemEffects(player, player.Calamity(), player.ActiveItem()); - if (player.Calamity().explosiveMinionsEnchant) - projectile.Calamity().ExplosiveEnchantCountdown = CalamityGlobalProjectile.ExplosiveEnchantTime; - } - return proj; - }; - } - - private static void MakeMouseHoverItemsSupportAnimations() + private static int IncorporateMinionExplodingCountdown(On.Terraria.Projectile.orig_NewProjectile_float_float_float_float_int_int_float_int_float_float orig, float x, float y, float xSpeed, float ySpeed, int type, int damage, float knockback, int owner, float ai0, float ai1) { - IL.Terraria.Main.DrawInterface_40_InteractItemIcon += (il) => + // This is unfortunately not something that can be done via SetDefaults since owner is set + // after that method is called. Doing it directly when the projectile is spawned appears to be the only reasonable way. + int proj = orig(x, y, xSpeed, ySpeed, type, damage, knockback, owner, ai0, ai1); + Projectile projectile = Main.projectile[proj]; + if (projectile.minion) { - var cursor = new ILCursor(il); - - // Locate the location where the frame rectangle is created. - if (!cursor.TryGotoNext(MoveType.After, i => i.MatchNewobj())) - return; - - int endIndex = cursor.Index; - - // And then go back to where it began, right after the draw position vector. - if (!cursor.TryGotoPrev(MoveType.After, i => i.MatchNewobj())) - return; - - // And delete the range that creates the rectangle with intent to replace it. - cursor.RemoveRange(Math.Abs(endIndex - cursor.Index)); - - cursor.Emit(OpCodes.Ldloc_0); - cursor.EmitDelegate>(itemType => - { - return Main.itemAnimations[itemType]?.GetFrame(Main.itemTexture[itemType]) ?? null; - }); - }; + Player player = Main.player[projectile.owner]; + CalamityPlayerMiscEffects.EnchantHeldItemEffects(player, player.Calamity(), player.ActiveItem()); + if (player.Calamity().explosiveMinionsEnchant) + projectile.Calamity().ExplosiveEnchantCountdown = CalamityGlobalProjectile.ExplosiveEnchantTime; + } + return proj; } - private static void IncorporateEnchantmentInAffix() + private static void MakeMouseHoverItemsSupportAnimations(ILContext il) { - On.Terraria.Item.AffixName += (orig, self) => + var cursor = new ILCursor(il); + + // Locate the location where the frame rectangle is created. + if (!cursor.TryGotoNext(MoveType.After, i => i.MatchNewobj())) + return; + + int endIndex = cursor.Index; + + // And then go back to where it began, right after the draw position vector. + if (!cursor.TryGotoPrev(MoveType.After, i => i.MatchNewobj())) { - string result = orig(self); - if (!self.IsAir && self.Calamity().AppliedEnchantment.HasValue) - result = $"{self.Calamity().AppliedEnchantment.Value.Name} {result}"; - return result; - }; + WriteFailToLog("hover item animation support", "Could not locate the creation of the draw position vector."); + return; + } + + // And delete the range that creates the rectangle with intent to replace it. + cursor.RemoveRange(Math.Abs(endIndex - cursor.Index)); + + cursor.Emit(OpCodes.Ldloc_0); + cursor.EmitDelegate>(itemType => + { + return Main.itemAnimations[itemType]?.GetFrame(Main.itemTexture[itemType]) ?? null; + }); + } + + private static string IncorporateEnchantmentInAffix(On.Terraria.Item.orig_AffixName orig, Item self) + { + string result = orig(self); + if (!self.IsAir && self.Calamity().AppliedEnchantment.HasValue) + result = $"{self.Calamity().AppliedEnchantment.Value.Name} {result}"; + return result; } #endregion @@ -563,101 +649,98 @@ namespace CalamityMod.ILEditing return orig(i, j, forced); } - private static void UseCoolFireCursorEffect() + private static void UseCoolFireCursorEffect(On.Terraria.Main.orig_DrawCursor orig, Vector2 bonus, bool smart) { - On.Terraria.Main.DrawCursor += (orig, bonus, smart) => + // Do nothing special if the player has a regular mouse or is on the menu. + if (Main.gameMenu || !Main.LocalPlayer.Calamity().ableToDrawBlazingMouse) { - // Do nothing special if the player has a regular mouse or is on the menu. - if (Main.gameMenu || !Main.LocalPlayer.Calamity().ableToDrawBlazingMouse) + orig(bonus, smart); + return; + } + + if (Main.LocalPlayer.dead) + { + Main.SmartInteractShowingGenuine = false; + Main.SmartInteractShowingFake = false; + Main.SmartInteractNPC = -1; + Main.SmartInteractNPCsNearby.Clear(); + Main.SmartInteractTileCoords.Clear(); + Main.SmartInteractTileCoordsSelected.Clear(); + Main.TileInteractionLX = (Main.TileInteractionHX = (Main.TileInteractionLY = (Main.TileInteractionHY = -1))); + } + + Color flameColor = Color.Lerp(Color.DarkRed, Color.OrangeRed, (float)Math.Cos(Main.GlobalTime * 7.4f) * 0.5f + 0.5f); + Color cursorColor = flameColor * 1.9f; + Vector2 baseDrawPosition = Main.MouseScreen + bonus; + + // Draw the mouse as usual if the player isn't using the gamepad. + if (!PlayerInput.UsingGamepad) + { + int cursorIndex = smart.ToInt(); + + Color desaturatedCursorColor = cursorColor; + desaturatedCursorColor.R /= 5; + desaturatedCursorColor.G /= 5; + desaturatedCursorColor.B /= 5; + desaturatedCursorColor.A /= 2; + + Vector2 drawPosition = baseDrawPosition; + Vector2 desaturatedDrawPosition = drawPosition + Vector2.One; + + // If the blazing mouse is actually going to do damage, draw an indicator aura. + if (Main.LocalPlayer.Calamity().blazingMouseDamageEffects && !Main.mapFullscreen) { - orig(bonus, smart); - return; - } + Texture2D auraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/CalamityAura"); + Rectangle auraFrame = auraTexture.Frame(1, 6, 0, (int)(Main.GlobalTime * 12.3f) % 6); + float auraScale = MathHelper.Lerp(0.95f, 1f, (float)Math.Sin(Main.GlobalTime * 1.1f) * 0.5f + 0.5f); - if (Main.LocalPlayer.dead) - { - Main.SmartInteractShowingGenuine = false; - Main.SmartInteractShowingFake = false; - Main.SmartInteractNPC = -1; - Main.SmartInteractNPCsNearby.Clear(); - Main.SmartInteractTileCoords.Clear(); - Main.SmartInteractTileCoordsSelected.Clear(); - Main.TileInteractionLX = (Main.TileInteractionHX = (Main.TileInteractionLY = (Main.TileInteractionHY = -1))); - } - - Color flameColor = Color.Lerp(Color.DarkRed, Color.OrangeRed, (float)Math.Cos(Main.GlobalTime * 7.4f) * 0.5f + 0.5f); - Color cursorColor = flameColor * 1.9f; - Vector2 baseDrawPosition = Main.MouseScreen + bonus; - - // Draw the mouse as usual if the player isn't using the gamepad. - if (!PlayerInput.UsingGamepad) - { - int cursorIndex = smart.ToInt(); - - Color desaturatedCursorColor = cursorColor; - desaturatedCursorColor.R /= 5; - desaturatedCursorColor.G /= 5; - desaturatedCursorColor.B /= 5; - desaturatedCursorColor.A /= 2; - - Vector2 drawPosition = baseDrawPosition; - Vector2 desaturatedDrawPosition = drawPosition + Vector2.One; - - // If the blazing mouse is actually going to do damage, draw an indicator aura. - if (Main.LocalPlayer.Calamity().blazingMouseDamageEffects && !Main.mapFullscreen) + for (int i = 0; i < 12; i++) { - Texture2D auraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/CalamityAura"); - Rectangle auraFrame = auraTexture.Frame(1, 6, 0, (int)(Main.GlobalTime * 12.3f) % 6); - float auraScale = MathHelper.Lerp(0.95f, 1f, (float)Math.Sin(Main.GlobalTime * 1.1f) * 0.5f + 0.5f); + Color auraColor = Color.Orange * Main.LocalPlayer.Calamity().blazingMouseAuraFade * 0.125f; + auraColor.A = 0; + Vector2 offsetDrawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 12f + Main.GlobalTime * 5f).ToRotationVector2() * 2.5f; + offsetDrawPosition.Y -= 18f; - for (int i = 0; i < 12; i++) - { - Color auraColor = Color.Orange * Main.LocalPlayer.Calamity().blazingMouseAuraFade * 0.125f; - auraColor.A = 0; - Vector2 offsetDrawPosition = baseDrawPosition + (MathHelper.TwoPi * i / 12f + Main.GlobalTime * 5f).ToRotationVector2() * 2.5f; - offsetDrawPosition.Y -= 18f; - - Main.spriteBatch.Draw(auraTexture, offsetDrawPosition, auraFrame, auraColor, 0f, auraFrame.Size() * 0.5f, Main.cursorScale * auraScale, SpriteEffects.None, 0f); - } + Main.spriteBatch.Draw(auraTexture, offsetDrawPosition, auraFrame, auraColor, 0f, auraFrame.Size() * 0.5f, Main.cursorScale * auraScale, SpriteEffects.None, 0f); } - - Main.spriteBatch.Draw(Main.cursorTextures[cursorIndex], drawPosition, null, desaturatedCursorColor, 0f, Vector2.Zero, Main.cursorScale, SpriteEffects.None, 0f); - - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.UIScaleMatrix); - GameShaders.Misc["CalamityMod:FireMouse"].UseColor(Color.Red); - GameShaders.Misc["CalamityMod:FireMouse"].UseSecondaryColor(Color.Lerp(Color.Red, Color.Orange, 0.75f)); - GameShaders.Misc["CalamityMod:FireMouse"].Apply(); - - Main.spriteBatch.Draw(Main.cursorTextures[cursorIndex], desaturatedDrawPosition, null, cursorColor, 0f, Vector2.Zero, Main.cursorScale * 1.075f, SpriteEffects.None, 0f); - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); - return; } - // Don't bother doing any more drawing if the player is dead. - if (Main.LocalPlayer.dead && !Main.LocalPlayer.ghost && !Main.gameMenu) - return; + Main.spriteBatch.Draw(Main.cursorTextures[cursorIndex], drawPosition, null, desaturatedCursorColor, 0f, Vector2.Zero, Main.cursorScale, SpriteEffects.None, 0f); - if (PlayerInput.InvisibleGamepadInMenus) - return; + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.UIScaleMatrix); + GameShaders.Misc["CalamityMod:FireMouse"].UseColor(Color.Red); + GameShaders.Misc["CalamityMod:FireMouse"].UseSecondaryColor(Color.Lerp(Color.Red, Color.Orange, 0.75f)); + GameShaders.Misc["CalamityMod:FireMouse"].Apply(); - // Draw a white circle instead if using the smart cursor. - if (smart && !(UILinkPointNavigator.Available && !PlayerInput.InBuildingMode)) - { - cursorColor = Color.White * Main.GamepadCursorAlpha; - int frameX = 0; - Texture2D smartCursorTexture = Main.cursorTextures[13]; - Rectangle frame = smartCursorTexture.Frame(2, 1, frameX, 0); - Main.spriteBatch.Draw(smartCursorTexture, baseDrawPosition, frame, cursorColor, 0f, frame.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); - return; - } + Main.spriteBatch.Draw(Main.cursorTextures[cursorIndex], desaturatedDrawPosition, null, cursorColor, 0f, Vector2.Zero, Main.cursorScale * 1.075f, SpriteEffects.None, 0f); + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix); + return; + } - // Otherwise draw an ordinary crosshair at the mouse position. - cursorColor = Color.White; - Texture2D crosshairTexture = Main.cursorTextures[15]; - Main.spriteBatch.Draw(crosshairTexture, baseDrawPosition, null, cursorColor, 0f, crosshairTexture.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); - }; + // Don't bother doing any more drawing if the player is dead. + if (Main.LocalPlayer.dead && !Main.LocalPlayer.ghost && !Main.gameMenu) + return; + + if (PlayerInput.InvisibleGamepadInMenus) + return; + + // Draw a white circle instead if using the smart cursor. + if (smart && !(UILinkPointNavigator.Available && !PlayerInput.InBuildingMode)) + { + cursorColor = Color.White * Main.GamepadCursorAlpha; + int frameX = 0; + Texture2D smartCursorTexture = Main.cursorTextures[13]; + Rectangle frame = smartCursorTexture.Frame(2, 1, frameX, 0); + Main.spriteBatch.Draw(smartCursorTexture, baseDrawPosition, frame, cursorColor, 0f, frame.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); + return; + } + + // Otherwise draw an ordinary crosshair at the mouse position. + cursorColor = Color.White; + Texture2D crosshairTexture = Main.cursorTextures[15]; + Main.spriteBatch.Draw(crosshairTexture, baseDrawPosition, null, cursorColor, 0f, crosshairTexture.Size() * 0.5f, Main.cursorScale, SpriteEffects.None, 0f); } private static void PreventSmashAltarCode(On.Terraria.WorldGen.orig_SmashAltar orig, int i, int j) @@ -727,6 +810,8 @@ namespace CalamityMod.ILEditing Main.PlaySound(SoundID.DoorClosed, doorX * 16, doorY * 16); return true; } + + public static void WriteFailToLog(string editName, string reason) => CalamityMod.Instance.Logger.Warn($"The {editName} IL edit failed. {reason}"); #endregion } } diff --git a/Items/Accessories/Abaddon.cs b/Items/Accessories/Abaddon.cs index 1aa69484d0..a5c896c7df 100644 --- a/Items/Accessories/Abaddon.cs +++ b/Items/Accessories/Abaddon.cs @@ -1,7 +1,7 @@ -using CalamityMod.Buffs.DamageOverTime; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Items.Accessories { [AutoloadEquip(EquipType.Face)] @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Abaddon"); - Tooltip.SetDefault("Reduces the damage caused by the Brimstone Flames debuff"); + Tooltip.SetDefault("Reduces the damage caused by the Brimstone Flames debuff and provides immunity to Searing Lava"); } public override void SetDefaults() @@ -22,9 +22,6 @@ namespace CalamityMod.Items.Accessories item.accessory = true; } - public override void UpdateAccessory(Player player, bool hideVisual) - { - player.Calamity().abaddon = true; - } + public override void UpdateAccessory(Player player, bool hideVisual) => player.Calamity().abaddon = true; } } diff --git a/Items/Accessories/AbyssalAmulet.cs b/Items/Accessories/AbyssalAmulet.cs index 2cd5d0c4d6..90c3a62cff 100644 --- a/Items/Accessories/AbyssalAmulet.cs +++ b/Items/Accessories/AbyssalAmulet.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using Terraria; using Terraria.ModLoader; @@ -12,6 +13,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Abyssal Amulet"); Tooltip.SetDefault("Attacks inflict the Crush Depth debuff\n" + + "Grants immunity to the Crush Depth debuff\n" + "While in the abyss you gain 10% increased max life"); } @@ -28,6 +30,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.abyssalAmulet = true; - } + player.buffImmune[ModContent.BuffType()] = true; + } } } diff --git a/Items/Accessories/AsgardianAegis.cs b/Items/Accessories/AsgardianAegis.cs index c7002d826b..dd4bb6d019 100644 --- a/Items/Accessories/AsgardianAegis.cs +++ b/Items/Accessories/AsgardianAegis.cs @@ -51,6 +51,7 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.dashMod = 4; modPlayer.elysianAegis = true; + modPlayer.abaddon = true; player.noKnockback = true; player.fireWalk = true; player.statLifeMax2 += 40; diff --git a/Items/Accessories/LumenousAmulet.cs b/Items/Accessories/LumenousAmulet.cs index 4f38ddd242..99ab153d64 100644 --- a/Items/Accessories/LumenousAmulet.cs +++ b/Items/Accessories/LumenousAmulet.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; @@ -14,6 +15,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Lumenous Amulet"); Tooltip.SetDefault("Attacks inflict the Crush Depth debuff\n" + + "Grants immunity to the Crush Depth debuff\n" + "While in the abyss you gain 25% increased max life\n" + "Provides a moderate amount of light in the abyss"); } @@ -32,7 +34,8 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); modPlayer.abyssalAmulet = true; modPlayer.lumenousAmulet = true; - } + player.buffImmune[ModContent.BuffType()] = true; + } public override void AddRecipes() { diff --git a/Items/Accessories/ReaperToothNecklace.cs b/Items/Accessories/ReaperToothNecklace.cs index 2535043e59..df1cfcf6cc 100644 --- a/Items/Accessories/ReaperToothNecklace.cs +++ b/Items/Accessories/ReaperToothNecklace.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Reaper Tooth Necklace"); - Tooltip.SetDefault("A grisly trophy from the ultimate predator\n" + "12% increased damage\n" + "Increases armor penetration by 30"); + Tooltip.SetDefault("A grisly trophy from the ultimate predator\n" + "10% increased damage\n" + "Increases armor penetration by 15"); } public override void SetDefaults() @@ -27,8 +27,8 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - player.allDamage += 0.12f; - player.armorPenetration += 30; + player.allDamage += 0.1f; + player.armorPenetration += 15; } public override void AddRecipes() diff --git a/Items/Accessories/SandSharkToothNecklace.cs b/Items/Accessories/SandSharkToothNecklace.cs index 63901be879..c75050eadb 100644 --- a/Items/Accessories/SandSharkToothNecklace.cs +++ b/Items/Accessories/SandSharkToothNecklace.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Sand Shark Tooth Necklace"); - Tooltip.SetDefault("Increases armor penetration by 15\n" + "6% increased damage"); + Tooltip.SetDefault("Increases armor penetration by 10\n" + "6% increased damage"); } public override void SetDefaults() @@ -25,7 +25,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.allDamage += 0.06f; - player.armorPenetration += 15; + player.armorPenetration += 10; } public override void AddRecipes() diff --git a/Items/Ammo/NapalmArrow.cs b/Items/Ammo/NapalmArrow.cs index 032e8f60f5..e9645d97c0 100644 --- a/Items/Ammo/NapalmArrow.cs +++ b/Items/Ammo/NapalmArrow.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Ammo recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ItemID.Torch); recipe.AddIngredient(ItemID.WoodenArrow, 250); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddTile(TileID.Anvils); recipe.SetResult(this, 250); recipe.AddRecipe(); } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 87574c2767..c5ad0d4451 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1015,6 +1015,21 @@ namespace CalamityMod.Items } return false; } + if (player.ActiveItem().type == ModContent.ItemType() && player.ownedProjectileCounts[ModContent.ProjectileType()] == 0) + { + for (int i = 0; i < Main.projectile.Length; i++) + { + if (Main.projectile[i].modProjectile is VoidConcentrationAura) + { + if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI) + { + (Main.projectile[i].modProjectile as VoidConcentrationAura).HandleRightClick(); + break; + } + } + } + return false; + } if (player.ActiveItem().type == ModContent.ItemType()) { bool canContinue = true; @@ -1899,8 +1914,11 @@ namespace CalamityMod.Items player.endurance += 0.01f; } - if (item.prefix == PrefixID.Precise || item.prefix == PrefixID.Lucky) + // TODO -- make all prefixes relevant. Details in Ozz's todo. + /* + if (item.prefix == PrefixID.Precise || item.prefix == PrefixID.Lucky) player.armorPenetration += 1; + */ if (item.prefix == PrefixID.Brisk) player.moveSpeed += 0.01f; diff --git a/Items/CalamityGlobalItemLoot.cs b/Items/CalamityGlobalItemLoot.cs index 333fb21183..035fc9eec6 100644 --- a/Items/CalamityGlobalItemLoot.cs +++ b/Items/CalamityGlobalItemLoot.cs @@ -29,6 +29,10 @@ namespace CalamityMod.Items else if (context == "bossBag") BossBagLoot(player, itemID); + + // Bat Hook is now acquired from Vampires. + else if (context == "goodieBag") + DropHelper.BlockDrops(ItemID.BatHook); } #region Boss Bags diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index 8c6b99fe0f..fc617cf59c 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -43,10 +43,20 @@ namespace CalamityMod.Items // This is placed between vanilla tooltip edits and mod mechanics because it can apply to vanilla items. StealthGenAccessoryTooltip(item, tooltips); + // If an item has special tags (specifically Ice, Fire, and Nature), show that in the tooltip. + ElementTooltip(item, tooltips); + // If an item has an enchantment, show its prefix in the first tooltip line and append its description to the // tooltip list. EnchantmentTooltips(item, tooltips); + // Adds "Does extra damage to enemies shot at point-blank range" to weapons capable of it. + if (canFirePointBlankShots) + { + TooltipLine line = new TooltipLine(mod, "PointBlankShot", "Does extra damage to enemies shot at point-blank range"); + tooltips.Add(line); + } + // Everything below this line can only apply to modded items. If the item is vanilla, stop here for efficiency. if (item.type < ItemID.Count) return; @@ -76,13 +86,6 @@ namespace CalamityMod.Items tooltips.Add(line); } - // Adds "Does extra damage to enemies shot at point-blank range" to weapons capable of it. - if (canFirePointBlankShots) - { - TooltipLine line = new TooltipLine(mod, "PointBlankShot", "Does extra damage to enemies shot at point-blank range"); - tooltips.Add(line); - } - // Adds "Challenge Drop" or "Legendary Challenge Drop" to Malice Mode drops. // For Legendary Challenge Drops, this tooltip matches their unique rarity color. if (challengeDrop) @@ -320,6 +323,10 @@ namespace CalamityMod.Items if (item.type == ItemID.ArcheryPotion) EditTooltipByNum(0, (line) => line.text = "20% increased arrow speed and 1.05x arrow damage"); + // Nerfed Swiftness Potion tooltip + if (item.type == ItemID.SwiftnessPotion) + EditTooltipByNum(0, (line) => line.text = "15% increased movement speed"); + // Hand Warmer provides Death Mode cold protection and has a side bonus with Eskimo armor if (item.type == ItemID.HandWarmer) { @@ -918,10 +925,6 @@ namespace CalamityMod.Items case PrefixID.Quick2: // Quick2 is the "Quick" for accessories EditTooltipByName("PrefixAccMoveSpeed", (line) => line.text = line.text.Replace("4%", "8%")); return; - case PrefixID.Precise: - case PrefixID.Lucky: - EditTooltipByName("PrefixAccCritChance", (line) => line.text += "\n+1 armor penetration"); - return; case PrefixID.Hard: EditTooltipByName("PrefixAccDefense", (line) => line.text = line.text.Replace("1", CalamityUtils.GetScalingDefense(item.prefix).ToString()) + DRString(0.25f)); @@ -988,6 +991,38 @@ namespace CalamityMod.Items } #endregion + #region Element Tooltip + private void ElementTooltip(Item item, IList tooltips) + { + if (CalamityLists.fireWeaponList.Contains(item.type)) + { + TooltipLine fireTooltip = new TooltipLine(mod, "FireWeapon", "-Fire Weapon-") + { + overrideColor = new Color(255, 165, 0) + }; + tooltips.Add(fireTooltip); + } + + if (CalamityLists.iceWeaponList.Contains(item.type)) + { + TooltipLine iceTooltip = new TooltipLine(mod, "IceWeapon", "-Ice Weapon-") + { + overrideColor = new Color(94, 230, 255) + }; + tooltips.Add(iceTooltip); + } + + if (CalamityLists.natureWeaponList.Contains(item.type)) + { + TooltipLine natureTooltip = new TooltipLine(mod, "NatureWeapon", "-Nature Weapon-") + { + overrideColor = new Color(46, 165, 0) + }; + tooltips.Add(natureTooltip); + } + } + #endregion + #region Enchanted Rarity Text Drawing public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset) { diff --git a/Items/Dyes/BloodflareDye.cs b/Items/Dyes/BloodflareDye.cs new file mode 100644 index 0000000000..c48e0567da --- /dev/null +++ b/Items/Dyes/BloodflareDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class BloodflareDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/BloodflareDyeShader")), "DyePass"). + UseColor(new Color(122, 10, 60)).UseSecondaryColor(new Color(219, 102, 106)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Bloodflare Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.PureGreen; + item.value = Item.sellPrice(0, 4, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 2); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/BloodflareDye.png b/Items/Dyes/BloodflareDye.png new file mode 100644 index 0000000000..aa7383fe1d Binary files /dev/null and b/Items/Dyes/BloodflareDye.png differ diff --git a/Items/Dyes/BlueCosmicFlameDye.cs b/Items/Dyes/BlueCosmicFlameDye.cs new file mode 100644 index 0000000000..be095f9472 --- /dev/null +++ b/Items/Dyes/BlueCosmicFlameDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class BlueCosmicFlameDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CosmicFlameShader")), "DyePass"). + UseColor(new Color(52, 212, 229)).UseSecondaryColor(new Color(52, 212, 229)).UseImage("Images/Misc/Noise").UseSaturation(0f); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Blue Cosmic Flame Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.value = Item.sellPrice(0, 5, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 2); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/BlueCosmicFlameDye.png b/Items/Dyes/BlueCosmicFlameDye.png new file mode 100644 index 0000000000..103049ae10 Binary files /dev/null and b/Items/Dyes/BlueCosmicFlameDye.png differ diff --git a/Items/Dyes/CalamitousDye.cs b/Items/Dyes/CalamitousDye.cs new file mode 100644 index 0000000000..ce329f8051 --- /dev/null +++ b/Items/Dyes/CalamitousDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class CalamitousDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CalamitousDyeShader")), "DyePass"). + UseColor(new Color(227, 79, 79)).UseSecondaryColor(new Color(145, 27, 135)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Calamitous Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.value = Item.sellPrice(0, 10, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 3); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 3); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/CalamitousDye.png b/Items/Dyes/CalamitousDye.png new file mode 100644 index 0000000000..587ec7e601 Binary files /dev/null and b/Items/Dyes/CalamitousDye.png differ diff --git a/Items/Dyes/CryonicDye.cs b/Items/Dyes/CryonicDye.cs new file mode 100644 index 0000000000..86fd0e89bc --- /dev/null +++ b/Items/Dyes/CryonicDye.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Placeables.Ores; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Dyes +{ + public class CryonicDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CryonicDyeShader")), "DyePass"). + UseColor(new Color(138, 225, 255)).UseSecondaryColor(new Color(90, 90, 204)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Cryonic Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Pink; + item.value = Item.sellPrice(0, 0, 75, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 2); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/CryonicDye.png b/Items/Dyes/CryonicDye.png new file mode 100644 index 0000000000..7aa240fd98 Binary files /dev/null and b/Items/Dyes/CryonicDye.png differ diff --git a/Items/Dyes/PhantoplasmDye.cs b/Items/Dyes/PhantoplasmDye.cs new file mode 100644 index 0000000000..993f77f826 --- /dev/null +++ b/Items/Dyes/PhantoplasmDye.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class PhantoplasmDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/PhantoplasmDyeShader")), "DyePass"). + UseColor(new Color(245, 143, 182)).UseSecondaryColor(new Color(119, 238, 255)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Phantoplasm Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Purple; + item.value = Item.sellPrice(0, 2, 50, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 2); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/PhantoplasmDye.png b/Items/Dyes/PhantoplasmDye.png new file mode 100644 index 0000000000..792d4bd633 Binary files /dev/null and b/Items/Dyes/PhantoplasmDye.png differ diff --git a/Items/Dyes/PinkCosmicFlameDye.cs b/Items/Dyes/PinkCosmicFlameDye.cs new file mode 100644 index 0000000000..9c953cf4bd --- /dev/null +++ b/Items/Dyes/PinkCosmicFlameDye.cs @@ -0,0 +1,37 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class PinkCosmicFlameDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CosmicFlameShader")), "DyePass"). + UseColor(new Color(255, 115, 221)).UseSecondaryColor(new Color(255, 115, 221)).UseImage("Images/Misc/Noise").UseSaturation(0f); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Pink Cosmic Flame Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.value = Item.sellPrice(0, 5, 0, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 2); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/PinkCosmicFlameDye.png b/Items/Dyes/PinkCosmicFlameDye.png new file mode 100644 index 0000000000..65c1fd39ad Binary files /dev/null and b/Items/Dyes/PinkCosmicFlameDye.png differ diff --git a/Items/Dyes/ProfanedFlameDye.cs b/Items/Dyes/ProfanedFlameDye.cs new file mode 100644 index 0000000000..e777cce2b1 --- /dev/null +++ b/Items/Dyes/ProfanedFlameDye.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Materials; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class ProfanedFlameDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/ProfanedFlameDyeShader")), "DyePass"). + UseColor(new Color(255, 191, 73)).UseSecondaryColor(new Color(255, 255, 186)).UseImage("Images/Misc/Perlin"); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Profaned Flame Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Purple; + item.value = Item.sellPrice(0, 2, 50, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.BottledWater, 2); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this, 2); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/ProfanedFlameDye.png b/Items/Dyes/ProfanedFlameDye.png new file mode 100644 index 0000000000..fefa274ca2 Binary files /dev/null and b/Items/Dyes/ProfanedFlameDye.png differ diff --git a/Items/Dyes/SwirlingCosmicFlameDye.cs b/Items/Dyes/SwirlingCosmicFlameDye.cs new file mode 100644 index 0000000000..f227541687 --- /dev/null +++ b/Items/Dyes/SwirlingCosmicFlameDye.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Graphics.Shaders; +using Microsoft.Xna.Framework; + +namespace CalamityMod.Items.Dyes +{ + public class SwirlingCosmicFlameDye : BaseDye + { + public override ArmorShaderData ShaderDataToBind => new ArmorShaderData(new Ref(mod.GetEffect("Effects/Dyes/CosmicFlameShader")), "DyePass"). + UseColor(new Color(52, 212, 229)).UseSecondaryColor(new Color(255, 115, 221)).UseImage("Images/Misc/Noise").UseSaturation(1f); + public override void SafeSetStaticDefaults() + { + DisplayName.SetDefault("Swirling Cosmic Flame Dye"); + } + + public override void SafeSetDefaults() + { + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.value = Item.sellPrice(0, 7, 50, 0); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddTile(TileID.DyeVat); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} \ No newline at end of file diff --git a/Items/Dyes/SwirlingCosmicFlameDye.png b/Items/Dyes/SwirlingCosmicFlameDye.png new file mode 100644 index 0000000000..bc524d1cc6 Binary files /dev/null and b/Items/Dyes/SwirlingCosmicFlameDye.png differ diff --git a/Items/Fishing/SulphurCatches/AbyssalCrate.cs b/Items/Fishing/SulphurCatches/AbyssalCrate.cs index 23a60fdd9c..de4be89516 100644 --- a/Items/Fishing/SulphurCatches/AbyssalCrate.cs +++ b/Items/Fishing/SulphurCatches/AbyssalCrate.cs @@ -8,12 +8,14 @@ using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; -using CalamityMod.Tiles.Abyss; using CalamityMod.World; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using CrateTile = CalamityMod.Tiles.Abyss.AbyssalCrateTile; +using CalamityMod.Items.Placeables; + namespace CalamityMod.Items.Fishing.SulphurCatches { public class AbyssalCrate : ModItem @@ -32,7 +34,7 @@ namespace CalamityMod.Items.Fishing.SulphurCatches item.height = 32; item.rare = ItemRarityID.Green; item.value = Item.sellPrice(gold: 1); - item.createTile = ModContent.TileType(); + item.createTile = ModContent.TileType(); item.useTurn = true; item.autoReuse = true; item.useAnimation = 15; @@ -45,21 +47,22 @@ namespace CalamityMod.Items.Fishing.SulphurCatches public override void RightClick(Player player) { //Modded materials - DropHelper.DropItem(player, ModContent.ItemType(), 5, 10); - DropHelper.DropItem(player, ModContent.ItemType(), 5, 10); + DropHelper.DropItem(player, ModContent.ItemType(), 5, 10); + DropHelper.DropItem(player, ModContent.ItemType(), 5, 10); + DropHelper.DropItem(player, ModContent.ItemType(), 5, 10); DropHelper.DropItem(player, ModContent.ItemType(), 5, 10); DropHelper.DropItemChance(player, ItemID.Starfish, 0.5f, 2, 3); DropHelper.DropItemChance(player, ItemID.Seashell, 0.5f, 2, 3); DropHelper.DropItemChance(player, ItemID.Coral, 0.5f, 2, 3); DropHelper.DropItemChance(player, ModContent.ItemType(), 0.25f, 2, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedEoCAcidRain, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAquaticScourgeAcidRain, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); - DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedGolemBoss, 0.1f, 1, 3); - DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedPolterghast && CalamityWorld.downedBoomerDuke, 0.1f, 1, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedEoCAcidRain, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedAquaticScourgeAcidRain, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedCalamitas, 0.2f, 2, 5); + DropHelper.DropItemCondition(player, ModContent.ItemType(), NPC.downedGolemBoss, 0.1f, 1, 3); + DropHelper.DropItemCondition(player, ModContent.ItemType(), CalamityWorld.downedPolterghast && CalamityWorld.downedBoomerDuke, 0.1f, 1, 5); // Weapons DropHelper.DropItemFromSetCondition(player, CalamityWorld.downedSlimeGod || Main.hardMode, 0.1f, @@ -101,29 +104,29 @@ namespace CalamityMod.Items.Fishing.SulphurCatches DropHelper.DropItemChance(player, ItemID.HeartreachPotion, 10, 1, 3); DropHelper.DropItemChance(player, ItemID.TrapsightPotion, 10, 1, 3); //Dangersense Potion DropHelper.DropItemChance(player, ModContent.ItemType(), 10, 1, 3); - int healingPotID = ItemID.LesserHealingPotion; - int manaPotID = ItemID.LesserManaPotion; - if (CalamityWorld.downedDoG) - { - healingPotID = ModContent.ItemType(); - manaPotID = ModContent.ItemType(); - } - else if (CalamityWorld.downedProvidence) - { - healingPotID = ItemID.SuperHealingPotion; - manaPotID = ItemID.SuperManaPotion; - } - else if (NPC.downedMechBossAny) - { - healingPotID = ItemID.GreaterHealingPotion; - manaPotID = ItemID.GreaterManaPotion; - } - else if (NPC.downedBoss3) - { - healingPotID = ItemID.HealingPotion; - manaPotID = ItemID.ManaPotion; - } - DropHelper.DropItemChance(player, Main.rand.Next(100) >= 49 ? healingPotID : manaPotID, 0.25f, 2, 5); + int healingPotID = ItemID.LesserHealingPotion; + int manaPotID = ItemID.LesserManaPotion; + if (CalamityWorld.downedDoG) + { + healingPotID = ModContent.ItemType(); + manaPotID = ModContent.ItemType(); + } + else if (CalamityWorld.downedProvidence) + { + healingPotID = ItemID.SuperHealingPotion; + manaPotID = ItemID.SuperManaPotion; + } + else if (NPC.downedMechBossAny) + { + healingPotID = ItemID.GreaterHealingPotion; + manaPotID = ItemID.GreaterManaPotion; + } + else if (NPC.downedBoss3) + { + healingPotID = ItemID.HealingPotion; + manaPotID = ItemID.ManaPotion; + } + DropHelper.DropItemChance(player, Main.rand.NextBool(2) ? healingPotID : manaPotID, 0.25f, 2, 5); //Money DropHelper.DropItem(player, ItemID.SilverCoin, 10, 90); diff --git a/Items/SuperDummy.cs b/Items/SuperDummy.cs index e692e34262..c4dcc1dbb7 100644 --- a/Items/SuperDummy.cs +++ b/Items/SuperDummy.cs @@ -35,21 +35,41 @@ namespace CalamityMod.Items return true; } + public static void DeleteDummies() + { + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc.type == ModContent.NPCType() && npc.active) + { + npc.life = 0; + npc.active = false; + + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); + } + } + } + public override bool UseItem(Player player) { if (player.altFunctionUse == 2) { - for (int i = 0; i < Main.maxNPCs; i++) + if (Main.myPlayer == player.whoAmI) { - NPC npc = Main.npc[i]; - if (npc.type == ModContent.NPCType() && npc.active) + if (Main.netMode == NetmodeID.SinglePlayer) + DeleteDummies(); + + // A custom packet must be sent so that the deletion can be done on the server. This hook does not run there. + // Why? Well, netUpdate/MessageID.SyncNPC packets do not send data to the server. They only send data to other clients. What this means is that prior to this fix + // what would happen was every client EXCEPT THE SERVER would be told by this player that the dummies disappeared. + // However, since the server isn't notified, it is inevitable that the server will do a sync of its own, unaware that the + // dummies are gone, and cause them to reappear, making the deletion moot. + else { - if (player.whoAmI == Main.myPlayer) - { - npc.active = false; - npc.netUpdate = true; - } - Main.PlaySound(SoundID.NPCDeath2, npc.Center); + var netMessage = mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DeleteAllSuperDummies); + netMessage.Send(); } } } diff --git a/Items/Tools/Grax.cs b/Items/Tools/Grax.cs index e2de7f2ae4..231c660616 100644 --- a/Items/Tools/Grax.cs +++ b/Items/Tools/Grax.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Tools public override void SetStaticDefaults() { DisplayName.SetDefault("Grax"); - Tooltip.SetDefault("Hitting an enemy will greatly boost your defense and melee stats for a short time\n" + + Tooltip.SetDefault("Hitting an enemy will greatly boost your defense, melee damage and melee crit for a short time\n" + "Right click to use without hammering down walls or chopping down trees"); } diff --git a/Items/TreasureBags/YharonBag.cs b/Items/TreasureBags/YharonBag.cs index 69f01e7cd3..7970a74788 100644 --- a/Items/TreasureBags/YharonBag.cs +++ b/Items/TreasureBags/YharonBag.cs @@ -11,6 +11,8 @@ using CalamityMod.World; using Terraria; using Terraria.ModLoader; using Terraria.ID; +using CalamityMod.Items.Accessories.Wings; +using CalamityMod.Items.Materials; namespace CalamityMod.Items.TreasureBags { @@ -57,8 +59,13 @@ namespace CalamityMod.Items.TreasureBags ); // Equipment + DropHelper.DropItem(player, ModContent.ItemType()); DropHelper.DropItem(player, ModContent.ItemType()); + int soulFragMin = 22; + int soulFragMax = 28; + DropHelper.DropItem(player, ModContent.ItemType(), soulFragMin, soulFragMax); + // Vanity DropHelper.DropItemChance(player, ModContent.ItemType(), 7); DropHelper.DropItemChance(player, ModContent.ItemType(), 10); diff --git a/Items/Weapons/Magic/AsteroidStaff.cs b/Items/Weapons/Magic/AsteroidStaff.cs index d6965e436a..6895e322e6 100644 --- a/Items/Weapons/Magic/AsteroidStaff.cs +++ b/Items/Weapons/Magic/AsteroidStaff.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Magic item.rare = ItemRarityID.Purple; } - public override Vector2? HoldoutOrigin() => new Vector2(12, 25); + public override Vector2? HoldoutOrigin() => new Vector2(2, 2); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Magic/Atlantis.cs b/Items/Weapons/Magic/Atlantis.cs index 1c77be368f..255277c242 100644 --- a/Items/Weapons/Magic/Atlantis.cs +++ b/Items/Weapons/Magic/Atlantis.cs @@ -6,7 +6,7 @@ using Microsoft.Xna.Framework; namespace CalamityMod.Items.Weapons.Magic { - public class Atlantis : ModItem + public class Atlantis : ModItem { public override void SetStaticDefaults() { diff --git a/Items/Weapons/Magic/HeliumFlash.cs b/Items/Weapons/Magic/HeliumFlash.cs index 9f44eb0892..7dcf2abc09 100644 --- a/Items/Weapons/Magic/HeliumFlash.cs +++ b/Items/Weapons/Magic/HeliumFlash.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Weapons.Magic { DisplayName.SetDefault("Helium Flash"); Tooltip.SetDefault("The power of a galaxy, if only for mere moments\n" + - "Launches volatile star cores which erupt into colossal fusion blasts"); + "Launches volatile star cores which erupt into colossal fusion blasts"); Item.staff[item.type] = true; } @@ -34,11 +34,11 @@ namespace CalamityMod.Items.Weapons.Magic item.useStyle = ItemUseStyleID.HoldingOut; item.UseSound = SoundID.Item73; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Violet; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; - item.shoot = ModContent.ProjectileType(); + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 15f; } @@ -97,7 +97,7 @@ namespace CalamityMod.Items.Weapons.Magic r.AddTile(TileID.LunarCraftingStation); r.AddIngredient(ModContent.ItemType()); r.AddIngredient(ModContent.ItemType()); - r.AddIngredient(ModContent.ItemType()); + r.AddIngredient(ModContent.ItemType()); r.AddIngredient(ModContent.ItemType(), 4); r.AddIngredient(ItemID.FragmentSolar, 80); r.AddIngredient(ItemID.FragmentNebula, 20); diff --git a/Items/Weapons/Magic/Starfall.cs b/Items/Weapons/Magic/Starfall.cs index af2a6e00b5..adc7ed1a44 100644 --- a/Items/Weapons/Magic/Starfall.cs +++ b/Items/Weapons/Magic/Starfall.cs @@ -34,8 +34,8 @@ namespace CalamityMod.Items.Weapons.Magic item.shootSpeed = 12f; } - // Terraria seems to really dislike high crit values in SetDefaults - public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; + // Terraria seems to really dislike high crit values in SetDefaults + public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { diff --git a/Items/Weapons/Melee/AegisBlade.cs b/Items/Weapons/Melee/AegisBlade.cs index b473d99535..7d3419fe2b 100644 --- a/Items/Weapons/Melee/AegisBlade.cs +++ b/Items/Weapons/Melee/AegisBlade.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 58; item.height = 58; item.scale = 1.5f; - item.damage = 68; + item.damage = 110; item.melee = true; item.useAnimation = item.useTime = 15; item.useTurn = true; @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 0.6), knockBack, player.whoAmI); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 0.37), knockBack, player.whoAmI); return false; } diff --git a/Items/Weapons/Melee/AstralPike.cs b/Items/Weapons/Melee/AstralPike.cs index df0983db65..70de4755f0 100644 --- a/Items/Weapons/Melee/AstralPike.cs +++ b/Items/Weapons/Melee/AstralPike.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 44; - item.damage = 128; + item.damage = 90; item.melee = true; item.noMelee = true; item.useTurn = true; diff --git a/Items/Weapons/Melee/Ataraxia.cs b/Items/Weapons/Melee/Ataraxia.cs index 23f4d63bee..1a40403a52 100644 --- a/Items/Weapons/Melee/Ataraxia.cs +++ b/Items/Weapons/Melee/Ataraxia.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 94; item.height = 92; item.melee = true; - item.damage = 1095; + item.damage = 710; item.knockBack = 2.5f; item.useAnimation = 19; item.useTime = 19; diff --git a/Items/Weapons/Melee/BladeofEnmity.cs b/Items/Weapons/Melee/BladeofEnmity.cs index 2ed5dcb022..c9ffe6ce17 100644 --- a/Items/Weapons/Melee/BladeofEnmity.cs +++ b/Items/Weapons/Melee/BladeofEnmity.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 60; item.height = 64; item.scale = 1.5f; - item.damage = 158; + item.damage = 190; item.melee = true; item.useAnimation = 10; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/BrinyBaron.cs b/Items/Weapons/Melee/BrinyBaron.cs index 0e7e4c6097..0fbb6efb04 100644 --- a/Items/Weapons/Melee/BrinyBaron.cs +++ b/Items/Weapons/Melee/BrinyBaron.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - item.damage = 200; + item.damage = 127; item.knockBack = 4f; item.useAnimation = item.useTime = 15; item.melee = true; @@ -66,7 +66,7 @@ namespace CalamityMod.Items.Weapons.Melee public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage / 3, knockBack, player.whoAmI); + Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), (int)(damage * 0.52), knockBack, player.whoAmI); return false; } diff --git a/Items/Weapons/Melee/DiseasedPike.cs b/Items/Weapons/Melee/DiseasedPike.cs index 138d12accd..b7853c91c5 100644 --- a/Items/Weapons/Melee/DiseasedPike.cs +++ b/Items/Weapons/Melee/DiseasedPike.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 62; - item.damage = 75; + item.damage = 92; item.melee = true; item.noMelee = true; item.useTurn = true; diff --git a/Items/Weapons/Melee/ExsanguinationLance.cs b/Items/Weapons/Melee/ExsanguinationLance.cs index 733f11b7db..e142c93180 100644 --- a/Items/Weapons/Melee/ExsanguinationLance.cs +++ b/Items/Weapons/Melee/ExsanguinationLance.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 44; - item.damage = 60; + item.damage = 90; item.melee = true; item.noMelee = true; item.useTurn = true; diff --git a/Items/Weapons/Melee/GrandGuardian.cs b/Items/Weapons/Melee/GrandGuardian.cs index eb922de395..fc9bf9cbe5 100644 --- a/Items/Weapons/Melee/GrandGuardian.cs +++ b/Items/Weapons/Melee/GrandGuardian.cs @@ -70,16 +70,16 @@ namespace CalamityMod.Items.Weapons.Melee Projectile.NewProjectile(targetPos, Vector2.Zero, ModContent.ProjectileType(), (int)(damage * 0.5f), 0f, player.whoAmI); if (targetLife <= (targetMaxLife * 0.5f) && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) { - float randomSpeedX = Main.rand.Next(9); - float randomSpeedY = Main.rand.Next(6, 15); - Projectile.NewProjectile(player.Center.X, player.Center.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(damage * 0.75f), knockback, player.whoAmI); - Projectile.NewProjectile(player.Center.X, player.Center.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(damage * 0.75f), knockback, player.whoAmI); - Projectile.NewProjectile(player.Center.X, player.Center.Y, 0f, -randomSpeedY, ModContent.ProjectileType(), (int)(damage * 0.75f), knockback, player.whoAmI); + float randomSpeedX = Main.rand.Next(6, 13); + float randomSpeedY = Main.rand.Next(6, 13); + Projectile.NewProjectile(targetPos.X, targetPos.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(damage * 0.75f), knockback, player.whoAmI); + Projectile.NewProjectile(targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), (int)(damage * 0.75f), knockback, player.whoAmI); + Projectile.NewProjectile(targetPos.X, targetPos.Y, 0f, -randomSpeedY, ModContent.ProjectileType(), (int)(damage * 0.75f), knockback, player.whoAmI); } if (targetLife <= 0 && !player.moonLeech && player.ownedProjectileCounts[ModContent.ProjectileType()] < 3) { - float randomSpeedX = Main.rand.Next(9); - float randomSpeedY = Main.rand.Next(6, 15); + float randomSpeedX = Main.rand.Next(3, 7); + float randomSpeedY = Main.rand.Next(3, 7); Projectile.NewProjectile(targetPos.X, targetPos.Y, -randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); Projectile.NewProjectile(targetPos.X, targetPos.Y, randomSpeedX, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); Projectile.NewProjectile(targetPos.X, targetPos.Y, 0f, -randomSpeedY, ModContent.ProjectileType(), 0, 0f, player.whoAmI); diff --git a/Items/Weapons/Melee/HolyCollider.cs b/Items/Weapons/Melee/HolyCollider.cs index 2f2bc11870..a1ee34def1 100644 --- a/Items/Weapons/Melee/HolyCollider.cs +++ b/Items/Weapons/Melee/HolyCollider.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 94; item.height = 80; item.scale = 1.5f; - item.damage = 342; + item.damage = 270; item.melee = true; item.useAnimation = 22; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index 30c4f8561a..49d498e579 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.height = 128; item.width = 56; - item.damage = 2001; + item.damage = 3001; item.melee = true; item.noMelee = true; item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/Omniblade.cs b/Items/Weapons/Melee/Omniblade.cs index 0ccd879f86..6baf919099 100644 --- a/Items/Weapons/Melee/Omniblade.cs +++ b/Items/Weapons/Melee/Omniblade.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 64; - item.damage = 95; + item.damage = 138; item.melee = true; item.useAnimation = 10; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/Oracle.cs b/Items/Weapons/Melee/Oracle.cs index fd80f86eb2..4dd5bd38ac 100644 --- a/Items/Weapons/Melee/Oracle.cs +++ b/Items/Weapons/Melee/Oracle.cs @@ -10,9 +10,9 @@ namespace CalamityMod.Items.Weapons.Melee { public class Oracle : ModItem { - public const int YoyoBaseDamage = 115; - public const int AuraBaseDamage = 40; - public const int AuraMaxDamage = 105; + public const int YoyoBaseDamage = 170; + public const int AuraBaseDamage = 100; + public const int AuraMaxDamage = 220; public override void SetStaticDefaults() { diff --git a/Items/Weapons/Melee/PhosphorescentGauntlet.cs b/Items/Weapons/Melee/PhosphorescentGauntlet.cs index 29d9a5ff8d..8c977ce9b8 100644 --- a/Items/Weapons/Melee/PhosphorescentGauntlet.cs +++ b/Items/Weapons/Melee/PhosphorescentGauntlet.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = item.height = 40; - item.damage = 930; + item.damage = 2705; item.melee = true; item.noMelee = true; item.noUseGraphic = true; diff --git a/Items/Weapons/Melee/PhotonRipper.cs b/Items/Weapons/Melee/PhotonRipper.cs index 24e2d87a0e..5b6bee5630 100644 --- a/Items/Weapons/Melee/PhotonRipper.cs +++ b/Items/Weapons/Melee/PhotonRipper.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.height = 134; item.width = 54; - item.damage = 3660; + item.damage = 4050; // Displayed axe% is 1/5th of axePower here because trees have 500% hardness. This corrects for that. item.axe = 6000 / 5; diff --git a/Items/Weapons/Melee/SpineOfThanatos.cs b/Items/Weapons/Melee/SpineOfThanatos.cs index e702cd99ac..4f1b9a089e 100644 --- a/Items/Weapons/Melee/SpineOfThanatos.cs +++ b/Items/Weapons/Melee/SpineOfThanatos.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = item.height = 28; - item.damage = 369; + item.damage = 260; item.rare = ItemRarityID.Red; item.value = CalamityGlobalItem.RarityVioletBuyPrice; item.Calamity().customRarity = CalamityRarity.Violet; diff --git a/Items/Weapons/Melee/TheBurningSky.cs b/Items/Weapons/Melee/TheBurningSky.cs index 0b762aaddf..15ae2be156 100644 --- a/Items/Weapons/Melee/TheBurningSky.cs +++ b/Items/Weapons/Melee/TheBurningSky.cs @@ -1,6 +1,5 @@ using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -9,94 +8,57 @@ namespace CalamityMod.Items.Weapons.Melee { public class TheBurningSky : ModItem { + private const int ProjectilesPerBarrage = 6; + public override void SetStaticDefaults() { DisplayName.SetDefault("The Burning Sky"); - Tooltip.SetDefault("Summons a massive barrage of burning meteors from the sky"); + Tooltip.SetDefault("Hold the blade to the sky, and witness Armageddon"); + + // Visually a sword, but with no true melee capability. The Burning Sky is held out like a staff. + Item.staff[item.type] = true; } public override void SetDefaults() { item.width = 62; - item.damage = 600; - item.melee = true; - item.useTime = 15; - item.useAnimation = 15; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.knockBack = 8f; - item.UseSound = SoundID.Item1; - item.autoReuse = true; item.height = 64; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Violet; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; + item.damage = 244; + item.knockBack = 2.5f; + + item.melee = true; + item.noMelee = true; + + item.useTime = 9; + item.useAnimation = 9; + item.useStyle = ItemUseStyleID.HoldingOut; + item.autoReuse = true; + item.UseSound = SoundID.Item105; + + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14f; + + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - int i = Main.myPlayer; - float num72 = item.shootSpeed; - player.itemTime = item.useTime; - Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true); - float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (player.gravDir == -1f) + // Every time the item spawns more meteors, play a violent, bass heavy sound to add onto Star Wrath's use sound. + Main.PlaySound(SoundID.Item70, player.Center); + + Vector2 originalVelocity = new Vector2(speedX, speedY); + float speed = originalVelocity.Length(); + for (int i = 0; i < ProjectilesPerBarrage; ++i) { - num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y; - } - float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f)) - { - num78 = (float)player.direction; - num79 = 0f; - num80 = num72; - } - else - { - num80 = num72 / num80; - } - - int num107 = 20; - for (int num108 = 0; num108 < num107; num108++) - { - vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f); - vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201); - vector2.Y -= (float)(100 * num108); - num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X; - num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y; - if (num79 < 0f) - { - num79 *= -1f; - } - if (num79 < 20f) - { - num79 = 20f; - } - num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79)); - num80 = num72 / num80; - num78 *= num80; - num79 *= num80; - float speedX4 = num78 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - float speedY5 = num79 + (float)Main.rand.Next(-1000, 1001) * 0.02f; - Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, ModContent.ProjectileType(), damage, knockBack, i, 0f, (float)Main.rand.Next(10)); + float randomSpeed = speed * Main.rand.NextFloat(0.7f, 1.4f); + CalamityUtils.ProjectileRain(Main.MouseWorld, 290f, 130f, 850f, 1100f, randomSpeed, type, damage, knockBack, player.whoAmI); } return false; } - public override void MeleeEffects(Player player, Rectangle hitbox) - { - if (Main.rand.NextBool(3)) - { - int dust = Dust.NewDust(new Vector2(hitbox.X, hitbox.Y), hitbox.Width, hitbox.Height, 244); - } - } - - public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Daybreak, 600); - } + public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) => target.AddBuff(BuffID.Daybreak, 600); + public override void OnHitPvp(Player player, Player target, int damage, bool crit) => target.AddBuff(BuffID.Daybreak, 600); } } diff --git a/Items/Weapons/Melee/TheEnforcer.cs b/Items/Weapons/Melee/TheEnforcer.cs index cb2969333d..f73a27cef9 100644 --- a/Items/Weapons/Melee/TheEnforcer.cs +++ b/Items/Weapons/Melee/TheEnforcer.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 100; item.height = 100; item.scale = 1.5f; - item.damage = 760; + item.damage = 890; item.melee = true; item.useAnimation = 17; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Melee/TheMutilator.cs b/Items/Weapons/Melee/TheMutilator.cs index 25a33f05c9..159e44f4af 100644 --- a/Items/Weapons/Melee/TheMutilator.cs +++ b/Items/Weapons/Melee/TheMutilator.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee item.width = 90; item.height = 90; item.scale = 1.5f; - item.damage = 596; + item.damage = 483; item.melee = true; item.useAnimation = 18; item.useStyle = ItemUseStyleID.SwingThrow; diff --git a/Items/Weapons/Ranged/AcesHigh.cs b/Items/Weapons/Ranged/AcesHigh.cs index 8884fcf40e..49a26ce573 100644 --- a/Items/Weapons/Ranged/AcesHigh.cs +++ b/Items/Weapons/Ranged/AcesHigh.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 230; + item.damage = 325; item.ranged = true; item.width = 48; item.height = 30; diff --git a/Items/Weapons/Ranged/ChickenCannon.cs b/Items/Weapons/Ranged/ChickenCannon.cs index 9263922eb7..f75a48d2d0 100644 --- a/Items/Weapons/Ranged/ChickenCannon.cs +++ b/Items/Weapons/Ranged/ChickenCannon.cs @@ -11,39 +11,69 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Chicken Cannon"); - Tooltip.SetDefault("Fires chicken rockets"); + Tooltip.SetDefault("Fires chicken flares which create enormous incendiary explosions\n" + + "Right click to detonate all airborne rockets"); } public override void SetDefaults() { - item.damage = 90; + item.damage = 416; item.ranged = true; item.width = 76; item.height = 24; - item.useTime = 39; - item.useAnimation = 39; + item.useTime = item.useAnimation = 33; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; - item.knockBack = 8.5f; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Violet; - item.UseSound = SoundID.Item11; + item.knockBack = 1.5f; + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + // No use sound is intentional item.autoReuse = true; - item.shootSpeed = 24f; - item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 14.5f; + item.shoot = ModContent.ProjectileType(); item.useAmmo = AmmoID.Rocket; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + + public override bool AltFunctionUse(Player player) => true; + + // Right click doesn't use ammo because it's a detonation signal. + public override bool ConsumeAmmo(Player player) => player.altFunctionUse != 2; public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI); + // Play a sound and detonate all in-flight rockets, but don't shoot anything. + if (player.altFunctionUse == 2) + { + Main.PlaySound(SoundID.Item110, position); + DetonateRockets(player); + return false; + } + + // Otherwise just play a grenade launcher sound and fire a rocket. + Main.PlaySound(SoundID.Item61, position); + Projectile.NewProjectile(position, new Vector2(speedX, speedY), item.shoot, damage, knockBack, player.whoAmI); return false; } + + private void DetonateRockets(Player player) + { + for (int i = 0; i < Main.maxProjectiles; ++i) + { + Projectile p = Main.projectile[i]; + if (!p.active || p.owner != player.whoAmI || p.type != item.shoot) + continue; + + // All rockets will instantly explode on the next frame and send packets to indicate as such. + p.timeLeft = 1; + p.netUpdate = true; + p.netSpam = 0; + } + } + + // Right clicking to detonate all rockets is very fast. + public override float UseTimeMultiplier(Player player) => player.altFunctionUse == 2 ? 5f : 1f; } } diff --git a/Items/Weapons/Ranged/CursedCapper.cs b/Items/Weapons/Ranged/CursedCapper.cs index 28213ab0d1..521369a4f0 100644 --- a/Items/Weapons/Ranged/CursedCapper.cs +++ b/Items/Weapons/Ranged/CursedCapper.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Ranged ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.PhoenixBlaster); recipe.AddIngredient(ItemID.CursedFlame, 10); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddTile(TileID.Anvils); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Weapons/Ranged/DragonsBreath.cs b/Items/Weapons/Ranged/DragonsBreath.cs index 4766897338..e46d503b62 100644 --- a/Items/Weapons/Ranged/DragonsBreath.cs +++ b/Items/Weapons/Ranged/DragonsBreath.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged public const int BetweenShotsPause = 15; public const int PelletsPerShot = 6; public const float FullAutoFireRateMult = 0.8f; - public const float FullAutoDamageMult = 0.85f; + public const float FullAutoDamageMult = 0.8f; // note this is extremely low because it's per pellet public const float Spread = 0.018f; @@ -21,14 +21,14 @@ namespace CalamityMod.Items.Weapons.Ranged Tooltip.SetDefault("Left click fires in two-shot bursts\n" + "The first shot is a spread of 6 normal bullets\n" + "The second shot is a tight spread of 6 Dragon's Breath rounds\n" + - "Right click fires full auto and mixes the bullets randomly, but does 15% less damage\n" + + "Right click fires full auto and mixes the bullets randomly, but does 20% less damage\n" + "This weapon has no randomness to its spread pattern\n" + "66% chance to not consume ammo"); } public override void SetDefaults() { - item.damage = 200; + item.damage = 272; item.ranged = true; item.width = 64; item.height = 28; diff --git a/Items/Weapons/Ranged/HeavenlyGale.cs b/Items/Weapons/Ranged/HeavenlyGale.cs index d4de9703bb..a72de55197 100644 --- a/Items/Weapons/Ranged/HeavenlyGale.cs +++ b/Items/Weapons/Ranged/HeavenlyGale.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public class HeavenlyGale : ModItem { - public const float NormalArrowDamageMult = 1.2f; + public const float NormalArrowDamageMult = 1.25f; private static int[] ExoArrows; public override void SetStaticDefaults() @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Ranged "Blue exo arrows burst into barrages of following arrows\n" + "Orange exo arrows explode into flames\n" + "Teal exo arrows pierce infinitely and ignore immunity frames\n" + - "Any non-wooden arrows used will deal 1.2x damage\n" + + $"Any non-wooden arrows used will deal {NormalArrowDamageMult}x damage\n" + "66% chance to not consume ammo"); ExoArrows = new int[] diff --git a/Items/Weapons/Ranged/Karasawa.cs b/Items/Weapons/Ranged/Karasawa.cs index fa8681b09f..d3457396b7 100644 --- a/Items/Weapons/Ranged/Karasawa.cs +++ b/Items/Weapons/Ranged/Karasawa.cs @@ -76,7 +76,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { ModRecipe r = new ModRecipe(mod); - r.AddIngredient(ModContent.ItemType()); + r.AddIngredient(ItemID.LargeRuby); r.AddIngredient(ModContent.ItemType(), 5); r.AddIngredient(ModContent.ItemType(), 10); r.AddIngredient(ModContent.ItemType(), 15); diff --git a/Items/Weapons/Ranged/Photoviscerator.cs b/Items/Weapons/Ranged/Photoviscerator.cs index a3ccae8ffb..0bfa278040 100644 --- a/Items/Weapons/Ranged/Photoviscerator.cs +++ b/Items/Weapons/Ranged/Photoviscerator.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged public class Photoviscerator : ModItem { public const int CooldownTime = 60 * 7; // 7 second cooldown. - public const double AltFireDamageMult = 1.5; + public const double AltFireDamageMult = 1D; public override void SetStaticDefaults() { diff --git a/Items/Weapons/Ranged/SurgeDriver.cs b/Items/Weapons/Ranged/SurgeDriver.cs index f3e8ed0a68..94b23d9a56 100644 --- a/Items/Weapons/Ranged/SurgeDriver.cs +++ b/Items/Weapons/Ranged/SurgeDriver.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Items.Weapons.Ranged { Vector2 newShootVelocity = shootVelocity * Main.rand.NextFloat(1f, 1.45f); newShootVelocity = newShootVelocity.RotatedByRandom(0.15f); - Projectile.NewProjectile(gunTip, newShootVelocity, item.shoot, damage, knockBack, player.whoAmI); + Projectile.NewProjectile(gunTip, newShootVelocity, item.shoot, (int)(damage * 1.08), knockBack, player.whoAmI); } } diff --git a/Items/Weapons/Rogue/Celestus.cs b/Items/Weapons/Rogue/Celestus.cs index c56e6934f7..ac504037b3 100644 --- a/Items/Weapons/Rogue/Celestus.cs +++ b/Items/Weapons/Rogue/Celestus.cs @@ -19,9 +19,9 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { - item.damage = 259; + item.damage = 240; item.knockBack = 6f; - item.useAnimation = item.useTime = 20; + item.useAnimation = item.useTime = 22; item.Calamity().rogue = true; item.autoReuse = true; item.shootSpeed = 25f; diff --git a/Items/Weapons/Rogue/ProfanedTrident.cs b/Items/Weapons/Rogue/ProfanedTrident.cs index 989447ddb2..31030aa6b5 100644 --- a/Items/Weapons/Rogue/ProfanedTrident.cs +++ b/Items/Weapons/Rogue/ProfanedTrident.cs @@ -10,40 +10,36 @@ namespace CalamityMod.Items.Weapons.Rogue { public override void SetStaticDefaults() { - DisplayName.SetDefault("Infernal Spear"); - Tooltip.SetDefault("Throws a homing spear that explodes on enemy hits\n" + - "Stealth strikes summon fireballs as they fly before exploding into a fiery fountain"); + DisplayName.SetDefault("Wrathwing"); + Tooltip.SetDefault("Throws an agile, homing winged spear that constantly spits fire\n" + + "Stealth strikes create an eruption of cinders on hit"); } public override void SafeSetDefaults() { item.width = 72; - item.damage = 700; + item.damage = 592; + item.knockBack = 5f; item.noMelee = true; item.noUseGraphic = true; - item.useAnimation = 13; item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = 13; - item.knockBack = 8f; - item.UseSound = SoundID.Item1; + item.useTime = item.useAnimation = 13; item.autoReuse = true; + item.UseSound = SoundID.Item1; item.height = 72; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Violet; - item.shoot = ModContent.ProjectileType(); + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 28f; item.Calamity().rogue = true; } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - if (player.Calamity().StealthStrikeAvailable()) - damage = (int)(damage * 0.6); - int proj = Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); + if (proj.WithinBounds(Main.maxProjectiles)) + Main.projectile[proj].Calamity().stealthStrike = player.Calamity().StealthStrikeAvailable(); return false; } } diff --git a/Items/Weapons/Rogue/RefractionRotor.cs b/Items/Weapons/Rogue/RefractionRotor.cs index 9bc6ada7d3..48056eeaad 100644 --- a/Items/Weapons/Rogue/RefractionRotor.cs +++ b/Items/Weapons/Rogue/RefractionRotor.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = item.height = 120; - item.damage = 660; + item.damage = 616; item.knockBack = 8.5f; item.useAnimation = item.useTime = 17; item.Calamity().rogue = true; diff --git a/Items/Weapons/Rogue/TheAtomSplitter.cs b/Items/Weapons/Rogue/TheAtomSplitter.cs index d37d9ee856..e640233cc8 100644 --- a/Items/Weapons/Rogue/TheAtomSplitter.cs +++ b/Items/Weapons/Rogue/TheAtomSplitter.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void SafeSetDefaults() { item.width = item.height = 128; - item.damage = 456; + item.damage = 410; item.knockBack = 7f; item.useAnimation = item.useTime = 25; item.Calamity().rogue = true; diff --git a/Items/Weapons/Summon/AngryChickenStaff.cs b/Items/Weapons/Summon/AngryChickenStaff.cs index ca405e227c..66804946d5 100644 --- a/Items/Weapons/Summon/AngryChickenStaff.cs +++ b/Items/Weapons/Summon/AngryChickenStaff.cs @@ -8,6 +8,7 @@ namespace CalamityMod.Items.Weapons.Summon { public class AngryChickenStaff : ModItem { + public const int Damage = 107; public override void SetStaticDefaults() { DisplayName.SetDefault("Yharon's Kindle Staff"); @@ -18,17 +19,17 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { item.mana = 50; - item.damage = 83; + item.damage = Damage; item.useStyle = ItemUseStyleID.SwingThrow; item.width = 32; item.height = 32; item.useTime = item.useAnimation = 10; item.noMelee = true; item.knockBack = 7f; - item.value = CalamityGlobalItem.Rarity15BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Violet; - item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/FlareSound"); + item.value = CalamityGlobalItem.Rarity15BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Violet; + item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/FlareSound"); item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; diff --git a/Items/Weapons/Summon/CosmicImmaterializer.cs b/Items/Weapons/Summon/CosmicImmaterializer.cs index bd29889670..ba6848556c 100644 --- a/Items/Weapons/Summon/CosmicImmaterializer.cs +++ b/Items/Weapons/Summon/CosmicImmaterializer.cs @@ -3,14 +3,13 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Summon { - public class CosmicImmaterializer : ModItem + public class CosmicImmaterializer : ModItem { public override void SetStaticDefaults() { @@ -25,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { item.mana = 100; - item.damage = 630; + item.damage = 560; item.useStyle = ItemUseStyleID.SwingThrow; item.width = 74; item.height = 72; @@ -45,7 +44,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); CalamityPlayer modPlayer = player.Calamity(); bool hasSummonerSet = modPlayer.tarraSummon || modPlayer.bloodflareSummon || modPlayer.silvaSummon || modPlayer.dsSetBonus || modPlayer.omegaBlueSet || modPlayer.fearmongerSet; //demonshade included so summoner isn't forced to use auric for BR Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, (int)(damage * (hasSummonerSet ? 1 : 0.66)), knockBack, player.whoAmI, 0f, 0f); @@ -59,8 +58,8 @@ namespace CalamityMod.Items.Weapons.Summon recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 4); - recipe.AddTile(ModContent.TileType()); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Weapons/Summon/FleshOfInfidelity.cs b/Items/Weapons/Summon/FleshOfInfidelity.cs index 3d0f142d8a..210b65829c 100644 --- a/Items/Weapons/Summon/FleshOfInfidelity.cs +++ b/Items/Weapons/Summon/FleshOfInfidelity.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 31; + item.damage = 26; item.mana = 10; item.width = item.height = 48; item.useTime = item.useAnimation = 30; diff --git a/Items/Weapons/Summon/FlowersOfMortality.cs b/Items/Weapons/Summon/FlowersOfMortality.cs index 8020b91c54..02aa74bf4e 100644 --- a/Items/Weapons/Summon/FlowersOfMortality.cs +++ b/Items/Weapons/Summon/FlowersOfMortality.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Weapons.Summon { DisplayName.SetDefault("Flowers of Mortality"); Tooltip.SetDefault("Summons five rainbow flowers over your head\n" + - "The combined flowers consume three minion slots"); + "The combined flowers consume two and a half minion slots"); } public override void SetDefaults() diff --git a/Items/Weapons/Summon/MidnightSunBeacon.cs b/Items/Weapons/Summon/MidnightSunBeacon.cs index 447091eaa0..0b832294e5 100644 --- a/Items/Weapons/Summon/MidnightSunBeacon.cs +++ b/Items/Weapons/Summon/MidnightSunBeacon.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 96; + item.damage = 91; item.mana = 12; item.width = item.height = 32; item.useTime = item.useAnimation = 10; diff --git a/Items/Weapons/Summon/VoidConcentrationStaff.cs b/Items/Weapons/Summon/VoidConcentrationStaff.cs new file mode 100644 index 0000000000..f7fc78b653 --- /dev/null +++ b/Items/Weapons/Summon/VoidConcentrationStaff.cs @@ -0,0 +1,66 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + class VoidConcentrationStaff : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Void Concentration Staff"); + Tooltip.SetDefault("Summons a foreboding aura\n" + //If you have flavour text ideas, feel free to implement, my brain is still like nonexistant as per usual yeah. + "Requires three minion slots to use\n" + + "Only one may exist\n" + + "Right click to launch a black hole that grows in size"); + } + + public override void SetDefaults() + { + item.width = 52; + item.height = 72; + item.useStyle = ItemUseStyleID.SwingThrow; + item.noMelee = true; + item.UseSound = SoundID.DD2_EtherianPortalOpen; + item.summon = true; + + item.mana = 100; + item.damage = 150; + item.knockBack = 4f; + item.useTime = item.useAnimation = 10; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 10f; + + item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.PureGreen; + } + + public override bool CanUseItem(Player player) + { + if (player.altFunctionUse != 2) + return player.ownedProjectileCounts[ModContent.ProjectileType()] == 0; + return base.CanUseItem(player); + } + + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) + { + if (player.altFunctionUse != 2) + { + Projectile.NewProjectile(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI, 0f); + player.AddBuff(ModContent.BuffType(), 120); + } + return false; + } + + public override bool AltFunctionUse(Player player) + { + return base.AltFunctionUse(player); + } + } +} diff --git a/Items/Weapons/Summon/VoidConcentrationStaff.png b/Items/Weapons/Summon/VoidConcentrationStaff.png new file mode 100644 index 0000000000..d1cf945db4 Binary files /dev/null and b/Items/Weapons/Summon/VoidConcentrationStaff.png differ diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index d7798bcc38..6274567b3a 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -424,7 +424,7 @@ namespace CalamityMod int summon = ItemType(); List loot = new List() { ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.GreaterHealingPotion }; List collection = new List() { ItemType(), ItemType(), ItemType() }; - string instructions = $"Use an [i:{summon}]"; + string instructions = $"Use a [i:{summon}]"; string despawn = CalamityUtils.ColorMessage("The automaton of misshapen victims went looking for the true perpetrator.", new Color(0xB2, 0x22, 0x22)); string bossLogTex = "CalamityMod/NPCs/Ravager/Ravager_BossChecklist"; AddBoss(bossChecklist, calamity, "Ravager", order, segments, DownedRavager, summon, loot, collection, instructions, despawn, bossLogTex); diff --git a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs index 1b9d7ad58f..b74faf0e5f 100644 --- a/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyAltHuge.cs @@ -1,3 +1,4 @@ +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -55,7 +56,13 @@ namespace CalamityMod.NPCs.Abyss { npc.damage = 0; - if (npc.ai[2] > 0f) + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; // Check if other segments are still alive, if not, die @@ -82,8 +89,8 @@ namespace CalamityMod.NPCs.Abyss CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - float chargePhaseGateValue = 300f; - float lightningChargePhaseGateValue = 180f; + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; @@ -111,7 +118,7 @@ namespace CalamityMod.NPCs.Abyss if (Vector2.Distance(npc.Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) > 160f) { npc.localAI[0] += 1f; - float shootShadowFireballGateValue = 90f; + float shootShadowFireballGateValue = malice ? 60f : death ? 70f : revenge ? 75f : expertMode ? 80f : 90f; float divisor = 2f; if (npc.ai[3] % divisor == 0f && npc.localAI[0] >= shootShadowFireballGateValue) { diff --git a/NPCs/Abyss/EidolonWyrmBodyHuge.cs b/NPCs/Abyss/EidolonWyrmBodyHuge.cs index 8d975e6f76..59a6a68acf 100644 --- a/NPCs/Abyss/EidolonWyrmBodyHuge.cs +++ b/NPCs/Abyss/EidolonWyrmBodyHuge.cs @@ -1,3 +1,4 @@ +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -55,7 +56,13 @@ namespace CalamityMod.NPCs.Abyss { npc.damage = 0; - if (npc.ai[2] > 0f) + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; // Check if other segments are still alive, if not, die @@ -82,8 +89,8 @@ namespace CalamityMod.NPCs.Abyss CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - float chargePhaseGateValue = 300f; - float lightningChargePhaseGateValue = 180f; + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; @@ -111,7 +118,7 @@ namespace CalamityMod.NPCs.Abyss if (Vector2.Distance(npc.Center, Main.player[Main.npc[(int)npc.ai[2]].target].Center) > 160f) { npc.localAI[0] += 1f; - float spawnAncientLightGateValue = 120f; + float spawnAncientLightGateValue = malice ? 90f : death ? 100f : revenge ? 105f : expertMode ? 110f : 120f; float divisor = 4f; if (npc.ai[3] % divisor == 0f && npc.localAI[0] >= spawnAncientLightGateValue) { diff --git a/NPCs/Abyss/EidolonWyrmHead.cs b/NPCs/Abyss/EidolonWyrmHead.cs index ad12776944..c824e17976 100644 --- a/NPCs/Abyss/EidolonWyrmHead.cs +++ b/NPCs/Abyss/EidolonWyrmHead.cs @@ -451,7 +451,19 @@ namespace CalamityMod.NPCs.Abyss return 0f; } - public override void NPCLoot() + public override bool PreNPCLoot() + { + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } + + return !adultWyrmAlive; + } + + public override void NPCLoot() { DropHelper.DropItem(npc, ModContent.ItemType(), 30, 40); if (Main.rand.NextBool(10)) diff --git a/NPCs/Abyss/EidolonWyrmHeadHuge.cs b/NPCs/Abyss/EidolonWyrmHeadHuge.cs index 1e937bdafa..44127460ec 100644 --- a/NPCs/Abyss/EidolonWyrmHeadHuge.cs +++ b/NPCs/Abyss/EidolonWyrmHeadHuge.cs @@ -276,14 +276,14 @@ namespace CalamityMod.NPCs.Abyss // Phase gate values float velocityAdjustTime = 20f; - float chargePhaseGateValue = 300f; - float lightningRainDuration = 180f; - float eidolonWyrmPhaseDuration = 180f; - float iceMistDuration = 180f; - float spinPhaseDuration = 300f; + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningRainDuration = malice ? 150f : 180f; + float eidolonWyrmPhaseDuration = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; + float iceMistDuration = malice ? 150f : 180f; + float spinPhaseDuration = malice ? 210f : death ? 240f : revenge ? 255f : expertMode ? 270f : 300f; float ancientDoomPhaseGateValue = 30f; - float ancientDoomGateValue = 120f; - float lightningChargePhaseGateValue = 180f; + float ancientDoomGateValue = malice ? 80f : death ? 95f : revenge ? 100f : expertMode ? 105f : 120f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; // Adjust slowing debuff immunity bool immuneToSlowingDebuffs = AIState == (float)Phase.FinalPhase || AIState == (float)Phase.ShadowFireballSpin; @@ -365,7 +365,7 @@ namespace CalamityMod.NPCs.Abyss } Vector2 chargeLocation = destination + chargeVector; Vector2 chargeVectorFlipped = chargeVector * -1f; - float chargePredictionAmt = 60f; + float chargePredictionAmt = malice ? 60f : death ? 50f : revenge ? 40f : expertMode ? 30f : 20f; // Lightning Rain variables Vector2 lightningRainLocation = new Vector2(0f, -baseDistance); @@ -374,7 +374,8 @@ namespace CalamityMod.NPCs.Abyss // Wyrm and Eidolist variables Vector2 eidolonWyrmPhaseLocation = new Vector2(0f, baseDistance); float eidolonWyrmPhaseLocationDistance = turnDistance * 0.5f; - int maxEidolists = targetDownDeep ? 3 : 5; + int eidolistScale = malice ? 4 : death ? 3 : revenge ? 2 : expertMode ? 1 : 0; + int maxEidolists = (targetDownDeep ? 3 : 5) + eidolistScale; // Ice Mist variables Vector2 iceMistLocation = new Vector2(0f, baseDistance); @@ -388,8 +389,9 @@ namespace CalamityMod.NPCs.Abyss // Ancient Doom variables Vector2 ancientDoomLocation = new Vector2(0f, -baseDistance); float ancientDoomLocationDistance = turnDistance * 0.2f; - int ancientDoomLimit = targetDownDeep ? 3 : 5; - int ancientDoomDistance = 550; + int ancientDoomScale = malice ? 4 : death ? 3 : revenge ? 2 : expertMode ? 1 : 0; + int ancientDoomLimit = (targetDownDeep ? 4 : 6) + ancientDoomScale; + int ancientDoomDistance = malice ? 480 : death ? 520 : revenge ? 535 : expertMode ? 550 : 600; float maxAncientDoomRings = 3f; // Lightning charge variables @@ -398,13 +400,14 @@ namespace CalamityMod.NPCs.Abyss Vector2 lightningChargeLocation = destination + lightningChargeVector; Vector2 lightningChargeVectorFlipped = lightningChargeVector * -1f; float lightningSpawnY = 540f; - Vector2 lightningSpawnLocation = new Vector2(lightningChargeVector.X, -lightningSpawnY); - int numLightningBolts = 8; + Vector2 lightningSpawnLocation = new Vector2(npc.Center.X, npc.Center.Y - lightningSpawnY); + int numLightningBolts = malice ? 12 : death ? 10 : revenge ? 8 : expertMode ? 6 : 4; float distanceBetweenBolts = lightningSpawnY * 2f / numLightningBolts; // Velocity and turn speed values + float velocityScale = malice ? 4f : death ? 2.5f : revenge ? 2f : expertMode ? 1.5f : 0f; float baseVelocity = targetDownDeep ? 12f : 18f; - float turnSpeed = targetDownDeep ? MathHelper.ToRadians(1.5f) : MathHelper.ToRadians(2.25f); + float turnSpeed = baseVelocity * 0.125f; float normalChargeVelocityMult = MathHelper.Lerp(1f, 2f, chargeVelocityScalar); float normalChargeTurnSpeedMult = MathHelper.Lerp(1f, 8f, chargeVelocityScalar); float invisiblePhaseVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); @@ -548,7 +551,8 @@ namespace CalamityMod.NPCs.Abyss } float predictionAmt = targetDownDeep ? 45f : 60f; - float lightningVelocity = (targetDownDeep && !targetOnMount) ? 6f : 8f; + float lightningVelocityScale = malice ? 3f : death ? 2f : revenge ? 1.5f : expertMode ? 1f : 0f; + float lightningVelocity = ((targetDownDeep && !targetOnMount) ? 6f : 8f) + lightningVelocityScale; for (int i = 0; i < numProjectiles; i++) { // Predictive bolt @@ -864,7 +868,8 @@ namespace CalamityMod.NPCs.Abyss } float predictionAmt = targetDownDeep ? 90f : 120f; - float iceMistVelocity = targetDownDeep ? 12f : 16f; + float iceMistVelocityScale = malice ? 3f : death ? 2f : revenge ? 1.5f : expertMode ? 1f : 0f; + float iceMistVelocity = (targetDownDeep ? 12f : 16f) + iceMistVelocityScale; for (int i = 0; i < numProjectiles; i++) { // Predictive mist @@ -1015,9 +1020,9 @@ namespace CalamityMod.NPCs.Abyss if (aiGateValue % ancientDoomGateValue == 0f) { // Spawn 3 (or more) circles of Ancient Dooms around the target - int ancientDoomScale = (int)(aiGateValue / ancientDoomGateValue); - ancientDoomLimit += ancientDoomScale; - ancientDoomDistance += ancientDoomScale * 45; + int ancientDoomScale2 = (int)(aiGateValue / ancientDoomGateValue); + ancientDoomLimit += ancientDoomScale2; + ancientDoomDistance += ancientDoomScale2 * 45; int ancientDoomDegrees = 360 / ancientDoomLimit; for (int i = 0; i < ancientDoomLimit; i++) { @@ -1099,7 +1104,7 @@ namespace CalamityMod.NPCs.Abyss { Vector2 projectileDestination = player.Center - lightningSpawnLocation; float ai = Main.rand.Next(100); - int proj = Projectile.NewProjectile(lightningSpawnLocation, npc.velocity, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); + int proj = Projectile.NewProjectile(lightningSpawnLocation, npc.velocity * 0.5f, type, damage, 0f, Main.myPlayer, projectileDestination.ToRotation(), ai); Main.projectile[proj].tileCollide = false; lightningSpawnLocation.Y += distanceBetweenBolts; if (i == numLightningBolts / 2) @@ -1213,9 +1218,9 @@ namespace CalamityMod.NPCs.Abyss if (aiGateValue % ancientDoomGateValue == 0f) { // Spawn 3 (or more) circles of Ancient Dooms around the target - int ancientDoomScale = (int)(aiGateValue / ancientDoomGateValue); - ancientDoomLimit += ancientDoomScale; - ancientDoomDistance += ancientDoomScale * 45; + int ancientDoomScale2 = (int)(aiGateValue / ancientDoomGateValue); + ancientDoomLimit += ancientDoomScale2; + ancientDoomDistance += ancientDoomScale2 * 45; int ancientDoomDegrees = 360 / ancientDoomLimit; for (int i = 0; i < ancientDoomLimit; i++) { diff --git a/NPCs/Abyss/EidolonWyrmTailHuge.cs b/NPCs/Abyss/EidolonWyrmTailHuge.cs index f4884a0383..4feebde6d5 100644 --- a/NPCs/Abyss/EidolonWyrmTailHuge.cs +++ b/NPCs/Abyss/EidolonWyrmTailHuge.cs @@ -1,3 +1,4 @@ +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -44,7 +45,13 @@ namespace CalamityMod.NPCs.Abyss { npc.damage = 0; - if (npc.ai[2] > 0f) + // Difficulty modes + bool malice = CalamityWorld.malice; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + if (npc.ai[2] > 0f) npc.realLife = (int)npc.ai[2]; // Check if other segments are still alive, if not, die @@ -71,8 +78,8 @@ namespace CalamityMod.NPCs.Abyss CalamityGlobalNPC calamityGlobalNPC_Head = Main.npc[(int)npc.ai[2]].Calamity(); - float chargePhaseGateValue = 300f; - float lightningChargePhaseGateValue = 180f; + float chargePhaseGateValue = malice ? 120f : death ? 180f : revenge ? 210f : expertMode ? 240f : 300f; + float lightningChargePhaseGateValue = malice ? 90f : death ? 120f : revenge ? 135f : expertMode ? 150f : 180f; bool invisiblePartOfChargePhase = calamityGlobalNPC_Head.newAI[2] >= chargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= chargePhaseGateValue + 1f && (calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeOne || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.ChargeTwo || calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.FastCharge); bool invisiblePartOfLightningChargePhase = calamityGlobalNPC_Head.newAI[2] >= lightningChargePhaseGateValue && calamityGlobalNPC_Head.newAI[2] <= lightningChargePhaseGateValue + 1f && calamityGlobalNPC_Head.newAI[0] == (float)EidolonWyrmHeadHuge.Phase.LightningCharge; diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 1782798cc0..c3b4448cbb 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -354,7 +354,7 @@ namespace CalamityMod.NPCs.AstrumAureus } // Drop an Astral Meteor if applicable - ThreadPool.QueueUserWorkItem(WorldGenerationMethods.AstralMeteorThreadWrapper); + ThreadPool.QueueUserWorkItem(_ => AstralBiome.PlaceAstralMeteor()); // If Astrum Aureus has not yet been killed, notify players of new Astral enemy drops if (!CalamityWorld.downedAstrageldon) diff --git a/NPCs/BrimstoneElemental/Brimling.cs b/NPCs/BrimstoneElemental/Brimling.cs index b8ff7fbce3..e763bc5f72 100644 --- a/NPCs/BrimstoneElemental/Brimling.cs +++ b/NPCs/BrimstoneElemental/Brimling.cs @@ -106,7 +106,7 @@ namespace CalamityMod.NPCs.BrimstoneElemental Vector2 vector251 = Main.player[npc.target].Center - value53; bool flag104 = Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1); npc.localAI[0] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= 360f && Main.npc[CalamityGlobalNPC.brimstoneElemental].ai[0] != 4f) + if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= (CalamityWorld.malice ? 180f : 360f) && Main.npc[CalamityGlobalNPC.brimstoneElemental].ai[0] != 4f) { npc.localAI[0] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index f65507dcf2..25a523621e 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -252,7 +252,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { float velocity = death ? 9.5f : revenge ? 7.5f : 6.5f; - int totalProjectiles = expertMode ? 30 : 20; + int totalProjectiles = malice ? 40 : expertMode ? 30 : 20; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -264,7 +264,7 @@ namespace CalamityMod.NPCs if (phase3) { - int num320 = expertMode ? 14 : 7; + int num320 = malice ? 21 : expertMode ? 14 : 7; type = ModContent.ProjectileType(); damage = npc.GetProjectileDamage(type); for (int num321 = 0; num321 < num320; num321++) @@ -769,7 +769,7 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { npc.localAI[1] += 1f; - if (npc.localAI[1] >= (death ? 150f : 180f)) + if (npc.localAI[1] >= (malice ? 60f : death ? 150f : 180f)) { npc.TargetClosest(); npc.localAI[1] = 0f; @@ -820,7 +820,7 @@ namespace CalamityMod.NPCs Main.dust[dust].noGravity = true; Main.dust[dust].fadeIn = 1f; } - npc.alpha += 2; + npc.alpha += malice ? 4 : 2; if (npc.alpha >= 255) { if (Main.netMode != NetmodeID.MultiplayerClient && NPC.CountNPCS(ModContent.NPCType()) < 2 && revenge) @@ -1465,6 +1465,9 @@ namespace CalamityMod.NPCs else if (npc.timeLeft < 1800) npc.timeLeft = 1800; + // Reset damage from bullet hell phases + npc.damage = npc.defDamage; + // Bullet hell phase if (calamityGlobalNPC.newAI[2] > 0f) { @@ -1540,7 +1543,7 @@ namespace CalamityMod.NPCs if (calamityGlobalNPC.newAI[2] == 2f) { int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int damage = npc.GetProjectileDamage(type) + (provy ? 30 : 0); float gigaBlastFrequency = (expertMode ? 180f : 240f) - enrageScale * 15f; float projSpeed = malice ? 6.25f : 5f; if (calamityGlobalNPC.newAI[3] <= 300f) @@ -1566,28 +1569,28 @@ namespace CalamityMod.NPCs { npc.ai[0] = 0f; int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); + int damage = npc.GetProjectileDamage(type) + (provy ? 30 : 0); float projSpeed = malice ? 5f : 4f; if (calamityGlobalNPC.newAI[3] % (hellblastGateValue * 6f) == 0f) { float distance = Main.rand.NextBool() ? -1000f : 1000f; float velocity = distance == -1000f ? projSpeed : -projSpeed; - Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.position.X + distance, player.position.Y, velocity, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); } if (calamityGlobalNPC.newAI[3] < 300f) // Blasts from above { - Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed, type, damage, 0f, Main.myPlayer, 2f, 0f); } else if (calamityGlobalNPC.newAI[3] < 600f) // Blasts from left and right { - Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 1f, 0f); - Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 0.5f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 0.5f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); } else // Blasts from above, left, and right { - Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 1f, 0f); - Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 1f, 0f); - Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 1f, 0f); + Projectile.NewProjectile(player.position.X + Main.rand.Next(-1000, 1001), player.position.Y - 1000f, 0f, projSpeed - 1f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(player.position.X + 1000f, player.position.Y + Main.rand.Next(-1000, 1001), -(projSpeed - 1f), 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); + Projectile.NewProjectile(player.position.X - 1000f, player.position.Y + Main.rand.Next(-1000, 1001), projSpeed - 1f, 0f, type, damage, 0f, Main.myPlayer, 2f, 0f); } } } @@ -1937,7 +1940,7 @@ namespace CalamityMod.NPCs if (provy) chargeVelocity *= 1.25f; - Vector2 vector = Vector2.Normalize(player.Center - npc.Center); + Vector2 vector = Vector2.Normalize(player.Center + (phase5 && malice ? player.velocity * 20f : Vector2.Zero) - npc.Center); npc.velocity = vector * chargeVelocity; npc.ai[1] = 3f; @@ -2769,8 +2772,8 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.Item, (int)npc.position.X, (int)npc.position.Y, 33); float num179 = death ? 20f : 18.5f; - int maxProjectiles = death ? 6 : 4; - int spread = death ? 60 : 45; + int maxProjectiles = malice ? 8 : death ? 6 : 4; + int spread = malice ? 80 : death ? 60 : 45; if (!phase2) { @@ -2820,7 +2823,7 @@ namespace CalamityMod.NPCs { // If hit or after two seconds start Idle phase npc.ai[1] += 1f; - if (npc.justHit || npc.ai[1] >= 120f) + if (npc.justHit || npc.ai[1] >= 120f || malice) { // Set AI to next phase (Idle) and reset other AI npc.ai[0] = 1f; @@ -2842,7 +2845,7 @@ namespace CalamityMod.NPCs // Stay vulnerable for a maximum of 1.5 or 2.5 seconds npc.ai[1] += 1f; - if (npc.ai[1] >= 120f) + if (npc.ai[1] >= 120f || malice) { // Increase defense npc.defense = npc.defDefense; @@ -2926,7 +2929,7 @@ namespace CalamityMod.NPCs // Walk for a maximum of 6 seconds npc.ai[1] += 1f; - if (npc.ai[1] >= (360f - (death ? 90f * (1f - lifeRatio) : 0f))) + if (npc.ai[1] >= ((malice ? 270f : 360f) - (death ? 90f * (1f - lifeRatio) : 0f))) { // Collide with tiles again npc.noTileCollide = false; @@ -3054,8 +3057,8 @@ namespace CalamityMod.NPCs if (Main.netMode != NetmodeID.MultiplayerClient) { float num179 = death ? 20f : 18.5f; - int maxProjectiles = death ? 6 : 4; - int spread = death ? 60 : 45; + int maxProjectiles = malice ? 12 : death ? 6 : 4; + int spread = malice ? 120 : death ? 60 : 45; Vector2 value9 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num180 = player.position.X + player.width * 0.5f - value9.X; float num181 = Math.Abs(num180) * 0.1f; @@ -3153,7 +3156,7 @@ namespace CalamityMod.NPCs if (phase3) npc.localAI[1] += 1f; - if (npc.localAI[1] >= (240f - (death ? 60f * (1f - lifeRatio) : 0f))) + if (npc.localAI[1] >= ((malice ? 120f : 240f) - (death ? 60f * (1f - lifeRatio) : 0f))) { // Spawn slimes bool spawnFlag = revenge; @@ -4071,6 +4074,9 @@ namespace CalamityMod.NPCs Player player = Main.player[npc.target]; + // Speed enrage + bool moveVeryFast = Vector2.Distance(npc.Center, player.Center) > 960f || (!player.ZoneDungeon && !BossRushEvent.BossRushActive && player.position.Y < Main.worldSurface * 16.0); + // Despawn if (!player.active || player.dead || Vector2.Distance(player.Center, vector) > 5600f) { @@ -4405,10 +4411,8 @@ namespace CalamityMod.NPCs // Basic movement towards a location void Movement(bool succ) { - float velocity = (!player.ZoneDungeon || BossRushEvent.BossRushActive) ? 25f : ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; - float acceleration = malice ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f; - if (!player.ZoneDungeon || BossRushEvent.BossRushActive) - velocity = expertMode ? 25f : 20f; + float velocity = moveVeryFast ? 25f : BossRushEvent.BossRushActive ? 15f : ((expertMode ? 7.5f : 6f) + (float)(death ? 2f * (1D - lifeRatio) : 0f)) * tileEnrageMult; + float acceleration = moveVeryFast ? 0.75f : malice ? 0.3f : death ? 0.2f : expertMode ? 0.16f : 0.12f; // Increase speed dramatically in succ phase if (succ) @@ -5553,7 +5557,6 @@ namespace CalamityMod.NPCs } // Rotation - // Phase switch float rateOfRotation = 0.04f; if (npc.ai[0] == 1f || npc.ai[0] == 6f || npc.ai[0] == 7f || npc.ai[0] == 14f) rateOfRotation = 0f; diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 274b8c4afa..210372c5bd 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -1284,7 +1284,9 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[0] += 1f; if (calamityGlobalNPC.newAI[0] > 3f) calamityGlobalNPC.newAI[0] = 0f; - } + + npc.SyncExtraAI(); + } npc.netUpdate = true; @@ -1370,6 +1372,13 @@ namespace CalamityMod.NPCs bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; + // Causes it to split far more in malice mode + if (malice && (npc.type == NPCID.EaterofWorldsHead || npc.type == NPCID.EaterofWorldsTail)) + { + calamityGlobalNPC.DR = 0.8f; + npc.defense = npc.defDefense * 4; + } + // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) npc.TargetClosest(); @@ -2076,7 +2085,7 @@ namespace CalamityMod.NPCs Main.PlaySound(SoundID.ForceRoar, (int)npc.position.X, (int)npc.position.Y, -1, 1f, 0f); // Velocity - npc.velocity = Vector2.Normalize(Main.player[npc.target].Center - npc.Center) * ((death ? 16f : 14f) + 4f * enrageScale); + npc.velocity = Vector2.Normalize(Main.player[npc.target].Center + (malice ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center) * ((death ? 16f : 14f) + 4f * enrageScale); } } @@ -2678,6 +2687,15 @@ namespace CalamityMod.NPCs npc.buffImmune[BuffID.Slow] = immuneToSlowingDebuffs; npc.buffImmune[BuffID.Webbed] = immuneToSlowingDebuffs; + // Always start in enemy spawning phase + if (calamityGlobalNPC.newAI[3] == 0f) + { + calamityGlobalNPC.newAI[3] = 1f; + npc.ai[0] = 2f; + npc.netUpdate = true; + npc.SyncExtraAI(); + } + if (npc.ai[0] == 5f) { npc.velocity.Y *= 0.98f; @@ -2898,7 +2916,10 @@ namespace CalamityMod.NPCs calamityGlobalNPC.newAI[0] += 1f; if (calamityGlobalNPC.newAI[0] > 90f) + { + npc.SyncExtraAI(); npc.velocity.X *= 1.01f; + } npc.localAI[0] = 1f; return false; @@ -2936,6 +2957,7 @@ namespace CalamityMod.NPCs npc.ai[2] = 0f; npc.ai[1] += 1f; calamityGlobalNPC.newAI[0] = 0f; + npc.SyncExtraAI(); } npc.netUpdate = true; @@ -2967,6 +2989,7 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; calamityGlobalNPC.newAI[0] = 0f; npc.netUpdate = true; + npc.SyncExtraAI(); return false; } @@ -3381,7 +3404,7 @@ namespace CalamityMod.NPCs } bool handsDead = num156 == 0; npc.chaseable = handsDead; - calamityGlobalNPC.DR = 0.05f + num156 * 0.45f; + calamityGlobalNPC.DR = (malice ? 0.45f : 0.05f) + num156 * 0.45f; if (calamityGlobalNPC.DR > 0.95f) calamityGlobalNPC.DR = 0.95f; @@ -4028,7 +4051,7 @@ namespace CalamityMod.NPCs if (phase3) npc.ai[1] += 1f; if (malice) - npc.ai[1] += 2f; + npc.ai[1] += 3f; if (npc.ai[1] > 2700f) npc.ai[2] = 1f; @@ -4176,7 +4199,7 @@ namespace CalamityMod.NPCs float speedMult = 1f; if (malice) - timeBeforeEnrage *= 0.5f; + timeBeforeEnrage *= 0.25f; if (calamityGlobalNPC.newAI[0] < timeBeforeEnrage) { @@ -4228,6 +4251,9 @@ namespace CalamityMod.NPCs } } + if (malice) + speedMult += 0.2f; + if (enraged) speedMult += 0.7f; @@ -4300,7 +4326,7 @@ namespace CalamityMod.NPCs chance *= 2; if (malice) - chance /= 2; + chance /= 4; if (Main.rand.NextBool(chance)) { @@ -5190,7 +5216,7 @@ namespace CalamityMod.NPCs if (npc.justHit) npc.localAI[0] = 0f; - float laserGateValue = malice ? 180f : 240f; + float laserGateValue = malice ? 150f : 240f; if (Main.netMode != NetmodeID.MultiplayerClient && npc.localAI[0] >= laserGateValue) { npc.localAI[0] = 0f; @@ -5933,8 +5959,8 @@ namespace CalamityMod.NPCs { float num399 = 9.5f + (death ? 3f * (0.7f - lifeRatio) : 0f); float num400 = 0.175f + (death ? 0.05f * (0.7f - lifeRatio) : 0f); - num399 += 6f * enrageScale; - num400 += 0.1f * enrageScale; + num399 += 4.5f * enrageScale; + num400 += 0.075f * enrageScale; // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = Main.player[npc.target].inventory[Main.player[npc.target].selectedItem]; @@ -6043,8 +6069,8 @@ namespace CalamityMod.NPCs float num409 = 9.5f + (death ? 3f * (0.7f - lifeRatio) : 0f); float num410 = 0.25f + (death ? 0.075f * (0.7f - lifeRatio) : 0f); - num409 += 6f * enrageScale; - num410 += 0.2f * enrageScale; + num409 += 4.5f * enrageScale; + num410 += 0.15f * enrageScale; // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = Main.player[npc.target].inventory[Main.player[npc.target].selectedItem]; @@ -6176,6 +6202,7 @@ namespace CalamityMod.NPCs chargeTime = spazAlive ? 90f : 60f; if (death) chargeTime -= chargeTime * 0.25f * (0.7f - lifeRatio); + chargeTime -= chargeTime / 5 * enrageScale; // Slow down if (npc.ai[2] >= chargeTime) @@ -6225,8 +6252,10 @@ namespace CalamityMod.NPCs } } - // Charge four times - if (npc.ai[2] >= chargeTime + 30f) + // Charge four times + float chargeGateValue = 30f; + chargeGateValue -= chargeGateValue / 4 * enrageScale; + if (npc.ai[2] >= chargeTime + 30f) { npc.ai[2] = 0f; npc.ai[3] += 1f; @@ -6818,13 +6847,8 @@ namespace CalamityMod.NPCs if (targetFloatingUp) num450 += 2f; - Vector2 vector47 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num451 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector47.X; - float num452 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector47.Y; - float num453 = (float)Math.Sqrt(num451 * num451 + num452 * num452); - num453 = num450 / num453; - npc.velocity.X = num451 * num453; - npc.velocity.Y = num452 * num453; + Vector2 distanceVector = Main.player[npc.target].Center - npc.Center; + npc.velocity = Vector2.Normalize(distanceVector) * num450; npc.ai[1] = 2f; return false; } @@ -6898,19 +6922,18 @@ namespace CalamityMod.NPCs if (npc.ai[2] == -1f || (!retAlive && npc.ai[3] == secondFastCharge)) num48 *= 1.3f; - Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; - float num50 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector10.Y; - float num51 = (float)Math.Sqrt(num49 * num49 + num50 * num50); - float num52 = num51; + Vector2 distanceVector = Main.player[npc.target].Center + (!retAlive && malice ? Main.player[npc.target].velocity * 20f : Vector2.Zero) - npc.Center; + npc.velocity = Vector2.Normalize(distanceVector) * num48; - num51 = num48 / num51; - npc.velocity.X = num49 * num51; - npc.velocity.Y = num50 * num51; - - if (retAlive) + if (retAlive) { - if (num52 < 100f) + Vector2 vector10 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); + float num49 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector10.X; + float num50 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector10.Y; + float num51 = (float)Math.Sqrt(num49 * num49 + num50 * num50); + float num52 = num51; + + if (num52 < 100f) { if (Math.Abs(npc.velocity.X) > Math.Abs(npc.velocity.Y)) { @@ -7277,7 +7300,7 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - int totalProjectiles = malice ? 18 : 12; + int totalProjectiles = malice ? 24 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); @@ -7290,7 +7313,7 @@ namespace CalamityMod.NPCs { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 300; + Main.projectile[proj].timeLeft = 480; } calamityGlobalNPC.newAI[3] += 1f; } @@ -7316,6 +7339,7 @@ namespace CalamityMod.NPCs float rotation = MathHelper.ToRadians(5); if (malice) { + rotation = MathHelper.ToRadians(8); for (int i = 0; i < numProj; i++) { Projectile.NewProjectile(npc.Center, value19.RotatedBy(-rotation * (i + 1)), type, damage, 0f, Main.myPlayer, 0f, 1f); @@ -7338,8 +7362,8 @@ namespace CalamityMod.NPCs npc.rotation = npc.velocity.X / 15f; float velocityY = 3f - (death ? 1f - lifeRatio : 0f); - float velocityX = 7f - (death ? 2f * (1f - lifeRatio) : 0f); - float acceleration = 0.1f + (death ? 0.03f * (1f - lifeRatio) : 0f); + float velocityX = 7f - (death ? 3.5f * (1f - lifeRatio) : 0f); + float acceleration = 0.1f + (death ? 0.05f * (1f - lifeRatio) : 0f); if (!cannonAlive) { @@ -7362,6 +7386,13 @@ namespace CalamityMod.NPCs acceleration += 0.025f; } + if (malice) + { + velocityY = 0.25f; + velocityX = 0.5f; + acceleration = 0.3f; + } + // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = Main.player[npc.target].inventory[Main.player[npc.target].selectedItem]; if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) @@ -7395,7 +7426,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.98f; - npc.velocity.X -= death ? 0.12f : 0.1f; + npc.velocity.X -= acceleration; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -7405,7 +7436,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.98f; - npc.velocity.X += death ? 0.12f : 0.1f; + npc.velocity.X += acceleration; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -7427,10 +7458,7 @@ namespace CalamityMod.NPCs { npc.localAI[1] = 0f; - int totalProjectiles = malice ? 18 : 12; - if (Main.rand.NextBool(2)) - totalProjectiles -= (int)(totalProjectiles * 0.25); - + int totalProjectiles = malice ? 24 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); @@ -7443,7 +7471,7 @@ namespace CalamityMod.NPCs { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = 300; + Main.projectile[proj].timeLeft = 480; } calamityGlobalNPC.newAI[3] += 1f; } @@ -7593,7 +7621,7 @@ namespace CalamityMod.NPCs else { npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocity * -calamityGlobalNPC.newAI[0]); - float skullSpawnDivisor = enraged ? 10f : BossRushEvent.BossRushActive ? 15f : death ? 30f - (float)Math.Round(10f * (1f - lifeRatio)) : 30f; + float skullSpawnDivisor = enraged ? 10f : BossRushEvent.BossRushActive ? 15f : malice ? 20f : death ? 30f - (float)Math.Round(10f * (1f - lifeRatio)) : 30f; if (npc.ai[2] % skullSpawnDivisor == 0f) { calamityGlobalNPC.newAI[1] += 1f; @@ -7621,7 +7649,7 @@ namespace CalamityMod.NPCs int damage = npc.GetProjectileDamage(type); vector16 += value * 5f; int num165 = Projectile.NewProjectile(vector16.X, vector16.Y, num160, num161, type, damage, 0f, Main.myPlayer, -1f, 0f); - Main.projectile[num165].timeLeft = 300; + Main.projectile[num165].timeLeft = 480; Main.projectile[num165].tileCollide = false; } } @@ -7647,86 +7675,51 @@ namespace CalamityMod.NPCs // Fly overhead and spit missiles if (npc.ai[1] == 6f) { - npc.ai[2] += 1f; + npc.damage = 0; npc.rotation = npc.velocity.X / 15f; - float flightVelocity = 10f + (death ? 3f * (1f - lifeRatio) : 0f); - float fligthAcceleration = 0.12f + (death ? 0.4f * (1f - lifeRatio) : 0f); + float flightVelocity = malice ? 25f : 15f + (death ? 5f * (1f - lifeRatio) : 0f); + float flightAcceleration = malice ? 0.25f : 0.15f + (death ? 0.5f * (1f - lifeRatio) : 0f); - // Spit homing missiles and then go to floating phase - Vector2 center = new Vector2(npc.Center.X, npc.Center.Y); - float posX = Main.player[npc.target].Center.X - center.X; - float posY = Main.player[npc.target].Center.Y - center.Y - 500f; + Vector2 destination = new Vector2(Main.player[npc.target].Center.X, Main.player[npc.target].Center.Y - 500f); + npc.SimpleFlyMovement(Vector2.Normalize(destination - npc.Center) * flightVelocity, flightAcceleration); - float distance = (float)Math.Sqrt(posX * posX + posY * posY); - if (distance < 20f) - { - posX = npc.velocity.X; - posY = npc.velocity.Y; - } - else - { - distance = flightVelocity / distance; - posX *= distance; - posY *= distance; - } + // Spit homing missiles and then go to floating phase + if (Vector2.Distance(npc.Center, destination) < 160f || npc.ai[2] > 0f) + { + float missileSpawnDivisor = death ? 12f - (float)Math.Round(4f * (1f - lifeRatio)) : 12f; + npc.ai[2] += 1f; + if (npc.ai[2] % missileSpawnDivisor == 0f) + { + calamityGlobalNPC.newAI[1] += 1f; - if (npc.velocity.X < posX) - { - npc.velocity.X += fligthAcceleration; - if (npc.velocity.X < 0f && posX > 0f) - npc.velocity.X += fligthAcceleration; - } - else if (npc.velocity.X > posX) - { - npc.velocity.X -= fligthAcceleration; - if (npc.velocity.X > 0f && posX < 0f) - npc.velocity.X -= fligthAcceleration; - } - if (npc.velocity.Y < posY) - { - npc.velocity.Y += fligthAcceleration; - if (npc.velocity.Y < 0f && posY > 0f) - npc.velocity.Y += fligthAcceleration; - } - else if (npc.velocity.Y > posY) - { - npc.velocity.Y -= fligthAcceleration; - if (npc.velocity.Y > 0f && posY < 0f) - npc.velocity.Y -= fligthAcceleration; - } + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Vector2 velocity = new Vector2(-1f * (float)Main.rand.NextDouble() * 3f, 1f); + velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * MathHelper.PiOver4); + velocity *= enraged ? 10f : 5f; + int type = ProjectileID.SaucerMissile; + int damage = npc.GetProjectileDamage(type); + float delayBeforeHoming = enraged ? 15f : malice ? 25f : 45f; + Projectile.NewProjectile(npc.Center.X + Main.rand.Next(npc.width / 2), npc.Center.Y + 4f, velocity.X, velocity.Y, type, damage, 0f, Main.myPlayer, 0f, delayBeforeHoming); + } - float missileSpawnDivisor = death ? 12f - (float)Math.Round(4f * (1f - lifeRatio)) : 12f; - if (npc.ai[2] % missileSpawnDivisor == 0f) - { - calamityGlobalNPC.newAI[1] += 1f; + Main.PlaySound(SoundID.Item39, npc.Center); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Vector2 velocity = new Vector2(-1f * (float)Main.rand.NextDouble() * 3f, 1f); - velocity = velocity.RotatedBy((Main.rand.NextDouble() - 0.5) * MathHelper.PiOver4); - velocity *= enraged ? 10f : 5f; - int type = ProjectileID.SaucerMissile; - int damage = npc.GetProjectileDamage(type); - float delayBeforeHoming = enraged ? 15f : malice ? 30f : 45f; - Projectile.NewProjectile(npc.Center.X + Main.rand.Next(npc.width / 2), npc.Center.Y + 4f, velocity.X, velocity.Y, type, damage, 0f, Main.myPlayer, 0f, delayBeforeHoming); - } - - Main.PlaySound(SoundID.Item39, npc.Center); - - if (calamityGlobalNPC.newAI[1] >= 10f) - { - npc.ai[1] = 0f; - npc.ai[2] = 0f; - calamityGlobalNPC.newAI[0] = 0f; - calamityGlobalNPC.newAI[1] = 0f; - npc.localAI[1] = -90f; - npc.localAI[2] = -90f; - npc.TargetClosest(); - npc.netUpdate = true; - } - } + if (calamityGlobalNPC.newAI[1] >= 10f) + { + npc.ai[1] = 0f; + npc.ai[2] = 0f; + calamityGlobalNPC.newAI[0] = 0f; + calamityGlobalNPC.newAI[1] = 0f; + npc.localAI[1] = -90f; + npc.localAI[2] = -90f; + npc.TargetClosest(); + npc.netUpdate = true; + } + } + } } } @@ -7820,15 +7813,15 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - float velocityY = death ? 2f : 2.5f; - float velocityX = death ? 5f : 7f; + float velocityY = malice ? 0.5f : death ? 2f : 2.5f; + float velocityX = malice ? 1f : death ? 5f : 7f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 100f) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= death ? 0.12f : 0.1f; + npc.velocity.Y -= malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -7838,7 +7831,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += death ? 0.12f : 0.1f; + npc.velocity.Y += malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -7849,7 +7842,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= death ? 0.16f : 0.14f; + npc.velocity.X -= malice ? 0.3f : death ? 0.16f : 0.14f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -7859,7 +7852,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += death ? 0.16f : 0.14f; + npc.velocity.X += malice ? 0.3f : death ? 0.16f : 0.14f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -7927,7 +7920,7 @@ namespace CalamityMod.NPCs float num513 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - 320f - vector63.X; float num514 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 160f - vector63.Y; float num515 = (float)Math.Sqrt(num513 * num513 + num514 * num514); - num515 = 7f / num515; + num515 = 9f / num515; num513 *= num515; num514 *= num515; @@ -7935,25 +7928,25 @@ namespace CalamityMod.NPCs { if (npc.velocity.X > 0f) npc.velocity.X *= 0.9f; - npc.velocity.X -= death ? 0.12f : 0.1f; + npc.velocity.X -= malice ? 0.3f : death ? 0.12f : 0.1f; } if (npc.velocity.X < num513) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.9f; - npc.velocity.X += death ? 0.12f : 0.1f; + npc.velocity.X += malice ? 0.3f : death ? 0.12f : 0.1f; } if (npc.velocity.Y > num514) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y -= death ? 0.08f : 0.06f; + npc.velocity.Y -= malice ? 0.3f : death ? 0.08f : 0.06f; } if (npc.velocity.Y < num514) { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y += death ? 0.08f : 0.06f; + npc.velocity.Y += malice ? 0.3f : death ? 0.08f : 0.06f; } vector63 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -7976,11 +7969,11 @@ namespace CalamityMod.NPCs { npc.localAI[0] = 0f; npc.TargetClosest(); - int totalProjectiles = malice ? 18 : 12; + int totalProjectiles = malice ? 24 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ProjectileID.DeathLaser; int damage = npc.GetProjectileDamage(type); - float velocity = enraged ? 8f : malice ? 6.5f : 5f; + float velocity = enraged ? 8f : 5f; double angleA = radians * 0.5; double angleB = MathHelper.ToRadians(90f) - angleA; float velocityX = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); @@ -7989,7 +7982,7 @@ namespace CalamityMod.NPCs { Vector2 vector255 = spinningPoint.RotatedBy(radians * k); int proj = Projectile.NewProjectile(npc.Center, vector255, type, damage, 0f, Main.myPlayer); - Main.projectile[proj].timeLeft = enraged ? 600 : 300; + Main.projectile[proj].timeLeft = enraged ? 600 : 480; } npc.localAI[1] += 1f; } @@ -8120,15 +8113,15 @@ namespace CalamityMod.NPCs if (Main.npc[(int)npc.ai[1]].ai[1] == 3f && npc.timeLeft > 10) npc.timeLeft = 10; - float velocityY = death ? 2f : 2.5f; - float velocityX = death ? 5f : 7f; + float velocityY = malice ? 0.5f : death ? 2f : 2.5f; + float velocityX = malice ? 1f : death ? 5f : 7f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y - 150f) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= death ? 0.1f : 0.08f; + npc.velocity.Y -= malice ? 0.275f : death ? 0.1f : 0.08f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8138,7 +8131,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += death ? 0.1f : 0.08f; + npc.velocity.Y += malice ? 0.275f : death ? 0.1f : 0.08f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8149,7 +8142,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= death ? 0.22f : 0.2f; + npc.velocity.X -= malice ? 0.275f : death ? 0.22f : 0.2f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8159,7 +8152,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += death ? 0.22f : 0.2f; + npc.velocity.X += malice ? 0.275f : death ? 0.22f : 0.2f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8206,7 +8199,7 @@ namespace CalamityMod.NPCs float num500 = Main.npc[(int)npc.ai[1]].position.Y - vector61.Y; num500 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - 160f - vector61.Y; float num501 = (float)Math.Sqrt(num499 * num499 + num500 * num500); - num501 = 7f / num501; + num501 = 9f / num501; num499 *= num501; num500 *= num501; @@ -8214,25 +8207,25 @@ namespace CalamityMod.NPCs { if (npc.velocity.X > 0f) npc.velocity.X *= 0.9f; - npc.velocity.X -= death ? 0.1f : 0.08f; + npc.velocity.X -= malice ? 0.275f : death ? 0.1f : 0.08f; } if (npc.velocity.X < num499) { if (npc.velocity.X < 0f) npc.velocity.X *= 0.9f; - npc.velocity.X += death ? 0.1f : 0.08f; + npc.velocity.X += malice ? 0.275f : death ? 0.1f : 0.08f; } if (npc.velocity.Y > num500) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y -= death ? 0.1f : 0.08f; + npc.velocity.Y -= malice ? 0.275f : death ? 0.1f : 0.08f; } if (npc.velocity.Y < num500) { if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.9f; - npc.velocity.Y += death ? 0.1f : 0.08f; + npc.velocity.Y += malice ? 0.275f : death ? 0.1f : 0.08f; } vector61 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); @@ -8265,6 +8258,7 @@ namespace CalamityMod.NPCs float rotation = MathHelper.ToRadians(5); if (malice) { + rotation = MathHelper.ToRadians(8); for (int i = 0; i < numProj; i++) { Projectile.NewProjectile(npc.Center, value19.RotatedBy(-rotation * (i + 1)), type, damage, 0f, Main.myPlayer, 0f, 1f); @@ -8290,6 +8284,7 @@ namespace CalamityMod.NPCs public static bool BuffedPrimeViceAI(NPC npc, bool enraged, Mod mod) { bool death = CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -8363,15 +8358,15 @@ namespace CalamityMod.NPCs // Return to the head if (npc.ai[2] == 99f) { - float velocityY = death ? 5f : 7f; - float velocityX = death ? 8f : 10f; + float velocityY = malice ? 1f : death ? 5f : 7f; + float velocityX = malice ? 1.5f : death ? 8f : 10f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= death ? 0.12f : 0.1f; + npc.velocity.Y -= malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8381,7 +8376,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += death ? 0.12f : 0.1f; + npc.velocity.Y += malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8392,7 +8387,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= death ? 0.55f : 0.5f; + npc.velocity.X -= malice ? 1f : death ? 0.55f : 0.5f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8402,7 +8397,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += death ? 0.55f : 0.5f; + npc.velocity.X += malice ? 1f : death ? 0.55f : 0.5f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8436,16 +8431,16 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - float velocityY = death ? 2f : 2.5f; - float velocityX = death ? 7f : 8f; - float velocityX2 = death ? 6f : 7f; + float velocityY = malice ? 0.5f : death ? 2f : 2.5f; + float velocityX = malice ? 1.5f : death ? 7f : 8f; + float velocityX2 = malice ? 1.25f : death ? 6f : 7f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 300f) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= death ? 0.12f : 0.1f; + npc.velocity.Y -= malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8455,7 +8450,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += death ? 0.12f : 0.1f; + npc.velocity.Y += malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8466,7 +8461,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.94f; - npc.velocity.X -= death ? 0.33f : 0.3f; + npc.velocity.X -= malice ? 0.8f : death ? 0.33f : 0.3f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8476,7 +8471,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.94f; - npc.velocity.X += death ? 0.22f : 0.2f; + npc.velocity.X += malice ? 0.8f : death ? 0.22f : 0.2f; if (npc.velocity.X < -velocityX2) npc.velocity.X = -velocityX2; @@ -8509,7 +8504,7 @@ namespace CalamityMod.NPCs if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 280f) { - float chargeVelocity = enraged ? 24f : 16f; + float chargeVelocity = enraged ? 24f : malice ? 20f : 16f; if (!cannonAlive) chargeVelocity += 1.5f; if (!laserAlive) @@ -8573,7 +8568,7 @@ namespace CalamityMod.NPCs if (npc.position.X + (npc.width / 2) < Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - 500f || npc.position.X + (npc.width / 2) > Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) + 500f) { - float chargeVelocity = enraged ? 21f : 14f; + float chargeVelocity = enraged ? 21f : malice ? 17.5f : 14f; if (!cannonAlive) chargeVelocity += 1.15f; if (!laserAlive) @@ -8625,6 +8620,7 @@ namespace CalamityMod.NPCs public static bool BuffedPrimeSawAI(NPC npc, bool enraged, Mod mod) { bool death = CalamityWorld.death || BossRushEvent.BossRushActive || CalamityWorld.malice; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; // Get a target if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) @@ -8693,15 +8689,15 @@ namespace CalamityMod.NPCs if (npc.ai[2] == 99f) { - float velocityY = death ? 6f : 7f; - float velocityX = death ? 8f : 10f; + float velocityY = malice ? 1f : death ? 6f : 7f; + float velocityX = malice ? 1.5f : death ? 8f : 10f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= death ? 0.12f : 0.1f; + npc.velocity.Y -= malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8711,7 +8707,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += death ? 0.12f : 0.1f; + npc.velocity.Y += malice ? 0.3f : death ? 0.12f : 0.1f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8722,7 +8718,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= death ? 0.55f : 0.5f; + npc.velocity.X -= malice ? 1.2f : death ? 0.55f : 0.5f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8732,7 +8728,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += death ? 0.55f : 0.5f; + npc.velocity.X += malice ? 1.2f : death ? 0.55f : 0.5f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8762,15 +8758,15 @@ namespace CalamityMod.NPCs npc.netUpdate = true; } - float velocityY = death ? 2f : 2.5f; - float velocityX = death ? 8f : 10f; + float velocityY = malice ? 0.5f : death ? 2f : 2.5f; + float velocityX = malice ? 1.5f : death ? 8f : 10f; if (npc.position.Y > Main.npc[(int)npc.ai[1]].position.Y + 320f) { if (npc.velocity.Y > 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y -= death ? 0.05f : 0.04f; + npc.velocity.Y -= malice ? 0.15f : death ? 0.05f : 0.04f; if (npc.velocity.Y > velocityY) npc.velocity.Y = velocityY; @@ -8780,7 +8776,7 @@ namespace CalamityMod.NPCs if (npc.velocity.Y < 0f) npc.velocity.Y *= 0.96f; - npc.velocity.Y += death ? 0.05f : 0.04f; + npc.velocity.Y += malice ? 0.15f : death ? 0.05f : 0.04f; if (npc.velocity.Y < -velocityY) npc.velocity.Y = -velocityY; @@ -8791,7 +8787,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X > 0f) npc.velocity.X *= 0.96f; - npc.velocity.X -= death ? 0.33f : 0.3f; + npc.velocity.X -= malice ? 0.8f : death ? 0.33f : 0.3f; if (npc.velocity.X > velocityX) npc.velocity.X = velocityX; @@ -8801,7 +8797,7 @@ namespace CalamityMod.NPCs if (npc.velocity.X < 0f) npc.velocity.X *= 0.96f; - npc.velocity.X += death ? 0.33f : 0.3f; + npc.velocity.X += malice ? 0.8f : death ? 0.33f : 0.3f; if (npc.velocity.X < -velocityX) npc.velocity.X = -velocityX; @@ -8828,7 +8824,7 @@ namespace CalamityMod.NPCs if (npc.position.Y < Main.npc[(int)npc.ai[1]].position.Y - 200f) { - float chargeVelocity = enraged ? 33f : 22f; + float chargeVelocity = enraged ? 33f : malice ? 27.5f : 22f; if (!cannonAlive) chargeVelocity += 1.5f; if (!laserAlive) @@ -8859,7 +8855,7 @@ namespace CalamityMod.NPCs { if (npc.ai[2] == 4f) { - float chargeVelocity = enraged ? 16.5f : 11f; + float chargeVelocity = enraged ? 16.5f : malice ? 13.5f : 11f; if (!cannonAlive) chargeVelocity += 1.5f; if (!laserAlive) @@ -8875,7 +8871,7 @@ namespace CalamityMod.NPCs num474 *= num476; num475 *= num476; - float acceleration = death ? 0.06f : 0.05f; + float acceleration = malice ? 0.15f : death ? 0.06f : 0.05f; if (npc.velocity.X > num474) { if (npc.velocity.X > 0f) @@ -9021,21 +9017,27 @@ namespace CalamityMod.NPCs num731 /= num732; // Velocity and acceleration - float velocity = 3f; - float acceleration = 0.03f; + float velocity = 4f; + float acceleration = 0.04f; if (phase3) { - velocity = 6f; - acceleration = 0.055f; + velocity = 6.5f; + acceleration = 0.06f; if (phase4) - velocity = 6.5f; + velocity = 7f; } else if (phase2) { - velocity = 5.5f; - acceleration = 0.055f; + velocity = 6f; + acceleration = 0.06f; } + if (malice) + { + velocity += 2f; + acceleration += 0.02f; + } + // Enrage if target is on the surface if (!BossRushEvent.BossRushActive && (surface || Main.player[npc.target].position.Y > ((Main.maxTilesY - 200) * 16))) { @@ -9233,7 +9235,7 @@ namespace CalamityMod.NPCs projectileType = ModContent.ProjectileType(); projectileVelocity = 3f; } - if (lifeRatio < 0.9f && Main.rand.NextBool(2)) + if (lifeRatio < 0.9f && Main.rand.NextBool(3)) { npc.localAI[1] = -30f; projectileType = ProjectileID.PoisonSeedPlantera; @@ -9347,6 +9349,7 @@ namespace CalamityMod.NPCs int num762 = NPC.NewNPC((int)npc.Center.X, (int)npc.Center.Y, NPCID.Spore); Main.npc[num762].velocity.X = num758; Main.npc[num762].velocity.Y = num760; + Main.npc[num762].dontTakeDamage = malice; Main.npc[num762].netUpdate = true; } } @@ -9373,9 +9376,11 @@ namespace CalamityMod.NPCs { Vector2 vector93 = npc.Center; - float num742 = 8f - ((0.5f - lifeRatio) * 4f); // 8f to 6f, slower projectiles are harder to avoid + float num742 = 8f + ((0.5f - lifeRatio) * 8f); // 8f to 12f if (nearbyActiveTiles < 300) - num742 = 8.5f; + num742 = 12f; + if (malice) + num742 += 4f; float num743 = Main.player[npc.target].position.X + Main.player[npc.target].width * 0.5f - vector93.X; float num744 = Main.player[npc.target].position.Y + Main.player[npc.target].height * 0.5f - vector93.Y; @@ -9407,7 +9412,7 @@ namespace CalamityMod.NPCs else { int numProj = 2; - int spread = 3 + (int)Math.Round((0.5f - lifeRatio) * 14f); // 3 to 10, wider spread is harder to avoid + int spread = 3 + (int)Math.Round((0.5f - lifeRatio) * 10f); // 3 to 8, wider spread is harder to avoid if (nearbyActiveTiles < 300) spread = Main.rand.Next(3, 7) + (int)Math.Round((0.5f - lifeRatio) * 8f); @@ -9453,7 +9458,7 @@ namespace CalamityMod.NPCs int numProj = 4; int spread = 30; if (nearbyActiveTiles <= 300) - spread = Main.rand.NextBool(2) ? 30 : 60; + spread = Main.rand.NextBool(2) ? 45 : 60; float rotation = MathHelper.ToRadians(spread); float baseSpeed = (float)Math.Sqrt(num743 * num743 + num744 * num744); diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index fe3ee4c34a..e0b12307d4 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -1,14 +1,13 @@ using CalamityMod.Buffs; -using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer; using CalamityMod.Dusts; using CalamityMod.Events; -using CalamityMod.Items.Tools; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Tools; using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; using CalamityMod.NPCs.Abyss; using CalamityMod.NPCs.AcidRain; using CalamityMod.NPCs.AquaticScourge; @@ -30,8 +29,8 @@ using CalamityMod.NPCs.Leviathan; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; using CalamityMod.NPCs.Perforator; -using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.PlaguebringerGoliath; +using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.Polterghast; using CalamityMod.NPCs.ProfanedGuardians; using CalamityMod.NPCs.Providence; @@ -43,7 +42,6 @@ using CalamityMod.NPCs.SulphurousSea; using CalamityMod.NPCs.SupremeCalamitas; using CalamityMod.NPCs.Yharon; using CalamityMod.Particles; -using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; @@ -887,7 +885,7 @@ namespace CalamityMod.NPCs if (npc.defense < 0) npc.defense = 0; - int depthDamage = Main.hardMode ? 80 : 12; + int depthDamage = Main.hardMode ? 36 : 12; if (hurtByAbyss) depthDamage = 300; @@ -1884,14 +1882,25 @@ namespace CalamityMod.NPCs { float DRScalar = CalamityWorld.malice ? 2f : (!GetDownedBossVariable(npc.type) || CalamityConfig.Instance.FullPowerReactiveBossDR) ? 1.5f : 1f; - // Boost Providence timed DR during the night, Destroyer, Aquatic Scourge, Astrum Deus, Storm Weaver and DoG body timed DR + // Boost Providence timed DR during the night if (npc.type == NPCType() && !Main.dayTime) DRScalar = 10f; - if ((DestroyerIDs.Contains(npc.type) && !NPC.downedPlantBoss) || (AquaticScourgeIDs.Contains(npc.type) && !NPC.downedPlantBoss) || - (AstrumDeusIDs.Contains(npc.type) && !NPC.downedMoonlord) || (StormWeaverIDs.Contains(npc.type) && !CalamityWorld.downedDoG) || + + // Boost most worm boss timed DR to prevent speed killing + if ((DestroyerIDs.Contains(npc.type) && (!NPC.downedPlantBoss || CalamityWorld.malice)) || + (AquaticScourgeIDs.Contains(npc.type) && (!NPC.downedPlantBoss || CalamityWorld.malice)) || + (AstrumDeusIDs.Contains(npc.type) && (!NPC.downedMoonlord || CalamityWorld.malice)) || + (StormWeaverIDs.Contains(npc.type) && (!CalamityWorld.downedDoG || CalamityWorld.malice)) || ThanatosIDs.Contains(npc.type)) DRScalar = 5f; + // Boost Desert Scourge and Perforator Worm timed DR during Malice Mode to prevent speed killing + if (CalamityWorld.malice) + { + if (DesertScourgeIDs.Contains(npc.type) || PerforatorIDs.Contains(npc.type)) + DRScalar = 5f; + } + // The limit for how much extra DR the boss can have float extraDRLimit = (1f - DR) * DRScalar; @@ -3204,7 +3213,7 @@ namespace CalamityMod.NPCs if (npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType() && - npc.type != NPCType() && npc.type != NPCType() && + npc.type != NPCType() && npc.type != NPCType() && npc.type != NPCType()) { npc.active = false; @@ -3789,8 +3798,12 @@ namespace CalamityMod.NPCs else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) damage = (int)(damage * 0.75); } - else if (npc.type == NPCType()) + else if (npc.type == NPCType()) { + // 30% resist to Surge Driver's alt click comets. + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.7); + // 20% resist to Executioner's Blade stealth strikes. if (projectile.type == ProjectileType()) damage = (int)(damage * 0.8); @@ -3880,16 +3893,20 @@ namespace CalamityMod.NPCs } else if (npc.type == NPCType()) { + // 85% resist to Chicken Cannon. + if (projectile.type == ProjectileType()) + damage = (int)(damage * 0.15); + // 30% resist to Murasama. - if (projectile.type == ProjectileType()) + else if (projectile.type == ProjectileType()) damage = (int)(damage * 0.7); // 25% resist to Yharim's Crystal. else if (projectile.type == ProjectileType()) damage = (int)(damage * 0.75); - // 10% resist to Executioner's Blade stealth strikes. - else if (projectile.type == ProjectileType()) + // 10% resist to Surge Driver's alt click comets and Executioner's Blade stealth strikes. + else if (projectile.type == ProjectileType() || projectile.type == ProjectileType()) damage = (int)(damage * 0.9); } else if (npc.type == NPCID.CultistBoss) diff --git a/NPCs/CalamityGlobalNPCLoot.cs b/NPCs/CalamityGlobalNPCLoot.cs index adb1b20baa..18a75a0f53 100644 --- a/NPCs/CalamityGlobalNPCLoot.cs +++ b/NPCs/CalamityGlobalNPCLoot.cs @@ -17,6 +17,7 @@ using CalamityMod.NPCs.SulphurousSea; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Tiles.Ores; using CalamityMod.World; +using CalamityMod.World.Planets; using Microsoft.Xna.Framework; using System.Threading; using Terraria; @@ -211,8 +212,8 @@ namespace CalamityMod.NPCs { string key3 = "Mods.CalamityMod.HardmodeOreTier1Text"; Color messageColor3 = new Color(50, 255, 130); - WorldGenerationMethods.SpawnOre(TileID.Cobalt, 12E-05, .4f, .6f); - WorldGenerationMethods.SpawnOre(TileID.Palladium, 12E-05, .4f, .6f); + CalamityUtils.SpawnOre(TileID.Cobalt, 12E-05, 0.4f, 0.6f, 3, 8); + CalamityUtils.SpawnOre(TileID.Palladium, 12E-05, 0.4f, 0.6f, 3, 8); CalamityUtils.DisplayLocalizedText(key3, messageColor3); } } @@ -316,7 +317,7 @@ namespace CalamityMod.NPCs string key3 = "Mods.CalamityMod.SandSharkText3"; Color messageColor3 = Color.Goldenrod; - WorldGenerationMethods.SpawnOre(ModContent.TileType(), 12E-05, .5f, .7f); + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.5f, 0.7f, 3, 8, TileID.Dirt, TileID.Stone); CalamityUtils.DisplayLocalizedText(key2, messageColor2); CalamityUtils.DisplayLocalizedText(key3, messageColor3); @@ -499,7 +500,7 @@ namespace CalamityMod.NPCs // This operation is done on a separate thread to lighten the load on servers so that they // can focus on more critical operations asychronously and ideally avoid a time-out crash. // Very few operations in Terraria utilize the pool, so it is highly unlikely that no threads will remain in it. - ThreadPool.QueueUserWorkItem(_ => WorldGenerationMethods.GenerateLuminitePlanetoids()); + ThreadPool.QueueUserWorkItem(_ => LuminitePlanet.GenerateLuminitePlanetoids()); CalamityWorld.HasGeneratedLuminitePlanetoids = true; @@ -605,23 +606,23 @@ namespace CalamityMod.NPCs { string key = "Mods.CalamityMod.HardmodeOreTier2Text"; Color messageColor = new Color(50, 255, 130); - WorldGenerationMethods.SpawnOre(TileID.Mythril, 12E-05, .5f, .7f); - WorldGenerationMethods.SpawnOre(TileID.Orichalcum, 12E-05, .5f, .7f); + CalamityUtils.SpawnOre(TileID.Mythril, 12E-05, 0.5f, 0.7f, 3, 8); + CalamityUtils.SpawnOre(TileID.Orichalcum, 12E-05, 0.5f, 0.7f, 3, 8); CalamityUtils.DisplayLocalizedText(key, messageColor); } else if ((!NPC.downedMechBoss1 && !NPC.downedMechBoss2) || (!NPC.downedMechBoss2 && !NPC.downedMechBoss3) || (!NPC.downedMechBoss3 && !NPC.downedMechBoss1)) { string key = "Mods.CalamityMod.HardmodeOreTier3Text"; Color messageColor = new Color(50, 255, 130); - WorldGenerationMethods.SpawnOre(TileID.Adamantite, 12E-05, .6f, .8f); - WorldGenerationMethods.SpawnOre(TileID.Titanium, 12E-05, .6f, .8f); + CalamityUtils.SpawnOre(TileID.Adamantite, 12E-05, 0.6f, 0.8f, 3, 8); + CalamityUtils.SpawnOre(TileID.Titanium, 12E-05, 0.6f, 0.8f, 3, 8); CalamityUtils.DisplayLocalizedText(key, messageColor); } else { string key = "Mods.CalamityMod.HardmodeOreTier4Text"; Color messageColor = new Color(50, 255, 130); - WorldGenerationMethods.SpawnOre(ModContent.TileType(), 12E-05, .45f, .8f); + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.45f, 0.8f, 3, 8, TileID.Pearlstone, TileID.HallowHardenedSand, TileID.HallowSandstone, TileID.HallowedIce); CalamityUtils.DisplayLocalizedText(key, messageColor); } } @@ -912,6 +913,12 @@ namespace CalamityMod.NPCs DropHelper.DropItemChance(npc, ModContent.ItemType(), amuletDropRate); break; + case NPCID.VampireBat: + case NPCID.Vampire: + float batHookDropRate = Main.expertMode ? 0.05f : 0.025f; + DropHelper.DropItemChance(npc, ItemID.BatHook, batHookDropRate); + break; + case NPCID.SeaSnail: DropHelper.DropItem(npc, ModContent.ItemType()); break; diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index b6b384d4e3..511c049d5b 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -114,7 +114,10 @@ namespace CalamityMod.NPCs "Amber", // <@!114677116473180169> (Mishiro Usui#1295) }; private const int TavernkeepVanillaNames = 16; - private static readonly string[] TavernkeepNames = null; + private static readonly string[] TavernkeepNames = + { + "Tim Lockwood", // <@!605839945483026434> (Deimelo#0001) + }; private const int TaxCollectorVanillaNames = 19; private static readonly string[] TaxCollectorNames = { @@ -1372,4 +1375,4 @@ namespace CalamityMod.NPCs } #endregion } -} \ No newline at end of file +} diff --git a/NPCs/CeaselessVoid/CeaselessVoid.cs b/NPCs/CeaselessVoid/CeaselessVoid.cs index 6e040ed565..3ba094cea9 100644 --- a/NPCs/CeaselessVoid/CeaselessVoid.cs +++ b/NPCs/CeaselessVoid/CeaselessVoid.cs @@ -7,6 +7,7 @@ using CalamityMod.Items.Placeables.Furniture.Trophies; using CalamityMod.Items.Potions; using CalamityMod.Items.TreasureBags; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -172,11 +173,13 @@ namespace CalamityMod.NPCs.CeaselessVoid // Materials DropHelper.DropItem(npc, ModContent.ItemType(), true, 2, 3); - // Weapons - DropHelper.DropItemChance(npc, ModContent.ItemType(), 4); + // Weapons + float dropChance = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropItemChance(npc, ModContent.ItemType(), dropChance); + DropHelper.DropItemChance(npc, ModContent.ItemType(), dropChance); - // Equipment - DropHelper.DropItemChance(npc, ModContent.ItemType(), 2); + // Equipment + DropHelper.DropItemChance(npc, ModContent.ItemType(), 2); // Vanity DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); diff --git a/NPCs/Crabulon/CrabShroom.cs b/NPCs/Crabulon/CrabShroom.cs index fa2a3ea716..bfa9301db0 100644 --- a/NPCs/Crabulon/CrabShroom.cs +++ b/NPCs/Crabulon/CrabShroom.cs @@ -49,7 +49,7 @@ namespace CalamityMod.NPCs.Crabulon Lighting.AddLight((int)((npc.position.X + (npc.width / 2)) / 16f), (int)((npc.position.Y + (npc.height / 2)) / 16f), 0f, 0.2f, 0.4f); bool enraged = npc.Calamity().enraged > 0; bool revenge = CalamityWorld.revenge || BossRushEvent.BossRushActive || CalamityWorld.malice; - float xVelocityLimit = enraged ? 10f : 5f; + float xVelocityLimit = enraged ? 10f : CalamityWorld.malice ? 7.5f : 5f; float yVelocityLimit = revenge ? 1.25f : 1f; Player player = Main.player[npc.target]; npc.velocity.Y += 0.02f; diff --git a/NPCs/Crabulon/CrabulonIdle.cs b/NPCs/Crabulon/CrabulonIdle.cs index 3898ad1aaa..634fbba787 100644 --- a/NPCs/Crabulon/CrabulonIdle.cs +++ b/NPCs/Crabulon/CrabulonIdle.cs @@ -227,7 +227,7 @@ namespace CalamityMod.NPCs.Crabulon Main.dust[sporeDust].noGravity = true; Main.dust[sporeDust].velocity *= 0.5f; npc.ai[1] += 1f; - if (npc.justHit || npc.ai[1] >= 420f) + if (npc.justHit || npc.ai[1] >= 600f) { npc.ai[0] = 1f; npc.ai[1] = 0f; @@ -238,7 +238,7 @@ namespace CalamityMod.NPCs.Crabulon { npc.velocity *= 0.98f; npc.ai[1] += 1f; - if (npc.ai[1] >= (death ? 5f : revenge ? 30f : 60f)) + if (npc.ai[1] >= (death ? 5f : revenge ? 10f : 15f)) { npc.TargetClosest(); npc.noGravity = true; @@ -379,7 +379,7 @@ namespace CalamityMod.NPCs.Crabulon npc.ai[1] += !revenge ? 4f : 1f; } - float jumpGateValue = 300f / (enrageScale + 1f); + float jumpGateValue = (malice ? 90f : 240f) / (enrageScale + 1f); if (npc.ai[1] >= jumpGateValue) { npc.ai[1] = -20f; @@ -461,12 +461,18 @@ namespace CalamityMod.NPCs.Crabulon if (Main.netMode != NetmodeID.MultiplayerClient) { float velocityX = npc.ai[2] == 0f ? -4f : 4f; - for (int x = 0; x < 20; x++) + int totalMushrooms = malice ? 50 : 20; + int shotSpacingDecrement = malice ? 80 : 100; + if (malice) + shotSpacing = 2000; + + for (int x = 0; x < totalMushrooms; x++) { Projectile.NewProjectile(npc.Center.X + shotSpacing, npc.Center.Y - 1000f, velocityX, 0f, type, damage, 0f, Main.myPlayer, 0f, 0f); - shotSpacing -= 100; + shotSpacing -= shotSpacingDecrement; } - shotSpacing = 1000; + + shotSpacing = malice ? 2000 : 1000; } } diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index e7f6f32399..330ed4573a 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -12,6 +12,7 @@ using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Boss; +using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Ores; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -201,7 +202,7 @@ namespace CalamityMod.NPCs.Cryogen if (Main.netMode != NetmodeID.MultiplayerClient && expertMode && (npc.ai[0] < 5f || !phase6)) { time++; - if (time >= 600) + if (time >= (malice ? 480 : 600)) { time = 0; Main.PlaySound(SoundID.Item28, npc.Center); @@ -222,7 +223,9 @@ namespace CalamityMod.NPCs.Cryogen } } - if (npc.ai[0] == 0f) + float chargeGateValue = malice ? 240f : 360f; + + if (npc.ai[0] == 0f) { npc.rotation = npc.velocity.X * 0.1f; @@ -236,7 +239,7 @@ namespace CalamityMod.NPCs.Cryogen if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = 16; + int totalProjectiles = malice ? 24 : 16; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -275,7 +278,7 @@ namespace CalamityMod.NPCs.Cryogen } else if (npc.ai[0] == 1f) { - if (npc.ai[1] < 360f) + if (npc.ai[1] < chargeGateValue) { npc.ai[1] += 1f; @@ -291,7 +294,7 @@ namespace CalamityMod.NPCs.Cryogen if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = 12; + int totalProjectiles = malice ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -353,7 +356,7 @@ namespace CalamityMod.NPCs.Cryogen npc.velocity.X = -velocity; } } - else if (npc.ai[1] < 390f) + else if (npc.ai[1] < chargeGateValue + 30f) { npc.ai[1] += 1f; @@ -366,11 +369,11 @@ namespace CalamityMod.NPCs.Cryogen } else { - if (npc.ai[1] == 390f) + if (npc.ai[1] == chargeGateValue + 30f) { npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); - npc.ai[1] = 450f; + npc.ai[1] = chargeGateValue + 90f; calamityGlobalNPC.newAI[0] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -401,7 +404,7 @@ namespace CalamityMod.NPCs.Cryogen } npc.ai[1] -= 1f; - if (npc.ai[1] == 390f) + if (npc.ai[1] == chargeGateValue + 30f) { npc.TargetClosest(); @@ -410,7 +413,7 @@ namespace CalamityMod.NPCs.Cryogen npc.rotation = npc.velocity.X * 0.1f; } - else if (npc.ai[1] <= 405f) + else if (npc.ai[1] <= chargeGateValue + 45f) { npc.velocity *= 0.95f; npc.rotation = npc.velocity.X * 0.15f; @@ -432,7 +435,7 @@ namespace CalamityMod.NPCs.Cryogen } else if (npc.ai[0] == 2f) { - if (npc.ai[1] < 360f) + if (npc.ai[1] < chargeGateValue) { npc.ai[1] += 1f; @@ -448,7 +451,7 @@ namespace CalamityMod.NPCs.Cryogen if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = 12; + int totalProjectiles = malice ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -477,7 +480,7 @@ namespace CalamityMod.NPCs.Cryogen npc.velocity.X = (npc.velocity.X * 50f + num1243) / 51f; npc.velocity.Y = (npc.velocity.Y * 50f + num1244) / 51f; } - else if (npc.ai[1] < 380f) + else if (npc.ai[1] < chargeGateValue + 20f) { npc.ai[1] += 1f; @@ -490,11 +493,11 @@ namespace CalamityMod.NPCs.Cryogen } else { - if (npc.ai[1] == 380f) + if (npc.ai[1] == chargeGateValue + 20f) { npc.velocity = Vector2.Normalize(player.Center - npc.Center) * (18f + enrageScale * 2f); - npc.ai[1] = 440f; + npc.ai[1] = chargeGateValue + 80f; calamityGlobalNPC.newAI[0] = 0f; if (Main.netMode != NetmodeID.MultiplayerClient) @@ -525,7 +528,7 @@ namespace CalamityMod.NPCs.Cryogen } npc.ai[1] -= 1f; - if (npc.ai[1] == 380f) + if (npc.ai[1] == chargeGateValue + 20f) { npc.TargetClosest(); @@ -539,7 +542,7 @@ namespace CalamityMod.NPCs.Cryogen npc.rotation = npc.velocity.X * 0.1f; } - else if (npc.ai[1] <= 395f) + else if (npc.ai[1] <= chargeGateValue + 35f) { npc.velocity *= 0.95f; npc.rotation = npc.velocity.X * 0.15f; @@ -572,7 +575,7 @@ namespace CalamityMod.NPCs.Cryogen if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) { Main.PlaySound(SoundID.Item28, npc.Center); - int totalProjectiles = 12; + int totalProjectiles = malice ? 18 : 12; float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); @@ -679,7 +682,7 @@ namespace CalamityMod.NPCs.Cryogen float velocity = 9f + enrageScale; for (int i = 0; i < 3; i++) { - int totalProjectiles = 6; + int totalProjectiles = malice ? 9 : 6; float radians = MathHelper.TwoPi / totalProjectiles; float newVelocity = velocity - (velocity * 0.33f * i); float velocityX = 0f; @@ -761,7 +764,7 @@ namespace CalamityMod.NPCs.Cryogen float velocity = 9f + enrageScale; for (int i = 0; i < 4; i++) { - int totalProjectiles = 4; + int totalProjectiles = malice ? 6 : 4; float radians = MathHelper.TwoPi / totalProjectiles; float newVelocity = velocity - (velocity * 0.25f * i); float velocityX = 0f; @@ -853,7 +856,7 @@ namespace CalamityMod.NPCs.Cryogen npc.rotation = npc.velocity.X * 0.1f; time++; - if (time >= 75) + if (time >= (malice ? 50 : 75)) { time = 0; Main.PlaySound(SoundID.Item28, npc.Center); @@ -874,7 +877,7 @@ namespace CalamityMod.NPCs.Cryogen } npc.ai[1] += 1f; - if (npc.ai[1] >= 180f) + if (npc.ai[1] >= (malice ? 120f : 180f)) { npc.TargetClosest(); npc.ai[0] = 4f; @@ -1130,7 +1133,7 @@ namespace CalamityMod.NPCs.Cryogen { string key = "Mods.CalamityMod.IceOreText"; Color messageColor = Color.LightSkyBlue; - WorldGenerationMethods.SpawnOre(ModContent.TileType(), 15E-05, .45f, .65f); + CalamityUtils.SpawnOre(ModContent.TileType(), 15E-05, 0.45f, 0.65f, 3, 8, TileID.SnowBlock, TileID.IceBlock, TileID.CorruptIce, TileID.FleshIce, TileID.HallowedIce, ModContent.TileType(), ModContent.TileType()); CalamityUtils.DisplayLocalizedText(key, messageColor); } diff --git a/NPCs/DesertScourge/DesertScourgeBody.cs b/NPCs/DesertScourge/DesertScourgeBody.cs index c9f31f86b7..b628a2d704 100644 --- a/NPCs/DesertScourge/DesertScourgeBody.cs +++ b/NPCs/DesertScourge/DesertScourgeBody.cs @@ -86,8 +86,8 @@ namespace CalamityMod.NPCs.DesertScourge if (Main.netMode != NetmodeID.MultiplayerClient && revenge && !burrow) { - npc.localAI[0] += (float)Main.rand.Next(4); - if (npc.localAI[0] >= (float)Main.rand.Next(1400, 26001)) + npc.localAI[0] += malice ? 4f : Main.rand.Next(4); + if (npc.localAI[0] >= Main.rand.Next(1400, 26001)) { npc.localAI[0] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 4d65853932..806576b057 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -36,6 +36,7 @@ namespace CalamityMod.NPCs.DesertScourge { npc.Calamity().canBreakPlayerDefense = true; npc.GetNPCDamage(); + npc.defense = 4; npc.npcSlots = 12f; npc.width = 32; npc.height = 80; @@ -145,7 +146,7 @@ namespace CalamityMod.NPCs.DesertScourge if (lungeUpward) { - speed *= 1.5f; + speed *= 1.25f; turnSpeed *= 1.5f; } @@ -274,7 +275,8 @@ namespace CalamityMod.NPCs.DesertScourge float num188 = speed; float num189 = turnSpeed; - float burrowTarget = player.Center.Y + 1000f; + float burrowDistance = malice ? 500f : 750f; + float burrowTarget = player.Center.Y + burrowDistance; float lungeTarget = player.Center.Y - 600f; Vector2 vector18 = npc.Center; float num191 = player.Center.X; diff --git a/NPCs/DesertScourge/DesertScourgeHeadSmall.cs b/NPCs/DesertScourge/DesertScourgeHeadSmall.cs index de064cf9e3..6aff97cd3b 100644 --- a/NPCs/DesertScourge/DesertScourgeHeadSmall.cs +++ b/NPCs/DesertScourge/DesertScourgeHeadSmall.cs @@ -25,10 +25,10 @@ namespace CalamityMod.NPCs.DesertScourge { npc.Calamity().canBreakPlayerDefense = true; npc.GetNPCDamage(); + npc.defense = 2; npc.npcSlots = 2f; npc.width = 60; npc.height = 60; - npc.defense = 0; npc.lifeMax = 800; if (BossRushEvent.BossRushActive) { diff --git a/NPCs/ExoMechs/Ares/AresArmSegment.png b/NPCs/ExoMechs/Ares/AresArmSegment.png new file mode 100644 index 0000000000..120a62d7c5 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresArmSegment.png differ diff --git a/NPCs/ExoMechs/Ares/AresArmSegment_Glow.png b/NPCs/ExoMechs/Ares/AresArmSegment_Glow.png new file mode 100644 index 0000000000..981953b1a8 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresArmSegment_Glow.png differ diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs new file mode 100644 index 0000000000..b61eecbd3b --- /dev/null +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -0,0 +1,660 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Items.Potions; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Ares +{ + //[AutoloadBossHead] + public class AresBody : ModNPC + { + public enum Phase + { + Normal = 0, + Deathrays = 1 + } + + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } + + public enum SecondaryPhase + { + Nothing = 0, + Passive = 1, + PassiveAndImmune = 2 + } + + public float SecondaryAIState + { + get => npc.Calamity().newAI[1]; + set => npc.Calamity().newAI[1] = value; + } + + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; + + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; + + // The exact frame the animation is currently on + private int exactFrame = 0; + + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageDeathrayChargeFrameLimit = 23; + private const int secondStageDeathrayChargeFrameLimit = 35; + private const int finalStageDeathrayChargeFrameLimit = 47; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Max distance from the target before they are unable to hear sound telegraphs + private const float soundDistance = 2800f; + + // Total duration of the deathray telegraph + private const float deathrayTelegraphDuration = 240f; + + // Total duration of the deathrays + private const float deathrayDuration = 600f; + + // Whether or not the other exo mechs have been spawned + private bool otherExoMechsSpawned = false; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XF-09 Ares"); + } + + public override void SetDefaults() + { + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 220; + npc.height = 252; + npc.defense = 100; + npc.DR_NERD(0.35f); + npc.LifeMaxNERB(1000000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; + npc.Opacity = 0f; + npc.knockBackResist = 0f; + npc.value = Item.buyPrice(10, 0, 0, 0); + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + CalamityGlobalNPC.draedonExoMechPrime = npc.whoAmI; + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // Spawn arms + if (npc.ai[0] == 0f) + { + int totalArms = 4; + for (int i = 0; i < totalArms; i++) + { + int lol = 0; + switch (i) + { + case 0: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + case 1: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + case 2: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + case 3: + lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); + break; + default: + break; + } + + Main.npc[lol].realLife = npc.whoAmI; + Main.npc[lol].ai[0] = npc.whoAmI; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, lol, 0f, 0f, 0f, 0); + } + npc.ai[0] = 1f; + } + + // Percent life remaining + float lifeRatio = npc.life / (float)npc.lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoSpazAlive = false; + bool exoRetAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoSpazAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) + { + otherExoMechsAlive++; + exoRetAlive = true; + } + } + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoSpazLifeRatio = defaultLifeRatio; + float exoRetLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoSpazAlive) + exoSpazLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + if (exoRetAlive) + exoRetLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoSpazLifeRatio + exoRetLifeRatio; + + // Check if any of the other mechs are passive + bool exoWormPassive = false; + bool exoSpazPassive = false; + bool exoRetPassive = false; + if (exoWormAlive) + exoWormPassive = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.Passive; + /*if (exoSpazAlive) + exoSpazPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] == (float)Apollo.SecondaryPhase.Passive; + if (exoRetAlive) + exoRetPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] == (float)Artemis.SecondaryPhase.Passive;*/ + bool anyOtherExoMechPassive = exoWormPassive || exoSpazPassive || exoRetPassive; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool spawnOtherExoMechs = lifeRatio > 0.4f && otherExoMechsAlive == 0 && lifeRatio < 0.7f; + + // If Ares doesn't go berserk + bool otherMechIsBerserk = exoWormLifeRatio < 0.4f || exoSpazLifeRatio < 0.4f || exoRetLifeRatio < 0.4f; + + // Get a target + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + npc.TargetClosest(); + + // Despawn safety, make sure to target another player if the current player target is too far away + if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + npc.TargetClosest(); + + // Target variable + Player player = Main.player[npc.target]; + + if (npc.ai[2] > 0f) + npc.realLife = (int)npc.ai[2]; + + // Despawn if target is dead + bool targetDead = false; + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + targetDead = true; + + AIState = (float)Phase.Normal; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + npc.velocity.Y -= 2f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 2f; + + /*if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + }*/ + } + } + + // General AI pattern + // 0 - Fly above target + // 1 - Fly towards the target, slow down when close enough + // 2 - Fire deathrays from telegraph locations to avoid cheap hits and rotate them around for 10 seconds while the plasma and tesla arms fire projectiles to make dodging difficult + // 3 - Go passive and fly above the target while firing less projectiles + // 4 - Go passive, immune and invisible; fly above the target and do nothing until next phase + + // Attack patterns + // If spawned first + // Phase 1 - 0 + // Phase 2 - 4 + // Phase 3 - 3 + + // If berserk, this is the last phase of Ares + // Phase 4 - 1, 2 + + // If not berserk + // Phase 4 - 4 + // Phase 5 - 0 + + // If berserk, this is the last phase of Ares + // Phase 6 - 1, 2 + + // If not berserk + // Phase 6 - 4 + // Phase 7 - 1, 2 + + // Adjust opacity + bool invisiblePhase = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Rotation + npc.rotation = npc.velocity.X * 0.003f; + + // Light + Lighting.AddLight(npc.Center, Main.DiscoR / 255f, Main.DiscoG / 255f, Main.DiscoB / 255f); + + // Default vector to fly to + Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X, player.Center.Y - 800f) : AIState != (float)Phase.Deathrays ? new Vector2(player.Center.X, player.Center.Y - 450f) : player.Center; + + // Velocity and acceleration values + float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; + float baseVelocity = 12f * baseVelocityMult; + float baseAcceleration = 1f; + if (berserk) + { + baseVelocity *= 1.25f; + baseAcceleration *= 1.25f; + } + Vector2 desiredVelocity = Vector2.Normalize(destination - npc.Center) * baseVelocity; + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); + + // Gate values + float deathrayPhaseGateValue = 900f; + float deathrayDistanceGateValue = 480f; + float deathrayPhaseVelocityMult = 0.95f; + + // Passive and Immune phases + switch ((int)SecondaryAIState) + { + case (int)SecondaryPhase.Nothing: + + // Spawn the other mechs if Ares is first + if (otherExoMechsAlive == 0) + { + if (spawnOtherExoMechs) + { + // Reset everything + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.TargetClosest(); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + // Spawn code here + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + // NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + // NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + } + } + else + { + // If not spawned first, go to passive state if any other mech is passive or if Ares is under 70% life + // Do not run this if berserk + // Do not run this if any exo mech is dead + if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) + { + // Tells Ares to return to the battle in passive state and reset everything + SecondaryAIState = (float)SecondaryPhase.Passive; + npc.TargetClosest(); + } + + // Go passive and immune if one of the other mechs is berserk + // This is only called if two exo mechs are alive + if (otherMechIsBerserk) + { + // Reset everything + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.TargetClosest(); + } + } + + break; + + // Fire projectiles less often + case (int)SecondaryPhase.Passive: + + // Enter passive and invincible phase if one of the other exo mechs is berserk + if (otherMechIsBerserk) + { + // Reset everything + SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.TargetClosest(); + } + + // If Ares is the first mech to go berserk + if (berserk) + { + // Reset everything + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + } + + break; + + // Fly above target and become immune + case (int)SecondaryPhase.PassiveAndImmune: + + // Enter the fight again if any of the other exo mechs is below 70% and the other mechs aren't berserk + if ((exoWormLifeRatio < 0.7f || exoSpazLifeRatio < 0.7f || exoRetLifeRatio < 0.7f) && !otherMechIsBerserk) + { + // Tells Ares to return to the battle in passive state and reset everything + // Return to normal phases if one or more mechs have been downed + SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; + npc.TargetClosest(); + } + + if (berserk) + { + // Reset everything + npc.TargetClosest(); + + // Never be passive if berserk + SecondaryAIState = (float)SecondaryPhase.Nothing; + } + + break; + } + + // Attacking phases + switch ((int)AIState) + { + // Fly above the target + case (int)Phase.Normal: + + if (!targetDead) + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + + if (berserk) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] > deathrayPhaseGateValue) + { + calamityGlobalNPC.newAI[2] = 0f; + AIState = (float)Phase.Deathrays; + } + } + + break; + + // Move close to target, reduce velocity when close enough, create telegraph beams, fire deathrays + case (int)Phase.Deathrays: + + if (!targetDead) + { + if (distanceFromTarget > deathrayDistanceGateValue && calamityGlobalNPC.newAI[3] == 0f) + { + Vector2 desiredVelocity2 = Vector2.Normalize(destination - npc.Center) * baseVelocity; + npc.SimpleFlyMovement(desiredVelocity2, baseAcceleration); + } + else + { + calamityGlobalNPC.newAI[3] = 1f; + npc.velocity *= deathrayPhaseVelocityMult; + + int totalProjectiles = 8; + float radians = MathHelper.TwoPi / totalProjectiles; + Vector2 spinningPoint = new Vector2(0f, -1f); + Vector2 laserSpawnPoint = new Vector2(npc.Center.X, npc.Center.Y); + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) + { + // Fire deathray telegraph beams + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Set frames to deathray charge up frames + npc.frameCounter = 0D; + frameX = 1; + frameY = 5; + exactFrame = 12; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + /*int type = ModContent.ProjectileType(); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(laserSpawnPoint, velocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + }*/ + } + } + } + else + { + // Fire deathrays + if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + /*int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(laserSpawnPoint, velocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + }*/ + } + } + } + + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) + { + AIState = (float)Phase.Normal; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.TargetClosest(); + } + } + } + + break; + } + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) => !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) + { + scale = 2f; + return null; + } + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using deathrays + npc.frameCounter += 1D; + if (AIState == (float)Phase.Normal || npc.Calamity().newAI[3] == 0f) + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > normalFrameLimit) + frameX = frameY = exactFrame = 0; + } + } + else + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > finalStageDeathrayChargeFrameLimit) + { + frameX = 4; + frameY = 5; + exactFrame = secondStageDeathrayChargeFrameLimit + 1; + } + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Vector2 center = npc.Center - Main.screenPosition; + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresBodyGlow"); + spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + return false; + } + + public override void BossLoot(ref string name, ref int potionType) + { + potionType = ModContent.ItemType(); + } + + // Needs edits + public override void NPCLoot() + { + /*DropHelper.DropItem(npc, ModContent.ItemType(), 80, 100); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + DropHelper.DropItem(npc, ModContent.ItemType()); + + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas, 1, 50, 108); + DropHelper.DropItemCondition(npc, ModContent.ItemType(), CalamityWorld.downedCalamitas && Main.expertMode, 2, 15, 27); + DropHelper.DropItemCondition(npc, ItemID.Ectoplasm, NPC.downedPlantBoss, 1, 21, 32);*/ + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody4"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody5"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody6"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresBody7"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } + } +} diff --git a/NPCs/ExoMechs/Ares/AresBody.png b/NPCs/ExoMechs/Ares/AresBody.png new file mode 100644 index 0000000000..dc4bb33f62 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresBody.png differ diff --git a/NPCs/ExoMechs/Ares/AresBodyGlow.png b/NPCs/ExoMechs/Ares/AresBodyGlow.png new file mode 100644 index 0000000000..6e644a8fbe Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresBodyGlow.png differ diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs new file mode 100644 index 0000000000..9f71b09e1e --- /dev/null +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -0,0 +1,480 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Items.Potions; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Ares +{ + //[AutoloadBossHead] + public class AresGaussNuke : ModNPC + { + public enum Phase + { + Nothing = 0, + GaussNuke = 1, + Reload = 2 + } + + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } + + // Number of frames on the X and Y axis + private const int maxFramesX = 9; + private const int maxFramesY = 12; + + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; + + // The exact frame the animation is currently on + private int exactFrame = 0; + + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageGaussNukeChargeFrameLimit = 23; + private const int secondStageGaussNukeChargeFrameLimit = 35; + private const int finalStageGaussNukeChargeFrameLimit = 47; + private const int reloadFrameLimit = 107; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Total duration of the gauss nuke telegraph + private const float gaussNukeTelegraphDuration = 360f; + + // Total duration of the gauss nuke firing phase + private const float gaussNukeReloadDuration = 600f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XF-09 Ares Gauss Nuke"); + } + + public override void SetDefaults() + { + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 170; + npc.height = 120; + npc.defense = 80; + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(1000000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; + npc.Opacity = 0f; + npc.knockBackResist = 0f; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoSpazAlive = false; + bool exoRetAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoSpazAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) + { + otherExoMechsAlive++; + exoRetAlive = true; + } + } + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoSpazLifeRatio = defaultLifeRatio; + float exoRetLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoSpazAlive) + exoSpazLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + if (exoRetAlive) + exoRetLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoSpazLifeRatio + exoRetLifeRatio; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + if (npc.ai[0] > 0f) + npc.realLife = (int)npc.ai[0]; + + // Despawn if target is dead + bool targetDead = false; + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + targetDead = true; + + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + npc.velocity.Y -= 2f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 2f; + + /*if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + }*/ + } + } + + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Predictiveness + float predictionAmt = malice ? 30f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; + Vector2 predictionVector = player.velocity * predictionAmt; + Vector2 rotationVector = player.Center + predictionVector - npc.Center; + + float rateOfRotation = AIState == (int)Phase.GaussNuke ? 0.08f : 0.04f; + Vector2 lookAt = player.Center + Vector2.Normalize(rotationVector); + + float rotation = (float)Math.Atan2(lookAt.Y - npc.Center.Y, lookAt.X - npc.Center.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + if (npc.rotation < rotation) + { + if (rotation - npc.rotation > MathHelper.Pi) + npc.rotation -= rateOfRotation; + else + npc.rotation += rateOfRotation; + } + if (npc.rotation > rotation) + { + if (npc.rotation - rotation > MathHelper.Pi) + npc.rotation += rateOfRotation; + else + npc.rotation -= rateOfRotation; + } + + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + if (npc.rotation < 0f) + npc.rotation += MathHelper.TwoPi; + if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + + // Light + Lighting.AddLight(npc.Center, 0.2f, 0.25f, 0.05f); + + // Default vector to fly to + Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + 540f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + 540f) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + 750f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y); + + // Velocity and acceleration values + float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; + float baseVelocity = 15f * baseVelocityMult; + float baseAcceleration = 1f; + if (berserk) + { + baseVelocity *= 1.5f; + baseAcceleration *= 1.5f; + } + Vector2 desiredVelocity = Vector2.Normalize(destination - npc.Center) * baseVelocity; + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); + + // Gate values + float gaussNukePhaseGateValue = 600f; + + // Variable to disable deathray firing + bool doNotFire = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays || calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + if (doNotFire) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Do nothing and fly in place + case (int)Phase.Nothing: + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= gaussNukePhaseGateValue) + { + AIState = (float)Phase.GaussNuke; + calamityGlobalNPC.newAI[1] = 0f; + } + + break; + + // Fire gauss nuke that emits a wave pounder stealth strike-size explosion on death + case (int)Phase.GaussNuke: + + if (!targetDead) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < gaussNukeTelegraphDuration) + { + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Set frames to gauss nuke charge up frames + npc.frameCounter = 0D; + frameX = 1; + frameY = 0; + exactFrame = 12; + } + + // Fire gauss nuke on frame 41 + if (exactFrame == 41 && calamityGlobalNPC.newAI[1] == 0f) + { + calamityGlobalNPC.newAI[1] = 1f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); + float projectileVelocity = 12f; + Vector2 gaussNukeVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center + Vector2.Normalize(gaussNukeVelocity) * 40f, gaussNukeVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f); + + // Recoil + npc.velocity -= gaussNukeVelocity; + } + } + } + else + { + AIState = (float)Phase.Reload; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + // Set frames to gauss nuke reload frames + npc.frameCounter = 0D; + frameX = 4; + frameY = 0; + exactFrame = 48; + } + } + + break; + + case (int)Phase.Reload: + + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= gaussNukeReloadDuration) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + } + + break; + } + + // Movement + if (!targetDead) + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) => !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using gauss nuke + npc.frameCounter += 1D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > normalFrameLimit) + frameX = frameY = exactFrame = 0; + } + } + else + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > reloadFrameLimit) + frameX = frameY = exactFrame = 0; + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Vector2 center = npc.Center - Main.screenPosition; + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresGaussNukeGlow"); + spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + return false; + } + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke3"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } + } +} diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.png b/NPCs/ExoMechs/Ares/AresGaussNuke.png new file mode 100644 index 0000000000..85c7d6b073 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresGaussNuke.png differ diff --git a/NPCs/ExoMechs/Ares/AresGaussNukeGlow.png b/NPCs/ExoMechs/Ares/AresGaussNukeGlow.png new file mode 100644 index 0000000000..c0bfa254f4 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresGaussNukeGlow.png differ diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.cs b/NPCs/ExoMechs/Ares/AresLaserCannon.cs new file mode 100644 index 0000000000..a593f80be6 --- /dev/null +++ b/NPCs/ExoMechs/Ares/AresLaserCannon.cs @@ -0,0 +1,474 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Items.Potions; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Ares +{ + //[AutoloadBossHead] + public class AresLaserCannon : ModNPC + { + public enum Phase + { + Nothing = 0, + Deathray = 1 + } + + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } + + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; + + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; + + // The exact frame the animation is currently on + private int exactFrame = 0; + + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageDeathrayChargeFrameLimit = 23; + private const int secondStageDeathrayChargeFrameLimit = 35; + private const int finalStageDeathrayChargeFrameLimit = 47; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Total duration of the deathray telegraph + private const float deathrayTelegraphDuration = 240f; + + // Total duration of the deathray + private const float deathrayDuration = 60f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XF-09 Ares Laser Cannon"); + } + + public override void SetDefaults() + { + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 154; + npc.height = 90; + npc.defense = 80; + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(1000000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; + npc.Opacity = 0f; + npc.knockBackResist = 0f; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoSpazAlive = false; + bool exoRetAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoSpazAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) + { + otherExoMechsAlive++; + exoRetAlive = true; + } + } + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoSpazLifeRatio = defaultLifeRatio; + float exoRetLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoSpazAlive) + exoSpazLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + if (exoRetAlive) + exoRetLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoSpazLifeRatio + exoRetLifeRatio; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + if (npc.ai[0] > 0f) + npc.realLife = (int)npc.ai[0]; + + // Despawn if target is dead + bool targetDead = false; + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + targetDead = true; + + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + npc.velocity.Y -= 2f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 2f; + + /*if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + }*/ + } + } + + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Rotate the cannon to look at the target while not firing the beam + // Rotate the cannon to look in the direction it will fire only while it's charging or while it's firing + // Rotation + float rateOfRotation = AIState == (int)Phase.Deathray ? 0.08f : 0.04f; + Vector2 lookAt = AIState == (int)Phase.Deathray ? (calamityGlobalNPC.newAI[3] == 0f ? new Vector2(0f, npc.Center.Y + 1000f) : new Vector2(npc.Center.X + 1000f, 0f)) : player.Center; + + float rotation = (float)Math.Atan2(lookAt.Y - npc.Center.Y, lookAt.X - npc.Center.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + if (npc.rotation < rotation) + { + if (rotation - npc.rotation > MathHelper.Pi) + npc.rotation -= rateOfRotation; + else + npc.rotation += rateOfRotation; + } + if (npc.rotation > rotation) + { + if (npc.rotation - rotation > MathHelper.Pi) + npc.rotation += rateOfRotation; + else + npc.rotation -= rateOfRotation; + } + + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + if (npc.rotation < 0f) + npc.rotation += MathHelper.TwoPi; + if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + + // Light + Lighting.AddLight(npc.Center, 0.25f, 0.1f, 0.1f); + + // Default vector to fly to + Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X - 540f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y - 540f) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X - 750f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y); + + // Velocity and acceleration values + float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; + float baseVelocity = 15f * baseVelocityMult; + float baseAcceleration = 1f; + if (berserk) + { + baseVelocity *= 1.5f; + baseAcceleration *= 1.5f; + } + Vector2 desiredVelocity = Vector2.Normalize(destination - npc.Center) * baseVelocity; + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); + + // Gate values + float deathrayPhaseGateValue = 420f; + float deathrayPhaseVelocityMult = 0.95f; + float deathrayDecelerationTime = 15f; + float deathrayPhaseVelocity = 15f; + + // Variable to disable deathray firing + bool doNotFire = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays || calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + if (doNotFire) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Do nothing, rotate to aim at the target and fly in place + case (int)Phase.Nothing: + + if (!targetDead) + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= deathrayPhaseGateValue) + { + AIState = (float)Phase.Deathray; + calamityGlobalNPC.newAI[1] = 0f; + } + + break; + + // Move close to target, reduce velocity when close enough, create telegraph beams, fire deathrays + case (int)Phase.Deathray: + + if (!targetDead) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) + { + // Reduce velocity for 15 frames once charging is nearly complete + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration - deathrayDecelerationTime) + npc.velocity *= deathrayPhaseVelocityMult; + + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Set frames to deathray charge up frames + npc.frameCounter = 0D; + frameX = 1; + frameY = 5; + exactFrame = 12; + } + } + else + { + // Fire deathray + if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) + { + // Two possible variants: 1 - Left to right, 2 - Top to bottom + npc.velocity = calamityGlobalNPC.newAI[3] == 0f ? new Vector2(deathrayPhaseVelocity, 0f) : new Vector2(0f, deathrayPhaseVelocity); + Vector2 laserVelocity = calamityGlobalNPC.newAI[3] == 0f ? Vector2.UnitY : Vector2.UnitX; + + calamityGlobalNPC.newAI[3] += 1f; + if (calamityGlobalNPC.newAI[3] > 1f) + calamityGlobalNPC.newAI[3] = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + /*int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(npc.Center, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + }*/ + } + } + } + + if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + } + } + + break; + } + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) => !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using deathrays + npc.frameCounter += 1D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > normalFrameLimit) + frameX = frameY = exactFrame = 0; + } + } + else + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > finalStageDeathrayChargeFrameLimit) + { + frameX = 4; + frameY = 5; + exactFrame = secondStageDeathrayChargeFrameLimit + 1; + } + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Vector2 center = npc.Center - Main.screenPosition; + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresLaserCannonGlow"); + spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + return false; + } + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresLaserCannon1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresLaserCannon2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } + } +} diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.png b/NPCs/ExoMechs/Ares/AresLaserCannon.png new file mode 100644 index 0000000000..46dad813bc Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresLaserCannon.png differ diff --git a/NPCs/ExoMechs/Ares/AresLaserCannonGlow.png b/NPCs/ExoMechs/Ares/AresLaserCannonGlow.png new file mode 100644 index 0000000000..be549f27bb Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresLaserCannonGlow.png differ diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs new file mode 100644 index 0000000000..8956d070fe --- /dev/null +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -0,0 +1,465 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Items.Potions; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Ares +{ + //[AutoloadBossHead] + public class AresPlasmaFlamethrower : ModNPC + { + public enum Phase + { + Nothing = 0, + PlasmaBolts = 1 + } + + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } + + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; + + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; + + // The exact frame the animation is currently on + private int exactFrame = 0; + + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStagePlasmaBoltChargeFrameLimit = 23; + private const int secondStagePlasmaBoltChargeFrameLimit = 35; + private const int finalStagePlasmaBoltChargeFrameLimit = 47; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Total duration of the plasma bolt telegraph + private const float plasmaBoltTelegraphDuration = 240f; + + // Total duration of the plasma bolt firing phase + private const float plasmaBoltDuration = 120f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XF-09 Ares Plasma Cannon"); + } + + public override void SetDefaults() + { + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 152; + npc.height = 90; + npc.defense = 80; + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(1000000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; + npc.Opacity = 0f; + npc.knockBackResist = 0f; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoSpazAlive = false; + bool exoRetAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoSpazAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) + { + otherExoMechsAlive++; + exoRetAlive = true; + } + } + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoSpazLifeRatio = defaultLifeRatio; + float exoRetLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoSpazAlive) + exoSpazLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + if (exoRetAlive) + exoRetLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoSpazLifeRatio + exoRetLifeRatio; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + if (npc.ai[0] > 0f) + npc.realLife = (int)npc.ai[0]; + + // Despawn if target is dead + bool targetDead = false; + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + targetDead = true; + + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + npc.velocity.Y -= 2f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 2f; + + /*if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + }*/ + } + } + + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Predictiveness + float predictionAmt = malice ? 30f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; + Vector2 predictionVector = player.velocity * predictionAmt; + Vector2 rotationVector = player.Center + predictionVector - npc.Center; + + float rateOfRotation = AIState == (int)Phase.PlasmaBolts ? 0.08f : 0.04f; + Vector2 lookAt = player.Center + Vector2.Normalize(rotationVector); + + float rotation = (float)Math.Atan2(lookAt.Y - npc.Center.Y, lookAt.X - npc.Center.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + if (npc.rotation < rotation) + { + if (rotation - npc.rotation > MathHelper.Pi) + npc.rotation -= rateOfRotation; + else + npc.rotation += rateOfRotation; + } + if (npc.rotation > rotation) + { + if (npc.rotation - rotation > MathHelper.Pi) + npc.rotation += rateOfRotation; + else + npc.rotation -= rateOfRotation; + } + + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + if (npc.rotation < 0f) + npc.rotation += MathHelper.TwoPi; + if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + + // Light + Lighting.AddLight(npc.Center, 0.1f, 0.25f, 0.05f); + + // Default vector to fly to + Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + 540f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y - 540f) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X + 375f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + 160f); + + // Velocity and acceleration values + float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; + float baseVelocity = 15f * baseVelocityMult; + float baseAcceleration = 1f; + if (berserk) + { + baseVelocity *= 1.5f; + baseAcceleration *= 1.5f; + } + Vector2 desiredVelocity = Vector2.Normalize(destination - npc.Center) * baseVelocity; + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); + + // Gate values + bool fireMoreBolts = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; + float plasmaBoltPhaseGateValue = fireMoreBolts ? 90f : 210f; + + // Variable to cancel plasma bolt firing + bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + if (doNotFire) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Do nothing and fly in place + case (int)Phase.Nothing: + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= plasmaBoltPhaseGateValue) + { + AIState = (float)Phase.PlasmaBolts; + calamityGlobalNPC.newAI[1] = 0f; + } + + break; + + // Fire plasma bolts in a double burst that burst into a halo of smaller bolts + case (int)Phase.PlasmaBolts: + + if (!targetDead) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < plasmaBoltTelegraphDuration) + { + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Set frames to plasma bolt charge up frames + npc.frameCounter = 0D; + frameX = 1; + frameY = 5; + exactFrame = 12; + } + } + else + { + // Fire plasma bolts + int numPlasmaBolts = 2; + float divisor = plasmaBoltDuration / numPlasmaBolts; + + if (calamityGlobalNPC.newAI[2] % divisor == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"), npc.Center); + float projectileVelocity = 12f; + Vector2 plasmaBoltVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; + /*int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(npc.Center + Vector2.Normalize(plasmaBoltVelocity) * 40f, plasmaBoltVelocity, type, damage, 0f, Main.myPlayer, 0f, 0f);*/ + } + } + } + + if (calamityGlobalNPC.newAI[2] >= plasmaBoltTelegraphDuration + plasmaBoltDuration) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + } + } + + break; + } + + // Movement + if (!targetDead) + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) => !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using plasma bolts + npc.frameCounter += 1D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > normalFrameLimit) + frameX = frameY = exactFrame = 0; + } + } + else + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > finalStagePlasmaBoltChargeFrameLimit) + { + frameX = 4; + frameY = 5; + exactFrame = secondStagePlasmaBoltChargeFrameLimit + 1; + } + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Vector2 center = npc.Center - Main.screenPosition; + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresPlasmaFlamethrowerGlow"); + spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + return false; + } + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresPlasmaFlamethrower1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresPlasmaFlamethrower2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } + } +} diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.png b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.png new file mode 100644 index 0000000000..a3e922c737 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.png differ diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrowerGlow.png b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrowerGlow.png new file mode 100644 index 0000000000..f3d1061106 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrowerGlow.png differ diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs new file mode 100644 index 0000000000..1656fa4940 --- /dev/null +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -0,0 +1,463 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using CalamityMod.Events; +using CalamityMod.Items.Potions; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.Particles; +using CalamityMod.Projectiles.Boss; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.ExoMechs.Ares +{ + //[AutoloadBossHead] + public class AresTeslaCannon : ModNPC + { + public enum Phase + { + Nothing = 0, + TeslaOrbs = 1 + } + + public float AIState + { + get => npc.Calamity().newAI[0]; + set => npc.Calamity().newAI[0] = value; + } + + // Number of frames on the X and Y axis + private const int maxFramesX = 6; + private const int maxFramesY = 8; + + // Counters for frames on the X and Y axis + private int frameX = 0; + private int frameY = 0; + + // The exact frame the animation is currently on + private int exactFrame = 0; + + // Frame limit per animation, these are the specific frames where each animation ends + private const int normalFrameLimit = 11; + private const int firstStageTeslaOrbChargeFrameLimit = 23; + private const int secondStageTeslaOrbChargeFrameLimit = 35; + private const int finalStageTeslaOrbChargeFrameLimit = 47; + + // Default life ratio for the other mechs + private const float defaultLifeRatio = 5f; + + // Total duration of the tesla orb telegraph + private const float teslaOrbTelegraphDuration = 240f; + + // Total duration of the tesla orb firing phase + private const float teslaOrbDuration = 120f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("XF-09 Ares Tesla Cannon"); + } + + public override void SetDefaults() + { + npc.npcSlots = 5f; + npc.damage = 100; + npc.width = 172; + npc.height = 108; + npc.defense = 80; + npc.DR_NERD(0.25f); + npc.LifeMaxNERB(1000000, 1150000, 500000); + double HPBoost = CalamityConfig.Instance.BossHealthBoost * 0.01; + npc.lifeMax += (int)(npc.lifeMax * HPBoost); + npc.aiStyle = -1; + aiType = -1; + npc.Opacity = 0f; + npc.knockBackResist = 0f; + npc.noGravity = true; + npc.noTileCollide = true; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath14; + npc.netAlways = true; + npc.boss = true; + music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(npc.chaseable); + writer.Write(npc.dontTakeDamage); + for (int i = 0; i < 4; i++) + writer.Write(npc.Calamity().newAI[i]); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + npc.chaseable = reader.ReadBoolean(); + npc.dontTakeDamage = reader.ReadBoolean(); + for (int i = 0; i < 4; i++) + npc.Calamity().newAI[i] = reader.ReadSingle(); + } + + public override void AI() + { + CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + npc.active = false; + return; + } + + // Difficulty modes + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool death = CalamityWorld.death || malice; + bool revenge = CalamityWorld.revenge || malice; + bool expertMode = Main.expertMode || malice; + + // Percent life remaining + float lifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechPrime].lifeMax; + + // Check if the other exo mechs are alive + int otherExoMechsAlive = 0; + bool exoWormAlive = false; + bool exoSpazAlive = false; + bool exoRetAlive = false; + if (CalamityGlobalNPC.draedonExoMechWorm != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechWorm].active) + { + otherExoMechsAlive++; + exoWormAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinGreen != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].active) + { + otherExoMechsAlive++; + exoSpazAlive = true; + } + } + if (CalamityGlobalNPC.draedonExoMechTwinRed != -1) + { + if (Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].active) + { + otherExoMechsAlive++; + exoRetAlive = true; + } + } + + // These are 5 by default to avoid triggering passive phases after the other mechs are dead + float exoWormLifeRatio = defaultLifeRatio; + float exoSpazLifeRatio = defaultLifeRatio; + float exoRetLifeRatio = defaultLifeRatio; + if (exoWormAlive) + exoWormLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechWorm].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechWorm].lifeMax; + if (exoSpazAlive) + exoSpazLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].lifeMax; + if (exoRetAlive) + exoRetLifeRatio = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].life / (float)Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].lifeMax; + float totalOtherExoMechLifeRatio = exoWormLifeRatio + exoSpazLifeRatio + exoRetLifeRatio; + + // Phases + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + + // Target variable + Player player = Main.player[Main.npc[CalamityGlobalNPC.draedonExoMechPrime].target]; + + if (npc.ai[0] > 0f) + npc.realLife = (int)npc.ai[0]; + + // Despawn if target is dead + bool targetDead = false; + if (player.dead) + { + npc.TargetClosest(false); + player = Main.player[npc.target]; + if (player.dead) + { + targetDead = true; + + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + + npc.velocity.Y -= 2f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 2f; + + /*if ((double)npc.position.Y < Main.topWorld + 16f) + { + for (int a = 0; a < Main.maxNPCs; a++) + { + if (Main.npc[a].type == npc.type || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType() || Main.npc[a].type == ModContent.NPCType()) + Main.npc[a].active = false; + } + }*/ + } + } + + CalamityGlobalNPC calamityGlobalNPC_Body = Main.npc[(int)npc.ai[0]].Calamity(); + + // Adjust opacity + bool invisiblePhase = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + npc.dontTakeDamage = invisiblePhase; + if (!invisiblePhase) + { + npc.Opacity += 0.2f; + if (npc.Opacity > 1f) + npc.Opacity = 1f; + } + else + { + npc.Opacity -= 0.05f; + if (npc.Opacity < 0f) + npc.Opacity = 0f; + } + + // Predictiveness + float predictionAmt = malice ? 30f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; + Vector2 predictionVector = player.velocity * predictionAmt; + Vector2 rotationVector = player.Center + predictionVector - npc.Center; + + float rateOfRotation = AIState == (int)Phase.TeslaOrbs ? 0.08f : 0.04f; + Vector2 lookAt = player.Center + Vector2.Normalize(rotationVector); + + float rotation = (float)Math.Atan2(lookAt.Y - npc.Center.Y, lookAt.X - npc.Center.X); + if (npc.spriteDirection == 1) + rotation += MathHelper.Pi; + if (rotation < 0f) + rotation += MathHelper.TwoPi; + if (rotation > MathHelper.TwoPi) + rotation -= MathHelper.TwoPi; + + if (npc.rotation < rotation) + { + if (rotation - npc.rotation > MathHelper.Pi) + npc.rotation -= rateOfRotation; + else + npc.rotation += rateOfRotation; + } + if (npc.rotation > rotation) + { + if (npc.rotation - rotation > MathHelper.Pi) + npc.rotation += rateOfRotation; + else + npc.rotation -= rateOfRotation; + } + + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + if (npc.rotation < 0f) + npc.rotation += MathHelper.TwoPi; + if (npc.rotation > MathHelper.TwoPi) + npc.rotation -= MathHelper.TwoPi; + if (npc.rotation > rotation - rateOfRotation && npc.rotation < rotation + rateOfRotation) + npc.rotation = rotation; + + // Light + Lighting.AddLight(npc.Center, 0.1f, 0.25f, 0.25f); + + // Default vector to fly to + Vector2 destination = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays ? new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X - 540f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + 540f) : new Vector2(Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.X - 375f, Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Center.Y + 160f); + + // Velocity and acceleration values + float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; + float baseVelocity = 15f * baseVelocityMult; + float baseAcceleration = 1f; + if (berserk) + { + baseVelocity *= 1.5f; + baseAcceleration *= 1.5f; + } + Vector2 desiredVelocity = Vector2.Normalize(destination - npc.Center) * baseVelocity; + + // Distance from target + float distanceFromTarget = Vector2.Distance(npc.Center, player.Center); + + // Gate values + bool fireMoreOrbs = calamityGlobalNPC_Body.newAI[0] == (float)AresBody.Phase.Deathrays; + float teslaOrbPhaseGateValue = fireMoreOrbs ? 90f : 210f; + + // Variable to cancel tesla orb firing + bool doNotFire = calamityGlobalNPC_Body.newAI[1] == (float)AresBody.SecondaryPhase.PassiveAndImmune; + if (doNotFire) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + } + + // Attacking phases + switch ((int)AIState) + { + // Do nothing and fly in place + case (int)Phase.Nothing: + + calamityGlobalNPC.newAI[1] += 1f; + if (calamityGlobalNPC.newAI[1] >= teslaOrbPhaseGateValue) + { + AIState = (float)Phase.TeslaOrbs; + calamityGlobalNPC.newAI[1] = 0f; + } + + break; + + // Fire tesla orbs in a quadruple burst that arc electricity between them + case (int)Phase.TeslaOrbs: + + if (!targetDead) + { + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] < teslaOrbTelegraphDuration) + { + if (calamityGlobalNPC.newAI[2] == 1f) + { + // Set frames to tesla orb charge up frames + npc.frameCounter = 0D; + frameX = 1; + frameY = 5; + exactFrame = 12; + } + } + else + { + // Fire tesla orbs + int numTeslaOrbs = 4; + float divisor = teslaOrbDuration / numTeslaOrbs; + + if (calamityGlobalNPC.newAI[2] % divisor == 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float projectileVelocity = 12f; + Vector2 teslaOrbVelocity = Vector2.Normalize(rotationVector) * projectileVelocity; + /*int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type);*/ + } + } + } + + if (calamityGlobalNPC.newAI[2] >= teslaOrbTelegraphDuration + teslaOrbDuration) + { + AIState = (float)Phase.Nothing; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + } + } + + break; + } + + // Movement + if (!targetDead) + npc.SimpleFlyMovement(desiredVelocity, baseAcceleration); + } + + public override bool CanHitPlayer(Player target, ref int cooldownSlot) => false; + + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) => !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); + + public override void FindFrame(int frameHeight) + { + // Use telegraph frames when using tesla orbs + npc.frameCounter += 1D; + if (AIState == (float)Phase.Nothing) + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > normalFrameLimit) + frameX = frameY = exactFrame = 0; + } + } + else + { + if (npc.frameCounter >= 10D) + { + npc.frameCounter = 0D; + frameY++; + exactFrame++; + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + if (exactFrame > finalStageTeslaOrbChargeFrameLimit) + { + frameX = 4; + frameY = 5; + exactFrame = secondStageTeslaOrbChargeFrameLimit + 1; + } + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D texture = Main.npcTexture[npc.type]; + Rectangle frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + Vector2 vector = new Vector2(npc.width / 2, npc.height / 2); + Vector2 center = npc.Center - Main.screenPosition; + spriteBatch.Draw(texture, center, frame, npc.GetAlpha(drawColor), npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + texture = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/Ares/AresTeslaCannonGlow"); + spriteBatch.Draw(texture, center, frame, Color.White * npc.Opacity, npc.rotation, vector, npc.scale, SpriteEffects.None, 0f); + + return false; + } + + public override bool PreNPCLoot() => false; + + public override void HitEffect(int hitDirection, double damage) + { + for (int k = 0; k < 3; k++) + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f); + + if (npc.life <= 0) + { + for (int num193 = 0; num193 < 2; num193++) + { + Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + } + for (int num194 = 0; num194 < 20; num194++) + { + int num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f); + Main.dust[num195].noGravity = true; + Main.dust[num195].velocity *= 3f; + num195 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f); + Main.dust[num195].velocity *= 2f; + Main.dust[num195].noGravity = true; + } + + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresTeslaCannon1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresTeslaCannon2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase1"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase2"), 1f); + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/Ares/AresHandBase3"), 1f); + } + } + + public override bool CheckActive() => false; + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); + npc.damage = (int)(npc.damage * 0.8f); + } + } +} diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.png b/NPCs/ExoMechs/Ares/AresTeslaCannon.png new file mode 100644 index 0000000000..7fcfe38bda Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresTeslaCannon.png differ diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannonGlow.png b/NPCs/ExoMechs/Ares/AresTeslaCannonGlow.png new file mode 100644 index 0000000000..5e38962b26 Binary files /dev/null and b/NPCs/ExoMechs/Ares/AresTeslaCannonGlow.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index d362e877f6..a55a6debb4 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -139,7 +139,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.localAI[2] == 0f) npc.localAI[2] = npc.ai[0]; - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + // Set the AI to become more aggressive if head is berserk + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Deathray) + npc.Calamity().newAI[3] = 1f; + + bool berserk = npc.Calamity().newAI[3] == 1f; + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage || berserk) && calamityGlobalNPC_Head.newAI[2] > 0f; if (shootLasers && !invisiblePhase) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -148,11 +153,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.Calamity().newAI[0] == 0f) npc.ai[3] += 1f; - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge && !berserk) { float divisor = 120f; int numSegments = ThanatosHead.minLength; - double numSegmentsAbleToFire = malice ? 25D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + double numSegmentsAbleToFire = malice ? 30D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); if ((npc.ai[3] % divisor == 0f && npc.localAI[2] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) { @@ -215,11 +220,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { + // This is only used in deathray phase to prevent laser spam + int numSegments = ThanatosHead.minLength; + double numSegmentsAbleToFire = 5D; + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + npc.ai[3] += 1f; float shootProjectile = 120f; float timer = npc.ai[0] + 15f; float divisor = timer + shootProjectile; - if (npc.ai[3] % divisor == 0f || npc.Calamity().newAI[0] > 0f) + if ((npc.ai[3] % divisor == 0f && (npc.localAI[2] % segmentDivisor == 0f || !berserk)) || npc.Calamity().newAI[0] > 0f) { // Body is vulnerable while firing lasers vulnerable = true; @@ -256,7 +266,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } - float predictionAmt = malice ? 40f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; + float predictionAmt = malice ? 30f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); @@ -270,6 +280,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { + // Normal laser + if (malice && berserk) + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + // Predictive laser Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); @@ -332,6 +346,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos SmokeDrawer.ParticleSpawnRate = 9999999; if (vulnerable) { + // Light + Lighting.AddLight(npc.Center, 0.35f, 0.05f, 0.05f); + // Noise float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; if (npc.localAI[0] == 0f) @@ -346,7 +363,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } else + { + // Light + Lighting.AddLight(npc.Center, 0.05f, 0.2f, 0.2f); + npc.localAI[0] = 0f; + } SmokeDrawer.Update(); @@ -430,7 +452,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { if (npc.Calamity().newAI[1] == 0f && npc.Calamity().newAI[0] > 0f) { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y += frameHeight; npc.frameCounter = 0D; @@ -441,7 +463,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y -= frameHeight; npc.frameCounter = 0D; @@ -452,7 +474,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y -= frameHeight; npc.frameCounter = 0D; @@ -521,20 +543,5 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (npc.Opacity == 1f) - { - int duration = vulnerable ? 120 : 60; - player.AddBuff(BuffID.Ichor, duration); - player.AddBuff(BuffID.CursedInferno, duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(BuffID.Frostburn, duration); - player.AddBuff(BuffID.OnFire, duration); - } - } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow.png b/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow.png index cfa0941d35..74f921332d 100644 Binary files a/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow.png and b/NPCs/ExoMechs/Thanatos/ThanatosBody1Glow.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 83fb0b7418..9639c99d89 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -139,7 +139,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.localAI[2] == 0f) npc.localAI[2] = npc.ai[0]; - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + // Set the AI to become more aggressive if head is berserk + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Deathray) + npc.Calamity().newAI[3] = 1f; + + bool berserk = npc.Calamity().newAI[3] == 1f; + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage || berserk) && calamityGlobalNPC_Head.newAI[2] > 0f; if (shootLasers && !invisiblePhase) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -148,11 +153,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.Calamity().newAI[0] == 0f) npc.ai[3] += 1f; - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge && !berserk) { float divisor = 120f; int numSegments = ThanatosHead.minLength; - double numSegmentsAbleToFire = malice ? 25D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + double numSegmentsAbleToFire = malice ? 30D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); if ((npc.ai[3] % divisor == 0f && npc.localAI[2] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) { @@ -215,11 +220,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { + // This is only used in deathray phase to prevent laser spam + int numSegments = ThanatosHead.minLength; + double numSegmentsAbleToFire = 5D; + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + npc.ai[3] += 1f; float shootProjectile = 120f; float timer = npc.ai[0] + 15f; float divisor = timer + shootProjectile; - if (npc.ai[3] % divisor == 0f || npc.Calamity().newAI[0] > 0f) + if ((npc.ai[3] % divisor == 0f && (npc.localAI[2] % segmentDivisor == 0f || !berserk)) || npc.Calamity().newAI[0] > 0f) { // Body is vulnerable while firing lasers vulnerable = true; @@ -256,7 +266,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } - float predictionAmt = malice ? 40f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; + float predictionAmt = malice ? 30f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); @@ -270,6 +280,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { + // Normal laser + if (malice && berserk) + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + // Predictive laser Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); @@ -332,6 +346,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos SmokeDrawer.ParticleSpawnRate = 9999999; if (vulnerable) { + // Light + Lighting.AddLight(npc.Center, 0.35f, 0.05f, 0.05f); + // Noise float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; if (npc.localAI[0] == 0f) @@ -346,7 +363,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } else + { + // Light + Lighting.AddLight(npc.Center, 0.05f, 0.2f, 0.2f); + npc.localAI[0] = 0f; + } SmokeDrawer.Update(); @@ -430,7 +452,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { if (npc.Calamity().newAI[1] == 0f && npc.Calamity().newAI[0] > 0f) { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y += frameHeight; npc.frameCounter = 0D; @@ -441,7 +463,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y -= frameHeight; npc.frameCounter = 0D; @@ -452,7 +474,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y -= frameHeight; npc.frameCounter = 0D; @@ -521,20 +543,5 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (npc.Opacity == 1f) - { - int duration = vulnerable ? 120 : 60; - player.AddBuff(BuffID.Ichor, duration); - player.AddBuff(BuffID.CursedInferno, duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(BuffID.Frostburn, duration); - player.AddBuff(BuffID.OnFire, duration); - } - } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow.png b/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow.png index 8fea258abe..34dc02d5b3 100644 Binary files a/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow.png and b/NPCs/ExoMechs/Thanatos/ThanatosBody2Glow.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index 1c77ac9bb2..7fcd784d52 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Events; using CalamityMod.Items.Potions; +using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.Particles; using CalamityMod.Projectiles.Boss; using CalamityMod.World; @@ -85,7 +86,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Total duration of the deathray private const float deathrayDuration = 180f; - + public override void SetStaticDefaults() { DisplayName.SetDefault("XM-05 Thanatos"); @@ -210,18 +211,17 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos bool exoPrimePassive = false; bool exoSpazPassive = false; bool exoRetPassive = false; - /*if (exoPrimeAlive) - exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].newAI[1] == (float)AresBody.SecondaryPhase.Passive; - if (exoSpazAlive) - exoSpazPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].newAI[1] == (float)Apollo.SecondaryPhase.Passive; + if (exoPrimeAlive) + exoPrimePassive = Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[1] == (float)AresBody.SecondaryPhase.Passive; + /*if (exoSpazAlive) + exoSpazPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinGreen].Calamity().newAI[1] == (float)Apollo.SecondaryPhase.Passive; if (exoRetAlive) - exoRetPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].newAI[1] == (float)Artemis.SecondaryPhase.Passive;*/ + exoRetPassive = Main.npc[CalamityGlobalNPC.draedonExoMechTwinRed].Calamity().newAI[1] == (float)Artemis.SecondaryPhase.Passive;*/ bool anyOtherExoMechPassive = exoPrimePassive || exoSpazPassive || exoRetPassive; // Phases - bool lessThan70PercentLife = lifeRatio < 0.7f; - bool phase2 = lessThan70PercentLife && otherExoMechsAlive <= 1; - bool berserk = lifeRatio < 0.4f || totalOtherExoMechLifeRatio > 3f; + bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); + bool spawnOtherExoMechs = lifeRatio > 0.4f && otherExoMechsAlive == 0 && lifeRatio < 0.7f; // Set vulnerable to false by default vulnerable = false; @@ -288,11 +288,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos calamityGlobalNPC.newAI[3] = 0f; chargeVelocityScalar = 0f; - npc.velocity.Y += 2f; - if (npc.position.Y > Main.worldSurface * 16.0) - npc.velocity.Y += 2f; + npc.velocity.Y -= 2f; + if ((double)npc.position.Y < Main.topWorld + 16f) + npc.velocity.Y -= 2f; - if (npc.position.Y > Main.rockLayer * 16.0) + if ((double)npc.position.Y < Main.topWorld + 16f) { for (int a = 0; a < Main.maxNPCs; a++) { @@ -304,11 +304,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } // General AI pattern - // Fly towards the target for 7 seconds, gradually speeding up for the first 5 seconds and slowing down for the last 2 seconds, fire lasers from segments that are venting - // Fly underneath the target and fire barrages of lasers - // Fire deathray from mouth with a telegraph similar to the railgun from enter the gungeon, turn speed is very low during this to avoid cheap hits - // Go passive and fly underneath the target while firing lasers - // Go passive, immune and invisible; fly far underneath the target and do nothing until next phase + // 0 - Fly towards the target for 7 seconds, gradually speeding up for the first 5 seconds and slowing down for the last 2 seconds, fire lasers from segments that are venting + // 1 - Fly underneath the target and fire barrages of lasers + // 2 - Fire deathray from mouth with a telegraph similar to the railgun from enter the gungeon, turn speed is very low during this to avoid cheap hits + // 3 - Go passive and fly underneath the target while firing lasers + // 4 - Go passive, immune and invisible; fly far underneath the target and do nothing until next phase // Attack patterns // If spawned first @@ -335,7 +335,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos float speedUpTime = berserk ? 360f : 480f; float slowDownTime = berserk ? 90f : 120f; float chargePhaseGateValue = speedUpTime + slowDownTime; - float laserBarrageDuration = berserk ? 330f : 420f; // Adjust opacity @@ -378,8 +377,8 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos float turnDegrees = baseVelocity * 0.11f; if (berserk) { - baseVelocity *= 1.25f; - turnDegrees *= 1.25f; + baseVelocity *= 1.5f; + turnDegrees *= 1.5f; } float turnSpeed = MathHelper.ToRadians(turnDegrees); float chargeVelocityMult = MathHelper.Lerp(1f, 1.5f, chargeVelocityScalar); @@ -411,7 +410,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Spawn the other mechs if Thanatos is first if (otherExoMechsAlive == 0) { - if (phase2 && !berserk) + if (spawnOtherExoMechs) { // Reset everything SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; @@ -425,6 +424,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (Main.netMode != NetmodeID.MultiplayerClient) { // Spawn code here + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + // NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + // NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); } } } @@ -433,7 +435,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // If not spawned first, go to passive state if any other mech is passive or if Thanatos is under 70% life // Do not run this if berserk // Do not run this if any exo mech is dead - if ((anyOtherExoMechPassive || lessThan70PercentLife) && !berserk && totalOtherExoMechLifeRatio < 5f) + if ((anyOtherExoMechPassive || lifeRatio < 0.7f) && !berserk && totalOtherExoMechLifeRatio < 5f) { // Tells Thanatos to return to the battle in passive state and reset everything SecondaryAIState = (float)SecondaryPhase.Passive; @@ -614,7 +616,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos calamityGlobalNPC.newAI[3] += 1f; if (calamityGlobalNPC.newAI[3] >= velocityAdjustTime) { - npc.localAI[0] = (berserk || otherExoMechsAlive == 0) ? 1f : 0f; + npc.localAI[0] = berserk ? 1f : 0f; AIState = (float)Phase.Charge; calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; @@ -675,10 +677,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos baseVelocity *= velocityScale; turnSpeed *= velocityScale; + calamityGlobalNPC.newAI[2] += 1f; if (calamityGlobalNPC.newAI[2] < deathrayTelegraphDuration) { // Fire deathray telegraph beams - if (calamityGlobalNPC.newAI[2] == 0f) + if (calamityGlobalNPC.newAI[2] == 1f) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -728,7 +731,6 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos chargeVelocityScalar = 0f; npc.TargetClosest(); } - calamityGlobalNPC.newAI[2] += 1f; } break; @@ -748,6 +750,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos SmokeDrawer.ParticleSpawnRate = 9999999; if (vulnerable) { + // Light + Lighting.AddLight(npc.Center, 0.35f, 0.05f, 0.05f); + // Noise if (npc.localAI[1] == 0f) Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/ThanatosVent"), npc.Center); @@ -761,7 +766,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } else + { + // Light + Lighting.AddLight(npc.Center, 0.05f, 0.2f, 0.2f); + npc.localAI[1] = 0f; + } SmokeDrawer.Update(); @@ -831,7 +841,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.frameCounter += 1D; if (AIState == (float)Phase.Charge || AIState == (float)Phase.UndergroundLaserBarrage) { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y -= frameHeight; npc.frameCounter = 0D; @@ -841,7 +851,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y += frameHeight; npc.frameCounter = 0D; @@ -925,21 +935,5 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (npc.Opacity == 1f) - { - int duration = vulnerable ? 180 : 90; - player.AddBuff(BuffID.Ichor, duration); - player.AddBuff(BuffID.CursedInferno, duration); - player.AddBuff(ModContent.BuffType(), duration / 4); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(BuffID.Frostburn, duration); - player.AddBuff(BuffID.OnFire, duration); - } - } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow.png b/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow.png index b4a0e95b3b..477da0aa63 100644 Binary files a/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow.png and b/NPCs/ExoMechs/Thanatos/ThanatosHeadGlow.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index 1d3724bd5b..ecccdec52b 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -138,7 +138,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.localAI[2] == 0f) npc.localAI[2] = npc.ai[0]; - bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage) && calamityGlobalNPC_Head.newAI[2] > 0f; + // Set the AI to become more aggressive if head is berserk + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Deathray) + npc.Calamity().newAI[3] = 1f; + + bool berserk = npc.Calamity().newAI[3] == 1f; + bool shootLasers = (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge || calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.UndergroundLaserBarrage || berserk) && calamityGlobalNPC_Head.newAI[2] > 0f; if (shootLasers && !invisiblePhase) { if (Main.netMode != NetmodeID.MultiplayerClient) @@ -147,11 +152,11 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.Calamity().newAI[0] == 0f) npc.ai[3] += 1f; - if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge) + if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge && !berserk) { float divisor = 120f; int numSegments = ThanatosHead.minLength; - double numSegmentsAbleToFire = malice ? 25D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + double numSegmentsAbleToFire = malice ? 30D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); if ((npc.ai[3] % divisor == 0f && npc.localAI[2] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) { @@ -214,11 +219,16 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { + // This is only used in deathray phase to prevent laser spam + int numSegments = ThanatosHead.minLength; + double numSegmentsAbleToFire = 5D; + float segmentDivisor = (float)Math.Round(numSegments / numSegmentsAbleToFire); + npc.ai[3] += 1f; float shootProjectile = 120f; float timer = npc.ai[0] + 15f; float divisor = timer + shootProjectile; - if (npc.ai[3] % divisor == 0f || npc.Calamity().newAI[0] > 0f) + if ((npc.ai[3] % divisor == 0f && (npc.localAI[2] % segmentDivisor == 0f || !berserk)) || npc.Calamity().newAI[0] > 0f) { // Body is vulnerable while firing lasers vulnerable = true; @@ -255,7 +265,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } - float predictionAmt = malice ? 40f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; + float predictionAmt = malice ? 30f : death ? 25f : revenge ? 20f : expertMode ? 15f : 5f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); @@ -269,6 +279,10 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { + // Normal laser + if (malice && berserk) + Projectile.NewProjectile(npc.Center, targetCenterArray[i], type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); + // Predictive laser Vector2 projectileDestination = targetCenterArray[i] + Main.player[whoAmIArray[i]].velocity * predictionAmt; Projectile.NewProjectile(npc.Center, projectileDestination, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); @@ -331,6 +345,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos SmokeDrawer.ParticleSpawnRate = 9999999; if (vulnerable) { + // Light + Lighting.AddLight(npc.Center, 0.35f, 0.05f, 0.05f); + // Noise float volume = calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge ? 0.1f : 1f; if (npc.localAI[0] == 0f) @@ -345,7 +362,12 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } } else + { + // Light + Lighting.AddLight(npc.Center, 0.05f, 0.2f, 0.2f); + npc.localAI[0] = 0f; + } SmokeDrawer.Update(); @@ -429,7 +451,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos { if (npc.Calamity().newAI[1] == 0f && npc.Calamity().newAI[0] > 0f) { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y += frameHeight; npc.frameCounter = 0D; @@ -440,7 +462,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y -= frameHeight; npc.frameCounter = 0D; @@ -451,7 +473,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos } else { - if (npc.frameCounter >= 12D) + if (npc.frameCounter >= 10D) { npc.frame.Y -= frameHeight; npc.frameCounter = 0D; @@ -521,20 +543,5 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * npc.GetExpertDamageMultiplier()); } - - public override void OnHitPlayer(Player player, int damage, bool crit) - { - if (npc.Opacity == 1f) - { - int duration = vulnerable ? 60 : 30; - player.AddBuff(BuffID.Ichor, duration); - player.AddBuff(BuffID.CursedInferno, duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(ModContent.BuffType(), duration); - player.AddBuff(BuffID.Frostburn, duration); - player.AddBuff(BuffID.OnFire, duration); - } - } } } diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTailGlow.png b/NPCs/ExoMechs/Thanatos/ThanatosTailGlow.png index 54a5e2ecaf..8e758d699b 100644 Binary files a/NPCs/ExoMechs/Thanatos/ThanatosTailGlow.png and b/NPCs/ExoMechs/Thanatos/ThanatosTailGlow.png differ diff --git a/NPCs/HiveMind/HiveMindP2.cs b/NPCs/HiveMind/HiveMindP2.cs index fc85ac2df0..dc13438e9b 100644 --- a/NPCs/HiveMind/HiveMindP2.cs +++ b/NPCs/HiveMind/HiveMindP2.cs @@ -537,7 +537,7 @@ namespace CalamityMod.NPCs.HiveMind if (phase2timer <= 0) { phase2timer = lungeTime - 4 * (int)enrageScale; - npc.velocity = player.Center - npc.Center; + npc.velocity = player.Center + (malice ? player.velocity * 20f : Vector2.Zero) - npc.Center; npc.velocity.Normalize(); npc.velocity *= teleportRadius / (lungeTime - (int)enrageScale); dashStarted = true; @@ -799,7 +799,7 @@ namespace CalamityMod.NPCs.HiveMind { string key = "Mods.CalamityMod.SkyOreText"; Color messageColor = Color.Cyan; - WorldGenerationMethods.SpawnOre(ModContent.TileType(), 12E-05, .4f, .6f); + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.4f, 0.6f, 3, 8); CalamityUtils.DisplayLocalizedText(key, messageColor); } diff --git a/NPCs/NormalNPCs/Eidolist.cs b/NPCs/NormalNPCs/Eidolist.cs index 922081c5e2..d34ac6c102 100644 --- a/NPCs/NormalNPCs/Eidolist.cs +++ b/NPCs/NormalNPCs/Eidolist.cs @@ -311,7 +311,19 @@ namespace CalamityMod.NPCs.NormalNPCs } } - public override void NPCLoot() + public override bool PreNPCLoot() + { + bool adultWyrmAlive = false; + if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) + { + if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) + adultWyrmAlive = true; + } + + return !adultWyrmAlive; + } + + public override void NPCLoot() { if (Main.rand.NextBool(10)) { diff --git a/NPCs/NormalNPCs/MantisShrimp.cs b/NPCs/NormalNPCs/MantisShrimp.cs index d90e8276de..1b5483f5bb 100644 --- a/NPCs/NormalNPCs/MantisShrimp.cs +++ b/NPCs/NormalNPCs/MantisShrimp.cs @@ -93,10 +93,9 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) - { + if (spawnInfo.playerSafe || !Main.hardMode || spawnInfo.player.Calamity().ZoneSulphur) return 0f; - } + return SpawnCondition.OceanMonster.Chance * 0.2f; } diff --git a/NPCs/NormalNPCs/WulfrumDrone.cs b/NPCs/NormalNPCs/WulfrumDrone.cs index eea07039dc..3de37e340d 100644 --- a/NPCs/NormalNPCs/WulfrumDrone.cs +++ b/NPCs/NormalNPCs/WulfrumDrone.cs @@ -77,14 +77,14 @@ namespace CalamityMod.NPCs.NormalNPCs Player player = Main.player[npc.target]; - bool farFromPlayer = npc.Distance(player.Center) > 640f; + bool farFromPlayer = npc.Distance(player.Center) > 920f; bool obstanceInFrontOfPlayer = !Collision.CanHitLine(npc.position, npc.width, npc.height, player.position, player.width, player.height); if (npc.target < 0 || npc.target >= 255 || farFromPlayer || obstanceInFrontOfPlayer || player.dead || !player.active) { npc.TargetClosest(false); player = Main.player[npc.target]; - farFromPlayer = npc.Distance(player.Center) > 640f; + farFromPlayer = npc.Distance(player.Center) > 920f; obstanceInFrontOfPlayer = !Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height); // Fly away if there is no living target, or the closest target is too far away. if (player.dead || !player.active || farFromPlayer || obstanceInFrontOfPlayer) @@ -173,7 +173,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 3f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; diff --git a/NPCs/NormalNPCs/WulfrumGyrator.cs b/NPCs/NormalNPCs/WulfrumGyrator.cs index dfdca63712..a140927223 100644 --- a/NPCs/NormalNPCs/WulfrumGyrator.cs +++ b/NPCs/NormalNPCs/WulfrumGyrator.cs @@ -149,7 +149,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 3f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.0333f : 0.115f) * pylonMult; diff --git a/NPCs/NormalNPCs/WulfrumHovercraft.cs b/NPCs/NormalNPCs/WulfrumHovercraft.cs index 7ca82fe54c..acce509c13 100644 --- a/NPCs/NormalNPCs/WulfrumHovercraft.cs +++ b/NPCs/NormalNPCs/WulfrumHovercraft.cs @@ -100,14 +100,14 @@ namespace CalamityMod.NPCs.NormalNPCs Player player = Main.player[npc.target]; - bool farFromPlayer = npc.Distance(player.Center) > 640f; + bool farFromPlayer = npc.Distance(player.Center) > 920f; bool obstanceInFrontOfPlayer = !Collision.CanHitLine(npc.position, npc.width, npc.height, player.position, player.width, player.height); if (npc.target < 0 || npc.target >= 255 || farFromPlayer || obstanceInFrontOfPlayer || player.dead || !player.active) { npc.TargetClosest(false); player = Main.player[npc.target]; - farFromPlayer = npc.Distance(player.Center) > 640f; + farFromPlayer = npc.Distance(player.Center) > 920f; obstanceInFrontOfPlayer = !Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height); // Fly away if there is no living target, or the closest target is too far away. if (player.dead || !player.active || farFromPlayer || obstanceInFrontOfPlayer) @@ -238,7 +238,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 3f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.025f : 0.1f) * pylonMult; diff --git a/NPCs/NormalNPCs/WulfrumPylon.cs b/NPCs/NormalNPCs/WulfrumPylon.cs index 8e1ce7e09d..d680d7905f 100644 --- a/NPCs/NormalNPCs/WulfrumPylon.cs +++ b/NPCs/NormalNPCs/WulfrumPylon.cs @@ -6,6 +6,7 @@ using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework; using System.Collections.Generic; +using CalamityMod.World; namespace CalamityMod.NPCs.NormalNPCs { @@ -27,8 +28,8 @@ namespace CalamityMod.NPCs.NormalNPCs ModContent.NPCType(), ModContent.NPCType() }; - public const float ChargeRadiusMax = 200f; - public const float SuperchargeTime = 600f; + public const float ChargeRadiusMax = 495f; + public const float SuperchargeTime = 720f; public override void SetStaticDefaults() { DisplayName.SetDefault("Wulfrum Pylon"); @@ -43,7 +44,7 @@ namespace CalamityMod.NPCs.NormalNPCs npc.width = 44; npc.height = 44; npc.defense = 4; - npc.lifeMax = 49; + npc.lifeMax = 92; npc.knockBackResist = 0f; npc.value = Item.buyPrice(0, 0, 1, 50); npc.noGravity = false; @@ -60,8 +61,31 @@ namespace CalamityMod.NPCs.NormalNPCs Player player = Main.player[npc.target]; - if (!Charging && npc.Distance(player.Center) < ChargeRadiusMax * 0.667f) + if (Main.netMode != NetmodeID.MultiplayerClient && !Charging && npc.Distance(player.Center) < ChargeRadiusMax * 0.667f) { + // Spawn some off-screen enemies to act as threats if the player enters the field. + int enemiesToSpawn = CalamityWorld.death ? 2 : 1; + for (int i = 0; i < enemiesToSpawn; i++) + { + int tries = 0; + Vector2 spawnPosition; + do + { + spawnPosition = player.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(600f, 1015f) * new Vector2(1.5f, 1f); + if (spawnPosition.Y > player.Center.Y) + spawnPosition.Y = player.Center.Y; + if (tries > 500) + break; + tries++; + } + while (WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16))); + + if (tries < 500) + { + int npcToSpawn = Main.rand.NextBool(2) ? ModContent.NPCType() : ModContent.NPCType(); + NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, npcToSpawn); + } + } Charging = true; npc.netUpdate = true; } @@ -71,12 +95,13 @@ namespace CalamityMod.NPCs.NormalNPCs if (Main.rand.NextBool(4)) { - float dustCount = MathHelper.TwoPi * ChargeRadius / 5f; + float dustCount = MathHelper.TwoPi * ChargeRadius / 8f; for (int i = 0; i < dustCount; i++) { float angle = MathHelper.TwoPi * i / dustCount; Dust dust = Dust.NewDustPerfect(npc.Center, 229); dust.position = npc.Center + angle.ToRotationVector2() * ChargeRadius; + dust.scale = 0.7f; dust.noGravity = true; dust.velocity = npc.velocity; } @@ -91,8 +116,7 @@ namespace CalamityMod.NPCs.NormalNPCs // For some strange reason, the Wulfrum Rover is not counted when it's added to a static list. // What I assume is going on is that it hasn't been loaded yet since it's later alphabetically (Pylon is before Rover). // As a result, they are checked separately. - if (!SuperchargableEnemies.Contains(npcAtIndex.type) && - npcAtIndex.type != ModContent.NPCType()) + if (!SuperchargableEnemies.Contains(npcAtIndex.type) && npcAtIndex.type != ModContent.NPCType()) continue; if (npcAtIndex.ai[3] > 0f) continue; diff --git a/NPCs/NormalNPCs/WulfrumRover.cs b/NPCs/NormalNPCs/WulfrumRover.cs index 316df54f57..f6d0c8368d 100644 --- a/NPCs/NormalNPCs/WulfrumRover.cs +++ b/NPCs/NormalNPCs/WulfrumRover.cs @@ -93,7 +93,7 @@ namespace CalamityMod.NPCs.NormalNPCs public override float SpawnChance(NPCSpawnInfo spawnInfo) { - float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 3f : 1f; + float pylonMult = NPC.AnyNPCs(ModContent.NPCType()) ? 5.5f : 1f; if (spawnInfo.playerSafe || spawnInfo.player.Calamity().ZoneSulphur) return 0f; return SpawnCondition.OverworldDaySlime.Chance * (Main.hardMode ? 0.05f : 0.135f) * pylonMult; diff --git a/NPCs/Other/BrimstoneOrb.cs b/NPCs/Other/BrimstoneOrb.cs index 8468cd95e5..466bd838d9 100644 --- a/NPCs/Other/BrimstoneOrb.cs +++ b/NPCs/Other/BrimstoneOrb.cs @@ -24,7 +24,7 @@ namespace CalamityMod.NPCs.Other npc.width = npc.height = 28; npc.damage = 0; npc.defense = 0; - npc.lifeMax = 97444; + npc.lifeMax = 181445; npc.noGravity = true; npc.noTileCollide = true; npc.value = 0f; @@ -36,7 +36,7 @@ namespace CalamityMod.NPCs.Other npc.Calamity().DoesNotGenerateRage = true; } - public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 97444; + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) => npc.lifeMax = 181445; public override void AI() { @@ -53,6 +53,8 @@ namespace CalamityMod.NPCs.Other } Vector2 destination = Vector2.Lerp(Owner.Center, Main.MouseWorld, 0.3f); + if (!Owner.WithinRange(Main.MouseWorld, 225f)) + destination = Owner.Center + Owner.SafeDirectionTo(Main.MouseWorld) * 225f; npc.Center = Vector2.Lerp(npc.Center, destination, 0.035f).MoveTowards(destination, 5f); if (!npc.WithinRange(destination, 2000f)) npc.Center = Owner.Center; @@ -95,7 +97,8 @@ namespace CalamityMod.NPCs.Other public override void NPCLoot() { - for (int i = 0; i < 8; i++) + int heartsToGive = (int)MathHelper.Lerp(0f, 7f, Utils.InverseLerp(45f, 540f, Time, true)); + for (int i = 0; i < heartsToGive; i++) DropHelper.DropItem(npc, ItemID.Heart); } diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index 41f1d79ba1..923e8d918a 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -115,7 +115,7 @@ namespace CalamityMod.NPCs.Perforator if (lungeUpward) { speed *= 1.25f; - turnSpeed *= 1.25f; + turnSpeed *= 1.5f; } if (npc.ai[3] > 0f) @@ -262,9 +262,11 @@ namespace CalamityMod.NPCs.Perforator } } } + float num188 = speed; float num189 = turnSpeed; - float burrowTarget = player.Center.Y + 1000f; + float burrowDistance = malice ? 500f : 750f; + float burrowTarget = player.Center.Y + burrowDistance; float lungeTarget = player.Center.Y - 600f; Vector2 vector18 = npc.Center; float num191 = player.Center.X; diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 52221159cb..fa566074a0 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -83,8 +83,14 @@ namespace CalamityMod.NPCs.Perforator if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) npc.TargetClosest(); + bool enraged = calamityGlobalNPC.enraged > 0; + bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; + bool expertMode = Main.expertMode || malice; + bool revenge = CalamityWorld.revenge || malice; + bool death = CalamityWorld.death || malice; + // Variables for ichor spore phase - float sporePhaseGateValue = 600f; + float sporePhaseGateValue = malice ? 450f : 600f; bool floatAboveToFireBlobs = npc.ai[2] >= sporePhaseGateValue - 120f; // Don't deal damage for 3 seconds after spawning or while firing blobs @@ -99,12 +105,6 @@ namespace CalamityMod.NPCs.Perforator Player player = Main.player[npc.target]; - bool enraged = calamityGlobalNPC.enraged > 0; - bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; - bool expertMode = Main.expertMode || malice; - bool revenge = CalamityWorld.revenge || malice; - bool death = CalamityWorld.death || malice; - // Percent life remaining float lifeRatio = npc.life / (float)npc.lifeMax; @@ -219,7 +219,7 @@ namespace CalamityMod.NPCs.Perforator if (npc.ai[2] < sporePhaseGateValue + 300f) { if (npc.velocity.Length() > 0.5f) - npc.velocity *= 0.96f; + npc.velocity *= malice ? 0.94f : 0.96f; else npc.ai[2] = sporePhaseGateValue + 300f; } @@ -493,7 +493,7 @@ namespace CalamityMod.NPCs.Perforator { string key = "Mods.CalamityMod.SkyOreText"; Color messageColor = Color.Cyan; - WorldGenerationMethods.SpawnOre(ModContent.TileType(), 12E-05, .4f, .6f); + CalamityUtils.SpawnOre(ModContent.TileType(), 12E-05, 0.4f, 0.6f, 3, 8); CalamityUtils.DisplayLocalizedText(key, messageColor); } diff --git a/NPCs/PlaguebringerGoliath/PlagueBeeG.cs b/NPCs/PlaguebringerGoliath/PlagueBeeG.cs index 26ea15450a..e8c7285bad 100644 --- a/NPCs/PlaguebringerGoliath/PlagueBeeG.cs +++ b/NPCs/PlaguebringerGoliath/PlagueBeeG.cs @@ -228,8 +228,8 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/PlagueBeeGlow"); + + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) diff --git a/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs b/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs index 9e71e33082..5955282814 100644 --- a/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs +++ b/NPCs/PlaguebringerGoliath/PlagueBeeLargeG.cs @@ -122,7 +122,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/NormalNPCs/PlagueBeeGlow"); + texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/PlagueEnemies/PlagueBeeGlow"); Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); if (CalamityConfig.Instance.Afterimages) diff --git a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs index e015eefacb..aebcd8500f 100644 --- a/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs +++ b/NPCs/PlaguebringerGoliath/PlaguebringerGoliath.cs @@ -208,7 +208,7 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath enrageScale = 2.5f; } - bool diagonalDash = revenge && phase2; + bool diagonalDash = (revenge && phase2) || malice; if (npc.ai[0] != 0f && npc.ai[0] != 4f) npc.rotation = npc.velocity.X * 0.02f; @@ -251,6 +251,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath return; } + // Always start in enemy spawning phase + if (calamityGlobalNPC.newAI[3] == 0f) + { + calamityGlobalNPC.newAI[3] = 1f; + npc.ai[0] = 2f; + npc.netUpdate = true; + } + // Phase switch if (npc.ai[0] == -1f) { @@ -826,12 +834,14 @@ namespace CalamityMod.NPCs.PlaguebringerGoliath baseVelocity.Normalize(); baseVelocity *= speed; - for (int i = 0; i < MissileProjectiles; i++) + int missiles = malice ? 16 : MissileProjectiles; + int spread = malice ? 18 : 24; + for (int i = 0; i < missiles; i++) { - Vector2 spawn = vectorCenter; - spawn.X += i * 27 - (MissileProjectiles * 12); // -96 to 93 - Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-MissileAngleSpread / 2 + (MissileAngleSpread * i / MissileProjectiles))); - Projectile.NewProjectile(spawn.X, spawn.Y, velocity.X, velocity.Y, type, damage, 0f, Main.myPlayer, 0f, player.position.Y); + Vector2 spawn = vectorCenter; // Normal = 96, Malice = 144 + spawn.X += i * (int)(spread * 1.125) - (missiles * (spread / 2)); // Normal = -96 to 93, Malice = -144 to 156 + Vector2 velocity = baseVelocity.RotatedBy(MathHelper.ToRadians(-MissileAngleSpread / 2 + (MissileAngleSpread * i / missiles))); + Projectile.NewProjectile(spawn, velocity, type, damage, 0f, Main.myPlayer, 0f, player.position.Y); } } } diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 996af43130..1f66f72d6f 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -102,8 +102,6 @@ namespace CalamityMod.NPCs.Providence npc.noGravity = true; npc.noTileCollide = true; npc.netAlways = true; - npc.chaseable = true; - npc.canGhostHeal = false; music = CalamityMod.Instance.GetMusicFromMusicMod("ProvidenceTheme") ?? MusicID.LunarBoss; npc.DeathSound = mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/ProvidenceDeath"); bossBag = ModContent.ItemType(); @@ -277,10 +275,10 @@ namespace CalamityMod.NPCs.Providence { if (!player.dead && player.active) player.AddBuff(ModContent.BuffType(), 2); - } + } - // Count the remaining Guardians, healer especially because it allows the boss to heal - int guardianAmt = 0; + // Count the remaining Guardians, healer especially because it allows the boss to heal + int guardianAmt = 0; bool healerAlive = false; if (CalamityGlobalNPC.holyBossAttacker != -1) { @@ -1276,6 +1274,43 @@ namespace CalamityMod.NPCs.Providence } } + public float CalculateBurnIntensity() + { + float distanceToTarget = Vector2.Distance(Main.player[npc.target].Center, npc.Center); + float aiTimer = npc.ai[3]; + + float baseDistance = 2800f; + float shorterFlameCocoonDistance = (CalamityWorld.death || CalamityWorld.malice || !Main.dayTime) ? 600f : CalamityWorld.revenge ? 400f : Main.expertMode ? 200f : 0f; + float shorterSpearCocoonDistance = (CalamityWorld.death || CalamityWorld.malice || !Main.dayTime) ? 1000f : CalamityWorld.revenge ? 650f : Main.expertMode ? 300f : 0f; + float shorterDistance = AIState == (int)Phase.FlameCocoon ? shorterFlameCocoonDistance : shorterSpearCocoonDistance; + + bool guardianAlive = false; + if (CalamityGlobalNPC.holyBossAttacker != -1 && Main.npc[CalamityGlobalNPC.holyBossAttacker].active) + guardianAlive = true; + + if (CalamityGlobalNPC.holyBossDefender != -1 && Main.npc[CalamityGlobalNPC.holyBossDefender].active) + guardianAlive = true; + + if (CalamityGlobalNPC.holyBossHealer != -1 && Main.npc[CalamityGlobalNPC.holyBossHealer].active) + guardianAlive = true; + + float maxDistance = baseDistance; + + // A factor which measures how much of the distance shortening shave-off should be taken into account. + // It is determined based on how much time has elapsed during the attack thus far, specifically for the two cocoon attacks. + // This shave-off does not happen when guardians are present. + float shorterDistanceFade = Utils.InverseLerp(0f, 120f, aiTimer, true); + if (!guardianAlive) + { + maxDistance = baseDistance; + if (AIState == (int)Phase.FlameCocoon || AIState == (int)Phase.SpearCocoon) + maxDistance -= shorterDistance * shorterDistanceFade; + } + + float drawFireDistanceStart = maxDistance - 800f; + return Utils.InverseLerp(drawFireDistanceStart, maxDistance, distanceToTarget, true); + } + private void DespawnSpecificProjectiles() { for (int x = 0; x < Main.maxProjectiles; x++) @@ -1356,7 +1391,7 @@ namespace CalamityMod.NPCs.Providence string key3 = "Mods.CalamityMod.TreeOreText"; Color messageColor3 = Color.LightGreen; - WorldGenerationMethods.SpawnOre(ModContent.TileType(), 15E-05, .4f, .8f); + CalamityUtils.SpawnOre(ModContent.TileType(), 15E-05, 0.4f, 0.8f, 3, 8, TileID.Mud); CalamityUtils.DisplayLocalizedText(key2, messageColor2); CalamityUtils.DisplayLocalizedText(key3, messageColor3); diff --git a/NPCs/SupremeCalamitas/SCalWormHeart.cs b/NPCs/SupremeCalamitas/BrimstoneHeart.cs similarity index 82% rename from NPCs/SupremeCalamitas/SCalWormHeart.cs rename to NPCs/SupremeCalamitas/BrimstoneHeart.cs index 43ea6157ca..ed6df8c4bc 100644 --- a/NPCs/SupremeCalamitas/SCalWormHeart.cs +++ b/NPCs/SupremeCalamitas/BrimstoneHeart.cs @@ -10,7 +10,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.SupremeCalamitas { - public class SCalWormHeart : ModNPC + public class BrimstoneHeart : ModNPC { public PrimitiveTrail ChainDrawer = null; public int ChainHeartIndex => (int)npc.ai[0]; @@ -18,6 +18,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Heart"); + Main.npcFrameCount[npc.type] = 6; } public override void SetDefaults() @@ -49,7 +50,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void ReceiveExtraAI(BinaryReader reader) { ChainEndpoints.Clear(); - for (int i = 0; i < reader.ReadInt32(); i++) + int endpointCount = reader.ReadInt32(); + for (int i = 0; i < endpointCount; i++) ChainEndpoints.Add(reader.ReadVector2()); } @@ -72,7 +74,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas float widthInterpolant = Utils.InverseLerp(0f, 0.16f, completionRatio, true) * Utils.InverseLerp(1f, 0.84f, completionRatio, true); widthInterpolant = (float)Math.Pow(widthInterpolant, 8D); float baseWidth = MathHelper.Lerp(4f, 1f, widthInterpolant); - float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTime * 4.4f + npc.whoAmI * 1.3f + completionRatio), 16D)); + float pulseWidth = MathHelper.Lerp(0f, 3.2f, (float)Math.Pow(Math.Sin(Main.GlobalTime * 2.6f + npc.whoAmI * 1.3f + completionRatio), 16D)); return baseWidth + pulseWidth; } @@ -82,6 +84,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas return Color.Lerp(Color.DarkRed * 0.7f, Color.Red, colorInterpolant) * 0.425f; } + public override void FindFrame(int frameHeight) + { + int frame = (int)Math.Round((float)Math.Pow(Math.Sin(Main.GlobalTime * 2.6f + npc.whoAmI * 1.3f), 6D) * Main.npcFrameCount[npc.type]); + if (frame >= Main.npcFrameCount[npc.type]) + frame = Main.npcFrameCount[npc.type] - 1; + npc.frame.Y = frame * frameHeight; + } + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { if (ChainDrawer is null) @@ -114,6 +124,11 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (npc.life <= 0) { + for (int i = 1; i <= 2; i++) + { + Vector2 heartGoreVelocity = new Vector2((i == 1).ToDirectionInt() * 3f, Main.rand.NextFloat(-2f, 0f)); + Gore.NewGorePerfect(npc.Center, heartGoreVelocity, mod.GetGoreSlot($"Gores/SupremeCalamitas/BrimstoneHeart_Gore{i}"), npc.scale); + } for (int i = 0; i < ChainEndpoints.Count; i++) TendrilDestructionEffects(i); } diff --git a/NPCs/SupremeCalamitas/BrimstoneHeart.png b/NPCs/SupremeCalamitas/BrimstoneHeart.png new file mode 100644 index 0000000000..c597cfe505 Binary files /dev/null and b/NPCs/SupremeCalamitas/BrimstoneHeart.png differ diff --git a/NPCs/SupremeCalamitas/SCalSky.cs b/NPCs/SupremeCalamitas/SCalSky.cs deleted file mode 100644 index bf4233d713..0000000000 --- a/NPCs/SupremeCalamitas/SCalSky.cs +++ /dev/null @@ -1,107 +0,0 @@ -using CalamityMod.Projectiles.Boss; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.Graphics.Effects; -using Terraria.ModLoader; - -namespace CalamityMod.NPCs.SupremeCalamitas -{ - public class SCalSky : CustomSky - { - private bool isActive = false; - private float intensity = 0f; - private int SCalIndex = -1; - public static float OverridingIntensity = 0f; - - public override void Update(GameTime gameTime) - { - if (isActive && intensity < 1f) - { - intensity += 0.01f; - } - else if (!isActive && intensity > 0f) - { - intensity -= 0.01f; - } - } - - private float GetIntensity() - { - if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) > 0) - return OverridingIntensity; - - OverridingIntensity = 0f; - if (this.UpdateSCalIndex()) - { - float x = 0f; - if (this.SCalIndex != -1) - { - x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.SCalIndex].Center); - } - return 1f - Utils.SmoothStep(3000f, 6000f, x); - } - return 0f; - } - - public override Color OnTileColor(Color inColor) - { - float intensity = this.GetIntensity(); - return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity)); - } - - private bool UpdateSCalIndex() - { - int SCalType = ModContent.NPCType(); - if (SCalIndex >= 0 && Main.npc[SCalIndex].active && Main.npc[SCalIndex].type == SCalType) - { - return true; - } - SCalIndex = -1; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.npc[i].active && Main.npc[i].type == SCalType) - { - SCalIndex = i; - break; - } - } - //this.DoGIndex = DoGIndex; - return SCalIndex != -1; - } - - public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) - { - if (maxDepth >= 0 && minDepth < 0) - { - float intensity = this.GetIntensity(); - spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity); - } - } - - public override float GetCloudAlpha() - { - return 0f; - } - - public override void Activate(Vector2 position, params object[] args) - { - isActive = true; - } - - public override void Deactivate(params object[] args) - { - isActive = false; - } - - public override void Reset() - { - isActive = false; - } - - public override bool IsActive() - { - return isActive || intensity > 0f; - } - } -} diff --git a/NPCs/SupremeCalamitas/SCalWormArm.cs b/NPCs/SupremeCalamitas/SCalWormArm.cs new file mode 100644 index 0000000000..126860646d --- /dev/null +++ b/NPCs/SupremeCalamitas/SCalWormArm.cs @@ -0,0 +1,217 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.SupremeCalamitas +{ + public class SCalWormArm : ModNPC + { + public class SepulcherArmLimb + { + public Vector2 Center; + public float Rotation; + + public SepulcherArmLimb(Vector2 center, float rotation) + { + Center = center; + Rotation = rotation; + } + + public void SendData(BinaryWriter writer) + { + writer.WritePackedVector2(Center); + writer.Write(Rotation); + } + + public void ReceiveData(BinaryReader reader) + { + Center = reader.ReadPackedVector2(); + Rotation = reader.ReadSingle(); + } + } + + public NPC SegmentToAttachTo => Main.npc[(int)npc.ai[0]]; + public bool CurrentlyMoving + { + get => npc.ai[1] == 1f; + set => npc.ai[1] = value.ToInt(); + } + public Vector2 MoveDestination + { + get => new Vector2(npc.ai[2], npc.ai[3]); + set + { + npc.ai[2] = value.X; + npc.ai[3] = value.Y; + } + } + public ref float Time => ref npc.localAI[0]; + public bool ReelingBack + { + get => npc.localAI[1] == 0f; + set => npc.localAI[1] = 1f - value.ToInt(); + } + public Player Target => Main.player[npc.target]; + public SepulcherArmLimb[] Limbs = new SepulcherArmLimb[4]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Sepulcher"); + } + + public override void SetDefaults() + { + npc.damage = 0; + npc.npcSlots = 5f; + npc.width = 34; + npc.height = 48; + npc.defense = 0; + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + npc.lifeMax = CalamityWorld.revenge ? 345000 : 300000; + npc.aiStyle = aiType = -1; + npc.knockBackResist = 0f; + npc.scale = Main.expertMode ? 1.35f : 1.2f; + npc.dontTakeDamage = true; + npc.alpha = 255; + npc.chaseable = false; + npc.behindTiles = true; + npc.noGravity = true; + npc.noTileCollide = true; + npc.canGhostHeal = false; + npc.netAlways = true; + npc.dontCountMe = true; + + for (int i = 0; i < Limbs.Length; i++) + Limbs[i] = new SepulcherArmLimb(npc.Center, 0f); + } + + public override void SendExtraAI(BinaryWriter writer) + { + for (int i = 0; i < Limbs.Length; i++) + Limbs[i].SendData(writer); + writer.Write(npc.rotation); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + for (int i = 0; i < Limbs.Length; i++) + Limbs[i].ReceiveData(reader); + npc.rotation = reader.ReadSingle(); + } + + public override void AI() + { + // Die if the segment is not present. + if (!Main.npc.IndexInRange((int)npc.ai[0]) || !Main.npc[(int)npc.ai[0]].active) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + return; + } + + npc.Opacity = SegmentToAttachTo.Opacity; + npc.TargetClosest(false); + + Vector2 idealMovePosition = SegmentToAttachTo.Center; + float sideFactor = MathHelper.Lerp(200f, 18f, Utils.InverseLerp(-0.51f, -0.06f, npc.rotation, true)); + float aheadFactor = MathHelper.Lerp(284f, 680f, Utils.InverseLerp(-0.51f, -0.06f, npc.rotation, true)); + idealMovePosition += (SegmentToAttachTo.rotation + npc.rotation * npc.direction - MathHelper.PiOver2).ToRotationVector2() * npc.scale * aheadFactor; + idealMovePosition += (SegmentToAttachTo.rotation + npc.rotation * npc.direction - MathHelper.PiOver2 + MathHelper.PiOver2 * npc.direction).ToRotationVector2() * npc.scale * sideFactor; + npc.Center = idealMovePosition; + UpdateLimbs(); + + if (ReelingBack) + { + npc.rotation -= 0.066f; + if (npc.rotation < -0.55f) + ReelingBack = false; + } + else + { + npc.rotation += 0.029f; + if (npc.rotation > 0.77f) + ReelingBack = true; + } + + Time++; + } + + public void MoveToDestination() + { + npc.Center = Vector2.Lerp(npc.Center, MoveDestination, 0.05f); + npc.Center = npc.Center.MoveTowards(MoveDestination, 10f); + + // Stop moving if sufficiently close to the desired destination. + if (npc.WithinRange(MoveDestination, 15f)) + { + npc.Center = MoveDestination; + MoveDestination = Vector2.Zero; + CurrentlyMoving = false; + npc.netUpdate = true; + } + } + + public void UpdateLimbs() + { + Vector2 offsetFromSegment = Vector2.Zero; + + offsetFromSegment += new Vector2(npc.direction * 60f, 55f).RotatedBy(SegmentToAttachTo.rotation - (MathHelper.PiOver2 - npc.rotation * 1.7f - 0.77f) * npc.direction).SafeNormalize(Vector2.UnitY) * 92f; + Limbs[0].Center = SegmentToAttachTo.Center + offsetFromSegment; + Limbs[0].Rotation = offsetFromSegment.ToRotation(); + + Limbs[1].Rotation = npc.AngleFrom(Limbs[0].Center); + Limbs[1].Center = Limbs[0].Center + offsetFromSegment * 0.5f + (npc.Center - Limbs[0].Center).SafeNormalize(Vector2.UnitY) * 84f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D armTexture = Main.npcTexture[npc.type]; + Texture2D foreArmTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormForeArm"); + Texture2D handTexture = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormHand"); + + Vector2 forearmDrawPosition = Limbs[0].Center - Main.screenPosition; + Color drawColor = Lighting.GetColor((int)(Limbs[0].Center.X / 16), (int)(Limbs[0].Center.Y / 16)); + spriteBatch.Draw(foreArmTexture, forearmDrawPosition, null, drawColor, Limbs[0].Rotation + MathHelper.PiOver2, foreArmTexture.Size() * 0.5f, npc.scale, SpriteEffects.None, 0f); + + Vector2 armDrawPosition = Limbs[1].Center - Main.screenPosition; + drawColor = Lighting.GetColor((int)(Limbs[1].Center.X / 16), (int)(Limbs[1].Center.Y / 16)); + spriteBatch.Draw(armTexture, armDrawPosition, null, drawColor, Limbs[1].Rotation + MathHelper.PiOver2, armTexture.Size() * new Vector2(0.5f, 0f), npc.scale, SpriteEffects.FlipVertically, 0f); + + Vector2 handDrawPosition = armDrawPosition; + SpriteEffects handDirection = npc.direction == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(handTexture, handDrawPosition, null, drawColor, Limbs[1].Rotation - MathHelper.PiOver2, handTexture.Size() * new Vector2(0.5f, 0f), npc.scale, handDirection, 0f); + + return false; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life <= 0) + { + Vector2 forearmGoreSpawnPosition = Limbs[0].Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 armGoreSpawnPosition = Limbs[1].Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 handGoreSpawnPosition = armGoreSpawnPosition + Main.rand.NextVector2Circular(6f, 6f); + + Gore.NewGorePerfect(armGoreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherArm_Gore"), npc.scale); + for (int i = 1; i <= 2; i++) + Gore.NewGorePerfect(forearmGoreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherForearm_Gore{i}"), npc.scale); + for (int i = 1; i <= 2; i++) + Gore.NewGorePerfect(handGoreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherHand_Gore{i}"), npc.scale); + } + } + + public override bool CheckActive() => false; + + public override bool PreNPCLoot() => false; + + public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false; + } +} diff --git a/NPCs/SupremeCalamitas/SCalWormArm.png b/NPCs/SupremeCalamitas/SCalWormArm.png new file mode 100644 index 0000000000..b45111f206 Binary files /dev/null and b/NPCs/SupremeCalamitas/SCalWormArm.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormBody.cs b/NPCs/SupremeCalamitas/SCalWormBody.cs index a6265bf8d7..59835db0ec 100644 --- a/NPCs/SupremeCalamitas/SCalWormBody.cs +++ b/NPCs/SupremeCalamitas/SCalWormBody.cs @@ -12,8 +12,10 @@ namespace CalamityMod.NPCs.SupremeCalamitas public class SCalWormBody : ModNPC { private bool setAlpha = false; + public NPC AheadSegment => Main.npc[(int)npc.ai[1]]; + public NPC HeadSegment => Main.npc[(int)npc.ai[2]]; - public override void SetStaticDefaults() + public override void SetStaticDefaults() { DisplayName.SetDefault("Sepulcher"); } @@ -22,8 +24,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { npc.damage = 0; //70 npc.npcSlots = 5f; - npc.width = 20; //28 - npc.height = 20; //28 + npc.width = npc.height = 48; npc.defense = 0; CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; @@ -43,8 +44,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; } @@ -73,85 +72,49 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.realLife = (int)npc.ai[2]; } - bool flag = false; - if (npc.ai[1] <= 0f) - { - flag = true; - } - else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0) - { - flag = true; - } - if (flag) - { - npc.life = 0; - npc.HitEffect(0, 10.0); - npc.checkDead(); - } + bool shouldDie = false; + if (npc.ai[1] <= 0f) + shouldDie = true; + else if (AheadSegment.life <= 0 || !AheadSegment.active || npc.life <= 0) + shouldDie = true; - if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) - { - if (npc.alpha != 0) - { - for (int num934 = 0; num934 < 2; num934++) - { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; - } - } - npc.alpha -= 42; - if (npc.alpha <= 0) - { - setAlpha = true; - npc.alpha = 0; - } - } - else - { - npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - } + if (shouldDie) + { + npc.life = 0; + npc.HitEffect(0, 10.0); + npc.checkDead(); + } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) - { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; - npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } - } - } + if (AheadSegment.alpha < 128 && !setAlpha) + { + if (npc.alpha != 0) + { + for (int i = 0; i < 2; i++) + { + Dust fire = Dust.NewDustDirect(npc.position, npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); + fire.noGravity = true; + fire.noLight = true; + } + } + npc.alpha -= 42; + if (npc.alpha <= 0) + { + setAlpha = true; + npc.alpha = 0; + } + } + else + npc.alpha = HeadSegment.alpha; + + if (Main.npc.IndexInRange((int)npc.ai[1])) + { + Vector2 offsetToAheadSegment = AheadSegment.Center - npc.Center; + npc.rotation = offsetToAheadSegment.ToRotation() + MathHelper.PiOver2; + npc.velocity = Vector2.Zero; + npc.Center = AheadSegment.Center - offsetToAheadSegment.SafeNormalize(Vector2.UnitY) * 52f; + npc.spriteDirection = (offsetToAheadSegment.X > 0f).ToDirectionInt(); + } + } public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { @@ -174,7 +137,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (npc.spriteDirection == 1) spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = npc.localAI[3] == 1f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAlt") : Main.npcTexture[npc.type]; + Texture2D texture2D15 = npc.localAI[3] / 2f % 2f == 0f ? ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAlt") : Main.npcTexture[npc.type]; Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / 2)); Vector2 vector43 = npc.Center - Main.screenPosition; @@ -182,14 +145,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - if (npc.localAI[3] == 1f) - { - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormBodyAltGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - return false; } @@ -207,29 +162,28 @@ namespace CalamityMod.NPCs.SupremeCalamitas { if (npc.life <= 0) { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 5; num621++) + int variant = (int)(npc.localAI[3] / 2f % 2f); + if (variant == 0) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) + for (int i = 1; i <= 9; i++) { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + if (!Main.rand.NextBool(3)) + continue; + + Vector2 goreSpawnPosition = npc.Center; + Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(2f, 2f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherBody1_Gore{i}"), npc.scale); } } - for (int num623 = 0; num623 < 10; num623++) + else { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; + for (int i = 1; i <= 7; i++) + { + if (!Main.rand.NextBool(3)) + continue; + + Vector2 goreSpawnPosition = npc.Center; + Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(2f, 2f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherBody2_Gore{i}"), npc.scale); + } } } } diff --git a/NPCs/SupremeCalamitas/SCalWormBody.png b/NPCs/SupremeCalamitas/SCalWormBody.png index 5a37855ad8..5e8b75333e 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormBody.png and b/NPCs/SupremeCalamitas/SCalWormBody.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormBodyAlt.png b/NPCs/SupremeCalamitas/SCalWormBodyAlt.png index 35971e8491..7bddb6f35e 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormBodyAlt.png and b/NPCs/SupremeCalamitas/SCalWormBodyAlt.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormBodyAltGlow.png b/NPCs/SupremeCalamitas/SCalWormBodyAltGlow.png deleted file mode 100644 index 5e4e89bd98..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormBodyAltGlow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs index 33fa11dda4..913ddad300 100644 --- a/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs +++ b/NPCs/SupremeCalamitas/SCalWormBodyWeak.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Boss; +using CalamityMod.Projectiles.Typeless; using CalamityMod.World; using Microsoft.Xna.Framework; using System.IO; @@ -11,10 +12,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas public class SCalWormBodyWeak : ModNPC { private bool setAlpha = false; + public NPC AheadSegment => Main.npc[(int)npc.ai[1]]; + public NPC HeadSegment => Main.npc[(int)npc.ai[2]]; + public ref float AttackTimer => ref npc.localAI[0]; public override void SetStaticDefaults() { DisplayName.SetDefault("Brimstone Heart"); + Main.npcFrameCount[npc.type] = 5; } public override void SetDefaults() @@ -27,70 +32,60 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.aiStyle = -1; aiType = -1; npc.knockBackResist = 0f; - CalamityGlobalNPC global = npc.Calamity(); - global.DR = 0.999999f; - global.unbreakableDR = true; - npc.scale = 1.2f; - if (Main.expertMode) - { - npc.scale = 1.35f; - } + npc.scale = Main.expertMode ? 1.35f : 1.2f; npc.alpha = 255; npc.chaseable = false; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit13; - npc.DeathSound = SoundID.NPCDeath13; npc.netAlways = true; npc.dontCountMe = true; - } + + CalamityGlobalNPC global = npc.Calamity(); + global.DR = 0.999999f; + global.unbreakableDR = true; + } public override void SendExtraAI(BinaryWriter writer) { - writer.Write(npc.localAI[0]); + writer.Write(AttackTimer); writer.Write(setAlpha); } public override void ReceiveExtraAI(BinaryReader reader) { - npc.localAI[0] = reader.ReadSingle(); + AttackTimer = reader.ReadSingle(); setAlpha = reader.ReadBoolean(); } public override void AI() { if (npc.ai[2] > 0f) - { npc.realLife = (int)npc.ai[2]; - } - bool flag = false; + bool shouldDie = false; if (npc.ai[1] <= 0f) - { - flag = true; - } - else if (Main.npc[(int)npc.ai[1]].life <= 0 || npc.life <= 0) - { - flag = true; - } - if (flag) + shouldDie = true; + else if (AheadSegment.life <= 0 || !AheadSegment.active || npc.life <= 0) + shouldDie = true; + + if (shouldDie) { npc.life = 0; npc.HitEffect(0, 10.0); npc.checkDead(); } - if (Main.npc[(int)npc.ai[1]].alpha < 128 && !setAlpha) + if (AheadSegment.alpha < 128 && !setAlpha) { if (npc.alpha != 0) { - for (int num934 = 0; num934 < 2; num934++) + for (int i = 0; i < 2; i++) { - int num935 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); - Main.dust[num935].noGravity = true; - Main.dust[num935].noLight = true; + Dust fire = Dust.NewDustDirect(npc.position, npc.width, npc.height, 182, 0f, 0f, 100, default, 2f); + fire.noGravity = true; + fire.noLight = true; } } npc.alpha -= 42; @@ -101,16 +96,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } else - { - npc.alpha = Main.npc[(int)npc.ai[2]].alpha; - } + npc.alpha = HeadSegment.alpha; - if (Main.netMode != NetmodeID.MultiplayerClient) + AttackTimer += CalamityWorld.malice ? 1.5f : 1f; + if (AttackTimer >= 900f) { - npc.localAI[0] += CalamityWorld.malice ? 1.5f : 1f; - if (npc.localAI[0] >= 900f) + AttackTimer = 0f; + if (Main.netMode != NetmodeID.MultiplayerClient) { - npc.localAI[0] = 0f; int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); int totalProjectiles = 4; @@ -121,48 +114,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 velocity = spinningPoint.RotatedBy(radians * k); Projectile.NewProjectile(npc.Center, velocity, type, damage, 0f, Main.myPlayer); } - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); + npc.netUpdate = true; } + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), npc.Center); } - Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); - float num192 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2); - num191 = (int)(num191 / 16f) * 16; - num192 = (int)(num192 / 16f) * 16; - vector18.X = (int)(vector18.X / 16f) * 16; - vector18.Y = (int)(vector18.Y / 16f) * 16; - num191 -= vector18.X; - num192 -= vector18.Y; - float num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - if (npc.ai[1] > 0f && npc.ai[1] < Main.npc.Length) + if (Main.npc.IndexInRange((int)npc.ai[1])) { - try - { - vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); - num191 = Main.npc[(int)npc.ai[1]].position.X + (Main.npc[(int)npc.ai[1]].width / 2) - vector18.X; - num192 = Main.npc[(int)npc.ai[1]].position.Y + (Main.npc[(int)npc.ai[1]].height / 2) - vector18.Y; - } - catch - { - } - npc.rotation = (float)System.Math.Atan2(num192, num191) + 1.57f; - num193 = (float)System.Math.Sqrt(num191 * num191 + num192 * num192); - int num194 = npc.width; - num193 = (num193 - num194) / num193; - num191 *= num193; - num192 *= num193; + Vector2 offsetToAheadSegment = AheadSegment.Center - npc.Center; + npc.rotation = offsetToAheadSegment.ToRotation() + MathHelper.PiOver2; npc.velocity = Vector2.Zero; - npc.position.X = npc.position.X + num191; - npc.position.Y = npc.position.Y + num192; - if (num191 < 0f) - { - npc.spriteDirection = -1; - } - else if (num191 > 0f) - { - npc.spriteDirection = 1; - } + npc.Center = AheadSegment.Center - offsetToAheadSegment.SafeNormalize(Vector2.UnitY) * 34f; + npc.spriteDirection = (offsetToAheadSegment.X > 0f).ToDirectionInt(); } } @@ -181,6 +144,27 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } + public override void FindFrame(int frameHeight) + { + npc.frameCounter++; + npc.frame.Y = ((int)(npc.frameCounter / 5) + npc.whoAmI) % Main.npcFrameCount[npc.type] * frameHeight; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (Main.netMode != NetmodeID.MultiplayerClient && npc.life <= 0) + { + for (int i = 0; i < Main.rand.Next(1, 3 + 1); i++) + { + if (!Main.rand.NextBool(3)) + continue; + + Vector2 soulVelocity = -Vector2.UnitY.RotatedByRandom(0.53f) * Main.rand.NextFloat(2.5f, 4f); + Projectile.NewProjectile(npc.Center, soulVelocity, ModContent.ProjectileType(), 0, 0f); + } + } + } + public override bool CheckActive() { return false; diff --git a/NPCs/SupremeCalamitas/SCalWormBodyWeak.png b/NPCs/SupremeCalamitas/SCalWormBodyWeak.png index 8bc8635d1b..3ab290bdf1 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormBodyWeak.png and b/NPCs/SupremeCalamitas/SCalWormBodyWeak.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormForeArm.png b/NPCs/SupremeCalamitas/SCalWormForeArm.png new file mode 100644 index 0000000000..da24ee8a4f Binary files /dev/null and b/NPCs/SupremeCalamitas/SCalWormForeArm.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormHand.png b/NPCs/SupremeCalamitas/SCalWormHand.png new file mode 100644 index 0000000000..c28935e9f2 Binary files /dev/null and b/NPCs/SupremeCalamitas/SCalWormHand.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormHead.cs b/NPCs/SupremeCalamitas/SCalWormHead.cs index bf98c7ff11..97fa659099 100644 --- a/NPCs/SupremeCalamitas/SCalWormHead.cs +++ b/NPCs/SupremeCalamitas/SCalWormHead.cs @@ -27,7 +27,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.damage = 0; //150 npc.npcSlots = 5f; npc.width = 62; //324 - npc.height = 78; //216 + npc.height = 64; //216 npc.defense = 0; CalamityGlobalNPC global = npc.Calamity(); global.DR = 0.999999f; @@ -36,20 +36,16 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.aiStyle = -1; //new aiType = -1; //new npc.knockBackResist = 0f; - npc.scale = 1.2f; - if (Main.expertMode) - { - npc.scale = 1.35f; - } - npc.alpha = 255; + npc.scale = Main.expertMode ? 1.35f : 1.2f; + npc.scale *= 1.25f; + + npc.alpha = 255; npc.chaseable = false; npc.behindTiles = true; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; - npc.netAlways = true; + npc.netAlways = true; } public override void SendExtraAI(BinaryWriter writer) @@ -81,44 +77,58 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) npc.TargetClosest(); - Player player = Main.player[npc.target]; - if (npc.ai[2] > 0f) - { npc.realLife = (int)npc.ai[2]; - } if (Main.netMode != NetmodeID.MultiplayerClient) { if (!TailSpawned && npc.ai[0] == 0f) { + float rotationalOffset = 0f; int Previous = npc.whoAmI; - for (int num36 = 0; num36 < maxLength; num36++) + for (int i = 0; i < maxLength; i++) { int lol; - if (num36 >= 0 && num36 < minLength && num36 % 2 == 0) + if (i >= 0 && i < minLength && i % 2 == 1) { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); Main.npc[lol].localAI[0] += passedVar; passedVar += 36f; } - else if (num36 >= 0 && num36 < minLength) + else if (i >= 0 && i < minLength) { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - if (npc.localAI[0] % 2 == 0) - { - Main.npc[lol].localAI[3] = 1f; - npc.localAI[0] = 1f; - } - else - { - npc.localAI[0] = 2f; - } - } + Main.npc[lol].localAI[3] = i; + } else - { lol = NPC.NewNPC((int)npc.position.X + (npc.width / 2), (int)npc.position.Y + (npc.height / 2), ModContent.NPCType(), npc.whoAmI); - } + + // Create arms. + if (i >= 3 && i % 4 == 0) + { + NPC segment = Main.npc[lol]; + int arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); + if (Main.npc.IndexInRange(arm)) + { + Main.npc[arm].ai[0] = lol; + Main.npc[arm].direction = 1; + Main.npc[arm].rotation = rotationalOffset; + } + + rotationalOffset += MathHelper.Pi / 6f; + + arm = NPC.NewNPC((int)segment.Center.X, (int)segment.Center.Y, ModContent.NPCType(), lol); + if (Main.npc.IndexInRange(arm)) + { + Main.npc[arm].ai[0] = lol; + Main.npc[arm].direction = -1; + Main.npc[arm].rotation = rotationalOffset + MathHelper.Pi; + } + + rotationalOffset += MathHelper.Pi / 6f; + rotationalOffset = MathHelper.WrapAngle(rotationalOffset); + } + Main.npc[lol].realLife = npc.whoAmI; Main.npc[lol].ai[2] = npc.whoAmI; Main.npc[lol].ai[1] = Previous; @@ -133,30 +143,17 @@ namespace CalamityMod.NPCs.SupremeCalamitas } } - if (Main.player[npc.target].dead || !NPC.AnyNPCs(ModContent.NPCType()) || CalamityGlobalNPC.SCal < 0 || !Main.npc[CalamityGlobalNPC.SCal].active) - { - npc.TargetClosest(false); - npc.alpha += 5; - if (npc.alpha >= 255) - { - npc.alpha = 255; - for (int i = 0; i < Main.maxNPCs; i++) - { - if (Main.npc[i].type == npc.type || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType() || Main.npc[i].type == ModContent.NPCType()) - { - Main.npc[i].active = false; - } - } - } - } - else - { - npc.alpha -= 42; - if (npc.alpha < 0) - { - npc.alpha = 0; - } - } + if (Main.player[npc.target].dead || !NPC.AnyNPCs(ModContent.NPCType()) || CalamityGlobalNPC.SCal < 0 || !Main.npc[CalamityGlobalNPC.SCal].active) + { + npc.TargetClosest(false); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.NPCKilled, "Sounds/NPCKilled/SepulcherDeath"), Main.player[npc.target].Center); + npc.life = 0; + npc.HitEffect(); + npc.active = false; + npc.netUpdate = true; + } + else + npc.Opacity = MathHelper.Clamp(npc.Opacity + 0.165f, 0f, 1f); Vector2 vector18 = new Vector2(npc.position.X + npc.width * 0.5f, npc.position.Y + npc.height * 0.5f); float num191 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2); @@ -304,11 +301,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormHeadGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; } @@ -334,33 +326,20 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void HitEffect(int hitDirection, double damage) { - if (npc.life <= 0) - { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 5; num621++) + if (npc.life <= 0) + { + for (int i = 1; i <= 3; i++) { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } + Vector2 goreSpawnPosition = npc.Center; + + // Spawn at a slight offset when spawning mandibles. + if (i == 2) + goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver4) * 16f; + if (i == 3) + goreSpawnPosition += npc.velocity.SafeNormalize(Vector2.Zero).RotatedBy(-MathHelper.PiOver4) * 16f; + Gore.NewGorePerfect(goreSpawnPosition, npc.velocity, mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherHead_Gore{i}"), npc.scale); } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + } } } } diff --git a/NPCs/SupremeCalamitas/SCalWormHead.png b/NPCs/SupremeCalamitas/SCalWormHead.png index 8bd5ba6d26..ce918150f1 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormHead.png and b/NPCs/SupremeCalamitas/SCalWormHead.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormHeadGlow.png b/NPCs/SupremeCalamitas/SCalWormHeadGlow.png deleted file mode 100644 index 6b5306839a..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormHeadGlow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SCalWormHeart.png b/NPCs/SupremeCalamitas/SCalWormHeart.png deleted file mode 100644 index 8bc8635d1b..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormHeart.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SCalWormTail.cs b/NPCs/SupremeCalamitas/SCalWormTail.cs index 3fb861c106..d0200712e0 100644 --- a/NPCs/SupremeCalamitas/SCalWormTail.cs +++ b/NPCs/SupremeCalamitas/SCalWormTail.cs @@ -42,8 +42,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; npc.netAlways = true; npc.dontCountMe = true; } @@ -164,11 +162,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas vector43 += vector11 * npc.scale + new Vector2(0f, npc.gfxOffY); spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - texture2D15 = ModContent.GetTexture("CalamityMod/NPCs/SupremeCalamitas/SCalWormTailGlow"); - Color color37 = Color.Lerp(Color.White, Color.Red, 0.5f); - - spriteBatch.Draw(texture2D15, vector43, npc.frame, color37, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; } @@ -190,32 +183,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override void HitEffect(int hitDirection, double damage) { if (npc.life <= 0) - { - npc.position.X = npc.position.X + (float)(npc.width / 2); - npc.position.Y = npc.position.Y + (float)(npc.height / 2); - npc.width = 50; - npc.height = 50; - npc.position.X = npc.position.X - (float)(npc.width / 2); - npc.position.Y = npc.position.Y - (float)(npc.height / 2); - for (int num621 = 0; num621 < 5; num621++) - { - int num622 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 10; num623++) - { - int num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, 173, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } + { + for (int i = 1; i <= 2; i++) + { + Vector2 goreSpawnPosition = npc.Center; + if (i == 2) + goreSpawnPosition -= (npc.rotation - MathHelper.PiOver2).ToRotationVector2() * 20f; + Gore.NewGorePerfect(goreSpawnPosition, Main.rand.NextVector2Circular(3f, 3f), mod.GetGoreSlot($"Gores/SupremeCalamitas/SepulcherTail_Gore{i}"), npc.scale); + } + } } public override bool CheckActive() diff --git a/NPCs/SupremeCalamitas/SCalWormTail.png b/NPCs/SupremeCalamitas/SCalWormTail.png index a8e1ab41e1..283e094283 100644 Binary files a/NPCs/SupremeCalamitas/SCalWormTail.png and b/NPCs/SupremeCalamitas/SCalWormTail.png differ diff --git a/NPCs/SupremeCalamitas/SCalWormTailGlow.png b/NPCs/SupremeCalamitas/SCalWormTailGlow.png deleted file mode 100644 index 2d4265fd16..0000000000 Binary files a/NPCs/SupremeCalamitas/SCalWormTailGlow.png and /dev/null differ diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs index 894bb0b395..9d706a6e3e 100644 --- a/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs +++ b/NPCs/SupremeCalamitas/SoulSeekerSupreme.cs @@ -16,11 +16,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas { private int timer = 0; private bool start = true; + public NPC SCal => Main.npc[CalamityGlobalNPC.SCal]; + public Player Target => Main.player[npc.target]; + public Vector2 EyePosition => npc.Center + new Vector2(npc.spriteDirection == -1 ? 40f : -36f, 16f); + public ref float RotationalDegreeOffset => ref npc.ai[1]; public override void SetStaticDefaults() { DisplayName.SetDefault("Soul Seeker"); - Main.npcFrameCount[npc.type] = 8; + Main.npcFrameCount[npc.type] = 6; NPCID.Sets.TrailingMode[npc.type] = 1; } @@ -37,8 +41,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas npc.defense = 60; npc.DR_NERD(0.25f); npc.LifeMaxNERB(Main.expertMode ? 24000 : 15000, 28000); - npc.HitSound = SoundID.NPCHit4; - npc.DeathSound = SoundID.NPCDeath14; + npc.DeathSound = SoundID.DD2_SkeletonDeath; } public override void SendExtraAI(BinaryWriter writer) @@ -62,33 +65,35 @@ namespace CalamityMod.NPCs.SupremeCalamitas public override bool PreAI() { - NPC parent = Main.npc[CalamityGlobalNPC.SCal]; - bool expertMode = Main.expertMode; + // Die if SCal is no longer present. + if (CalamityGlobalNPC.SCal < 0 || !SCal.active) + { + npc.active = false; + npc.netUpdate = true; + return false; + } + if (start) { - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); - } - npc.ai[1] = npc.ai[0]; + for (int i = 0; i < 10; i++) + Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); + RotationalDegreeOffset = npc.ai[0]; start = false; } // Get a target - if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead || !Main.player[npc.target].active) + if (npc.target < 0 || npc.target == Main.maxPlayers || Target.dead || !Target.active) npc.TargetClosest(); - // Despawn safety, make sure to target another player if the current player target is too far away - if (Vector2.Distance(Main.player[npc.target].Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance200Tiles) + // Target another player if the current player target is too far away + if (!npc.WithinRange(Target.Center, CalamityGlobalNPC.CatchUpDistance200Tiles)) npc.TargetClosest(); - Vector2 direction = Main.player[npc.target].Center - npc.Center; - direction.Normalize(); - direction *= 9f; - npc.rotation = direction.ToRotation(); + npc.spriteDirection = (Target.Center.X < npc.Center.X).ToDirectionInt(); + timer++; - int timerLimit = CalamityWorld.malice ? 120 : 180; - if (timer > timerLimit) + int shootRate = CalamityWorld.malice ? 120 : 180; + if (timer > shootRate) { for (int i = 0; i < Main.maxNPCs; i++) { @@ -96,7 +101,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (seeker.type == npc.type) { if (seeker == npc) - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), parent.Center); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/BrimstoneShoot"), SCal.Center); break; } } @@ -104,24 +109,15 @@ namespace CalamityMod.NPCs.SupremeCalamitas { int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(npc.Center, direction, type, damage, 1f, Main.myPlayer); + Vector2 shootVelocity = (Target.Center - EyePosition).SafeNormalize(Vector2.UnitY) * 9f; + Projectile.NewProjectile(EyePosition, shootVelocity, type, damage, 1f, Main.myPlayer); } timer = 0; npc.netUpdate = true; } - if (CalamityGlobalNPC.SCal < 0 || !parent.active) - { - npc.active = false; - npc.netUpdate = true; - return false; - } - Player player = Main.player[npc.target]; - double deg = npc.ai[1]; - double rad = deg * (Math.PI / 180); - double dist = 300; - npc.position.X = parent.Center.X - (int)(Math.Cos(rad) * dist) - npc.width / 2; - npc.position.Y = parent.Center.Y - (int)(Math.Sin(rad) * dist) - npc.height / 2; - npc.ai[1] += 0.5f; //2 + + npc.position = SCal.Center - MathHelper.ToRadians(RotationalDegreeOffset).ToRotationVector2() * 300f - npc.Size * 0.5f; + RotationalDegreeOffset += 0.5f; return false; } @@ -159,16 +155,13 @@ namespace CalamityMod.NPCs.SupremeCalamitas num624 = Dust.NewDust(new Vector2(npc.position.X, npc.position.Y), npc.width, npc.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SoulSeekerSupremeGores/SupremeSoulSeeker"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SoulSeekerSupremeGores/SupremeSoulSeeker2"), npc.scale); - Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/SoulSeekerSupremeGores/SupremeSoulSeeker3"), npc.scale); + + for (int i = 1; i <= 5; i++) + Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot($"Gores/SoulSeekerSupremeGores/SupremeSoulSeeker_Gore{i}"), npc.scale); } } - public override bool CheckActive() - { - return false; - } + public override bool CheckActive() => false; public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { @@ -180,7 +173,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); Color color36 = Color.White; float amount9 = 0.5f; - int num153 = 5; + int num153 = 2; if (CalamityConfig.Instance.Afterimages) { diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupreme.png b/NPCs/SupremeCalamitas/SoulSeekerSupreme.png index d0ae0b4980..cea992e2a7 100644 Binary files a/NPCs/SupremeCalamitas/SoulSeekerSupreme.png and b/NPCs/SupremeCalamitas/SoulSeekerSupreme.png differ diff --git a/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png b/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png index 27c809cbac..5c481d1bf2 100644 Binary files a/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png and b/NPCs/SupremeCalamitas/SoulSeekerSupremeGlow.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index d438591214..d2f24dcac9 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -86,8 +86,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas private int spawnY = 0; private int spawnYReset = 0; private int spawnYAdd = 0; - private int bulletHellCounter = 0; - private int bulletHellCounter2 = 0; + public int bulletHellCounter = 0; + public int bulletHellCounter2 = 0; private int attackCastDelay = 0; private int hitTimer = 0; @@ -415,7 +415,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas } // Summon a shield if the next attack will be a charge. - else if (!npc.dontTakeDamage && ((willCharge && AttackCloseToBeingOver) || npc.ai[1] == 2f)) + else if (((willCharge && AttackCloseToBeingOver) || npc.ai[1] == 2f) && bulletHellCounter2 % 900 == 0) { if (npc.ai[1] != 2f) { @@ -1869,7 +1869,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas for (int num388 = 0; num388 < 50; num388++) Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.Brimstone, Main.rand.Next(-30, 31) * 0.2f, Main.rand.Next(-30, 31) * 0.2f, 0, default, 1f); - Main.PlaySound(SoundID.Roar, (int)npc.position.X, (int)npc.position.Y, 0); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SupremeCalamitasSpawn"), npc.Center); } } @@ -2543,20 +2543,18 @@ namespace CalamityMod.NPCs.SupremeCalamitas } // And play a fire-like sound effect. - Main.PlaySound(SoundID.DD2_BetsyWindAttack, target.Center); hasSummonedSepulcher1 = true; hasSummonedSepulcher2 = npc.life <= npc.lifeMax * 0.08; - // TODO: Resprite brimstone hearts a bit. if (Main.netMode != NetmodeID.MultiplayerClient) { List hearts = new List(); for (int x = 0; x < 5; x++) { - hearts.Add(NPC.NewNPC(spawnX + 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); + hearts.Add(NPC.NewNPC(spawnX + 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); spawnX += spawnXAdd; - hearts.Add(NPC.NewNPC(spawnX2 - 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); + hearts.Add(NPC.NewNPC(spawnX2 - 50, tempSpawnY, ModContent.NPCType(), 0, 0f, 0f, 0f, 0f, 255)); spawnX2 -= spawnXAdd; tempSpawnY += spawnYAdd; } @@ -2569,6 +2567,8 @@ namespace CalamityMod.NPCs.SupremeCalamitas NPC.SpawnOnPlayer(npc.FindClosestPlayer(), ModContent.NPCType()); npc.netUpdate = true; } + + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SCalSounds/SepulcherSpawn"), target.Center); } } @@ -2662,7 +2662,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas public void ConnectAllBrimstoneHearts(List heartIndices) { - int heartType = ModContent.NPCType(); + int heartType = ModContent.NPCType(); // Ensure that the hearts go in order based on the arena. IEnumerable hearts = heartIndices.Select(i => Main.npc[i]); @@ -2695,14 +2695,14 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (tries >= 100) endpoint.X = MathHelper.Clamp(endpoint.X, safeBox.Left, safeBox.Right); - heart.ModNPC().ChainEndpoints.Add(endpoint); + heart.ModNPC().ChainEndpoints.Add(endpoint); } if (Main.rand.NextBool(2)) { endpoint.X = heart.Center.X + Main.rand.NextBool(2).ToDirectionInt() * Main.rand.NextFloat(45f, 360f); endpoint.X = MathHelper.Clamp(endpoint.X, safeBox.Left, safeBox.Right); - heart.ModNPC().ChainEndpoints.Add(endpoint); + heart.ModNPC().ChainEndpoints.Add(endpoint); } heart.netUpdate = true; @@ -2945,7 +2945,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas if (lifeRatio < 0.05f) flickerPower += 0.1f; float opacity = forcefieldOpacity; - opacity *= MathHelper.Lerp(1f, 1f - flickerPower, (float)Math.Pow(Math.Cos(Main.GlobalTime * MathHelper.Lerp(3f, 9f, flickerPower)), 24D)); + opacity *= MathHelper.Lerp(1f, MathHelper.Max(1f - flickerPower, 0.56f), (float)Math.Pow(Math.Cos(Main.GlobalTime * MathHelper.Lerp(3f, 5f, flickerPower)), 24D)); // During/prior to a charge the forcefield is always darker than usual and thus its intensity is also higher. if (!npc.dontTakeDamage && (willCharge || npc.ai[1] == 2f)) diff --git a/NPCs/SupremeCalamitas/unknown.png b/NPCs/SupremeCalamitas/unknown.png deleted file mode 100644 index 8aec7550d7..0000000000 Binary files a/NPCs/SupremeCalamitas/unknown.png and /dev/null differ diff --git a/NPCs/TownNPCs/FAP_Head.png b/NPCs/TownNPCs/FAP_Head.png index cce3f796b8..05a348609d 100644 Binary files a/NPCs/TownNPCs/FAP_Head.png and b/NPCs/TownNPCs/FAP_Head.png differ diff --git a/NPCs/TownNPCs/WITCH.cs b/NPCs/TownNPCs/WITCH.cs index a86bed73e7..219026ada2 100644 --- a/NPCs/TownNPCs/WITCH.cs +++ b/NPCs/TownNPCs/WITCH.cs @@ -40,8 +40,6 @@ namespace CalamityMod.NPCs.TownNPCs npc.damage = 10; // You should not be able to kill SCal under any typical circumstances. - npc.Calamity().DR = 0.999999f; - npc.Calamity().unbreakableDR = true; npc.lifeMax = 1000000; npc.defense = 120; diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index fe8964ca63..be93674baa 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -2879,37 +2879,37 @@ namespace CalamityMod.NPCs.Yharon DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); DropHelper.DropItemCondition(npc, ModContent.ItemType(), true, CalamityWorld.malice); - // Phase 1 drops: Contained in the bag, so they only drop directly on Normal - if (!Main.expertMode) - { - // Weapons - float w = DropHelper.NormalWeaponDropRateFloat; - DropHelper.DropEntireWeightedSet(npc, - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), - DropHelper.WeightStack(w), // Yharon Kindle Staff - DropHelper.WeightStack(w), // Infernal Spear - DropHelper.WeightStack(w) - ); + // Normal drops: Everything that would otherwise be in the bag + if (!Main.expertMode) + { + // Weapons + float w = DropHelper.NormalWeaponDropRateFloat; + DropHelper.DropEntireWeightedSet(npc, + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), + DropHelper.WeightStack(w), // Yharon Kindle Staff + DropHelper.WeightStack(w), // Infernal Spear + DropHelper.WeightStack(w) + ); - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - } + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 7); + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); - // Materials - int soulFragMin = Main.expertMode ? 22 : 15; - int soulFragMax = Main.expertMode ? 28 : 22; - DropHelper.DropItem(npc, ModContent.ItemType(), true, soulFragMin, soulFragMax); + // Materials + int soulFragMin = 15; + int soulFragMax = 22; + DropHelper.DropItem(npc, ModContent.ItemType(), true, soulFragMin, soulFragMax); - // Equipment - DropHelper.DropItem(npc, ModContent.ItemType(), Main.expertMode); + // Equipment + DropHelper.DropItem(npc, ModContent.ItemType(), Main.expertMode); + } - // Vanity - DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); + // Vanity + DropHelper.DropItemChance(npc, ModContent.ItemType(), 10); // Other // DropHelper.DropItem(npc, ModContent.ItemType()); @@ -2918,7 +2918,7 @@ namespace CalamityMod.NPCs.Yharon // If Yharon has not been killed yet, notify players of Auric Ore if (!CalamityWorld.downedYharon) { - WorldGenerationMethods.SpawnOre(ModContent.TileType(), 2E-05, .6f, .8f); + CalamityUtils.SpawnOre(ModContent.TileType(), 2E-05, 0.6f, 0.8f, 6, 12); string key = "Mods.CalamityMod.AuricOreText"; Color messageColor = Color.Gold; diff --git a/Particles/BaseParticleSet.cs b/Particles/BaseParticleSet.cs index 8490181b26..f5c48fdf59 100644 --- a/Particles/BaseParticleSet.cs +++ b/Particles/BaseParticleSet.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Particles return; bool closeToDeath = LocalTimer >= SetLifetime - ParticleLifetime && SetLifetime > 0; - if (LocalTimer % ParticleSpawnRate == 0 && !closeToDeath) + if (LocalTimer % ParticleSpawnRate == ParticleSpawnRate - 1 && !closeToDeath) { Particle particle = SpawnParticle(); particle.Lifetime = ParticleLifetime; diff --git a/Projectiles/Boss/AresDeathBeamStart.png b/Projectiles/Boss/AresDeathBeamStart.png new file mode 100644 index 0000000000..ff960c8d6a Binary files /dev/null and b/Projectiles/Boss/AresDeathBeamStart.png differ diff --git a/Projectiles/Boss/AresGaussNukeProjectile.cs b/Projectiles/Boss/AresGaussNukeProjectile.cs new file mode 100644 index 0000000000..e950b6c502 --- /dev/null +++ b/Projectiles/Boss/AresGaussNukeProjectile.cs @@ -0,0 +1,185 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class AresGaussNukeProjectile : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Nuke"); + Main.projFrames[projectile.type] = 12; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 100; + projectile.height = 100; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = 480; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } + + public override void AI() + { + // Animation + projectile.frameCounter++; + if (projectile.frameCounter >= 10) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= 12) + projectile.frame = 0; + + // Rotation + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + + Vector2 dustOffset = Vector2.One * 50f; + + if (projectile.ai[1] == 0f) + { + projectile.ai[1] = 1f; + for (int i = 0; i < 25; i++) + { + // Choose a random speed and angle + float dustSpeed = Main.rand.NextFloat(3f, 13f); + float angleRandom = 0.06f; + Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(projectile.velocity.ToRotation()); + dustVel = dustVel.RotatedBy(-angleRandom); + dustVel = dustVel.RotatedByRandom(2f * angleRandom); + + // Random size + float scale = Main.rand.NextFloat(0.5f, 1.6f); + + // Spawn dust + Dust dust = Dust.NewDustPerfect(projectile.Center + dustOffset, 107, -dustVel, 0, default, scale); + dust.noGravity = true; + } + } + else + { + // Generate dust behind the nuke + for (int i = 0; i < 2; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + dustOffset, 107); + dust.velocity = -projectile.velocity * 0.5f; + dust.noGravity = true; + } + } + + // Light + Lighting.AddLight(projectile.Center, 0.2f, 0.25f, 0.05f); + + // Get a target and calculate distance from it + int target = Player.FindClosest(projectile.Center, 1, 1); + Vector2 distanceFromTarget = Main.player[target].Center - projectile.Center; + + // Set AI to stop homing, start accelerating + float stopHomingDistance = 300f; + if (distanceFromTarget.Length() < stopHomingDistance || projectile.ai[0] == 1f) + { + projectile.ai[0] = 1f; + + if (projectile.velocity.Length() < 24f) + projectile.velocity *= 1.025f; + + return; + } + + // Home in on target + float scaleFactor = projectile.velocity.Length(); + float inertia = 10f; + distanceFromTarget.Normalize(); + distanceFromTarget *= scaleFactor; + projectile.velocity = (projectile.velocity * inertia + distanceFromTarget) / (inertia + 1f); + projectile.velocity.Normalize(); + projectile.velocity *= scaleFactor; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + + Rectangle frame = new Rectangle(0, projectile.frame * Main.projectileTexture[projectile.type].Height, Main.projectileTexture[projectile.type].Width, Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]); + + Color color = Color.Lerp(Color.White, Color.GreenYellow, 0.5f) * projectile.Opacity; + + spriteBatch.Draw(ModContent.GetTexture("CalamityMod/Projectiles/Boss/AresGaussNukeProjectileGlow"), projectile.Center - Main.screenPosition, frame, color, projectile.rotation, projectile.Size / 2, 1f, SpriteEffects.None, 0f); + + return false; + } + + public override bool CanHitPlayer(Player target) + { + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= 45f; + } + + public override void Kill(int timeLeft) + { + // Nuke explosion sound + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), projectile.Center); + + // Nuke gores + Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke1"), 1f); + Gore.NewGore(projectile.position, projectile.velocity, mod.GetGoreSlot("Gores/Ares/AresGaussNuke3"), 1f); + + if (Main.myPlayer == projectile.owner) + { + // Gauss sparks + int totalProjectiles = CalamityWorld.malice ? 18 : 12; + float radians = MathHelper.TwoPi / totalProjectiles; + int type = ModContent.ProjectileType(); + float velocity = 12f; + double angleA = radians * 0.5; + double angleB = MathHelper.ToRadians(90f) - angleA; + float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); + Vector2 spinningPoint = Main.rand.NextBool() ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); + for (int k = 0; k < totalProjectiles; k++) + { + Vector2 velocity2 = spinningPoint.RotatedBy(radians * k); + Projectile.NewProjectile(projectile.Center, velocity2, type, (int)(projectile.damage * 0.6), 0f, Main.myPlayer); + } + + // Explosion waves + for (int i = 0; i < 7; i++) + { + Projectile explosion = Projectile.NewProjectileDirect(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, Main.myPlayer); + if (explosion.whoAmI.WithinBounds(Main.maxProjectiles)) + { + explosion.ai[1] = 800f + i * 45f; + explosion.localAI[1] = 0.25f; + explosion.Opacity = MathHelper.Lerp(0.18f, 0.6f, i / 7f) + Main.rand.NextFloat(-0.08f, 0.08f); + explosion.netUpdate = true; + } + } + } + } + } +} diff --git a/Projectiles/Boss/AresGaussNukeProjectile.png b/Projectiles/Boss/AresGaussNukeProjectile.png new file mode 100644 index 0000000000..ef31e390ff Binary files /dev/null and b/Projectiles/Boss/AresGaussNukeProjectile.png differ diff --git a/Projectiles/Boss/AresGaussNukeProjectileBoom.cs b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs new file mode 100644 index 0000000000..5ead9f995c --- /dev/null +++ b/Projectiles/Boss/AresGaussNukeProjectileBoom.cs @@ -0,0 +1,153 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public struct ScreenShakeSpot + { + public float ScreenShakePower; + public Vector2 Position; + public ScreenShakeSpot(float screenShakePower, Vector2 position) + { + ScreenShakePower = screenShakePower; + Position = position; + } + } + + public class AresGaussNukeProjectileBoom : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public ScreenShakeSpot CurrentSpot; + + public float Radius + { + get => projectile.ai[0]; + set => projectile.ai[0] = value; + } + + public float MaxRadius + { + get => projectile.ai[1]; + set => projectile.ai[1] = value; + } + + public float InterpolationStep + { + get => projectile.localAI[1]; + set => projectile.localAI[1] = value; + } + + public const int Lifetime = 60; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Explosion"); + ProjectileID.Sets.NeedsUUID[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.Calamity().canBreakPlayerDefense = true; + projectile.width = 2; + projectile.height = 2; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.penetrate = -1; + projectile.timeLeft = Lifetime; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(projectile.localAI[0]); + writer.Write(projectile.localAI[1]); + writer.Write(CurrentSpot.ScreenShakePower); + writer.WriteVector2(CurrentSpot.Position); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + projectile.localAI[0] = reader.ReadSingle(); + projectile.localAI[1] = reader.ReadSingle(); + CurrentSpot = new ScreenShakeSpot(reader.ReadInt32(), reader.ReadVector2()); + } + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + CurrentSpot = new ScreenShakeSpot(0, projectile.Center); + projectile.localAI[0] = 1f; + } + + CurrentSpot.ScreenShakePower = (float)Math.Sin(MathHelper.Pi * projectile.timeLeft / Lifetime) * 16f; + CurrentSpot.Position = projectile.Center; + CalamityWorld.ScreenShakeSpots[Projectile.GetByUUID(projectile.owner, projectile.whoAmI)] = CurrentSpot; + + Lighting.AddLight(projectile.Center, 0.2f, 0.1f, 0f); + Radius = MathHelper.Lerp(Radius, MaxRadius, 0.25f); + projectile.scale = MathHelper.Lerp(1.2f, 5f, Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true)); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, (int)(Radius * projectile.scale), (int)(Radius * projectile.scale)); + } + + public override void Kill(int timeLeft) + { + CalamityWorld.ScreenShakeSpots.Remove(Projectile.GetByUUID(projectile.owner, projectile.whoAmI)); // Remove the explosion associated with this projectile's UUID. + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.ZoomMatrix); + + float pulseCompletionRatio = Utils.InverseLerp(Lifetime, 0f, projectile.timeLeft, true); + Vector2 scale = new Vector2(1.5f, 1f); + DrawData drawData = new DrawData(ModContent.GetTexture("Terraria/Misc/Perlin"), + projectile.Center - Main.screenPosition + projectile.Size * scale * 0.5f, + new Rectangle(0, 0, projectile.width, projectile.height), + new Color(new Vector4(1f - (float)Math.Sqrt(pulseCompletionRatio))) * 0.7f * projectile.Opacity, + projectile.rotation, + projectile.Size, + scale, + SpriteEffects.None, 0); + + Color pulseColor = Color.Lerp(Color.Yellow * 1.6f, Color.White, MathHelper.Clamp(pulseCompletionRatio * 2.2f, 0f, 1f)); + GameShaders.Misc["ForceField"].UseColor(pulseColor); + GameShaders.Misc["ForceField"].Apply(drawData); + drawData.Draw(spriteBatch); + + spriteBatch.End(); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + return false; + } + + public override bool CanHitPlayer(Player target) + { + Rectangle targetHitbox = target.Hitbox; + + float dist1 = Vector2.Distance(projectile.Center, targetHitbox.TopLeft()); + float dist2 = Vector2.Distance(projectile.Center, targetHitbox.TopRight()); + float dist3 = Vector2.Distance(projectile.Center, targetHitbox.BottomLeft()); + float dist4 = Vector2.Distance(projectile.Center, targetHitbox.BottomRight()); + + float minDist = dist1; + if (dist2 < minDist) + minDist = dist2; + if (dist3 < minDist) + minDist = dist3; + if (dist4 < minDist) + minDist = dist4; + + return minDist <= Radius * projectile.scale * 0.5f; + } + } +} diff --git a/Projectiles/Boss/AresGaussNukeProjectileGlow.png b/Projectiles/Boss/AresGaussNukeProjectileGlow.png new file mode 100644 index 0000000000..9af93005df Binary files /dev/null and b/Projectiles/Boss/AresGaussNukeProjectileGlow.png differ diff --git a/Projectiles/Boss/AresGaussNukeProjectileSpark.cs b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs new file mode 100644 index 0000000000..064e5ab9f3 --- /dev/null +++ b/Projectiles/Boss/AresGaussNukeProjectileSpark.cs @@ -0,0 +1,63 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class AresGaussNukeProjectileSpark : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gauss Spark"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 0; + } + + public override void SetDefaults() + { + projectile.width = 14; + projectile.height = 14; + projectile.hostile = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.alpha = 255; + projectile.penetrate = -1; + projectile.timeLeft = 600; + projectile.Calamity().affectedByMaliceModeVelocityMultiplier = true; + } + + public override void AI() + { + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; + + if (projectile.alpha > 0) + projectile.alpha -= 50; + if (projectile.alpha < 0) + projectile.alpha = 0; + + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) - MathHelper.PiOver2; + } + + public override Color? GetAlpha(Color lightColor) + { + return new Color(255, 255, 255, projectile.alpha); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Boss/AresGaussNukeProjectileSpark.png b/Projectiles/Boss/AresGaussNukeProjectileSpark.png new file mode 100644 index 0000000000..7424a71ed9 Binary files /dev/null and b/Projectiles/Boss/AresGaussNukeProjectileSpark.png differ diff --git a/Projectiles/Boss/AresLaserBeamStart.png b/Projectiles/Boss/AresLaserBeamStart.png new file mode 100644 index 0000000000..c8f3f346d7 Binary files /dev/null and b/Projectiles/Boss/AresLaserBeamStart.png differ diff --git a/Projectiles/Boss/AresPlasmaBolt.png b/Projectiles/Boss/AresPlasmaBolt.png new file mode 100644 index 0000000000..90c44f1636 Binary files /dev/null and b/Projectiles/Boss/AresPlasmaBolt.png differ diff --git a/Projectiles/Boss/AresPlasmaFireball.png b/Projectiles/Boss/AresPlasmaFireball.png new file mode 100644 index 0000000000..633e28aa10 Binary files /dev/null and b/Projectiles/Boss/AresPlasmaFireball.png differ diff --git a/Projectiles/Boss/AresTeslaOrb.png b/Projectiles/Boss/AresTeslaOrb.png new file mode 100644 index 0000000000..3b97306c4d Binary files /dev/null and b/Projectiles/Boss/AresTeslaOrb.png differ diff --git a/Projectiles/Boss/BrimstoneHellblast2.cs b/Projectiles/Boss/BrimstoneHellblast2.cs index 835fcf0b35..776cab7cc1 100644 --- a/Projectiles/Boss/BrimstoneHellblast2.cs +++ b/Projectiles/Boss/BrimstoneHellblast2.cs @@ -1,9 +1,11 @@ using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Boss { public class BrimstoneHellblast2 : ModProjectile @@ -31,6 +33,13 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + // Cal Clone bullet hell projectiles accelerate after a certain time has passed + if (projectile.ai[0] == 2f && Main.expertMode && projectile.timeLeft < 1260) + { + if (projectile.velocity.Length() < (CalamityWorld.malice ? 10f : 8f)) + projectile.velocity *= 1.02f; + } + projectile.frameCounter++; if (projectile.frameCounter >= 10) { diff --git a/Projectiles/Boss/ExoDestroyerLaser.cs b/Projectiles/Boss/ExoDestroyerLaser.cs index c24cd45435..082961f046 100644 --- a/Projectiles/Boss/ExoDestroyerLaser.cs +++ b/Projectiles/Boss/ExoDestroyerLaser.cs @@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Boss projectile.alpha = 255; projectile.penetrate = -1; projectile.extraUpdates = 1; - projectile.timeLeft = 300; + projectile.timeLeft = 600; cooldownSlot = 1; } @@ -95,6 +95,7 @@ namespace CalamityMod.Projectiles.Boss // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> if (Velocity != Vector2.Zero) { + projectile.extraUpdates = 2; projectile.velocity = Velocity * (CalamityWorld.malice ? 1.25f : 1f); Velocity = Vector2.Zero; projectile.netUpdate = true; @@ -154,7 +155,8 @@ namespace CalamityMod.Projectiles.Boss // If a velocity is in reserve, set the true velocity to it and make it as "taken" by setting it to <0,0> if (Velocity != Vector2.Zero) { - projectile.velocity = Velocity * (CalamityWorld.malice ? 1.25f : 1f); + projectile.extraUpdates = 2; + projectile.velocity = Velocity * (CalamityWorld.malice ? 1.25f : 1f); Velocity = Vector2.Zero; projectile.netUpdate = true; } diff --git a/Projectiles/Boss/MushBombFall.cs b/Projectiles/Boss/MushBombFall.cs index 9d2bb04388..97e10db02c 100644 --- a/Projectiles/Boss/MushBombFall.cs +++ b/Projectiles/Boss/MushBombFall.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - projectile.velocity.Y = CalamityWorld.malice ? 7.5f : CalamityWorld.death ? 6f : 5f; + projectile.velocity.Y = CalamityWorld.malice ? 8f : CalamityWorld.death ? 6f : 5f; projectile.frameCounter++; if (projectile.frameCounter > 4) diff --git a/Projectiles/Boss/SCalRitualDrama.cs b/Projectiles/Boss/SCalRitualDrama.cs index 215ae94a4f..eb6ca69f86 100644 --- a/Projectiles/Boss/SCalRitualDrama.cs +++ b/Projectiles/Boss/SCalRitualDrama.cs @@ -1,5 +1,6 @@ using CalamityMod.Dusts; using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Skies; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -53,7 +54,6 @@ namespace CalamityMod.Projectiles.Boss // Make a laugh sound and create a burst of brimstone dust. Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/SupremeCalamitasSpawn"), projectile.Center); - Main.PlaySound(SoundID.DD2_EtherianPortalDryadTouch, projectile.Center); Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.InverseLerp(3400f, 1560f, Main.LocalPlayer.Distance(projectile.Center), true) * 16f; diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index acaf027920..a6b5708cd6 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -230,6 +230,11 @@ namespace CalamityMod.Projectiles projectile.idStaticNPCHitCooldown = 18; break; + case ProjectileID.MonkStaffT3: + case ProjectileID.MonkStaffT3_Alt: + projectile.scale = 2f; + break; + case ProjectileID.Retanimini: case ProjectileID.MiniRetinaLaser: case ProjectileID.FlowerPetal: @@ -2130,20 +2135,20 @@ namespace CalamityMod.Projectiles { if (projectile.type == ProjectileID.PureSpray || projectile.type == ProjectileID.PurificationPowder) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Pure, !isPowder); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Pure, !isPowder); } //commented out for Terraria 1.4 when vile/vicious powder spread corruption/crimson if (projectile.type == ProjectileID.CorruptSpray)// || projectile.type == ProjectileID.VilePowder) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Corrupt, !isPowder); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Corrupt, !isPowder); } if (projectile.type == ProjectileID.CrimsonSpray)// || projectile.type == ProjectileID.ViciousPowder) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Crimson, !isPowder); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Crimson, !isPowder); } if (projectile.type == ProjectileID.HallowSpray) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Hallow); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Hallow); } NetMessage.SendTileRange(-1, i, j, 1, 1); } diff --git a/Projectiles/Enemy/DraedonLaser.cs b/Projectiles/Enemy/DraedonLaser.cs index bd23f57e4d..3c586a3628 100644 --- a/Projectiles/Enemy/DraedonLaser.cs +++ b/Projectiles/Enemy/DraedonLaser.cs @@ -40,7 +40,10 @@ namespace CalamityMod.Projectiles.Enemy if (projectile.localAI[0] == 0f) { // play a sound frame 1. changed this from space gun sound because that sound was way too annoying - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), projectile.Center); + var sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), projectile.Center); + if (sound != null) + sound.Volume *= 0.35f; + projectile.localAI[0] = 1f; } projectile.alpha = (int)(Math.Sin(projectile.timeLeft / 240f * MathHelper.Pi) * 1.6f * 255f); diff --git a/Projectiles/Healing/RainHeal.cs b/Projectiles/Healing/RainHeal.cs index 7ec71fe52d..3a4669b204 100644 --- a/Projectiles/Healing/RainHeal.cs +++ b/Projectiles/Healing/RainHeal.cs @@ -25,9 +25,13 @@ namespace CalamityMod.Projectiles.Healing public override void AI() { - projectile.velocity *= 0.99f; - - projectile.HealingProjectile(8, projectile.owner, 12f, 15f, false); + if (projectile.timeLeft < 165) + { + if (projectile.timeLeft > 150) + projectile.velocity *= 0.9f; + else + projectile.HealingProjectile(8, projectile.owner, 12f, 15f, false); + } float num498 = projectile.velocity.X * 0.2f; float num499 = -(projectile.velocity.Y * 0.2f); diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index 43dfe695e1..57c21c93f0 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee projectile.melee = true; projectile.friendly = true; projectile.penetrate = -1; - projectile.timeLeft = 300; + projectile.timeLeft = 90000; projectile.tileCollide = false; projectile.ignoreWater = true; projectile.alpha = 255; @@ -36,12 +36,13 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { Player player = Main.player[projectile.owner]; - float lifeSpan = 50f; + float spinCycleTime = 50f; // If the player is dead, destroy the projectile - if (player.dead) + if (player.dead || !player.channel) { projectile.Kill(); + player.reuseDelay = 2; return; } @@ -59,25 +60,16 @@ namespace CalamityMod.Projectiles.Melee } projectile.ai[0] += 1f; - projectile.rotation += MathHelper.TwoPi * 2f / lifeSpan * (float)direction; - bool halfWay = projectile.ai[0] == lifeSpan / 2f; - if (projectile.ai[0] >= lifeSpan || (halfWay && !player.controlUseItem)) + projectile.rotation += MathHelper.TwoPi * 2f / spinCycleTime * (float)direction; + int expectedDirection = (player.SafeDirectionTo(Main.MouseWorld).X > 0f).ToDirectionInt(); + if (projectile.ai[0] % spinCycleTime > spinCycleTime * 0.5f && expectedDirection != projectile.velocity.X) { - projectile.Kill(); - player.reuseDelay = 2; + player.ChangeDir(expectedDirection); + projectile.velocity = Vector2.UnitX * expectedDirection; + projectile.rotation -= MathHelper.Pi; + projectile.netUpdate = true; } - else if (halfWay) - { - int expectedDirection = (player.SafeDirectionTo(Main.MouseWorld).X > 0f).ToDirectionInt(); - if (expectedDirection != projectile.velocity.X) - { - player.ChangeDir(expectedDirection); - projectile.velocity = Vector2.UnitX * expectedDirection; - projectile.rotation -= MathHelper.Pi; - projectile.netUpdate = true; - } - } - SpawnDust(player, direction); + SpawnDust(player, direction); PositionAndRotation(player); VisibilityAndLight(); } diff --git a/Projectiles/Melee/RainBolt.cs b/Projectiles/Melee/RainBolt.cs index a1817ae411..f430295a54 100644 --- a/Projectiles/Melee/RainBolt.cs +++ b/Projectiles/Melee/RainBolt.cs @@ -27,8 +27,6 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - projectile.velocity *= 0.95f; - if (projectile.localAI[0] == 0f) { Main.PlaySound(SoundID.Item9, projectile.Center); @@ -41,9 +39,11 @@ namespace CalamityMod.Projectiles.Melee if (projectile.timeLeft < 150) CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 600f, 12f, 20f); - } + else + projectile.velocity *= 0.95f; + } - public override void Kill(int timeLeft) + public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item60, projectile.Center); for (int k = 0; k < 5; k++) diff --git a/Projectiles/Melee/UltimusCleaverDust.cs b/Projectiles/Melee/UltimusCleaverDust.cs index 34be378aa3..6c52362304 100644 --- a/Projectiles/Melee/UltimusCleaverDust.cs +++ b/Projectiles/Melee/UltimusCleaverDust.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Melee projectile.height = 12; projectile.friendly = true; projectile.ignoreWater = true; - projectile.penetrate = 5; - projectile.timeLeft = 120; + projectile.penetrate = 2; + projectile.timeLeft = 90; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.tileCollide = false; diff --git a/Projectiles/Melee/Yoyos/OracleYoyo.cs b/Projectiles/Melee/Yoyos/OracleYoyo.cs index e23ff9c76e..64e6a384b9 100644 --- a/Projectiles/Melee/Yoyos/OracleYoyo.cs +++ b/Projectiles/Melee/Yoyos/OracleYoyo.cs @@ -27,9 +27,12 @@ namespace CalamityMod.Projectiles.Melee.Yoyos private const float MinDischargeRate = 0.05f; private const float MaxDischargeRate = 0.53f; private const float DischargeRateScaleFactor = 0.003f; - private const float ChargePerHit = 3f; + private const float ChargePerHit = 4.5f; private const int HitsPerOrbVolley = 3; + // The aura hits once per this many frames. + private const int AuraLocalIFrames = 10; + // Ensures that the main AI only runs once per frame, despite the projectile's multiple updates private const int UpdatesPerFrame = 3; @@ -67,13 +70,13 @@ namespace CalamityMod.Projectiles.Melee.Yoyos projectile.penetrate = -1; projectile.MaxUpdates = UpdatesPerFrame; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 3 * UpdatesPerFrame; + projectile.localNPCHitCooldown = 7 * UpdatesPerFrame; } public override void AI() { - if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks - projectile.Kill(); + if ((projectile.position - Main.player[projectile.owner].position).Length() > 3200f) //200 blocks + projectile.Kill(); // Only do stuff once per frame, despite the yoyo's extra updates. if (!projectile.FinalExtraUpdate()) @@ -117,7 +120,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Main.PlaySound(SoundID.Item93, (int)projectile.Center.X, (int)projectile.Center.Y); } - if (AuraFrame % 5 == 4) + if (AuraFrame % AuraLocalIFrames == 0) { // The aura's direct damage scales with its charge and with melee stats. float chargeRatio = AuraCharge / MaxCharge; @@ -127,7 +130,8 @@ namespace CalamityMod.Projectiles.Melee.Yoyos } else projectile.soundDelay = 2; - AuraFrame++; + + AuraFrame = (AuraFrame + 1) % AuraLocalIFrames; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -235,11 +239,11 @@ namespace CalamityMod.Projectiles.Melee.Yoyos if (projectile.owner == Main.myPlayer) { Projectile p = Projectile.NewProjectileDirect(target.Center, Vector2.Zero, ModContent.ProjectileType(), finalDamage, 0f, projectile.owner, i); - if (p.whoAmI.WithinBounds(Main.maxProjectiles)) - { - p.melee = true; - p.Calamity().forceMelee = true; - } + if (p.whoAmI.WithinBounds(Main.maxProjectiles)) + { + p.melee = true; + p.Calamity().forceMelee = true; + } } } } diff --git a/Projectiles/Ranged/Chicken.cs b/Projectiles/Ranged/Chicken.cs deleted file mode 100644 index 6c2ece7e7f..0000000000 --- a/Projectiles/Ranged/Chicken.cs +++ /dev/null @@ -1,121 +0,0 @@ -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class Chicken : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Chicken"); - Main.projFrames[projectile.type] = 4; - } - - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.aiStyle = 1; - projectile.ranged = true; - } - - public override void AI() - { - projectile.frameCounter++; - if (projectile.frameCounter > 4) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - if (Math.Abs(projectile.velocity.X) >= 8f || Math.Abs(projectile.velocity.Y) >= 8f) - { - for (int num246 = 0; num246 < 2; num246++) - { - float num247 = 0f; - float num248 = 0f; - if (num246 == 1) - { - num247 = projectile.velocity.X * 0.5f; - num248 = projectile.velocity.Y * 0.5f; - } - int num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); - Main.dust[num249].scale *= 2f + (float)Main.rand.Next(10) * 0.1f; - Main.dust[num249].velocity *= 0.2f; - Main.dust[num249].noGravity = true; - num249 = Dust.NewDust(new Vector2(projectile.position.X + 3f + num247, projectile.position.Y + 3f + num248) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); - Main.dust[num249].fadeIn = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num249].velocity *= 0.05f; - } - if (Math.Abs(projectile.velocity.X) < 15f && Math.Abs(projectile.velocity.Y) < 15f) - { - projectile.velocity *= 1.1f; - } - else if (Main.rand.NextBool(2)) - { - int num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 0.1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].fadeIn = 1.5f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy((double)projectile.rotation, default) * 1.1f; - Main.rand.Next(2); - num252 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); - Main.dust[num252].scale = 1f + (float)Main.rand.Next(5) * 0.1f; - Main.dust[num252].noGravity = true; - Main.dust[num252].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy((double)projectile.rotation, default) * 1.1f; - } - } - projectile.ai[0] += 1f; - projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; - } - - public override bool OnTileCollide(Vector2 oldVelocity) - { - projectile.velocity.X = 0f; - projectile.velocity.Y = -15f; - projectile.timeLeft = 20; - return false; - } - - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 1040; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - if (projectile.owner == Main.myPlayer) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); - } - Main.PlaySound(SoundID.Item14, (int)projectile.Center.X, (int)projectile.Center.Y); - for (int num621 = 0; num621 < 40; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 70; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - - - } -} diff --git a/Projectiles/Ranged/ChickenExplosion.cs b/Projectiles/Ranged/ChickenExplosion.cs index d7dc9c24a0..a1ea46359f 100644 --- a/Projectiles/Ranged/ChickenExplosion.cs +++ b/Projectiles/Ranged/ChickenExplosion.cs @@ -3,6 +3,7 @@ using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Ranged { public class ChickenExplosion : ModProjectile @@ -11,7 +12,7 @@ namespace CalamityMod.Projectiles.Ranged public override void SetStaticDefaults() { - DisplayName.SetDefault("Explosion"); + DisplayName.SetDefault("Kentucky Fried Explosion"); } public override void SetDefaults() @@ -25,7 +26,7 @@ namespace CalamityMod.Projectiles.Ranged projectile.timeLeft = 150; projectile.ranged = true; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; + projectile.localNPCHitCooldown = 15; } public override void AI() @@ -36,62 +37,42 @@ namespace CalamityMod.Projectiles.Ranged Main.PlaySound(SoundID.Item20, (int)projectile.position.X, (int)projectile.position.Y); projectile.localAI[0] += 1f; } - bool flag15 = false; - bool flag16 = false; - if (projectile.velocity.X < 0f && projectile.position.X < projectile.ai[0]) + + EmitDust(); + } + + public void EmitDust() + { + if (Main.dedServ) + return; + + for (int i = 0; i < 70; i++) { - flag15 = true; - } - if (projectile.velocity.X > 0f && projectile.position.X > projectile.ai[0]) - { - flag15 = true; - } - if (projectile.velocity.Y < 0f && projectile.position.Y < projectile.ai[1]) - { - flag16 = true; - } - if (projectile.velocity.Y > 0f && projectile.position.Y > projectile.ai[1]) - { - flag16 = true; - } - if (flag15 && flag16) - { - projectile.Kill(); - } - float num461 = 25f; - if (projectile.ai[0] > 180f) - { - num461 -= (projectile.ai[0] - 180f) / 2f; - } - if (num461 <= 0f) - { - num461 = 0f; - projectile.Kill(); - } - num461 *= 0.7f; - projectile.ai[0] += 4f; - int num462 = 0; - while ((float)num462 < num461) - { - float num463 = (float)Main.rand.Next(-120, 121); - float num464 = (float)Main.rand.Next(-120, 121); - float num465 = (float)Main.rand.Next(36, 108); - float num466 = (float)Math.Sqrt((double)(num463 * num463 + num464 * num464)); - num466 = num465 / num466; - num463 *= num466; - num464 *= num466; - int num467 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2.5f); - Main.dust[num467].noGravity = true; - Main.dust[num467].position.X = projectile.Center.X; - Main.dust[num467].position.Y = projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[num467]; - expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[num467]; - expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[num467].velocity.X = num463; - Main.dust[num467].velocity.Y = num464; - num462++; + // The exponent being greater than 1 gives the randomness a bias towards 0. This means that more dust will spawn + // closer to the center than the edge. + Vector2 dustSpawnOffset = Main.rand.NextVector2Unit() * (float)Math.Pow(Main.rand.NextFloat(), 2.4D) * projectile.Size * 0.5f; + + // Dust should fly off more quickly the farther away it is from the center. + // At 5% out, a speed of 5 pixels/second is achieved. At 85%, a speed of 15 pixels/second is. + // Direction is determined based on the outward direction rotated by anywhere from -90 to 90 degrees. + Vector2 dustVelocity = dustSpawnOffset.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.PiOver2 * Main.rand.NextFloatDirection()); + dustVelocity *= MathHelper.Lerp(5f, 15f, Utils.InverseLerp(0.05f, 0.85f, (dustSpawnOffset / projectile.Size / 0.5f).Length())); + + // Fire variants. + int dustType = 6; + if (Main.rand.NextBool(4)) + dustType = 244; + + // Smoke. + if (Main.rand.NextBool(7)) + dustType = 31; + + Dust flame = Dust.NewDustPerfect(projectile.Center + dustSpawnOffset, dustType, dustVelocity); + flame.scale = Main.rand.NextFloat(0.85f, 1.3f); + flame.noGravity = true; } } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(projectile.Center, projectile.Size.Length() * 0.5f, targetHitbox); } } diff --git a/Projectiles/Ranged/ChickenRocket.cs b/Projectiles/Ranged/ChickenRocket.cs new file mode 100644 index 0000000000..27fbee1ae4 --- /dev/null +++ b/Projectiles/Ranged/ChickenRocket.cs @@ -0,0 +1,133 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class ChickenRocket : ModProjectile + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Chicken Rocket"); + Main.projFrames[projectile.type] = 4; + } + + public override void SetDefaults() + { + projectile.width = 10; + projectile.height = 10; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.MaxUpdates = 2; + projectile.timeLeft = 300; + projectile.ranged = true; + } + + public override void AI() + { + // Animation frames. + projectile.frameCounter++; + if (projectile.frameCounter > 4) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; + + float speed = projectile.velocity.Length(); + if (speed >= 12f) + { + // If the rocket is going fast enough, emit some dust. + for (int i = 0; i < 2; i++) + { + float dx = i == 1 ? projectile.velocity.X * 0.5f : 0f; + float dy = i == 1 ? projectile.velocity.Y * 0.5f : 0f; + int d = Dust.NewDust(new Vector2(projectile.position.X + 3f + dx, projectile.position.Y + 3f + dy) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 6, 0f, 0f, 100, default, 1f); + Main.dust[d].scale *= 2f + Main.rand.NextFloat(); + Main.dust[d].velocity *= 0.2f; + Main.dust[d].noGravity = true; + d = Dust.NewDust(new Vector2(projectile.position.X + 3f + dx, projectile.position.Y + 3f + dy) - projectile.velocity * 0.5f, projectile.width - 8, projectile.height - 8, 244, 0f, 0f, 100, default, 0.5f); + Main.dust[d].fadeIn = 1f + Main.rand.NextFloat(0.5f); + Main.dust[d].velocity *= 0.05f; + } + + // Exponentially accelerate if not going fast enough yet. + if (speed < 18f) + projectile.velocity *= 1.006f; + + // When going at very high speed, emit even more dust. + else if (Main.rand.NextBool()) + { + int d = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); + Main.dust[d].scale = 0.1f + Main.rand.NextFloat(0.5f); + Main.dust[d].fadeIn = 1.5f + Main.rand.NextFloat(0.5f); + Main.dust[d].noGravity = true; + Main.dust[d].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2)).RotatedBy(projectile.rotation) * 1.1f; + Main.rand.Next(2); + d = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 1f); + Main.dust[d].scale = 1f + Main.rand.NextFloat(0.5f); + Main.dust[d].noGravity = true; + Main.dust[d].position = projectile.Center + new Vector2(0f, (float)(-(float)projectile.height / 2 - 6)).RotatedBy(projectile.rotation) * 1.1f; + } + } + + projectile.ai[0] += 1f; + projectile.rotation = (float)Math.Atan2(projectile.velocity.Y, projectile.velocity.X) + MathHelper.PiOver2; + + // Slight gravity, equivalent to Plasma Grenade. + projectile.velocity.Y += 0.09f; + } + + // Instead of dying instantly on collision, fly straight up for a moment. + public override bool OnTileCollide(Vector2 oldVelocity) + { + projectile.velocity.X = 0f; + projectile.velocity.Y = -15f; + + // If there isn't much time left anyway, just explode immediately on collision. + if (projectile.timeLeft > 20) + projectile.timeLeft = 20; + else + return true; + + return false; + } + + public override void Kill(int timeLeft) + { + projectile.position = projectile.Center; + projectile.width = projectile.height = 1040; + projectile.position.X = projectile.position.X - (float)(projectile.width / 2); + projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); + if (projectile.owner == Main.myPlayer) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + Main.PlaySound(SoundID.Item14, (int)projectile.Center.X, (int)projectile.Center.Y); + for (int i = 0; i < 40; i++) + { + int d = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 31, 0f, 0f, 100, default, 2f); + Main.dust[d].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[d].scale = 0.5f; + Main.dust[d].fadeIn = 1f + Main.rand.NextFloat(); + } + } + for (int i = 0; i < 70; i++) + { + int d = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 3f); + Main.dust[d].noGravity = true; + Main.dust[d].velocity *= 5f; + d = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 6, 0f, 0f, 100, default, 2f); + Main.dust[d].velocity *= 2f; + } + } + + + } +} diff --git a/Projectiles/Ranged/Chicken.png b/Projectiles/Ranged/ChickenRocket.png similarity index 100% rename from Projectiles/Ranged/Chicken.png rename to Projectiles/Ranged/ChickenRocket.png diff --git a/Projectiles/Ranged/PrismMine.cs b/Projectiles/Ranged/PrismMine.cs index 5be27c2cb6..6dd01e07dc 100644 --- a/Projectiles/Ranged/PrismMine.cs +++ b/Projectiles/Ranged/PrismMine.cs @@ -7,12 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { - public class PrismMine : ModProjectile + public class PrismMine : ModProjectile { public List MinesToConnectTo = new List(); public ref float Time => ref projectile.ai[0]; + public const float DamageFactorLowerBound = 0.425f; public const float MineConnectDistanceMax = 1200f; - public override void SetStaticDefaults() => DisplayName.SetDefault("Mine"); + public override void SetStaticDefaults() => DisplayName.SetDefault("Mine"); public override void SetDefaults() { @@ -20,16 +21,16 @@ namespace CalamityMod.Projectiles.Ranged projectile.friendly = true; projectile.ignoreWater = true; projectile.tileCollide = false; - projectile.ranged = true; - projectile.penetrate = -1; + projectile.ranged = true; + projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 7; projectile.timeLeft = 280; } - public override void AI() - { - projectile.velocity *= 0.96f; + public override void AI() + { + projectile.velocity *= 0.96f; Lighting.AddLight(projectile.Center, Color.Cyan.ToVector3()); float idealScale = MathHelper.Lerp(0.93f, 1.07f, (float)Math.Sin(MathHelper.TwoPi * projectile.timeLeft / 14f) * 0.5f + 0.5f); @@ -37,7 +38,7 @@ namespace CalamityMod.Projectiles.Ranged Time++; } - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) { foreach (Projectile mine in LocateOtherMines()) { @@ -51,11 +52,24 @@ namespace CalamityMod.Projectiles.Ranged return base.Colliding(projHitbox, targetHitbox); } - public List LocateOtherMines() - { + public override void ModifyHitNPC(NPC target, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) + { + // Have the damage be reduced based on hit count. This effect becomes stronger the more hits, before hitting a lower bound. + float damageFactor = 1f - 3f * (float)Math.Pow(projectile.numHits / 14f, 2D) + 2f * (float)Math.Pow(projectile.numHits / 14f, 3D); + + // The above equation is a polynomial that will eventually shoot off to infinity if the hit count somehow gets high enough. + // To amend this, the limit is reached by default after enough hits have been made. + if (projectile.numHits > 12 || damageFactor < DamageFactorLowerBound) + damageFactor = DamageFactorLowerBound; + + damage = (int)(damage * damageFactor); + } + + public List LocateOtherMines() + { List mines = new List(); for (int i = 0; i < Main.maxProjectiles; i++) - { + { Projectile proj = Main.projectile[i]; if (proj.type != projectile.type || !proj.active || proj.timeLeft <= 12 || i == projectile.whoAmI) continue; @@ -63,31 +77,31 @@ namespace CalamityMod.Projectiles.Ranged continue; mines.Add(proj); - } + } return mines; - } + } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D baseTexture = Main.projectileTexture[projectile.type]; Texture2D glowTexture = ModContent.GetTexture($"{Texture}Glowmask"); Texture2D laserTexture = ModContent.GetTexture($"CalamityMod/Projectiles/Ranged/PrismMineArc"); void drawLineTo(Vector2 destination, Color laserColor) - { + { float rotation = projectile.AngleTo(destination); float remainingDistance = projectile.Distance(destination) - 30f; float laserScale = 0.5f; Rectangle frame = laserTexture.Frame(1, 7, 0, (int)(Main.GlobalTime * 10f + projectile.identity * 3f) % 7); Vector2 laserOrigin = frame.Size() * 0.5f; while (remainingDistance > frame.Height * laserScale) - { + { Vector2 laserDrawPosition = projectile.Center + projectile.SafeDirectionTo(destination, -Vector2.UnitY) * remainingDistance - Main.screenPosition; spriteBatch.Draw(laserTexture, laserDrawPosition, frame, laserColor, rotation, laserOrigin, laserScale, SpriteEffects.None, 0f); remainingDistance -= frame.Height * laserScale; } - } + } Vector2 origin = baseTexture.Size() * 0.5f; Vector2 drawPosition = projectile.Center - Main.screenPosition; @@ -105,6 +119,6 @@ namespace CalamityMod.Projectiles.Ranged glowColor.A = 0; spriteBatch.Draw(glowTexture, drawPosition, glowFrame, glowColor, projectile.rotation, origin, projectile.scale, SpriteEffects.None, 0f); return false; - } - } -} \ No newline at end of file + } + } +} diff --git a/Projectiles/Ranged/PrismaticEnergyBlast.cs b/Projectiles/Ranged/PrismaticEnergyBlast.cs index 073240ffd1..ee55885a43 100644 --- a/Projectiles/Ranged/PrismaticEnergyBlast.cs +++ b/Projectiles/Ranged/PrismaticEnergyBlast.cs @@ -58,7 +58,7 @@ namespace CalamityMod.Projectiles.Ranged if (Main.myPlayer != projectile.owner || ExplodedYet || LaserLength <= 60f) return; - Projectile.NewProjectile(laserEnd, Vector2.Zero, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner); + Projectile.NewProjectile(laserEnd, Vector2.Zero, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); if (!ExplodedYet) { diff --git a/Projectiles/Ranged/VeriumBulletProj.cs b/Projectiles/Ranged/VeriumBulletProj.cs index 27f22dda0a..8a2b121bb2 100644 --- a/Projectiles/Ranged/VeriumBulletProj.cs +++ b/Projectiles/Ranged/VeriumBulletProj.cs @@ -121,7 +121,7 @@ namespace CalamityMod.Projectiles.Ranged return true; } - public override bool? CanHitNPC(NPC target) => projectile.ai[0] <= 0f; + public override bool? CanHitNPC(NPC target) => projectile.ai[0] <= 0f && target.CanBeChasedBy(projectile); public override bool CanHitPvp(Player target) => projectile.ai[0] <= 0f; diff --git a/Projectiles/Rogue/FinalDawnFlame.cs b/Projectiles/Rogue/FinalDawnFlame.cs index c5ba6d565f..294f0b6a24 100644 --- a/Projectiles/Rogue/FinalDawnFlame.cs +++ b/Projectiles/Rogue/FinalDawnFlame.cs @@ -47,7 +47,7 @@ namespace CalamityMod.Projectiles.Rogue Flames = new Flame[TotalFlames]; for (int i = 0; i < Flames.Length; i++) { - Vector2 flamePosition = Main.rand.NextVector2Circular(projectile.width / 2, projectile.height / 2); + Vector2 flamePosition = Main.rand.NextVector2Circular(projectile.width * 0.36f, projectile.height / 2); Flames[i].Position = flamePosition; Flames[i].Frame = Main.rand.Next(8); @@ -57,16 +57,16 @@ namespace CalamityMod.Projectiles.Rogue Flames[i].Direction = Main.rand.Next(2); } } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; int frameHeight = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; - + if (Flames.Length > 0) { - for(int i = 0; i < Flames.Length; i++) - { + for (int i = 0; i < Flames.Length; i++) + { int frameHeight2 = frameHeight * Flames[i].Frame; spriteBatch.Draw(texture, projectile.Center + Flames[i].Position - Main.screenPosition, @@ -77,9 +77,9 @@ namespace CalamityMod.Projectiles.Rogue Flames[i].Scale, Flames[i].Direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0f); - } + } } - return false; + return false; } public override void AI() @@ -106,7 +106,7 @@ namespace CalamityMod.Projectiles.Rogue { if (projectile.ai[0] < 570) { - Vector2 pos = new Vector2(Main.rand.NextFloat(projectile.width / 2)).RotatedByRandom(MathHelper.TwoPi); + Vector2 pos = new Vector2(Main.rand.NextFloat(projectile.width * 0.36f)).RotatedByRandom(MathHelper.TwoPi); float widthHeightRatio = (float)projectile.height / projectile.width; pos.Y *= widthHeightRatio; diff --git a/Projectiles/Rogue/FinalDawnProjectile.cs b/Projectiles/Rogue/FinalDawnProjectile.cs index cfc94e209e..ce177acb2a 100644 --- a/Projectiles/Rogue/FinalDawnProjectile.cs +++ b/Projectiles/Rogue/FinalDawnProjectile.cs @@ -102,7 +102,7 @@ namespace CalamityMod.Projectiles.Rogue int stealth = Projectile.NewProjectile(player.Center, player.SafeDirectionTo(Main.MouseWorld) * 38f, ModContent.ProjectileType(), - (int)(projectile.damage * 1.5f), + (int)(projectile.damage * 1.05f), projectile.knockBack, projectile.owner); Main.projectile[stealth].Calamity().stealthStrike = true; diff --git a/Projectiles/Rogue/GacruxianHome.cs b/Projectiles/Rogue/GacruxianHome.cs index f3502d90a7..27f8ae3d03 100644 --- a/Projectiles/Rogue/GacruxianHome.cs +++ b/Projectiles/Rogue/GacruxianHome.cs @@ -23,8 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.aiStyle = 18; projectile.friendly = true; projectile.Calamity().rogue = true; - projectile.penetrate = 5; - projectile.timeLeft = 180; + projectile.penetrate = 3; + projectile.timeLeft = 120; projectile.ignoreWater = true; aiType = ProjectileID.DeathSickle; projectile.usesLocalNPCImmunity = true; @@ -37,15 +37,11 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (projectile.timeLeft % 10 == 0 && projectile.owner == Main.myPlayer) + if (projectile.timeLeft % 30 == 0 && projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.5), projectile.knockBack, projectile.owner); if (proj.WithinBounds(Main.maxProjectiles)) - { Main.projectile[proj].Calamity().forceRogue = true; - Main.projectile[proj].localNPCHitCooldown = 10; - Main.projectile[proj].penetrate = 3; - } } CalamityGlobalProjectile.HomeInOnNPC(projectile, !projectile.tileCollide, 250f, 12f, 20f); } diff --git a/Projectiles/Rogue/GacruxianProj.cs b/Projectiles/Rogue/GacruxianProj.cs index 43158e4955..db907d792b 100644 --- a/Projectiles/Rogue/GacruxianProj.cs +++ b/Projectiles/Rogue/GacruxianProj.cs @@ -35,7 +35,7 @@ namespace CalamityMod.Projectiles.Rogue { Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, ModContent.DustType(), projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } - if (projectile.timeLeft % 10 == 0) + if (projectile.timeLeft % 15 == 0) { if (projectile.Calamity().stealthStrike == true) { @@ -45,11 +45,7 @@ namespace CalamityMod.Projectiles.Rogue { int proj = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); if (proj.WithinBounds(Main.maxProjectiles)) - { Main.projectile[proj].Calamity().forceRogue = true; - Main.projectile[proj].localNPCHitCooldown = 10; - Main.projectile[proj].penetrate = 3; - } } } } diff --git a/Projectiles/Rogue/InfernalSpearProjectile.cs b/Projectiles/Rogue/InfernalSpearProjectile.cs deleted file mode 100644 index 384775759b..0000000000 --- a/Projectiles/Rogue/InfernalSpearProjectile.cs +++ /dev/null @@ -1,131 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class InfernalSpearProjectile : ModProjectile - { - private float speedX = -3f; - private float speedX2 = -5f; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Spear"); - Main.projFrames[projectile.type] = 4; - ProjectileID.Sets.TrailCacheLength[projectile.type] = 6; - ProjectileID.Sets.TrailingMode[projectile.type] = 0; - } - - public override void SetDefaults() - { - projectile.width = 62; - projectile.height = 62; - projectile.friendly = true; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.tileCollide = false; - projectile.timeLeft = 300; - projectile.Calamity().rogue = true; - } - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(speedX); - writer.Write(speedX2); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - speedX = reader.ReadSingle(); - speedX2 = reader.ReadSingle(); - } - - public override void AI() - { - if (projectile.timeLeft % 12 == 0) - { - if (projectile.owner == Main.myPlayer) - { - if (projectile.Calamity().stealthStrike) - { - Projectile.NewProjectile(projectile.Center, projectile.velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.75), projectile.knockBack, projectile.owner); - } - } - } - - projectile.frameCounter++; - if (projectile.frameCounter > 6) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; - CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 200f, 12f, 20f); - } - - public override void Kill(int timeLeft) - { - if (projectile.Calamity().stealthStrike) - { - if (projectile.owner == Main.myPlayer) - { - for (int x = 0; x < 3; x++) - { - Projectile.NewProjectile((int)projectile.Center.X, (int)projectile.Center.Y, speedX, -50f, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 0f); - speedX += 3f; - } - for (int x = 0; x < 2; x++) - { - Projectile.NewProjectile((int)projectile.Center.X, (int)projectile.Center.Y, speedX2, -75f, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, 0f); - speedX2 += 10f; - } - } - } - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 160); - projectile.maxPenetrate = -1; - projectile.penetrate = -1; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - projectile.Damage(); - Main.PlaySound(SoundID.Item14, projectile.position); - for (int d = 0; d < 20; d++) - { - int fire = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1.2f); - Main.dust[fire].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[fire].scale = 0.5f; - Main.dust[fire].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int d = 0; d < 30; d++) - { - int fire = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1.7f); - Main.dust[fire].noGravity = true; - Main.dust[fire].velocity *= 5f; - fire = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1f); - Main.dust[fire].velocity *= 2f; - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(BuffID.Daybreak, 360); - } - - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/Rogue/SacrificeProjectile.cs b/Projectiles/Rogue/SacrificeProjectile.cs index e86e784981..f091712f59 100644 --- a/Projectiles/Rogue/SacrificeProjectile.cs +++ b/Projectiles/Rogue/SacrificeProjectile.cs @@ -23,7 +23,8 @@ namespace CalamityMod.Projectiles.Rogue public override void SetDefaults() { - projectile.width = projectile.height = 68; + projectile.width = 62; + projectile.height = 18; projectile.friendly = true; projectile.ignoreWater = true; projectile.penetrate = -1; @@ -101,12 +102,15 @@ namespace CalamityMod.Projectiles.Rogue return false; } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => projectile.RotatingHitboxCollision(targetHitbox.TopLeft(), targetHitbox.Size()); + public override void Kill(int timeLeft) { for (int i = 0; i < 5; i++) { - int dust = Dust.NewDust(projectile.Center, 1, 1, 5, 0, 0, 0, default, 1.5f); - Main.dust[dust].noGravity = true; + Dust blood = Dust.NewDustDirect(projectile.Center, 1, 1, 5, 0, 0, 0, default, 1.5f); + blood.position += projectile.velocity.SafeNormalize(Vector2.Zero) * projectile.scale * 42f; + blood.noGravity = true; } } } diff --git a/Projectiles/Rogue/TheAtomSplitterDuplicate.cs b/Projectiles/Rogue/TheAtomSplitterDuplicate.cs index 0dfc874940..aad20f8398 100644 --- a/Projectiles/Rogue/TheAtomSplitterDuplicate.cs +++ b/Projectiles/Rogue/TheAtomSplitterDuplicate.cs @@ -23,6 +23,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.scale = 0.66f; projectile.width = projectile.height = (int)(124f * projectile.scale); projectile.friendly = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; projectile.penetrate = 3; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 16; diff --git a/Projectiles/Rogue/TheAtomSplitterProjectile.cs b/Projectiles/Rogue/TheAtomSplitterProjectile.cs index cb23b8ba13..530230a8b7 100644 --- a/Projectiles/Rogue/TheAtomSplitterProjectile.cs +++ b/Projectiles/Rogue/TheAtomSplitterProjectile.cs @@ -1,16 +1,19 @@ using CalamityMod.Items; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using System; using System.IO; using Terraria; -using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class TheAtomSplitterProjectile : ModProjectile { + // Atom splitting is cool and all, but actual thermonuclear meltdown levels of DPS is unacceptable. + // DO NOT increase this unless you are ABSOLUTELY SURE you know what will happen. + private const float NormalSplitMultiplier = 0.7f; + private const float StealthSplitMultiplier = 0.12f; + public ref float HitTargetIndex => ref projectile.ai[0]; public ref float Time => ref projectile.ai[1]; @@ -23,6 +26,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = projectile.height = 124; projectile.friendly = true; projectile.tileCollide = false; + projectile.ignoreWater = true; projectile.penetrate = 2; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; @@ -61,12 +65,14 @@ namespace CalamityMod.Projectiles.Rogue if (projectile.alpha < 255) projectile.alpha = Utils.Clamp(projectile.alpha + 30, 0, 255); - int shootRate = projectile.Calamity().stealthStrike ? 2 : 4; + bool stealth = projectile.Calamity().stealthStrike; + int shootRate = stealth ? 2 : 4; if (projectile.timeLeft % shootRate == shootRate - 1) { - FireDuplicateAtTarget(Main.npc[(int)HitTargetIndex], projectile.Calamity().stealthStrike ? 305f : 200f); - if (projectile.Calamity().stealthStrike) - FireExtraDuplicatesAtTarget(Main.npc[(int)HitTargetIndex]); + NPC target = Main.npc[(int)HitTargetIndex]; + FireDuplicateAtTarget(target, stealth ? 305f : 200f, stealth); + if (stealth) + FireExtraDuplicatesAtTarget(target); } } projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; @@ -99,14 +105,15 @@ namespace CalamityMod.Projectiles.Rogue } } - public void FireDuplicateAtTarget(NPC target, float baseOutwardness) + public void FireDuplicateAtTarget(NPC target, float baseOutwardness, bool stealth) { if (Main.myPlayer != projectile.owner) return; Vector2 spawnPosition = target.Center + Main.rand.NextVector2CircularEdge(baseOutwardness, baseOutwardness) * Main.rand.NextFloat(0.9f, 1.15f); Vector2 shootVelocity = (target.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(12f, 14f); - Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, baseOutwardness / 9f); + int damage = (int)(projectile.damage * (stealth ? StealthSplitMultiplier : NormalSplitMultiplier)); + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), damage, projectile.knockBack, projectile.owner, 0f, baseOutwardness / 9f); } public void FireExtraDuplicatesAtTarget(NPC target) @@ -116,9 +123,9 @@ namespace CalamityMod.Projectiles.Rogue Vector2 spawnPosition = target.Center + Vector2.UnitY * Main.rand.NextBool(2).ToDirectionInt() * Main.rand.NextFloat(200f, 270f); spawnPosition.X += Main.rand.NextFloatDirection() * target.width * 0.45f; - + int damage = (int)(projectile.damage * StealthSplitMultiplier); Vector2 shootVelocity = Vector2.UnitY * (target.Center.Y - spawnPosition.Y > 0f).ToDirectionInt() * Main.rand.NextFloat(14f, 16.5f); - Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 24f); + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), damage, projectile.knockBack, projectile.owner, 0f, 24f); } public void ReleaseHitDust(Vector2 spawnPosition) @@ -155,6 +162,13 @@ namespace CalamityMod.Projectiles.Rogue public override bool CanDamage() => projectile.alpha < 80; + public override bool? CanHitNPC(NPC target) + { + if (HitTargetIndex >= 0 && target.whoAmI != HitTargetIndex) + return false; + return base.CanHitNPC(target); + } + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { ReleaseHitDust(target.Center - projectile.velocity * 3f); diff --git a/Projectiles/Rogue/InfernalFireballEruption.cs b/Projectiles/Rogue/WrathwingCinder.cs similarity index 89% rename from Projectiles/Rogue/InfernalFireballEruption.cs rename to Projectiles/Rogue/WrathwingCinder.cs index 41d3b35b1e..f7fabbe202 100644 --- a/Projectiles/Rogue/InfernalFireballEruption.cs +++ b/Projectiles/Rogue/WrathwingCinder.cs @@ -7,13 +7,13 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class InfernalFireballEruption : ModProjectile + public class WrathwingCinder : ModProjectile { - public override string Texture => "CalamityMod/Projectiles/Rogue/InfernalFireball"; + public override string Texture => "CalamityMod/Projectiles/Rogue/WrathwingFireball"; public override void SetStaticDefaults() { - DisplayName.SetDefault("Dragon Fireball"); + DisplayName.SetDefault("Wrathwing Eruption"); Main.projFrames[projectile.type] = 5; ProjectileID.Sets.TrailCacheLength[projectile.type] = 4; ProjectileID.Sets.TrailingMode[projectile.type] = 0; @@ -24,10 +24,11 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 34; projectile.height = 34; projectile.friendly = true; - projectile.ignoreWater = true; - projectile.alpha = 255; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.alpha = 255; projectile.penetrate = -1; - projectile.timeLeft = 3600; + projectile.timeLeft = 480; projectile.Calamity().rogue = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 30; @@ -76,11 +77,16 @@ namespace CalamityMod.Projectiles.Rogue } projectile.velocity.X *= 0.995f; projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + + // commented out sound because it was way too loud + /* if (projectile.localAI[0] == 0f) { projectile.localAI[0] = 1f; Main.PlayTrackedSound(SoundID.DD2_BetsyFireballShot, projectile.Center); } + */ + if (projectile.ai[0] >= 2f) { projectile.alpha -= 25; @@ -97,15 +103,6 @@ namespace CalamityMod.Projectiles.Rogue } } - public override bool CanHitPlayer(Player target) - { - if (projectile.velocity.Y < -16f) - { - return false; - } - return true; - } - public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) @@ -117,7 +114,7 @@ namespace CalamityMod.Projectiles.Rogue public override void Kill(int timeLeft) { Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 14, 0.5f, 0f); - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); for (int d = 0; d < 2; d++) { Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 100, default, 1.5f); diff --git a/Projectiles/Rogue/InfernalFireball.cs b/Projectiles/Rogue/WrathwingFireball.cs similarity index 70% rename from Projectiles/Rogue/InfernalFireball.cs rename to Projectiles/Rogue/WrathwingFireball.cs index 3159eb2ac5..f9b4741fea 100644 --- a/Projectiles/Rogue/InfernalFireball.cs +++ b/Projectiles/Rogue/WrathwingFireball.cs @@ -6,11 +6,11 @@ using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { - public class InfernalFireball : ModProjectile + public class WrathwingFireball : ModProjectile { public override void SetStaticDefaults() { - DisplayName.SetDefault("Dragon Fireball"); + DisplayName.SetDefault("Wrathwing Fireball"); Main.projFrames[projectile.type] = 5; ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; ProjectileID.Sets.TrailingMode[projectile.type] = 2; @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Rogue projectile.width = 34; projectile.height = 34; projectile.friendly = true; - projectile.ignoreWater = true; + projectile.ignoreWater = true; projectile.alpha = 255; projectile.penetrate = 1; projectile.timeLeft = 180; @@ -32,6 +32,10 @@ namespace CalamityMod.Projectiles.Rogue public override void AI() { + // Cancel out the first ten frames of Betsy fireball gravity, and half of all gravity thereafter + projectile.velocity.Y -= 0.1f; + + // Animation projectile.frameCounter++; if (projectile.frameCounter > 4) { @@ -39,11 +43,11 @@ namespace CalamityMod.Projectiles.Rogue projectile.frameCounter = 0; } if (projectile.frame >= Main.projFrames[projectile.type]) - { projectile.frame = 0; - } + + // Keep the fireball rotated the correct way because the sheet faces down, not up projectile.rotation += MathHelper.Pi; - } + } public override Color? GetAlpha(Color lightColor) => new Color(200, 200, 200, projectile.alpha); @@ -74,21 +78,29 @@ namespace CalamityMod.Projectiles.Rogue return false; } + // Expand hitbox and explode on hit. public override void Kill(int timeLeft) { - CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); - for (int d = 0; d < 2; d++) - { + CalamityGlobalProjectile.ExpandHitboxBy(projectile, 144); + + // Allow infinite piercing and ignoring iframes for this one extra AoE hit + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + projectile.Damage(); + + for (int i = 0; i < 2; i++) Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 50, default, 1.5f); - } - for (int d = 0; d < 20; d++) + + for (int i = 0; i < 20; i++) { - int idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 0, default, 2.5f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - idx = Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 50, default, 1.5f); - Main.dust[idx].velocity *= 2f; - Main.dust[idx].noGravity = true; + int d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 0, default, 2.5f); + Main.dust[d].noGravity = true; + Main.dust[d].velocity *= 3f; + d = Dust.NewDust(projectile.position, projectile.width, projectile.height, 55, 0f, 0f, 50, default, 1.5f); + Main.dust[d].velocity *= 2f; + Main.dust[d].noGravity = true; } } } diff --git a/Projectiles/Rogue/InfernalFireball.png b/Projectiles/Rogue/WrathwingFireball.png similarity index 100% rename from Projectiles/Rogue/InfernalFireball.png rename to Projectiles/Rogue/WrathwingFireball.png diff --git a/Projectiles/Rogue/WrathwingSpear.cs b/Projectiles/Rogue/WrathwingSpear.cs new file mode 100644 index 0000000000..a1d54242ee --- /dev/null +++ b/Projectiles/Rogue/WrathwingSpear.cs @@ -0,0 +1,114 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Rogue +{ + public class WrathwingSpear : ModProjectile + { + private const float FireballAngleVariance = 0.07f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Wrathwing"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 8; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + } + + public override void SetDefaults() + { + projectile.width = 62; + projectile.height = 62; + projectile.friendly = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.penetrate = 1; + projectile.timeLeft = 300; + projectile.Calamity().rogue = true; + } + + public override void AI() + { + // Spit fireballs constantly, but slightly randomly. Always spits one fireball immediately upon being thrown. + if (projectile.owner == Main.myPlayer && projectile.ai[0] <= 0f) + { + projectile.ai[0] = Main.rand.NextFloat(15f, 19f); + + int fireballID = ModContent.ProjectileType(); + int damage = (int)(projectile.damage * 0.8f); + float angleDiff = Main.rand.NextFloat(-FireballAngleVariance, FireballAngleVariance); + Vector2 velocity = projectile.velocity.RotatedBy(angleDiff) * 1.06f; + float kb = projectile.knockBack * 0.6f; + Projectile.NewProjectile(projectile.Center, velocity, fireballID, damage, kb, projectile.owner); + } + + projectile.ai[0] -= 1f; + + // Homing + // The item's default velocity is 28. Homing speed is intentionally a bit lower. + CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 450f, 23f, 30f); + + // Animation + projectile.frameCounter++; + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + projectile.frame = 0; + + // Rotation + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver4; + } + + public override void Kill(int timeLeft) + { + // Stealth strikes create an eruption on hit. + if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + { + int eruptionID = ModContent.ProjectileType(); + int damage = (int)(projectile.damage * 0.75f); + float kb = 0f; + + // Spawns 13 erupting fireballs in total. + for (int x = -6; x <= 6; x++) + { + Vector2 pos = projectile.Center + Vector2.UnitY * Main.rand.NextFloat(44f, 60f); + pos.X += Main.rand.NextFloat(-14f, 14f); + float ySpeed = x % 2 == 0 ? -13f : -19f; + ySpeed *= Main.rand.NextFloat(0.85f, 1.05f); + Vector2 velocity = new Vector2(x, ySpeed); + Projectile.NewProjectile(pos, velocity, eruptionID, damage, kb, projectile.owner); + } + } + + // Spawn shrapnel dust. Code adapted from Holy Fire Bullets. + for (int k = 0; k < 36; k++) + { + float scale = Main.rand.NextFloat(1.4f, 1.8f); + Vector2 corner = projectile.Center - Vector2.One * 2f; + int dustID = Dust.NewDust(corner, 4, 4, DustID.CopperCoin); + Main.dust[dustID].noGravity = false; + Main.dust[dustID].scale = scale; + float angleDeviation = 0.25f; + float angle = Main.rand.NextFloat(-angleDeviation, angleDeviation); + float velMult = Main.rand.NextFloat(0.08f, 0.14f); + Vector2 shrapnelVelocity = projectile.velocity.RotatedBy(angle) * velMult; + Main.dust[dustID].velocity = shrapnelVelocity; + } + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(BuffID.Daybreak, 360); + public override void OnHitPvp(Player target, int damage, bool crit) => target.AddBuff(BuffID.Daybreak, 360); + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], lightColor, 1); + return false; + } + } +} diff --git a/Projectiles/Rogue/InfernalSpearProjectile.png b/Projectiles/Rogue/WrathwingSpear.png similarity index 100% rename from Projectiles/Rogue/InfernalSpearProjectile.png rename to Projectiles/Rogue/WrathwingSpear.png diff --git a/Projectiles/Summon/EyeOfNightSummon.cs b/Projectiles/Summon/EyeOfNightSummon.cs index 6af7ff3d56..d558709329 100644 --- a/Projectiles/Summon/EyeOfNightSummon.cs +++ b/Projectiles/Summon/EyeOfNightSummon.cs @@ -30,6 +30,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minionSlots = 1f; projectile.timeLeft = 90000; projectile.penetrate = -1; + projectile.extraUpdates = 1; projectile.tileCollide = false; projectile.minion = true; projectile.usesLocalNPCImmunity = true; @@ -108,7 +109,7 @@ namespace CalamityMod.Projectiles.Summon internal void AttackTarget(NPC target) { - if (Main.myPlayer == projectile.owner && HoverTime % 30 == 29) + if (Main.myPlayer == projectile.owner && HoverTime % 70f == 69f) { Projectile.NewProjectile(projectile.Center, projectile.SafeDirectionTo(target.Center) * 8f, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); HoverTime++; diff --git a/Projectiles/Summon/FleshBallMinion.cs b/Projectiles/Summon/FleshBallMinion.cs index 57dab5bbee..ba44c8210d 100644 --- a/Projectiles/Summon/FleshBallMinion.cs +++ b/Projectiles/Summon/FleshBallMinion.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Projectiles.Summon projectile.minionSlots = 1f; projectile.timeLeft = 90000; projectile.penetrate = -1; + projectile.extraUpdates = 1; projectile.tileCollide = false; projectile.minion = true; } diff --git a/Projectiles/Summon/FlowersOfMortalityPetal.cs b/Projectiles/Summon/FlowersOfMortalityPetal.cs index b743c1018e..b4478dfbeb 100644 --- a/Projectiles/Summon/FlowersOfMortalityPetal.cs +++ b/Projectiles/Summon/FlowersOfMortalityPetal.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Projectiles.Summon Time++; NPC potentialTarget = projectile.Center.MinionHoming(1050f, Owner, false); - if (Time % 25 == 24 && Main.myPlayer == projectile.owner && potentialTarget != null) + if (Time % 50f == 49f && Main.myPlayer == projectile.owner && potentialTarget != null) { Vector2 shootVelocity = projectile.SafeDirectionTo(potentialTarget.Center) * 10f; Projectile.NewProjectile(projectile.Center, shootVelocity, ModContent.ProjectileType(), projectile.damage / 3, projectile.knockBack, projectile.owner); diff --git a/Projectiles/Summon/SonOfYharon.cs b/Projectiles/Summon/SonOfYharon.cs index 647c7500cc..f24f76fb13 100644 --- a/Projectiles/Summon/SonOfYharon.cs +++ b/Projectiles/Summon/SonOfYharon.cs @@ -92,22 +92,22 @@ namespace CalamityMod.Projectiles.Summon { projectile.frame = 0; } - } - else - { - projectile.frameCounter++; - if (projectile.frameCounter > 12) - { - projectile.frame++; - projectile.frameCounter = 0; - } - if (projectile.frame > 3) - { - projectile.frame = 0; - } - } + } + else + { + projectile.frameCounter++; + if (projectile.frameCounter > 12) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame > 3) + { + projectile.frame = 0; + } + } - projectile.ChargingMinionAI(1000f, 2000f, 3000f, 500f, 1, 30f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, true, true); + projectile.ChargingMinionAI(1000f, 2000f, 3000f, 500f, 1, 30f, 8f, 4f, new Vector2(0f, -60f), 40f, 8f, true, true); } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Summon/VoidConcentrationAura.cs b/Projectiles/Summon/VoidConcentrationAura.cs new file mode 100644 index 0000000000..41076dda92 --- /dev/null +++ b/Projectiles/Summon/VoidConcentrationAura.cs @@ -0,0 +1,94 @@ +using CalamityMod.Buffs.Summon; +using CalamityMod.CalPlayer; +using Microsoft.Xna.Framework; +using Steamworks; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + class VoidConcentrationAura : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int timer = 0; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Concentrated Void Aura"); + } + + public override void SetDefaults() + { + projectile.width = 46; + projectile.height = 80; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 3f; + projectile.timeLeft = 18000; + projectile.penetrate = -1; + + projectile.tileCollide = false; + projectile.timeLeft *= 5; + projectile.minion = true; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(timer); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + timer = reader.ReadInt32(); + } + + public override bool? CanCutTiles() + { + return true; + } + + public void HandleRightClick() + { + Vector2 velocity = Main.MouseWorld - Main.player[projectile.owner].Center; + velocity.Normalize(); + velocity *= 2f; + Projectile.NewProjectile(Main.player[projectile.owner].Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 5f), 0f, projectile.owner); + projectile.Kill(); + } + + public override void AI() + { + Player owner = Main.player[projectile.owner]; + CalamityPlayer mp = owner.Calamity(); + projectile.Center = owner.Center; + mp.voidAuraDamage = true; + if (owner.dead) + mp.voidAuraDamage = false; + if (!mp.voidAuraDamage) + { + mp.voidAura = false; + projectile.Kill(); + } + if (owner.whoAmI == Main.myPlayer && owner.ownedProjectileCounts[projectile.type] <= 25 && timer > 0 && timer % 4 == 0) + { + NPC target = CalamityUtils.MinionHoming(projectile.Center, 1800f, owner); + if (target != null) + { + Vector2 correctedVelocity = target.Center - owner.Center; + correctedVelocity.Normalize(); + correctedVelocity *= 3f; + int perturbificator9000 = Main.rand.Next(-1, 2); + Vector2 perturbedspeed = new Vector2(correctedVelocity.X + perturbificator9000, correctedVelocity.Y + perturbificator9000).RotatedBy(MathHelper.ToRadians(Main.rand.Next(1, 3))); + Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, perturbedspeed.X, perturbedspeed.Y, ModContent.ProjectileType(), (int)(projectile.damage * 0.75f), 0f, owner.whoAmI); + } + timer = -1; + } + if (timer > 50 && timer % 4 == 0) + return; + timer++; + } + } +} diff --git a/Projectiles/Summon/VoidConcentrationBlackhole.cs b/Projectiles/Summon/VoidConcentrationBlackhole.cs new file mode 100644 index 0000000000..e05dd64f54 --- /dev/null +++ b/Projectiles/Summon/VoidConcentrationBlackhole.cs @@ -0,0 +1,190 @@ +using CalamityMod.NPCs; +using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + class VoidConcentrationBlackhole : ModProjectile + { + private int damage = 0; + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(damage); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + damage = reader.ReadInt32(); + } + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Black Hole"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 80; //32 base, 2.5x the normal (for hitbox purposes) + projectile.height = 85; //34 base, 2.5x the normal (for hitbox purposes) + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 1800; + projectile.penetrate = -1; + + projectile.tileCollide = false; + projectile.minion = true; + projectile.scale = 0.01f; + } + + private void ApplySucc(NPC npc) + { + float succStrength = 4f / projectile.scale; + succStrength *= projectile.scale; + Vector2 velocity = projectile.Center - npc.Center; + velocity *= 2f; + velocity.SafeNormalize(Vector2.Zero); + float num550 = 5f * projectile.scale; + Vector2 vector43 = new Vector2(npc.position.X + (float)npc.width * 0.5f, npc.position.Y + (float)npc.height * 0.5f); + float num551 = projectile.Center.X - vector43.X; + float num552 = projectile.Center.Y - vector43.Y; + float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); + if (num553 < 100f) + { + num550 = 28f; //14 + } + num553 = num550 / num553; + num551 *= num553; + num552 *= num553; + npc.velocity.X = (velocity.X * 15f + num551) / 16f; + npc.velocity.Y = (velocity.Y * 15f + num552) / 16f; + npc.velocity = (velocity / succStrength); + } + + private void Death() + { + if (projectile.scale >= 2.5f) //it's boom o' clock + { + projectile.height *= 2; + projectile.width *= 2; + projectile.maxPenetrate = -1; + projectile.penetrate = -1; + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = 10; + projectile.damage = damage; + projectile.Damage(); + projectile.friendly = false; + projectile.Damage(); + Main.PlaySound(SoundID.Item, (int)projectile.Center.X, (int)projectile.Center.Y, 14); + projectile.Kill(); + } + } + + public override void Kill(int timeLeft) + { + for (int d = 0; d < 6; d++) + { + int shadow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 100, new Color(0, 0, 0), 4f); + Main.dust[shadow].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[shadow].scale = 0.5f; + Main.dust[shadow].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int d = 0; d < 18; d++) + { + int shadow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 100, new Color(0, 0, 0), 4f); + Main.dust[shadow].noGravity = true; + Main.dust[shadow].velocity *= 5f; + shadow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 100, new Color(0, 0, 0), 3f); + Main.dust[shadow].velocity *= 2f; + } + } + + public override bool PreAI() + { + if (damage == 0) + { + damage = projectile.damage; + projectile.damage = 0; + projectile.position = Main.player[projectile.owner].position; + } + return true; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + Vector2 drawPos = projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); + int height = texture.Height / Main.projFrames[projectile.type]; + int frameHeight = height * projectile.frame; + Rectangle rectangle = new Rectangle(0, frameHeight, texture.Width, height); + Vector2 origin = new Vector2(texture.Width / 2f, height / 2f); + SpriteEffects spriteEffects = SpriteEffects.None; + if (projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + spriteBatch.Draw(texture, drawPos, new Microsoft.Xna.Framework.Rectangle?(rectangle), lightColor, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); + return false; + } + + public override void AI() + { + + projectile.scale += 0.01f; + if (projectile.scale % 0.02f == 0) + { + projectile.scale += 0.01f; //speeds up the projectile's growth to prevent it being too long + } + int radius = (int)(projectile.scale * 100f); //0.01f; to a max of 2.5f; so radius of 1 to 250 by default + if (projectile.scale >= 2f) + radius *= 2; + + int baseWidth = 32; + int baseHeight = 34; + int newWidth = (int)(baseWidth * projectile.scale); + int newHeight = (int)(baseHeight * projectile.scale); + CalamityGlobalProjectile.ExpandHitboxBy(projectile, newWidth, newHeight); + + + + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type] - 1) + { + projectile.frame = 0; + } + projectile.frameCounter++; + + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && !Main.npc[i].friendly /*&& CalamityGlobalNPC.ShouldAffectNPC(Main.npc[i])*/) //TODO - REMOVE COMMENT BEFORE MERGE + { + if (Vector2.Distance(projectile.Center, Main.npc[i].Center) <= radius) + ApplySucc(Main.npc[i]); + } + } + + + if (projectile.scale >= 2.5f) //it's boom o' clock + { + Death(); + } + } + } +} diff --git a/Projectiles/Summon/VoidConcentrationBlackhole.png b/Projectiles/Summon/VoidConcentrationBlackhole.png new file mode 100644 index 0000000000..ab6fe62770 Binary files /dev/null and b/Projectiles/Summon/VoidConcentrationBlackhole.png differ diff --git a/Projectiles/Summon/VoidConcentrationOrb.cs b/Projectiles/Summon/VoidConcentrationOrb.cs new file mode 100644 index 0000000000..51bd4f81ad --- /dev/null +++ b/Projectiles/Summon/VoidConcentrationOrb.cs @@ -0,0 +1,115 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + class VoidConcentrationOrb : ModProjectile + { + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Void Orb"); + Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 54; + projectile.height = 50; + projectile.netImportant = true; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.minionSlots = 0f; + projectile.timeLeft = 300; + projectile.penetrate = 1; + + projectile.tileCollide = false; + projectile.minion = true; + projectile.scale = 0.01f; + } + + public override bool? CanHitNPC(NPC target) + { + if (projectile.scale < 1f) + return false; + return null; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + for (int d = 0; d < 6; d++) + { + int shadow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 100, new Color(0, 0, 0), 2f); + Main.dust[shadow].velocity *= 3f; + if (Main.rand.NextBool(2)) + { + Main.dust[shadow].scale = 0.5f; + Main.dust[shadow].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + for (int d = 0; d < 10; d++) + { + int shadow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 100, new Color(0, 0, 0), 3f); + Main.dust[shadow].noGravity = true; + Main.dust[shadow].velocity *= 5f; + shadow = Dust.NewDust(projectile.position, projectile.width, projectile.height, 27, 0f, 0f, 100, new Color(0, 0, 0), 2f); + Main.dust[shadow].velocity *= 2f; + } + } + + public override void AI() + { + Player owner = Main.player[projectile.owner]; + NPC target = CalamityUtils.MinionHoming(projectile.Center, 1800f, owner); + + if (projectile.scale >= 1f) + { + if (target != null) + { + float num550 = 40f; + Vector2 vector43 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f); + float num551 = target.Center.X - vector43.X; + float num552 = target.Center.Y - vector43.Y; + float num553 = (float)Math.Sqrt((double)(num551 * num551 + num552 * num552)); + if (num553 < 100f) + { + num550 = 28f; //14 + } + num553 = num550 / num553; + num551 *= num553; + num552 *= num553; + projectile.velocity.X = (projectile.velocity.X * 25f + num551) / 26f; + projectile.velocity.Y = (projectile.velocity.Y * 25f + num552) / 26f; + if (Main.rand.NextBool(5)) + projectile.velocity *= 1.1f; + } + + } + else + { + projectile.scale += 0.025f; + projectile.velocity *= 1.03f; + } + + if (projectile.frameCounter > 6) + { + projectile.frame++; + projectile.frameCounter = 0; + } + if (projectile.frame >= Main.projFrames[projectile.type] - 1) + { + projectile.frame = 0; + } + projectile.frameCounter++; + + if (projectile.timeLeft <= 60) + { + projectile.alpha += 4; + } + } + } +} diff --git a/Projectiles/Summon/VoidConcentrationOrb.png b/Projectiles/Summon/VoidConcentrationOrb.png new file mode 100644 index 0000000000..036c9b9603 Binary files /dev/null and b/Projectiles/Summon/VoidConcentrationOrb.png differ diff --git a/Projectiles/Typeless/AstralSpray.cs b/Projectiles/Typeless/AstralSpray.cs index 5e9971ceca..01e3656923 100644 --- a/Projectiles/Typeless/AstralSpray.cs +++ b/Projectiles/Typeless/AstralSpray.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Typeless int x = (int)(projectile.Center.X / 16f); int y = (int)(projectile.Center.Y / 16f); - WorldGenerationMethods.ConvertToAstral(x - 1, x + 1, y - 1, y + 1); + AstralBiome.ConvertToAstral(x - 1, x + 1, y - 1, y + 1); } if (projectile.timeLeft > 133) { diff --git a/Projectiles/Typeless/SepulcherSoul.cs b/Projectiles/Typeless/SepulcherSoul.cs new file mode 100644 index 0000000000..38e6ccace4 --- /dev/null +++ b/Projectiles/Typeless/SepulcherSoul.cs @@ -0,0 +1,42 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class SepulcherSoul : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Tormented Soul"); + Main.projFrames[projectile.type] = 3; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 16; + projectile.Opacity = 0f; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = 120; + } + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + projectile.frame = Main.rand.Next(Main.projFrames[projectile.type]); + projectile.localAI[0] = 1f; + } + Vector2 idealVelocity = Vector2.Zero; + idealVelocity.X = (float)(Math.Sin(Time / 27f + projectile.identity * 1.1f) + (float)Math.Cos(Math.E * (Time / 27f + projectile.identity * 1.1f))) * 4f; + idealVelocity.Y = MathHelper.SmoothStep(-3f, -9f, (float)Math.Sin(Time / 23f + projectile.identity * 1.1f) * 0.5f + 0.5f); + projectile.velocity = Vector2.Lerp(projectile.velocity, idealVelocity, 0.075f); + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; + projectile.Opacity = Utils.InverseLerp(0f, 15f, Time, true) * Utils.InverseLerp(0f, 25f, projectile.timeLeft, true); + Time++; + } + } +} diff --git a/Projectiles/Typeless/SepulcherSoul.png b/Projectiles/Typeless/SepulcherSoul.png new file mode 100644 index 0000000000..a59212a6b7 Binary files /dev/null and b/Projectiles/Typeless/SepulcherSoul.png differ diff --git a/Projectiles/Typeless/WaterConvertor.cs b/Projectiles/Typeless/WaterConvertor.cs index e5afdf2afe..0072558c70 100644 --- a/Projectiles/Typeless/WaterConvertor.cs +++ b/Projectiles/Typeless/WaterConvertor.cs @@ -41,23 +41,23 @@ namespace CalamityMod.Projectiles.Typeless { if (projectile.ai[0] == 0f) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Pure); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Pure); } if (projectile.ai[0] == 1f) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Corrupt); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Corrupt); } if (projectile.ai[0] == 2f) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Crimson); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Crimson); } if (projectile.ai[0] == 3f) { - WorldGenerationMethods.ConvertFromAstral(i, j, ConvertType.Hallow); + AstralBiome.ConvertFromAstral(i, j, ConvertType.Hallow); } if (projectile.ai[0] == 4f) { - WorldGenerationMethods.ConvertToAstral(i, j); + AstralBiome.ConvertToAstral(i, j); NetMessage.SendTileRange(-1, i, j, 1, 1); } } diff --git a/Schematics/LargeScrapPile1.csch b/Schematics/LargeScrapPile1.csch new file mode 100644 index 0000000000..71acadddb1 Binary files /dev/null and b/Schematics/LargeScrapPile1.csch differ diff --git a/Schematics/LargeScrapPile2.csch b/Schematics/LargeScrapPile2.csch new file mode 100644 index 0000000000..415cbbcfc6 Binary files /dev/null and b/Schematics/LargeScrapPile2.csch differ diff --git a/Schematics/LargeScrapPile3.csch b/Schematics/LargeScrapPile3.csch new file mode 100644 index 0000000000..3faf1e1d48 Binary files /dev/null and b/Schematics/LargeScrapPile3.csch differ diff --git a/Schematics/LargeScrapPile4.csch b/Schematics/LargeScrapPile4.csch new file mode 100644 index 0000000000..d444a71416 Binary files /dev/null and b/Schematics/LargeScrapPile4.csch differ diff --git a/Schematics/SchematicManager.cs b/Schematics/SchematicManager.cs index 0dda76c2b1..031a94261e 100644 --- a/Schematics/SchematicManager.cs +++ b/Schematics/SchematicManager.cs @@ -33,6 +33,16 @@ namespace CalamityMod.Schematics // Astral world gen structures ["Astral Beacon"] = CalamitySchematicIO.LoadSchematic("Schematics/AstralBeacon.csch"), + + // Sulphurous Sea scrap world gen structures + ["Sulphurous Scrap 1"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile1.csch").ShaveOffEdge(), + ["Sulphurous Scrap 2"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile2.csch").ShaveOffEdge(), + ["Sulphurous Scrap 3"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile3.csch").ShaveOffEdge(), + ["Sulphurous Scrap 4"] = CalamitySchematicIO.LoadSchematic("Schematics/SmallScrapPile4.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 1"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile1.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 2"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile2.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 3"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile3.csch").ShaveOffEdge(), + ["Large Sulphurous Scrap 4"] = CalamitySchematicIO.LoadSchematic("Schematics/LargeScrapPile4.csch").ShaveOffEdge(), }; } internal static void Unload() @@ -41,7 +51,18 @@ namespace CalamityMod.Schematics PilePlacementMaps = null; } #endregion + + #region Get Schematic Area + public static Vector2? GetSchematicArea(string name) + { + // If no schematic exists with this name, simply return null. + if (!TileMaps.TryGetValue(name, out SchematicMetaTile[,] schematic)) + return null; + return new Vector2(schematic.GetLength(0), schematic.GetLength(1)); + } + #endregion Get Schematic Area + #region Place Schematic public static void PlaceSchematic(string name, Point pos, SchematicAnchor anchorType, ref bool specialCondition, T chestDelegate = null) where T : Delegate { diff --git a/Schematics/SmallScrapPile1.csch b/Schematics/SmallScrapPile1.csch new file mode 100644 index 0000000000..71adf27c17 Binary files /dev/null and b/Schematics/SmallScrapPile1.csch differ diff --git a/Schematics/SmallScrapPile2.csch b/Schematics/SmallScrapPile2.csch new file mode 100644 index 0000000000..51fc4a598e Binary files /dev/null and b/Schematics/SmallScrapPile2.csch differ diff --git a/Schematics/SmallScrapPile3.csch b/Schematics/SmallScrapPile3.csch new file mode 100644 index 0000000000..6d291fcf13 Binary files /dev/null and b/Schematics/SmallScrapPile3.csch differ diff --git a/Schematics/SmallScrapPile4.csch b/Schematics/SmallScrapPile4.csch new file mode 100644 index 0000000000..0161115799 Binary files /dev/null and b/Schematics/SmallScrapPile4.csch differ diff --git a/NPCs/SupremeCalamitas/SCalScreenShaderData.cs b/Skies/SCalScreenShaderData.cs similarity index 94% rename from NPCs/SupremeCalamitas/SCalScreenShaderData.cs rename to Skies/SCalScreenShaderData.cs index 7f0b3dca34..af7e823da1 100644 --- a/NPCs/SupremeCalamitas/SCalScreenShaderData.cs +++ b/Skies/SCalScreenShaderData.cs @@ -1,8 +1,9 @@ +using CalamityMod.NPCs.SupremeCalamitas; using Terraria; using Terraria.Graphics.Shaders; using Terraria.ModLoader; -namespace CalamityMod.NPCs.SupremeCalamitas +namespace CalamityMod.Skies { public class SCalScreenShaderData : ScreenShaderData { diff --git a/Skies/SCalSky.cs b/Skies/SCalSky.cs new file mode 100644 index 0000000000..d0e2978fe8 --- /dev/null +++ b/Skies/SCalSky.cs @@ -0,0 +1,246 @@ +using CalamityMod.NPCs; +using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.Projectiles.Boss; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.Graphics.Effects; +using Terraria.ModLoader; + +namespace CalamityMod.Skies +{ + public class SCalSky : CustomSky + { + public class Cinder + { + public int Time; + public int Lifetime; + public int IdentityIndex; + public float Scale; + public float Depth; + public Color DrawColor; + public Vector2 Velocity; + public Vector2 Center; + public Cinder(int lifetime, int identity, float depth, Color color, Vector2 startingPosition, Vector2 startingVelocity) + { + Lifetime = lifetime; + IdentityIndex = identity; + Depth = depth; + DrawColor = color; + Center = startingPosition; + Velocity = startingVelocity; + } + } + + private bool isActive = false; + private float intensity = 0f; + private int SCalIndex = -1; + public List Cinders = new List(); + public static int CinderReleaseChance + { + get + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) + return int.MaxValue; + + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + float lifeRatio = scal.life / (float)scal.lifeMax; + + // Release a good amount of cinders during bullet hells. If this is too distracting this can be + // inverted so that less appear than usual instead. + if (scal.ModNPC().bulletHellCounter2 % 900 != 0) + return lifeRatio <= 0.1f ? 8 : 11; + + // Release more and more cinders at the end of the battle until the acceptance phase, where it all slows down dramatically, with just a few ashes. + if (lifeRatio < 0.1f) + { + if (lifeRatio <= 0.01f) + return 32; + + return (int)Math.Round(MathHelper.Lerp(2f, 11f, Utils.InverseLerp(0.03f, 0.1f, lifeRatio, true))); + } + + // Release a good amount of cinders while brothers or Sepulcher-1 are alive. Sepulcher-2 falls into an above case and does not execute this return. + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + return 10; + + // Release a moderate amount of cinders normally. + return 18; + } + } + public static float CinderSpeed + { + get + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) + return 0f; + + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + float lifeRatio = scal.life / (float)scal.lifeMax; + + // Move more and more quickly at the end of the battle until the acceptance phase, where it all slows down dramatically. + if (lifeRatio < 0.1f) + { + if (lifeRatio <= 0.01f) + return 4.5f; + + return MathHelper.Lerp(10.75f, 6.7f, Utils.InverseLerp(0.03f, 0.1f, lifeRatio, true)); + } + + // Move a little quickly while brothers or Sepulcher-1 are alive. Sepulcher-2 falls into an above case and does not execute this return. + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + return 7.4f; + + // Move moderately quickly usually. + return 5.6f; + } + } + public static float OverridingIntensity = 0f; + + public override void Update(GameTime gameTime) + { + if (isActive && intensity < 1f) + { + intensity += 0.01f; + } + else if (!isActive && intensity > 0f) + { + intensity -= 0.01f; + } + + Color selectCinderColor() + { + if (!Main.npc.IndexInRange(CalamityGlobalNPC.SCal) || Main.npc[CalamityGlobalNPC.SCal].type != ModContent.NPCType()) + return Color.Transparent; + + NPC scal = Main.npc[CalamityGlobalNPC.SCal]; + float lifeRatio = scal.life / (float)scal.lifeMax; + if (lifeRatio > 0.5f) + return Color.Lerp(Color.Red, Color.Orange, Main.rand.NextFloat(0.8f)); + else if (lifeRatio > 0.3f) + return Color.Lerp(Color.DarkRed, Color.Lerp(Color.Blue, Color.DarkBlue, Main.rand.NextFloat() * 0.65f), 0.45f); + else if (lifeRatio > 0.01f) + return Color.Lerp(Color.Red, Color.Yellow, Main.rand.NextFloat(0.2f, 0.9f)); + else + return Color.Gray; + } + + // Randomly add cinders. + if (intensity >= 1f && Main.rand.NextBool(CinderReleaseChance)) + { + int lifetime = Main.rand.Next(285, 445); + float depth = Main.rand.NextFloat(1.8f, 5f); + Vector2 startingPosition = Main.screenPosition + new Vector2(Main.screenWidth * Main.rand.NextFloat(-0.1f, 1.1f), Main.screenHeight * 1.05f); + Vector2 startingVelocity = -Vector2.UnitY.RotatedByRandom(0.91f); + Cinders.Add(new Cinder(lifetime, Cinders.Count, depth, selectCinderColor(), startingPosition, startingVelocity)); + } + + // Update all cinders. + for (int i = 0; i < Cinders.Count; i++) + { + Cinders[i].Scale = Utils.InverseLerp(Cinders[i].Lifetime, Cinders[i].Lifetime / 3, Cinders[i].Time, true); + Cinders[i].Scale *= MathHelper.Lerp(0.6f, 0.9f, Cinders[i].IdentityIndex % 6f / 6f); + + Vector2 idealVelocity = -Vector2.UnitY.RotatedBy(MathHelper.Lerp(-0.94f, 0.94f, (float)Math.Sin(Cinders[i].Time / 36f + Cinders[i].IdentityIndex) * 0.5f + 0.5f)) * CinderSpeed; + float movementInterpolant = MathHelper.Lerp(0.01f, 0.08f, Utils.InverseLerp(45f, 145f, Cinders[i].Time, true)); + Cinders[i].Velocity = Vector2.Lerp(Cinders[i].Velocity, idealVelocity, movementInterpolant); + Cinders[i].Velocity = Cinders[i].Velocity.SafeNormalize(-Vector2.UnitY) * CinderSpeed; + Cinders[i].Time++; + + Cinders[i].Center += Cinders[i].Velocity; + } + + // Clear away all dead cinders. + Cinders.RemoveAll(c => c.Time >= c.Lifetime); + } + + private float GetIntensity() + { + if (CalamityUtils.CountProjectiles(ModContent.ProjectileType()) > 0) + return OverridingIntensity; + + OverridingIntensity = 0f; + if (UpdateSCalIndex()) + { + float x = 0f; + if (SCalIndex != -1) + x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this.SCalIndex].Center); + + return 1f - Utils.SmoothStep(3000f, 6000f, x); + } + return 0f; + } + + public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - GetIntensity())); + + private bool UpdateSCalIndex() + { + int SCalType = ModContent.NPCType(); + if (SCalIndex >= 0 && Main.npc[SCalIndex].active && Main.npc[SCalIndex].type == SCalType) + { + return true; + } + SCalIndex = -1; + for (int i = 0; i < Main.npc.Length; i++) + { + if (Main.npc[i].active && Main.npc[i].type == SCalType) + { + SCalIndex = i; + break; + } + } + return SCalIndex != -1; + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (maxDepth >= 0 && minDepth < 0) + { + float intensity = GetIntensity(); + spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity); + } + + // Draw cinders. + Texture2D cinderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/CalamitasCinder"); + for (int i = 0; i < Cinders.Count; i++) + { + Vector2 drawPosition = Cinders[i].Center - Main.screenPosition; + for (int j = 0; j < 3; j++) + { + Vector2 offsetDrawPosition = drawPosition + (MathHelper.TwoPi * j / 3f).ToRotationVector2() * 1.4f; + Color offsetDrawColor = Color.Red * 0.56f; + offsetDrawColor.A = 0; + spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); + } + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale, SpriteEffects.None, 0f); + } + } + + public override float GetCloudAlpha() + { + return 0f; + } + + public override void Activate(Vector2 position, params object[] args) + { + isActive = true; + } + + public override void Deactivate(params object[] args) + { + isActive = false; + } + + public override void Reset() + { + isActive = false; + } + + public override bool IsActive() + { + return isActive || intensity > 0f; + } + } +} diff --git a/Sounds/Custom/SCalSounds/SepulcherSpawn.cs b/Sounds/Custom/SCalSounds/SepulcherSpawn.cs new file mode 100644 index 0000000000..45ffb992dd --- /dev/null +++ b/Sounds/Custom/SCalSounds/SepulcherSpawn.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.Custom.SCalSounds +{ + public class SepulcherSpawn : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/Custom/SCalSounds/SepulcherSpawn.ogg b/Sounds/Custom/SCalSounds/SepulcherSpawn.ogg new file mode 100644 index 0000000000..b0b6e2ccf8 Binary files /dev/null and b/Sounds/Custom/SCalSounds/SepulcherSpawn.ogg differ diff --git a/Sounds/Custom/THanosLaser.ogg b/Sounds/Custom/THanosLaser.ogg new file mode 100644 index 0000000000..46efb4dc75 Binary files /dev/null and b/Sounds/Custom/THanosLaser.ogg differ diff --git a/Sounds/NPCKilled/SepulcherDeath.cs b/Sounds/NPCKilled/SepulcherDeath.cs new file mode 100644 index 0000000000..d4e74ea577 --- /dev/null +++ b/Sounds/NPCKilled/SepulcherDeath.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework.Audio; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Sounds.NPCKilled +{ + public class SepulcherDeath : ModSound + { + public override SoundEffectInstance PlaySound(ref SoundEffectInstance soundInstance, float volume, float pan, SoundType type) + { + soundInstance = sound.CreateInstance(); + soundInstance.Volume = volume; + soundInstance.Pan = pan; + Main.PlaySoundInstance(soundInstance); + return soundInstance; + } + } +} diff --git a/Sounds/NPCKilled/SepulcherDeath.ogg b/Sounds/NPCKilled/SepulcherDeath.ogg new file mode 100644 index 0000000000..8da5bc6466 Binary files /dev/null and b/Sounds/NPCKilled/SepulcherDeath.ogg differ diff --git a/Tiles/Abyss/HardenedSulphurousSandstone.cs b/Tiles/Abyss/HardenedSulphurousSandstone.cs index 96246262f5..5009eeb8b5 100644 --- a/Tiles/Abyss/HardenedSulphurousSandstone.cs +++ b/Tiles/Abyss/HardenedSulphurousSandstone.cs @@ -18,8 +18,7 @@ namespace CalamityMod.Tiles.Abyss dustType = 32; drop = ModContent.ItemType(); AddMapEntry(new Color(76, 58, 59)); - mineResist = 1f; - minPick = 55; + mineResist = 1.45f; soundType = SoundID.Dig; } diff --git a/Tiles/Abyss/SulphurousSand.cs b/Tiles/Abyss/SulphurousSand.cs index d618d98692..4b71230ae7 100644 --- a/Tiles/Abyss/SulphurousSand.cs +++ b/Tiles/Abyss/SulphurousSand.cs @@ -22,7 +22,6 @@ namespace CalamityMod.Tiles.Abyss drop = ModContent.ItemType(); AddMapEntry(new Color(150, 100, 50)); mineResist = 1f; - minPick = 55; soundType = SoundID.Dig; SetModPalmTree(new AcidWoodTree()); SetModCactus(new SulphurousCactus()); diff --git a/Tiles/Abyss/SulphurousSandstone.cs b/Tiles/Abyss/SulphurousSandstone.cs index 4427a0dd15..d6f296f702 100644 --- a/Tiles/Abyss/SulphurousSandstone.cs +++ b/Tiles/Abyss/SulphurousSandstone.cs @@ -18,8 +18,7 @@ namespace CalamityMod.Tiles.Abyss dustType = 32; drop = ModContent.ItemType(); AddMapEntry(new Color(113, 90, 71)); - mineResist = 1f; - minPick = 55; + mineResist = 1.2f; soundType = SoundID.Dig; } diff --git a/Tiles/DraedonStructures/DraedonLabTurret.cs b/Tiles/DraedonStructures/DraedonLabTurret.cs index c20e55d5ab..32ab987461 100644 --- a/Tiles/DraedonStructures/DraedonLabTurret.cs +++ b/Tiles/DraedonStructures/DraedonLabTurret.cs @@ -41,9 +41,8 @@ namespace CalamityMod.Tiles.DraedonStructures soundType = SoundID.Item; soundStyle = 14; - // Requires a Gold Pickaxe or better to mine. Has 500% durability. - mineResist = 5.00f; - minPick = 55; + // Has 500% durability. + mineResist = 5f; } public override bool CanExplode(int i, int j) => false; diff --git a/Tiles/SunkenSea/Navystone.cs b/Tiles/SunkenSea/Navystone.cs index 657024ec36..83a85d5457 100644 --- a/Tiles/SunkenSea/Navystone.cs +++ b/Tiles/SunkenSea/Navystone.cs @@ -24,7 +24,6 @@ namespace CalamityMod.Tiles.SunkenSea name.SetDefault("Navystone"); AddMapEntry(new Color(0, 50, 50), name); mineResist = 2f; - minPick = 55; soundType = SoundID.Tink; } diff --git a/Tiles/SunkenSea/SeaPrism.cs b/Tiles/SunkenSea/SeaPrism.cs index 03acfe7ddd..6337a4a41e 100644 --- a/Tiles/SunkenSea/SeaPrism.cs +++ b/Tiles/SunkenSea/SeaPrism.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Tiles.SunkenSea name.SetDefault("Sea Prism"); AddMapEntry(new Color(0, 150, 200), name); mineResist = 3f; - minPick = 55; soundType = SoundID.Tink; Main.tileSpelunker[Type] = true; } diff --git a/Utilities/CollisionUtils.cs b/Utilities/CollisionUtils.cs index 2ba78d6163..13537d71e1 100644 --- a/Utilities/CollisionUtils.cs +++ b/Utilities/CollisionUtils.cs @@ -24,5 +24,29 @@ namespace CalamityMod float _ = 0f; return Collision.CheckAABBvLineCollision(targetTopLeft, targetHitboxDimensions, start, end, entity.width, ref _); } + + /// + /// Determines if a typical hitbox rectangle is intersecting a circular hitbox. + /// + /// The center of the circular hitbox. + /// The radius of the circular hitbox. + /// The hitbox of the target to check. + public static bool CircularHitboxCollision(Vector2 centerCheckPosition, float radius, Rectangle targetHitbox) + { + float topLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopLeft()); + float topRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.TopRight()); + float bottomLeftDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomLeft()); + float bottomRightDistance = Vector2.Distance(centerCheckPosition, targetHitbox.BottomRight()); + + float distanceToClosestPoint = topLeftDistance; + if (topRightDistance < distanceToClosestPoint) + distanceToClosestPoint = topRightDistance; + if (bottomLeftDistance < distanceToClosestPoint) + distanceToClosestPoint = bottomLeftDistance; + if (bottomRightDistance < distanceToClosestPoint) + distanceToClosestPoint = bottomRightDistance; + + return distanceToClosestPoint <= radius; + } } } diff --git a/Utilities/MiscUtils.cs b/Utilities/MiscUtils.cs index 12b400734c..31d3f21c91 100644 --- a/Utilities/MiscUtils.cs +++ b/Utilities/MiscUtils.cs @@ -44,6 +44,19 @@ namespace CalamityMod return array; } + public static T[,] ShaveOffEdge(this T[,] array) + { + T[,] result = new T[array.GetLength(0) - 2, array.GetLength(1) - 2]; + for (int i = 0; i < result.GetLength(0); i++) + { + for (int j = 0; j < result.GetLength(1); j++) + { + result[i, j] = array[i + 1, j + 1]; + } + } + return result; + } + /// /// Retrieves all the colors from a and returns them as a 2D array. /// @@ -294,5 +307,12 @@ namespace CalamityMod end = start + Vector2.Normalize(end - start) * maxDistance; } } + + public static void ChangeTime(bool changeToDay) + { + Main.time = 0D; + Main.dayTime = changeToDay; + CalamityNetcode.SyncWorld(); + } } } diff --git a/Utilities/NPCDebuffs.cs b/Utilities/NPCDebuffs.cs index 794f7ce459..8c214aa6bc 100644 --- a/Utilities/NPCDebuffs.cs +++ b/Utilities/NPCDebuffs.cs @@ -190,7 +190,7 @@ namespace CalamityMod { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, - { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, + { ModContent.NPCType(), new Tuple(false, CalamityMod.cragEnemyImmunities) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, { ModContent.NPCType(), new Tuple(true, new int[] { }) }, diff --git a/Utilities/NPCStats.cs b/Utilities/NPCStats.cs index 5709e12e23..9073336a0b 100644 --- a/Utilities/NPCStats.cs +++ b/Utilities/NPCStats.cs @@ -11,6 +11,7 @@ using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs.Ares; using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.HiveMind; using CalamityMod.NPCs.Leviathan; @@ -810,6 +811,13 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 500, 752, 788, 808, 1182 } }, + //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 712, 732, 1068 } }, + //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 600, 632, 648, 948 } }, + //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + //{ new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 500, 752, 788, 808, 1182 } }, + { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossIceMist), new int[] { 400, 600, 632, 648, 948 } }, { new Tuple(ModContent.NPCType(), ProjectileID.CultistBossLightningOrbArc), new int[] { 500, 752, 788, 808, 1182 } }, { new Tuple(ModContent.NPCType(), ProjectileID.AncientDoomProjectile), new int[] { 400, 600, 632, 648, 948 } }, diff --git a/Utilities/WorldgenUtils.cs b/Utilities/WorldgenUtils.cs new file mode 100644 index 0000000000..7552177cc3 --- /dev/null +++ b/Utilities/WorldgenUtils.cs @@ -0,0 +1,35 @@ +using System.Linq; +using Terraria; +using Terraria.ID; + +namespace CalamityMod +{ + public static partial class CalamityUtils + { + /// + /// Generates clusters of ore across the world based on various requirements and with various strengths/frequencies. + /// + /// + /// + /// + /// + /// + /// + /// + public static void SpawnOre(int type, double frequency, float verticalStartFactor, float verticalEndFactor, int strengthMin, int strengthMax, params int[] convertibleTiles) + { + int x = Main.maxTilesX; + int y = Main.maxTilesY; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int k = 0; k < (int)(x * y * frequency); k++) + { + int tilesX = WorldGen.genRand.Next(0, x); + int tilesY = WorldGen.genRand.Next((int)(y * verticalStartFactor), (int)(y * verticalEndFactor)); + if (convertibleTiles.Length <= 0 || convertibleTiles.Contains(ParanoidTileRetrieval(tilesX, tilesY).type)) + WorldGen.OreRunner(tilesX, tilesY, WorldGen.genRand.Next(strengthMin, strengthMax), WorldGen.genRand.Next(3, 8), (ushort)type); + } + } + } + } +} diff --git a/World/Abyss.cs b/World/Abyss.cs index e8ced8b34c..3bb51503c8 100644 --- a/World/Abyss.cs +++ b/World/Abyss.cs @@ -1,13 +1,24 @@ +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Pets; +using CalamityMod.Items.Tools.ClimateChange; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Items.Weapons.Ranged; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Items.Weapons.Summon; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.FurnitureVoid; +using CalamityMod.Tiles.Ores; using CalamityMod.Walls; +using Microsoft.Xna.Framework; +using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.World { - public class Abyss : ModWorld + public class Abyss { public static void PlaceAbyss() { @@ -219,7 +230,7 @@ namespace CalamityMod.World } } - WorldGenerationMethods.ChasmGenerator(abyssChasmX, (int)WorldGen.worldSurfaceLow, CalamityWorld.abyssChasmBottom, true); + MiscWorldgenRoutines.ChasmGenerator(abyssChasmX, (int)WorldGen.worldSurfaceLow, CalamityWorld.abyssChasmBottom, true); int maxAbyssIslands = 11; //Small World if (y > 2100) @@ -227,8 +238,9 @@ namespace CalamityMod.World else if (y > 1500) maxAbyssIslands = 16; //Medium World - WorldGenerationMethods.SpecialHut((ushort)ModContent.TileType(), (ushort)ModContent.TileType(), - (ushort)ModContent.WallType(), 8, abyssChasmX, CalamityWorld.abyssChasmBottom); + // Place the Terminus shrine. + UndergroundShrines.SpecialHut((ushort)ModContent.TileType(), (ushort)ModContent.TileType(), + (ushort)ModContent.WallType(), UndergroundShrines.UndergroundShrineType.Abyss, abyssChasmX, CalamityWorld.abyssChasmBottom); int islandLocationOffset = 30; int islandLocationY = rockLayer; @@ -241,32 +253,32 @@ namespace CalamityMod.World switch (randomIsland) { case 0: - WorldGenerationMethods.AbyssIsland(islandLocationX, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX + 40, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX - 40, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX + 40, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 40, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); break; case 1: - WorldGenerationMethods.AbyssIsland(islandLocationX + 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX - 40, islandLocationY + 10, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX + 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 40, islandLocationY + 10, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); islandLocationX += 30; break; case 2: - WorldGenerationMethods.AbyssIsland(islandLocationX - 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX + 30, islandLocationY + 10, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 30, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX + 30, islandLocationY + 10, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); islandLocationX -= 30; break; case 3: - WorldGenerationMethods.AbyssIsland(islandLocationX + 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX - 5, islandLocationY + 5, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX - 35, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX + 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX - 5, islandLocationY + 5, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 35, islandLocationY + 15, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); islandLocationX += 25; break; case 4: - WorldGenerationMethods.AbyssIsland(islandLocationX - 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX + 5, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); - WorldGenerationMethods.AbyssIsland(islandLocationX + 35, islandLocationY + 5, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX - 25, islandLocationY, 60, 66, 30, 36, true, false, hasVoidstone); + AbyssIsland(islandLocationX + 5, islandLocationY + 15, 60, 66, 30, 36, false, tenebrisSide, hasVoidstone); + AbyssIsland(islandLocationX + 35, islandLocationY + 5, 60, 66, 30, 36, false, !tenebrisSide, hasVoidstone); islandLocationX -= 25; break; } @@ -283,7 +295,7 @@ namespace CalamityMod.World for (int abyssHouse = 0; abyssHouse < CalamityWorld.numAbyssIslands; abyssHouse++) //11 15 19 { if (abyssHouse != 20) - WorldGenerationMethods.AbyssIslandHouse(CalamityWorld.AbyssIslandX[abyssHouse], + AbyssIslandHouse(CalamityWorld.AbyssIslandX[abyssHouse], CalamityWorld.AbyssIslandY[abyssHouse], CalamityWorld.AbyssItemArray[abyssHouse > 9 ? (abyssHouse - 10) : abyssHouse], //10 choices 0 to 9 CalamityWorld.AbyssIslandY[abyssHouse] > (rockLayer + y * 0.143)); @@ -350,5 +362,460 @@ namespace CalamityMod.World } } } - } + + #region Houses + public static void AbyssIsland(int i, int j, int sizeMin, int sizeMax, int sizeMin2, int sizeMax2, bool hasChest, bool hasTenebris, bool isVoid) + { + int sizeMinSmall = sizeMin / 5; + int sizeMaxSmall = sizeMax / 5; + double num = (double)WorldGen.genRand.Next(sizeMin, sizeMax); //100 150 + float num2 = (float)WorldGen.genRand.Next(sizeMinSmall, sizeMaxSmall); //20 30 + int num3 = i; + int num4 = i; + int num5 = i; + int num6 = j; + Vector2 vector; + vector.X = (float)i; + vector.Y = (float)j; + Vector2 vector2; + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + while (vector2.X > -2f && vector2.X < 2f) + { + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + } + vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; + while (num > 0.0 && num2 > 0f) + { + num -= (double)WorldGen.genRand.Next(4); + num2 -= 1f; + int num7 = (int)((double)vector.X - num * 0.5); + int num8 = (int)((double)vector.X + num * 0.5); + int num9 = (int)((double)vector.Y - num * 0.5); + int num10 = (int)((double)vector.Y + num * 0.5); + if (num7 < 0) + { + num7 = 0; + } + if (num8 > Main.maxTilesX) + { + num8 = Main.maxTilesX; + } + if (num9 < 0) + { + num9 = 0; + } + if (num10 > Main.maxTilesY) + { + num10 = Main.maxTilesY; + } + double num11 = num * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 + float num12 = vector.Y + 1f; + for (int k = num7; k < num8; k++) + { + if (WorldGen.genRand.Next(2) == 0) + { + num12 += (float)WorldGen.genRand.Next(-1, 2); + } + if (num12 < vector.Y) + { + num12 = vector.Y; + } + if (num12 > vector.Y + 2f) + { + num12 = vector.Y + 2f; + } + for (int l = num9; l < num10; l++) + { + if ((float)l > num12) + { + float arg_218_0 = Math.Abs((float)k - vector.X); + float num13 = Math.Abs((float)l - vector.Y) * 3f; + if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) + { + if (k < num3) + { + num3 = k; + } + if (k > num4) + { + num4 = k; + } + if (l < num5) + { + num5 = l; + } + if (l > num6) + { + num6 = l; + } + Main.tile[k, l].active(true); + Main.tile[k, l].type = (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType()); + CalamityUtils.SafeSquareTileFrame(k, l, true); + } + } + } + } + vector += vector2; + vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; + if (vector2.X > 1f) + { + vector2.X = 1f; + } + if (vector2.X < -1f) + { + vector2.X = -1f; + } + if ((double)vector2.Y > 0.2) + { + vector2.Y = -0.2f; + } + if ((double)vector2.Y < -0.2) + { + vector2.Y = -0.2f; + } + } + int m = num3; + int num15; + for (m += WorldGen.genRand.Next(5); m < num4; m += WorldGen.genRand.Next(num15, (int)((double)num15 * 1.5))) + { + int num14 = num6; + while (!Main.tile[m, num14].active()) + { + num14--; + } + num14 += WorldGen.genRand.Next(-3, 4); + num15 = WorldGen.genRand.Next(4, 8); + int num16 = isVoid ? ModContent.TileType() : ModContent.TileType(); + if (WorldGen.genRand.Next(4) == 0) + { + num16 = hasChest ? ModContent.TileType() : ModContent.TileType(); + } + for (int n = m - num15; n <= m + num15; n++) + { + for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) + { + if (num17 > num5) + { + float arg_409_0 = (float)Math.Abs(n - m); + float num18 = (float)(Math.Abs(num17 - num14) * 2); + if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) + { + Main.tile[n, num17].active(true); + Main.tile[n, num17].type = (ushort)num16; + CalamityUtils.SafeSquareTileFrame(n, num17, true); + } + } + } + } + } + if (hasTenebris) + { + int p = num3; + int num150; + for (p += WorldGen.genRand.Next(5); p < num4; p += WorldGen.genRand.Next(num150, (int)((double)num150 * 1.5))) + { + int num14 = num6; + while (!Main.tile[p, num14].active()) + { + num14--; + } + num14 += WorldGen.genRand.Next(-3, 4); //-3 4 + num150 = 1; //4 8 + int num16 = ModContent.TileType(); + for (int n = p - num150; n <= p + num150; n++) + { + for (int num17 = num14 - num150; num17 <= num14 + num150; num17++) + { + if (num17 > num5) + { + float arg_409_0 = (float)Math.Abs(n - p); + float num18 = (float)(Math.Abs(num17 - num14) * 2); + if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num150 + WorldGen.genRand.Next(2))) + { + Main.tile[n, num17].active(true); + Main.tile[n, num17].type = (ushort)num16; + CalamityUtils.SafeSquareTileFrame(n, num17, true); + } + } + } + } + } + } + int sizeMinSmall2 = sizeMin2 / 8; + int sizeMaxSmall2 = sizeMax2 / 8; + num = (double)WorldGen.genRand.Next(sizeMin2, sizeMax2); + num2 = (float)WorldGen.genRand.Next(sizeMinSmall2, sizeMaxSmall2); + vector.X = (float)i; + vector.Y = (float)num5; + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + while (vector2.X > -2f && vector2.X < 2f) + { + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + } + vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; + while (num > 0.0 && num2 > 0f) + { + num -= (double)WorldGen.genRand.Next(4); + num2 -= 1f; + vector += vector2; + vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; + if (vector2.X > 1f) + { + vector2.X = 1f; + } + if (vector2.X < -1f) + { + vector2.X = -1f; + } + if ((double)vector2.Y > 0.2) + { + vector2.Y = -0.2f; + } + if ((double)vector2.Y < -0.2) + { + vector2.Y = -0.2f; + } + } + int num23 = num3; + num23 += WorldGen.genRand.Next(5); + while (num23 < num4) + { + int num24 = num6; + while ((!Main.tile[num23, num24].active() || Main.tile[num23, num24].type != 0) && num23 < num4) + { + num24--; + if (num24 < num5) + { + num24 = num6; + num23 += WorldGen.genRand.Next(1, 4); + } + } + if (num23 < num4) + { + num24 += WorldGen.genRand.Next(0, 4); + int num25 = WorldGen.genRand.Next(2, 5); + int num26 = isVoid ? ModContent.TileType() : ModContent.TileType(); + for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) + { + for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) + { + if (num28 > num5) + { + float arg_890_0 = (float)Math.Abs(num27 - num23); + float num29 = (float)(Math.Abs(num28 - num24) * 2); + if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < (double)num25) + { + Main.tile[num27, num28].type = (ushort)num26; + CalamityUtils.SafeSquareTileFrame(num27, num28, true); + } + } + } + } + num23 += WorldGen.genRand.Next(num25, (int)((double)num25 * 1.5)); + } + } + for (int num30 = num3 - 20; num30 <= num4 + 20; num30++) + { + for (int num31 = num5 - 20; num31 <= num6 + 20; num31++) + { + bool flag = true; + for (int num32 = num30 - 1; num32 <= num30 + 1; num32++) + { + for (int num33 = num31 - 1; num33 <= num31 + 1; num33++) + { + if (!Main.tile[num32, num33].active()) + { + flag = false; + } + } + } + if (flag) + { + Main.tile[num30, num31].wall = (ushort)(isVoid ? ModContent.WallType() : ModContent.WallType()); + WorldGen.SquareWallFrame(num30, num31, true); + } + } + } + for (int num34 = num3; num34 <= num4; num34++) + { + int num35 = num5 - 10; + while (!Main.tile[num34, num35 + 1].active()) + { + num35++; + } + if (num35 < num6 && Main.tile[num34, num35 + 1].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) + { + if (WorldGen.genRand.Next(10) == 0) + { + int num36 = WorldGen.genRand.Next(1, 3); + for (int num37 = num34 - num36; num37 <= num34 + num36; num37++) + { + if (Main.tile[num37, num35].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) + { + Main.tile[num37, num35].active(false); + Main.tile[num37, num35].liquid = 255; + Main.tile[num37, num35].lava(false); + CalamityUtils.SafeSquareTileFrame(num34, num35, true); + } + if (Main.tile[num37, num35 + 1].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) + { + Main.tile[num37, num35 + 1].active(false); + Main.tile[num37, num35 + 1].liquid = 255; + Main.tile[num37, num35 + 1].lava(false); + CalamityUtils.SafeSquareTileFrame(num34, num35 + 1, true); + } + if (num37 > num34 - num36 && num37 < num34 + 2 && Main.tile[num37, num35 + 2].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) + { + Main.tile[num37, num35 + 2].active(false); + Main.tile[num37, num35 + 2].liquid = 255; + Main.tile[num37, num35 + 2].lava(false); + CalamityUtils.SafeSquareTileFrame(num34, num35 + 2, true); + } + } + } + if (WorldGen.genRand.Next(5) == 0) + { + Main.tile[num34, num35].liquid = 255; + } + Main.tile[num34, num35].lava(false); + CalamityUtils.SafeSquareTileFrame(num34, num35, true); + } + } + } + + public static void AbyssIslandHouse(int i, int j, int itemChoice, bool isVoid) + { + ushort type = (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType()); //tile + ushort wall = (ushort)(isVoid ? ModContent.WallType() : ModContent.WallType()); //wall + Vector2 vector = new Vector2((float)i, (float)j); + int num = 1; + if (WorldGen.genRand.Next(2) == 0) + { + num = -1; + } + int num2 = WorldGen.genRand.Next(5, 9); + int num3 = 3; + vector.X = (float)(i + (num2 + 2) * num); + for (int k = j - 15; k < j + 30; k++) + { + if (Main.tile[(int)vector.X, k].active()) + { + vector.Y = (float)(k - 1); + break; + } + } + vector.X = (float)i; + int num4 = (int)(vector.X - (float)num2 - 1f); + int num5 = (int)(vector.X + (float)num2 + 1f); + int num6 = (int)(vector.Y - (float)num3 - 1f); + int num7 = (int)(vector.Y + 2f); + if (num4 < 0) + { + num4 = 0; + } + if (num5 > Main.maxTilesX) + { + num5 = Main.maxTilesX; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int l = num4; l <= num5; l++) + { + for (int m = num6 - 1; m < num7 + 1; m++) + { + if (m != num6 - 1 || (l != num4 && l != num5)) + { + Main.tile[l, m].active(true); + Main.tile[l, m].type = type; + Main.tile[l, m].wall = wall; + Main.tile[l, m].halfBrick(false); + Main.tile[l, m].slope(0); + } + } + } + num4 = (int)(vector.X - (float)num2); + num5 = (int)(vector.X + (float)num2); + num6 = (int)(vector.Y - (float)num3); + num7 = (int)(vector.Y + 1f); + if (num4 < 0) + { + num4 = 0; + } + if (num5 > Main.maxTilesX) + { + num5 = Main.maxTilesX; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int n = num4; n <= num5; n++) + { + for (int num8 = num6; num8 < num7; num8++) + { + if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].wall == wall) + { + Main.tile[n, num8].active(false); + } + } + } + int num9 = i + (num2 + 1) * num; + int num10 = (int)vector.Y; + for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) + { + Main.tile[num11, num10].active(false); + Main.tile[num11, num10 - 1].active(false); + Main.tile[num11, num10 - 2].active(false); + } + switch (itemChoice) + { + case 0: + itemChoice = ModContent.ItemType(); + break; //rain item + case 1: + itemChoice = ModContent.ItemType(); + break; //movement acc + case 2: + itemChoice = ModContent.ItemType(); + break; //regen acc + case 3: + itemChoice = ModContent.ItemType(); + break; //ranged + case 4: + itemChoice = ModContent.ItemType(); + break; //defense acc + case 5: + itemChoice = ModContent.ItemType(); + break; //melee + case 6: + itemChoice = ModContent.ItemType(); + break; //light pet + case 7: + itemChoice = ModContent.ItemType(); + break; //summon + case 8: + itemChoice = ModContent.ItemType(); + break; //magic + case 9: + itemChoice = ModContent.ItemType(); + break; //throwing + default: + itemChoice = 497; + break; + } + WorldGen.AddBuriedChest(i, num10 - 3, itemChoice, false, 4); //chest + } + #endregion + + } } diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs new file mode 100644 index 0000000000..8d44f12849 --- /dev/null +++ b/World/AstralBiome.cs @@ -0,0 +1,1175 @@ +using CalamityMod.Schematics; +using CalamityMod.Tiles.Abyss; +using CalamityMod.Tiles.Astral; +using CalamityMod.Tiles.AstralDesert; +using CalamityMod.Tiles.AstralSnow; +using CalamityMod.Tiles.FurnitureVoid; +using CalamityMod.Tiles.Ores; +using CalamityMod.Walls; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Utilities; +using Terraria.World.Generation; + +namespace CalamityMod.World +{ + public class AstralBiome + { + public static bool CanAstralMeteorSpawn() + { + int astralOreCount = 0; + float worldSizeFactor = Main.maxTilesX / 4200f; // Small = 4200, Medium = 6400, Large = 8400 + int astralOreAllowed = (int)(200f * worldSizeFactor); // Small = 201 Medium = 305 Large = 401 + for (int x = 5; x < Main.maxTilesX - 5; x++) + { + int y = 5; + while (y < Main.worldSurface) + { + if (Main.tile[x, y].active() && Main.tile[x, y].type == ModContent.TileType()) + { + astralOreCount++; + if (astralOreCount > astralOreAllowed) + return false; + } + y++; + } + } + return true; + } + + public static bool CanAstralBiomeSpawn() + { + int astralTileCount = 0; + float worldSizeFactor = Main.maxTilesX / 4200f; // Small = 4200, Medium = 6400, Large = 8400 + int astralTilesAllowed = (int)(400f * worldSizeFactor); // Small = 401 Medium = 605 Large = 801 + for (int x = 5; x < Main.maxTilesX - 5; x++) + { + int y = 5; + while (y < Main.worldSurface) + { + if (Main.tile[x, y].active() && + (Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || + Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || + Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || + Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || + Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || + Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType())) + { + astralTileCount++; + if (astralTileCount > astralTilesAllowed) + return false; + } + y++; + } + } + return true; + } + + public static void PlaceAstralMeteor() + { + Mod ancientsAwakened = CalamityMod.Instance.ancientsAwakened; + + // This flag is also used to determine whether players are nearby. + bool meteorDropped = true; + + // Clients in multiplayer don't drop meteors. + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + for (int i = 0; i < 255; i++) + { + if (Main.player[i].active) + { + meteorDropped = false; + break; + } + } + + // Check whether there is already too much ore. + if (!CanAstralMeteorSpawn()) + return; + + UnifiedRandom rand = WorldGen.genRand; + float solidTileRequirement = 600f; + bool localAbyssSide = WorldGen.dungeonX < Main.maxTilesX / 2; + while (!meteorDropped) + { + float worldEdgeMargin = (float)Main.maxTilesX * 0.08f; + int xLimit = Main.maxTilesX / 2; + int x = CalamityWorld.abyssSide ? rand.Next(400, xLimit) : rand.Next(xLimit, Main.maxTilesX - 400); + while ((float)x > (float)Main.spawnTileX - worldEdgeMargin && (float)x < (float)Main.spawnTileX + worldEdgeMargin) + { + x = CalamityWorld.abyssSide ? rand.Next(400, xLimit) : rand.Next(xLimit, Main.maxTilesX - 400); + } + //world surface = 920 large 740 medium 560 small + int y = (int)(Main.worldSurface * 0.5); //Large = 522, Medium = 444, Small = 336 + while (y < Main.maxTilesY) + { + if (Main.tile[x, y].active() && Main.tileSolid[(int)Main.tile[x, y].type]) + { + int suitableTiles = 0; + int checkRadius = 15; + for (int l = x - checkRadius; l < x + checkRadius; l++) + { + for (int m = y - checkRadius; m < y + checkRadius; m++) + { + if (WorldGen.SolidTile(l, m)) + { + suitableTiles++; + + // Avoid floating islands: Clouds and Sunplate both harshly punish attempted meteor spawns + if (Main.tile[l, m].type == TileID.Cloud || Main.tile[l, m].type == TileID.Sunplate) + { + suitableTiles -= 100; + } + // Avoid Sulphurous Sea beach: Cannot be converted by astral + else if (Main.tile[l, m].type == ModContent.TileType() || Main.tile[l, m].type == ModContent.TileType()) + { + suitableTiles -= 100; + } + + // Prevent the Astral biome from overriding or interfering with an AA biome + else if (ancientsAwakened != null) + { + if (Main.tile[l, m].type == ancientsAwakened.TileType("InfernoGrass") || Main.tile[l, m].type == ancientsAwakened.TileType("Torchstone") || + Main.tile[l, m].type == ancientsAwakened.TileType("Torchsand") || Main.tile[l, m].type == ancientsAwakened.TileType("Torchsandstone") || + Main.tile[l, m].type == ancientsAwakened.TileType("Torchsandhardened") || Main.tile[l, m].type == ancientsAwakened.TileType("Torchice") || + Main.tile[l, m].type == ancientsAwakened.TileType("Depthstone") || Main.tile[l, m].type == ancientsAwakened.TileType("Depthsand") || + Main.tile[l, m].type == ancientsAwakened.TileType("Depthsandstone") || Main.tile[l, m].type == ancientsAwakened.TileType("Depthsandhardened") || + Main.tile[l, m].type == ancientsAwakened.TileType("Depthice")) + { + suitableTiles -= 100; + } + } + } + + // Liquid aversion makes meteors less likely to fall in lakes + else if (Main.tile[l, m].liquid > 0) + { + suitableTiles--; + } + } + } + + if ((float)suitableTiles < solidTileRequirement) + { + solidTileRequirement -= 0.5f; + break; + } + meteorDropped = GenerateAstralMeteor(x, y); + + // If the meteor actually dropped, post the message stating as such. + if (meteorDropped) + { + string key = "Mods.CalamityMod.AstralText"; + Color messageColor = Color.Gold; + + CalamityUtils.DisplayLocalizedText(key, messageColor); + break; + } + break; + } + else + { + y++; + } + } + if (solidTileRequirement < 100f) + { + return; + } + } + } + + public static bool GenerateAstralMeteor(int i, int j) + { + UnifiedRandom rand = WorldGen.genRand; + if (i < 50 || i > Main.maxTilesX - 50) + { + return false; + } + // Avoid the dungeon so that the beacon doesn't eat it. + if (Math.Abs(i - WorldGen.dungeonX) < 65) + { + return false; + } + if (j < 50 || j > Main.maxTilesY - 50) + { + return false; + } + int num = 35; + Rectangle rectangle = new Rectangle((i - num) * 16, (j - num) * 16, num * 2 * 16, num * 2 * 16); + for (int k = 0; k < 255; k++) + { + if (Main.player[k].active) + { + Rectangle value = new Rectangle((int)(Main.player[k].position.X + (float)(Main.player[k].width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.player[k].position.Y + (float)(Main.player[k].height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2); + if (rectangle.Intersects(value)) + { + return false; + } + } + } + for (int l = 0; l < 200; l++) + { + if (Main.npc[l].active) + { + Rectangle value2 = new Rectangle((int)Main.npc[l].position.X, (int)Main.npc[l].position.Y, Main.npc[l].width, Main.npc[l].height); + if (rectangle.Intersects(value2)) + { + return false; + } + } + } + for (int m = i - num; m < i + num; m++) + { + for (int n = j - num; n < j + num; n++) + { + if (Main.tile[m, n].active() && Main.tile[m, n].type == 21) + { + return false; + } + } + } + num = rand.Next(17, 23); + for (int num2 = i - num; num2 < i + num; num2++) + { + for (int num3 = j - num; num3 < j + num; num3++) + { + if (num3 > j + rand.Next(-2, 3) - 5) + { + float num4 = (float)Math.Abs(i - num2); + float num5 = (float)Math.Abs(j - num3); + float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); + if ((double)num6 < (double)num * 0.9 + (double)rand.Next(-4, 5)) + { + if (Main.tile[num2, num3] != null) + { + if (!Main.tileSolid[(int)Main.tile[num2, num3].type]) + { + Main.tile[num2, num3].active(false); + } + Main.tile[num2, num3].type = (ushort)ModContent.TileType(); + } + } + } + } + } + num = WorldGen.genRand.Next(8, 14); + for (int num7 = i - num; num7 < i + num; num7++) + { + for (int num8 = j - num; num8 < j + num; num8++) + { + if (num8 > j + rand.Next(-2, 3) - 4) + { + float num9 = (float)Math.Abs(i - num7); + float num10 = (float)Math.Abs(j - num8); + float num11 = (float)Math.Sqrt((double)(num9 * num9 + num10 * num10)); + if ((double)num11 < (double)num * 0.8 + (double)rand.Next(-3, 4)) + { + if (Main.tile[num7, num8] != null) + Main.tile[num7, num8].active(false); + } + } + } + } + num = WorldGen.genRand.Next(25, 35); + for (int num12 = i - num; num12 < i + num; num12++) + { + for (int num13 = j - num; num13 < j + num; num13++) + { + float num14 = (float)Math.Abs(i - num12); + float num15 = (float)Math.Abs(j - num13); + float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); + if (Main.tile[num12, num13] != null) + { + if ((double)num16 < (double)num * 0.7) + { + if (Main.tile[num12, num13].type == 5 || Main.tile[num12, num13].type == 32 || Main.tile[num12, num13].type == 352) + { + try + { WorldGen.KillTile(num12, num13, false, false, true); } + catch (NullReferenceException) + { } + } + Main.tile[num12, num13].liquid = 0; + } + if (Main.tile[num12, num13].type == (ushort)ModContent.TileType()) + { + if (!WorldGen.SolidTile(num12 - 1, num13) && !WorldGen.SolidTile(num12 + 1, num13) && !WorldGen.SolidTile(num12, num13 - 1) && !WorldGen.SolidTile(num12, num13 + 1)) + { + Main.tile[num12, num13].active(false); + } + else if ((Main.tile[num12, num13].halfBrick() || Main.tile[num12 - 1, num13].topSlope()) && !WorldGen.SolidTile(num12, num13 + 1)) + { + Main.tile[num12, num13].active(false); + } + } + WorldGen.SquareTileFrame(num12, num13, true); + WorldGen.SquareWallFrame(num12, num13, true); + } + } + } + num = WorldGen.genRand.Next(23, 32); + for (int num17 = i - num; num17 < i + num; num17++) + { + for (int num18 = j - num; num18 < j + num; num18++) + { + if (num18 > j + WorldGen.genRand.Next(-3, 4) - 3 && Main.tile[num17, num18].active() && rand.NextBool(10)) + { + float num19 = (float)Math.Abs(i - num17); + float num20 = (float)Math.Abs(j - num18); + float num21 = (float)Math.Sqrt((double)(num19 * num19 + num20 * num20)); + if ((double)num21 < (double)num * 0.8) + { + if (Main.tile[num17, num18] != null) + { + if (Main.tile[num17, num18].type == 5 || Main.tile[num17, num18].type == 32 || Main.tile[num17, num18].type == 352) + { + WorldGen.KillTile(num17, num18, false, false, false); + } + Main.tile[num17, num18].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(num17, num18, true); + } + } + } + } + } + num = WorldGen.genRand.Next(30, 38); + for (int num22 = i - num; num22 < i + num; num22++) + { + for (int num23 = j - num; num23 < j + num; num23++) + { + if (num23 > j + WorldGen.genRand.Next(-2, 3) && Main.tile[num22, num23].active() && rand.NextBool(20)) + { + float num24 = (float)Math.Abs(i - num22); + float num25 = (float)Math.Abs(j - num23); + float num26 = (float)Math.Sqrt((double)(num24 * num24 + num25 * num25)); + if ((double)num26 < (double)num * 0.85) + { + if (Main.tile[num22, num23] != null) + { + if (Main.tile[num22, num23].type == 5 || Main.tile[num22, num23].type == 32 || Main.tile[num22, num23].type == 352) + { + WorldGen.KillTile(num22, num23, false, false, false); + } + Main.tile[num22, num23].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(num22, num23, true); + } + } + } + } + } + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NetMessage.SendTileSquare(-1, i, j, 40, TileChangeType.None); + if (CanAstralBiomeSpawn()) + { + DoAstralConversion(new Point(i, j)); + + // Upward checks go up 180 tiles. If for whatever reason the placement Y position + // would cause this upward movement to go outside of the world, clamp it to prevent index problems. + if (j < 181) + j = 181; + + int checkWidth = 180; + float averageHeight = 0f; + float lowestHeight = 0f; + + int xAreaToSpawn = i; + + Dictionary xAreaHeightMap = new Dictionary(); + + // Gauge the bumpiness of various potential locations. + // The least bumpy one will be selected as the place to spawn the monolith. + for (int tries = 0; tries < 30; tries++) + { + int x = i + Main.rand.Next(-60, 61); + + // Don't attempt to add duplicate keys. + if (xAreaHeightMap.ContainsKey(x)) + continue; + + float averageRelativeHeight = 0f; + for (int dx = -30; dx <= 30; dx++) + { + WorldUtils.Find(new Point(x + dx, j - 180), Searches.Chain(new Searches.Down(360), new Conditions.IsSolid()), out Point result); + averageRelativeHeight += Math.Abs(result.Y - j); + } + averageRelativeHeight /= 60f; + xAreaHeightMap.Add(x, averageRelativeHeight); + } + + i = xAreaHeightMap.OrderBy(x => x.Value).First().Key; + + for (int x = i - checkWidth / 2; x < i + checkWidth / 2; x++) + { + int y = j - 200; + Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); + while (!Main.tileSolid[tileAtPosition.type] || + !tileAtPosition.active() || + TileID.Sets.Platforms[tileAtPosition.type]) + { + y++; + if (y > j - 10) + break; + tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); + } + lowestHeight = (int)MathHelper.Max(lowestHeight, y); + averageHeight += y; + } + lowestHeight -= 35f; + averageHeight /= checkWidth; + float height = lowestHeight; + + // If there's a sudden change between the average and lowest height (which is indicative of holes/chasms), go with the average. + if (Math.Abs(lowestHeight - averageHeight) > 50f) + height = averageHeight; + + // WorldGen.gen prevents NewItem from working, and thus prevents a bunch of dumb items from being spawned immediately and deleting the WoF/Aureus loot in the process. + WorldGen.gen = true; + // Add the average height of a tree to the Y position to offset trees usually messing with the calculation. + // Then also add 10 blocks because these things seem to always like to appear standing on the floor. + int finalVerticalOffset = 18; + bool _ = true; + SchematicManager.PlaceSchematic>("Astral Beacon", new Point(i, (int)height + finalVerticalOffset), SchematicAnchor.Center, ref _); + WorldGen.gen = false; + } + } + return true; + } + + public static void DoAstralConversion(object obj) + { + //Pre-calculate all variables necessary for elliptical area checking + Point origin = (Point)obj; + Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); + + float angle = MathHelper.Pi * 0.15f; + float otherAngle = MathHelper.PiOver2 - angle; + + int distanceInTiles = 150 + (Main.maxTilesX - 4200) / 4200 * 200; + float distance = distanceInTiles * 16f; + float constant = distance * 2f / (float)Math.Sin(angle); + + float fociSpacing = distance * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); + int verticalRadius = (int)(constant / 16f); + + Vector2 fociOffset = Vector2.UnitY * fociSpacing; + Vector2 topFoci = center - fociOffset; + Vector2 bottomFoci = center + fociOffset; + + UnifiedRandom rand = WorldGen.genRand; + for (int x = origin.X - distanceInTiles - 2; x <= origin.X + distanceInTiles + 2; x++) + { + for (int y = (int)(origin.Y - verticalRadius * 0.4f) - 3; y <= origin.Y + verticalRadius + 3; y++) + { + if (CheckInEllipse(new Point(x, y), topFoci, bottomFoci, constant, center, out float dist, y < origin.Y)) + { + //If we're in the outer blurPercent% of the ellipse + float percent = dist / constant; + float blurPercent = 0.98f; + if (percent > blurPercent) + { + float outerEdgePercent = (percent - blurPercent) / (1f - blurPercent); + if (rand.NextFloat(1f) > outerEdgePercent) + { + ConvertToAstral(x, y); + } + } + else + { + ConvertToAstral(x, y); + } + } + } + } + } + + public static void ConvertToAstral(int startX, int endX, int startY, int endY) + { + for (int x = startX; x <= endX; x++) + { + for (int y = startY; y <= endY; y++) + { + ConvertToAstral(x, y); + } + } + } + + public static void ConvertToAstral(int x, int y) + { + if (WorldGen.InWorld(x, y, 1)) + { + int type = Main.tile[x, y].type; + int wallType = Main.tile[x, y].wall; + + if (Main.tile[x, y] != null) + { + if (WallID.Sets.Conversion.Grass[wallType]) + { + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (WallID.Sets.Conversion.HardenedSand[wallType]) + { + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (WallID.Sets.Conversion.Sandstone[wallType]) + { + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (WallID.Sets.Conversion.Stone[wallType]) + { + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else + { + switch (wallType) + { + case WallID.DirtUnsafe: + case WallID.DirtUnsafe1: + case WallID.DirtUnsafe2: + case WallID.DirtUnsafe3: + case WallID.DirtUnsafe4: + case WallID.Cave6Unsafe: + case WallID.Dirt: + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.SnowWallUnsafe: + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.DesertFossil: + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.IceUnsafe: + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.LivingWood: + Main.tile[x, y].wall = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + } + } + if (TileID.Sets.Conversion.Grass[type] && !TileID.Sets.GrassSpecial[type]) + { + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Stone[type] || Main.tileMoss[type]) + { + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Sand[type]) + { + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.HardenedSand[type]) + { + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Sandstone[type]) + { + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Ice[type]) + { + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else + { + Tile tile = Main.tile[x, y]; + switch (type) + { + case TileID.Dirt: + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.SnowBlock: + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.Silt: + case TileID.Slush: + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.DesertFossil: + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.ClayBlock: + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.Vines: + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.LivingWood: + Main.tile[x, y].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.LeafBlock: + case TileID.Sunflower: + WorldGen.KillTile(x, y); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, x, y); + } + break; + case TileID.LargePiles: + if (tile.frameX <= 1170) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 0, 1170, 0, 18); + } + if (tile.frameX >= 1728) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1728, 1872, 0, 18); + } + if (tile.frameX >= 1404 && tile.frameX <= 1710) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1404, 1710, 0, 18); + } + break; + case TileID.LargePiles2: + if (tile.frameX >= 1566 && tile.frameY < 36) + { + RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 1566, 1872, 0, 18); + } + if (tile.frameX >= 756 && tile.frameX <= 900) + { + RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 756, 900, 0, 18); + } + break; + case TileID.SmallPiles: + if (tile.frameY == 18) + { + ushort newType; + if (tile.frameX >= 1476 && tile.frameX <= 1674) + { + newType = (ushort)ModContent.TileType(); + } + else if (tile.frameX <= 558 || (tile.frameX >= 1368 && tile.frameX <= 1458)) + { + newType = (ushort)ModContent.TileType(); + } + else if (tile.frameX >= 900 && tile.frameX <= 1098) + { + newType = (ushort)ModContent.TileType(); + } + else + { + break; + } + int leftMost = x; + if (tile.frameX % 36 != 0) //this means it's the right tile of the two + { + leftMost--; + } + if (Main.tile[leftMost, y] != null) + { + Main.tile[leftMost, y].type = newType; + WorldGen.SquareTileFrame(leftMost, y, true); + NetMessage.SendTileSquare(-1, leftMost, y, 1); + } + if (Main.tile[leftMost + 1, y] != null) + { + Main.tile[leftMost + 1, y].type = newType; + WorldGen.SquareTileFrame(leftMost + 1, y, true); + NetMessage.SendTileSquare(-1, leftMost + 1, y, 1); + } + while (Main.tile[leftMost, y].frameX >= 216) + { + if (Main.tile[leftMost, y] != null) + Main.tile[leftMost, y].frameX -= 216; + if (Main.tile[leftMost + 1, y] != null) + Main.tile[leftMost + 1, y].frameX -= 216; + } + } + else if (tile.frameY == 0) + { + ushort newType3; + if (tile.frameX >= 972 && tile.frameX <= 1062) + { + newType3 = (ushort)ModContent.TileType(); + } + else if (tile.frameX <= 486) + { + newType3 = (ushort)ModContent.TileType(); + } + else if (tile.frameX >= 648 && tile.frameX <= 846) + { + newType3 = (ushort)ModContent.TileType(); + } + else + { + break; + } + Main.tile[x, y].type = newType3; + while (Main.tile[x, y].frameX >= 108) //REFRAME IT + { + Main.tile[x, y].frameX -= 108; + } + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + break; + case TileID.Stalactite: + int topMost = tile.frameY <= 54 ? (tile.frameY % 36 == 0 ? y : y - 1) : y; + bool twoTall = tile.frameY <= 54; + bool hanging = tile.frameY <= 18 || tile.frameY == 72; + ushort newType2; + if (tile.frameX >= 378 && tile.frameX <= 414) //DESERT + { + newType2 = (ushort)ModContent.TileType(); + } + else if ((tile.frameX >= 54 && tile.frameX <= 90) || (tile.frameX >= 216 && tile.frameX <= 360)) + { + newType2 = (ushort)ModContent.TileType(); + } + else if (tile.frameX <= 36) + { + newType2 = (ushort)ModContent.TileType(); + } + else + { + break; + } + + //Set types + if (Main.tile[x, topMost] != null) + { + Main.tile[x, topMost].type = newType2; + } + if (twoTall) + { + if (Main.tile[x, topMost + 1] != null) + Main.tile[x, topMost + 1].type = newType2; + } + + //Fix frames + while (Main.tile[x, topMost].frameX >= 54) + { + if (Main.tile[x, topMost] != null) + Main.tile[x, topMost].frameX -= 54; + if (twoTall) + { + if (Main.tile[x, topMost + 1] != null) + Main.tile[x, topMost + 1].frameX -= 54; + } + } + + if (Main.tile[x, topMost] != null) + { + WorldGen.SquareTileFrame(x, topMost, true); + NetMessage.SendTileSquare(-1, x, topMost, 1); + } + + if (Main.tile[x, topMost + 1] != null) + { + WorldGen.SquareTileFrame(x, topMost + 1, true); + NetMessage.SendTileSquare(-1, x, topMost + 1, 1); + } + + if (hanging) + { + ConvertToAstral(x, topMost - 1); + break; + } + else + { + if (twoTall) + { + ConvertToAstral(x, topMost + 2); + break; + } + ConvertToAstral(x, topMost + 1); + break; + } + } + } + } + } + } + + public static void ConvertFromAstral(int x, int y, ConvertType convert, bool tileframe = true) + { + Tile tile = Main.tile[x, y]; + int type = tile.type; + int wallType = tile.wall; + + if (WorldGen.InWorld(x, y, 1)) + { + #region WALL + if (Main.tile[x, y] != null) + { + if (wallType == ModContent.WallType()) + { + Main.tile[x, y].wall = WallID.DirtUnsafe; + } + else if (wallType == ModContent.WallType() || wallType == ModContent.WallType()) + { + Main.tile[x, y].wall = WallID.SnowWallUnsafe; + } + else if (wallType == ModContent.WallType()) + { + Main.tile[x, y].wall = WallID.DesertFossil; + } + else if (wallType == ModContent.WallType()) + { + switch (convert) + { + case ConvertType.Corrupt: + Main.tile[x, y].wall = WallID.CorruptGrassUnsafe; + break; + case ConvertType.Crimson: + Main.tile[x, y].wall = WallID.CrimsonGrassUnsafe; + break; + case ConvertType.Hallow: + Main.tile[x, y].wall = WallID.HallowedGrassUnsafe; + break; + case ConvertType.Pure: + Main.tile[x, y].wall = WallID.GrassUnsafe; + break; + } + } + else if (wallType == ModContent.WallType()) + { + Main.tile[x, y].wall = WallID.IceUnsafe; + } + else if (wallType == ModContent.WallType()) + { + Main.tile[x, y].wall = WallID.LivingWood; + } + else if (wallType == ModContent.WallType()) + { + switch (convert) + { + case ConvertType.Corrupt: + Main.tile[x, y].wall = WallID.EbonstoneUnsafe; + break; + case ConvertType.Crimson: + Main.tile[x, y].wall = WallID.CrimstoneUnsafe; + break; + case ConvertType.Hallow: + Main.tile[x, y].wall = WallID.PearlstoneBrickUnsafe; + break; + case ConvertType.Pure: + Main.tile[x, y].wall = WallID.Stone; + break; + } + } + } + #endregion + + #region TILE + if (Main.tile[x, y] != null) + { + if (type == ModContent.TileType()) + { + tile.type = TileID.Dirt; + } + else if (type == ModContent.TileType()) + { + tile.type = TileID.SnowBlock; + } + else if (type == ModContent.TileType()) + { + tile.type = TileID.Silt; + } + else if (type == ModContent.TileType()) + { + tile.type = TileID.DesertFossil; + } + else if (type == ModContent.TileType()) + { + tile.type = TileID.ClayBlock; + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, TileID.CorruptGrass, TileID.FleshGrass, TileID.HallowedGrass, TileID.Grass); + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, TileID.Ebonstone, TileID.Crimstone, TileID.Pearlstone, TileID.Stone); + } + else if (type == ModContent.TileType()) + { + tile.type = TileID.LivingWood; + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, TileID.Ebonsand, TileID.Crimsand, TileID.Pearlsand, TileID.Sand); + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, TileID.CorruptSandstone, TileID.CrimsonSandstone, TileID.HallowSandstone, TileID.Sandstone); + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, TileID.CorruptHardenedSand, TileID.CrimsonHardenedSand, TileID.HallowHardenedSand, TileID.HardenedSand); + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, TileID.CorruptIce, TileID.FleshIce, TileID.HallowedIce, TileID.IceBlock); + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, ushort.MaxValue, TileID.CrimsonVines, TileID.HallowedVines, TileID.Vines); + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, TileID.CorruptPlants, ushort.MaxValue, TileID.HallowedPlants, TileID.Plants); + } + else if (type == ModContent.TileType()) + { + SetTileFromConvert(x, y, convert, ushort.MaxValue, ushort.MaxValue, TileID.HallowedPlants2, TileID.Plants2); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 378, 0); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 18); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 0); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles2, x, y, 1566, 0); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 1476, 18); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 972, 0); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 1404, 0); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 900, 18); + } + else if (type == ModContent.TileType()) + { + RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 648, 0); + } + else if (type == ModContent.TileType()) + { + ushort originType = TileID.Stone; + switch (convert) + { + case ConvertType.Corrupt: + originType = TileID.Ebonstone; + break; + case ConvertType.Crimson: + originType = TileID.Crimstone; + break; + case ConvertType.Hallow: + originType = TileID.Pearlstone; + break; + } + ReplaceAstralStalactite(TileID.Stalactite, originType, x, y); + } + else if (type == ModContent.TileType()) + { + ushort originType = TileID.Sandstone; + switch (convert) + { + case ConvertType.Corrupt: + originType = TileID.CorruptSandstone; + break; + case ConvertType.Crimson: + originType = TileID.CrimsonSandstone; + break; + case ConvertType.Hallow: + originType = TileID.HallowSandstone; + break; + } + ReplaceAstralStalactite(TileID.Stalactite, originType, x, y); + } + else if (type == ModContent.TileType()) + { + ReplaceAstralStalactite(TileID.Stalactite, TileID.IceBlock, x, y); + } + if (TileID.Sets.Conversion.Grass[type] || type == TileID.Dirt) + { + WorldGen.SquareTileFrame(x, y); + } + } + #endregion + + if (tileframe) + { + if (Main.netMode == NetmodeID.SinglePlayer) + { + WorldGen.SquareTileFrame(x, y, true); + } + else if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, x, y, 1); + } + } + } + } + + public static void SetTileFromConvert(int x, int y, ConvertType convert, ushort corrupt, ushort crimson, ushort hallow, ushort pure) + { + switch (convert) + { + case ConvertType.Corrupt: + if (corrupt != ushort.MaxValue) + { + Main.tile[x, y].type = corrupt; + WorldGen.SquareTileFrame(x, y); + } + break; + case ConvertType.Crimson: + if (crimson != ushort.MaxValue) + { + Main.tile[x, y].type = crimson; + WorldGen.SquareTileFrame(x, y); + } + break; + case ConvertType.Hallow: + if (hallow != ushort.MaxValue) + { + Main.tile[x, y].type = hallow; + WorldGen.SquareTileFrame(x, y); + } + break; + case ConvertType.Pure: + if (pure != ushort.MaxValue) + { + Main.tile[x, y].type = pure; + WorldGen.SquareTileFrame(x, y); + } + break; + } + } + + public static void RecursiveReplaceToAstral(ushort checkType, ushort replaceType, int x, int y, int replaceTextureWidth, int minFrameX = 0, int maxFrameX = int.MaxValue, int minFrameY = 0, int maxFrameY = int.MaxValue) + { + Tile tile = Main.tile[x, y]; + if (tile == null || !tile.active() || tile.type != checkType || tile.frameX < minFrameX || tile.frameX > maxFrameX || tile.frameY < minFrameY || tile.frameY > maxFrameY) + return; + + Main.tile[x, y].type = replaceType; + while (Main.tile[x, y].frameX >= replaceTextureWidth) + { + Main.tile[x, y].frameX -= (short)replaceTextureWidth; + } + + if (Main.tile[x - 1, y] != null) + RecursiveReplaceToAstral(checkType, replaceType, x - 1, y, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + if (Main.tile[x + 1, y] != null) + RecursiveReplaceToAstral(checkType, replaceType, x + 1, y, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + if (Main.tile[x, y - 1] != null) + RecursiveReplaceToAstral(checkType, replaceType, x, y - 1, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + if (Main.tile[x, y + 1] != null) + RecursiveReplaceToAstral(checkType, replaceType, x, y + 1, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); + } + + public static void RecursiveReplaceFromAstral(ushort checkType, ushort replaceType, int x, int y, int addFrameX, int addFrameY) + { + Tile tile = Main.tile[x, y]; + if (tile == null || !tile.active() || tile.type != checkType) + return; + + Main.tile[x, y].type = replaceType; + Main.tile[x, y].frameX += (short)addFrameX; + Main.tile[x, y].frameY += (short)addFrameY; + + if (Main.tile[x - 1, y] != null) + RecursiveReplaceFromAstral(checkType, replaceType, x - 1, y, addFrameX, addFrameY); + if (Main.tile[x + 1, y] != null) + RecursiveReplaceFromAstral(checkType, replaceType, x + 1, y, addFrameX, addFrameY); + if (Main.tile[x, y - 1] != null) + RecursiveReplaceFromAstral(checkType, replaceType, x, y - 1, addFrameX, addFrameY); + if (Main.tile[x, y + 1] != null) + RecursiveReplaceFromAstral(checkType, replaceType, x, y + 1, addFrameX, addFrameY); + } + + public static void ReplaceAstralStalactite(ushort replaceType, ushort replaceOriginTile, int x, int y) + { + Tile tile = Main.tile[x, y]; + + int topMost = tile.frameY <= 54 ? (tile.frameY % 36 == 0 ? y : y - 1) : y; + bool twoTall = tile.frameY <= 54; + bool hanging = tile.frameY <= 18 || tile.frameY == 72; + + int yOriginTile = hanging ? topMost - 1 : (twoTall ? topMost + 2 : y + 1); + + if (Main.tile[x, topMost++] != null) + Main.tile[x, topMost++].type = replaceType; + if (twoTall) + { + if (Main.tile[x, topMost] != null) + Main.tile[x, topMost].type = replaceType; + } + if (Main.tile[x, yOriginTile] != null) + Main.tile[x, yOriginTile].type = replaceOriginTile; + } + + public static bool CheckInEllipse(Point tile, Vector2 focus1, Vector2 focus2, float distanceConstant, Vector2 center, out float distance, bool collapse = false) + { + Vector2 point = tile.ToWorldCoordinates(); + if (collapse) //Collapse ensures the ellipse is shrunk down a lot in terms of distance. + { + float distY = center.Y - point.Y; + point.Y -= distY * 8f; + } + float distance1 = Vector2.Distance(point, focus1); + float distance2 = Vector2.Distance(point, focus2); + distance = distance1 + distance2; + return distance <= distanceConstant; + } + } +} diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 3fe5c8dd69..6556205af6 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -28,6 +28,7 @@ using CalamityMod.Tiles.AstralSnow; using CalamityMod.Tiles.Crags; using CalamityMod.Tiles.Ores; using CalamityMod.Tiles.SunkenSea; +using CalamityMod.World.Planets; using Microsoft.Xna.Framework; using System; using System.Collections.Generic; @@ -983,20 +984,20 @@ namespace CalamityMod.World #region ModifyWorldGenTasks public override void ModifyWorldGenTasks(List tasks, ref float totalWeight) { - int ShiniesIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Shinies")); - if (ShiniesIndex != -1) + int islandIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Island Houses")); + if (islandIndex != -1) { - tasks.Insert(ShiniesIndex + 2, new PassLegacy("EvilIsland", delegate (GenerationProgress progress) + tasks.Insert(islandIndex + 2, new PassLegacy("EvilIsland", delegate (GenerationProgress progress) { progress.Message = "Evil Island"; - SmallBiomes.PlaceEvilIsland(); + WorldEvilIsland.PlaceEvilIsland(); })); } int DungeonChestIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Dungeon")); if (DungeonChestIndex != -1) { - tasks.Insert(DungeonChestIndex + 1, new PassLegacy("Calamity Mod: Biome Chests", WorldGenerationMethods.GenerateBiomeChests)); + tasks.Insert(DungeonChestIndex + 1, new PassLegacy("Calamity Mod: Biome Chests", MiscWorldgenRoutines.GenerateBiomeChests)); } int WaterFromSandIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Remove Water From Sand")); @@ -1050,27 +1051,27 @@ namespace CalamityMod.World fuhX = xUnderworldGen; fuhY = yUnderworldGen; - WorldGenerationMethods.UnderworldIsland(xUnderworldGen, yUnderworldGen, 180, 201, 120, 136); - WorldGenerationMethods.UnderworldIsland(xUnderworldGen - 50, yUnderworldGen - 30, 100, 111, 60, 71); - WorldGenerationMethods.UnderworldIsland(xUnderworldGen + 50, yUnderworldGen - 30, 100, 111, 60, 71); + MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen, yUnderworldGen, 180, 201, 120, 136); + MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 50, yUnderworldGen - 30, 100, 111, 60, 71); + MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 50, yUnderworldGen - 30, 100, 111, 60, 71); - WorldGenerationMethods.ChasmGenerator(fuhX - 110, fuhY - 10, WorldGen.genRand.Next(150) + 150); - WorldGenerationMethods.ChasmGenerator(fuhX + 110, fuhY - 10, WorldGen.genRand.Next(150) + 150); + MiscWorldgenRoutines.ChasmGenerator(fuhX - 110, fuhY - 10, WorldGen.genRand.Next(150) + 150); + MiscWorldgenRoutines.ChasmGenerator(fuhX + 110, fuhY - 10, WorldGen.genRand.Next(150) + 150); - WorldGenerationMethods.UnderworldIsland(xUnderworldGen - 150, yUnderworldGen - 30, 60, 66, 35, 41); - WorldGenerationMethods.UnderworldIsland(xUnderworldGen + 150, yUnderworldGen - 30, 60, 66, 35, 41); - WorldGenerationMethods.UnderworldIsland(xUnderworldGen - 180, yUnderworldGen - 20, 60, 66, 35, 41); - WorldGenerationMethods.UnderworldIsland(xUnderworldGen + 180, yUnderworldGen - 20, 60, 66, 35, 41); + MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 150, yUnderworldGen - 30, 60, 66, 35, 41); + MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 150, yUnderworldGen - 30, 60, 66, 35, 41); + MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen - 180, yUnderworldGen - 20, 60, 66, 35, 41); + MiscWorldgenRoutines.UnderworldIsland(xUnderworldGen + 180, yUnderworldGen - 20, 60, 66, 35, 41); - WorldGenerationMethods.UnderworldIslandHouse(fuhX, fuhY + 30, 1323); - WorldGenerationMethods.UnderworldIslandHouse(fuhX - 22, fuhY + 15, 1322); - WorldGenerationMethods.UnderworldIslandHouse(fuhX + 22, fuhY + 15, 535); - WorldGenerationMethods.UnderworldIslandHouse(fuhX - 50, fuhY - 30, 112); - WorldGenerationMethods.UnderworldIslandHouse(fuhX + 50, fuhY - 30, 906); - WorldGenerationMethods.UnderworldIslandHouse(fuhX - 150, fuhY - 30, 218); - WorldGenerationMethods.UnderworldIslandHouse(fuhX + 150, fuhY - 30, 3019); - WorldGenerationMethods.UnderworldIslandHouse(fuhX - 180, fuhY - 20, 274); - WorldGenerationMethods.UnderworldIslandHouse(fuhX + 180, fuhY - 20, 220); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX, fuhY + 30, 1323); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 22, fuhY + 15, 1322); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 22, fuhY + 15, 535); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 50, fuhY - 30, 112); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 50, fuhY - 30, 906); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 150, fuhY - 30, 218); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 150, fuhY - 30, 3019); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX - 180, fuhY - 20, 274); + MiscWorldgenRoutines.UnderworldIslandHouse(fuhX + 180, fuhY - 20, 220); })); #endregion @@ -1087,7 +1088,7 @@ namespace CalamityMod.World tasks.Insert(FinalIndex + 2, new PassLegacy("SpecialShrines", delegate (GenerationProgress progress) { progress.Message = "Special Shrines"; - SmallBiomes.PlaceShrines(); + UndergroundShrines.PlaceShrines(); })); @@ -1136,11 +1137,11 @@ namespace CalamityMod.World tasks.Insert(FinalIndex + 6, new PassLegacy("IWannaRock", delegate (GenerationProgress progress) { progress.Message = "I Wanna Rock"; - WorldGenerationMethods.PlaceRoxShrine(); + MiscWorldgenRoutines.PlaceRoxShrine(); })); } - tasks.Add(new PassLegacy("Planetoid Test", WorldGenerationMethods.Planetoids)); + tasks.Add(new PassLegacy("Planetoid Test", Planetoid.GenerateAllBasePlanetoids)); } // An Astral Meteor always falls at the beginning of Hardmode. @@ -1152,917 +1153,13 @@ namespace CalamityMod.World // Insert the Astral biome generation right before the final hardmode announcement. tasks.Insert(announceIndex, new PassLegacy("AstralMeteor", delegate (GenerationProgress progress) { - WorldGenerationMethods.PlaceAstralMeteor(); + AstralBiome.PlaceAstralMeteor(); })); } #endregion #region PostUpdate - public override void PostUpdate() - { - // Sunken Sea Location...duh - SunkenSeaLocation = new Rectangle(WorldGen.UndergroundDesertLocation.Left, WorldGen.UndergroundDesertLocation.Bottom, - WorldGen.UndergroundDesertLocation.Width, WorldGen.UndergroundDesertLocation.Height / 2); - - // Player variable, always finds the closest player relative to the center of the map - int closestPlayer = Player.FindClosest(new Vector2(Main.maxTilesX / 2, (float)Main.worldSurface / 2f) * 16f, 0, 0); - Player player = Main.player[closestPlayer]; - CalamityPlayer modPlayer = player.Calamity(); - - // Force boss rush to off - if (!BossRushEvent.DeactivateStupidFuckingBullshit) - { - BossRushEvent.DeactivateStupidFuckingBullshit = true; - BossRushEvent.BossRushActive = false; - CalamityNetcode.SyncWorld(); - } - - // Attempt to start the acid rain at the 4:29AM - bool moreRain = !downedEoCAcidRain || (!downedAquaticScourgeAcidRain && downedAquaticScourge) || (!downedBoomerDuke && downedPolterghast); - if (Main.time == 32399 && !Main.dayTime && Main.rand.NextBool(moreRain ? 3 : 300)) - { - bool noRain = false; - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) - { - if (!Main.player[playerIndex].active) - continue; - if (Main.player[playerIndex].Calamity().noStupidNaturalARSpawns) - { - noRain = true; - break; - } - } - if (!noRain) - { - AcidRainEvent.TryStartEvent(); - CalamityNetcode.SyncWorld(); - } - } - if (NPC.downedBoss1 && !downedEoCAcidRain && !forcedRainAlready) - { - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) - { - if (Main.player[playerIndex].active) - { - if (Main.player[playerIndex].Calamity().ZoneSulphur) - { - forcedRainAlready = true; - AcidRainEvent.TryStartEvent(); - CalamityNetcode.SyncWorld(); - } - } - } - } - if (forceRainTimer == 1) - { - AcidRainEvent.TryStartEvent(); - CalamityNetcode.SyncWorld(); - } - if (forceRainTimer > 0) - forceRainTimer--; - - if (rainingAcid) - { - timeSinceAcidRainKill++; - timeSinceAcidStarted++; - - // If enough time has passed, and no enemy has been killed, end the invasion early. - // The player almost certainly does not want to deal with it. - if (timeSinceAcidRainKill >= AcidRainEvent.InvasionNoKillPersistTime) - { - acidRainPoints = 0; - triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } - if (!startAcidicDownpour) - { - int sulphSeaWidth = SulphurousSea.BiomeWidth; - for (int playerIndex = 0; playerIndex < Main.maxPlayers; playerIndex++) - { - // A variable named "player" already exists above, which retrieves the player who is closest to the map center. - Player player2 = Main.player[playerIndex]; - if (player2.active) - { - // An artificial biome can be made, and therefore, the event could be started by an artificial biome. - // While fighting the event in an artificial biome is not bad, having it be started by a patch of Sulphurous Sand - // would definitely be strange. - // Because of this, this code is executed based on if the player is in the sea (based on tile count) AND position relative to the naturally generated sea. - if (((player2.Center.X <= (sulphSeaWidth + 60f) * 16f && abyssSide) || - (player2.Center.X >= (Main.maxTilesX - (sulphSeaWidth + 60f)) * 16f && !abyssSide)) && - player2.Calamity().ZoneSulphur) - { - // Makes rain pour at its maximum intensity (but only after an idiot meanders into the Sulphurous Sea) - // You'll never catch me, Fabs, Not when I shift into MAXIMUM OVERDRIVE!! - startAcidicDownpour = true; - CalamityNetcode.SyncWorld(); - break; - } - } - } - } - - // Stop the rain if the Old Duke is present for visibility during the fight. - if (Main.raining && NPC.AnyNPCs(ModContent.NPCType())) - { - Main.raining = false; - CalamityNetcode.SyncWorld(); - } - - // If the rain stops for whatever reason, end the invasion. - // This is primarily done for compatibility, so that if another mod wants to manipulate the weather, - // they can without having to deal with endless rain. - if (!Main.raining && !NPC.AnyNPCs(ModContent.NPCType()) && timeSinceAcidStarted > 20) - { - acidRainPoints = 0; - triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } - else if (timeSinceAcidStarted < 20) - { - Main.raining = true; - Main.cloudBGActive = 1f; - Main.numCloudsTemp = Main.cloudLimit; - Main.numClouds = Main.numCloudsTemp; - Main.windSpeedTemp = 0.72f; - Main.windSpeedSet = Main.windSpeedTemp; - Main.weatherCounter = 60 * 60 * 10; // 10 minutes of rain. Remember, once the rain goes away, so does the invasion. - Main.rainTime = Main.weatherCounter; - Main.maxRaining = 0.89f; - } - - // Summon Old Duke tornado post-Polter as needed - if (downedPolterghast && acidRainPoints == 1) - { - if (!NPC.AnyNPCs(ModContent.NPCType()) && - CalamityUtils.CountProjectiles(ModContent.ProjectileType()) <= 0) - { - if (triedToSummonOldDuke) - { - acidRainPoints = 0; - triedToSummonOldDuke = false; - AcidRainEvent.UpdateInvasion(false); - } - else - { - int playerClosestToAbyss = Player.FindClosest(new Vector2(abyssSide ? 0 : Main.maxTilesX * 16, (int)Main.worldSurface), 0, 0); - Player closestToAbyss = Main.player[playerClosestToAbyss]; - if (Main.netMode != NetmodeID.MultiplayerClient && Math.Abs(closestToAbyss.Center.X - (abyssSide ? 0 : Main.maxTilesX * 16)) <= 12000f) - { - Projectile.NewProjectile(closestToAbyss.Center + Vector2.UnitY * 160f, Vector2.Zero, - ModContent.ProjectileType(), 120, 8f, Main.myPlayer); - } - } - } - } - } - else - { - if (timeSinceAcidStarted != 0) - timeSinceAcidStarted = 0; - startAcidicDownpour = false; - } - - // Lumenyl crystal, tenebris spread and sea prism crystal spawn rates - int l = 0; - float mult2 = 1.5E-05f * Main.worldRate; - while (l < Main.maxTilesX * Main.maxTilesY * mult2) - { - int x = WorldGen.genRand.Next(10, Main.maxTilesX - 10); - int y = WorldGen.genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20); - - int y2 = y - 1; - if (y2 < 10) - y2 = 10; - - if (Main.tile[x, y] != null) - { - if (Main.tile[x, y].nactive()) - { - if (Main.tile[x, y].liquid <= 32) - { - if (Main.tile[x, y].type == TileID.JungleGrass) - { - if (Main.tile[x, y2].liquid == 0) - { - // Plantera Bulbs pre-mech - if (WorldGen.genRand.Next(1500) == 0) - { - if (Main.hardMode && (!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3)) - { - bool placeBulb = true; - int minDistanceFromOtherBulbs = 150; - for (int i = x - minDistanceFromOtherBulbs; i < x + minDistanceFromOtherBulbs; i += 2) - { - for (int j = y - minDistanceFromOtherBulbs; j < y + minDistanceFromOtherBulbs; j += 2) - { - if (i > 1 && i < Main.maxTilesX - 2 && j > 1 && j < Main.maxTilesY - 2 && Main.tile[i, j].active() && Main.tile[i, j].type == TileID.PlanteraBulb) - { - placeBulb = false; - break; - } - } - } - - if (placeBulb) - { - WorldGen.PlaceJunglePlant(x, y2, TileID.PlanteraBulb, 0, 0); - WorldGen.SquareTileFrame(x, y2); - WorldGen.SquareTileFrame(x + 2, y2); - WorldGen.SquareTileFrame(x - 1, y2); - if (Main.tile[x, y2].type == TileID.PlanteraBulb && Main.netMode == NetmodeID.Server) - { - NetMessage.SendTileSquare(-1, x, y2, 5); - } - } - } - } - - // Life Fruit pre-mech - int random = Main.expertMode ? 90 : 120; - if (WorldGen.genRand.Next(random) == 0) - { - if (Main.hardMode && !NPC.downedMechBossAny) - { - bool placeFruit = true; - int minDistanceFromOtherFruit = Main.expertMode ? 50 : 60; - for (int i = x - minDistanceFromOtherFruit; i < x + minDistanceFromOtherFruit; i += 2) - { - for (int j = y - minDistanceFromOtherFruit; j < y + minDistanceFromOtherFruit; j += 2) - { - if (i > 1 && i < Main.maxTilesX - 2 && j > 1 && j < Main.maxTilesY - 2 && Main.tile[i, j].active() && Main.tile[i, j].type == TileID.LifeFruit) - { - placeFruit = false; - break; - } - } - } - - if (placeFruit) - { - WorldGen.PlaceJunglePlant(x, y2, TileID.LifeFruit, WorldGen.genRand.Next(3), 0); - WorldGen.SquareTileFrame(x, y2); - WorldGen.SquareTileFrame(x + 1, y2 + 1); - if (Main.tile[x, y2].type == TileID.LifeFruit && Main.netMode == NetmodeID.Server) - { - NetMessage.SendTileSquare(-1, x, y2, 4); - } - } - } - } - } - } - } - - int tileType = Main.tile[x, y].type; - bool tenebris = tileType == ModContent.TileType() && downedCalamitas; - - if (CalamityGlobalTile.GrowthTiles.Contains(tileType) || tenebris) - { - int growthChance = tenebris ? 4 : 2; - if (tileType == ModContent.TileType()) - growthChance *= 5; - - if (Main.rand.NextBool(growthChance)) - { - switch (WorldGen.genRand.Next(4)) - { - case 0: - x++; - break; - case 1: - x--; - break; - case 2: - y++; - break; - case 3: - y--; - break; - default: - break; - } - - if (Main.tile[x, y] != null) - { - Tile tile = Main.tile[x, y]; - bool growTile = tenebris ? (tile.active() && tile.type == ModContent.TileType()) : (!tile.active() && tile.liquid >= 128); - bool isSunkenSeaTile = tileType == ModContent.TileType() || tileType == ModContent.TileType() || tileType == ModContent.TileType(); - bool meetsAdditionalGrowConditions = tile.slope() == 0 && !tile.halfBrick() && !tile.lava(); - - if (growTile && meetsAdditionalGrowConditions) - { - int tileType2 = ModContent.TileType(); - - if (tileType == ModContent.TileType()) - tileType2 = ModContent.TileType(); - - bool canPlaceBasedOnAttached = true; - if (tileType2 == ModContent.TileType() && !isSunkenSeaTile) - canPlaceBasedOnAttached = false; - - if (canPlaceBasedOnAttached && (CanPlaceBasedOnProximity(x, y, tileType2) || tenebris)) - { - tile.type = tenebris ? (ushort)tileType : (ushort)tileType2; - - if (!tenebris) - { - tile.active(true); - if (Main.tile[x, y + 1].active() && Main.tileSolid[Main.tile[x, y + 1].type] && Main.tile[x, y + 1].slope() == 0 && !Main.tile[x, y + 1].halfBrick()) - { - tile.frameY = 0; - } - else if (Main.tile[x, y - 1].active() && Main.tileSolid[Main.tile[x, y - 1].type] && Main.tile[x, y - 1].slope() == 0 && !Main.tile[x, y - 1].halfBrick()) - { - tile.frameY = 18; - } - else if (Main.tile[x + 1, y].active() && Main.tileSolid[Main.tile[x + 1, y].type] && Main.tile[x + 1, y].slope() == 0 && !Main.tile[x + 1, y].halfBrick()) - { - tile.frameY = 36; - } - else if (Main.tile[x - 1, y].active() && Main.tileSolid[Main.tile[x - 1, y].type] && Main.tile[x - 1, y].slope() == 0 && !Main.tile[x - 1, y].halfBrick()) - { - tile.frameY = 54; - } - tile.frameX = (short)(WorldGen.genRand.Next(18) * 18); - } - - WorldGen.SquareTileFrame(x, y); - - if (Main.netMode == NetmodeID.Server) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - } - } - } - } - } - } - l++; - } - - BossRushEvent.Update(); - - if (bossRushHostileProjKillCounter > 0) - { - bossRushHostileProjKillCounter--; - if (bossRushHostileProjKillCounter == 1) - CalamityUtils.KillAllHostileProjectiles(); - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.BRHostileProjKillSync); - netMessage.Write(bossRushHostileProjKillCounter); - netMessage.Send(); - } - } - - if (DoGSecondStageCountdown > 0) - { - DoGSecondStageCountdown--; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (DoGSecondStageCountdown == 21540) - CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); - if (DoGSecondStageCountdown == 14340) - CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); - if (DoGSecondStageCountdown == 7140) - CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); - - if (DoGSecondStageCountdown <= 60) - { - int freeNPCSlots = Main.maxNPCs - Main.npc.Take(Main.maxNPCs).Where(npc => npc.active).Count(); - - // If there are too many slots occupied, make a note in the logs, - // and don't attempt to spawn the Devourer of Gods. - if (freeNPCSlots < 102) - { - CalamityMod.Instance.Logger.Warn("You have too many occupied NPC slots for DoG to spawn. Remove dummies or kill excessive town NPCs."); - DoGSecondStageCountdown = 0; - } - else if (!NPC.AnyNPCs(ModContent.NPCType())) - { - NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); - string key = "Mods.CalamityMod.EdgyBossText10"; - Color messageColor = Color.Cyan; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - } - } - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); - netMessage.Write(DoGSecondStageCountdown); - netMessage.Send(); - } - } - - if (player.ZoneDungeon && !NPC.downedBoss3 && !player.dead) - { - if (!NPC.AnyNPCs(NPCID.DungeonGuardian) && Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(closestPlayer, NPCID.DungeonGuardian); //your hell is as vast as my bonergrin, pray your life ends quickly - } - - if (player.ZoneRockLayerHeight && - !player.ZoneUnderworldHeight && - !player.ZoneDungeon && - !player.ZoneJungle && - !modPlayer.ZoneSunkenSea && - !CalamityPlayer.areThereAnyDamnBosses) - { - if (NPC.downedPlantBoss && - !modPlayer.ZoneAbyss && - player.townNPCs < 3f) - { - double spawnRate = 100000D; - - if (revenge) - spawnRate *= 0.85D; - - if (demonMode) - spawnRate *= 0.75D; - - if (death && Main.bloodMoon) - spawnRate *= 0.2D; - if (modPlayer.zerg) - spawnRate *= 0.5D; - if (modPlayer.chaosCandle) - spawnRate *= 0.6D; - if (player.enemySpawns) - spawnRate *= 0.7D; - if (Main.waterCandles > 0) - spawnRate *= 0.8D; - - if (modPlayer.bossZen || DoGSecondStageCountdown > 0) - spawnRate *= 50D; - if (modPlayer.zen || (CalamityConfig.Instance.DisableExpertTownSpawns && player.townNPCs > 1f && Main.expertMode)) - spawnRate *= 2D; - if (modPlayer.tranquilityCandle) - spawnRate *= 1.67D; - if (player.calmed) - spawnRate *= 1.43D; - if (Main.peaceCandles > 0) - spawnRate *= 1.25D; - - int chance = (int)spawnRate; - if (Main.rand.Next(chance) == 0) - { - if (!NPC.AnyNPCs(ModContent.NPCType()) && Main.netMode != NetmodeID.MultiplayerClient && - ArmoredDiggerSpawnCooldown <= 0) - { - NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); - ArmoredDiggerSpawnCooldown = 3600; - } - } - } - } - if (ArmoredDiggerSpawnCooldown > 0) - { - ArmoredDiggerSpawnCooldown--; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.ArmoredDiggerCountdownSync); - netMessage.Write(ArmoredDiggerSpawnCooldown); - netMessage.Send(); - } - } - - if (modPlayer.ZoneAbyss) - { - if (player.chaosState && !player.dead) - { - bool adultWyrmAlive = false; - if (CalamityGlobalNPC.adultEidolonWyrmHead != -1) - { - if (Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active) - adultWyrmAlive = true; - } - - if (!adultWyrmAlive && Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); - } - } - - // DO NOT REMOVE -- this code is being kept for April Fools 2020 - if (Main.rand.NextBool(100000000) && DateTime.Now.Month == 4 && DateTime.Now.Day == 1) - { - string key = "Mods.CalamityMod.AprilFools"; - Color messageColor = Color.Crimson; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } - - if (death && !CalamityPlayer.areThereAnyDamnBosses && !Main.snowMoon && !Main.pumpkinMoon && !DD2Event.Ongoing && player.statLifeMax2 >= 300 && !WorldGen.spawnEye && WorldGen.spawnHardBoss <= 0) //does not occur while a boss is alive or during certain events - { - if (bossSpawnCountdown <= 0 && deathBossSpawnCooldown <= 0) // Check for countdown and cooldown being 0 - { - if (Main.rand.NextBool(50000)) - { - // Only set countdown and boss type if conditions are met - // Night time bosses set message only before 11pm. Day time bosses only before 2pm. - if (!NPC.downedBoss1 && bossType == 0) - if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) - { - BossText(); - bossType = NPCID.EyeofCthulhu; - bossSpawnCountdown = 3600; // 1 minute - } - - if (!NPC.downedBoss2 && bossType == 0) - if (player.ZoneCorrupt) - { - BossText(); - bossType = NPCID.EaterofWorldsHead; - bossSpawnCountdown = 3600; - } - - if (!NPC.downedBoss2 && bossType == 0) - if (player.ZoneCrimson) - { - BossText(); - bossType = NPCID.BrainofCthulhu; - bossSpawnCountdown = 3600; - } - - /*if (!NPC.downedQueenBee && bossType == 0) - if (player.ZoneJungle && !player.ZoneOverworldHeight && !player.ZoneSkyHeight) - { - BossText(); - bossType = NPCID.QueenBee; - bossSpawnCountdown = 3600; - }*/ - - if (!downedDesertScourge && bossType == 0) - if (player.ZoneDesert) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - if (!downedPerforator && bossType == 0) - if (player.ZoneCrimson) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - if (!downedHiveMind && bossType == 0) - if (player.ZoneCorrupt) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - if (!downedCrabulon && bossType == 0) - if (player.ZoneGlowshroom) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - if (Main.hardMode) - { - if (!NPC.downedMechBoss1 && bossType == 0) - if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) - { - BossText(); - bossType = NPCID.TheDestroyer; - bossSpawnCountdown = 3600; - } - - if (!NPC.downedMechBoss2 && bossType == 0) - if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) - { - BossText(); - bossType = NPCID.Spazmatism; - bossSpawnCountdown = 3600; - } - - if (!NPC.downedMechBoss3 && bossType == 0) - if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) - { - BossText(); - bossType = NPCID.SkeletronPrime; - bossSpawnCountdown = 3600; - } - - if (!NPC.downedPlantBoss && bossType == 0) - if (player.ZoneJungle && !player.ZoneOverworldHeight && !player.ZoneSkyHeight) - { - BossText(); - bossType = NPCID.Plantera; - bossSpawnCountdown = 3600; - } - - if (!NPC.downedFishron && bossType == 0) - if (player.ZoneBeach && !modPlayer.ZoneSulphur) - { - BossText(); - bossType = NPCID.DukeFishron; - bossSpawnCountdown = 3600; - } - - if (!downedCryogen && bossType == 0) - if (player.ZoneSnow && player.ZoneOverworldHeight) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - if (!downedCalamitas && bossType == 0) - if (!Main.dayTime && player.ZoneOverworldHeight && Main.time < 12600) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - if (!downedAstrageldon && bossType == 0) - if (modPlayer.ZoneAstral && - !Main.dayTime && player.ZoneOverworldHeight) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - /*if (!downedPlaguebringer && bossType == 0) - if (player.ZoneJungle && NPC.downedGolemBoss && !player.ZoneOverworldHeight && !player.ZoneSkyHeight) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - }*/ - - if (NPC.downedMoonlord) - { - if (!downedGuardians && bossType == 0) - if (Main.dayTime && (player.ZoneUnderworldHeight || - (player.ZoneHoly && player.ZoneOverworldHeight)) && Main.time < 34200) //only before 2pm - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - - if (!downedBumble && bossType == 0) - if (player.ZoneJungle && player.ZoneOverworldHeight) - { - BossText(); - bossType = ModContent.NPCType(); - bossSpawnCountdown = 3600; - } - } - } - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.BossSpawnCountdownSync); - netMessage.Write(bossSpawnCountdown); - netMessage.Send(); - var netMessage2 = mod.GetPacket(); - netMessage2.Write((byte)CalamityModMessageType.BossTypeSync); - netMessage2.Write(bossType); - netMessage2.Send(); - } - } - } - else - { - if (bossSpawnCountdown > 0) - { - bossSpawnCountdown--; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.BossSpawnCountdownSync); - netMessage.Write(bossSpawnCountdown); - netMessage.Send(); - } - } - - if (bossSpawnCountdown <= 0 && deathBossSpawnCooldown <= 0) // Check both cooldowns again here to avoid infinite message possibilities - { - bool canSpawn = true; - switch (bossType) - { - case NPCID.EyeofCthulhu: - if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) - canSpawn = false; - break; - case NPCID.EaterofWorldsHead: - if (!player.ZoneCorrupt) - canSpawn = false; - break; - case NPCID.BrainofCthulhu: - if (!player.ZoneCrimson) - canSpawn = false; - break; - /*case NPCID.QueenBee: - if (!player.ZoneJungle || player.ZoneOverworldHeight || player.ZoneSkyHeight) - canSpawn = false; - break;*/ - case NPCID.TheDestroyer: - if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) - canSpawn = false; - break; - case NPCID.Spazmatism: - if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) - canSpawn = false; - break; - case NPCID.SkeletronPrime: - if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) - canSpawn = false; - break; - case NPCID.Plantera: - if (!player.ZoneJungle || player.ZoneOverworldHeight || player.ZoneSkyHeight) - canSpawn = false; - break; - case NPCID.DukeFishron: - if (!player.ZoneBeach) - canSpawn = false; - break; - } - - if (bossType == ModContent.NPCType()) - { - if (!player.ZoneDesert) - canSpawn = false; - } - else if (bossType == ModContent.NPCType()) - { - if (!player.ZoneCrimson) - canSpawn = false; - } - else if (bossType == ModContent.NPCType()) - { - if (!player.ZoneCorrupt) - canSpawn = false; - } - else if (bossType == ModContent.NPCType()) - { - if (!player.ZoneGlowshroom) - canSpawn = false; - } - else if (bossType == ModContent.NPCType()) - { - if (!player.ZoneSnow || !player.ZoneOverworldHeight) - canSpawn = false; - } - else if (bossType == ModContent.NPCType()) - { - if (Main.dayTime || !player.ZoneOverworldHeight || Main.time > 16200) - canSpawn = false; - } - else if (bossType == ModContent.NPCType()) - { - if (!modPlayer.ZoneAstral || - Main.dayTime || !player.ZoneOverworldHeight) - canSpawn = false; - } - /*else if (bossType == ModContent.NPCType()) - { - if (!player.ZoneJungle || player.ZoneOverworldHeight || player.ZoneSkyHeight) - canSpawn = false; - }*/ - else if (bossType == ModContent.NPCType()) - { - if (!Main.dayTime || (!player.ZoneUnderworldHeight && - (!player.ZoneHoly || !player.ZoneOverworldHeight)) || Main.time > 37800) - canSpawn = false; - } - else if (bossType == ModContent.NPCType()) - { - if (!player.ZoneJungle || !player.ZoneOverworldHeight) - canSpawn = false; - } - - if (canSpawn) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (bossType == NPCID.Spazmatism) - NPC.SpawnOnPlayer(closestPlayer, NPCID.Retinazer); - else if (bossType == ModContent.NPCType()) - { - NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); - NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); - } - else if (bossType == ModContent.NPCType()) - { - NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); - NPC.SpawnOnPlayer(closestPlayer, ModContent.NPCType()); - } - if (bossType == NPCID.DukeFishron) - { - NPC.NewNPC((int)player.Center.X - 300, (int)player.Center.Y - 300, bossType); - } - else - { - NPC.SpawnOnPlayer(closestPlayer, bossType); - } - } - - deathBossSpawnCooldown = 86400; // 24 minutes (1 full Terraria day) - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DeathBossSpawnCountdownSync); - netMessage.Write(deathBossSpawnCooldown); - netMessage.Send(); - } - } - - bossType = 0; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.BossTypeSync); - netMessage.Write(bossType); - netMessage.Send(); - } - } - - // IMPORTANT! Decrement this cooldown AFTER everything else to avoid infinite possibilities - if (deathBossSpawnCooldown > 0) - { - deathBossSpawnCooldown--; - if (Main.netMode == NetmodeID.Server) - { - var netMessage = mod.GetPacket(); - netMessage.Write((byte)CalamityModMessageType.DeathBossSpawnCountdownSync); - netMessage.Write(deathBossSpawnCooldown); - netMessage.Send(); - } - } - } - } - - if (!downedDesertScourge && Main.netMode != NetmodeID.MultiplayerClient && !Main.hardMode) - CalamityUtils.StopSandstorm(); - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - CultistRitual.delay -= Main.dayRate * 10; - if (CultistRitual.delay < 0) - { - CultistRitual.delay = 0; - } - CultistRitual.recheck -= Main.dayRate * 10; - if (CultistRitual.recheck < 0) - { - CultistRitual.recheck = 0; - } - } - } - #endregion - - #region Check Placement Proximity - private bool CanPlaceBasedOnProximity(int x, int y, int tileType) - { - if (tileType == ModContent.TileType() && !downedCalamitas) - return false; - - int minDistanceFromOtherTiles = 6; - int sameTilesNearby = 0; - for (int i = x - minDistanceFromOtherTiles; i < x + minDistanceFromOtherTiles; i++) - { - for (int j = y - minDistanceFromOtherTiles; j < y + minDistanceFromOtherTiles; j++) - { - if (Main.tile[i, j].active() && Main.tile[i, j].type == tileType) - { - sameTilesNearby++; - if (sameTilesNearby > 1) - return false; - } - } - } - - return true; - } - #endregion - - #region ChangeTime - public static void ChangeTime(bool day) - { - Main.time = 0.0; - Main.dayTime = day; - CalamityNetcode.SyncWorld(); - } - #endregion - - #region BossText - public void BossText() - { - string key = "Mods.CalamityMod.BossSpawnText"; - Color messageColor = Color.Crimson; - CalamityUtils.DisplayLocalizedText(key, messageColor); - } + public override void PostUpdate() => WorldUpdateMiscEffects.PerformWorldUpdates(); #endregion } } diff --git a/World/CustomActions.cs b/World/CustomActions.cs index ec92f38827..19781906c4 100644 --- a/World/CustomActions.cs +++ b/World/CustomActions.cs @@ -40,6 +40,20 @@ namespace CalamityMod.World } } + public class SetPaint : GenAction + { + private readonly byte _paintID; + public SetPaint(byte paintID) => _paintID = paintID; + public override bool Apply(Point origin, int x, int y, params object[] args) + { + if (!WorldGen.InWorld(x, y)) + return false; + + WorldGen.paintTile(x, y, _paintID); + return UnitApply(origin, x, y, args); + } + } + public class JungleGrass : GenAction { private bool _tryMushrooms; diff --git a/World/CustomShapes.cs b/World/CustomShapes.cs new file mode 100644 index 0000000000..788e14472d --- /dev/null +++ b/World/CustomShapes.cs @@ -0,0 +1,45 @@ +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.World.Generation; + +namespace CalamityMod.World +{ + public static class CustomShapes + { + public class DistortedCircle : GenShape + { + private readonly int baseRadius; + private readonly float distortionFactor; + + public DistortedCircle(int radius, float distortionFactor) + { + baseRadius = radius; + this.distortionFactor = distortionFactor; + } + + public override bool Perform(Point origin, GenAction action) + { + float offsetAngle = WorldGen.genRand.NextFloat(-10f, 10f); + for (float angle = 0f; angle < MathHelper.TwoPi; angle += MathHelper.Pi * 0.0084f) + { + // Adding two sinusoids with irrational periods results in final sinusoid having no period at all. + // This behavior is ideal for creating a unique distortion surface with many varying hills and valleys. + float distortionQuantity = (float)(Math.Sin(MathHelper.PiOver2 * angle + offsetAngle) + Math.Sin(Math.E * angle * 0.5f + offsetAngle)) * distortionFactor * 0.5f; + int currentRadius = (int)(baseRadius - distortionQuantity * baseRadius); + if (currentRadius <= 0) + continue; + + int horizontalOffset = (int)(Math.Cos(angle) * currentRadius); + int verticalOffset = (int)(Math.Sin(angle) * currentRadius); + for (int dx = 0; dx != horizontalOffset; dx += Math.Sign(horizontalOffset)) + { + for (int dy = 0; dy != verticalOffset; dy += Math.Sign(verticalOffset)) + UnitApply(action, origin, origin.X + dx, origin.Y + dy, new object[0]); + } + } + return true; + } + } + } +} diff --git a/World/MiscWorldgenRoutines.cs b/World/MiscWorldgenRoutines.cs new file mode 100644 index 0000000000..14f9a10476 --- /dev/null +++ b/World/MiscWorldgenRoutines.cs @@ -0,0 +1,832 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Items.Potions; +using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Tiles; +using CalamityMod.Tiles.Abyss; +using CalamityMod.Tiles.Astral; +using CalamityMod.Tiles.Crags; +using CalamityMod.Tiles.FurnitureAncient; +using CalamityMod.Tiles.Ores; +using CalamityMod.Walls; +using Microsoft.Xna.Framework; +using System; +using System.Reflection; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.World.Generation; + +namespace CalamityMod.World +{ + public class MiscWorldgenRoutines + { + #region Dungeon Biome Chests + public static void GenerateBiomeChests(GenerationProgress progress) + { + progress.Message = "Calamity Mod: Biome Chests"; + + // Get dungeon size field infos. These fields are private for some reason + int MinX = (int)typeof(WorldGen).GetField("dMinX", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) + 25; + int MaxX = (int)typeof(WorldGen).GetField("dMaxX", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) - 25; + int MaxY = (int)typeof(WorldGen).GetField("dMaxY", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) - 25; + + int[] ChestTypes = { ModContent.TileType() }; + int[] ItemTypes = { ModContent.ItemType() }; + int[] ChestStyles = { 1 }; // Astral Chest generates in style 1, which is locked + + for (int i = 0; i < ChestTypes.Length; ++i) + { + Chest chest = null; + int attempts = 0; + + // Try 1000 times to place the chest somewhere in the dungeon. + // The placement algorithm ensures that if it tries to appear in midair, it is moved down to the floor. + while (chest == null && attempts < 1000) + { + attempts++; + int x = WorldGen.genRand.Next(MinX, MaxX); + int y = WorldGen.genRand.Next((int)Main.worldSurface, MaxY); + if (Main.wallDungeon[Main.tile[x, y].wall] && !Main.tile[x, y].active()) + chest = AddChestWithLoot(x, y, (ushort)ChestTypes[i], tileStyle: ChestStyles[i]); + } + + // If a chest was placed, force its first item to be the unique Biome Chest weapon. + if (chest != null) + { + chest.item[0].SetDefaults(ItemTypes[i]); + chest.item[0].Prefix(-1); + } + } + } + + internal static Chest AddChestWithLoot(int i, int j, ushort type = TileID.Containers, uint startingSlot = 1, int tileStyle = 0) + { + int chestIndex = -1; + + // Slide downwards on the Y axis trying to find the floor beneath the empty position initially picked + while (j < Main.maxTilesY - 210) + { + if (!WorldGen.SolidTile(i, j)) + { + j++; + continue; + } + + // If there are already 1,000 chests in the world and this one fails to place, just give up. + chestIndex = WorldGen.PlaceChest(i - 1, j - 1, type, false, tileStyle); + break; + } + + if (chestIndex < 0) + return null; + Chest chest = Main.chest[chestIndex]; + PlaceLootInChest(ref chest, type, startingSlot); + return chest; + } + + internal static void PlaceLootInChest(ref Chest chest, ushort type, uint startingSlot) + { + uint itemIndex = startingSlot; + + void PutItemInChest(ref Chest c, int id, int minQuantity = 0, int maxQuantity = 0, bool condition = true) + { + if (!condition) + return; + c.item[itemIndex].SetDefaults(id, false); + + // Don't set quantity unless quantity is specified + if(minQuantity > 0) + { + // Max quantity cannot be less than min quantity. It's zero if not specified, meaning you get exactly minQuantity. + if (maxQuantity < minQuantity) + maxQuantity = minQuantity; + c.item[itemIndex].stack = WorldGen.genRand.Next(minQuantity, maxQuantity + 1); + } + itemIndex++; + } + + // Astral Chest has completely different loot in it + if (type == ModContent.TileType()) + { + PutItemInChest(ref chest, ModContent.ItemType(), 30, 80); + PutItemInChest(ref chest, ModContent.ItemType(), 10, 14); + PutItemInChest(ref chest, ModContent.ItemType(), 8); + PutItemInChest(ref chest, ModContent.ItemType(), 3, 5); + PutItemInChest(ref chest, ItemID.FallenStar, 12, 30); + + // Gold Coins don't stack above 100, so this efficiently lets you stuff over a platinum into a chest + int goldCoins = WorldGen.genRand.Next(30, 120); + if (goldCoins > 100) + { + PutItemInChest(ref chest, ItemID.PlatinumCoin); + goldCoins -= 100; + } + PutItemInChest(ref chest, ItemID.GoldCoin, goldCoins); + } + else if (type == ModContent.TileType()) + { + // 15-29 torches (in accordence with vanilla) + PutItemInChest(ref chest, ItemID.Torch, 15, 29); + + // 50% chance of 1 or 2 of the following potions + int[] potions = new int[] + { + ModContent.ItemType(), ItemID.WaterWalkingPotion, ItemID.ShinePotion, ItemID.GillsPotion, ItemID.FlipperPotion + }; + PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); + PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); + + // 33% chance of flippers + PutItemInChest(ref chest, ItemID.Flipper, condition: WorldGen.genRand.NextBool(3)); + + // Typical coins + PutItemInChest(ref chest, ItemID.GoldCoin, 2, 4); + } + // Default loot + else + { + // Silver, Tungsten, Gold or Platinum bars (following worldgen choice) + int barID = WorldGen.genRand.NextBool() ? WorldGen.goldBar : WorldGen.silverBar; + PutItemInChest(ref chest, barID, 3, 10); + + // 50% chance of 25-50 Holy Arrows + PutItemInChest(ref chest, ItemID.HolyArrow, 25, 50, WorldGen.genRand.NextBool()); + + // 50% chance of 1 or 2 of the following potions + int[] potions = new int[] { + ItemID.SpelunkerPotion, ItemID.FeatherfallPotion, ItemID.NightOwlPotion, + ItemID.WaterWalkingPotion, ItemID.ArcheryPotion, ItemID.GravitationPotion + }; + PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); + + // 50% chance of 1 or 2 of the following potions + // Yes, in vanilla, Dangersense Potions have double the chance to appear. + potions = new int[] { + ItemID.ThornsPotion, ItemID.WaterWalkingPotion, ItemID.InvisibilityPotion, + ItemID.ManaRegenerationPotion, ItemID.TeleportationPotion, ItemID.TrapsightPotion, ItemID.TrapsightPotion + }; + + PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); + PutItemInChest(ref chest, ItemID.RecallPotion, 1, 2, WorldGen.genRand.NextBool()); + PutItemInChest(ref chest, ItemID.GoldCoin, 1, 2); + } + } + #endregion + + #region Place Rox Shrine + public static void PlaceRoxShrine() + { + while (!CalamityWorld.roxShrinePlaced) + { + CalamityWorld.roxShrinePlaced = true; + for (int x = 0; x < Main.maxTilesX; x++) + { + for (int y = 0; y < Main.maxTilesY; y++) + { + if (Main.tile[x, y] != null && Main.tile[x, y].type == TileID.LargePiles) + { + if ((Main.tile[x, y].frameX == 18 && Main.tile[x, y].frameY == 0) || (Main.tile[x, y].frameX == 45 && Main.tile[x, y].frameY == 0)) + { + if (WorldGen.genRand.Next(3) == 0) + { + for (int dx = -1; dx < 2; dx++) + { + for (int dy = -1; dy < 2; dy++) + Main.tile[x + dx, y + dy].active(false); + } + + WorldGen.PlaceTile(x, y + 1, ModContent.TileType()); + return; + } + else + CalamityWorld.roxShrinePlaced = false; + } + } + } + } + } + } + #endregion + + // NOTE - The crag gen is scheduled for a rework soon. As such, its code will not be moved. + + #region UnderworldIsland + public static void UnderworldIsland(int i, int j, int sizeMin, int sizeMax, int sizeMin2, int sizeMax2) + { + double num = (double)WorldGen.genRand.Next(sizeMin, sizeMax); //100 150 + float num2 = (float)WorldGen.genRand.Next(sizeMin / 5, sizeMax / 5); //20 30 + int num3 = i; + int num4 = i; + int num5 = i; + int num6 = j; + Vector2 vector; + vector.X = (float)i; + vector.Y = (float)j; + Vector2 vector2; + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + while (vector2.X > -2f && vector2.X < 2f) + { + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + } + vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; + while (num > 0.0 && num2 > 0f) + { + num -= (double)WorldGen.genRand.Next(4); + num2 -= 1f; + int num7 = (int)((double)vector.X - num * 0.5); + int num8 = (int)((double)vector.X + num * 0.5); + int num9 = (int)((double)vector.Y - num * 0.5); + int num10 = (int)((double)vector.Y + num * 0.5); + if (num7 < 0) + { + num7 = 0; + } + if (num8 > Main.maxTilesX) + { + num8 = Main.maxTilesX; + } + if (num9 < Main.maxTilesY - 270) + { + num9 = Main.maxTilesY - 270; + } + if (num10 > Main.maxTilesY) + { + num10 = Main.maxTilesY; + } + double num11 = num * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 + float num12 = vector.Y + 1f; + for (int k = num7; k < num8; k++) + { + if (WorldGen.genRand.Next(2) == 0) + { + num12 += (float)WorldGen.genRand.Next(-1, 2); + } + if (num12 < vector.Y) + { + num12 = vector.Y; + } + if (num12 > vector.Y + 2f) + { + num12 = vector.Y + 2f; + } + for (int l = num9; l < num10; l++) + { + if ((float)l > num12) + { + float arg_218_0 = Math.Abs((float)k - vector.X); + float num13 = Math.Abs((float)l - vector.Y) * 3f; + if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) + { + if (k < num3) + { + num3 = k; + } + if (k > num4) + { + num4 = k; + } + if (l < num5) + { + num5 = l; + } + if (l > num6) + { + num6 = l; + } + Main.tile[k, l].active(true); + Main.tile[k, l].type = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(k, l, true); + } + } + } + } + vector += vector2; + vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; + if (vector2.X > 1f) + { + vector2.X = 1f; + } + if (vector2.X < -1f) + { + vector2.X = -1f; + } + if ((double)vector2.Y > 0.2) + { + vector2.Y = -0.2f; + } + if ((double)vector2.Y < -0.2) + { + vector2.Y = -0.2f; + } + } + int m = num3; + int num15; + for (m += WorldGen.genRand.Next(5); m < num4; m += WorldGen.genRand.Next(num15, (int)((double)num15 * 1.5))) + { + int num14 = num6; + while (!Main.tile[m, num14].active()) + { + num14--; + if (num14 < Main.maxTilesX - WorldGen.genRand.Next(265, 275 + 1)) + break; + } + num14 += WorldGen.genRand.Next(-3, 4); + num15 = WorldGen.genRand.Next(4, 8); + int num16 = ModContent.TileType(); + if (WorldGen.genRand.Next(4) == 0) + { + num16 = ModContent.TileType(); + } + for (int n = m - num15; n <= m + num15; n++) + { + for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) + { + if (num17 > num5) + { + float arg_409_0 = (float)Math.Abs(n - m); + float num18 = (float)(Math.Abs(num17 - num14) * 2); + if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) + { + Main.tile[n, num17].active(true); + Main.tile[n, num17].type = (ushort)num16; + WorldGen.SquareTileFrame(n, num17, true); + } + } + } + } + } + num = (double)WorldGen.genRand.Next(sizeMin2, sizeMax2); + num2 = (float)WorldGen.genRand.Next(sizeMin2 / 8, sizeMax2 / 8); + vector.X = (float)i; + vector.Y = (float)num5; + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + while (vector2.X > -2f && vector2.X < 2f) + { + vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; + } + vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; + while (num > 0.0 && num2 > 0f) + { + num -= (double)WorldGen.genRand.Next(4); + num2 -= 1f; + vector += vector2; + vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; + if (vector2.X > 1f) + { + vector2.X = 1f; + } + if (vector2.X < -1f) + { + vector2.X = -1f; + } + if ((double)vector2.Y > 0.2) + { + vector2.Y = -0.2f; + } + if ((double)vector2.Y < -0.2) + { + vector2.Y = -0.2f; + } + } + int num23 = num3; + num23 += WorldGen.genRand.Next(5); + while (num23 < num4) + { + int num24 = num6; + while ((!Main.tile[num23, num24].active() || Main.tile[num23, num24].type != 0) && num23 < num4) + { + num24--; + if (num24 < num5) + { + num24 = num6; + num23 += WorldGen.genRand.Next(1, 4); + } + } + if (num23 < num4) + { + num24 += WorldGen.genRand.Next(0, 4); + int num25 = WorldGen.genRand.Next(2, 5); + int num26 = ModContent.TileType(); + for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) + { + for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) + { + if (num28 > num5) + { + float arg_890_0 = (float)Math.Abs(num27 - num23); + float num29 = (float)(Math.Abs(num28 - num24) * 2); + if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < (double)num25) + { + Main.tile[num27, num28].type = (ushort)num26; + WorldGen.SquareTileFrame(num27, num28, true); + } + } + } + } + num23 += WorldGen.genRand.Next(num25, (int)((double)num25 * 1.5)); + } + } + for (int num34 = num3; num34 <= num4; num34++) + { + int num35 = num5 - 10; + while (!Main.tile[num34, num35 + 1].active()) + { + num35++; + } + if (num35 < num6 && Main.tile[num34, num35 + 1].type == (ushort)ModContent.TileType()) + { + if (WorldGen.genRand.Next(10) == 0) + { + int num36 = WorldGen.genRand.Next(1, 3); + for (int num37 = num34 - num36; num37 <= num34 + num36; num37++) + { + if (Main.tile[num37, num35].type == (ushort)ModContent.TileType()) + { + Main.tile[num37, num35].active(false); + Main.tile[num37, num35].liquid = 255; + Main.tile[num37, num35].lava(false); + WorldGen.SquareTileFrame(num34, num35, true); + } + if (Main.tile[num37, num35 + 1].type == (ushort)ModContent.TileType()) + { + Main.tile[num37, num35 + 1].active(false); + Main.tile[num37, num35 + 1].liquid = 255; + Main.tile[num37, num35 + 1].lava(false); + WorldGen.SquareTileFrame(num34, num35 + 1, true); + } + if (num37 > num34 - num36 && num37 < num34 + 2 && Main.tile[num37, num35 + 2].type == (ushort)ModContent.TileType()) + { + Main.tile[num37, num35 + 2].active(false); + Main.tile[num37, num35 + 2].liquid = 255; + Main.tile[num37, num35 + 2].lava(false); + WorldGen.SquareTileFrame(num34, num35 + 2, true); + } + } + } + if (WorldGen.genRand.Next(5) == 0) + { + Main.tile[num34, num35].liquid = 255; + } + Main.tile[num34, num35].lava(false); + WorldGen.SquareTileFrame(num34, num35, true); + } + } + } + #endregion + + #region UnderworldIslandHouse + public static void UnderworldIslandHouse(int i, int j, int item) + { + ushort type = (ushort)ModContent.TileType(); //tile + byte wall = (byte)ModContent.WallType(); //wall + Vector2 vector = new Vector2((float)i, (float)j); + int num = 1; + if (WorldGen.genRand.Next(2) == 0) + { + num = -1; + } + int num2 = WorldGen.genRand.Next(7, 12); + int num3 = WorldGen.genRand.Next(5, 7); + vector.X = (float)(i + (num2 + 2) * num); + for (int k = j - 15; k < j + 30; k++) + { + if (Main.tile[(int)vector.X, k].active()) + { + vector.Y = (float)(k - 1); + break; + } + } + vector.X = (float)i; + int num4 = (int)(vector.X - (float)num2 - 1f); + int num5 = (int)(vector.X + (float)num2 + 1f); + int num6 = (int)(vector.Y - (float)num3 - 1f); + int num7 = (int)(vector.Y + 2f); + if (num4 < 0) + { + num4 = 0; + } + if (num5 > Main.maxTilesX) + { + num5 = Main.maxTilesX; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int l = num4; l <= num5; l++) + { + for (int m = num6 - 1; m < num7 + 1; m++) + { + if (m != num6 - 1 || (l != num4 && l != num5)) + { + Main.tile[l, m].active(true); + Main.tile[l, m].liquid = 0; + Main.tile[l, m].type = type; + Main.tile[l, m].wall = 0; + Main.tile[l, m].halfBrick(false); + Main.tile[l, m].slope(0); + } + } + } + num4 = (int)(vector.X - (float)num2); + num5 = (int)(vector.X + (float)num2); + num6 = (int)(vector.Y - (float)num3); + num7 = (int)(vector.Y + 1f); + if (num4 < 0) + { + num4 = 0; + } + if (num5 > Main.maxTilesX) + { + num5 = Main.maxTilesX; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int n = num4; n <= num5; n++) + { + for (int num8 = num6; num8 < num7; num8++) + { + if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].wall == 0) + { + Main.tile[n, num8].active(false); + Main.tile[n, num8].wall = wall; + } + } + } + int num9 = i + (num2 + 1) * num; + int num10 = (int)vector.Y; + for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) + { + Main.tile[num11, num10].active(false); + Main.tile[num11, num10 - 1].active(false); + Main.tile[num11, num10 - 2].active(false); + } + WorldGen.PlaceTile(num9, num10, ModContent.TileType(), true, false, -1); //door + num9 = i + (num2 + 1) * -num - num; + for (int num12 = num6; num12 <= num7 + 1; num12++) + { + Main.tile[num9, num12].active(true); + Main.tile[num9, num12].liquid = 0; + Main.tile[num9, num12].type = type; + Main.tile[num9, num12].wall = 0; + Main.tile[num9, num12].halfBrick(false); + Main.tile[num9, num12].slope(0); + } + WorldGen.AddBuriedChest(i, num10 - 3, item, false, 4); //chest + int num22 = i + (num2 / 2 + 1) * -num; + WorldGen.PlaceTile(num22, num7 - 1, ModContent.TileType(), true, false, -1); //table + WorldGen.PlaceTile(num22 - 2, num7 - 1, ModContent.TileType(), true, false, 0); //chair + Tile tile = Main.tile[num22 - 2, num7 - 1]; + tile.frameX += 18; + Tile tile2 = Main.tile[num22 - 2, num7 - 2]; + tile2.frameX += 18; + WorldGen.PlaceTile(num22 + 2, num7 - 1, ModContent.TileType(), true, false, 0); //chair + } + #endregion + + #region ChasmGenerator + public static void ChasmGenerator(int i, int j, int steps, bool ocean = false) + { + float num = steps; //850 small 1450 medium 2050 large + if (ocean) + { + int tileYLookup = j; + if (CalamityWorld.abyssSide) + { + while (!Main.tile[i + 125, tileYLookup].active()) + { + tileYLookup++; + } + } + else + { + while (!Main.tile[i - 125, tileYLookup].active()) + { + tileYLookup++; + } + } + j = tileYLookup; + } + Vector2 vector; + vector.X = i; + vector.Y = j; + Vector2 vector2; + vector2.X = WorldGen.genRand.Next(-1, 2) * 0.1f; + vector2.Y = WorldGen.genRand.Next(3, 8) * 0.2f + 0.5f; + int num2 = 5; + double num3 = WorldGen.genRand.Next(5, 7) + 20; //start width + while (num3 > 0.0) + { + if (num > 0f) + { + num3 += WorldGen.genRand.Next(2); + num3 -= WorldGen.genRand.Next(2); + float smallHoleLimit = 790f; //small + if (Main.maxTilesY > 1500) + { smallHoleLimit = 1360f; if (Main.maxTilesY > 2100) { smallHoleLimit = 1950f; } } + if (ocean && num > smallHoleLimit) + { + if (num3 < 7.0) //min width + { + num3 = 7.0; //min width + } + if (num3 > 11.0) //max width + { + num3 = 11.0; //max width + } + } + else //dig large hole + { + if (num3 < (ocean ? 45.0 : 8.0)) //min width + { + num3 = ocean ? 45.0 : 8.0; //min width + } + if (num3 > (ocean ? 50.0 : 20.0)) //max width + { + num3 = ocean ? 50.0 : 20.0; //max width + } + if (num == 1f && num3 < (ocean ? 50.0 : 15.0)) + { + num3 = ocean ? 50.0 : 15.0; + } + } + } + else + { + if ((double)vector.Y > CalamityWorld.abyssChasmBottom) + { + num3 -= WorldGen.genRand.Next(5) + 8; + } + } + if (Main.maxTilesY > 2100) + { + if (((double)vector.Y > CalamityWorld.abyssChasmBottom && num > 0f && ocean) || + (vector.Y >= Main.maxTilesY && num > 0f && !ocean)) + { + num = 0f; + } + } + else if (Main.maxTilesY > 1500) + { + if (((double)vector.Y > CalamityWorld.abyssChasmBottom && num > 0f && ocean) || + (vector.Y > Main.maxTilesY && num > 0f && !ocean)) + { + num = 0f; + } + } + else + { + if (((double)vector.Y > CalamityWorld.abyssChasmBottom && num > 0f && ocean) || + (vector.Y > Main.maxTilesY && num > 0f && !ocean)) + { + num = 0f; + } + } + num -= 1f; + int num4; + int num5; + int num6; + int num7; + if (num > num2) + { + num4 = (int)(vector.X - num3 * 0.5); + num5 = (int)(vector.X + num3 * 0.5); + num6 = (int)(vector.Y - num3 * 0.5); + num7 = (int)(vector.Y + num3 * 0.5); + if (num4 < 0) + { + num4 = 0; + } + if (num5 > Main.maxTilesX - 1) + { + num5 = Main.maxTilesX - 1; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int k = num4; k < num5; k++) + { + for (int l = num6; l < num7; l++) + { + if ((Math.Abs(k - vector.X) + Math.Abs(l - vector.Y)) < num3 * 0.5 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + { + if (ocean) + { + Main.tile[k, l].active(false); + Main.tile[k, l].liquid = 255; + Main.tile[k, l].lava(false); + } + else + { + Main.tile[k, l].active(false); + Main.tile[k, l].liquid = 255; + Main.tile[k, l].lava(true); + } + } + } + } + } + /*if (num <= 2f && vector.Y < (Main.rockLayer + Main.maxTilesY * 0.3)) + { + num = 2f; + }*/ + vector += vector2; + vector2.X += WorldGen.genRand.Next(-1, 2) * 0.01f; + if (vector2.X > 0.02) + { + vector2.X = 0.02f; + } + if (vector2.X < -0.02) + { + vector2.X = -0.02f; + } + num4 = (int)(vector.X - num3 * 1.1); + num5 = (int)(vector.X + num3 * 1.1); + num6 = (int)(vector.Y - num3 * 1.1); + num7 = (int)(vector.Y + num3 * 1.1); + if (num4 < 1) + { + num4 = 1; + } + if (num5 > Main.maxTilesX - 1) + { + num5 = Main.maxTilesX - 1; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int m = num4; m < num5; m++) + { + for (int n = num6; n < num7; n++) + { + if ((Math.Abs(m - vector.X) + Math.Abs(n - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + { + if (n > j + WorldGen.genRand.Next(7, 16)) + { + Main.tile[m, n].active(false); + } + if (steps <= num2) + { + Main.tile[m, n].active(false); + } + if (ocean) + { + Main.tile[m, n].liquid = 255; + Main.tile[m, n].lava(false); + } + else + { + Main.tile[m, n].liquid = 255; + Main.tile[m, n].lava(true); + } + } + } + } + for (int num11 = num4; num11 < num5; num11++) + { + for (int num12 = num6; num12 < num7; num12++) + { + if ((Math.Abs(num11 - vector.X) + Math.Abs(num12 - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) + { + if (ocean) + { + Main.tile[num11, num12].liquid = 255; + Main.tile[num11, num12].lava(false); + } + else + { + Main.tile[num11, num12].liquid = 255; + Main.tile[num11, num12].lava(true); + } + if (steps <= num2) + { + Main.tile[num11, num12].active(false); + } + } + } + } + } + } + #endregion + } +} diff --git a/World/Planets/LuminitePlanet.cs b/World/Planets/LuminitePlanet.cs index 288136fa9b..7886b6dc64 100644 --- a/World/Planets/LuminitePlanet.cs +++ b/World/Planets/LuminitePlanet.cs @@ -9,6 +9,38 @@ namespace CalamityMod.World.Planets { public class LuminitePlanet : Planetoid { + public static void GenerateLuminitePlanetoids() + { + // Don't attempt to generate these things client-side. + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + // The worldgen structure map only gets created/regenerated when you generate a world, for some reason. + // This means if you simply enter a world and generate this planetoid, the map will not exist yet, and errors will arise. + // As a result, a new one is generated as necessary. + if (WorldGen.structures is null) + WorldGen.structures = new StructureMap(); + + int totalPlanetoidsToGenerate = Main.maxTilesX / 4200 + 1; + for (int i = 0; i < totalPlanetoidsToGenerate; i++) + { + for (int tries = 0; tries < 3000; tries++) + { + Point planetoidOrigin = new Point(WorldGen.genRand.Next(Main.maxTilesX / 2 - 700, Main.maxTilesX / 2 + 700), WorldGen.genRand.Next(85, 110)); + if (WorldGen.genRand.NextBool(2)) + { + if (Biomes.Place(planetoidOrigin, WorldGen.structures)) + break; + } + else + { + if (Biomes.Place(planetoidOrigin, WorldGen.structures)) + break; + } + } + } + } + public override bool Place(Point origin, StructureMap structures) { int radius = _random.Next(18, 21); diff --git a/World/Planets/LuminitePlanet2.cs b/World/Planets/LuminitePlanet2.cs index 0b5c20e235..d54e4e765a 100644 --- a/World/Planets/LuminitePlanet2.cs +++ b/World/Planets/LuminitePlanet2.cs @@ -1,6 +1,5 @@ using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; -using System.Linq; using Terraria; using Terraria.ID; using Terraria.ModLoader; diff --git a/World/Planets/Planetoid.cs b/World/Planets/Planetoid.cs index 8a50a06157..d3e882d2c7 100644 --- a/World/Planets/Planetoid.cs +++ b/World/Planets/Planetoid.cs @@ -11,6 +11,69 @@ namespace CalamityMod.World.Planets { private Rectangle _area; + public static void GenerateAllBasePlanetoids(GenerationProgress progress) + { + progress.Message = "Generating Planetoids..."; + + int GrassPlanetoidCount = Main.maxTilesX / 1100; + int LCPlanetoidCount = Main.maxTilesX / 800; + int MudPlanetoidCount = Main.maxTilesX / 1100; + + const int MainPlanetoidAttempts = 3000; + int i = 0; + while (i < MainPlanetoidAttempts) + { + if (Biomes.Place(new Point(WorldGen.genRand.Next(Main.maxTilesX / 2 - 300, Main.maxTilesX / 2 + 300), WorldGen.genRand.Next(128, 134)), WorldGen.structures)) + { + break; + } + i++; + } + + const int CrystalHeartPlanetoidAttempts = 15000; + i = 0; + while (LCPlanetoidCount > 0 && i < CrystalHeartPlanetoidAttempts) + { + int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.2), (int)(Main.maxTilesX * 0.8)); + int y = WorldGen.genRand.Next(70, 101); + + bool placed = Biomes.Place(x, y, WorldGen.structures); + + if (placed) + LCPlanetoidCount--; + i++; + } + + const int GrassPlanetoidAttempts = 12000; + i = 0; + while (GrassPlanetoidCount > 0 && i < GrassPlanetoidAttempts) + { + int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.333), (int)(Main.maxTilesX * 0.666)); + int y = WorldGen.genRand.Next(100, 131); + + + bool placed = Biomes.Place(x, y, WorldGen.structures); + + if (placed) + GrassPlanetoidCount--; + i++; + } + + const int MudPlanetoidAttempts = 12000; + i = 0; + while (MudPlanetoidCount > 0 && i < MudPlanetoidAttempts) + { + int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.3f), (int)(Main.maxTilesX * 0.7f)); + int y = WorldGen.genRand.Next(100, 131); + + bool placed = Biomes.Place(x, y, WorldGen.structures); + + if (placed) + MudPlanetoidCount--; + i++; + } + } + public static bool InvalidSkyPlacementArea(Rectangle area) { Mod varia = CalamityMod.Instance.varia; diff --git a/World/SmallBiomes.cs b/World/SmallBiomes.cs deleted file mode 100644 index 7e50ac1da2..0000000000 --- a/World/SmallBiomes.cs +++ /dev/null @@ -1,172 +0,0 @@ -using CalamityMod.World.Planets; -using Microsoft.Xna.Framework; -using System; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.World -{ - public class SmallBiomes : ModWorld - { - public static void PlaceEvilIsland() - { - int x = Main.maxTilesX; - int xIslandGen; - int yIslandGen; - Rectangle potentialArea; - - do - { - xIslandGen = WorldGen.crimson ? - WorldGen.genRand.Next((int)(x * 0.1), (int)(x * 0.15)) : - WorldGen.genRand.Next((int)(x * 0.85), (int)(x * 0.9)); - yIslandGen = WorldGen.genRand.Next(90, 151); - yIslandGen = Math.Min(yIslandGen, (int)WorldGen.worldSurfaceLow - 50); - - int checkAreaX = 200; - int checkAreaY = 200; - potentialArea = new Rectangle(xIslandGen + checkAreaX / 2, yIslandGen + checkAreaY / 2, checkAreaX, checkAreaY); - } - while (!Planetoid.InvalidSkyPlacementArea(potentialArea)); - - int tileXLookup = xIslandGen; - if (WorldGen.crimson) - { - while (Main.tile[tileXLookup, yIslandGen].active()) - tileXLookup++; - } - else - { - while (Main.tile[tileXLookup, yIslandGen].active()) - tileXLookup--; - } - - xIslandGen = tileXLookup; - CalamityWorld.fehX = xIslandGen; - CalamityWorld.fehY = yIslandGen; - WorldGenerationMethods.EvilIsland(xIslandGen, yIslandGen); - WorldGenerationMethods.EvilIslandHouse(CalamityWorld.fehX, CalamityWorld.fehY); - } - - public static void PlaceShrines() - { - int x = Main.maxTilesX; - int y = Main.maxTilesY; - int genLimit = x / 2; - int generateBack = genLimit - 80; //Small = 2020 - int generateForward = genLimit + 80; //Small = 2180 - double shrineChance = 100E-05; - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Surface Shrine - { - int tilesX = WorldGen.genRand.Next((int)(x * 0.35), generateBack); - int tilesX2 = WorldGen.genRand.Next(generateForward, (int)(x * 0.65)); - int tilesY = WorldGen.genRand.Next((int)(y * 0.3f), (int)(y * 0.35f)); - - if (Main.tile[tilesX, tilesY].type == TileID.Dirt || Main.tile[tilesX, tilesY].type == TileID.Stone) - { - WorldGenerationMethods.SpecialHut(TileID.RedBrick, TileID.Dirt, WallID.RedBrick, 0, tilesX, tilesY); - break; - } - if (Main.tile[tilesX2, tilesY].type == TileID.Dirt || Main.tile[tilesX2, tilesY].type == TileID.Stone) - { - WorldGenerationMethods.SpecialHut(TileID.RedBrick, TileID.Dirt, WallID.RedBrick, 0, tilesX2, tilesY); - break; - } - } - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Evil Shrine - { - int tilesX = WorldGen.genRand.Next(0, x); - int tilesY = WorldGen.genRand.Next((int)(y * 0.3f), (int)(y * 0.35f)); - - if (Main.tile[tilesX, tilesY].type == (WorldGen.crimson ? TileID.Crimstone : TileID.Ebonstone)) - { - WorldGenerationMethods.SpecialHut(WorldGen.crimson ? TileID.CrimtaneBrick : TileID.DemoniteBrick, - WorldGen.crimson ? TileID.Crimstone : TileID.Ebonstone, - WorldGen.crimson ? WallID.CrimtaneBrick : WallID.DemoniteBrick, 1, tilesX, tilesY); - break; - } - } - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Cavern Shrine - { - int tilesX = WorldGen.genRand.Next((int)(x * 0.3), generateBack); - int tilesX2 = WorldGen.genRand.Next(generateForward, (int)(x * 0.7)); - int tilesY = WorldGen.genRand.Next((int)(y * 0.55f), (int)(y * 0.8f)); - - if (Main.tile[tilesX, tilesY].type == TileID.Stone) - { - WorldGenerationMethods.SpecialHut(TileID.ObsidianBrick, TileID.Obsidian, WallID.ObsidianBrick, 2, tilesX, tilesY); - break; - } - if (Main.tile[tilesX2, tilesY].type == TileID.Stone) - { - WorldGenerationMethods.SpecialHut(TileID.ObsidianBrick, TileID.Obsidian, WallID.ObsidianBrick, 2, tilesX2, tilesY); - break; - } - } - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Ice Shrine - { - int tilesX = WorldGen.genRand.Next(0, x); - int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); - - if (Main.tile[tilesX, tilesY].type == TileID.IceBlock) - { - WorldGenerationMethods.SpecialHut(TileID.IceBrick, TileID.IceBlock, WallID.IceBrick, 3, tilesX, tilesY); - break; - } - } - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Desert Shrine - { - int tilesX = WorldGen.genRand.Next(0, x); - int tilesY = WorldGen.genRand.Next((int)(y * 0.3f), (int)(y * 0.5f)); - - if (Main.tile[tilesX, tilesY].type == TileID.DesertFossil) - { - WorldGenerationMethods.SpecialHut(TileID.DesertFossil, TileID.Sandstone, WallID.DesertFossil, 4, tilesX, tilesY); - break; - } - } - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Mushroom Shrine - { - int tilesX = WorldGen.genRand.Next(0, x); - int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); - - if (Main.tile[tilesX, tilesY].type == TileID.MushroomGrass) - { - WorldGenerationMethods.SpecialHut(TileID.MushroomBlock, TileID.Mud, WallID.MushroomUnsafe, 5, tilesX, tilesY); - break; - } - } - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Granite Shrine - { - int tilesX = WorldGen.genRand.Next(0, x); - int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); - - if (Main.tile[tilesX, tilesY].type == TileID.Granite) - { - WorldGenerationMethods.SpecialHut(TileID.GraniteBlock, TileID.Granite, WallID.GraniteUnsafe, 6, tilesX, tilesY); - break; - } - } - - for (int k = 0; k < (int)(x * y * shrineChance); k++) //Marble Shrine - { - int tilesX = WorldGen.genRand.Next(0, x); - int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); - - if (Main.tile[tilesX, tilesY].type == TileID.Marble) - { - WorldGenerationMethods.SpecialHut(TileID.MarbleBlock, TileID.Marble, WallID.MarbleUnsafe, 7, tilesX, tilesY); - break; - } - } - } - } -} diff --git a/World/SulphurousSea.cs b/World/SulphurousSea.cs index d1cc3969d1..893443a221 100644 --- a/World/SulphurousSea.cs +++ b/World/SulphurousSea.cs @@ -1,11 +1,13 @@ using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Schematics; using CalamityMod.Tiles.Abyss; using CalamityMod.Walls; using Microsoft.Xna.Framework; using System; using System.Collections.Generic; +using System.Linq; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,7 +15,7 @@ using Terraria.World.Generation; namespace CalamityMod.World { - public class SulphurousSea : ModWorld + public class SulphurousSea { #region Fields and Properties public static int BiomeWidth @@ -91,6 +93,7 @@ namespace CalamityMod.World PlaceColumns(); PlaceRustyChests(); CreateBeachNearSea(); + PlaceScrapPiles(); } #endregion @@ -691,7 +694,7 @@ namespace CalamityMod.World SulphSeaTiles.Contains(CalamityUtils.ParanoidTileRetrieval(x, y + 1).type) && CalamityUtils.ParanoidTileRetrieval(x, y + 1).active()) { - chest = WorldGenerationMethods.AddChestWithLoot(x, y, (ushort)ModContent.TileType()); + chest = MiscWorldgenRoutines.AddChestWithLoot(x, y, (ushort)ModContent.TileType()); } } } @@ -837,6 +840,80 @@ namespace CalamityMod.World } #endregion + #region Scrap Piles + public static void PlaceScrapPiles() + { + List pastPlacementPostiion = new List(); + for (int i = 0; i < 3; i++) + { + int x = WorldGen.genRand.Next(75, BiomeWidth - 85); + if (!CalamityWorld.abyssSide) + x = Main.maxTilesX - x; + int y = WorldGen.genRand.Next(YStart + (int)(BlockDepth * 0.3f), YStart + (int)(BlockDepth * 0.8f)); + + Point pilePlacementPosition = new Point(x, y); + + // If the selected position is sitting inside of a tile, try again. + if (WorldGen.SolidTile(pilePlacementPosition.X, pilePlacementPosition.Y)) + { + i--; + continue; + } + + // If the selected position is close to other piles, try again. + if (pastPlacementPostiion.Any(p => Vector2.Distance(p, pilePlacementPosition.ToVector2()) < 85f)) + { + i--; + continue; + } + + // Otherwise, decide which pile should be created. + bool createLargePile = WorldGen.genRand.NextBool(3); + int pileVariant = WorldGen.genRand.Next(4); + string schematicName = $"{(createLargePile ? "Large " : string.Empty)}Sulphurous Scrap {pileVariant + 1}"; + Vector2? wrappedSchematicArea = SchematicManager.GetSchematicArea(schematicName); + + // Create a log message if for some reason the schematic in question doesn't exist. + if (!wrappedSchematicArea.HasValue) + { + CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{schematicName}\". No matching schematic file found."); + continue; + } + + Vector2 schematicArea = wrappedSchematicArea.Value; + + // Decide the placement position by searching downward and looking for the lowest point. + // If the position is quite steep, try again. + Vector2 left = pilePlacementPosition.ToVector2() - Vector2.UnitX * schematicArea.X * 0.5f; + Vector2 right = pilePlacementPosition.ToVector2() + Vector2.UnitX * schematicArea.X * 0.5f; + while (!WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)left.X, (int)left.Y))) + left.Y++; + while (!WorldGen.SolidTile(CalamityUtils.ParanoidTileRetrieval((int)right.X, (int)right.Y))) + right.Y++; + + if (Math.Abs(left.Y - right.Y) >= 20f) + { + i--; + continue; + } + + // If the placement position ended up in the abyss, try again. + if (left.Y >= YStart + BlockDepth + 5 || right.Y >= YStart + BlockDepth + 5) + { + i--; + continue; + } + + // Pick the lowest point vertically. + Point bottomCenter = new Point(pilePlacementPosition.X, (int)Math.Max(left.Y, right.Y) + 6); + bool _ = false; + SchematicManager.PlaceSchematic>(schematicName, bottomCenter, SchematicAnchor.BottomCenter, ref _); + + pastPlacementPostiion.Add(bottomCenter.ToVector2()); + } + } + #endregion Scrap Piles + #region Misc Functions public static List YStartWhitelist = new List() { diff --git a/World/SunkenSea.cs b/World/SunkenSea.cs index 72f0cbac25..271e4536ee 100644 --- a/World/SunkenSea.cs +++ b/World/SunkenSea.cs @@ -9,7 +9,7 @@ using Terraria.World.Generation; namespace CalamityMod.World { - public class SunkenSea : ModWorld + public class SunkenSea { private struct Hub { @@ -537,7 +537,7 @@ namespace CalamityMod.World { if (WorldGen.genRand.Next(5) == 0) { - WorldGenerationMethods.PlaceTit(num5, num6, (ushort)ModContent.TileType()); + PlaceTit(num5, num6, (ushort)ModContent.TileType()); } if (WorldGen.genRand.Next(8) == 0) { @@ -602,5 +602,76 @@ namespace CalamityMod.World } return true; } + + public static void PlaceTit(int x, int y, ushort type = 165) + { + if (Main.tile[x, y - 1] == null) + { + Main.tile[x, y - 1] = new Tile(); + } + if (Main.tile[x, y] == null) + { + Main.tile[x, y] = new Tile(); + } + if (Main.tile[x, y + 1] == null) + { + Main.tile[x, y + 1] = new Tile(); + } + if (WorldGen.SolidTile(x, y - 1) && !Main.tile[x, y].active() && !Main.tile[x, y + 1].active()) + { + if (Main.tile[x, y - 1].type == (ushort)ModContent.TileType()) + { + if (WorldGen.genRand.Next(2) == 0 || Main.tile[x, y + 2].active()) + { + int num2 = WorldGen.genRand.Next(3) * 18; + Main.tile[x, y].type = type; + Main.tile[x, y].active(true); + Main.tile[x, y].frameX = (short)num2; + Main.tile[x, y].frameY = 72; + } + else + { + int num3 = WorldGen.genRand.Next(3) * 18; + Main.tile[x, y].type = type; + Main.tile[x, y].active(true); + Main.tile[x, y].frameX = (short)num3; + Main.tile[x, y].frameY = 0; + Main.tile[x, y + 1].type = type; + Main.tile[x, y + 1].active(true); + Main.tile[x, y + 1].frameX = (short)num3; + Main.tile[x, y + 1].frameY = 18; + } + } + } + else + { + if (WorldGen.SolidTile(x, y + 1) && !Main.tile[x, y].active() && !Main.tile[x, y - 1].active()) + { + if (Main.tile[x, y + 1].type == (ushort)ModContent.TileType()) + { + if (WorldGen.genRand.Next(2) == 0 || Main.tile[x, y - 2].active()) + { + int num13 = WorldGen.genRand.Next(3) * 18; + Main.tile[x, y].type = type; + Main.tile[x, y].active(true); + Main.tile[x, y].frameX = (short)num13; + Main.tile[x, y].frameY = 90; + } + else + { + int num14 = WorldGen.genRand.Next(3) * 18; + Main.tile[x, y - 1].type = type; + Main.tile[x, y - 1].active(true); + Main.tile[x, y - 1].frameX = (short)num14; + Main.tile[x, y - 1].frameY = 36; + Main.tile[x, y].type = type; + Main.tile[x, y].active(true); + Main.tile[x, y].frameX = (short)num14; + Main.tile[x, y].frameY = 54; + } + } + } + } + } } } diff --git a/World/UndergroundShrines.cs b/World/UndergroundShrines.cs new file mode 100644 index 0000000000..933ae2dbaa --- /dev/null +++ b/World/UndergroundShrines.cs @@ -0,0 +1,301 @@ +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Mounts; +using CalamityMod.Items.Placeables.Furniture; +using CalamityMod.Items.SummonItems; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.World +{ + public class UndergroundShrines + { + #region Enumeration + public enum UndergroundShrineType + { + Surface, + Cavern, + WorldEvil, + Ice, + Desert, + Mushroom, + Granite, + Marble, + Abyss + } + #endregion + + #region Hut Outline Creation + + // Special Hut: Takes arguments of tile type 1, tile type 2, wall type, hut type (useful if you use this method to generate different huts), and location of the shrine (x and y) + public static void SpecialHut(ushort tile, ushort tile2, ushort wall, UndergroundShrineType hutType, int shrineLocationX, int shrineLocationY) + { + // Random variables for shrine size + int randomX = WorldGen.genRand.Next(2, 4); + int randomY = WorldGen.genRand.Next(2, 4); + + // Replace tiles in shrine area with shrine tile type 1 + for (int x = shrineLocationX - randomX - 1; x <= shrineLocationX + randomX + 1; x++) + { + for (int y = shrineLocationY - randomY - 1; y <= shrineLocationY + randomY + 1; y++) + { + Main.tile[x, y].active(true); + Main.tile[x, y].type = tile; + Main.tile[x, y].slope(0); + Main.tile[x, y].liquid = 0; + Main.tile[x, y].lava(false); + } + } + + // Replace walls in shrine area with shrine wall type + for (int x = shrineLocationX - randomX; x <= shrineLocationX + randomX; x++) + { + for (int y = shrineLocationY - randomY; y <= shrineLocationY + randomY; y++) + { + Main.tile[x, y].active(false); + Main.tile[x, y].wall = wall; + } + } + + // Remove tiles from the inner part of the shrine area + for (int x = shrineLocationX - randomX - 1; x <= shrineLocationX + randomX + 1; x++) + { + for (int y = shrineLocationY + randomY - 2; y <= shrineLocationY + randomY; y++) + Main.tile[x, y].active(false); + } + for (int x = shrineLocationX - randomX - 1; x <= shrineLocationX + randomX + 1; x++) + { + for (int y = shrineLocationY + randomY - 2; y <= shrineLocationY + randomY - 1; y++) + Main.tile[x, y].active(false); + } + + // Replace tiles from bottom of shrine area with shrine tile type 2 + for (int x = shrineLocationX - randomX - 1; x <= shrineLocationX + randomX + 1; x++) + { + int verticalOffset = 4; + int y = shrineLocationY + randomY + 2; + while (!Main.tile[x, y].active() && y < Main.maxTilesY && verticalOffset > 0) + { + Main.tile[x, y].active(true); + Main.tile[x, y].type = tile2; + Main.tile[x, y].slope(0); + y++; + verticalOffset--; + } + } + + // Replace tiles from top of shrine with shrine tile type 1 + randomX -= WorldGen.genRand.Next(1, 3); + int num21 = shrineLocationY - randomY - 2; + while (randomX > -1) + { + for (int x = shrineLocationX - randomX - 1; x <= shrineLocationX + randomX + 1; x++) + { + Main.tile[x, num21].active(true); + Main.tile[x, num21].type = tile; + } + randomX -= WorldGen.genRand.Next(1, 3); + num21--; + } + + // Place shrine chest + CalamityWorld.SChestX[(int)hutType] = shrineLocationX; + CalamityWorld.SChestY[(int)hutType] = shrineLocationY; + SpecialChest(hutType); + } + #endregion + + #region Chest Creation + // Special Chest: Used for placing shrine chests, takes argument of the shrine type which dictates what item will spawn in the first slot of this chest + public static void SpecialChest(UndergroundShrineType shrineType) + { + int item = 0; + int chestType = 0; + + switch (shrineType) + { + case UndergroundShrineType.Surface: + item = ModContent.ItemType(); + break; + case UndergroundShrineType.Cavern: + item = ModContent.ItemType(); + chestType = 44; + break; + case UndergroundShrineType.WorldEvil: + item = WorldGen.crimson ? ModContent.ItemType() : ModContent.ItemType(); + chestType = WorldGen.crimson ? 43 : 3; + break; + case UndergroundShrineType.Ice: + item = ModContent.ItemType(); + chestType = 47; + break; + case UndergroundShrineType.Desert: + item = ModContent.ItemType(); + chestType = 30; + break; + case UndergroundShrineType.Mushroom: + item = ModContent.ItemType(); + chestType = 32; + break; + case UndergroundShrineType.Granite: + item = ModContent.ItemType(); + chestType = 50; + break; + case UndergroundShrineType.Marble: + item = ModContent.ItemType(); + chestType = 51; + break; + case UndergroundShrineType.Abyss: + item = ModContent.ItemType(); + chestType = 4; + break; + } + + // Destroy tiles in chest spawn location + for (int j = CalamityWorld.SChestX[(int)shrineType] - 1; j <= CalamityWorld.SChestX[(int)shrineType] + 1; j++) + { + for (int k = CalamityWorld.SChestY[(int)shrineType]; k <= CalamityWorld.SChestY[(int)shrineType] + 2; k++) + WorldGen.KillTile(j, k, false, false, false); + } + + // Attempt to fix sloped tiles under the chest to prevent the chest from killing itself (literally) + for (int l = CalamityWorld.SChestX[(int)shrineType] - 1; l <= CalamityWorld.SChestX[(int)shrineType] + 1; l++) + { + for (int m = CalamityWorld.SChestY[(int)shrineType]; m <= CalamityWorld.SChestY[(int)shrineType] + 3; m++) + { + if (m < Main.maxTilesY) + { + Main.tile[l, m].slope(0); + Main.tile[l, m].halfBrick(false); + } + } + } + + // Place the chest, finally + WorldGen.AddBuriedChest(CalamityWorld.SChestX[(int)shrineType], CalamityWorld.SChestY[(int)shrineType], item, false, chestType); + } + #endregion + + #region Direct Gen + public static void PlaceShrines() + { + int x = Main.maxTilesX; + int y = Main.maxTilesY; + int genLimit = x / 2; + int generateBack = genLimit - 80; //Small = 2020 + int generateForward = genLimit + 80; //Small = 2180 + double shrineChance = 100E-05; + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Surface Shrine + { + int tilesX = WorldGen.genRand.Next((int)(x * 0.35), generateBack); + int tilesX2 = WorldGen.genRand.Next(generateForward, (int)(x * 0.65)); + int tilesY = WorldGen.genRand.Next((int)(y * 0.3f), (int)(y * 0.35f)); + + if (Main.tile[tilesX, tilesY].type == TileID.Dirt || Main.tile[tilesX, tilesY].type == TileID.Stone) + { + SpecialHut(TileID.RedBrick, TileID.Dirt, WallID.RedBrick, 0, tilesX, tilesY); + break; + } + if (Main.tile[tilesX2, tilesY].type == TileID.Dirt || Main.tile[tilesX2, tilesY].type == TileID.Stone) + { + SpecialHut(TileID.RedBrick, TileID.Dirt, WallID.RedBrick, 0, tilesX2, tilesY); + break; + } + } + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Evil Shrine + { + int tilesX = WorldGen.genRand.Next(0, x); + int tilesY = WorldGen.genRand.Next((int)(y * 0.3f), (int)(y * 0.35f)); + + if (Main.tile[tilesX, tilesY].type == (WorldGen.crimson ? TileID.Crimstone : TileID.Ebonstone)) + { + SpecialHut(WorldGen.crimson ? TileID.CrimtaneBrick : TileID.DemoniteBrick, + WorldGen.crimson ? TileID.Crimstone : TileID.Ebonstone, + WorldGen.crimson ? WallID.CrimtaneBrick : WallID.DemoniteBrick, UndergroundShrineType.WorldEvil, tilesX, tilesY); + break; + } + } + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Cavern Shrine + { + int tilesX = WorldGen.genRand.Next((int)(x * 0.3), generateBack); + int tilesX2 = WorldGen.genRand.Next(generateForward, (int)(x * 0.7)); + int tilesY = WorldGen.genRand.Next((int)(y * 0.55f), (int)(y * 0.8f)); + + if (Main.tile[tilesX, tilesY].type == TileID.Stone) + { + SpecialHut(TileID.ObsidianBrick, TileID.Obsidian, WallID.ObsidianBrick, UndergroundShrineType.Cavern, tilesX, tilesY); + break; + } + if (Main.tile[tilesX2, tilesY].type == TileID.Stone) + { + SpecialHut(TileID.ObsidianBrick, TileID.Obsidian, WallID.ObsidianBrick, UndergroundShrineType.Cavern, tilesX2, tilesY); + break; + } + } + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Ice Shrine + { + int tilesX = WorldGen.genRand.Next(0, x); + int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); + + if (Main.tile[tilesX, tilesY].type == TileID.IceBlock) + { + SpecialHut(TileID.IceBrick, TileID.IceBlock, WallID.IceBrick, UndergroundShrineType.Ice, tilesX, tilesY); + break; + } + } + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Desert Shrine + { + int tilesX = WorldGen.genRand.Next(0, x); + int tilesY = WorldGen.genRand.Next((int)(y * 0.3f), (int)(y * 0.5f)); + + if (Main.tile[tilesX, tilesY].type == TileID.DesertFossil) + { + SpecialHut(TileID.DesertFossil, TileID.Sandstone, WallID.DesertFossil, UndergroundShrineType.Desert, tilesX, tilesY); + break; + } + } + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Mushroom Shrine + { + int tilesX = WorldGen.genRand.Next(0, x); + int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); + + if (Main.tile[tilesX, tilesY].type == TileID.MushroomGrass) + { + SpecialHut(TileID.MushroomBlock, TileID.Mud, WallID.MushroomUnsafe, UndergroundShrineType.Mushroom, tilesX, tilesY); + break; + } + } + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Granite Shrine + { + int tilesX = WorldGen.genRand.Next(0, x); + int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); + + if (Main.tile[tilesX, tilesY].type == TileID.Granite) + { + SpecialHut(TileID.GraniteBlock, TileID.Granite, WallID.GraniteUnsafe, UndergroundShrineType.Granite, tilesX, tilesY); + break; + } + } + + for (int k = 0; k < (int)(x * y * shrineChance); k++) //Marble Shrine + { + int tilesX = WorldGen.genRand.Next(0, x); + int tilesY = WorldGen.genRand.Next((int)(y * 0.35f), (int)(y * 0.5f)); + + if (Main.tile[tilesX, tilesY].type == TileID.Marble) + { + SpecialHut(TileID.MarbleBlock, TileID.Marble, WallID.MarbleUnsafe, UndergroundShrineType.Marble, tilesX, tilesY); + break; + } + } + } + #endregion + } +} diff --git a/World/WorldEvilIsland.cs b/World/WorldEvilIsland.cs new file mode 100644 index 0000000000..6f3b99fc3d --- /dev/null +++ b/World/WorldEvilIsland.cs @@ -0,0 +1,388 @@ +using CalamityMod.DataStructures; +using CalamityMod.World.Planets; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.World.Generation; + +namespace CalamityMod.World +{ + public class WorldEvilIsland + { + public static void PlaceEvilIsland() + { + int x = Main.maxTilesX; + int xIslandGen; + int yIslandGen; + Rectangle potentialArea; + + do + { + xIslandGen = WorldGen.crimson ? + WorldGen.genRand.Next((int)(x * 0.1), (int)(x * 0.2)) : + WorldGen.genRand.Next((int)(x * 0.8), (int)(x * 0.9)); + yIslandGen = WorldGen.genRand.Next(95, 126); + yIslandGen = Math.Min(yIslandGen, (int)WorldGen.worldSurfaceLow - 50); + + int checkAreaX = 180; + int checkAreaY = 95; + potentialArea = Utils.CenteredRectangle(new Vector2(xIslandGen, yIslandGen), new Vector2(checkAreaX, checkAreaY)); + } + while (!Planetoid.InvalidSkyPlacementArea(potentialArea)); + + int tileXLookup = xIslandGen; + if (WorldGen.crimson) + { + while (Main.tile[tileXLookup, yIslandGen].active()) + tileXLookup++; + } + else + { + while (Main.tile[tileXLookup, yIslandGen].active()) + tileXLookup--; + } + + xIslandGen = tileXLookup; + CalamityWorld.fehX = xIslandGen; + CalamityWorld.fehY = yIslandGen; + EvilIsland(xIslandGen, yIslandGen); + EvilIslandHouse(CalamityWorld.fehX, CalamityWorld.fehY); + } + + public static void EvilIsland(int i, int j) + { + // Generate puffy clouds along the bottom. + int leftOffset = 86; + int rightOffset = 86; + int maxVerticalOffset = 24; + List cloudPositions = new List(); + for (int dx = -leftOffset; dx < rightOffset; dx += WorldGen.genRand.Next(21, 26)) + { + float completionRatio = Utils.InverseLerp(-leftOffset - 22f, rightOffset + 22f, dx, true); + float completionRatio010 = CalamityUtils.Convert01To010(completionRatio); + int verticalOffset = (int)(completionRatio010 * maxVerticalOffset); + Point cloudPosition = new Point(i + dx, j + verticalOffset); + + int radius = WorldGen.genRand.Next(22, 26) - (int)((1f - completionRatio010) * 15); + WorldUtils.Gen(cloudPosition, new CustomShapes.DistortedCircle(radius, 0.1f), Actions.Chain( + new Actions.SetTile(TileID.Cloud), + new Modifiers.Blotches(4, 1f))); + + cloudPositions.Add(cloudPosition); + } + + // Clear out a hole. + WorldUtils.Gen(new Point(i, j - 4), new Shapes.Circle((leftOffset + rightOffset - 30) / 2, 16), new Actions.ClearTile()); + + // Create random smaller clouds with offsets to fill in the cut out area. + foreach (Point cloudPosition in cloudPositions) + { + Vector2 offsetCloudPosition = cloudPosition.ToVector2(); + while (!CalamityUtils.ParanoidTileRetrieval((int)offsetCloudPosition.X, (int)offsetCloudPosition.Y).active()) + offsetCloudPosition.Y++; + + for (int k = 0; k < 3; k++) + { + int radius = WorldGen.genRand.Next(6, 9); + Vector2 randomCloudPosition = offsetCloudPosition + WorldGen.genRand.NextVector2Circular(radius, radius) * 0.75f; + + // Account for centering, somewhat. + randomCloudPosition.Y -= radius * 0.4f; + randomCloudPosition.Y += 5f; + + WorldUtils.Gen(randomCloudPosition.ToPoint(), new Shapes.Circle(radius / 2), new Actions.SetTile(TileID.Cloud)); + } + } + + // Fill the not cloud area with evil sandstone. + for (int dx = -leftOffset + 10; dx < rightOffset - 10; dx++) + { + float completionRatio = Utils.InverseLerp(-leftOffset - 22f, rightOffset + 22f, dx, true); + float completionRatio010 = CalamityUtils.Convert01To010(completionRatio); + int verticalOffset = (int)((1f - completionRatio010) * maxVerticalOffset); + for (int dy = -5; dy < maxVerticalOffset + 13 - verticalOffset; dy++) + { + if (!CalamityUtils.ParanoidTileRetrieval(i + dx, j + dy).active()) + { + Main.tile[i + dx, j + dy].type = WorldGen.crimson ? TileID.CorruptSandstone : TileID.CrimsonSandstone; + Main.tile[i + dx, j + dy].active(true); + } + } + } + + // Determine the lines at which clouds begin to form. + List borderPoints = new List(); + for (int dx = -leftOffset + 14; dx < rightOffset - 14; dx++) + { + int verticalBorder = j - 10; + while (CalamityUtils.ParanoidTileRetrieval(i + dx, verticalBorder).type != TileID.Cloud) + { + verticalBorder++; + if (verticalBorder > j + 35) + break; + } + + if (verticalBorder >= j + 35) + continue; + + borderPoints.Add(new Point(i + dx, verticalBorder)); + } + + // And generate blotches at those borders. + for (int k = 0; k < 10; k++) + { + Point borderToGenerateAt = borderPoints[WorldGen.genRand.Next(borderPoints.Count)]; + Vector2 moveDirection = Vector2.UnitY.RotatedBy(WorldGen.genRand.NextFloat(-0.4f, 0.4f)); + for (int l = 0; l < 4; l++) + { + Point blotchPosition = (borderToGenerateAt.ToVector2() + Main.rand.NextVector2Circular(5f, 5f) + moveDirection * l * 3f).ToPoint(); + WorldUtils.Gen(blotchPosition, new CustomShapes.DistortedCircle(WorldGen.genRand.Next(8, 10) - l, 0.4f), Actions.Chain( + new Actions.SetTile(WorldGen.crimson ? TileID.CorruptSandstone : TileID.CrimsonSandstone), + new Modifiers.IsSolid(), + new Modifiers.Blotches(5, 1f), + new Modifiers.OnlyTiles(TileID.CorruptSandstone, TileID.CrimsonSandstone))); + } + } + + // Create some blotches of hardened evil sand and evil ore. + for (int k = 0; k < 12; k++) + { + int radius = WorldGen.genRand.Next(6, 8); + ushort tileType = WorldGen.crimson ? TileID.CorruptHardenedSand : TileID.CrimsonHardenedSand; + + Point blotchPosition = new Point(i + WorldGen.genRand.Next(-leftOffset + 20, rightOffset - 20), j + WorldGen.genRand.Next(-3, 12)); + if (k > 4) + { + if (blotchPosition.Y > j + 3) + { + radius -= WorldGen.genRand.Next(3); + tileType = WorldGen.crimson ? TileID.Demonite : TileID.Crimtane; + } + else + continue; + } + + WorldUtils.Gen(blotchPosition, new CustomShapes.DistortedCircle(radius, 0.35f), Actions.Chain( + new Actions.SetTile(tileType), + new Modifiers.IsSolid(), + new Modifiers.Blotches(5, 1f), + new Modifiers.OnlyTiles(TileID.CorruptSandstone, TileID.CrimsonSandstone))); + } + + // Determine the lines at which ground begins to appear. This only applies if the ground is an evil tile. + List surfacePoints = new List(); + for (int dx = -leftOffset + 24; dx < rightOffset - 24; dx++) + { + // Ignore points near the center because bumps there could cause the house to offset in weird ways. + if (Math.Abs(dx) < 15) + continue; + + int surface = j - 15; + bool hitCloud = false; + while (!CalamityUtils.ParanoidTileRetrieval(i + dx, surface).active()) + { + surface++; + if (CalamityUtils.ParanoidTileRetrieval(i + dx, surface).type == TileID.Cloud) + { + hitCloud = true; + break; + } + if (surface > j + 35) + break; + } + + if (hitCloud || surface >= j + 35) + continue; + + surfacePoints.Add(new Point(i + dx, surface)); + } + + // Create "bumps" on the top by creating blotches just a bit below the surface. + for (int k = 0; k < 4; k++) + { + Point surfaceToGenerateAt = surfacePoints[WorldGen.genRand.Next(surfacePoints.Count)]; + Point blotchPosition = (surfaceToGenerateAt.ToVector2() + Vector2.UnitY * 5f).ToPoint(); + WorldUtils.Gen(blotchPosition, new Shapes.Circle(WorldGen.genRand.Next(8, 10)), Actions.Chain( + new Actions.SetTile(CalamityUtils.ParanoidTileRetrieval(surfaceToGenerateAt.X, surfaceToGenerateAt.Y).type), + new Modifiers.SkipTiles(TileID.Demonite, TileID.Crimtane), + new Modifiers.Blotches(5, 1f))); + } + + // Generate one large chunk of ore somewhere, just in case there isn't much otherwise. + Vector2 oreStartPosition = new Vector2(i + WorldGen.genRand.Next(-leftOffset + 28, rightOffset - 28), j + WorldGen.genRand.Next(8, 14)); + Vector2 oreEndPosition = oreStartPosition + Vector2.UnitX.RotatedBy(WorldGen.genRand.NextFloat(-0.36f, -0.14f)) * WorldGen.genRand.NextBool(2).ToDirectionInt() * WorldGen.genRand.NextFloat(18f, 25f); + Vector2 oreMiddlePosition = (oreStartPosition + oreEndPosition) * 0.5f + WorldGen.genRand.NextVector2Circular(6f, 6f); + List smoothOrePositions = new BezierCurve(oreStartPosition, oreMiddlePosition, oreStartPosition).GetPoints(25); + for (int k = 0; k < smoothOrePositions.Count; k++) + { + float strength = MathHelper.Lerp(1f, 4f, CalamityUtils.Convert01To010(k / (float)smoothOrePositions.Count)); + Point orePosition = smoothOrePositions[k].ToPoint(); + + WorldUtils.Gen(orePosition, new Shapes.Circle((int)strength), Actions.Chain( + new Actions.SetTile(WorldGen.crimson ? TileID.Demonite : TileID.Crimtane))); + } + + // Paint all clouds. + for (int dx = -leftOffset - 30; dx < rightOffset + 30; dx++) + { + for (int dy = -8; dy < 55; dy++) + { + if (CalamityUtils.ParanoidTileRetrieval(i + dx, j + dy).type == TileID.Cloud) + WorldGen.paintTile(i + dx, j + dy, WorldGen.crimson ? PaintID.Purple : PaintID.Red); + } + } + } + + public static void EvilIslandHouse(int i, int j) + { + ushort type = (ushort)(WorldGen.crimson ? 152 : 347); //tile + byte wall = (byte)(WorldGen.crimson ? 35 : 174); //wall + Vector2 vector = new Vector2((float)i, (float)j); + int num = 1; + if (WorldGen.genRand.Next(2) == 0) + { + num = -1; + } + int num2 = WorldGen.genRand.Next(7, 12); + int num3 = WorldGen.genRand.Next(5, 7); + vector.X = (float)(i + (num2 + 2) * num); + for (int k = j - 15; k < j + 30; k++) + { + if (Main.tile[(int)vector.X, k].active()) + { + vector.Y = (float)(k - 1); + break; + } + } + vector.X = (float)i; + int num4 = (int)(vector.X - (float)num2 - 1f); + int num5 = (int)(vector.X + (float)num2 + 1f); + int num6 = (int)(vector.Y - (float)num3 - 1f); + int num7 = (int)(vector.Y + 2f); + if (num4 < 0) + { + num4 = 0; + } + if (num5 > Main.maxTilesX) + { + num5 = Main.maxTilesX; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int l = num4; l <= num5; l++) + { + for (int m = num6 - 1; m < num7 + 1; m++) + { + if (m != num6 - 1 || (l != num4 && l != num5)) + { + Main.tile[l, m].active(true); + Main.tile[l, m].liquid = 0; + Main.tile[l, m].type = type; + Main.tile[l, m].wall = 0; + Main.tile[l, m].halfBrick(false); + Main.tile[l, m].slope(0); + } + } + } + num4 = (int)(vector.X - (float)num2); + num5 = (int)(vector.X + (float)num2); + num6 = (int)(vector.Y - (float)num3); + num7 = (int)(vector.Y + 1f); + if (num4 < 0) + { + num4 = 0; + } + if (num5 > Main.maxTilesX) + { + num5 = Main.maxTilesX; + } + if (num6 < 0) + { + num6 = 0; + } + if (num7 > Main.maxTilesY) + { + num7 = Main.maxTilesY; + } + for (int n = num4; n <= num5; n++) + { + for (int num8 = num6; num8 < num7; num8++) + { + if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].wall == 0) + { + Main.tile[n, num8].active(false); + Main.tile[n, num8].wall = wall; + } + } + } + int num9 = i + (num2 + 1) * num; + int num10 = (int)vector.Y; + for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) + { + Main.tile[num11, num10].active(false); + Main.tile[num11, num10 - 1].active(false); + Main.tile[num11, num10 - 2].active(false); + } + WorldGen.PlaceTile(num9, num10, 10, true, false, -1, WorldGen.crimson ? 1 : 10); //door + num9 = i + (num2 + 1) * -num - num; + for (int num12 = num6; num12 <= num7 + 1; num12++) + { + Main.tile[num9, num12].active(true); + Main.tile[num9, num12].liquid = 0; + Main.tile[num9, num12].type = type; + Main.tile[num9, num12].wall = 0; + Main.tile[num9, num12].halfBrick(false); + Main.tile[num9, num12].slope(0); + } + int contain; + if (WorldGen.crimson) + { + contain = 1571; //scourge + } + else + { + contain = 1569; //vampire + } + WorldGen.AddBuriedChest(i, num10 - 3, contain, false, WorldGen.crimson ? 19 : 20); //chest + int num14 = i - num2 / 2 + 1; + int num15 = i + num2 / 2 - 1; + int num16 = 1; + if (num2 > 10) + { + num16 = 2; + } + int num17 = (num6 + num7) / 2 - 1; + for (int num18 = num14 - num16; num18 <= num14 + num16; num18++) + { + for (int num19 = num17 - 1; num19 <= num17 + 1; num19++) + { + Main.tile[num18, num19].wall = 21; //glass + } + } + for (int num20 = num15 - num16; num20 <= num15 + num16; num20++) + { + for (int num21 = num17 - 1; num21 <= num17 + 1; num21++) + { + Main.tile[num20, num21].wall = 21; //glass + } + } + int num22 = i + (num2 / 2 + 1) * -num; + WorldGen.PlaceTile(num22, num7 - 1, 14, true, false, -1, WorldGen.crimson ? 1 : 8); //table + WorldGen.PlaceTile(num22 - 2, num7 - 1, 15, true, false, 0, WorldGen.crimson ? 2 : 11); //chair + Tile tile = Main.tile[num22 - 2, num7 - 1]; + tile.frameX += 18; + Tile tile2 = Main.tile[num22 - 2, num7 - 2]; + tile2.frameX += 18; + WorldGen.PlaceTile(num22 + 2, num7 - 1, 15, true, false, 0, WorldGen.crimson ? 2 : 11); //chair + } + } +} diff --git a/World/WorldGenerationMethods.cs b/World/WorldGenerationMethods.cs deleted file mode 100644 index 48f76bfa7e..0000000000 --- a/World/WorldGenerationMethods.cs +++ /dev/null @@ -1,3368 +0,0 @@ -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Materials; -using CalamityMod.Items.Mounts; -using CalamityMod.Items.Pets; -using CalamityMod.Items.Placeables.Furniture; -using CalamityMod.Items.Potions; -using CalamityMod.Items.SummonItems; -using CalamityMod.Items.Tools.ClimateChange; -using CalamityMod.Items.Weapons.Magic; -using CalamityMod.Items.Weapons.Melee; -using CalamityMod.Items.Weapons.Ranged; -using CalamityMod.Items.Weapons.Rogue; -using CalamityMod.Items.Weapons.Summon; -using CalamityMod.Schematics; -using CalamityMod.Tiles; -using CalamityMod.Tiles.Abyss; -using CalamityMod.Tiles.Astral; -using CalamityMod.Tiles.AstralDesert; -using CalamityMod.Tiles.AstralSnow; -using CalamityMod.Tiles.Crags; -using CalamityMod.Tiles.FurnitureAncient; -using CalamityMod.Tiles.Ores; -using CalamityMod.Tiles.SunkenSea; -using CalamityMod.Walls; -using CalamityMod.World.Planets; -using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Terraria; -using Terraria.ID; -using Terraria.Localization; -using Terraria.ModLoader; -using Terraria.Utilities; -using Terraria.World.Generation; - -namespace CalamityMod.World -{ - public class WorldGenerationMethods : ModWorld - { - #region Dungeon Biome Chests - public static void GenerateBiomeChests(GenerationProgress progress) - { - progress.Message = "Calamity Mod: Biome Chests"; - - // Get dungeon size field infos. These fields are private for some reason - int MinX = (int)typeof(WorldGen).GetField("dMinX", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) + 25; - int MaxX = (int)typeof(WorldGen).GetField("dMaxX", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) - 25; - int MaxY = (int)typeof(WorldGen).GetField("dMaxY", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) - 25; - - int[] ChestTypes = { ModContent.TileType() }; - int[] ItemTypes = { ModContent.ItemType() }; - int[] ChestStyles = { 1 }; // Astral Chest generates in style 1, which is locked - - for (int i = 0; i < ChestTypes.Length; ++i) - { - Chest chest = null; - int attempts = 0; - - // Try 1000 times to place the chest somewhere in the dungeon. - // The placement algorithm ensures that if it tries to appear in midair, it is moved down to the floor. - while (chest == null && attempts < 1000) - { - attempts++; - int x = WorldGen.genRand.Next(MinX, MaxX); - int y = WorldGen.genRand.Next((int)Main.worldSurface, MaxY); - if (Main.wallDungeon[Main.tile[x, y].wall] && !Main.tile[x, y].active()) - chest = AddChestWithLoot(x, y, (ushort)ChestTypes[i], tileStyle: ChestStyles[i]); - } - - // If a chest was placed, force its first item to be the unique Biome Chest weapon. - if (chest != null) - { - chest.item[0].SetDefaults(ItemTypes[i]); - chest.item[0].Prefix(-1); - } - } - } - - internal static Chest AddChestWithLoot(int i, int j, ushort type = TileID.Containers, uint startingSlot = 1, int tileStyle = 0) - { - int chestIndex = -1; - - // Slide downwards on the Y axis trying to find the floor beneath the empty position initially picked - while (j < Main.maxTilesY - 210) - { - if (!WorldGen.SolidTile(i, j)) - { - j++; - continue; - } - - // If there are already 1,000 chests in the world and this one fails to place, just give up. - chestIndex = WorldGen.PlaceChest(i - 1, j - 1, type, false, tileStyle); - break; - } - - if (chestIndex < 0) - return null; - Chest chest = Main.chest[chestIndex]; - PlaceLootInChest(ref chest, type, startingSlot); - return chest; - } - - internal static void PlaceLootInChest(ref Chest chest, ushort type, uint startingSlot) - { - uint itemIndex = startingSlot; - - void PutItemInChest(ref Chest c, int id, int minQuantity = 0, int maxQuantity = 0, bool condition = true) - { - if (!condition) - return; - c.item[itemIndex].SetDefaults(id, false); - - // Don't set quantity unless quantity is specified - if(minQuantity > 0) - { - // Max quantity cannot be less than min quantity. It's zero if not specified, meaning you get exactly minQuantity. - if (maxQuantity < minQuantity) - maxQuantity = minQuantity; - c.item[itemIndex].stack = WorldGen.genRand.Next(minQuantity, maxQuantity + 1); - } - itemIndex++; - } - - // Astral Chest has completely different loot in it - if (type == ModContent.TileType()) - { - PutItemInChest(ref chest, ModContent.ItemType(), 30, 80); - PutItemInChest(ref chest, ModContent.ItemType(), 10, 14); - PutItemInChest(ref chest, ModContent.ItemType(), 8); - PutItemInChest(ref chest, ModContent.ItemType(), 3, 5); - PutItemInChest(ref chest, ItemID.FallenStar, 12, 30); - - // Gold Coins don't stack above 100, so this efficiently lets you stuff over a platinum into a chest - int goldCoins = WorldGen.genRand.Next(30, 120); - if (goldCoins > 100) - { - PutItemInChest(ref chest, ItemID.PlatinumCoin); - goldCoins -= 100; - } - PutItemInChest(ref chest, ItemID.GoldCoin, goldCoins); - } - else if (type == ModContent.TileType()) - { - // 15-29 torches (in accordence with vanilla) - PutItemInChest(ref chest, ItemID.Torch, 15, 29); - - // 50% chance of 1 or 2 of the following potions - int[] potions = new int[] - { - ModContent.ItemType(), ItemID.WaterWalkingPotion, ItemID.ShinePotion, ItemID.GillsPotion, ItemID.FlipperPotion - }; - PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); - PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); - - // 33% chance of flippers - PutItemInChest(ref chest, ItemID.Flipper, condition: WorldGen.genRand.NextBool(3)); - - // Typical coins - PutItemInChest(ref chest, ItemID.GoldCoin, 2, 4); - } - // Default loot - else - { - // Silver, Tungsten, Gold or Platinum bars (following worldgen choice) - int barID = WorldGen.genRand.NextBool() ? WorldGen.goldBar : WorldGen.silverBar; - PutItemInChest(ref chest, barID, 3, 10); - - // 50% chance of 25-50 Holy Arrows - PutItemInChest(ref chest, ItemID.HolyArrow, 25, 50, WorldGen.genRand.NextBool()); - - // 50% chance of 1 or 2 of the following potions - int[] potions = new int[] { - ItemID.SpelunkerPotion, ItemID.FeatherfallPotion, ItemID.NightOwlPotion, - ItemID.WaterWalkingPotion, ItemID.ArcheryPotion, ItemID.GravitationPotion - }; - PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); - - // 50% chance of 1 or 2 of the following potions - // Yes, in vanilla, Dangersense Potions have double the chance to appear. - potions = new int[] { - ItemID.ThornsPotion, ItemID.WaterWalkingPotion, ItemID.InvisibilityPotion, - ItemID.ManaRegenerationPotion, ItemID.TeleportationPotion, ItemID.TrapsightPotion, ItemID.TrapsightPotion - }; - - PutItemInChest(ref chest, WorldGen.genRand.Next(potions), 1, 2, WorldGen.genRand.NextBool()); - PutItemInChest(ref chest, ItemID.RecallPotion, 1, 2, WorldGen.genRand.NextBool()); - PutItemInChest(ref chest, ItemID.GoldCoin, 1, 2); - } - } - #endregion - - #region Place Rox Shrine - public static void PlaceRoxShrine() - { - while (!CalamityWorld.roxShrinePlaced) - { - CalamityWorld.roxShrinePlaced = true; - for (int x = 0; x < Main.maxTilesX; x++) - { - for (int y = 0; y < Main.maxTilesY; y++) - { - if (Main.tile[x, y] != null && Main.tile[x, y].type == TileID.LargePiles) - { - if ((Main.tile[x, y].frameX == 18 && Main.tile[x, y].frameY == 0) || (Main.tile[x, y].frameX == 45 && Main.tile[x, y].frameY == 0)) - { - if (WorldGen.genRand.Next(3) == 0) - { - for (int dx = -1; dx < 2; dx++) - { - for (int dy = -1; dy < 2; dy++) - Main.tile[x + dx, y + dy].active(false); - } - - WorldGen.PlaceTile(x, y + 1, ModContent.TileType()); - return; - } - else - CalamityWorld.roxShrinePlaced = false; - } - } - } - } - } - } - #endregion - - #region OreSpawn - public static void SpawnOre(int type, double frequency, float depth, float depthLimit) - { - int x = Main.maxTilesX; - int y = Main.maxTilesY; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - for (int k = 0; k < (int)(x * y * frequency); k++) - { - int tilesX = WorldGen.genRand.Next(0, x); - int tilesY = WorldGen.genRand.Next((int)(y * depth), (int)(y * depthLimit)); - if (type == ModContent.TileType()) - { - WorldGen.OreRunner(tilesX, tilesY, WorldGen.genRand.Next(6, 12), WorldGen.genRand.Next(6, 12), (ushort)type); - } - else if (type == ModContent.TileType()) - { - if (Main.tile[tilesX, tilesY].type == TileID.Mud) - { - WorldGen.OreRunner(tilesX, tilesY, WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(3, 8), (ushort)type); - } - } - else if (type == ModContent.TileType() || type == TileID.LunarOre) - { - if (Main.tile[tilesX, tilesY].type == TileID.Dirt || Main.tile[tilesX, tilesY].type == TileID.Stone) - { - WorldGen.OreRunner(tilesX, tilesY, WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(3, 8), (ushort)type); - } - } - else if (type == ModContent.TileType()) - { - if (Main.tile[tilesX, tilesY].type == TileID.SnowBlock || Main.tile[tilesX, tilesY].type == TileID.IceBlock || Main.tile[tilesX, tilesY].type == TileID.CorruptIce || Main.tile[tilesX, tilesY].type == TileID.HallowedIce || Main.tile[tilesX, tilesY].type == TileID.FleshIce || Main.tile[tilesX, tilesY].type == ModContent.TileType() || Main.tile[tilesX, tilesY].type == ModContent.TileType()) - { - WorldGen.OreRunner(tilesX, tilesY, WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(3, 8), (ushort)type); - } - } - else if (type == ModContent.TileType()) - { - if (Main.tile[tilesX, tilesY].type == TileID.Pearlstone || Main.tile[tilesX, tilesY].type == TileID.HallowHardenedSand || Main.tile[tilesX, tilesY].type == TileID.HallowSandstone || Main.tile[tilesX, tilesY].type == TileID.HallowedIce) - { - WorldGen.OreRunner(tilesX, tilesY, WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(3, 8), (ushort)type); - } - } - else - { - WorldGen.OreRunner(tilesX, tilesY, WorldGen.genRand.Next(3, 8), WorldGen.genRand.Next(3, 8), (ushort)type); - } - } - } - } - #endregion - - #region AstralMeteor - public static bool CanAstralMeteorSpawn() - { - int astralOreCount = 0; - float worldSizeFactor = Main.maxTilesX / 4200f; // Small = 4200, Medium = 6400, Large = 8400 - int astralOreAllowed = (int)(200f * worldSizeFactor); // Small = 201 Medium = 305 Large = 401 - for (int x = 5; x < Main.maxTilesX - 5; x++) - { - int y = 5; - while (y < Main.worldSurface) - { - if (Main.tile[x, y].active() && Main.tile[x, y].type == ModContent.TileType()) - { - astralOreCount++; - if (astralOreCount > astralOreAllowed) - return false; - } - y++; - } - } - return true; - } - - public static bool CanAstralBiomeSpawn() - { - int astralTileCount = 0; - float worldSizeFactor = Main.maxTilesX / 4200f; // Small = 4200, Medium = 6400, Large = 8400 - int astralTilesAllowed = (int)(400f * worldSizeFactor); // Small = 401 Medium = 605 Large = 801 - for (int x = 5; x < Main.maxTilesX - 5; x++) - { - int y = 5; - while (y < Main.worldSurface) - { - if (Main.tile[x, y].active() && - (Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || - Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || - Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || - Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || - Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType() || - Main.tile[x, y].type == ModContent.TileType() || Main.tile[x, y].type == ModContent.TileType())) - { - astralTileCount++; - if (astralTileCount > astralTilesAllowed) - return false; - } - y++; - } - } - return true; - } - - public static void AstralMeteorThreadWrapper(object context) - { - PlaceAstralMeteor(); - } - - public static void PlaceAstralMeteor() - { - Mod ancientsAwakened = CalamityMod.Instance.ancientsAwakened; - - // This flag is also used to determine whether players are nearby. - bool meteorDropped = true; - - // Clients in multiplayer don't drop meteors. - if (Main.netMode == NetmodeID.MultiplayerClient) - return; - for (int i = 0; i < 255; i++) - { - if (Main.player[i].active) - { - meteorDropped = false; - break; - } - } - - // Check whether there is already too much ore. - if (!CanAstralMeteorSpawn()) - return; - - UnifiedRandom rand = WorldGen.genRand; - float solidTileRequirement = 600f; - bool localAbyssSide = WorldGen.dungeonX < Main.maxTilesX / 2; - while (!meteorDropped) - { - float worldEdgeMargin = (float)Main.maxTilesX * 0.08f; - int xLimit = Main.maxTilesX / 2; - int x = CalamityWorld.abyssSide ? rand.Next(400, xLimit) : rand.Next(xLimit, Main.maxTilesX - 400); - while ((float)x > (float)Main.spawnTileX - worldEdgeMargin && (float)x < (float)Main.spawnTileX + worldEdgeMargin) - { - x = CalamityWorld.abyssSide ? rand.Next(400, xLimit) : rand.Next(xLimit, Main.maxTilesX - 400); - } - //world surface = 920 large 740 medium 560 small - int y = (int)(Main.worldSurface * 0.5); //Large = 522, Medium = 444, Small = 336 - while (y < Main.maxTilesY) - { - if (Main.tile[x, y].active() && Main.tileSolid[(int)Main.tile[x, y].type]) - { - int suitableTiles = 0; - int checkRadius = 15; - for (int l = x - checkRadius; l < x + checkRadius; l++) - { - for (int m = y - checkRadius; m < y + checkRadius; m++) - { - if (WorldGen.SolidTile(l, m)) - { - suitableTiles++; - - // Avoid floating islands: Clouds and Sunplate both harshly punish attempted meteor spawns - if (Main.tile[l, m].type == TileID.Cloud || Main.tile[l, m].type == TileID.Sunplate) - { - suitableTiles -= 100; - } - // Avoid Sulphurous Sea beach: Cannot be converted by astral - else if (Main.tile[l, m].type == ModContent.TileType() || Main.tile[l, m].type == ModContent.TileType()) - { - suitableTiles -= 100; - } - - // Prevent the Astral biome from overriding or interfering with an AA biome - else if (ancientsAwakened != null) - { - if (Main.tile[l, m].type == ancientsAwakened.TileType("InfernoGrass") || Main.tile[l, m].type == ancientsAwakened.TileType("Torchstone") || - Main.tile[l, m].type == ancientsAwakened.TileType("Torchsand") || Main.tile[l, m].type == ancientsAwakened.TileType("Torchsandstone") || - Main.tile[l, m].type == ancientsAwakened.TileType("Torchsandhardened") || Main.tile[l, m].type == ancientsAwakened.TileType("Torchice") || - Main.tile[l, m].type == ancientsAwakened.TileType("Depthstone") || Main.tile[l, m].type == ancientsAwakened.TileType("Depthsand") || - Main.tile[l, m].type == ancientsAwakened.TileType("Depthsandstone") || Main.tile[l, m].type == ancientsAwakened.TileType("Depthsandhardened") || - Main.tile[l, m].type == ancientsAwakened.TileType("Depthice")) - { - suitableTiles -= 100; - } - } - } - - // Liquid aversion makes meteors less likely to fall in lakes - else if (Main.tile[l, m].liquid > 0) - { - suitableTiles--; - } - } - } - - if ((float)suitableTiles < solidTileRequirement) - { - solidTileRequirement -= 0.5f; - break; - } - meteorDropped = GenerateAstralMeteor(x, y); - - // If the meteor actually dropped, post the message stating as such. - if (meteorDropped) - { - string key = "Mods.CalamityMod.AstralText"; - Color messageColor = Color.Gold; - - CalamityUtils.DisplayLocalizedText(key, messageColor); - break; - } - break; - } - else - { - y++; - } - } - if (solidTileRequirement < 100f) - { - return; - } - } - } - - public static bool GenerateAstralMeteor(int i, int j) - { - UnifiedRandom rand = WorldGen.genRand; - if (i < 50 || i > Main.maxTilesX - 50) - { - return false; - } - // Avoid the dungeon so that the beacon doesn't eat it. - if (Math.Abs(i - WorldGen.dungeonX) < 65) - { - return false; - } - if (j < 50 || j > Main.maxTilesY - 50) - { - return false; - } - int num = 35; - Rectangle rectangle = new Rectangle((i - num) * 16, (j - num) * 16, num * 2 * 16, num * 2 * 16); - for (int k = 0; k < 255; k++) - { - if (Main.player[k].active) - { - Rectangle value = new Rectangle((int)(Main.player[k].position.X + (float)(Main.player[k].width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.player[k].position.Y + (float)(Main.player[k].height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2); - if (rectangle.Intersects(value)) - { - return false; - } - } - } - for (int l = 0; l < 200; l++) - { - if (Main.npc[l].active) - { - Rectangle value2 = new Rectangle((int)Main.npc[l].position.X, (int)Main.npc[l].position.Y, Main.npc[l].width, Main.npc[l].height); - if (rectangle.Intersects(value2)) - { - return false; - } - } - } - for (int m = i - num; m < i + num; m++) - { - for (int n = j - num; n < j + num; n++) - { - if (Main.tile[m, n].active() && Main.tile[m, n].type == 21) - { - return false; - } - } - } - num = rand.Next(17, 23); - for (int num2 = i - num; num2 < i + num; num2++) - { - for (int num3 = j - num; num3 < j + num; num3++) - { - if (num3 > j + rand.Next(-2, 3) - 5) - { - float num4 = (float)Math.Abs(i - num2); - float num5 = (float)Math.Abs(j - num3); - float num6 = (float)Math.Sqrt((double)(num4 * num4 + num5 * num5)); - if ((double)num6 < (double)num * 0.9 + (double)rand.Next(-4, 5)) - { - if (Main.tile[num2, num3] != null) - { - if (!Main.tileSolid[(int)Main.tile[num2, num3].type]) - { - Main.tile[num2, num3].active(false); - } - Main.tile[num2, num3].type = (ushort)ModContent.TileType(); - } - } - } - } - } - num = WorldGen.genRand.Next(8, 14); - for (int num7 = i - num; num7 < i + num; num7++) - { - for (int num8 = j - num; num8 < j + num; num8++) - { - if (num8 > j + rand.Next(-2, 3) - 4) - { - float num9 = (float)Math.Abs(i - num7); - float num10 = (float)Math.Abs(j - num8); - float num11 = (float)Math.Sqrt((double)(num9 * num9 + num10 * num10)); - if ((double)num11 < (double)num * 0.8 + (double)rand.Next(-3, 4)) - { - if (Main.tile[num7, num8] != null) - Main.tile[num7, num8].active(false); - } - } - } - } - num = WorldGen.genRand.Next(25, 35); - for (int num12 = i - num; num12 < i + num; num12++) - { - for (int num13 = j - num; num13 < j + num; num13++) - { - float num14 = (float)Math.Abs(i - num12); - float num15 = (float)Math.Abs(j - num13); - float num16 = (float)Math.Sqrt((double)(num14 * num14 + num15 * num15)); - if (Main.tile[num12, num13] != null) - { - if ((double)num16 < (double)num * 0.7) - { - if (Main.tile[num12, num13].type == 5 || Main.tile[num12, num13].type == 32 || Main.tile[num12, num13].type == 352) - { - try - { WorldGen.KillTile(num12, num13, false, false, true); } - catch (NullReferenceException) - { } - } - Main.tile[num12, num13].liquid = 0; - } - if (Main.tile[num12, num13].type == (ushort)ModContent.TileType()) - { - if (!WorldGen.SolidTile(num12 - 1, num13) && !WorldGen.SolidTile(num12 + 1, num13) && !WorldGen.SolidTile(num12, num13 - 1) && !WorldGen.SolidTile(num12, num13 + 1)) - { - Main.tile[num12, num13].active(false); - } - else if ((Main.tile[num12, num13].halfBrick() || Main.tile[num12 - 1, num13].topSlope()) && !WorldGen.SolidTile(num12, num13 + 1)) - { - Main.tile[num12, num13].active(false); - } - } - WorldGen.SquareTileFrame(num12, num13, true); - WorldGen.SquareWallFrame(num12, num13, true); - } - } - } - num = WorldGen.genRand.Next(23, 32); - for (int num17 = i - num; num17 < i + num; num17++) - { - for (int num18 = j - num; num18 < j + num; num18++) - { - if (num18 > j + WorldGen.genRand.Next(-3, 4) - 3 && Main.tile[num17, num18].active() && rand.NextBool(10)) - { - float num19 = (float)Math.Abs(i - num17); - float num20 = (float)Math.Abs(j - num18); - float num21 = (float)Math.Sqrt((double)(num19 * num19 + num20 * num20)); - if ((double)num21 < (double)num * 0.8) - { - if (Main.tile[num17, num18] != null) - { - if (Main.tile[num17, num18].type == 5 || Main.tile[num17, num18].type == 32 || Main.tile[num17, num18].type == 352) - { - WorldGen.KillTile(num17, num18, false, false, false); - } - Main.tile[num17, num18].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(num17, num18, true); - } - } - } - } - } - num = WorldGen.genRand.Next(30, 38); - for (int num22 = i - num; num22 < i + num; num22++) - { - for (int num23 = j - num; num23 < j + num; num23++) - { - if (num23 > j + WorldGen.genRand.Next(-2, 3) && Main.tile[num22, num23].active() && rand.NextBool(20)) - { - float num24 = (float)Math.Abs(i - num22); - float num25 = (float)Math.Abs(j - num23); - float num26 = (float)Math.Sqrt((double)(num24 * num24 + num25 * num25)); - if ((double)num26 < (double)num * 0.85) - { - if (Main.tile[num22, num23] != null) - { - if (Main.tile[num22, num23].type == 5 || Main.tile[num22, num23].type == 32 || Main.tile[num22, num23].type == 352) - { - WorldGen.KillTile(num22, num23, false, false, false); - } - Main.tile[num22, num23].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(num22, num23, true); - } - } - } - } - } - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NetMessage.SendTileSquare(-1, i, j, 40, TileChangeType.None); - if (CanAstralBiomeSpawn()) - { - DoAstralConversion(new Point(i, j)); - - // Upward checks go up 180 tiles. If for whatever reason the placement Y position - // would cause this upward movement to go outside of the world, clamp it to prevent index problems. - if (j < 181) - j = 181; - - int checkWidth = 180; - float averageHeight = 0f; - float lowestHeight = 0f; - - int xAreaToSpawn = i; - - Dictionary xAreaHeightMap = new Dictionary(); - - // Gauge the bumpiness of various potential locations. - // The least bumpy one will be selected as the place to spawn the monolith. - for (int tries = 0; tries < 30; tries++) - { - int x = i + Main.rand.Next(-60, 61); - - // Don't attempt to add duplicate keys. - if (xAreaHeightMap.ContainsKey(x)) - continue; - - float averageRelativeHeight = 0f; - for (int dx = -30; dx <= 30; dx++) - { - WorldUtils.Find(new Point(x + dx, j - 180), Searches.Chain(new Searches.Down(360), new Conditions.IsSolid()), out Point result); - averageRelativeHeight += Math.Abs(result.Y - j); - } - averageRelativeHeight /= 60f; - xAreaHeightMap.Add(x, averageRelativeHeight); - } - - i = xAreaHeightMap.OrderBy(x => x.Value).First().Key; - - for (int x = i - checkWidth / 2; x < i + checkWidth / 2; x++) - { - int y = j - 200; - Tile tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); - while (!Main.tileSolid[tileAtPosition.type] || - !tileAtPosition.active() || - TileID.Sets.Platforms[tileAtPosition.type]) - { - y++; - if (y > j - 10) - break; - tileAtPosition = CalamityUtils.ParanoidTileRetrieval(x, y); - } - lowestHeight = (int)MathHelper.Max(lowestHeight, y); - averageHeight += y; - } - lowestHeight -= 35f; - averageHeight /= checkWidth; - float height = lowestHeight; - - // If there's a sudden change between the average and lowest height (which is indicative of holes/chasms), go with the average. - if (Math.Abs(lowestHeight - averageHeight) > 50f) - height = averageHeight; - - // WorldGen.gen prevents NewItem from working, and thus prevents a bunch of dumb items from being spawned immediately and deleting the WoF/Aureus loot in the process. - WorldGen.gen = true; - // Add the average height of a tree to the Y position to offset trees usually messing with the calculation. - // Then also add 10 blocks because these things seem to always like to appear standing on the floor. - int finalVerticalOffset = 18; - bool _ = true; - SchematicManager.PlaceSchematic>("Astral Beacon", new Point(i, (int)height + finalVerticalOffset), SchematicAnchor.Center, ref _); - WorldGen.gen = false; - } - } - return true; - } - - public static void DoAstralConversion(object obj) - { - //Pre-calculate all variables necessary for elliptical area checking - Point origin = (Point)obj; - Vector2 center = origin.ToVector2() * 16f + new Vector2(8f); - - float angle = MathHelper.Pi * 0.15f; - float otherAngle = MathHelper.PiOver2 - angle; - - int distanceInTiles = 150 + (Main.maxTilesX - 4200) / 4200 * 200; - float distance = distanceInTiles * 16f; - float constant = distance * 2f / (float)Math.Sin(angle); - - float fociSpacing = distance * (float)Math.Sin(otherAngle) / (float)Math.Sin(angle); - int verticalRadius = (int)(constant / 16f); - - Vector2 fociOffset = Vector2.UnitY * fociSpacing; - Vector2 topFoci = center - fociOffset; - Vector2 bottomFoci = center + fociOffset; - - UnifiedRandom rand = WorldGen.genRand; - for (int x = origin.X - distanceInTiles - 2; x <= origin.X + distanceInTiles + 2; x++) - { - for (int y = (int)(origin.Y - verticalRadius * 0.4f) - 3; y <= origin.Y + verticalRadius + 3; y++) - { - if (CheckInEllipse(new Point(x, y), topFoci, bottomFoci, constant, center, out float dist, y < origin.Y)) - { - //If we're in the outer blurPercent% of the ellipse - float percent = dist / constant; - float blurPercent = 0.98f; - if (percent > blurPercent) - { - float outerEdgePercent = (percent - blurPercent) / (1f - blurPercent); - if (rand.NextFloat(1f) > outerEdgePercent) - { - ConvertToAstral(x, y); - } - } - else - { - ConvertToAstral(x, y); - } - } - } - } - } - - public static void ConvertToAstral(int startX, int endX, int startY, int endY) - { - for (int x = startX; x <= endX; x++) - { - for (int y = startY; y <= endY; y++) - { - ConvertToAstral(x, y); - } - } - } - - public static void ConvertToAstral(int x, int y) - { - if (WorldGen.InWorld(x, y, 1)) - { - int type = Main.tile[x, y].type; - int wallType = Main.tile[x, y].wall; - - if (Main.tile[x, y] != null) - { - if (WallID.Sets.Conversion.Grass[wallType]) - { - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (WallID.Sets.Conversion.HardenedSand[wallType]) - { - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (WallID.Sets.Conversion.Sandstone[wallType]) - { - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (WallID.Sets.Conversion.Stone[wallType]) - { - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else - { - switch (wallType) - { - case WallID.DirtUnsafe: - case WallID.DirtUnsafe1: - case WallID.DirtUnsafe2: - case WallID.DirtUnsafe3: - case WallID.DirtUnsafe4: - case WallID.Cave6Unsafe: - case WallID.Dirt: - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.SnowWallUnsafe: - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.DesertFossil: - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.IceUnsafe: - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.LivingWood: - Main.tile[x, y].wall = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - } - } - if (TileID.Sets.Conversion.Grass[type] && !TileID.Sets.GrassSpecial[type]) - { - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Stone[type] || Main.tileMoss[type]) - { - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Sand[type]) - { - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.HardenedSand[type]) - { - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Sandstone[type]) - { - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Ice[type]) - { - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else - { - Tile tile = Main.tile[x, y]; - switch (type) - { - case TileID.Dirt: - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.SnowBlock: - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.Silt: - case TileID.Slush: - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.DesertFossil: - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.ClayBlock: - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.Vines: - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.LivingWood: - Main.tile[x, y].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.LeafBlock: - case TileID.Sunflower: - WorldGen.KillTile(x, y); - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, x, y); - } - break; - case TileID.LargePiles: - if (tile.frameX <= 1170) - { - RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 0, 1170, 0, 18); - } - if (tile.frameX >= 1728) - { - RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1728, 1872, 0, 18); - } - if (tile.frameX >= 1404 && tile.frameX <= 1710) - { - RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1404, 1710, 0, 18); - } - break; - case TileID.LargePiles2: - if (tile.frameX >= 1566 && tile.frameY < 36) - { - RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 1566, 1872, 0, 18); - } - if (tile.frameX >= 756 && tile.frameX <= 900) - { - RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 756, 900, 0, 18); - } - break; - case TileID.SmallPiles: - if (tile.frameY == 18) - { - ushort newType; - if (tile.frameX >= 1476 && tile.frameX <= 1674) - { - newType = (ushort)ModContent.TileType(); - } - else if (tile.frameX <= 558 || (tile.frameX >= 1368 && tile.frameX <= 1458)) - { - newType = (ushort)ModContent.TileType(); - } - else if (tile.frameX >= 900 && tile.frameX <= 1098) - { - newType = (ushort)ModContent.TileType(); - } - else - { - break; - } - int leftMost = x; - if (tile.frameX % 36 != 0) //this means it's the right tile of the two - { - leftMost--; - } - if (Main.tile[leftMost, y] != null) - { - Main.tile[leftMost, y].type = newType; - WorldGen.SquareTileFrame(leftMost, y, true); - NetMessage.SendTileSquare(-1, leftMost, y, 1); - } - if (Main.tile[leftMost + 1, y] != null) - { - Main.tile[leftMost + 1, y].type = newType; - WorldGen.SquareTileFrame(leftMost + 1, y, true); - NetMessage.SendTileSquare(-1, leftMost + 1, y, 1); - } - while (Main.tile[leftMost, y].frameX >= 216) - { - if (Main.tile[leftMost, y] != null) - Main.tile[leftMost, y].frameX -= 216; - if (Main.tile[leftMost + 1, y] != null) - Main.tile[leftMost + 1, y].frameX -= 216; - } - } - else if (tile.frameY == 0) - { - ushort newType3; - if (tile.frameX >= 972 && tile.frameX <= 1062) - { - newType3 = (ushort)ModContent.TileType(); - } - else if (tile.frameX <= 486) - { - newType3 = (ushort)ModContent.TileType(); - } - else if (tile.frameX >= 648 && tile.frameX <= 846) - { - newType3 = (ushort)ModContent.TileType(); - } - else - { - break; - } - Main.tile[x, y].type = newType3; - while (Main.tile[x, y].frameX >= 108) //REFRAME IT - { - Main.tile[x, y].frameX -= 108; - } - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - break; - case TileID.Stalactite: - int topMost = tile.frameY <= 54 ? (tile.frameY % 36 == 0 ? y : y - 1) : y; - bool twoTall = tile.frameY <= 54; - bool hanging = tile.frameY <= 18 || tile.frameY == 72; - ushort newType2; - if (tile.frameX >= 378 && tile.frameX <= 414) //DESERT - { - newType2 = (ushort)ModContent.TileType(); - } - else if ((tile.frameX >= 54 && tile.frameX <= 90) || (tile.frameX >= 216 && tile.frameX <= 360)) - { - newType2 = (ushort)ModContent.TileType(); - } - else if (tile.frameX <= 36) - { - newType2 = (ushort)ModContent.TileType(); - } - else - { - break; - } - - //Set types - if (Main.tile[x, topMost] != null) - { - Main.tile[x, topMost].type = newType2; - } - if (twoTall) - { - if (Main.tile[x, topMost + 1] != null) - Main.tile[x, topMost + 1].type = newType2; - } - - //Fix frames - while (Main.tile[x, topMost].frameX >= 54) - { - if (Main.tile[x, topMost] != null) - Main.tile[x, topMost].frameX -= 54; - if (twoTall) - { - if (Main.tile[x, topMost + 1] != null) - Main.tile[x, topMost + 1].frameX -= 54; - } - } - - if (Main.tile[x, topMost] != null) - { - WorldGen.SquareTileFrame(x, topMost, true); - NetMessage.SendTileSquare(-1, x, topMost, 1); - } - - if (Main.tile[x, topMost + 1] != null) - { - WorldGen.SquareTileFrame(x, topMost + 1, true); - NetMessage.SendTileSquare(-1, x, topMost + 1, 1); - } - - if (hanging) - { - ConvertToAstral(x, topMost - 1); - break; - } - else - { - if (twoTall) - { - ConvertToAstral(x, topMost + 2); - break; - } - ConvertToAstral(x, topMost + 1); - break; - } - } - } - } - } - } - - public static void ConvertFromAstral(int x, int y, ConvertType convert, bool tileframe = true) - { - Tile tile = Main.tile[x, y]; - int type = tile.type; - int wallType = tile.wall; - - if (WorldGen.InWorld(x, y, 1)) - { - #region WALL - if (Main.tile[x, y] != null) - { - if (wallType == ModContent.WallType()) - { - Main.tile[x, y].wall = WallID.DirtUnsafe; - } - else if (wallType == ModContent.WallType() || wallType == ModContent.WallType()) - { - Main.tile[x, y].wall = WallID.SnowWallUnsafe; - } - else if (wallType == ModContent.WallType()) - { - Main.tile[x, y].wall = WallID.DesertFossil; - } - else if (wallType == ModContent.WallType()) - { - switch (convert) - { - case ConvertType.Corrupt: - Main.tile[x, y].wall = WallID.CorruptGrassUnsafe; - break; - case ConvertType.Crimson: - Main.tile[x, y].wall = WallID.CrimsonGrassUnsafe; - break; - case ConvertType.Hallow: - Main.tile[x, y].wall = WallID.HallowedGrassUnsafe; - break; - case ConvertType.Pure: - Main.tile[x, y].wall = WallID.GrassUnsafe; - break; - } - } - else if (wallType == ModContent.WallType()) - { - Main.tile[x, y].wall = WallID.IceUnsafe; - } - else if (wallType == ModContent.WallType()) - { - Main.tile[x, y].wall = WallID.LivingWood; - } - else if (wallType == ModContent.WallType()) - { - switch (convert) - { - case ConvertType.Corrupt: - Main.tile[x, y].wall = WallID.EbonstoneUnsafe; - break; - case ConvertType.Crimson: - Main.tile[x, y].wall = WallID.CrimstoneUnsafe; - break; - case ConvertType.Hallow: - Main.tile[x, y].wall = WallID.PearlstoneBrickUnsafe; - break; - case ConvertType.Pure: - Main.tile[x, y].wall = WallID.Stone; - break; - } - } - } - #endregion - - #region TILE - if (Main.tile[x, y] != null) - { - if (type == ModContent.TileType()) - { - tile.type = TileID.Dirt; - } - else if (type == ModContent.TileType()) - { - tile.type = TileID.SnowBlock; - } - else if (type == ModContent.TileType()) - { - tile.type = TileID.Silt; - } - else if (type == ModContent.TileType()) - { - tile.type = TileID.DesertFossil; - } - else if (type == ModContent.TileType()) - { - tile.type = TileID.ClayBlock; - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptGrass, TileID.FleshGrass, TileID.HallowedGrass, TileID.Grass); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.Ebonstone, TileID.Crimstone, TileID.Pearlstone, TileID.Stone); - } - else if (type == ModContent.TileType()) - { - tile.type = TileID.LivingWood; - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.Ebonsand, TileID.Crimsand, TileID.Pearlsand, TileID.Sand); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptSandstone, TileID.CrimsonSandstone, TileID.HallowSandstone, TileID.Sandstone); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptHardenedSand, TileID.CrimsonHardenedSand, TileID.HallowHardenedSand, TileID.HardenedSand); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptIce, TileID.FleshIce, TileID.HallowedIce, TileID.IceBlock); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, ushort.MaxValue, TileID.CrimsonVines, TileID.HallowedVines, TileID.Vines); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, TileID.CorruptPlants, ushort.MaxValue, TileID.HallowedPlants, TileID.Plants); - } - else if (type == ModContent.TileType()) - { - SetTileFromConvert(x, y, convert, ushort.MaxValue, ushort.MaxValue, TileID.HallowedPlants2, TileID.Plants2); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 378, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 18); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 0, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles2, x, y, 1566, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 1476, 18); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 972, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.LargePiles, x, y, 1404, 0); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 900, 18); - } - else if (type == ModContent.TileType()) - { - RecursiveReplaceFromAstral((ushort)type, TileID.SmallPiles, x, y, 648, 0); - } - else if (type == ModContent.TileType()) - { - ushort originType = TileID.Stone; - int frameXAdd = 54; - switch (convert) - { - case ConvertType.Corrupt: - originType = TileID.Ebonstone; - frameXAdd = 324; - break; - case ConvertType.Crimson: - originType = TileID.Crimstone; - frameXAdd = 270; - break; - case ConvertType.Hallow: - originType = TileID.Pearlstone; - frameXAdd = 216; - break; - } - ReplaceAstralStalactite((ushort)type, TileID.Stalactite, originType, x, y, frameXAdd, 0); - } - else if (type == ModContent.TileType()) - { - ushort originType = TileID.Sandstone; - int frameXAdd = 378; - switch (convert) - { - case ConvertType.Corrupt: - originType = TileID.CorruptSandstone; - frameXAdd = 324; - break; - case ConvertType.Crimson: - originType = TileID.CrimsonSandstone; - frameXAdd = 270; - break; - case ConvertType.Hallow: - originType = TileID.HallowSandstone; - frameXAdd = 216; - break; - } - ReplaceAstralStalactite((ushort)type, TileID.Stalactite, originType, x, y, frameXAdd, 0); - } - else if (type == ModContent.TileType()) - { - ReplaceAstralStalactite((ushort)type, TileID.Stalactite, TileID.IceBlock, x, y, 0, 0); - } - if (TileID.Sets.Conversion.Grass[type] || type == TileID.Dirt) - { - WorldGen.SquareTileFrame(x, y); - } - } - #endregion - - if (tileframe) - { - if (Main.netMode == NetmodeID.SinglePlayer) - { - WorldGen.SquareTileFrame(x, y, true); - } - else if (Main.netMode == NetmodeID.Server) - { - NetMessage.SendTileSquare(-1, x, y, 1); - } - } - } - } - - public static void SetTileFromConvert(int x, int y, ConvertType convert, ushort corrupt, ushort crimson, ushort hallow, ushort pure) - { - switch (convert) - { - case ConvertType.Corrupt: - if (corrupt != ushort.MaxValue) - { - Main.tile[x, y].type = corrupt; - WorldGen.SquareTileFrame(x, y); - } - break; - case ConvertType.Crimson: - if (crimson != ushort.MaxValue) - { - Main.tile[x, y].type = crimson; - WorldGen.SquareTileFrame(x, y); - } - break; - case ConvertType.Hallow: - if (hallow != ushort.MaxValue) - { - Main.tile[x, y].type = hallow; - WorldGen.SquareTileFrame(x, y); - } - break; - case ConvertType.Pure: - if (pure != ushort.MaxValue) - { - Main.tile[x, y].type = pure; - WorldGen.SquareTileFrame(x, y); - } - break; - } - } - - public static void RecursiveReplaceToAstral(ushort checkType, ushort replaceType, int x, int y, int replaceTextureWidth, int minFrameX = 0, int maxFrameX = int.MaxValue, int minFrameY = 0, int maxFrameY = int.MaxValue) - { - Tile tile = Main.tile[x, y]; - if (tile == null || !tile.active() || tile.type != checkType || tile.frameX < minFrameX || tile.frameX > maxFrameX || tile.frameY < minFrameY || tile.frameY > maxFrameY) - return; - - Main.tile[x, y].type = replaceType; - while (Main.tile[x, y].frameX >= replaceTextureWidth) - { - Main.tile[x, y].frameX -= (short)replaceTextureWidth; - } - - if (Main.tile[x - 1, y] != null) - RecursiveReplaceToAstral(checkType, replaceType, x - 1, y, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); - if (Main.tile[x + 1, y] != null) - RecursiveReplaceToAstral(checkType, replaceType, x + 1, y, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); - if (Main.tile[x, y - 1] != null) - RecursiveReplaceToAstral(checkType, replaceType, x, y - 1, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); - if (Main.tile[x, y + 1] != null) - RecursiveReplaceToAstral(checkType, replaceType, x, y + 1, replaceTextureWidth, minFrameX, maxFrameX, minFrameY, maxFrameY); - } - - public static void RecursiveReplaceFromAstral(ushort checkType, ushort replaceType, int x, int y, int addFrameX, int addFrameY) - { - Tile tile = Main.tile[x, y]; - if (tile == null || !tile.active() || tile.type != checkType) - return; - - Main.tile[x, y].type = replaceType; - Main.tile[x, y].frameX += (short)addFrameX; - Main.tile[x, y].frameY += (short)addFrameY; - - if (Main.tile[x - 1, y] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x - 1, y, addFrameX, addFrameY); - if (Main.tile[x + 1, y] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x + 1, y, addFrameX, addFrameY); - if (Main.tile[x, y - 1] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x, y - 1, addFrameX, addFrameY); - if (Main.tile[x, y + 1] != null) - RecursiveReplaceFromAstral(checkType, replaceType, x, y + 1, addFrameX, addFrameY); - } - - public static void ReplaceAstralStalactite(ushort checkType, ushort replaceType, ushort replaceOriginTile, int x, int y, int addFrameX, int addFrameY) - { - Tile tile = Main.tile[x, y]; - - int topMost = tile.frameY <= 54 ? (tile.frameY % 36 == 0 ? y : y - 1) : y; - bool twoTall = tile.frameY <= 54; - bool hanging = tile.frameY <= 18 || tile.frameY == 72; - - int yOriginTile = hanging ? topMost - 1 : (twoTall ? topMost + 2 : y + 1); - - if (Main.tile[x, topMost++] != null) - Main.tile[x, topMost++].type = replaceType; - if (twoTall) - { - if (Main.tile[x, topMost] != null) - Main.tile[x, topMost].type = replaceType; - } - if (Main.tile[x, yOriginTile] != null) - Main.tile[x, yOriginTile].type = replaceOriginTile; - } - - public static bool CheckInEllipse(Point tile, Vector2 focus1, Vector2 focus2, float distanceConstant, Vector2 center, out float distance, bool collapse = false) - { - Vector2 point = tile.ToVector2() * 16f + new Vector2(8f); - if (collapse) //Collapse ensures the ellipse is shrunk down a lot in terms of distance. - { - float distY = center.Y - point.Y; - point.Y -= distY * 8f; - } - float distance1 = Vector2.Distance(point, focus1); - float distance2 = Vector2.Distance(point, focus2); - distance = distance1 + distance2; - return distance <= distanceConstant; - } - #endregion - - #region EvilIsland - public static void EvilIsland(int i, int j) - { - double num = (double)WorldGen.genRand.Next(100, 150); - float num2 = (float)WorldGen.genRand.Next(20, 30); - int num3 = i; - int num4 = i; - int num5 = i; - int num6 = j; - Vector2 vector; - vector.X = (float)i; - vector.Y = (float)j; - Vector2 vector2; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - int num7 = (int)((double)vector.X - num * 0.5); - int num8 = (int)((double)vector.X + num * 0.5); - int num9 = (int)((double)vector.Y - num * 0.5); - int num10 = (int)((double)vector.Y + num * 0.5); - if (num7 < 0) - { - num7 = 0; - } - if (num8 > Main.maxTilesX) - { - num8 = Main.maxTilesX; - } - if (num9 < 0) - { - num9 = 0; - } - if (num10 > Main.maxTilesY) - { - num10 = Main.maxTilesY; - } - double num11 = num * (double)WorldGen.genRand.Next(80, 120) * 0.01; //80 120 - float num12 = vector.Y + 1f; - for (int k = num7; k < num8; k++) - { - if (WorldGen.genRand.Next(2) == 0) - { - num12 += (float)WorldGen.genRand.Next(-1, 2); - } - if (num12 < vector.Y) - { - num12 = vector.Y; - } - if (num12 > vector.Y + 2f) - { - num12 = vector.Y + 2f; - } - for (int l = num9; l < num10; l++) - { - if ((float)l > num12) - { - float arg_218_0 = Math.Abs((float)k - vector.X); - float num13 = Math.Abs((float)l - vector.Y) * 3f; - if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) - { - if (k < num3) - { - num3 = k; - } - if (k > num4) - { - num4 = k; - } - if (l < num5) - { - num5 = l; - } - if (l > num6) - { - num6 = l; - } - Main.tile[k, l].active(true); - Main.tile[k, l].type = (ushort)(WorldGen.crimson ? 400 : 401); //ebonstone or crimstone - WorldGen.SquareTileFrame(k, l, true); - } - } - } - } - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int m = num3; - int num15; - for (m += WorldGen.genRand.Next(5); m < num4; m += WorldGen.genRand.Next(num15, (int)((double)num15 * 1.5))) - { - int num14 = num6; - while (!Main.tile[m, num14].active()) - { - num14--; - } - num14 += WorldGen.genRand.Next(-3, 4); - num15 = WorldGen.genRand.Next(4, 8); - int num16 = WorldGen.crimson ? 400 : 401; - if (WorldGen.genRand.Next(4) == 0) - { - num16 = WorldGen.crimson ? 398 : 399; - } - for (int n = m - num15; n <= m + num15; n++) - { - for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) - { - if (num17 > num5) - { - float arg_409_0 = (float)Math.Abs(n - m); - float num18 = (float)(Math.Abs(num17 - num14) * 2); - if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) - { - Main.tile[n, num17].active(true); - Main.tile[n, num17].type = (ushort)num16; - WorldGen.SquareTileFrame(n, num17, true); - } - } - } - } - } - num = (double)WorldGen.genRand.Next(80, 95); - num2 = (float)WorldGen.genRand.Next(10, 15); - vector.X = (float)i; - vector.Y = (float)num5; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - int num7 = (int)((double)vector.X - num * 0.5); - int num8 = (int)((double)vector.X + num * 0.5); - int num9 = num5 - 1; - int num10 = (int)((double)vector.Y + num * 0.5); - if (num7 < 0) - { - num7 = 0; - } - if (num8 > Main.maxTilesX) - { - num8 = Main.maxTilesX; - } - if (num9 < 0) - { - num9 = 0; - } - if (num10 > Main.maxTilesY) - { - num10 = Main.maxTilesY; - } - double num11 = num * (double)WorldGen.genRand.Next(80, 120) * 0.01; - float num19 = vector.Y + 1f; - for (int num20 = num7; num20 < num8; num20++) - { - if (WorldGen.genRand.Next(2) == 0) - { - num19 += (float)WorldGen.genRand.Next(-1, 2); - } - if (num19 < vector.Y) - { - num19 = vector.Y; - } - if (num19 > vector.Y + 2f) - { - num19 = vector.Y + 2f; - } - for (int num21 = num9; num21 < num10; num21++) - { - if ((float)num21 > num19) - { - float arg_69E_0 = Math.Abs((float)num20 - vector.X); - float num22 = Math.Abs((float)num21 - vector.Y) * 3f; - if (Math.Sqrt((double)(arg_69E_0 * arg_69E_0 + num22 * num22)) < num11 * 0.4 && - Main.tile[num20, num21].type == (WorldGen.crimson ? 400 : 401)) - { - Main.tile[num20, num21].type = (ushort)(WorldGen.crimson ? 22 : 204); //ore - WorldGen.SquareTileFrame(num20, num21, true); - } - } - } - } - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int num23 = num3; - num23 += WorldGen.genRand.Next(5); - while (num23 < num4) - { - int num24 = num6; - while ((!Main.tile[num23, num24].active() || Main.tile[num23, num24].type != 0) && num23 < num4) - { - num24--; - if (num24 < num5) - { - num24 = num6; - num23 += WorldGen.genRand.Next(1, 4); - } - } - if (num23 < num4) - { - num24 += WorldGen.genRand.Next(0, 4); - int num25 = WorldGen.genRand.Next(2, 5); - int num26 = WorldGen.crimson ? 400 : 401; - for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) - { - for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) - { - if (num28 > num5) - { - float arg_890_0 = (float)Math.Abs(num27 - num23); - float num29 = (float)(Math.Abs(num28 - num24) * 2); - if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < (double)num25) - { - Main.tile[num27, num28].type = (ushort)num26; - WorldGen.SquareTileFrame(num27, num28, true); - } - } - } - } - num23 += WorldGen.genRand.Next(num25, (int)((double)num25 * 1.5)); - } - } - for (int num30 = num3 - 20; num30 <= num4 + 20; num30++) - { - for (int num31 = num5 - 20; num31 <= num6 + 20; num31++) - { - bool flag = true; - for (int num32 = num30 - 1; num32 <= num30 + 1; num32++) - { - for (int num33 = num31 - 1; num33 <= num31 + 1; num33++) - { - if (!Main.tile[num32, num33].active()) - { - flag = false; - } - } - } - if (flag) - { - Main.tile[num30, num31].wall = (ushort)(WorldGen.crimson ? 220 : 221); - WorldGen.SquareWallFrame(num30, num31, true); - } - } - } - for (int num34 = num3; num34 <= num4; num34++) - { - int num35 = num5 - 10; - while (!Main.tile[num34, num35 + 1].active()) - { - num35++; - } - if (num35 < num6 && Main.tile[num34, num35 + 1].type == (WorldGen.crimson ? 400 : 401)) - { - if (WorldGen.genRand.Next(10) == 0) - { - int num36 = WorldGen.genRand.Next(1, 3); - for (int num37 = num34 - num36; num37 <= num34 + num36; num37++) - { - if (Main.tile[num37, num35].type == (WorldGen.crimson ? 400 : 401)) - { - Main.tile[num37, num35].active(false); - Main.tile[num37, num35].liquid = 255; - Main.tile[num37, num35].lava(false); - WorldGen.SquareTileFrame(num34, num35, true); - } - if (Main.tile[num37, num35 + 1].type == (WorldGen.crimson ? 400 : 401)) - { - Main.tile[num37, num35 + 1].active(false); - Main.tile[num37, num35 + 1].liquid = 255; - Main.tile[num37, num35 + 1].lava(false); - WorldGen.SquareTileFrame(num34, num35 + 1, true); - } - if (num37 > num34 - num36 && num37 < num34 + 2 && Main.tile[num37, num35 + 2].type == (WorldGen.crimson ? 400 : 401)) - { - Main.tile[num37, num35 + 2].active(false); - Main.tile[num37, num35 + 2].liquid = 255; - Main.tile[num37, num35 + 2].lava(false); - WorldGen.SquareTileFrame(num34, num35 + 2, true); - } - } - } - if (WorldGen.genRand.Next(5) == 0) - { - Main.tile[num34, num35].liquid = 255; - } - Main.tile[num34, num35].lava(false); - WorldGen.SquareTileFrame(num34, num35, true); - } - } - int num38 = WorldGen.genRand.Next(4); - for (int num39 = 0; num39 <= num38; num39++) - { - int num40 = WorldGen.genRand.Next(num3 - 5, num4 + 5); - int num41 = num5 - WorldGen.genRand.Next(20, 40); - int num42 = WorldGen.genRand.Next(4, 8); - int num43 = WorldGen.crimson ? 400 : 401; - if (WorldGen.genRand.Next(2) == 0) - { - num43 = WorldGen.crimson ? 398 : 399; - } - for (int num44 = num40 - num42; num44 <= num40 + num42; num44++) - { - for (int num45 = num41 - num42; num45 <= num41 + num42; num45++) - { - float arg_C74_0 = (float)Math.Abs(num44 - num40); - float num46 = (float)(Math.Abs(num45 - num41) * 2); - if (Math.Sqrt((double)(arg_C74_0 * arg_C74_0 + num46 * num46)) < (double)(num42 + WorldGen.genRand.Next(-1, 2))) - { - Main.tile[num44, num45].active(true); - Main.tile[num44, num45].type = (ushort)num43; - WorldGen.SquareTileFrame(num44, num45, true); - } - } - } - for (int num47 = num40 - num42 + 2; num47 <= num40 + num42 - 2; num47++) - { - int num48 = num41 - num42; - while (!Main.tile[num47, num48].active()) - { - num48++; - } - Main.tile[num47, num48].active(false); - Main.tile[num47, num48].liquid = 255; - WorldGen.SquareTileFrame(num47, num48, true); - } - } - } - #endregion - - #region EvilIslandHouse - public static void EvilIslandHouse(int i, int j) - { - ushort type = (ushort)(WorldGen.crimson ? 152 : 347); //tile - byte wall = (byte)(WorldGen.crimson ? 35 : 174); //wall - Vector2 vector = new Vector2((float)i, (float)j); - int num = 1; - if (WorldGen.genRand.Next(2) == 0) - { - num = -1; - } - int num2 = WorldGen.genRand.Next(7, 12); - int num3 = WorldGen.genRand.Next(5, 7); - vector.X = (float)(i + (num2 + 2) * num); - for (int k = j - 15; k < j + 30; k++) - { - if (Main.tile[(int)vector.X, k].active()) - { - vector.Y = (float)(k - 1); - break; - } - } - vector.X = (float)i; - int num4 = (int)(vector.X - (float)num2 - 1f); - int num5 = (int)(vector.X + (float)num2 + 1f); - int num6 = (int)(vector.Y - (float)num3 - 1f); - int num7 = (int)(vector.Y + 2f); - if (num4 < 0) - { - num4 = 0; - } - if (num5 > Main.maxTilesX) - { - num5 = Main.maxTilesX; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int l = num4; l <= num5; l++) - { - for (int m = num6 - 1; m < num7 + 1; m++) - { - if (m != num6 - 1 || (l != num4 && l != num5)) - { - Main.tile[l, m].active(true); - Main.tile[l, m].liquid = 0; - Main.tile[l, m].type = type; - Main.tile[l, m].wall = 0; - Main.tile[l, m].halfBrick(false); - Main.tile[l, m].slope(0); - } - } - } - num4 = (int)(vector.X - (float)num2); - num5 = (int)(vector.X + (float)num2); - num6 = (int)(vector.Y - (float)num3); - num7 = (int)(vector.Y + 1f); - if (num4 < 0) - { - num4 = 0; - } - if (num5 > Main.maxTilesX) - { - num5 = Main.maxTilesX; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int n = num4; n <= num5; n++) - { - for (int num8 = num6; num8 < num7; num8++) - { - if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].wall == 0) - { - Main.tile[n, num8].active(false); - Main.tile[n, num8].wall = wall; - } - } - } - int num9 = i + (num2 + 1) * num; - int num10 = (int)vector.Y; - for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) - { - Main.tile[num11, num10].active(false); - Main.tile[num11, num10 - 1].active(false); - Main.tile[num11, num10 - 2].active(false); - } - WorldGen.PlaceTile(num9, num10, 10, true, false, -1, WorldGen.crimson ? 1 : 10); //door - num9 = i + (num2 + 1) * -num - num; - for (int num12 = num6; num12 <= num7 + 1; num12++) - { - Main.tile[num9, num12].active(true); - Main.tile[num9, num12].liquid = 0; - Main.tile[num9, num12].type = type; - Main.tile[num9, num12].wall = 0; - Main.tile[num9, num12].halfBrick(false); - Main.tile[num9, num12].slope(0); - } - int contain; - if (WorldGen.crimson) - { - contain = 1571; //scourge - } - else - { - contain = 1569; //vampire - } - WorldGen.AddBuriedChest(i, num10 - 3, contain, false, WorldGen.crimson ? 19 : 20); //chest - int num14 = i - num2 / 2 + 1; - int num15 = i + num2 / 2 - 1; - int num16 = 1; - if (num2 > 10) - { - num16 = 2; - } - int num17 = (num6 + num7) / 2 - 1; - for (int num18 = num14 - num16; num18 <= num14 + num16; num18++) - { - for (int num19 = num17 - 1; num19 <= num17 + 1; num19++) - { - Main.tile[num18, num19].wall = 21; //glass - } - } - for (int num20 = num15 - num16; num20 <= num15 + num16; num20++) - { - for (int num21 = num17 - 1; num21 <= num17 + 1; num21++) - { - Main.tile[num20, num21].wall = 21; //glass - } - } - int num22 = i + (num2 / 2 + 1) * -num; - WorldGen.PlaceTile(num22, num7 - 1, 14, true, false, -1, WorldGen.crimson ? 1 : 8); //table - WorldGen.PlaceTile(num22 - 2, num7 - 1, 15, true, false, 0, WorldGen.crimson ? 2 : 11); //chair - Tile tile = Main.tile[num22 - 2, num7 - 1]; - tile.frameX += 18; - Tile tile2 = Main.tile[num22 - 2, num7 - 2]; - tile2.frameX += 18; - WorldGen.PlaceTile(num22 + 2, num7 - 1, 15, true, false, 0, WorldGen.crimson ? 2 : 11); //chair - } - #endregion - - #region UnderworldIsland - public static void UnderworldIsland(int i, int j, int sizeMin, int sizeMax, int sizeMin2, int sizeMax2) - { - double num = (double)WorldGen.genRand.Next(sizeMin, sizeMax); //100 150 - float num2 = (float)WorldGen.genRand.Next(sizeMin / 5, sizeMax / 5); //20 30 - int num3 = i; - int num4 = i; - int num5 = i; - int num6 = j; - Vector2 vector; - vector.X = (float)i; - vector.Y = (float)j; - Vector2 vector2; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - int num7 = (int)((double)vector.X - num * 0.5); - int num8 = (int)((double)vector.X + num * 0.5); - int num9 = (int)((double)vector.Y - num * 0.5); - int num10 = (int)((double)vector.Y + num * 0.5); - if (num7 < 0) - { - num7 = 0; - } - if (num8 > Main.maxTilesX) - { - num8 = Main.maxTilesX; - } - if (num9 < Main.maxTilesY - 270) - { - num9 = Main.maxTilesY - 270; - } - if (num10 > Main.maxTilesY) - { - num10 = Main.maxTilesY; - } - double num11 = num * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 - float num12 = vector.Y + 1f; - for (int k = num7; k < num8; k++) - { - if (WorldGen.genRand.Next(2) == 0) - { - num12 += (float)WorldGen.genRand.Next(-1, 2); - } - if (num12 < vector.Y) - { - num12 = vector.Y; - } - if (num12 > vector.Y + 2f) - { - num12 = vector.Y + 2f; - } - for (int l = num9; l < num10; l++) - { - if ((float)l > num12) - { - float arg_218_0 = Math.Abs((float)k - vector.X); - float num13 = Math.Abs((float)l - vector.Y) * 3f; - if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) - { - if (k < num3) - { - num3 = k; - } - if (k > num4) - { - num4 = k; - } - if (l < num5) - { - num5 = l; - } - if (l > num6) - { - num6 = l; - } - Main.tile[k, l].active(true); - Main.tile[k, l].type = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(k, l, true); - } - } - } - } - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int m = num3; - int num15; - for (m += WorldGen.genRand.Next(5); m < num4; m += WorldGen.genRand.Next(num15, (int)((double)num15 * 1.5))) - { - int num14 = num6; - while (!Main.tile[m, num14].active()) - { - num14--; - if (num14 < Main.maxTilesX - WorldGen.genRand.Next(265, 275 + 1)) - break; - } - num14 += WorldGen.genRand.Next(-3, 4); - num15 = WorldGen.genRand.Next(4, 8); - int num16 = ModContent.TileType(); - if (WorldGen.genRand.Next(4) == 0) - { - num16 = ModContent.TileType(); - } - for (int n = m - num15; n <= m + num15; n++) - { - for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) - { - if (num17 > num5) - { - float arg_409_0 = (float)Math.Abs(n - m); - float num18 = (float)(Math.Abs(num17 - num14) * 2); - if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) - { - Main.tile[n, num17].active(true); - Main.tile[n, num17].type = (ushort)num16; - WorldGen.SquareTileFrame(n, num17, true); - } - } - } - } - } - num = (double)WorldGen.genRand.Next(sizeMin2, sizeMax2); - num2 = (float)WorldGen.genRand.Next(sizeMin2 / 8, sizeMax2 / 8); - vector.X = (float)i; - vector.Y = (float)num5; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int num23 = num3; - num23 += WorldGen.genRand.Next(5); - while (num23 < num4) - { - int num24 = num6; - while ((!Main.tile[num23, num24].active() || Main.tile[num23, num24].type != 0) && num23 < num4) - { - num24--; - if (num24 < num5) - { - num24 = num6; - num23 += WorldGen.genRand.Next(1, 4); - } - } - if (num23 < num4) - { - num24 += WorldGen.genRand.Next(0, 4); - int num25 = WorldGen.genRand.Next(2, 5); - int num26 = ModContent.TileType(); - for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) - { - for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) - { - if (num28 > num5) - { - float arg_890_0 = (float)Math.Abs(num27 - num23); - float num29 = (float)(Math.Abs(num28 - num24) * 2); - if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < (double)num25) - { - Main.tile[num27, num28].type = (ushort)num26; - WorldGen.SquareTileFrame(num27, num28, true); - } - } - } - } - num23 += WorldGen.genRand.Next(num25, (int)((double)num25 * 1.5)); - } - } - for (int num34 = num3; num34 <= num4; num34++) - { - int num35 = num5 - 10; - while (!Main.tile[num34, num35 + 1].active()) - { - num35++; - } - if (num35 < num6 && Main.tile[num34, num35 + 1].type == (ushort)ModContent.TileType()) - { - if (WorldGen.genRand.Next(10) == 0) - { - int num36 = WorldGen.genRand.Next(1, 3); - for (int num37 = num34 - num36; num37 <= num34 + num36; num37++) - { - if (Main.tile[num37, num35].type == (ushort)ModContent.TileType()) - { - Main.tile[num37, num35].active(false); - Main.tile[num37, num35].liquid = 255; - Main.tile[num37, num35].lava(false); - WorldGen.SquareTileFrame(num34, num35, true); - } - if (Main.tile[num37, num35 + 1].type == (ushort)ModContent.TileType()) - { - Main.tile[num37, num35 + 1].active(false); - Main.tile[num37, num35 + 1].liquid = 255; - Main.tile[num37, num35 + 1].lava(false); - WorldGen.SquareTileFrame(num34, num35 + 1, true); - } - if (num37 > num34 - num36 && num37 < num34 + 2 && Main.tile[num37, num35 + 2].type == (ushort)ModContent.TileType()) - { - Main.tile[num37, num35 + 2].active(false); - Main.tile[num37, num35 + 2].liquid = 255; - Main.tile[num37, num35 + 2].lava(false); - WorldGen.SquareTileFrame(num34, num35 + 2, true); - } - } - } - if (WorldGen.genRand.Next(5) == 0) - { - Main.tile[num34, num35].liquid = 255; - } - Main.tile[num34, num35].lava(false); - WorldGen.SquareTileFrame(num34, num35, true); - } - } - } - #endregion - - #region UnderworldIslandHouse - public static void UnderworldIslandHouse(int i, int j, int item) - { - ushort type = (ushort)ModContent.TileType(); //tile - byte wall = (byte)ModContent.WallType(); //wall - Vector2 vector = new Vector2((float)i, (float)j); - int num = 1; - if (WorldGen.genRand.Next(2) == 0) - { - num = -1; - } - int num2 = WorldGen.genRand.Next(7, 12); - int num3 = WorldGen.genRand.Next(5, 7); - vector.X = (float)(i + (num2 + 2) * num); - for (int k = j - 15; k < j + 30; k++) - { - if (Main.tile[(int)vector.X, k].active()) - { - vector.Y = (float)(k - 1); - break; - } - } - vector.X = (float)i; - int num4 = (int)(vector.X - (float)num2 - 1f); - int num5 = (int)(vector.X + (float)num2 + 1f); - int num6 = (int)(vector.Y - (float)num3 - 1f); - int num7 = (int)(vector.Y + 2f); - if (num4 < 0) - { - num4 = 0; - } - if (num5 > Main.maxTilesX) - { - num5 = Main.maxTilesX; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int l = num4; l <= num5; l++) - { - for (int m = num6 - 1; m < num7 + 1; m++) - { - if (m != num6 - 1 || (l != num4 && l != num5)) - { - Main.tile[l, m].active(true); - Main.tile[l, m].liquid = 0; - Main.tile[l, m].type = type; - Main.tile[l, m].wall = 0; - Main.tile[l, m].halfBrick(false); - Main.tile[l, m].slope(0); - } - } - } - num4 = (int)(vector.X - (float)num2); - num5 = (int)(vector.X + (float)num2); - num6 = (int)(vector.Y - (float)num3); - num7 = (int)(vector.Y + 1f); - if (num4 < 0) - { - num4 = 0; - } - if (num5 > Main.maxTilesX) - { - num5 = Main.maxTilesX; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int n = num4; n <= num5; n++) - { - for (int num8 = num6; num8 < num7; num8++) - { - if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].wall == 0) - { - Main.tile[n, num8].active(false); - Main.tile[n, num8].wall = wall; - } - } - } - int num9 = i + (num2 + 1) * num; - int num10 = (int)vector.Y; - for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) - { - Main.tile[num11, num10].active(false); - Main.tile[num11, num10 - 1].active(false); - Main.tile[num11, num10 - 2].active(false); - } - WorldGen.PlaceTile(num9, num10, ModContent.TileType(), true, false, -1); //door - num9 = i + (num2 + 1) * -num - num; - for (int num12 = num6; num12 <= num7 + 1; num12++) - { - Main.tile[num9, num12].active(true); - Main.tile[num9, num12].liquid = 0; - Main.tile[num9, num12].type = type; - Main.tile[num9, num12].wall = 0; - Main.tile[num9, num12].halfBrick(false); - Main.tile[num9, num12].slope(0); - } - WorldGen.AddBuriedChest(i, num10 - 3, item, false, 4); //chest - int num22 = i + (num2 / 2 + 1) * -num; - WorldGen.PlaceTile(num22, num7 - 1, ModContent.TileType(), true, false, -1); //table - WorldGen.PlaceTile(num22 - 2, num7 - 1, ModContent.TileType(), true, false, 0); //chair - Tile tile = Main.tile[num22 - 2, num7 - 1]; - tile.frameX += 18; - Tile tile2 = Main.tile[num22 - 2, num7 - 2]; - tile2.frameX += 18; - WorldGen.PlaceTile(num22 + 2, num7 - 1, ModContent.TileType(), true, false, 0); //chair - } - #endregion - - #region AbyssIsland - public static void AbyssIsland(int i, int j, int sizeMin, int sizeMax, int sizeMin2, int sizeMax2, bool hasChest, bool hasTenebris, bool isVoid) - { - int sizeMinSmall = sizeMin / 5; - int sizeMaxSmall = sizeMax / 5; - double num = (double)WorldGen.genRand.Next(sizeMin, sizeMax); //100 150 - float num2 = (float)WorldGen.genRand.Next(sizeMinSmall, sizeMaxSmall); //20 30 - int num3 = i; - int num4 = i; - int num5 = i; - int num6 = j; - Vector2 vector; - vector.X = (float)i; - vector.Y = (float)j; - Vector2 vector2; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - int num7 = (int)((double)vector.X - num * 0.5); - int num8 = (int)((double)vector.X + num * 0.5); - int num9 = (int)((double)vector.Y - num * 0.5); - int num10 = (int)((double)vector.Y + num * 0.5); - if (num7 < 0) - { - num7 = 0; - } - if (num8 > Main.maxTilesX) - { - num8 = Main.maxTilesX; - } - if (num9 < 0) - { - num9 = 0; - } - if (num10 > Main.maxTilesY) - { - num10 = Main.maxTilesY; - } - double num11 = num * (double)WorldGen.genRand.Next(sizeMin, sizeMax) * 0.01; //80 120 - float num12 = vector.Y + 1f; - for (int k = num7; k < num8; k++) - { - if (WorldGen.genRand.Next(2) == 0) - { - num12 += (float)WorldGen.genRand.Next(-1, 2); - } - if (num12 < vector.Y) - { - num12 = vector.Y; - } - if (num12 > vector.Y + 2f) - { - num12 = vector.Y + 2f; - } - for (int l = num9; l < num10; l++) - { - if ((float)l > num12) - { - float arg_218_0 = Math.Abs((float)k - vector.X); - float num13 = Math.Abs((float)l - vector.Y) * 3f; - if (Math.Sqrt((double)(arg_218_0 * arg_218_0 + num13 * num13)) < num11 * 0.4) - { - if (k < num3) - { - num3 = k; - } - if (k > num4) - { - num4 = k; - } - if (l < num5) - { - num5 = l; - } - if (l > num6) - { - num6 = l; - } - Main.tile[k, l].active(true); - Main.tile[k, l].type = (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType()); - CalamityUtils.SafeSquareTileFrame(k, l, true); - } - } - } - } - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int m = num3; - int num15; - for (m += WorldGen.genRand.Next(5); m < num4; m += WorldGen.genRand.Next(num15, (int)((double)num15 * 1.5))) - { - int num14 = num6; - while (!Main.tile[m, num14].active()) - { - num14--; - } - num14 += WorldGen.genRand.Next(-3, 4); - num15 = WorldGen.genRand.Next(4, 8); - int num16 = isVoid ? ModContent.TileType() : ModContent.TileType(); - if (WorldGen.genRand.Next(4) == 0) - { - num16 = hasChest ? ModContent.TileType() : ModContent.TileType(); - } - for (int n = m - num15; n <= m + num15; n++) - { - for (int num17 = num14 - num15; num17 <= num14 + num15; num17++) - { - if (num17 > num5) - { - float arg_409_0 = (float)Math.Abs(n - m); - float num18 = (float)(Math.Abs(num17 - num14) * 2); - if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num15 + WorldGen.genRand.Next(2))) - { - Main.tile[n, num17].active(true); - Main.tile[n, num17].type = (ushort)num16; - CalamityUtils.SafeSquareTileFrame(n, num17, true); - } - } - } - } - } - if (hasTenebris) - { - int p = num3; - int num150; - for (p += WorldGen.genRand.Next(5); p < num4; p += WorldGen.genRand.Next(num150, (int)((double)num150 * 1.5))) - { - int num14 = num6; - while (!Main.tile[p, num14].active()) - { - num14--; - } - num14 += WorldGen.genRand.Next(-3, 4); //-3 4 - num150 = 1; //4 8 - int num16 = ModContent.TileType(); - for (int n = p - num150; n <= p + num150; n++) - { - for (int num17 = num14 - num150; num17 <= num14 + num150; num17++) - { - if (num17 > num5) - { - float arg_409_0 = (float)Math.Abs(n - p); - float num18 = (float)(Math.Abs(num17 - num14) * 2); - if (Math.Sqrt((double)(arg_409_0 * arg_409_0 + num18 * num18)) < (double)(num150 + WorldGen.genRand.Next(2))) - { - Main.tile[n, num17].active(true); - Main.tile[n, num17].type = (ushort)num16; - CalamityUtils.SafeSquareTileFrame(n, num17, true); - } - } - } - } - } - } - int sizeMinSmall2 = sizeMin2 / 8; - int sizeMaxSmall2 = sizeMax2 / 8; - num = (double)WorldGen.genRand.Next(sizeMin2, sizeMax2); - num2 = (float)WorldGen.genRand.Next(sizeMinSmall2, sizeMaxSmall2); - vector.X = (float)i; - vector.Y = (float)num5; - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - while (vector2.X > -2f && vector2.X < 2f) - { - vector2.X = (float)WorldGen.genRand.Next(-20, 21) * 0.2f; - } - vector2.Y = (float)WorldGen.genRand.Next(-20, -10) * 0.02f; - while (num > 0.0 && num2 > 0f) - { - num -= (double)WorldGen.genRand.Next(4); - num2 -= 1f; - vector += vector2; - vector2.X += (float)WorldGen.genRand.Next(-20, 21) * 0.05f; - if (vector2.X > 1f) - { - vector2.X = 1f; - } - if (vector2.X < -1f) - { - vector2.X = -1f; - } - if ((double)vector2.Y > 0.2) - { - vector2.Y = -0.2f; - } - if ((double)vector2.Y < -0.2) - { - vector2.Y = -0.2f; - } - } - int num23 = num3; - num23 += WorldGen.genRand.Next(5); - while (num23 < num4) - { - int num24 = num6; - while ((!Main.tile[num23, num24].active() || Main.tile[num23, num24].type != 0) && num23 < num4) - { - num24--; - if (num24 < num5) - { - num24 = num6; - num23 += WorldGen.genRand.Next(1, 4); - } - } - if (num23 < num4) - { - num24 += WorldGen.genRand.Next(0, 4); - int num25 = WorldGen.genRand.Next(2, 5); - int num26 = isVoid ? ModContent.TileType() : ModContent.TileType(); - for (int num27 = num23 - num25; num27 <= num23 + num25; num27++) - { - for (int num28 = num24 - num25; num28 <= num24 + num25; num28++) - { - if (num28 > num5) - { - float arg_890_0 = (float)Math.Abs(num27 - num23); - float num29 = (float)(Math.Abs(num28 - num24) * 2); - if (Math.Sqrt((double)(arg_890_0 * arg_890_0 + num29 * num29)) < (double)num25) - { - Main.tile[num27, num28].type = (ushort)num26; - CalamityUtils.SafeSquareTileFrame(num27, num28, true); - } - } - } - } - num23 += WorldGen.genRand.Next(num25, (int)((double)num25 * 1.5)); - } - } - for (int num30 = num3 - 20; num30 <= num4 + 20; num30++) - { - for (int num31 = num5 - 20; num31 <= num6 + 20; num31++) - { - bool flag = true; - for (int num32 = num30 - 1; num32 <= num30 + 1; num32++) - { - for (int num33 = num31 - 1; num33 <= num31 + 1; num33++) - { - if (!Main.tile[num32, num33].active()) - { - flag = false; - } - } - } - if (flag) - { - Main.tile[num30, num31].wall = (ushort)(isVoid ? ModContent.WallType() : ModContent.WallType()); - WorldGen.SquareWallFrame(num30, num31, true); - } - } - } - for (int num34 = num3; num34 <= num4; num34++) - { - int num35 = num5 - 10; - while (!Main.tile[num34, num35 + 1].active()) - { - num35++; - } - if (num35 < num6 && Main.tile[num34, num35 + 1].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) - { - if (WorldGen.genRand.Next(10) == 0) - { - int num36 = WorldGen.genRand.Next(1, 3); - for (int num37 = num34 - num36; num37 <= num34 + num36; num37++) - { - if (Main.tile[num37, num35].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) - { - Main.tile[num37, num35].active(false); - Main.tile[num37, num35].liquid = 255; - Main.tile[num37, num35].lava(false); - CalamityUtils.SafeSquareTileFrame(num34, num35, true); - } - if (Main.tile[num37, num35 + 1].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) - { - Main.tile[num37, num35 + 1].active(false); - Main.tile[num37, num35 + 1].liquid = 255; - Main.tile[num37, num35 + 1].lava(false); - CalamityUtils.SafeSquareTileFrame(num34, num35 + 1, true); - } - if (num37 > num34 - num36 && num37 < num34 + 2 && Main.tile[num37, num35 + 2].type == (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType())) - { - Main.tile[num37, num35 + 2].active(false); - Main.tile[num37, num35 + 2].liquid = 255; - Main.tile[num37, num35 + 2].lava(false); - CalamityUtils.SafeSquareTileFrame(num34, num35 + 2, true); - } - } - } - if (WorldGen.genRand.Next(5) == 0) - { - Main.tile[num34, num35].liquid = 255; - } - Main.tile[num34, num35].lava(false); - CalamityUtils.SafeSquareTileFrame(num34, num35, true); - } - } - } - #endregion - - #region AbyssIslandHouse - public static void AbyssIslandHouse(int i, int j, int itemChoice, bool isVoid) - { - ushort type = (ushort)(isVoid ? ModContent.TileType() : ModContent.TileType()); //tile - ushort wall = (ushort)(isVoid ? ModContent.WallType() : ModContent.WallType()); //wall - Vector2 vector = new Vector2((float)i, (float)j); - int num = 1; - if (WorldGen.genRand.Next(2) == 0) - { - num = -1; - } - int num2 = WorldGen.genRand.Next(5, 9); - int num3 = 3; - vector.X = (float)(i + (num2 + 2) * num); - for (int k = j - 15; k < j + 30; k++) - { - if (Main.tile[(int)vector.X, k].active()) - { - vector.Y = (float)(k - 1); - break; - } - } - vector.X = (float)i; - int num4 = (int)(vector.X - (float)num2 - 1f); - int num5 = (int)(vector.X + (float)num2 + 1f); - int num6 = (int)(vector.Y - (float)num3 - 1f); - int num7 = (int)(vector.Y + 2f); - if (num4 < 0) - { - num4 = 0; - } - if (num5 > Main.maxTilesX) - { - num5 = Main.maxTilesX; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int l = num4; l <= num5; l++) - { - for (int m = num6 - 1; m < num7 + 1; m++) - { - if (m != num6 - 1 || (l != num4 && l != num5)) - { - Main.tile[l, m].active(true); - Main.tile[l, m].type = type; - Main.tile[l, m].wall = wall; - Main.tile[l, m].halfBrick(false); - Main.tile[l, m].slope(0); - } - } - } - num4 = (int)(vector.X - (float)num2); - num5 = (int)(vector.X + (float)num2); - num6 = (int)(vector.Y - (float)num3); - num7 = (int)(vector.Y + 1f); - if (num4 < 0) - { - num4 = 0; - } - if (num5 > Main.maxTilesX) - { - num5 = Main.maxTilesX; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int n = num4; n <= num5; n++) - { - for (int num8 = num6; num8 < num7; num8++) - { - if ((num8 != num6 || (n != num4 && n != num5)) && Main.tile[n, num8].wall == wall) - { - Main.tile[n, num8].active(false); - } - } - } - int num9 = i + (num2 + 1) * num; - int num10 = (int)vector.Y; - for (int num11 = num9 - 2; num11 <= num9 + 2; num11++) - { - Main.tile[num11, num10].active(false); - Main.tile[num11, num10 - 1].active(false); - Main.tile[num11, num10 - 2].active(false); - } - switch (itemChoice) - { - case 0: - itemChoice = ModContent.ItemType(); - break; //rain item - case 1: - itemChoice = ModContent.ItemType(); - break; //movement acc - case 2: - itemChoice = ModContent.ItemType(); - break; //regen acc - case 3: - itemChoice = ModContent.ItemType(); - break; //ranged - case 4: - itemChoice = ModContent.ItemType(); - break; //defense acc - case 5: - itemChoice = ModContent.ItemType(); - break; //melee - case 6: - itemChoice = ModContent.ItemType(); - break; //light pet - case 7: - itemChoice = ModContent.ItemType(); - break; //summon - case 8: - itemChoice = ModContent.ItemType(); - break; //magic - case 9: - itemChoice = ModContent.ItemType(); - break; //throwing - default: - itemChoice = 497; - break; - } - WorldGen.AddBuriedChest(i, num10 - 3, itemChoice, false, 4); //chest - } - #endregion - - #region SpecialHut - // Special Hut: Takes arguments of tile type 1, tile type 2, wall type, hut type (useful if you use this method to generate different huts), and location of the shrine (x and y) - public static void SpecialHut(ushort tile, ushort tile2, ushort wall, int hutType, int shrineLocationX, int shrineLocationY) - { - // Random variables for shrine size - int randomX = WorldGen.genRand.Next(2, 4); - int randomY = WorldGen.genRand.Next(2, 4); - - // Replace tiles in shrine area with shrine tile type 1 - for (int n = shrineLocationX - randomX - 1; n <= shrineLocationX + randomX + 1; n++) - { - for (int num8 = shrineLocationY - randomY - 1; num8 <= shrineLocationY + randomY + 1; num8++) - { - Main.tile[n, num8].active(true); - Main.tile[n, num8].type = tile; - Main.tile[n, num8].slope(0); - Main.tile[n, num8].liquid = 0; - Main.tile[n, num8].lava(false); - } - } - - // Replace walls in shrine area with shrine wall type - for (int num9 = shrineLocationX - randomX; num9 <= shrineLocationX + randomX; num9++) - { - for (int num10 = shrineLocationY - randomY; num10 <= shrineLocationY + randomY; num10++) - { - Main.tile[num9, num10].active(false); - Main.tile[num9, num10].wall = wall; - } - } - - // Remove tiles from the inner part of the shrine area - for (int num14 = shrineLocationX - randomX - 1; num14 <= shrineLocationX + randomX + 1; num14++) - { - for (int num15 = shrineLocationY + randomY - 2; num15 <= shrineLocationY + randomY; num15++) - Main.tile[num14, num15].active(false); - } - for (int num16 = shrineLocationX - randomX - 1; num16 <= shrineLocationX + randomX + 1; num16++) - { - for (int num17 = shrineLocationY + randomY - 2; num17 <= shrineLocationY + randomY - 1; num17++) - Main.tile[num16, num17].active(false); - } - - // Replace tiles from bottom of shrine area with shrine tile type 2 - for (int num18 = shrineLocationX - randomX - 1; num18 <= shrineLocationX + randomX + 1; num18++) - { - int num19 = 4; - int num20 = shrineLocationY + randomY + 2; - while (!Main.tile[num18, num20].active() && num20 < Main.maxTilesY && num19 > 0) - { - Main.tile[num18, num20].active(true); - Main.tile[num18, num20].type = tile2; - Main.tile[num18, num20].slope(0); - num20++; - num19--; - } - } - - // Replace tiles from top of shrine with shrine tile type 1 - randomX -= WorldGen.genRand.Next(1, 3); - int num21 = shrineLocationY - randomY - 2; - while (randomX > -1) - { - for (int num22 = shrineLocationX - randomX - 1; num22 <= shrineLocationX + randomX + 1; num22++) - { - Main.tile[num22, num21].active(true); - Main.tile[num22, num21].type = tile; - } - randomX -= WorldGen.genRand.Next(1, 3); - num21--; - } - - // Place shrine chest - CalamityWorld.SChestX[hutType] = shrineLocationX; - CalamityWorld.SChestY[hutType] = shrineLocationY; - SpecialChest(hutType); - } - #endregion - - #region SpecialChest - // Special Chest: Used for placing shrine chests, takes argument of item choice which dictates what item will spawn in the first slot of this chest - public static void SpecialChest(int itemChoice) - { - int item = 0; - int chestType = 0; - - switch (itemChoice) //0 to 9 - { - case 0: - item = ModContent.ItemType(); - break; - case 1: - item = WorldGen.crimson ? ModContent.ItemType() : ModContent.ItemType(); - chestType = WorldGen.crimson ? 43 : 3; - break; - case 2: - item = ModContent.ItemType(); - chestType = 44; - break; - case 3: - item = ModContent.ItemType(); - chestType = 47; - break; - case 4: - item = ModContent.ItemType(); - chestType = 30; - break; - case 5: - item = ModContent.ItemType(); - chestType = 32; - break; - case 6: - item = ModContent.ItemType(); - chestType = 50; - break; - case 7: - item = ModContent.ItemType(); - chestType = 51; - break; - case 8: - item = ModContent.ItemType(); - chestType = 4; - break; - } - - // Destroy tiles in chest spawn location - for (int j = CalamityWorld.SChestX[itemChoice] - 1; j <= CalamityWorld.SChestX[itemChoice] + 1; j++) - { - for (int k = CalamityWorld.SChestY[itemChoice]; k <= CalamityWorld.SChestY[itemChoice] + 2; k++) - WorldGen.KillTile(j, k, false, false, false); - } - - // Attempt to fix sloped tiles under the chest to prevent the chest from killing itself (literally) - for (int l = CalamityWorld.SChestX[itemChoice] - 1; l <= CalamityWorld.SChestX[itemChoice] + 1; l++) - { - for (int m = CalamityWorld.SChestY[itemChoice]; m <= CalamityWorld.SChestY[itemChoice] + 3; m++) - { - if (m < Main.maxTilesY) - { - Main.tile[l, m].slope(0); - Main.tile[l, m].halfBrick(false); - } - } - } - - // Place the chest, finally - WorldGen.AddBuriedChest(CalamityWorld.SChestX[itemChoice], CalamityWorld.SChestY[itemChoice], item, false, chestType); - } - #endregion - - #region ChasmGenerator - public static void ChasmGenerator(int i, int j, int steps, bool ocean = false) - { - float num = steps; //850 small 1450 medium 2050 large - if (ocean) - { - int tileYLookup = j; - if (CalamityWorld.abyssSide) - { - while (!Main.tile[i + 125, tileYLookup].active()) - { - tileYLookup++; - } - } - else - { - while (!Main.tile[i - 125, tileYLookup].active()) - { - tileYLookup++; - } - } - j = tileYLookup; - } - Vector2 vector; - vector.X = i; - vector.Y = j; - Vector2 vector2; - vector2.X = WorldGen.genRand.Next(-1, 2) * 0.1f; - vector2.Y = WorldGen.genRand.Next(3, 8) * 0.2f + 0.5f; - int num2 = 5; - double num3 = WorldGen.genRand.Next(5, 7) + 20; //start width - while (num3 > 0.0) - { - if (num > 0f) - { - num3 += WorldGen.genRand.Next(2); - num3 -= WorldGen.genRand.Next(2); - float smallHoleLimit = 790f; //small - if (Main.maxTilesY > 1500) - { smallHoleLimit = 1360f; if (Main.maxTilesY > 2100) { smallHoleLimit = 1950f; } } - if (ocean && num > smallHoleLimit) - { - if (num3 < 7.0) //min width - { - num3 = 7.0; //min width - } - if (num3 > 11.0) //max width - { - num3 = 11.0; //max width - } - } - else //dig large hole - { - if (num3 < (ocean ? 45.0 : 8.0)) //min width - { - num3 = ocean ? 45.0 : 8.0; //min width - } - if (num3 > (ocean ? 50.0 : 20.0)) //max width - { - num3 = ocean ? 50.0 : 20.0; //max width - } - if (num == 1f && num3 < (ocean ? 50.0 : 15.0)) - { - num3 = ocean ? 50.0 : 15.0; - } - } - } - else - { - if ((double)vector.Y > CalamityWorld.abyssChasmBottom) - { - num3 -= WorldGen.genRand.Next(5) + 8; - } - } - if (Main.maxTilesY > 2100) - { - if (((double)vector.Y > CalamityWorld.abyssChasmBottom && num > 0f && ocean) || - (vector.Y >= Main.maxTilesY && num > 0f && !ocean)) - { - num = 0f; - } - } - else if (Main.maxTilesY > 1500) - { - if (((double)vector.Y > CalamityWorld.abyssChasmBottom && num > 0f && ocean) || - (vector.Y > Main.maxTilesY && num > 0f && !ocean)) - { - num = 0f; - } - } - else - { - if (((double)vector.Y > CalamityWorld.abyssChasmBottom && num > 0f && ocean) || - (vector.Y > Main.maxTilesY && num > 0f && !ocean)) - { - num = 0f; - } - } - num -= 1f; - int num4; - int num5; - int num6; - int num7; - if (num > num2) - { - num4 = (int)(vector.X - num3 * 0.5); - num5 = (int)(vector.X + num3 * 0.5); - num6 = (int)(vector.Y - num3 * 0.5); - num7 = (int)(vector.Y + num3 * 0.5); - if (num4 < 0) - { - num4 = 0; - } - if (num5 > Main.maxTilesX - 1) - { - num5 = Main.maxTilesX - 1; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int k = num4; k < num5; k++) - { - for (int l = num6; l < num7; l++) - { - if ((Math.Abs(k - vector.X) + Math.Abs(l - vector.Y)) < num3 * 0.5 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) - { - if (ocean) - { - Main.tile[k, l].active(false); - Main.tile[k, l].liquid = 255; - Main.tile[k, l].lava(false); - } - else - { - Main.tile[k, l].active(false); - Main.tile[k, l].liquid = 255; - Main.tile[k, l].lava(true); - } - } - } - } - } - /*if (num <= 2f && vector.Y < (Main.rockLayer + Main.maxTilesY * 0.3)) - { - num = 2f; - }*/ - vector += vector2; - vector2.X += WorldGen.genRand.Next(-1, 2) * 0.01f; - if (vector2.X > 0.02) - { - vector2.X = 0.02f; - } - if (vector2.X < -0.02) - { - vector2.X = -0.02f; - } - num4 = (int)(vector.X - num3 * 1.1); - num5 = (int)(vector.X + num3 * 1.1); - num6 = (int)(vector.Y - num3 * 1.1); - num7 = (int)(vector.Y + num3 * 1.1); - if (num4 < 1) - { - num4 = 1; - } - if (num5 > Main.maxTilesX - 1) - { - num5 = Main.maxTilesX - 1; - } - if (num6 < 0) - { - num6 = 0; - } - if (num7 > Main.maxTilesY) - { - num7 = Main.maxTilesY; - } - for (int m = num4; m < num5; m++) - { - for (int n = num6; n < num7; n++) - { - if ((Math.Abs(m - vector.X) + Math.Abs(n - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) - { - if (n > j + WorldGen.genRand.Next(7, 16)) - { - Main.tile[m, n].active(false); - } - if (steps <= num2) - { - Main.tile[m, n].active(false); - } - if (ocean) - { - Main.tile[m, n].liquid = 255; - Main.tile[m, n].lava(false); - } - else - { - Main.tile[m, n].liquid = 255; - Main.tile[m, n].lava(true); - } - } - } - } - for (int num11 = num4; num11 < num5; num11++) - { - for (int num12 = num6; num12 < num7; num12++) - { - if ((Math.Abs(num11 - vector.X) + Math.Abs(num12 - vector.Y)) < num3 * 1.1 * (1.0 + WorldGen.genRand.Next(-5, 6) * 0.015)) - { - if (ocean) - { - Main.tile[num11, num12].liquid = 255; - Main.tile[num11, num12].lava(false); - } - else - { - Main.tile[num11, num12].liquid = 255; - Main.tile[num11, num12].lava(true); - } - if (steps <= num2) - { - Main.tile[num11, num12].active(false); - } - } - } - } - } - } - #endregion - - #region PlaceTits - public static void PlaceTit(int x, int y, ushort type = 165) - { - if (Main.tile[x, y - 1] == null) - { - Main.tile[x, y - 1] = new Tile(); - } - if (Main.tile[x, y] == null) - { - Main.tile[x, y] = new Tile(); - } - if (Main.tile[x, y + 1] == null) - { - Main.tile[x, y + 1] = new Tile(); - } - if (WorldGen.SolidTile(x, y - 1) && !Main.tile[x, y].active() && !Main.tile[x, y + 1].active()) - { - if (Main.tile[x, y - 1].type == (ushort)ModContent.TileType()) - { - if (WorldGen.genRand.Next(2) == 0 || Main.tile[x, y + 2].active()) - { - int num2 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y].type = type; - Main.tile[x, y].active(true); - Main.tile[x, y].frameX = (short)num2; - Main.tile[x, y].frameY = 72; - } - else - { - int num3 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y].type = type; - Main.tile[x, y].active(true); - Main.tile[x, y].frameX = (short)num3; - Main.tile[x, y].frameY = 0; - Main.tile[x, y + 1].type = type; - Main.tile[x, y + 1].active(true); - Main.tile[x, y + 1].frameX = (short)num3; - Main.tile[x, y + 1].frameY = 18; - } - } - } - else - { - if (WorldGen.SolidTile(x, y + 1) && !Main.tile[x, y].active() && !Main.tile[x, y - 1].active()) - { - if (Main.tile[x, y + 1].type == (ushort)ModContent.TileType()) - { - if (WorldGen.genRand.Next(2) == 0 || Main.tile[x, y - 2].active()) - { - int num13 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y].type = type; - Main.tile[x, y].active(true); - Main.tile[x, y].frameX = (short)num13; - Main.tile[x, y].frameY = 90; - } - else - { - int num14 = WorldGen.genRand.Next(3) * 18; - Main.tile[x, y - 1].type = type; - Main.tile[x, y - 1].active(true); - Main.tile[x, y - 1].frameX = (short)num14; - Main.tile[x, y - 1].frameY = 36; - Main.tile[x, y].type = type; - Main.tile[x, y].active(true); - Main.tile[x, y].frameX = (short)num14; - Main.tile[x, y].frameY = 54; - } - } - } - } - } - #endregion - - #region Planetoids - - public static void GenerateLuminitePlanetoids() - { - // Don't attempt to generate these things client-side. - if (Main.netMode == NetmodeID.MultiplayerClient) - return; - - // The worldgen structure map only gets created/regenerated when you generate a world, for some reason. - // This means if you simply enter a world and generate this planetoid, the map will not exist yet, and errors will arise. - // As a result, a new one is generated as necessary. - if (WorldGen.structures is null) - WorldGen.structures = new StructureMap(); - - int totalPlanetoidsToGenerate = Main.maxTilesX / 4200 + 1; - for (int i = 0; i < totalPlanetoidsToGenerate; i++) - { - for (int tries = 0; tries < 3000; tries++) - { - Point planetoidOrigin = new Point(WorldGen.genRand.Next(Main.maxTilesX / 2 - 700, Main.maxTilesX / 2 + 700), WorldGen.genRand.Next(85, 110)); - if (WorldGen.genRand.NextBool(2)) - { - if (Biomes.Place(planetoidOrigin, WorldGen.structures)) - break; - } - else - { - if (Biomes.Place(planetoidOrigin, WorldGen.structures)) - break; - } - } - } - } - - public static void Planetoids(GenerationProgress progress) - { - progress.Message = "Generating Planetoids..."; - - int GrassPlanetoidCount = Main.maxTilesX / 1100; - int LCPlanetoidCount = Main.maxTilesX / 800; - int MudPlanetoidCount = Main.maxTilesX / 1100; - - const int MainPlanetoidAttempts = 3000; - int i = 0; - while (i < MainPlanetoidAttempts) - { - if (Biomes.Place(new Point(WorldGen.genRand.Next(Main.maxTilesX / 2 - 300, Main.maxTilesX / 2 + 300), WorldGen.genRand.Next(128, 134)), WorldGen.structures)) - { - break; - } - i++; - } - - const int CrystalHeartPlanetoidAttempts = 15000; - i = 0; - while (LCPlanetoidCount > 0 && i < CrystalHeartPlanetoidAttempts) - { - int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.2), (int)(Main.maxTilesX * 0.8)); - int y = WorldGen.genRand.Next(70, 101); - - bool placed = Biomes.Place(x, y, WorldGen.structures); - - if (placed) - LCPlanetoidCount--; - i++; - } - - const int GrassPlanetoidAttempts = 12000; - i = 0; - while (GrassPlanetoidCount > 0 && i < GrassPlanetoidAttempts) - { - int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.333), (int)(Main.maxTilesX * 0.666)); - int y = WorldGen.genRand.Next(100, 131); - - - bool placed = Biomes.Place(x, y, WorldGen.structures); - - if (placed) - GrassPlanetoidCount--; - i++; - } - - const int MudPlanetoidAttempts = 12000; - i = 0; - while (MudPlanetoidCount > 0 && i < MudPlanetoidAttempts) - { - int x = WorldGen.genRand.Next((int)(Main.maxTilesX * 0.3f), (int)(Main.maxTilesX * 0.7f)); - int y = WorldGen.genRand.Next(100, 131); - - bool placed = Biomes.Place(x, y, WorldGen.structures); - - if (placed) - MudPlanetoidCount--; - i++; - } - } - #endregion - } -} diff --git a/World/WorldUpdateMiscEffects.cs b/World/WorldUpdateMiscEffects.cs new file mode 100644 index 0000000000..a4daebebf4 --- /dev/null +++ b/World/WorldUpdateMiscEffects.cs @@ -0,0 +1,808 @@ +using CalamityMod.CalPlayer; +using CalamityMod.DataStructures; +using CalamityMod.Events; +using CalamityMod.NPCs; +using CalamityMod.NPCs.Abyss; +using CalamityMod.NPCs.AstrumAureus; +using CalamityMod.NPCs.Bumblebirb; +using CalamityMod.NPCs.Calamitas; +using CalamityMod.NPCs.CeaselessVoid; +using CalamityMod.NPCs.Crabulon; +using CalamityMod.NPCs.Cryogen; +using CalamityMod.NPCs.DesertScourge; +using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.HiveMind; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.NPCs.Perforator; +using CalamityMod.NPCs.ProfanedGuardians; +using CalamityMod.NPCs.Signus; +using CalamityMod.NPCs.StormWeaver; +using CalamityMod.Tiles; +using CalamityMod.Tiles.Abyss; +using CalamityMod.Tiles.SunkenSea; +using Microsoft.Xna.Framework; +using System; +using System.Linq; +using Terraria; +using Terraria.GameContent.Events; +using Terraria.ID; +using Terraria.ModLoader; + +using static CalamityMod.World.CalamityWorld; + +namespace CalamityMod.World +{ + public class WorldUpdateMiscEffects + { + public static void PerformWorldUpdates() + { + // Sunken Sea Location...duh + SunkenSeaLocation = new Rectangle(WorldGen.UndergroundDesertLocation.Left, WorldGen.UndergroundDesertLocation.Bottom, WorldGen.UndergroundDesertLocation.Width, WorldGen.UndergroundDesertLocation.Height / 2); + + // Player variable, always finds the closest player relative to the center of the map + int closestPlayer = Player.FindClosest(new Vector2(Main.maxTilesX / 2, (float)Main.worldSurface / 2f) * 16f, 0, 0); + Player player = Main.player[closestPlayer]; + CalamityPlayer modPlayer = player.Calamity(); + + // Force boss rush to off if necessary. + if (!BossRushEvent.DeactivateStupidFuckingBullshit) + { + BossRushEvent.DeactivateStupidFuckingBullshit = true; + BossRushEvent.BossRushActive = false; + CalamityNetcode.SyncWorld(); + } + + // Handle Acid Rain update logic. + if (rainingAcid) + AcidRainEvent.Update(); + else + { + if (timeSinceAcidStarted != 0) + timeSinceAcidStarted = 0; + startAcidicDownpour = false; + } + + // Lumenyl crystal, tenebris spread and sea prism crystal spawn rates + HandleTileGrowth(); + + // Update Boss Rush. + BossRushEvent.Update(); + + // Handle Phase 2 DoG's summon-code, for both DoG directly and his sentinels. + HandleDoGP2Countdown(player); + + // Handle conditional summons. + TrySpawnArmoredDigger(player, modPlayer); + TrySpawnDungeonGuardian(player); + TrySpawnAEoW(player, modPlayer); + TrySpawnRandomDeathmodeBosses(player, modPlayer); + + // Very, very, very rarely display a Lorde joke text if the system clock is set to April Fools Day. + if (Main.rand.NextBool(100000000) && DateTime.Now.Month == 4 && DateTime.Now.Day == 1) + { + string key = "Mods.CalamityMod.AprilFools"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + + // Disable sandstorms if the Desert Scourge is still alive and Hardmode hasn't begun. + if (!downedDesertScourge && Main.netMode != NetmodeID.MultiplayerClient && !Main.hardMode) + CalamityUtils.StopSandstorm(); + + // Make the cultist countdown happen much more quickly. + if (Main.netMode != NetmodeID.MultiplayerClient) + { + CultistRitual.delay -= Main.dayRate * 10; + CultistRitual.recheck -= Main.dayRate * 10; + if (CultistRitual.recheck < 0) + CultistRitual.recheck = 0; + if (CultistRitual.delay < 0) + CultistRitual.delay = 0; + } + } + + #region Handle Tile Growing + + public static void HandleTileGrowth() + { + int l = 0; + float mult2 = 1.5E-05f * Main.worldRate; + while (l < Main.maxTilesX * Main.maxTilesY * mult2) + { + int x = WorldGen.genRand.Next(10, Main.maxTilesX - 10); + int y = WorldGen.genRand.Next((int)Main.worldSurface - 1, Main.maxTilesY - 20); + + int y2 = y - 1; + if (y2 < 10) + y2 = 10; + + if (Main.tile[x, y] != null) + { + if (Main.tile[x, y].nactive()) + { + if (Main.tile[x, y].liquid <= 32) + { + if (Main.tile[x, y].type == TileID.JungleGrass) + { + if (Main.tile[x, y2].liquid == 0) + { + // Plantera Bulbs pre-mech + if (WorldGen.genRand.Next(1500) == 0) + { + if (Main.hardMode && (!NPC.downedMechBoss1 || !NPC.downedMechBoss2 || !NPC.downedMechBoss3)) + { + bool placeBulb = true; + int minDistanceFromOtherBulbs = 150; + for (int i = x - minDistanceFromOtherBulbs; i < x + minDistanceFromOtherBulbs; i += 2) + { + for (int j = y - minDistanceFromOtherBulbs; j < y + minDistanceFromOtherBulbs; j += 2) + { + if (i > 1 && i < Main.maxTilesX - 2 && j > 1 && j < Main.maxTilesY - 2 && Main.tile[i, j].active() && Main.tile[i, j].type == TileID.PlanteraBulb) + { + placeBulb = false; + break; + } + } + } + + if (placeBulb) + { + WorldGen.PlaceJunglePlant(x, y2, TileID.PlanteraBulb, 0, 0); + WorldGen.SquareTileFrame(x, y2); + WorldGen.SquareTileFrame(x + 2, y2); + WorldGen.SquareTileFrame(x - 1, y2); + if (Main.tile[x, y2].type == TileID.PlanteraBulb && Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, x, y2, 5); + } + } + } + } + + // Life Fruit pre-mech + int random = Main.expertMode ? 90 : 120; + if (WorldGen.genRand.Next(random) == 0) + { + if (Main.hardMode && !NPC.downedMechBossAny) + { + bool placeFruit = true; + int minDistanceFromOtherFruit = Main.expertMode ? 50 : 60; + for (int i = x - minDistanceFromOtherFruit; i < x + minDistanceFromOtherFruit; i += 2) + { + for (int j = y - minDistanceFromOtherFruit; j < y + minDistanceFromOtherFruit; j += 2) + { + if (i > 1 && i < Main.maxTilesX - 2 && j > 1 && j < Main.maxTilesY - 2 && Main.tile[i, j].active() && Main.tile[i, j].type == TileID.LifeFruit) + { + placeFruit = false; + break; + } + } + } + + if (placeFruit) + { + WorldGen.PlaceJunglePlant(x, y2, TileID.LifeFruit, WorldGen.genRand.Next(3), 0); + WorldGen.SquareTileFrame(x, y2); + WorldGen.SquareTileFrame(x + 1, y2 + 1); + if (Main.tile[x, y2].type == TileID.LifeFruit && Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, x, y2, 4); + } + } + } + } + } + } + } + + int tileType = Main.tile[x, y].type; + bool tenebris = tileType == ModContent.TileType() && downedCalamitas; + + if (CalamityGlobalTile.GrowthTiles.Contains(tileType) || tenebris) + { + int growthChance = tenebris ? 4 : 2; + if (tileType == ModContent.TileType()) + growthChance *= 5; + + if (Main.rand.NextBool(growthChance)) + { + switch (WorldGen.genRand.Next(4)) + { + case 0: + x++; + break; + case 1: + x--; + break; + case 2: + y++; + break; + case 3: + y--; + break; + default: + break; + } + + if (Main.tile[x, y] != null) + { + Tile tile = Main.tile[x, y]; + bool growTile = tenebris ? (tile.active() && tile.type == ModContent.TileType()) : (!tile.active() && tile.liquid >= 128); + bool isSunkenSeaTile = tileType == ModContent.TileType() || tileType == ModContent.TileType() || tileType == ModContent.TileType(); + bool meetsAdditionalGrowConditions = tile.slope() == 0 && !tile.halfBrick() && !tile.lava(); + + if (growTile && meetsAdditionalGrowConditions) + { + int tileType2 = ModContent.TileType(); + + if (tileType == ModContent.TileType()) + tileType2 = ModContent.TileType(); + + bool canPlaceBasedOnAttached = true; + if (tileType2 == ModContent.TileType() && !isSunkenSeaTile) + canPlaceBasedOnAttached = false; + + if (canPlaceBasedOnAttached && (CanPlaceBasedOnProximity(x, y, tileType2) || tenebris)) + { + tile.type = tenebris ? (ushort)tileType : (ushort)tileType2; + + if (!tenebris) + { + tile.active(true); + if (Main.tile[x, y + 1].active() && Main.tileSolid[Main.tile[x, y + 1].type] && Main.tile[x, y + 1].slope() == 0 && !Main.tile[x, y + 1].halfBrick()) + { + tile.frameY = 0; + } + else if (Main.tile[x, y - 1].active() && Main.tileSolid[Main.tile[x, y - 1].type] && Main.tile[x, y - 1].slope() == 0 && !Main.tile[x, y - 1].halfBrick()) + { + tile.frameY = 18; + } + else if (Main.tile[x + 1, y].active() && Main.tileSolid[Main.tile[x + 1, y].type] && Main.tile[x + 1, y].slope() == 0 && !Main.tile[x + 1, y].halfBrick()) + { + tile.frameY = 36; + } + else if (Main.tile[x - 1, y].active() && Main.tileSolid[Main.tile[x - 1, y].type] && Main.tile[x - 1, y].slope() == 0 && !Main.tile[x - 1, y].halfBrick()) + { + tile.frameY = 54; + } + tile.frameX = (short)(WorldGen.genRand.Next(18) * 18); + } + + WorldGen.SquareTileFrame(x, y); + + if (Main.netMode == NetmodeID.Server) + NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); + } + } + } + } + } + } + } + l++; + } + + } + + public static bool CanPlaceBasedOnProximity(int x, int y, int tileType) + { + if (tileType == ModContent.TileType() && !downedCalamitas) + return false; + + int minDistanceFromOtherTiles = 6; + int sameTilesNearby = 0; + for (int i = x - minDistanceFromOtherTiles; i < x + minDistanceFromOtherTiles; i++) + { + for (int j = y - minDistanceFromOtherTiles; j < y + minDistanceFromOtherTiles; j++) + { + if (Main.tile[i, j].active() && Main.tile[i, j].type == tileType) + { + sameTilesNearby++; + if (sameTilesNearby > 1) + return false; + } + } + } + + return true; + } + #endregion + + #region Handle Phase 2 DoG's Summoning + public static void HandleDoGP2Countdown(Player player) + { + if (DoGSecondStageCountdown <= 0) + return; + + DoGSecondStageCountdown--; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (DoGSecondStageCountdown == 21540) + CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); + if (DoGSecondStageCountdown == 14340) + CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); + if (DoGSecondStageCountdown == 7140) + CalamityUtils.SpawnBossBetter(player.Center, ModContent.NPCType(), new OffscreenBossSpawnContext()); + + if (DoGSecondStageCountdown <= 60) + { + int freeNPCSlots = Main.maxNPCs - Main.npc.Take(Main.maxNPCs).Where(npc => npc.active).Count(); + + // If there are too many slots occupied, make a note in the logs, + // and don't attempt to spawn the Devourer of Gods. + if (freeNPCSlots < 102) + { + CalamityMod.Instance.Logger.Warn("You have too many occupied NPC slots for DoG to spawn. Remove dummies or kill excessive town NPCs."); + DoGSecondStageCountdown = 0; + } + else if (!NPC.AnyNPCs(ModContent.NPCType())) + { + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + string key = "Mods.CalamityMod.EdgyBossText10"; + Color messageColor = Color.Cyan; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + } + } + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DoGCountdownSync); + netMessage.Write(DoGSecondStageCountdown); + netMessage.Send(); + } + } + #endregion + + #region Handle Armored Digger Random Spawns + public static void TrySpawnArmoredDigger(Player player, CalamityPlayer modPlayer) + { + if (player.ZoneRockLayerHeight && !player.ZoneUnderworldHeight && !player.ZoneDungeon && !player.ZoneJungle && !modPlayer.ZoneSunkenSea && !modPlayer.ZoneAbyss && !CalamityPlayer.areThereAnyDamnBosses) + { + if (NPC.downedPlantBoss && player.townNPCs < 3f) + { + double spawnRate = 100000D; + + if (revenge) + spawnRate *= 0.85D; + + if (demonMode) + spawnRate *= 0.75D; + + if (death && Main.bloodMoon) + spawnRate *= 0.2D; + if (modPlayer.zerg) + spawnRate *= 0.5D; + if (modPlayer.chaosCandle) + spawnRate *= 0.6D; + if (player.enemySpawns) + spawnRate *= 0.7D; + if (Main.waterCandles > 0) + spawnRate *= 0.8D; + + if (modPlayer.bossZen || DoGSecondStageCountdown > 0) + spawnRate *= 50D; + if (modPlayer.zen || (CalamityConfig.Instance.DisableExpertTownSpawns && player.townNPCs > 1f && Main.expertMode)) + spawnRate *= 2D; + if (modPlayer.tranquilityCandle) + spawnRate *= 1.67D; + if (player.calmed) + spawnRate *= 1.43D; + if (Main.peaceCandles > 0) + spawnRate *= 1.25D; + + int chance = (int)spawnRate; + if (Main.rand.NextBool(chance)) + { + if (!NPC.AnyNPCs(ModContent.NPCType()) && Main.netMode != NetmodeID.MultiplayerClient && + ArmoredDiggerSpawnCooldown <= 0) + { + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + ArmoredDiggerSpawnCooldown = 3600; + } + } + } + } + if (ArmoredDiggerSpawnCooldown > 0) + { + ArmoredDiggerSpawnCooldown--; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.ArmoredDiggerCountdownSync); + netMessage.Write(ArmoredDiggerSpawnCooldown); + netMessage.Send(); + } + } + } + #endregion + + #region Handle Dungeon Guardian Spawns + public static void TrySpawnDungeonGuardian(Player player) + { + if (Main.netMode == NetmodeID.MultiplayerClient || !player.ZoneDungeon || NPC.downedBoss3 || player.dead) + return; + + if (!NPC.AnyNPCs(NPCID.DungeonGuardian)) + NPC.SpawnOnPlayer(player.whoAmI, NPCID.DungeonGuardian); //your hell is as vast as my bonergrin, pray your life ends quickly + } + #endregion + + #region Handle Adult Eidolon Wyrm Spawns + public static void TrySpawnAEoW(Player player, CalamityPlayer modPlayer) + { + if (Main.netMode == NetmodeID.MultiplayerClient || !modPlayer.ZoneAbyss || !player.chaosState || player.dead) + return; + + bool adultWyrmAlive = CalamityGlobalNPC.adultEidolonWyrmHead != -1 && Main.npc[CalamityGlobalNPC.adultEidolonWyrmHead].active; + if (!adultWyrmAlive) + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + #endregion + + #region Handle Deathmode Random Boss Spawns + + public static void TrySpawnRandomDeathmodeBosses(Player player, CalamityPlayer modPlayer) + { + void BossText() + { + string key = "Mods.CalamityMod.BossSpawnText"; + Color messageColor = Color.Crimson; + CalamityUtils.DisplayLocalizedText(key, messageColor); + } + + //does not occur while a boss is alive or during certain events) + if (!death || CalamityPlayer.areThereAnyDamnBosses || Main.snowMoon || Main.pumpkinMoon || DD2Event.Ongoing || player.statLifeMax2 < 300 || WorldGen.spawnEye || WorldGen.spawnHardBoss > 0) + return; + + if (bossSpawnCountdown <= 0 && deathBossSpawnCooldown <= 0) // Check for countdown and cooldown being 0 + { + if (Main.rand.NextBool(50000)) + { + // Only set countdown and boss type if conditions are met + // Night time bosses set message only before 11pm. Day time bosses only before 2pm. + if (!NPC.downedBoss1 && bossType == 0) + if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) + { + BossText(); + bossType = NPCID.EyeofCthulhu; + bossSpawnCountdown = 3600; // 1 minute + } + + if (!NPC.downedBoss2 && bossType == 0) + if (player.ZoneCorrupt) + { + BossText(); + bossType = NPCID.EaterofWorldsHead; + bossSpawnCountdown = 3600; + } + + if (!NPC.downedBoss2 && bossType == 0) + if (player.ZoneCrimson) + { + BossText(); + bossType = NPCID.BrainofCthulhu; + bossSpawnCountdown = 3600; + } + + /*if (!NPC.downedQueenBee && bossType == 0) + if (player.ZoneJungle && !player.ZoneOverworldHeight && !player.ZoneSkyHeight) + { + BossText(); + bossType = NPCID.QueenBee; + bossSpawnCountdown = 3600; + }*/ + + if (!downedDesertScourge && bossType == 0) + if (player.ZoneDesert) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + if (!downedPerforator && bossType == 0) + if (player.ZoneCrimson) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + if (!downedHiveMind && bossType == 0) + if (player.ZoneCorrupt) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + if (!downedCrabulon && bossType == 0) + if (player.ZoneGlowshroom) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + if (Main.hardMode) + { + if (!NPC.downedMechBoss1 && bossType == 0) + if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) + { + BossText(); + bossType = NPCID.TheDestroyer; + bossSpawnCountdown = 3600; + } + + if (!NPC.downedMechBoss2 && bossType == 0) + if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) + { + BossText(); + bossType = NPCID.Spazmatism; + bossSpawnCountdown = 3600; + } + + if (!NPC.downedMechBoss3 && bossType == 0) + if (!Main.dayTime && (player.ZoneOverworldHeight || player.ZoneSkyHeight) && Main.time < 12600) + { + BossText(); + bossType = NPCID.SkeletronPrime; + bossSpawnCountdown = 3600; + } + + if (!NPC.downedPlantBoss && bossType == 0) + if (player.ZoneJungle && !player.ZoneOverworldHeight && !player.ZoneSkyHeight) + { + BossText(); + bossType = NPCID.Plantera; + bossSpawnCountdown = 3600; + } + + if (!NPC.downedFishron && bossType == 0) + if (player.ZoneBeach && !modPlayer.ZoneSulphur) + { + BossText(); + bossType = NPCID.DukeFishron; + bossSpawnCountdown = 3600; + } + + if (!downedCryogen && bossType == 0) + if (player.ZoneSnow && player.ZoneOverworldHeight) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + if (!downedCalamitas && bossType == 0) + if (!Main.dayTime && player.ZoneOverworldHeight && Main.time < 12600) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + if (!downedAstrageldon && bossType == 0) + if (modPlayer.ZoneAstral && + !Main.dayTime && player.ZoneOverworldHeight) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + /*if (!downedPlaguebringer && bossType == 0) + if (player.ZoneJungle && NPC.downedGolemBoss && !player.ZoneOverworldHeight && !player.ZoneSkyHeight) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + }*/ + + if (NPC.downedMoonlord) + { + if (!downedGuardians && bossType == 0) + if (Main.dayTime && (player.ZoneUnderworldHeight || + (player.ZoneHoly && player.ZoneOverworldHeight)) && Main.time < 34200) //only before 2pm + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + + if (!downedBumble && bossType == 0) + if (player.ZoneJungle && player.ZoneOverworldHeight) + { + BossText(); + bossType = ModContent.NPCType(); + bossSpawnCountdown = 3600; + } + } + } + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.BossSpawnCountdownSync); + netMessage.Write(bossSpawnCountdown); + netMessage.Send(); + var netMessage2 = CalamityMod.Instance.GetPacket(); + netMessage2.Write((byte)CalamityModMessageType.BossTypeSync); + netMessage2.Write(bossType); + netMessage2.Send(); + } + } + } + else + { + if (bossSpawnCountdown > 0) + { + bossSpawnCountdown--; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.BossSpawnCountdownSync); + netMessage.Write(bossSpawnCountdown); + netMessage.Send(); + } + } + + if (bossSpawnCountdown <= 0 && deathBossSpawnCooldown <= 0) // Check both cooldowns again here to avoid infinite message possibilities + { + bool canSpawn = true; + switch (bossType) + { + case NPCID.EyeofCthulhu: + if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) + canSpawn = false; + break; + case NPCID.EaterofWorldsHead: + if (!player.ZoneCorrupt) + canSpawn = false; + break; + case NPCID.BrainofCthulhu: + if (!player.ZoneCrimson) + canSpawn = false; + break; + /*case NPCID.QueenBee: + if (!player.ZoneJungle || player.ZoneOverworldHeight || player.ZoneSkyHeight) + canSpawn = false; + break;*/ + case NPCID.TheDestroyer: + if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) + canSpawn = false; + break; + case NPCID.Spazmatism: + if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) + canSpawn = false; + break; + case NPCID.SkeletronPrime: + if (Main.dayTime || (!player.ZoneOverworldHeight && !player.ZoneSkyHeight) || Main.time > 16200) + canSpawn = false; + break; + case NPCID.Plantera: + if (!player.ZoneJungle || player.ZoneOverworldHeight || player.ZoneSkyHeight) + canSpawn = false; + break; + case NPCID.DukeFishron: + if (!player.ZoneBeach) + canSpawn = false; + break; + } + + if (bossType == ModContent.NPCType()) + { + if (!player.ZoneDesert) + canSpawn = false; + } + else if (bossType == ModContent.NPCType()) + { + if (!player.ZoneCrimson) + canSpawn = false; + } + else if (bossType == ModContent.NPCType()) + { + if (!player.ZoneCorrupt) + canSpawn = false; + } + else if (bossType == ModContent.NPCType()) + { + if (!player.ZoneGlowshroom) + canSpawn = false; + } + else if (bossType == ModContent.NPCType()) + { + if (!player.ZoneSnow || !player.ZoneOverworldHeight) + canSpawn = false; + } + else if (bossType == ModContent.NPCType()) + { + if (Main.dayTime || !player.ZoneOverworldHeight || Main.time > 16200) + canSpawn = false; + } + else if (bossType == ModContent.NPCType()) + { + if (!modPlayer.ZoneAstral || + Main.dayTime || !player.ZoneOverworldHeight) + canSpawn = false; + } + /*else if (bossType == ModContent.NPCType()) + { + if (!player.ZoneJungle || player.ZoneOverworldHeight || player.ZoneSkyHeight) + canSpawn = false; + }*/ + else if (bossType == ModContent.NPCType()) + { + if (!Main.dayTime || (!player.ZoneUnderworldHeight && + (!player.ZoneHoly || !player.ZoneOverworldHeight)) || Main.time > 37800) + canSpawn = false; + } + else if (bossType == ModContent.NPCType()) + { + if (!player.ZoneJungle || !player.ZoneOverworldHeight) + canSpawn = false; + } + + if (canSpawn) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (bossType == NPCID.Spazmatism) + NPC.SpawnOnPlayer(player.whoAmI, NPCID.Retinazer); + else if (bossType == ModContent.NPCType()) + { + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + else if (bossType == ModContent.NPCType()) + { + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType()); + } + if (bossType == NPCID.DukeFishron) + { + NPC.NewNPC((int)player.Center.X - 300, (int)player.Center.Y - 300, bossType); + } + else + { + NPC.SpawnOnPlayer(player.whoAmI, bossType); + } + } + + deathBossSpawnCooldown = 86400; // 24 minutes (1 full Terraria day) + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DeathBossSpawnCountdownSync); + netMessage.Write(deathBossSpawnCooldown); + netMessage.Send(); + } + } + + bossType = 0; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.BossTypeSync); + netMessage.Write(bossType); + netMessage.Send(); + } + } + + // IMPORTANT! Decrement this cooldown AFTER everything else to avoid infinite possibilities + if (deathBossSpawnCooldown > 0) + { + deathBossSpawnCooldown--; + if (Main.netMode == NetmodeID.Server) + { + var netMessage = CalamityMod.Instance.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.DeathBossSpawnCountdownSync); + netMessage.Write(deathBossSpawnCooldown); + netMessage.Send(); + } + } + } + } + #endregion + } +}