diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 6cafdd9e11..7b3faf4768 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -1089,6 +1089,10 @@ namespace CalamityMod.CalPlayer public FireParticleSet ProvidenceBurnEffectDrawer = new FireParticleSet(-1, int.MaxValue, Color.Yellow, Color.Red * 1.2f, 10f, 0.65f); #endregion Draw Effects + #region Draedon Summoning + public bool AbleToSelectExoMech = false; + #endregion Draedon Summoning + #endregion #region SavingAndLoading @@ -2122,6 +2126,8 @@ namespace CalamityMod.CalPlayer lastProjectileHit = null; + AbleToSelectExoMech = false; + CalamityPlayerMiscEffects.EnchantHeldItemEffects(player, player.Calamity(), player.ActiveItem()); } #endregion diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 0bef4ba90b..066b57bb34 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -5,12 +5,14 @@ using CalamityMod.Buffs.Potions; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Buffs.Summon; +using CalamityMod.CustomRecipes; using CalamityMod.DataStructures; using CalamityMod.Dusts; using CalamityMod.Events; using CalamityMod.Items; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor; +using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Fishing.AstralCatches; using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.Fishing.FishingRods; @@ -126,6 +128,9 @@ namespace CalamityMod.CalPlayer // Potions (Quick Buff && Potion Sickness) HandlePotions(player, modPlayer); + // Check if schematics are present on the mouse, for the sake of registering their recipes. + CheckIfMouseItemIsSchematic(player); + // Update all particle sets for items. // This must be done here instead of in the item logic because these sets are not properly instanced // in the global classes. Attempting to update them there will cause multiple updates to one set for multiple items. @@ -156,57 +161,6 @@ namespace CalamityMod.CalPlayer { if (CalamityWorld.revenge || CalamityWorld.malice) { - // This effect is way too annoying during the fight so I disabled it - Fab - // Signus headcrab effect - /*if (CalamityGlobalNPC.signus != -1) - { - if (Main.npc[CalamityGlobalNPC.signus].active) - { - if (Vector2.Distance(player.Center, Main.npc[CalamityGlobalNPC.signus].Center) <= 5200f) - { - float signusLifeRatio = 1f - (Main.npc[CalamityGlobalNPC.signus].life / Main.npc[CalamityGlobalNPC.signus].lifeMax); - - // Reduce the power of Signus darkness based on your light level. - float multiplier = 1f; - switch (modPlayer.GetTotalLightStrength()) - { - case 0: - break; - case 1: - case 2: - multiplier = 0.75f; - break; - case 3: - case 4: - multiplier = 0.5f; - break; - case 5: - case 6: - multiplier = 0.25f; - break; - default: - multiplier = 0f; - break; - } - - // Increased darkness in Death Mode - if (CalamityWorld.death) - multiplier += (1f - multiplier) * 0.1f; - - // Total darkness - float signusDarkness = signusLifeRatio * multiplier; - - // Headcrab effect - if (!modPlayer.ZoneAbyss && !player.headcovered) - { - float screenObstructionAmt = MathHelper.Clamp(signusDarkness, 0f, 0.63f); - float targetValue = MathHelper.Clamp(screenObstructionAmt * 0.33f, 0.1f, 0.2f); - ScreenObstruction.screenObstruction = MathHelper.Lerp(ScreenObstruction.screenObstruction, screenObstructionAmt, targetValue); - } - } - } - }*/ - // Adjusts the life steal cap in rev/death float lifeStealCap = CalamityWorld.malice ? 30f : CalamityWorld.death ? 50f : 60f; /*if (Main.masterMode) @@ -4287,6 +4241,54 @@ namespace CalamityMod.CalPlayer } #endregion + #region Mouse Item Checks + public static void CheckIfMouseItemIsSchematic(Player player) + { + if (Main.myPlayer != player.whoAmI) + return; + + bool shouldSync = false; + + // ActiveItem doesn't need to be checked as the other possibility involves + // the item in question already being in the inventory. + if (Main.mouseItem != null && !Main.mouseItem.IsAir) + { + if (Main.mouseItem.type == ModContent.ItemType() && !RecipeUnlockHandler.HasFoundSunkenSeaSchematic) + { + RecipeUnlockHandler.HasFoundSunkenSeaSchematic = true; + shouldSync = true; + } + + if (Main.mouseItem.type == ModContent.ItemType() && !RecipeUnlockHandler.HasFoundPlanetoidSchematic) + { + RecipeUnlockHandler.HasFoundPlanetoidSchematic = true; + shouldSync = true; + } + + if (Main.mouseItem.type == ModContent.ItemType() && !RecipeUnlockHandler.HasFoundJungleSchematic) + { + RecipeUnlockHandler.HasFoundJungleSchematic = true; + shouldSync = true; + } + + if (Main.mouseItem.type == ModContent.ItemType() && !RecipeUnlockHandler.HasFoundHellSchematic) + { + RecipeUnlockHandler.HasFoundHellSchematic = true; + shouldSync = true; + } + + if (Main.mouseItem.type == ModContent.ItemType() && !RecipeUnlockHandler.HasFoundIceSchematic) + { + RecipeUnlockHandler.HasFoundIceSchematic = true; + shouldSync = true; + } + } + + if (shouldSync) + CalamityNetcode.SyncWorld(); + } + #endregion + #region Potion Handling private static void HandlePotions(Player player, CalamityPlayer modPlayer) { diff --git a/CalamityLists.cs b/CalamityLists.cs index 72012858f6..44afcb14ac 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -5,6 +5,7 @@ using CalamityMod.Items.Accessories; using CalamityMod.Items.Accessories.Wings; using CalamityMod.Items.Ammo.FiniteUse; using CalamityMod.Items.Armor.Vanity; +using CalamityMod.Items.DraedonMisc; using CalamityMod.Items.Fishing.AstralCatches; using CalamityMod.Items.Fishing.BrimstoneCragCatches; using CalamityMod.Items.Fishing.FishingRods; @@ -76,7 +77,6 @@ namespace CalamityMod public class CalamityLists { public static IList donatorList; - public static List trueMeleeProjectileList; // DO NOT, EVER, DELETE THIS LIST, OR I WILL COME FOR YOU :D public static List rangedProjectileExceptionList; public static List projectileDestroyExceptionList; public static List projectileMinionList; @@ -163,6 +163,8 @@ namespace CalamityMod public static List ZeroMinionSlotExceptionList; public static List DontCopyOriginalMinionAIList; + public static Dictionary EncryptedSchematicIDRelationship; + public static void LoadLists() { donatorList = new List() @@ -512,73 +514,6 @@ namespace CalamityMod "James" }; - trueMeleeProjectileList = new List() - { - // Vanilla shit - ProjectileID.Spear, - ProjectileID.Trident, - ProjectileID.TheRottedFork, - ProjectileID.Swordfish, - ProjectileID.Arkhalis, - ProjectileID.DarkLance, - ProjectileID.CobaltNaginata, - ProjectileID.PalladiumPike, - ProjectileID.MythrilHalberd, - ProjectileID.OrichalcumHalberd, - ProjectileID.AdamantiteGlaive, - ProjectileID.TitaniumTrident, - ProjectileID.MushroomSpear, - ProjectileID.Gungnir, - ProjectileID.ObsidianSwordfish, - ProjectileID.MonkStaffT1, - ProjectileID.MonkStaffT2, - - // Tools - ProjectileID.CobaltDrill, - ProjectileID.MythrilDrill, - ProjectileID.AdamantiteDrill, - ProjectileID.PalladiumDrill, - ProjectileID.OrichalcumDrill, - ProjectileID.TitaniumDrill, - ProjectileID.ChlorophyteDrill, - ProjectileID.CobaltChainsaw, - ProjectileID.MythrilChainsaw, - ProjectileID.AdamantiteChainsaw, - ProjectileID.PalladiumChainsaw, - ProjectileID.OrichalcumChainsaw, - ProjectileID.TitaniumChainsaw, - ProjectileID.ChlorophyteChainsaw, - ProjectileID.VortexDrill, - ProjectileID.VortexChainsaw, - ProjectileID.NebulaDrill, - ProjectileID.NebulaChainsaw, - ProjectileID.SolarFlareDrill, - ProjectileID.SolarFlareChainsaw, - ProjectileID.StardustDrill, - ProjectileID.StardustChainsaw, - ProjectileID.Hamdrax, - ProjectileID.ChlorophyteJackhammer, - ProjectileID.SawtoothShark, - ProjectileID.ButchersChainsaw, - - // Calamity shit - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType() - }; - rangedProjectileExceptionList = new List() { ProjectileID.Phantasm, @@ -2942,12 +2877,19 @@ namespace CalamityMod { ProjectileType() }; + + EncryptedSchematicIDRelationship = new Dictionary() + { + [1] = ItemType(), + [2] = ItemType(), + [3] = ItemType(), + [4] = ItemType(), + }; } public static void UnloadLists() { donatorList = null; - trueMeleeProjectileList = null; rangedProjectileExceptionList = null; projectileDestroyExceptionList = null; projectileMinionList = null; @@ -3033,6 +2975,8 @@ namespace CalamityMod MinionsToNotResurrectList = null; ZeroMinionSlotExceptionList = null; DontCopyOriginalMinionAIList = null; + + EncryptedSchematicIDRelationship = null; } } } diff --git a/CalamityMod.cs b/CalamityMod.cs index faed831e9b..74f3f64995 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -973,6 +973,13 @@ namespace CalamityMod CalamitasEnchantUI.Draw(Main.spriteBatch); return true; }, InterfaceScaleType.None)); + + // Codebreaker UI. + layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Codebreaker Decryption GUI", () => + { + CodebreakerUI.Draw(Main.spriteBatch); + return true; + }, InterfaceScaleType.None)); // Popup GUIs. layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Popup GUIs", () => @@ -980,6 +987,14 @@ namespace CalamityMod PopupGUIManager.UpdateAndDraw(Main.spriteBatch); return true; }, InterfaceScaleType.None)); + + // Exo Mech selection. + layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Exo Mech Selection", () => + { + if (Main.LocalPlayer.Calamity().AbleToSelectExoMech) + ExoMechSelectionUI.Draw(Main.spriteBatch); + return true; + }, InterfaceScaleType.None)); } // Invasion UIs. diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index abaa3d56c4..de3ff2cad0 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -184,6 +184,15 @@ namespace CalamityMod case CalamityModMessageType.LabHologramProjector: TELabHologramProjector.ReadSyncPacket(mod, reader); break; + case CalamityModMessageType.UpdateCodebreakerConstituents: + TECodebreaker.ReadConstituentsUpdateSync(mod, reader); + break; + case CalamityModMessageType.UpdateCodebreakerContainedStuff: + TECodebreaker.ReadContainmentSync(mod, reader); + break; + case CalamityModMessageType.UpdateCodebreakerDecryptCountdown: + TECodebreaker.ReadDecryptCountdownSync(mod, reader); + break; // // Boss Rush @@ -346,6 +355,9 @@ namespace CalamityMod ChargingStationItemChange, Turret, LabHologramProjector, + UpdateCodebreakerConstituents, + UpdateCodebreakerContainedStuff, + UpdateCodebreakerDecryptCountdown, // Boss Rush BossRushStage, diff --git a/CustomRecipes/ArsenalTierGatedRecipe.cs b/CustomRecipes/ArsenalTierGatedRecipe.cs new file mode 100644 index 0000000000..daae8f3b9a --- /dev/null +++ b/CustomRecipes/ArsenalTierGatedRecipe.cs @@ -0,0 +1,55 @@ +using CalamityMod.World; +using Terraria.ModLoader; + +namespace CalamityMod.CustomRecipes +{ + public class ArsenalTierGatedRecipe : ModRecipe + { + public int Tier; + public bool AllowedInOldWorlds; + public ArsenalTierGatedRecipe(Mod mod, int tier, bool allowedInOldWorlds = false) : base(mod) + { + Tier = tier; + AllowedInOldWorlds = allowedInOldWorlds; + } + + public static bool HasTierBeenLearned(int tier) + { + switch (tier) + { + case 1: + return RecipeUnlockHandler.HasUnlockedT1ArsenalRecipes; + case 2: + return RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes; + case 3: + return RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes; + case 4: + return RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes; + case 5: + return RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes; + } + return false; + } + + public override bool RecipeAvailable() + { + if (AllowedInOldWorlds && !CalamityWorld.IsWorldAfterDraedonUpdate) + return true; + + switch (Tier) + { + case 1: + return RecipeUnlockHandler.HasUnlockedT1ArsenalRecipes; + case 2: + return RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes; + case 3: + return RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes; + case 4: + return RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes; + case 5: + return RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes; + } + return false; + } + } +} \ No newline at end of file diff --git a/CustomRecipes/RecipeUnlockHandler.cs b/CustomRecipes/RecipeUnlockHandler.cs new file mode 100644 index 0000000000..7950a1f1fe --- /dev/null +++ b/CustomRecipes/RecipeUnlockHandler.cs @@ -0,0 +1,100 @@ +using System.Collections.Generic; +using System.IO; +using Terraria; + +namespace CalamityMod.CustomRecipes +{ + public static class RecipeUnlockHandler + { + public static bool HasUnlockedT1ArsenalRecipes = false; + public static bool HasUnlockedT2ArsenalRecipes = false; + public static bool HasUnlockedT3ArsenalRecipes = false; + public static bool HasUnlockedT4ArsenalRecipes = false; + public static bool HasUnlockedT5ArsenalRecipes = false; + + public static bool HasFoundSunkenSeaSchematic = false; + public static bool HasFoundPlanetoidSchematic = false; + public static bool HasFoundJungleSchematic = false; + public static bool HasFoundHellSchematic = false; + public static bool HasFoundIceSchematic = false; + + public static void Save(List boolTagContainer) + { + boolTagContainer.AddWithCondition("HasUnlockedT1ArsenalRecipes", HasUnlockedT1ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT2ArsenalRecipes", HasUnlockedT2ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT3ArsenalRecipes", HasUnlockedT3ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT4ArsenalRecipes", HasUnlockedT4ArsenalRecipes); + boolTagContainer.AddWithCondition("HasUnlockedT5ArsenalRecipes", HasUnlockedT5ArsenalRecipes); + + boolTagContainer.AddWithCondition("HasFoundSunkenSeaSchematic", HasFoundSunkenSeaSchematic); + boolTagContainer.AddWithCondition("HasFoundPlanetoidSchematic", HasFoundPlanetoidSchematic); + boolTagContainer.AddWithCondition("HasFoundJungleSchematic", HasFoundJungleSchematic); + boolTagContainer.AddWithCondition("HasFoundHellSchematic", HasFoundHellSchematic); + boolTagContainer.AddWithCondition("HasFoundIceSchematic", HasFoundIceSchematic); + + HasUnlockedT1ArsenalRecipes = false; + HasUnlockedT2ArsenalRecipes = false; + HasUnlockedT3ArsenalRecipes = false; + HasUnlockedT4ArsenalRecipes = false; + HasUnlockedT5ArsenalRecipes = false; + + HasFoundSunkenSeaSchematic = false; + HasFoundPlanetoidSchematic = false; + HasFoundJungleSchematic = false; + HasFoundHellSchematic = false; + HasFoundIceSchematic = false; + } + + public static void Load(IList boolTagContainer) + { + HasUnlockedT1ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT1ArsenalRecipes"); + HasUnlockedT2ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT2ArsenalRecipes"); + HasUnlockedT3ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT3ArsenalRecipes"); + HasUnlockedT4ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT4ArsenalRecipes"); + HasUnlockedT5ArsenalRecipes = boolTagContainer.Contains("HasUnlockedT5ArsenalRecipes"); + + HasFoundSunkenSeaSchematic = boolTagContainer.Contains("HasFoundSunkenSeaSchematic"); + HasFoundPlanetoidSchematic = boolTagContainer.Contains("HasFoundPlanetoidSchematic"); + HasFoundJungleSchematic = boolTagContainer.Contains("HasFoundJungleSchematic"); + HasFoundHellSchematic = boolTagContainer.Contains("HasFoundHellSchematic"); + HasFoundIceSchematic = boolTagContainer.Contains("HasFoundIceSchematic"); + } + + public static void SendData(BinaryWriter writer) + { + BitsByte flags = new BitsByte(); + flags[0] = HasUnlockedT1ArsenalRecipes; + flags[1] = HasUnlockedT2ArsenalRecipes; + flags[2] = HasUnlockedT3ArsenalRecipes; + flags[3] = HasUnlockedT4ArsenalRecipes; + flags[4] = HasUnlockedT5ArsenalRecipes; + flags[5] = HasFoundSunkenSeaSchematic; + flags[6] = HasFoundPlanetoidSchematic; + flags[7] = HasFoundJungleSchematic; + + BitsByte flags2 = new BitsByte(); + flags2[0] = HasFoundHellSchematic; + flags2[1] = HasFoundIceSchematic; + + writer.Write(flags); + writer.Write(flags2); + } + + public static void ReceiveData(BinaryReader reader) + { + BitsByte flags = reader.ReadByte(); + HasUnlockedT1ArsenalRecipes = flags[0]; + HasUnlockedT2ArsenalRecipes = flags[1]; + HasUnlockedT3ArsenalRecipes = flags[2]; + HasUnlockedT4ArsenalRecipes = flags[3]; + HasUnlockedT5ArsenalRecipes = flags[4]; + HasFoundSunkenSeaSchematic = flags[5]; + HasFoundPlanetoidSchematic = flags[6]; + HasFoundJungleSchematic = flags[7]; + + BitsByte flags2 = reader.ReadByte(); + HasFoundHellSchematic = flags2[0]; + HasFoundIceSchematic = flags2[1]; + } + } +} \ No newline at end of file diff --git a/CustomRecipes/SchematicRecipe.cs b/CustomRecipes/SchematicRecipe.cs new file mode 100644 index 0000000000..f097834200 --- /dev/null +++ b/CustomRecipes/SchematicRecipe.cs @@ -0,0 +1,33 @@ +using CalamityMod.World; +using Terraria.ModLoader; + +namespace CalamityMod.CustomRecipes +{ + public class SchematicRecipe : ModRecipe + { + public string SchematicName; + public SchematicRecipe(Mod mod, string schematicName) : base(mod) => SchematicName = schematicName; + + public override bool RecipeAvailable() + { + // Allow old worlds to craft the new schematics; They don't exist in old worlds + if (!CalamityWorld.IsWorldAfterDraedonUpdate) + return true; + + switch (SchematicName) + { + case "Sunken Sea": + return RecipeUnlockHandler.HasFoundSunkenSeaSchematic; + case "Planetoid": + return RecipeUnlockHandler.HasFoundPlanetoidSchematic; + case "Jungle": + return RecipeUnlockHandler.HasFoundJungleSchematic; + case "Hell": + return RecipeUnlockHandler.HasFoundHellSchematic; + case "Ice": + return RecipeUnlockHandler.HasFoundIceSchematic; + } + return false; + } + } +} \ No newline at end of file diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index c802bdf471..5a8cf82cb5 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -12,9 +12,11 @@ namespace CalamityMod.Effects public static Effect LightShader; public static Effect SCalMouseShader; public static Effect TentacleShader; + public static Effect TeleportDisplacementShader; public static Effect LightDistortionShader; public static Effect PhaseslayerRipShader; public static Effect FadedUVMapStreakShader; + public static Effect FlameStreakShader; public static Effect FadingSolidTrailShader; public static Effect ScarletDevilShader; public static Effect BordernadoFireShader; @@ -32,6 +34,7 @@ namespace CalamityMod.Effects AstralFogShader = CalamityMod.Instance.GetEffect("Effects/CustomShader"); LightShader = CalamityMod.Instance.GetEffect("Effects/LightBurstShader"); TentacleShader = CalamityMod.Instance.GetEffect("Effects/TentacleShader"); + TeleportDisplacementShader = CalamityMod.Instance.GetEffect("Effects/TeleportDisplacementShader"); SCalMouseShader = CalamityMod.Instance.GetEffect("Effects/SCalMouseShader"); LightDistortionShader = CalamityMod.Instance.GetEffect("Effects/DistortionShader"); PhaseslayerRipShader = CalamityMod.Instance.GetEffect("Effects/PhaseslayerRipShader"); @@ -39,6 +42,7 @@ namespace CalamityMod.Effects BordernadoFireShader = CalamityMod.Instance.GetEffect("Effects/BordernadoFire"); PrismCrystalShader = CalamityMod.Instance.GetEffect("Effects/PrismCrystalStreak"); FadedUVMapStreakShader = CalamityMod.Instance.GetEffect("Effects/FadedUVMapStreak"); + FlameStreakShader = CalamityMod.Instance.GetEffect("Effects/Flame"); FadingSolidTrailShader = CalamityMod.Instance.GetEffect("Effects/FadingSolidTrail"); ImpFlameTrailShader = CalamityMod.Instance.GetEffect("Effects/ImpFlameTrail"); SCalShieldShader = CalamityMod.Instance.GetEffect("Effects/SupremeShieldShader"); @@ -52,9 +56,11 @@ namespace CalamityMod.Effects GameShaders.Misc["CalamityMod:FireMouse"] = new MiscShaderData(new Ref(SCalMouseShader), "DyePass"); GameShaders.Misc["CalamityMod:SubsumingTentacle"] = new MiscShaderData(new Ref(TentacleShader), "BurstPass"); + GameShaders.Misc["CalamityMod:TeleportDisplacement"] = new MiscShaderData(new Ref(TeleportDisplacementShader), "GlitchPass"); GameShaders.Misc["CalamityMod:LightDistortion"] = new MiscShaderData(new Ref(LightDistortionShader), "DistortionPass"); GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"] = new MiscShaderData(new Ref(PhaseslayerRipShader), "TrailPass"); GameShaders.Misc["CalamityMod:TrailStreak"] = new MiscShaderData(new Ref(FadedUVMapStreakShader), "TrailPass"); + GameShaders.Misc["CalamityMod:Flame"] = new MiscShaderData(new Ref(FlameStreakShader), "TrailPass"); GameShaders.Misc["CalamityMod:FadingSolidTrail"] = new MiscShaderData(new Ref(FadingSolidTrailShader), "TrailPass"); GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"] = new MiscShaderData(new Ref(ScarletDevilShader), "TrailPass"); GameShaders.Misc["CalamityMod:Bordernado"] = new MiscShaderData(new Ref(BordernadoFireShader), "TrailPass"); diff --git a/Effects/Flame.fx b/Effects/Flame.fx new file mode 100644 index 0000000000..2fa2e1ffe6 --- /dev/null +++ b/Effects/Flame.fx @@ -0,0 +1,72 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput) 0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + // Read the fade map as a streak. + float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.y + cos(uTime) * 0.01), frac(coords.x - uTime * 1.4 * uSaturation))); + fadeMapColor.r *= pow(coords.x, 0.2); + + float opacity = lerp(1.45, 1.95, fadeMapColor.r) * color.a; + opacity *= pow(sin(coords.y * 3.141), lerp(1, 6, pow(coords.x, 2))); + opacity *= pow(sin(coords.x * 3.141), 0.4); + opacity *= fadeMapColor.r * 1.5 + 1; + opacity *= lerp(0.4, 0.9, fadeMapColor.r); + + float3 transformColor = lerp(float3(1, 205 / 255.0, 119 / 255.0), float3(1, 76 / 255.0, 79 / 255.0), fadeMapColor.r); + color.rgb = lerp(color.rgb, transformColor, fadeMapColor.r); + return color * opacity * 1.6; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/Flame.xnb b/Effects/Flame.xnb new file mode 100644 index 0000000000..6065bbc934 Binary files /dev/null and b/Effects/Flame.xnb differ diff --git a/Effects/TeleportDisplacementShader.fx b/Effects/TeleportDisplacementShader.fx new file mode 100644 index 0000000000..89eb599ac5 --- /dev/null +++ b/Effects/TeleportDisplacementShader.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; +float2 frameCount; + +float4 PixelShaderFunction(float4 sampleColor : TEXCOORD, float2 coords : TEXCOORD0) : COLOR0 +{ + float frameY = coords.y * frameCount.y; + + // 17.07947 is 2pi * e, while 25.13274 is 8pi. + // When two sinusoids are added in this way and the periods of each sinusoid are irrational, + // the resulting sinusoid from the addition has no period, meaning that it has pseudo-random + // bumps and valleys. This is ideal for a glitch effect. The * 0.5 at the end is make the range + // of the result be -1 to 1 like a typical sine. + float offsetBase = (sin(frameY * 17.07947 + uTime * 16) + sin(coords.y * 25.13274)) * 0.5; + + // Here, a power is used to make the valleys and hills sharper, and bias everything else + // towards 0, making horizontal stretches more noticable and powerful when they happen. + // Higher values of uOpacity will result in more powerful offsets, with a uOpacity of 0 + // doing nothing at all. + float horizontalOffset = pow(offsetBase, 3) * uOpacity / frameCount.x * 0.46; + float2 samplePosition = float2(saturate(coords.x + horizontalOffset), coords.y); + return tex2D(uImage0, samplePosition) * float4(uSecondaryColor, uSaturation); +} +technique Technique1 +{ + pass GlitchPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/TeleportDisplacementShader.xnb b/Effects/TeleportDisplacementShader.xnb new file mode 100644 index 0000000000..51b8d818e2 Binary files /dev/null and b/Effects/TeleportDisplacementShader.xnb differ diff --git a/Enums/ExoMech.cs b/Enums/ExoMech.cs new file mode 100644 index 0000000000..bc83c71dda --- /dev/null +++ b/Enums/ExoMech.cs @@ -0,0 +1,10 @@ +namespace CalamityMod +{ + public enum ExoMech + { + None, + Destroyer, + Prime, + Twins + } +} diff --git a/ExtraTextures/UI/CodebreakerDecyptionBar.png b/ExtraTextures/UI/CodebreakerDecyptionBar.png new file mode 100644 index 0000000000..63a3f1d1d2 Binary files /dev/null and b/ExtraTextures/UI/CodebreakerDecyptionBar.png differ diff --git a/ExtraTextures/UI/CodebreakerDecyptionBarCharge.png b/ExtraTextures/UI/CodebreakerDecyptionBarCharge.png new file mode 100644 index 0000000000..3b4109eb2b Binary files /dev/null and b/ExtraTextures/UI/CodebreakerDecyptionBarCharge.png differ diff --git a/ExtraTextures/UI/ContactIcon_Ares.png b/ExtraTextures/UI/ContactIcon_Ares.png new file mode 100644 index 0000000000..494e0c4b97 Binary files /dev/null and b/ExtraTextures/UI/ContactIcon_Ares.png differ diff --git a/ExtraTextures/UI/ContactIcon_THanos.png b/ExtraTextures/UI/ContactIcon_THanos.png new file mode 100644 index 0000000000..fc8a6fddb4 Binary files /dev/null and b/ExtraTextures/UI/ContactIcon_THanos.png differ diff --git a/ExtraTextures/UI/ContactIcon_Twins.png b/ExtraTextures/UI/ContactIcon_Twins.png new file mode 100644 index 0000000000..9e654fccf0 Binary files /dev/null and b/ExtraTextures/UI/ContactIcon_Twins.png differ diff --git a/ExtraTextures/UI/DecryptCancelIcon.png b/ExtraTextures/UI/DecryptCancelIcon.png new file mode 100644 index 0000000000..e718452a8b Binary files /dev/null and b/ExtraTextures/UI/DecryptCancelIcon.png differ diff --git a/ExtraTextures/UI/DecryptIcon.png b/ExtraTextures/UI/DecryptIcon.png new file mode 100644 index 0000000000..5b43bd3919 Binary files /dev/null and b/ExtraTextures/UI/DecryptIcon.png differ diff --git a/ExtraTextures/UI/DraedonDecrypterBackground.png b/ExtraTextures/UI/DraedonDecrypterBackground.png new file mode 100644 index 0000000000..10ced3699f Binary files /dev/null and b/ExtraTextures/UI/DraedonDecrypterBackground.png differ diff --git a/ExtraTextures/UI/DraedonDecrypterScreen.png b/ExtraTextures/UI/DraedonDecrypterScreen.png new file mode 100644 index 0000000000..6631b7dc02 Binary files /dev/null and b/ExtraTextures/UI/DraedonDecrypterScreen.png differ diff --git a/ExtraTextures/UI/EncryptedSchematicSlotBackground.png b/ExtraTextures/UI/EncryptedSchematicSlotBackground.png new file mode 100644 index 0000000000..75f2f538b5 Binary files /dev/null and b/ExtraTextures/UI/EncryptedSchematicSlotBackground.png differ diff --git a/ExtraTextures/UI/HeadIcon_Ares.png b/ExtraTextures/UI/HeadIcon_Ares.png new file mode 100644 index 0000000000..04e2526e68 Binary files /dev/null and b/ExtraTextures/UI/HeadIcon_Ares.png differ diff --git a/ExtraTextures/UI/HeadIcon_ArtemisApollo.png b/ExtraTextures/UI/HeadIcon_ArtemisApollo.png new file mode 100644 index 0000000000..bd061e097c Binary files /dev/null and b/ExtraTextures/UI/HeadIcon_ArtemisApollo.png differ diff --git a/ExtraTextures/UI/HeadIcon_THanos.png b/ExtraTextures/UI/HeadIcon_THanos.png new file mode 100644 index 0000000000..88e6edf8ef Binary files /dev/null and b/ExtraTextures/UI/HeadIcon_THanos.png differ diff --git a/Gores/Draedon/Chair1.png b/Gores/Draedon/Chair1.png new file mode 100644 index 0000000000..e514084ae2 Binary files /dev/null and b/Gores/Draedon/Chair1.png differ diff --git a/Gores/Draedon/Chair2.png b/Gores/Draedon/Chair2.png new file mode 100644 index 0000000000..99377710bc Binary files /dev/null and b/Gores/Draedon/Chair2.png differ diff --git a/Gores/Draedon/Chair3.png b/Gores/Draedon/Chair3.png new file mode 100644 index 0000000000..3d1a32e2bc Binary files /dev/null and b/Gores/Draedon/Chair3.png differ diff --git a/Gores/Draedon/Chair4.png b/Gores/Draedon/Chair4.png new file mode 100644 index 0000000000..767c9e1f02 Binary files /dev/null and b/Gores/Draedon/Chair4.png differ diff --git a/Gores/Draedon/Draedon1.png b/Gores/Draedon/Draedon1.png new file mode 100644 index 0000000000..88bd633548 Binary files /dev/null and b/Gores/Draedon/Draedon1.png differ diff --git a/Gores/Draedon/Draedon2.png b/Gores/Draedon/Draedon2.png new file mode 100644 index 0000000000..9fd23773a0 Binary files /dev/null and b/Gores/Draedon/Draedon2.png differ diff --git a/Gores/Draedon/Draedon3.png b/Gores/Draedon/Draedon3.png new file mode 100644 index 0000000000..ca30e2e8b9 Binary files /dev/null and b/Gores/Draedon/Draedon3.png differ diff --git a/Gores/Draedon/Draedon4.png b/Gores/Draedon/Draedon4.png new file mode 100644 index 0000000000..7343b8d0ec Binary files /dev/null and b/Gores/Draedon/Draedon4.png differ diff --git a/Gores/DraedonLabCritters/RepairUnit1.png b/Gores/DraedonLabCritters/RepairUnit1.png new file mode 100644 index 0000000000..c7fa6eae85 Binary files /dev/null and b/Gores/DraedonLabCritters/RepairUnit1.png differ diff --git a/Gores/DraedonLabCritters/RepairUnit2.png b/Gores/DraedonLabCritters/RepairUnit2.png new file mode 100644 index 0000000000..b4974143b2 Binary files /dev/null and b/Gores/DraedonLabCritters/RepairUnit2.png differ diff --git a/Gores/DraedonLabCritters/RepairUnit3.png b/Gores/DraedonLabCritters/RepairUnit3.png new file mode 100644 index 0000000000..971883e554 Binary files /dev/null and b/Gores/DraedonLabCritters/RepairUnit3.png differ diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index c0738357cb..1f35d5718f 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -2,6 +2,9 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.NPCs; +using CalamityMod.NPCs.AstrumAureus; +using CalamityMod.NPCs.Crabulon; +using CalamityMod.NPCs.Ravager; using CalamityMod.Particles; using CalamityMod.Projectiles; using CalamityMod.Tiles.DraedonStructures; @@ -111,6 +114,7 @@ namespace CalamityMod.ILEditing aLabDoorClosed = ModContent.TileType(); // Mechanics / features + On.Terraria.NPC.ApplyTileCollision += AllowTriggeredFallthrough; IL.Terraria.Main.UpdateTime += PermitNighttimeTownNPCSpawning; On.Terraria.Main.UpdateTime_SpawnTownNPCs += AlterTownNPCSpawnRate; IL.Terraria.Player.Hurt += RemoveRNGFromBlackBelt; @@ -127,6 +131,9 @@ namespace CalamityMod.ILEditing IL.Terraria.Player.AddBuff += AllowBuffTimeStackingForManaBurn; IL.Terraria.Main.DoDraw += DrawFusableParticles; + // Ravager platform fall fix + On.Terraria.NPC.Collision_DecideFallThroughPlatforms += EnableCalamityBossPlatformCollision; + // Damage and health balance IL.Terraria.Main.DamageVar += AdjustDamageVariance; IL.Terraria.NPC.scaleStats += RemoveExpertHardmodeScaling; @@ -164,6 +171,7 @@ namespace CalamityMod.ILEditing labDoorOpen = labDoorClosed = aLabDoorOpen = aLabDoorClosed = -1; // Mechanics / features + On.Terraria.NPC.ApplyTileCollision -= AllowTriggeredFallthrough; IL.Terraria.Main.UpdateTime -= PermitNighttimeTownNPCSpawning; On.Terraria.Main.UpdateTime_SpawnTownNPCs -= AlterTownNPCSpawnRate; IL.Terraria.Player.Hurt -= RemoveRNGFromBlackBelt; @@ -212,6 +220,15 @@ namespace CalamityMod.ILEditing #region IL Editing Routines and Injections #region Mechanics / features + + // Why this isn't a mechanism provided by TML itself or vanilla itself is beyond me. + private static void AllowTriggeredFallthrough(On.Terraria.NPC.orig_ApplyTileCollision orig, NPC self, bool fall, Vector2 cPosition, int cWidth, int cHeight) + { + if (self.active && self.Calamity().ShouldFallThroughPlatforms) + fall = true; + orig(self, fall, cPosition, cWidth, cHeight); + } + private static void PermitNighttimeTownNPCSpawning(ILContext il) { // Don't do town NPC spawning at the end (which lies after a !Main.dayTime return). @@ -326,6 +343,15 @@ namespace CalamityMod.ILEditing return orig(i, j, forced); } + private static bool EnableCalamityBossPlatformCollision(On.Terraria.NPC.orig_Collision_DecideFallThroughPlatforms orig, NPC self) + { + if ((self.type == ModContent.NPCType() || self.type == ModContent.NPCType() || self.type == ModContent.NPCType()) && + self.target >= 0 && Main.player[self.target].position.Y > self.position.Y + self.height) + return true; + + return orig(self); + } + private static void DisableTeleporters(On.Terraria.Wiring.orig_Teleport orig) { if (CalamityPlayer.areThereAnyDamnBosses) diff --git a/Items/Accessories/DarkSunRing.cs b/Items/Accessories/DarkSunRing.cs index 104901d01b..8ce3c5b2fa 100644 --- a/Items/Accessories/DarkSunRing.cs +++ b/Items/Accessories/DarkSunRing.cs @@ -1,24 +1,25 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; -using Terraria.ID; using Terraria.DataStructures; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Accessories { - public class DarkSunRing : ModItem + public class DarkSunRing : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Dark Sun Ring"); Tooltip.SetDefault("Contains the power of the dark sun\n" + - "12% increase to damage and melee speed\n" + + "12% increase to damage and melee speed\n" + "+1 life regen, 15% increased pick speed and +2 max minions\n" + "Increased minion knockback\n" + "During the day the player has +3 life regen\n" + "During the night the player has +15 defense\n" + - "Both of these bonuses are granted during an eclipse"); + "Both of these bonuses are granted during an eclipse"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(6, 7)); } @@ -27,7 +28,7 @@ namespace CalamityMod.Items.Accessories item.width = 54; item.height = 58; item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.defense = 10; item.lifeRegen = 1; item.accessory = true; @@ -44,8 +45,8 @@ namespace CalamityMod.Items.Accessories { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ModContent.ItemType(), 50); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Accessories/DimensionalSoulArtifact.cs b/Items/Accessories/DimensionalSoulArtifact.cs index 9da87af51c..7133641ac3 100644 --- a/Items/Accessories/DimensionalSoulArtifact.cs +++ b/Items/Accessories/DimensionalSoulArtifact.cs @@ -14,19 +14,19 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Dimensional Soul Artifact"); Tooltip.SetDefault("Power\n" + - "Boosts all damage by 25%, but at what cost?\n" + + "Boosts all damage by 25%, but at what cost?\n" + "Increases all damage taken by 15%"); } public override void SetDefaults() { - item.width = 28; - item.height = 28; - item.accessory = true; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - } + item.width = 28; + item.height = 28; + item.accessory = true; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + item.value = CalamityGlobalItem.Rarity14BuyPrice; + } public override void UpdateAccessory(Player player, bool hideVisual) { @@ -37,10 +37,10 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.DemonAltar); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 25); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.DemonAltar); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Accessories/EclipseMirror.cs b/Items/Accessories/EclipseMirror.cs index 046765cd02..0e7385d48a 100644 --- a/Items/Accessories/EclipseMirror.cs +++ b/Items/Accessories/EclipseMirror.cs @@ -1,5 +1,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -52,8 +53,8 @@ namespace CalamityMod.Items.Accessories ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Accessories/Wings/SilvaWings.cs b/Items/Accessories/Wings/SilvaWings.cs index 368f287a46..a1dfdd014b 100644 --- a/Items/Accessories/Wings/SilvaWings.cs +++ b/Items/Accessories/Wings/SilvaWings.cs @@ -1,11 +1,12 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.Graphics.Shaders; -using Terraria.ModLoader; using CalamityMod.Items.Armor; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; namespace CalamityMod.Items.Accessories.Wings { @@ -20,14 +21,14 @@ namespace CalamityMod.Items.Accessories.Wings "Acceleration multiplier: 2.8\n" + "Excellent vertical speed\n" + "Flight time: 270\n" + - "The Silva revive heals you to half health while wearing the Silva armor"); + "The Silva revive heals you to half health while wearing the Silva armor"); } public override void SetDefaults() { item.width = 22; item.height = 20; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.value = CalamityGlobalItem.Rarity14BuyPrice; item.Calamity().customRarity = CalamityRarity.DarkBlue; item.accessory = true; @@ -83,7 +84,7 @@ namespace CalamityMod.Items.Accessories.Wings recipe.AddRecipeGroup("AnyGoldBar", 3); recipe.AddIngredient(ModContent.ItemType(), 3); recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/FearmongerGreathelm.cs b/Items/Armor/FearmongerGreathelm.cs index d3e59b6a39..235af6c80a 100644 --- a/Items/Armor/FearmongerGreathelm.cs +++ b/Items/Armor/FearmongerGreathelm.cs @@ -103,8 +103,9 @@ This extra damage reduction ignores the soft cap"; { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.SpookyHelmet); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ItemID.SoulofFright, 8); + recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/FearmongerGreaves.cs b/Items/Armor/FearmongerGreaves.cs index dc6331225d..c131b591bf 100644 --- a/Items/Armor/FearmongerGreaves.cs +++ b/Items/Armor/FearmongerGreaves.cs @@ -39,8 +39,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.SpookyLeggings); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ItemID.SoulofFright, 10); + recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/FearmongerPlateMail.cs b/Items/Armor/FearmongerPlateMail.cs index 57352bef91..3cb9a6fb12 100644 --- a/Items/Armor/FearmongerPlateMail.cs +++ b/Items/Armor/FearmongerPlateMail.cs @@ -37,8 +37,9 @@ namespace CalamityMod.Items.Armor { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.SpookyBreastplate); - recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ItemID.SoulofFright, 12); + recipe.AddIngredient(ModContent.ItemType(), 3); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/SilvaArmor.cs b/Items/Armor/SilvaArmor.cs index 46369f5acc..44b3d13bcb 100644 --- a/Items/Armor/SilvaArmor.cs +++ b/Items/Armor/SilvaArmor.cs @@ -2,6 +2,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Items.Accessories; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -16,7 +17,7 @@ namespace CalamityMod.Items.Armor DisplayName.SetDefault("Silva Armor"); Tooltip.SetDefault("+80 max life\n" + "12% increased damage and 8% increased critical strike chance\n" + - "Grants immunity to the irradiated debuff"); + "Grants immunity to the irradiated debuff"); } public override void SetDefaults() @@ -25,7 +26,7 @@ namespace CalamityMod.Items.Armor item.height = 24; item.value = Item.buyPrice(0, 72, 0, 0); item.defense = 44; - item.rare = ItemRarityID.Purple; + item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.DarkBlue; } @@ -43,9 +44,9 @@ namespace CalamityMod.Items.Armor recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddRecipeGroup("AnyGoldBar", 10); recipe.AddIngredient(ModContent.ItemType(), 12); - recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 3); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/SilvaHelmet.cs b/Items/Armor/SilvaHelmet.cs index 9f318c27bc..797ea91628 100644 --- a/Items/Armor/SilvaHelmet.cs +++ b/Items/Armor/SilvaHelmet.cs @@ -3,6 +3,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; using CalamityMod.Projectiles.Summon; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -23,9 +24,9 @@ namespace CalamityMod.Items.Armor item.height = 24; item.value = Item.buyPrice(0, 90, 0, 0); item.defense = 13; //110 - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } public override bool IsArmorSet(Item head, Item body, Item legs) { @@ -60,8 +61,8 @@ namespace CalamityMod.Items.Armor } } player.minionDamage += 0.75f; - player.maxMinions += 5; - } + player.maxMinions += 5; + } public override void AddRecipes() { @@ -69,8 +70,8 @@ namespace CalamityMod.Items.Armor recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddRecipeGroup("AnyGoldBar", 5); recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Armor/SilvaLeggings.cs b/Items/Armor/SilvaLeggings.cs index 3c1d235802..635538e6d3 100644 --- a/Items/Armor/SilvaLeggings.cs +++ b/Items/Armor/SilvaLeggings.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Armor recipe.AddIngredient(ModContent.ItemType(), 7); recipe.AddRecipeGroup("AnyGoldBar", 7); recipe.AddIngredient(ModContent.ItemType(), 9); - recipe.AddIngredient(ModContent.ItemType(), 7); + recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Armor/SilvaMaskedCap.cs b/Items/Armor/SilvaMaskedCap.cs index 536bc0e960..cf23909ece 100644 --- a/Items/Armor/SilvaMaskedCap.cs +++ b/Items/Armor/SilvaMaskedCap.cs @@ -1,6 +1,7 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -23,9 +24,9 @@ namespace CalamityMod.Items.Armor item.height = 22; item.value = Item.buyPrice(0, 90, 0, 0); item.defense = 21; //110 - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } public override bool IsArmorSet(Item head, Item body, Item legs) { @@ -63,8 +64,8 @@ namespace CalamityMod.Items.Armor recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddRecipeGroup("AnyGoldBar", 5); recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 5559642e13..dc3d334e0a 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -80,18 +80,7 @@ namespace CalamityMod.Items public bool devItem = false; public bool challengeDrop = false; public bool canFirePointBlankShots = false; - - public static readonly Color[] ExoPalette = new Color[] - { - new Color(250, 255, 112), - new Color(211, 235, 108), - new Color(166, 240, 105), - new Color(105, 240, 220), - new Color(64, 130, 145), - new Color(145, 96, 145), - new Color(242, 112, 73), - new Color(199, 62, 62), - }; + public bool trueMelee = false; public static readonly Color ExhumedTooltipColor = new Color(198, 27, 64); @@ -218,6 +207,42 @@ namespace CalamityMod.Items canFirePointBlankShots = true; break; + // Set projectile true melee items to be true melee, this is so bosses know when the player is using a true melee projectile weapon + case ItemID.Spear: + case ItemID.Trident: + case ItemID.PalladiumPike: + case ItemID.ObsidianSwordfish: + case ItemID.CobaltDrill: + case ItemID.MythrilDrill: + case ItemID.AdamantiteDrill: + case ItemID.PalladiumDrill: + case ItemID.OrichalcumDrill: + case ItemID.TitaniumDrill: + case ItemID.ChlorophyteDrill: + case ItemID.CobaltChainsaw: + case ItemID.MythrilChainsaw: + case ItemID.AdamantiteChainsaw: + case ItemID.PalladiumChainsaw: + case ItemID.OrichalcumChainsaw: + case ItemID.TitaniumChainsaw: + case ItemID.ChlorophyteChainsaw: + case ItemID.VortexDrill: + case ItemID.VortexChainsaw: + case ItemID.NebulaDrill: + case ItemID.NebulaChainsaw: + case ItemID.SolarFlareDrill: + case ItemID.SolarFlareChainsaw: + case ItemID.StardustDrill: + case ItemID.StardustChainsaw: + case ItemID.Drax: + case ItemID.ChlorophyteJackhammer: + case ItemID.SawtoothShark: + case ItemID.Arkhalis: + case ItemID.ButchersChainsaw: + case ItemID.MonkStaffT2: + trueMelee = true; + break; + case ItemID.Dynamite: case ItemID.StickyDynamite: case ItemID.BouncyDynamite: @@ -327,6 +352,7 @@ namespace CalamityMod.Items break; case ItemID.AdamantiteGlaive: + trueMelee = true; item.damage = 65; item.shootSpeed *= 1.25f; break; @@ -336,25 +362,30 @@ namespace CalamityMod.Items break; case ItemID.CobaltNaginata: + trueMelee = true; item.damage = 90; break; case ItemID.Gungnir: + trueMelee = true; item.damage = 92; item.shootSpeed *= 1.25f; break; case ItemID.MythrilHalberd: + trueMelee = true; item.damage = 95; item.shootSpeed *= 1.25f; break; case ItemID.OrichalcumHalberd: + trueMelee = true; item.damage = 98; item.shootSpeed *= 1.25f; break; case ItemID.TitaniumTrident: + trueMelee = true; item.damage = 72; item.shootSpeed *= 1.25f; break; @@ -364,18 +395,22 @@ namespace CalamityMod.Items break; case ItemID.TheRottedFork: + trueMelee = true; item.damage = 20; break; case ItemID.Swordfish: + trueMelee = true; item.damage = 38; break; case ItemID.DarkLance: + trueMelee = true; item.damage = 68; break; case ItemID.MushroomSpear: + trueMelee = true; item.damage = 100; break; @@ -421,6 +456,7 @@ namespace CalamityMod.Items break; case ItemID.MonkStaffT1: + trueMelee = true; item.damage = 110; break; @@ -833,7 +869,7 @@ namespace CalamityMod.Items #region SavingAndLoading public override bool NeedsSaving(Item item) { - return rogue || canFirePointBlankShots || timesUsed != 0 || customRarity != 0 || Charge != 0 || reforgeTier != 0 || AppliedEnchantment.HasValue || DischargeEnchantExhaustion != 0; + return rogue || canFirePointBlankShots || trueMelee || timesUsed != 0 || customRarity != 0 || Charge != 0 || reforgeTier != 0 || AppliedEnchantment.HasValue || DischargeEnchantExhaustion != 0; } public override TagCompound Save(Item item) @@ -847,7 +883,8 @@ namespace CalamityMod.Items ["reforgeTier"] = reforgeTier, ["enchantmentID"] = AppliedEnchantment.HasValue ? AppliedEnchantment.Value.ID : 0, ["DischargeEnchantExhaustion"] = DischargeEnchantExhaustion, - ["canFirePointBlankShots"] = canFirePointBlankShots + ["canFirePointBlankShots"] = canFirePointBlankShots, + ["trueMelee"] = trueMelee }; } @@ -855,6 +892,7 @@ namespace CalamityMod.Items { rogue = tag.GetBool("rogue"); canFirePointBlankShots = tag.GetBool("canFirePointBlankShots"); + trueMelee = tag.GetBool("trueMelee"); timesUsed = tag.GetInt("timesUsed"); customRarity = (CalamityRarity)tag.GetInt("rarity"); @@ -888,6 +926,7 @@ namespace CalamityMod.Items BitsByte flags = reader.ReadByte(); rogue = flags[0]; canFirePointBlankShots = flags[1]; + trueMelee = flags[2]; } else { @@ -900,6 +939,7 @@ namespace CalamityMod.Items BitsByte flags = new BitsByte(); flags[0] = rogue; flags[1] = canFirePointBlankShots; + flags[2] = trueMelee; writer.Write(flags); writer.Write((int)customRarity); @@ -915,6 +955,7 @@ namespace CalamityMod.Items BitsByte flags = reader.ReadByte(); rogue = flags[0]; canFirePointBlankShots = flags[1]; + trueMelee = flags[2]; customRarity = (CalamityRarity)reader.ReadInt32(); timesUsed = reader.ReadInt32(); @@ -1161,7 +1202,7 @@ namespace CalamityMod.Items // If you have enough charge, decrement charge on the spot because this hook runs exactly once every time you use an item. // Mana has to be checked separately or you'll fail to use the weapon on a mana check later and still have consumed charge. - if (player.CheckMana(item)) + if (player.CheckMana(item) && item.modItem.CanUseItem(player)) Charge -= chargeNeeded; } } diff --git a/Items/CalamityGlobalItemTooltip.cs b/Items/CalamityGlobalItemTooltip.cs index ab56295a26..c71b0ab10a 100644 --- a/Items/CalamityGlobalItemTooltip.cs +++ b/Items/CalamityGlobalItemTooltip.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.CustomRecipes; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor; using CalamityMod.Items.Placeables.Furniture.Fountains; @@ -32,8 +33,8 @@ namespace CalamityMod.Items if (nameLine != null) ApplyRarityColor(item, nameLine); - // If the item is melee, add a true melee damage number adjacent to the standard damage number. - if (item.melee && item.damage > 0 && Main.LocalPlayer.Calamity().trueMeleeDamage > 0D) + // If the item is true melee, add a true melee damage number adjacent to the standard damage number. + if (item.melee && (item.shoot == ProjectileID.None || trueMelee) && item.damage > 0 && Main.LocalPlayer.Calamity().trueMeleeDamage > 0D) TrueMeleeDamageTooltip(item, tooltips); // Modify all vanilla tooltips before appending mod mechanics (if any). @@ -1078,6 +1079,19 @@ namespace CalamityMod.Items tooltips.Add(line); } } - #endregion - } + #endregion + + #region Schematic Knowledge Tooltip Utility + public static void InsertKnowledgeTooltip(List tooltips, int tier, bool allowOldWorlds = false) + { + TooltipLine line = new TooltipLine(CalamityMod.Instance, "SchematicKnowledge1", "You don't have sufficient knowledge to create this yet"); + TooltipLine line2 = new TooltipLine(CalamityMod.Instance, "SchematicKnowledge2", "A specific schematic must be deciphered first"); + line.overrideColor = line2.overrideColor = Color.Cyan; + + bool allowedDueToOldWorld = allowOldWorlds && CalamityWorld.IsWorldAfterDraedonUpdate; + tooltips.AddWithCondition(line, !ArsenalTierGatedRecipe.HasTierBeenLearned(tier) && !allowedDueToOldWorld); + tooltips.AddWithCondition(line2, !ArsenalTierGatedRecipe.HasTierBeenLearned(tier) && !allowedDueToOldWorld); + } + #endregion + } } diff --git a/Items/DraedonMisc/AdvancedDisplay.cs b/Items/DraedonMisc/AdvancedDisplay.cs new file mode 100644 index 0000000000..936b0b4d2f --- /dev/null +++ b/Items/DraedonMisc/AdvancedDisplay.cs @@ -0,0 +1,68 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.DraedonSummoner; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.TileEntities; +using CalamityMod.CustomRecipes; +using System.Collections.Generic; + +namespace CalamityMod.Items.DraedonMisc +{ + public class AdvancedDisplay : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Advanced Display"); + Tooltip.SetDefault("Can be placed on the Codebreaker"); + } + + public override void SetDefaults() + { + item.width = 52; + item.height = 52; + item.maxStack = 999; + item.consumable = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.rare = ItemRarityID.Yellow; + item.useTime = item.useAnimation = 15; + } + + public override bool UseItem(Player player) => true; + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + + public override bool ConsumeItem(Player player) + { + Point placeTileCoords = Main.MouseWorld.ToTileCoordinates(); + Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y); + float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f; + + if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType()) + { + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare); + if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsAdvancedDisplay) + return false; + + codebreakerTileEntity.ContainsAdvancedDisplay = true; + codebreakerTileEntity.SyncConstituents(); + return true; + } + + return false; + } + + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 3); + recipe.AddIngredient(ItemID.Glass, 20); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/AdvancedDisplay.png b/Items/DraedonMisc/AdvancedDisplay.png new file mode 100644 index 0000000000..c0a76b9fac Binary files /dev/null and b/Items/DraedonMisc/AdvancedDisplay.png differ diff --git a/Items/DraedonMisc/AuricQuantumCoolingCell.cs b/Items/DraedonMisc/AuricQuantumCoolingCell.cs new file mode 100644 index 0000000000..f8b7905310 --- /dev/null +++ b/Items/DraedonMisc/AuricQuantumCoolingCell.cs @@ -0,0 +1,85 @@ +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.TileEntities; +using CalamityMod.Tiles.DraedonSummoner; +using CalamityMod.Tiles.Furniture.CraftingStations; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using System.Collections.Generic; +using System.Linq; +using CalamityMod.World; + +namespace CalamityMod.Items.DraedonMisc +{ + public class AuricQuantumCoolingCell : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Auric Quantum Cooling Cell"); + Tooltip.SetDefault("Can be placed in the Codebreaker, completing it\n" + + "The completion of the Codebreaker allows you to make contact with its original creator\n" + + "Attempting to do so may have dire consequences"); + } + + public override void SetDefaults() + { + item.width = 26; + item.height = 44; + item.maxStack = 999; + item.consumable = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.rare = ItemRarityID.Red; + item.useTime = item.useAnimation = 15; + item.Calamity().customRarity = CalamityRarity.Violet; + } + + public override void ModifyTooltips(List tooltips) + { + tooltips.FirstOrDefault(x => x.Name == "Tooltip2" && x.mod == "Terraria").overrideColor = Color.DarkRed; + CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5, true); + } + + public override void Update(ref float gravity, ref float maxFallSpeed) + { + float brightness = Main.essScale * Main.rand.NextFloat(0.9f, 1.1f); + Lighting.AddLight(item.Center, 1.2f * brightness, 0.4f * brightness, 0.8f); + } + + public override bool UseItem(Player player) => true; + + public override bool ConsumeItem(Player player) + { + Point placeTileCoords = Main.MouseWorld.ToTileCoordinates(); + Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y); + float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f; + + if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType()) + { + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare); + if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsCoolingCell || codebreakerTileEntity.DecryptionCountdown > 0) + return false; + + codebreakerTileEntity.ContainsCoolingCell = true; + codebreakerTileEntity.SyncConstituents(); + return true; + } + + return false; + } + + public override void AddRecipes() + { + // Old worlds can craft the cell immediately for the sake of being able to easily fight Draedon in endgame worlds. + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5, true); + recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ItemID.Wire, 40); + recipe.AddIngredient(ModContent.ItemType(), 80); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddTile(ModContent.TileType()); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/AuricQuantumCoolingCell.png b/Items/DraedonMisc/AuricQuantumCoolingCell.png new file mode 100644 index 0000000000..ed57707d71 Binary files /dev/null and b/Items/DraedonMisc/AuricQuantumCoolingCell.png differ diff --git a/Items/DraedonMisc/CodebreakerBase.cs b/Items/DraedonMisc/CodebreakerBase.cs new file mode 100644 index 0000000000..a6d5d5f160 --- /dev/null +++ b/Items/DraedonMisc/CodebreakerBase.cs @@ -0,0 +1,39 @@ +using Terraria.ModLoader; +using Terraria.ID; +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.DraedonSummoner; +using CalamityMod.Items.Placeables.DraedonStructures; + +namespace CalamityMod.Items.DraedonMisc +{ + public class CodebreakerBase : ModItem + { + public override void SetStaticDefaults() => DisplayName.SetDefault("Codebreaker Base"); + + public override void SetDefaults() + { + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTurn = true; + item.useAnimation = 15; + item.useTime = 10; + item.autoReuse = true; + item.consumable = true; + item.width = 42; + item.height = 32; + item.maxStack = 999; + item.rare = ItemRarityID.Orange; + item.createTile = ModContent.TileType(); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 35); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/CodebreakerBase.png b/Items/DraedonMisc/CodebreakerBase.png new file mode 100644 index 0000000000..eacc52b6c4 Binary files /dev/null and b/Items/DraedonMisc/CodebreakerBase.png differ diff --git a/Items/DraedonMisc/DecryptionComputer.cs b/Items/DraedonMisc/DecryptionComputer.cs new file mode 100644 index 0000000000..0787f02636 --- /dev/null +++ b/Items/DraedonMisc/DecryptionComputer.cs @@ -0,0 +1,71 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.DraedonSummoner; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.TileEntities; +using CalamityMod.CustomRecipes; +using System.Collections.Generic; + +namespace CalamityMod.Items.DraedonMisc +{ + public class DecryptionComputer : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Decryption Computer"); + Tooltip.SetDefault("Can be placed on the Codebreaker\n" + + "Allows you to decrypt advanced schematics\n" + + "Doing so allows you to learn how to craft new things"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 40; + item.maxStack = 999; + item.consumable = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.rare = ItemRarityID.Orange; + item.useTime = item.useAnimation = 15; + } + + public override bool UseItem(Player player) => true; + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + + public override bool ConsumeItem(Player player) + { + Point placeTileCoords = Main.MouseWorld.ToTileCoordinates(); + Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y); + float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f; + + if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType()) + { + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare); + if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsDecryptionComputer) + return false; + + codebreakerTileEntity.ContainsDecryptionComputer = true; + codebreakerTileEntity.SyncConstituents(); + return true; + } + + return false; + } + + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); + recipe.AddIngredient(ModContent.ItemType(), 18); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.Wire, 300); // Anything prior to Tier 2 (Post-Mechs) is fair game. + recipe.AddRecipeGroup("AnyCopperBar", 10); + recipe.AddIngredient(ItemID.Glass, 15); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/DecryptionComputer.png b/Items/DraedonMisc/DecryptionComputer.png new file mode 100644 index 0000000000..bfe9dcbb2b Binary files /dev/null and b/Items/DraedonMisc/DecryptionComputer.png differ diff --git a/Items/DraedonMisc/EncryptedSchematic.cs b/Items/DraedonMisc/EncryptedSchematic.cs deleted file mode 100644 index 917e9198b9..0000000000 --- a/Items/DraedonMisc/EncryptedSchematic.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.DraedonMisc -{ - public class EncryptedSchematic : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Encrypted Schematic"); - Tooltip.SetDefault("It's impossible to decipher"); // But not for long. - } - - public override void SetDefaults() - { - item.width = 42; - item.height = 42; - item.rare = ItemRarityID.Red; - item.Calamity().customRarity = CalamityRarity.DraedonRust; - item.maxStack = 999; - } - } -} diff --git a/Items/DraedonMisc/EncryptedSchematicHell.cs b/Items/DraedonMisc/EncryptedSchematicHell.cs new file mode 100644 index 0000000000..cac05ab946 --- /dev/null +++ b/Items/DraedonMisc/EncryptedSchematicHell.cs @@ -0,0 +1,46 @@ +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DraedonMisc +{ + public class EncryptedSchematicHell : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Encrypted Schematic"); + Tooltip.SetDefault("Requires a Codebreaker with a sophisticated display to decrypt"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 42; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.maxStack = 1; + } + + public override void UpdateInventory(Player player) + { + if (Main.myPlayer == player.whoAmI && !RecipeUnlockHandler.HasFoundHellSchematic) + { + RecipeUnlockHandler.HasFoundHellSchematic = true; + CalamityNetcode.SyncWorld(); + } + } + + public override void AddRecipes() + { + SchematicRecipe recipe = new SchematicRecipe(mod, "Hell"); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.Glass, 50); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/EncryptedSchematicHell.png b/Items/DraedonMisc/EncryptedSchematicHell.png new file mode 100644 index 0000000000..ee834c680c Binary files /dev/null and b/Items/DraedonMisc/EncryptedSchematicHell.png differ diff --git a/Items/DraedonMisc/EncryptedSchematicIce.cs b/Items/DraedonMisc/EncryptedSchematicIce.cs new file mode 100644 index 0000000000..b84d3b2f93 --- /dev/null +++ b/Items/DraedonMisc/EncryptedSchematicIce.cs @@ -0,0 +1,47 @@ +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.DraedonStructures; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DraedonMisc +{ + public class EncryptedSchematicIce : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Encrypted Schematic"); + Tooltip.SetDefault("Requires a Codebreaker with a complex voltage regulation system to decrypt"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 42; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.maxStack = 1; + } + + public override void UpdateInventory(Player player) + { + if (Main.myPlayer == player.whoAmI && !RecipeUnlockHandler.HasFoundIceSchematic) + { + RecipeUnlockHandler.HasFoundIceSchematic = true; + CalamityNetcode.SyncWorld(); + } + } + + public override void AddRecipes() + { + SchematicRecipe recipe = new SchematicRecipe(mod, "Ice"); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.Glass, 50); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/EncryptedSchematicIce.png b/Items/DraedonMisc/EncryptedSchematicIce.png new file mode 100644 index 0000000000..6cad0a82a1 Binary files /dev/null and b/Items/DraedonMisc/EncryptedSchematicIce.png differ diff --git a/Items/DraedonMisc/EncryptedSchematicJungle.cs b/Items/DraedonMisc/EncryptedSchematicJungle.cs new file mode 100644 index 0000000000..febfbe0ca6 --- /dev/null +++ b/Items/DraedonMisc/EncryptedSchematicJungle.cs @@ -0,0 +1,46 @@ +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DraedonMisc +{ + public class EncryptedSchematicJungle : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Encrypted Schematic"); + Tooltip.SetDefault("Requires a Codebreaker with a fine tuned, long range sensor to decrypt"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 42; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.maxStack = 1; + } + + public override void UpdateInventory(Player player) + { + if (Main.myPlayer == player.whoAmI && !RecipeUnlockHandler.HasFoundJungleSchematic) + { + RecipeUnlockHandler.HasFoundJungleSchematic = true; + CalamityNetcode.SyncWorld(); + } + } + + public override void AddRecipes() + { + SchematicRecipe recipe = new SchematicRecipe(mod, "Jungle"); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.Glass, 50); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/EncryptedSchematicJungle.png b/Items/DraedonMisc/EncryptedSchematicJungle.png new file mode 100644 index 0000000000..f89f6ef3d0 Binary files /dev/null and b/Items/DraedonMisc/EncryptedSchematicJungle.png differ diff --git a/Items/DraedonMisc/EncryptedSchematicPlanetoid.cs b/Items/DraedonMisc/EncryptedSchematicPlanetoid.cs new file mode 100644 index 0000000000..17f131482d --- /dev/null +++ b/Items/DraedonMisc/EncryptedSchematicPlanetoid.cs @@ -0,0 +1,46 @@ +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DraedonMisc +{ + public class EncryptedSchematicPlanetoid : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Encrypted Schematic"); + Tooltip.SetDefault("Requires a Codebreaker with a basic decryption computer to decrypt"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 42; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.maxStack = 1; + } + + public override void UpdateInventory(Player player) + { + if (Main.myPlayer == player.whoAmI && !RecipeUnlockHandler.HasFoundPlanetoidSchematic) + { + RecipeUnlockHandler.HasFoundPlanetoidSchematic = true; + CalamityNetcode.SyncWorld(); + } + } + + public override void AddRecipes() + { + SchematicRecipe recipe = new SchematicRecipe(mod, "Planetoid"); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.Glass, 50); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/EncryptedSchematic.png b/Items/DraedonMisc/EncryptedSchematicPlanetoid.png similarity index 100% rename from Items/DraedonMisc/EncryptedSchematic.png rename to Items/DraedonMisc/EncryptedSchematicPlanetoid.png diff --git a/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs b/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs new file mode 100644 index 0000000000..f5e161e900 --- /dev/null +++ b/Items/DraedonMisc/EncryptedSchematicSunkenSea.cs @@ -0,0 +1,52 @@ +using CalamityMod.CustomRecipes; +using CalamityMod.Items.Materials; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.DraedonMisc +{ + public class EncryptedSchematicSunkenSea : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Schematic"); + Tooltip.SetDefault("You can barely make out its text...\n" + + "Finely detailed diagrams of numerous devices and weaponry dance across the holographic screen\n" + + "Picking up this item or holding it in your inventory permanently unlocks new recipes"); + } + + public override void SetDefaults() + { + item.width = 42; + item.height = 42; + item.rare = ItemRarityID.Red; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + item.maxStack = 1; + } + + public override void UpdateInventory(Player player) + { + // Since no decrypting is necessary for this item simply placing it in your inventory is sufficient enough to "learn" + // from it. + if (Main.myPlayer == player.whoAmI && (!RecipeUnlockHandler.HasUnlockedT1ArsenalRecipes || !RecipeUnlockHandler.HasFoundSunkenSeaSchematic)) + { + RecipeUnlockHandler.HasFoundSunkenSeaSchematic = true; + RecipeUnlockHandler.HasUnlockedT1ArsenalRecipes = true; + CalamityNetcode.SyncWorld(); + } + } + + // Recipe exists for posierity. + public override void AddRecipes() + { + SchematicRecipe recipe = new SchematicRecipe(mod, "Sunken Sea"); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.Glass, 50); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/EncryptedSchematicSunkenSea.png b/Items/DraedonMisc/EncryptedSchematicSunkenSea.png new file mode 100644 index 0000000000..86a157d03b Binary files /dev/null and b/Items/DraedonMisc/EncryptedSchematicSunkenSea.png differ diff --git a/Items/DraedonMisc/LongRangedSensorArray.cs b/Items/DraedonMisc/LongRangedSensorArray.cs new file mode 100644 index 0000000000..ae8e845f8c --- /dev/null +++ b/Items/DraedonMisc/LongRangedSensorArray.cs @@ -0,0 +1,68 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.DraedonSummoner; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.TileEntities; +using CalamityMod.CustomRecipes; +using System.Collections.Generic; + +namespace CalamityMod.Items.DraedonMisc +{ + public class LongRangedSensorArray : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Long Ranged Sensor Array"); + Tooltip.SetDefault("Can be placed on the Codebreaker"); + } + + public override void SetDefaults() + { + item.width = 52; + item.height = 52; + item.maxStack = 999; + item.consumable = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.rare = ItemRarityID.Pink; + item.useTime = item.useAnimation = 15; + } + + public override bool UseItem(Player player) => true; + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + + public override bool ConsumeItem(Player player) + { + Point placeTileCoords = Main.MouseWorld.ToTileCoordinates(); + Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y); + float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f; + + if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType()) + { + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare); + if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsSensorArray) + return false; + + codebreakerTileEntity.ContainsSensorArray = true; + codebreakerTileEntity.SyncConstituents(); + return true; + } + + return false; + } + + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ItemID.HallowedBar, 10); + recipe.AddIngredient(ItemID.Wire, 50); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/LongRangedSensorArray.png b/Items/DraedonMisc/LongRangedSensorArray.png new file mode 100644 index 0000000000..3b9a2bb067 Binary files /dev/null and b/Items/DraedonMisc/LongRangedSensorArray.png differ diff --git a/Items/DraedonMisc/VoltageRegulationSystem.cs b/Items/DraedonMisc/VoltageRegulationSystem.cs new file mode 100644 index 0000000000..0b048f36c6 --- /dev/null +++ b/Items/DraedonMisc/VoltageRegulationSystem.cs @@ -0,0 +1,69 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Tiles.DraedonSummoner; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Microsoft.Xna.Framework; +using CalamityMod.TileEntities; +using CalamityMod.CustomRecipes; +using System.Collections.Generic; + +namespace CalamityMod.Items.DraedonMisc +{ + public class VoltageRegulationSystem : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Voltage Regulation System"); + Tooltip.SetDefault("Can be placed on the Codebreaker"); + } + + public override void SetDefaults() + { + item.width = 52; + item.height = 52; + item.maxStack = 999; + item.consumable = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + item.useTime = item.useAnimation = 15; + } + + public override bool UseItem(Player player) => true; + + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + + public override bool ConsumeItem(Player player) + { + Point placeTileCoords = Main.MouseWorld.ToTileCoordinates(); + Tile tile = CalamityUtils.ParanoidTileRetrieval(placeTileCoords.X, placeTileCoords.Y); + float checkDistance = ((Player.tileRangeX + Player.tileRangeY) / 2f + player.blockRange) * 16f; + + if (Main.myPlayer == player.whoAmI && player.WithinRange(Main.MouseWorld, checkDistance) && tile.active() && tile.type == ModContent.TileType()) + { + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(placeTileCoords.X, placeTileCoords.Y, CodebreakerTile.Width, CodebreakerTile.Height, CodebreakerTile.SheetSquare); + if (codebreakerTileEntity is null || codebreakerTileEntity.ContainsVoltageRegulationSystem) + return false; + + codebreakerTileEntity.ContainsVoltageRegulationSystem = true; + codebreakerTileEntity.SyncConstituents(); + return true; + } + + return false; + } + + public override void AddRecipes() + { + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 10); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ItemID.LunarBar, 5); + recipe.AddTile(TileID.MythrilAnvil); + recipe.SetResult(this, 1); + recipe.AddRecipe(); + } + } +} diff --git a/Items/DraedonMisc/VoltageRegulationSystem.png b/Items/DraedonMisc/VoltageRegulationSystem.png new file mode 100644 index 0000000000..4336750cba Binary files /dev/null and b/Items/DraedonMisc/VoltageRegulationSystem.png differ diff --git a/Items/LabFinders/CyanSeekingMechanism.cs b/Items/LabFinders/CyanSeekingMechanism.cs new file mode 100644 index 0000000000..76ac4b77c6 --- /dev/null +++ b/Items/LabFinders/CyanSeekingMechanism.cs @@ -0,0 +1,44 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.LabFinders +{ + public class CyanSeekingMechanism : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cyan Seeking Mechanism"); + Tooltip.SetDefault("Moves swiftly towards a lab deep below the desert"); + } + + public override void SetDefaults() + { + item.width = 24; + item.height = 26; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = item.useAnimation = 36; + item.shoot = ModContent.ProjectileType(); + item.Calamity().MaxCharge = 100; + item.Calamity().ChargePerUse = 15; + item.Calamity().UsesCharge = true; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.SunkenSeaLabCenter != Vector2.Zero; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.WaterBucket); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/LabFinders/CyanSeekingMechanism.png b/Items/LabFinders/CyanSeekingMechanism.png new file mode 100644 index 0000000000..edd68f889e Binary files /dev/null and b/Items/LabFinders/CyanSeekingMechanism.png differ diff --git a/Items/LabFinders/GreenSeekingMechanism.cs b/Items/LabFinders/GreenSeekingMechanism.cs new file mode 100644 index 0000000000..da3188e614 --- /dev/null +++ b/Items/LabFinders/GreenSeekingMechanism.cs @@ -0,0 +1,44 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.LabFinders +{ + public class GreenSeekingMechanism : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Green Seeking Mechanism"); + Tooltip.SetDefault("Moves swiftly towards a lab within the jungle"); + } + + public override void SetDefaults() + { + item.width = 24; + item.height = 26; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = item.useAnimation = 36; + item.shoot = ModContent.ProjectileType(); + item.Calamity().MaxCharge = 100; + item.Calamity().ChargePerUse = 15; + item.Calamity().UsesCharge = true; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.JungleLabCenter != Vector2.Zero; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.Vine, 3); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/LabFinders/GreenSeekingMechanism.png b/Items/LabFinders/GreenSeekingMechanism.png new file mode 100644 index 0000000000..1f1377a9b9 Binary files /dev/null and b/Items/LabFinders/GreenSeekingMechanism.png differ diff --git a/Items/LabFinders/MysteriousMechanism.cs b/Items/LabFinders/MysteriousMechanism.cs new file mode 100644 index 0000000000..51dd30ac8d --- /dev/null +++ b/Items/LabFinders/MysteriousMechanism.cs @@ -0,0 +1,36 @@ +using CalamityMod.Items.Materials; +using CalamityMod.Projectiles.Typeless; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.LabFinders +{ + public class MysteriousMechanism : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Mysterious Mechanism"); + Tooltip.SetDefault("Used as a base for specialized homing technology"); + } + + public override void SetDefaults() + { + item.width = 24; + item.height = 26; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ModContent.ItemType(), 4); + recipe.AddIngredient(ItemID.IronBar, 10); + recipe.anyIronBar = true; + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/LabFinders/MysteriousMechanism.png b/Items/LabFinders/MysteriousMechanism.png new file mode 100644 index 0000000000..7f12c1775f Binary files /dev/null and b/Items/LabFinders/MysteriousMechanism.png differ diff --git a/Items/LabFinders/PurpleSeekingMechanism.cs b/Items/LabFinders/PurpleSeekingMechanism.cs new file mode 100644 index 0000000000..28e08b4a5b --- /dev/null +++ b/Items/LabFinders/PurpleSeekingMechanism.cs @@ -0,0 +1,44 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.LabFinders +{ + public class PurpleSeekingMechanism : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Purple Seeking Mechanism"); + Tooltip.SetDefault("Moves swiftly towards a lab within the sky"); + } + + public override void SetDefaults() + { + item.width = 24; + item.height = 26; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = item.useAnimation = 36; + item.shoot = ModContent.ProjectileType(); + item.Calamity().MaxCharge = 100; + item.Calamity().ChargePerUse = 15; + item.Calamity().UsesCharge = true; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.PlanetoidLabCenter != Vector2.Zero; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.Cloud, 20); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/LabFinders/PurpleSeekingMechanism.png b/Items/LabFinders/PurpleSeekingMechanism.png new file mode 100644 index 0000000000..aaf94eb5f1 Binary files /dev/null and b/Items/LabFinders/PurpleSeekingMechanism.png differ diff --git a/Items/LabFinders/RedSeekingMechanism.cs b/Items/LabFinders/RedSeekingMechanism.cs new file mode 100644 index 0000000000..ffd99cb84d --- /dev/null +++ b/Items/LabFinders/RedSeekingMechanism.cs @@ -0,0 +1,44 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.LabFinders +{ + public class RedSeekingMechanism : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Red Seeking Mechanism"); + Tooltip.SetDefault("Moves swiftly towards a lab within the underworld"); + } + + public override void SetDefaults() + { + item.width = 24; + item.height = 26; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = item.useAnimation = 36; + item.shoot = ModContent.ProjectileType(); + item.Calamity().MaxCharge = 100; + item.Calamity().ChargePerUse = 15; + item.Calamity().UsesCharge = true; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.HellLabCenter != Vector2.Zero; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.HellstoneBar, 4); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/LabFinders/RedSeekingMechanism.png b/Items/LabFinders/RedSeekingMechanism.png new file mode 100644 index 0000000000..0b1ff1cb19 Binary files /dev/null and b/Items/LabFinders/RedSeekingMechanism.png differ diff --git a/Items/LabFinders/YellowSeekingMechanism.cs b/Items/LabFinders/YellowSeekingMechanism.cs new file mode 100644 index 0000000000..a54448c777 --- /dev/null +++ b/Items/LabFinders/YellowSeekingMechanism.cs @@ -0,0 +1,44 @@ +using CalamityMod.Projectiles.Typeless; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.LabFinders +{ + public class YellowSeekingMechanism : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Yellow Seeking Mechanism"); + Tooltip.SetDefault("Moves swiftly towards a lab within the frozen caverns"); + } + + public override void SetDefaults() + { + item.width = 24; + item.height = 26; + item.noUseGraphic = true; + item.useStyle = ItemUseStyleID.SwingThrow; + item.useTime = item.useAnimation = 36; + item.shoot = ModContent.ProjectileType(); + item.Calamity().MaxCharge = 100; + item.Calamity().ChargePerUse = 15; + item.Calamity().UsesCharge = true; + item.Calamity().customRarity = CalamityRarity.DraedonRust; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && CalamityWorld.IceLabCenter != Vector2.Zero; + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ItemID.IceBlock, 50); + recipe.AddTile(TileID.Anvils); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/LabFinders/YellowSeekingMechanism.png b/Items/LabFinders/YellowSeekingMechanism.png new file mode 100644 index 0000000000..d0d0dfe69c Binary files /dev/null and b/Items/LabFinders/YellowSeekingMechanism.png differ diff --git a/Items/Mounts/GazeOfCrysthamyr.cs b/Items/Mounts/GazeOfCrysthamyr.cs index a6ce67377b..032c9cc707 100644 --- a/Items/Mounts/GazeOfCrysthamyr.cs +++ b/Items/Mounts/GazeOfCrysthamyr.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; +using CalamityMod.Tiles.Furniture.CraftingStations; using Terraria.ID; using Terraria.ModLoader; @@ -35,9 +36,9 @@ namespace CalamityMod.Items.Mounts ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.DD2PetDragon); recipe.AddIngredient(ItemID.SoulofNight, 100); - recipe.AddIngredient(ModContent.ItemType(), 50); + recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Mounts/Minecarts/DoGCart.cs b/Items/Mounts/Minecarts/DoGCart.cs index 14a57c6553..d715135e6a 100644 --- a/Items/Mounts/Minecarts/DoGCart.cs +++ b/Items/Mounts/Minecarts/DoGCart.cs @@ -32,7 +32,7 @@ namespace CalamityMod.Items.Mounts.Minecarts { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 10); - recipe.AddIngredient(ModContent.ItemType(), 1); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ItemID.Wire, 60); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); diff --git a/Items/Placeables/FurnitureSilva/SilvaCrystal.cs b/Items/Placeables/FurnitureSilva/SilvaCrystal.cs index 0ba123cb02..492271d146 100644 --- a/Items/Placeables/FurnitureSilva/SilvaCrystal.cs +++ b/Items/Placeables/FurnitureSilva/SilvaCrystal.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Placeables.FurnitureSilva recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType()); recipe.SetResult(this, 400); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddTile(ModContent.TileType()); recipe.AddRecipe(); recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 4); diff --git a/Items/Tools/MarniteObliterator.cs b/Items/Tools/MarniteObliterator.cs index 15f438f125..7c47be1e83 100644 --- a/Items/Tools/MarniteObliterator.cs +++ b/Items/Tools/MarniteObliterator.cs @@ -33,7 +33,8 @@ namespace CalamityMod.Items.Tools item.autoReuse = true; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 40f; - } + item.Calamity().trueMelee = true; + } public override void AddRecipes() { diff --git a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs index 7c4d99b2c1..703bc5730c 100644 --- a/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs +++ b/Items/Weapons/DraedonsArsenal/FrequencyManipulator.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -50,6 +52,8 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { int proj = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); @@ -60,7 +64,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ItemID.HallowedBar, 10); diff --git a/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs b/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs index a55146abb1..816c0561d0 100644 --- a/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs +++ b/Items/Weapons/DraedonsArsenal/GalvanizingGlaive.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -50,6 +52,8 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { float swingOffset = Main.rand.NextFloat(0.5f, 1f) * item.shootSpeed * 1.6f * player.direction; @@ -59,7 +63,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs index 0b1bd13c12..3e5ed17b95 100644 --- a/Items/Weapons/DraedonsArsenal/GatlingLaser.cs +++ b/Items/Weapons/DraedonsArsenal/GatlingLaser.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -53,6 +55,8 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { Projectile.NewProjectile(position.X, position.Y, speedX, speedY, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, 0f, 0f); @@ -63,7 +67,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Weapons/DraedonsArsenal/GaussDagger.cs b/Items/Weapons/DraedonsArsenal/GaussDagger.cs index fb0c702115..22455c6a18 100644 --- a/Items/Weapons/DraedonsArsenal/GaussDagger.cs +++ b/Items/Weapons/DraedonsArsenal/GaussDagger.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -43,6 +45,8 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal modItem.ChargePerUse = 0.05f; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void OnHitNPC(Player player, NPC target, int damage, float knockBack, bool crit) { target.Calamity().GaussFluxTimer += 50; @@ -61,7 +65,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 7); recipe.AddIngredient(ModContent.ItemType(), 4); diff --git a/Items/Weapons/DraedonsArsenal/GaussPistol.cs b/Items/Weapons/DraedonsArsenal/GaussPistol.cs index ff9b51e329..3a0479552d 100644 --- a/Items/Weapons/DraedonsArsenal/GaussPistol.cs +++ b/Items/Weapons/DraedonsArsenal/GaussPistol.cs @@ -1,5 +1,7 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; +using System.Collections.Generic; using Terraria.ID; using Terraria.ModLoader; @@ -43,9 +45,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal modItem.ChargePerUse = 0.05f; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ItemID.HallowedBar, 10); diff --git a/Items/Weapons/DraedonsArsenal/GaussRifle.cs b/Items/Weapons/DraedonsArsenal/GaussRifle.cs index 9616aed0c3..0645432e36 100644 --- a/Items/Weapons/DraedonsArsenal/GaussRifle.cs +++ b/Items/Weapons/DraedonsArsenal/GaussRifle.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -50,9 +52,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs b/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs index bce57c4285..96311baab1 100644 --- a/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs +++ b/Items/Weapons/DraedonsArsenal/HydraulicVoltCrasher.cs @@ -1,5 +1,7 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -43,6 +45,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal item.melee = true; item.channel = true; + modItem.trueMelee = true; modItem.UsesCharge = true; modItem.MaxCharge = 85f; modItem.ChargePerUse = 0f; // This weapon is a holdout. Charge is consumed by the holdout projectile. @@ -50,9 +53,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0 && item.Calamity().Charge > 0; + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ItemID.HallowedBar, 10); diff --git a/Items/Weapons/DraedonsArsenal/LaserRifle.cs b/Items/Weapons/DraedonsArsenal/LaserRifle.cs index 8c7c871921..929cda4cdb 100644 --- a/Items/Weapons/DraedonsArsenal/LaserRifle.cs +++ b/Items/Weapons/DraedonsArsenal/LaserRifle.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -62,6 +64,8 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override Vector2? HoldoutOffset() { return new Vector2(-20, 0); @@ -69,7 +73,7 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/MatterModulator.cs b/Items/Weapons/DraedonsArsenal/MatterModulator.cs index 3a23cd49a4..3356fa79e6 100644 --- a/Items/Weapons/DraedonsArsenal/MatterModulator.cs +++ b/Items/Weapons/DraedonsArsenal/MatterModulator.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -55,9 +57,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ItemID.HallowedBar, 10); diff --git a/Items/Weapons/DraedonsArsenal/MountedScanner.cs b/Items/Weapons/DraedonsArsenal/MountedScanner.cs index 111768cff3..51db8b0507 100644 --- a/Items/Weapons/DraedonsArsenal/MountedScanner.cs +++ b/Items/Weapons/DraedonsArsenal/MountedScanner.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -84,9 +86,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 2); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 2); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ItemID.HallowedBar, 10); diff --git a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs index dfb2111900..9a917740b1 100644 --- a/Items/Weapons/DraedonsArsenal/Phaseslayer.cs +++ b/Items/Weapons/DraedonsArsenal/Phaseslayer.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -69,9 +71,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 25); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs index 670409b303..a9033eac84 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaCaster.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -95,9 +97,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return new Vector2(-10, 0); } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs index 654b447d29..1346f4f8bb 100644 --- a/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs +++ b/Items/Weapons/DraedonsArsenal/PlasmaGrenade.cs @@ -1,8 +1,10 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -57,9 +59,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType()); diff --git a/Items/Weapons/DraedonsArsenal/PoleWarper.cs b/Items/Weapons/DraedonsArsenal/PoleWarper.cs index 529765ce5a..f9da2e0cfb 100644 --- a/Items/Weapons/DraedonsArsenal/PoleWarper.cs +++ b/Items/Weapons/DraedonsArsenal/PoleWarper.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -80,9 +82,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 52); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); recipe.AddIngredient(ModContent.ItemType(), 25); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/PulseDragon.cs b/Items/Weapons/DraedonsArsenal/PulseDragon.cs index f647169ffa..81eee4591f 100644 --- a/Items/Weapons/DraedonsArsenal/PulseDragon.cs +++ b/Items/Weapons/DraedonsArsenal/PulseDragon.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -58,9 +60,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/PulsePistol.cs b/Items/Weapons/DraedonsArsenal/PulsePistol.cs index 0659abbf32..1fec36a440 100644 --- a/Items/Weapons/DraedonsArsenal/PulsePistol.cs +++ b/Items/Weapons/DraedonsArsenal/PulsePistol.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -52,9 +54,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override Vector2? HoldoutOffset() => new Vector2(10f, 0f); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 7); recipe.AddIngredient(ModContent.ItemType(), 4); diff --git a/Items/Weapons/DraedonsArsenal/PulseRifle.cs b/Items/Weapons/DraedonsArsenal/PulseRifle.cs index 206f0d0e4c..ce71f5608b 100644 --- a/Items/Weapons/DraedonsArsenal/PulseRifle.cs +++ b/Items/Weapons/DraedonsArsenal/PulseRifle.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -67,9 +69,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override Vector2? HoldoutOffset() => new Vector2(-10, 0); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs b/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs index 9cc1ac8f71..d83697b76a 100644 --- a/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs +++ b/Items/Weapons/DraedonsArsenal/PulseTurretRemote.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -57,9 +59,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs index 2051589a03..b29efef263 100644 --- a/Items/Weapons/DraedonsArsenal/SnakeEyes.cs +++ b/Items/Weapons/DraedonsArsenal/SnakeEyes.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Summon; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -53,9 +55,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs b/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs index 162ed1187d..33eb8cdbef 100644 --- a/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs +++ b/Items/Weapons/DraedonsArsenal/StarSwallowerContainmentUnit.cs @@ -1,6 +1,8 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -55,9 +57,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddIngredient(ModContent.ItemType(), 4); diff --git a/Items/Weapons/DraedonsArsenal/SystemBane.cs b/Items/Weapons/DraedonsArsenal/SystemBane.cs index 43cb0cfddf..64991564af 100644 --- a/Items/Weapons/DraedonsArsenal/SystemBane.cs +++ b/Items/Weapons/DraedonsArsenal/SystemBane.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -58,9 +60,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 3); recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 5); diff --git a/Items/Weapons/DraedonsArsenal/Taser.cs b/Items/Weapons/DraedonsArsenal/Taser.cs index 19f7a9c04a..cec40c61eb 100644 --- a/Items/Weapons/DraedonsArsenal/Taser.cs +++ b/Items/Weapons/DraedonsArsenal/Taser.cs @@ -1,5 +1,7 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -45,9 +47,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); recipe.AddIngredient(ModContent.ItemType(), 7); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 4); diff --git a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs index 6154ff1e54..14ab9d1ac1 100644 --- a/Items/Weapons/DraedonsArsenal/TeslaCannon.cs +++ b/Items/Weapons/DraedonsArsenal/TeslaCannon.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Projectiles.DraedonsArsenal; using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -68,9 +70,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal public override Vector2? HoldoutOffset() => new Vector2(-20, 0); + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 5); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 5); recipe.AddIngredient(ModContent.ItemType(), 25); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs b/Items/Weapons/DraedonsArsenal/TrackingDisk.cs index 08db5e5ffc..d61410933e 100644 --- a/Items/Weapons/DraedonsArsenal/TrackingDisk.cs +++ b/Items/Weapons/DraedonsArsenal/TrackingDisk.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -58,9 +60,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 1); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 1); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 7); recipe.AddIngredient(ModContent.ItemType(), 4); diff --git a/Items/Weapons/DraedonsArsenal/WavePounder.cs b/Items/Weapons/DraedonsArsenal/WavePounder.cs index 4de1908432..dd5cb060aa 100644 --- a/Items/Weapons/DraedonsArsenal/WavePounder.cs +++ b/Items/Weapons/DraedonsArsenal/WavePounder.cs @@ -1,7 +1,9 @@ +using CalamityMod.CustomRecipes; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Rogue; using CalamityMod.Projectiles.DraedonsArsenal; using Microsoft.Xna.Framework; +using System.Collections.Generic; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -56,9 +58,11 @@ namespace CalamityMod.Items.Weapons.DraedonsArsenal return false; } + public override void ModifyTooltips(List tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 4); + public override void AddRecipes() { - ModRecipe recipe = new ModRecipe(mod); + ArsenalTierGatedRecipe recipe = new ArsenalTierGatedRecipe(mod, 4); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddIngredient(ModContent.ItemType(), 8); diff --git a/Items/Weapons/Magic/AlphaRay.cs b/Items/Weapons/Magic/AlphaRay.cs index 228546ecf9..e197165583 100644 --- a/Items/Weapons/Magic/AlphaRay.cs +++ b/Items/Weapons/Magic/AlphaRay.cs @@ -80,8 +80,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Magic/EventHorizon.cs b/Items/Weapons/Magic/EventHorizon.cs index 115962a0e6..c523d60ef4 100644 --- a/Items/Weapons/Magic/EventHorizon.cs +++ b/Items/Weapons/Magic/EventHorizon.cs @@ -57,7 +57,8 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddTile(TileID.Bookcases); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Magic/FaceMelter.cs b/Items/Weapons/Magic/FaceMelter.cs index 37cf56678c..3201f0e701 100644 --- a/Items/Weapons/Magic/FaceMelter.cs +++ b/Items/Weapons/Magic/FaceMelter.cs @@ -50,7 +50,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ItemID.MagicalHarp); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Magic/IceBarrage.cs b/Items/Weapons/Magic/IceBarrage.cs index 7978b1cd4c..12ef782e39 100644 --- a/Items/Weapons/Magic/IceBarrage.cs +++ b/Items/Weapons/Magic/IceBarrage.cs @@ -71,7 +71,8 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ItemID.BlizzardStaff); recipe.AddIngredient(ItemID.IceRod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 23); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 40); recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddTile(TileID.IceMachine); recipe.SetResult(this); diff --git a/Items/Weapons/Magic/LightGodsBrilliance.cs b/Items/Weapons/Magic/LightGodsBrilliance.cs index a0166c273c..94e3482229 100644 --- a/Items/Weapons/Magic/LightGodsBrilliance.cs +++ b/Items/Weapons/Magic/LightGodsBrilliance.cs @@ -54,9 +54,10 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ItemID.HolyWater, 10); - recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddIngredient(ItemID.SoulofLight, 30); recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(TileID.Bookcases); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Magic/PrimordialAncient.cs b/Items/Weapons/Magic/PrimordialAncient.cs index 878952e3d1..83e8c1b6b1 100644 --- a/Items/Weapons/Magic/PrimordialAncient.cs +++ b/Items/Weapons/Magic/PrimordialAncient.cs @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ItemID.AncientBattleArmorMaterial, 5); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(TileID.Bookcases); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Magic/RecitationoftheBeast.cs b/Items/Weapons/Magic/RecitationoftheBeast.cs index 55aa46d0ed..032cfc6cd8 100644 --- a/Items/Weapons/Magic/RecitationoftheBeast.cs +++ b/Items/Weapons/Magic/RecitationoftheBeast.cs @@ -64,7 +64,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ItemID.DemonScythe); recipe.AddIngredient(ModContent.ItemType(), 12); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(TileID.Bookcases); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/AstralPike.cs b/Items/Weapons/Melee/AstralPike.cs index 70de4755f0..f2220b17a8 100644 --- a/Items/Weapons/Melee/AstralPike.cs +++ b/Items/Weapons/Melee/AstralPike.cs @@ -33,7 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Cyan; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 13f; - } + item.Calamity().trueMelee = true; + } // Terraria seems to really dislike high crit values in SetDefaults public override void GetWeaponCrit(Player player, ref int crit) => crit += 25; diff --git a/Items/Weapons/Melee/Brimlance.cs b/Items/Weapons/Melee/Brimlance.cs index 81c28ce962..6f145669ee 100644 --- a/Items/Weapons/Melee/Brimlance.cs +++ b/Items/Weapons/Melee/Brimlance.cs @@ -32,7 +32,8 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Pink; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 12f; - } + item.Calamity().trueMelee = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; } diff --git a/Items/Weapons/Melee/DevilsDevastation.cs b/Items/Weapons/Melee/DevilsDevastation.cs index 5e92f8e618..363286dcf8 100644 --- a/Items/Weapons/Melee/DevilsDevastation.cs +++ b/Items/Weapons/Melee/DevilsDevastation.cs @@ -108,7 +108,7 @@ namespace CalamityMod.Items.Weapons.Melee recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/DevilsSunrise.cs b/Items/Weapons/Melee/DevilsSunrise.cs index 9ddc1e4168..85facd6e4d 100644 --- a/Items/Weapons/Melee/DevilsSunrise.cs +++ b/Items/Weapons/Melee/DevilsSunrise.cs @@ -36,7 +36,8 @@ namespace CalamityMod.Items.Weapons.Melee item.Calamity().customRarity = CalamityRarity.Turquoise; item.Calamity().donorItem = true; - item.shoot = ModContent.ProjectileType(); + item.Calamity().trueMelee = true; + item.shoot = ModContent.ProjectileType(); item.shootSpeed = 24f; } diff --git a/Items/Weapons/Melee/DiseasedPike.cs b/Items/Weapons/Melee/DiseasedPike.cs index 096fd9403f..a7988c2481 100644 --- a/Items/Weapons/Melee/DiseasedPike.cs +++ b/Items/Weapons/Melee/DiseasedPike.cs @@ -32,7 +32,8 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Yellow; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; - } + item.Calamity().trueMelee = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; } diff --git a/Items/Weapons/Melee/DragonRage.cs b/Items/Weapons/Melee/DragonRage.cs index 87d83b467d..3e2e7036c9 100644 --- a/Items/Weapons/Melee/DragonRage.cs +++ b/Items/Weapons/Melee/DragonRage.cs @@ -35,6 +35,7 @@ namespace CalamityMod.Items.Weapons.Melee item.value = CalamityGlobalItem.Rarity15BuyPrice; item.rare = ItemRarityID.Purple; item.Calamity().customRarity = CalamityRarity.Violet; - } + item.Calamity().trueMelee = true; + } } } diff --git a/Items/Weapons/Melee/EmpyreanKnives.cs b/Items/Weapons/Melee/EmpyreanKnives.cs index ded1b73987..5c173f9264 100644 --- a/Items/Weapons/Melee/EmpyreanKnives.cs +++ b/Items/Weapons/Melee/EmpyreanKnives.cs @@ -104,7 +104,7 @@ namespace CalamityMod.Items.Weapons.Melee recipe.AddIngredient(ItemID.VampireKnives); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/ExsanguinationLance.cs b/Items/Weapons/Melee/ExsanguinationLance.cs index e142c93180..82160962de 100644 --- a/Items/Weapons/Melee/ExsanguinationLance.cs +++ b/Items/Weapons/Melee/ExsanguinationLance.cs @@ -33,7 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Yellow; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; - } + item.Calamity().trueMelee = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Melee/FourSeasonsGalaxia.cs b/Items/Weapons/Melee/FourSeasonsGalaxia.cs index d4d0501ed6..30ce17dd99 100644 --- a/Items/Weapons/Melee/FourSeasonsGalaxia.cs +++ b/Items/Weapons/Melee/FourSeasonsGalaxia.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = 70; - item.damage = 66; + item.damage = 99; item.melee = true; item.useAnimation = 18; item.useTime = 18; @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Melee ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/FulgurationHalberd.cs b/Items/Weapons/Melee/FulgurationHalberd.cs index 8a9059267d..9b4dd908ec 100644 --- a/Items/Weapons/Melee/FulgurationHalberd.cs +++ b/Items/Weapons/Melee/FulgurationHalberd.cs @@ -33,7 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee item.value = Item.buyPrice(0, 36, 0, 0); item.rare = ItemRarityID.Pink; item.shootSpeed = 8f; - } + item.Calamity().trueMelee = true; + } public override bool AltFunctionUse(Player player) { diff --git a/Items/Weapons/Melee/GildedProboscis.cs b/Items/Weapons/Melee/GildedProboscis.cs index e3892577bc..45e411a0e3 100644 --- a/Items/Weapons/Melee/GildedProboscis.cs +++ b/Items/Weapons/Melee/GildedProboscis.cs @@ -32,7 +32,8 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Purple; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 13f; - } + item.Calamity().trueMelee = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; } diff --git a/Items/Weapons/Melee/GreatswordofBlah.cs b/Items/Weapons/Melee/GreatswordofBlah.cs index f8a3db23c5..8225336918 100644 --- a/Items/Weapons/Melee/GreatswordofBlah.cs +++ b/Items/Weapons/Melee/GreatswordofBlah.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { item.width = item.height = 102; - item.damage = 125; + item.damage = 138; item.melee = true; item.useAnimation = 18; item.useStyle = ItemUseStyleID.SwingThrow; @@ -43,7 +43,7 @@ namespace CalamityMod.Items.Weapons.Melee ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/MarniteSpear.cs b/Items/Weapons/Melee/MarniteSpear.cs index 0084cb1ec6..214bba9f81 100644 --- a/Items/Weapons/Melee/MarniteSpear.cs +++ b/Items/Weapons/Melee/MarniteSpear.cs @@ -31,7 +31,8 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Green; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 5f; - } + item.Calamity().trueMelee = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Melee/Murasama.cs b/Items/Weapons/Melee/Murasama.cs index 49d498e579..24abe58de2 100644 --- a/Items/Weapons/Melee/Murasama.cs +++ b/Items/Weapons/Melee/Murasama.cs @@ -42,6 +42,7 @@ namespace CalamityMod.Items.Weapons.Melee item.shootSpeed = 24f; item.Calamity().customRarity = CalamityRarity.Violet; Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(5, 14)); + item.Calamity().trueMelee = true; } // Terraria seems to really dislike high crit values in SetDefaults diff --git a/Items/Weapons/Melee/Nadir.cs b/Items/Weapons/Melee/Nadir.cs index c4d43b73df..b639822bf1 100644 --- a/Items/Weapons/Melee/Nadir.cs +++ b/Items/Weapons/Melee/Nadir.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Melee recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/Omniblade.cs b/Items/Weapons/Melee/Omniblade.cs index 566097b9bd..39fae23d88 100644 --- a/Items/Weapons/Melee/Omniblade.cs +++ b/Items/Weapons/Melee/Omniblade.cs @@ -34,7 +34,8 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = 24f; item.rare = ItemRarityID.Yellow; - } + item.Calamity().trueMelee = true; + } // Terraria seems to really dislike high crit values in SetDefaults public override void GetWeaponCrit(Player player, ref int crit) => crit += 45; diff --git a/Items/Weapons/Melee/PhosphorescentGauntlet.cs b/Items/Weapons/Melee/PhosphorescentGauntlet.cs index 8c977ce9b8..6c67ff0990 100644 --- a/Items/Weapons/Melee/PhosphorescentGauntlet.cs +++ b/Items/Weapons/Melee/PhosphorescentGauntlet.cs @@ -34,6 +34,7 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = 1f; item.Calamity().customRarity = CalamityRarity.PureGreen; + item.Calamity().trueMelee = true; } // Terraria seems to really dislike high crit values in SetDefaults. diff --git a/Items/Weapons/Melee/PrismaticBreaker.cs b/Items/Weapons/Melee/PrismaticBreaker.cs index 561ad7e3c1..47693bf1e0 100644 --- a/Items/Weapons/Melee/PrismaticBreaker.cs +++ b/Items/Weapons/Melee/PrismaticBreaker.cs @@ -162,7 +162,7 @@ namespace CalamityMod.Items.Weapons.Melee recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 3); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Melee/RemsRevenge.cs b/Items/Weapons/Melee/RemsRevenge.cs index 2aff20909c..15266bf64e 100644 --- a/Items/Weapons/Melee/RemsRevenge.cs +++ b/Items/Weapons/Melee/RemsRevenge.cs @@ -17,7 +17,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { - item.damage = 415; + item.damage = 375; item.melee = true; item.width = 44; item.height = 34; diff --git a/Items/Weapons/Melee/SausageMaker.cs b/Items/Weapons/Melee/SausageMaker.cs index bcd63e15e9..47f2b94d96 100644 --- a/Items/Weapons/Melee/SausageMaker.cs +++ b/Items/Weapons/Melee/SausageMaker.cs @@ -33,7 +33,8 @@ namespace CalamityMod.Items.Weapons.Melee item.rare = ItemRarityID.Orange; item.shoot = ModContent.ProjectileType(); item.shootSpeed = 6f; - } + item.Calamity().trueMelee = true; + } public override bool CanUseItem(Player player) => player.ownedProjectileCounts[item.shoot] <= 0; diff --git a/Items/Weapons/Melee/YateveoBloom.cs b/Items/Weapons/Melee/YateveoBloom.cs index a50307d9a7..c58001d435 100644 --- a/Items/Weapons/Melee/YateveoBloom.cs +++ b/Items/Weapons/Melee/YateveoBloom.cs @@ -45,7 +45,8 @@ namespace CalamityMod.Items.Weapons.Melee item.shoot = ModContent.ProjectileType(); item.shootSpeed = ShootSpeed; - } + item.Calamity().trueMelee = true; + } public override bool AltFunctionUse(Player player) { diff --git a/Items/Weapons/Ranged/Alluvion.cs b/Items/Weapons/Ranged/Alluvion.cs index 656ac5558d..8153a926f4 100644 --- a/Items/Weapons/Ranged/Alluvion.cs +++ b/Items/Weapons/Ranged/Alluvion.cs @@ -99,7 +99,7 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Ranged/Karasawa.cs b/Items/Weapons/Ranged/Karasawa.cs index d30e012404..8f3a505b54 100644 --- a/Items/Weapons/Ranged/Karasawa.cs +++ b/Items/Weapons/Ranged/Karasawa.cs @@ -81,7 +81,7 @@ namespace CalamityMod.Items.Weapons.Ranged r.AddIngredient(ModContent.ItemType(), 15); r.AddIngredient(ModContent.ItemType(), 5); r.AddIngredient(ModContent.ItemType(), 8); - r.AddIngredient(ModContent.ItemType(), 2); + r.AddIngredient(ModContent.ItemType(), 20); r.AddTile(ModContent.TileType()); r.SetResult(this); r.AddRecipe(); diff --git a/Items/Weapons/Ranged/Onyxia.cs b/Items/Weapons/Ranged/Onyxia.cs index a92cf34848..184b09b546 100644 --- a/Items/Weapons/Ranged/Onyxia.cs +++ b/Items/Weapons/Ranged/Onyxia.cs @@ -80,8 +80,7 @@ namespace CalamityMod.Items.Weapons.Ranged ModRecipe r = new ModRecipe(mod); r.AddIngredient(ModContent.ItemType()); r.AddIngredient(ModContent.ItemType(), 8); - r.AddIngredient(ModContent.ItemType(), 6); - r.AddIngredient(ModContent.ItemType(), 2); + r.AddIngredient(ModContent.ItemType(), 8); r.AddTile(ModContent.TileType()); r.SetResult(this); r.AddRecipe(); diff --git a/Items/Weapons/Ranged/Phangasm.cs b/Items/Weapons/Ranged/Phangasm.cs index e461a0074d..1137124739 100644 --- a/Items/Weapons/Ranged/Phangasm.cs +++ b/Items/Weapons/Ranged/Phangasm.cs @@ -54,7 +54,7 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddIngredient(ItemID.Phantasm); recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Ranged/RubicoPrime.cs b/Items/Weapons/Ranged/RubicoPrime.cs index 6c0f5a3076..c1f0a1a8de 100644 --- a/Items/Weapons/Ranged/RubicoPrime.cs +++ b/Items/Weapons/Ranged/RubicoPrime.cs @@ -53,7 +53,6 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ModContent.ItemType(), 20); - recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Ranged/SDFMG.cs b/Items/Weapons/Ranged/SDFMG.cs index 879bf534e4..9408f12bd1 100644 --- a/Items/Weapons/Ranged/SDFMG.cs +++ b/Items/Weapons/Ranged/SDFMG.cs @@ -73,7 +73,7 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Ranged/StarfleetMK2.cs b/Items/Weapons/Ranged/StarfleetMK2.cs index af650a63bd..4a994de9b3 100644 --- a/Items/Weapons/Ranged/StarfleetMK2.cs +++ b/Items/Weapons/Ranged/StarfleetMK2.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Ranged/ThePack.cs b/Items/Weapons/Ranged/ThePack.cs index b8e87b7f35..d74a78ba1b 100644 --- a/Items/Weapons/Ranged/ThePack.cs +++ b/Items/Weapons/Ranged/ThePack.cs @@ -56,7 +56,7 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddIngredient(ItemID.MarbleBlock, 50); recipe.AddIngredient(ModContent.ItemType(), 4); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Ranged/Ultima.cs b/Items/Weapons/Ranged/Ultima.cs index 641531080f..8091eaa700 100644 --- a/Items/Weapons/Ranged/Ultima.cs +++ b/Items/Weapons/Ranged/Ultima.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Weapons.Ranged recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Rogue/EclipsesFall.cs b/Items/Weapons/Rogue/EclipsesFall.cs index 39f4604d36..660bf75dc4 100644 --- a/Items/Weapons/Rogue/EclipsesFall.cs +++ b/Items/Weapons/Rogue/EclipsesFall.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Rogue; +using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -52,9 +53,10 @@ namespace CalamityMod.Items.Weapons.Rogue { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ModContent.ItemType(), 12); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Weapons/Rogue/Hypothermia.cs b/Items/Weapons/Rogue/Hypothermia.cs index 9936753070..daa44fd7eb 100644 --- a/Items/Weapons/Rogue/Hypothermia.cs +++ b/Items/Weapons/Rogue/Hypothermia.cs @@ -84,9 +84,8 @@ namespace CalamityMod.Items.Weapons.Rogue ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.IceBlock, 100); recipe.AddIngredient(ModContent.ItemType(), 6); - recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Rogue/Penumbra.cs b/Items/Weapons/Rogue/Penumbra.cs index f041c1318d..6a70ba8894 100644 --- a/Items/Weapons/Rogue/Penumbra.cs +++ b/Items/Weapons/Rogue/Penumbra.cs @@ -72,10 +72,9 @@ namespace CalamityMod.Items.Weapons.Rogue public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 6); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Summon/CorvidHarbringerStaff.cs b/Items/Weapons/Summon/CorvidHarbringerStaff.cs index 5c777bc0a4..f4e6f1aa3e 100644 --- a/Items/Weapons/Summon/CorvidHarbringerStaff.cs +++ b/Items/Weapons/Summon/CorvidHarbringerStaff.cs @@ -51,9 +51,8 @@ namespace CalamityMod.Items.Weapons.Summon { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.RavenStaff); - recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Summon/EndoHydraStaff.cs b/Items/Weapons/Summon/EndoHydraStaff.cs index 79b53ed827..c5123dc0ff 100644 --- a/Items/Weapons/Summon/EndoHydraStaff.cs +++ b/Items/Weapons/Summon/EndoHydraStaff.cs @@ -78,9 +78,8 @@ namespace CalamityMod.Items.Weapons.Summon { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.StaffoftheFrostHydra); - recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 8); - recipe.AddIngredient(ModContent.ItemType(), 2); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Summon/SarosPossession.cs b/Items/Weapons/Summon/SarosPossession.cs index 5debf265f3..ad07758adb 100644 --- a/Items/Weapons/Summon/SarosPossession.cs +++ b/Items/Weapons/Summon/SarosPossession.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Summon; +using CalamityMod.Tiles.Furniture.CraftingStations; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; @@ -9,14 +10,14 @@ namespace CalamityMod.Items.Weapons.Summon { public class SarosPossession : ModItem { - int radianceSlots; + int radianceSlots; public override void SetStaticDefaults() { DisplayName.SetDefault("Saros Possession"); Tooltip.SetDefault("Gain absolute control over light itself\n" + - "Summons a radiant aura\n" + + "Summons a radiant aura\n" + "Consumes all of the remaining minion slots on use\n" + - "Must be used from the hotbar\n" + + "Must be used from the hotbar\n" + "Increased power based on the number of minion slots used"); } @@ -36,33 +37,33 @@ namespace CalamityMod.Items.Weapons.Summon item.shoot = ModContent.ProjectileType(); item.shootSpeed = 10f; - item.value = CalamityGlobalItem.Rarity14BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.DarkBlue; - } + item.value = CalamityGlobalItem.Rarity14BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.DarkBlue; + } - public override void HoldItem(Player player) + public override void HoldItem(Player player) { - double minionCount = 0; - for (int j = 0; j < Main.projectile.Length; j++) - { + double minionCount = 0; + for (int j = 0; j < Main.projectile.Length; j++) + { Projectile proj = Main.projectile[j]; - if (proj.active && proj.owner == player.whoAmI && proj.minion && proj.type != item.shoot) - { - minionCount += proj.minionSlots; - } - } + if (proj.active && proj.owner == player.whoAmI && proj.minion && proj.type != item.shoot) + { + minionCount += proj.minionSlots; + } + } radianceSlots = (int)(player.maxMinions - minionCount); - } + } public override bool CanUseItem(Player player) - { - return radianceSlots >= 1; - } + { + return radianceSlots >= 1; + } public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - CalamityUtils.KillShootProjectiles(true, type, player); + CalamityUtils.KillShootProjectiles(true, type, player); Projectile.NewProjectile(position, Vector2.Zero, type, damage, knockBack, player.whoAmI, radianceSlots); return false; } @@ -71,8 +72,9 @@ namespace CalamityMod.Items.Weapons.Summon { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 25); - recipe.AddTile(TileID.LunarCraftingStation); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddTile(ModContent.TileType()); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Localization/CalamityLocalization.cs b/Localization/CalamityLocalization.cs index 07aca5bfa0..019fcc3a5b 100644 --- a/Localization/CalamityLocalization.cs +++ b/Localization/CalamityLocalization.cs @@ -117,7 +117,14 @@ namespace CalamityMod.Localization new [] { "CryogenBossText", "Cryogen is derping out!" }, - new [] { "HardmodeOreTier1Text", "Your world has been blessed with Cobalt and Palladium!" }, + new [] { "DraedonIntroductionText1", "This is a meeting that has been a long time coming." }, + new [] { "DraedonIntroductionText2", "The machine you constructed, deciphering and incercepting my channels of communication. It is no small feat of ingenuity." }, + new [] { "DraedonIntroductionText3", "I must be upfront, as this is a unique opportunity. Your observations have not been one-sided, and I have grown " + + "interested in your remarkable progression." }, + new [] { "DraedonIntroductionText4", "Humor me, in a battle with the results of my tinkering." }, + new [] { "DraedonIntroductionText5", "You may choose your first opponent." }, + + new [] { "HardmodeOreTier1Text", "Your world has been blessed with Cobalt and Palladium!" }, new [] { "HardmodeOreTier2Text", "Your world has been blessed with Mythril and Orichalcum!" }, new [] { "HardmodeOreTier3Text", "Your world has been blessed with Adamantite and Titanium!" }, new [] { "HardmodeOreTier4Text", "The hallow has been blessed with consecrated stone!" }, @@ -181,7 +188,7 @@ namespace CalamityMod.Localization new [] { "AprilFools2", "A boomer awaits..." }, //possible alternative to GhostBossText4 new [] { "AcidRainStart", "A toxic downpour falls over the wasteland seas!" }, - new [] { "AcidRainEnd", "The sulphuric skies begin to clear..." } + new [] { "AcidRainEnd", "The sulphuric skies begin to clear..." }, }; } diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index 95348faf79..e2a57dea9c 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1637,7 +1637,7 @@ namespace CalamityMod.NPCs // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num824 *= 0.5f; } @@ -1753,7 +1753,7 @@ namespace CalamityMod.NPCs // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num833 *= 0.5f; } @@ -2616,6 +2616,7 @@ namespace CalamityMod.NPCs // Phases bool phase2 = lifeRatio < 0.75f; bool phase3 = lifeRatio < 0.5f; + bool reduceFallSpeed = npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y && npc.ai[0] == 4f; bool despawnDistance = Vector2.Distance(player.Center, npc.Center) > CalamityGlobalNPC.CatchUpDistance350Tiles; @@ -2773,7 +2774,7 @@ namespace CalamityMod.NPCs // Increase defense npc.defense = npc.defDefense; - // Stop colliding with tiles + // Stop colliding with tiles npc.noTileCollide = true; // Set AI to next phase (Walk) and reset other AI @@ -2782,8 +2783,8 @@ namespace CalamityMod.NPCs npc.ai[1] = 0f; npc.netUpdate = true; } - - CustomGravity(); + else + CustomGravity(); } // Walk @@ -2815,41 +2816,50 @@ namespace CalamityMod.NPCs npc.velocity.X = (npc.velocity.X * 20f - num823) / 21f; } - // Walk through tiles if colliding with tiles and player is out of reach - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); - - bool flag52 = false; - if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f) - flag52 = true; - - if (flag52) + if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height) { - npc.velocity.Y += 0.5f; - } - else if (Collision.SolidCollision(position2, num854, num855)) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = 0f; - - if (npc.velocity.Y > -0.2) - npc.velocity.Y -= 0.025f; - else - npc.velocity.Y -= 0.2f; - - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; + CustomGravity(); + npc.noTileCollide = false; } else { - if (npc.velocity.Y < 0f) - npc.velocity.Y = 0f; + npc.noTileCollide = true; + // Walk through tiles if colliding with tiles and player is out of reach + int num854 = 80; + int num855 = 20; + Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); - if (npc.velocity.Y < 0.1) - npc.velocity.Y += 0.025f; - else + bool flag52 = false; + if (npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f) + flag52 = true; + + if (flag52) + { npc.velocity.Y += 0.5f; + } + else if (Collision.SolidCollision(position2, num854, num855)) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = 0f; + + if (npc.velocity.Y > -0.2) + npc.velocity.Y -= 0.025f; + else + npc.velocity.Y -= 0.2f; + + if (npc.velocity.Y < -4f) + npc.velocity.Y = -4f; + } + else + { + if (npc.velocity.Y < 0f) + npc.velocity.Y = 0f; + + if (npc.velocity.Y < 0.1) + npc.velocity.Y += 0.025f; + else + npc.velocity.Y += 0.5f; + } } // Walk for a maximum of 6 seconds @@ -3204,9 +3214,9 @@ namespace CalamityMod.NPCs void CustomGravity() { float gravity = 0.36f + 0.12f * enrageScale; - float maxFallSpeed = 12f + 4f * enrageScale; + float maxFallSpeed = reduceFallSpeed ? 12f : 12f + 4f * enrageScale; - if (calamityGlobalNPC.newAI[0] > 1f) + if (calamityGlobalNPC.newAI[0] > 1f && !reduceFallSpeed) maxFallSpeed *= calamityGlobalNPC.newAI[0]; npc.velocity.Y += gravity; diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 2fdfc7d835..ef2984b464 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -5401,7 +5401,7 @@ namespace CalamityMod.NPCs num422 = 0.175f; } // Reduce acceleration if target is holding a true melee weapon - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num421 *= 0.75f; num422 *= 0.5f; @@ -5512,7 +5512,7 @@ namespace CalamityMod.NPCs num431 = 0.25f; } // Reduce acceleration if target is holding a true melee weapon - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num430 *= 0.75f; num431 *= 0.5f; @@ -5974,7 +5974,7 @@ namespace CalamityMod.NPCs // 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))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num399 *= 0.75f; num400 *= 0.5f; @@ -6084,7 +6084,7 @@ namespace CalamityMod.NPCs // 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))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num409 *= 0.75f; num410 *= 0.5f; @@ -7409,7 +7409,7 @@ namespace CalamityMod.NPCs // 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))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { acceleration *= 0.5f; } @@ -9896,8 +9896,10 @@ namespace CalamityMod.NPCs npc.Calamity().CurrentlyEnraged = (!BossRushEvent.BossRushActive && (enrage || turboEnrage)) || enraged; - // Alpha - if (npc.alpha > 0) + bool reduceFallSpeed = npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y; + + // Alpha + if (npc.alpha > 0) { npc.alpha -= 10; if (npc.alpha < 0) @@ -9959,11 +9961,17 @@ namespace CalamityMod.NPCs } } - // Jump - if (npc.ai[0] == 0f) - { - npc.noTileCollide = false; + if (npc.noTileCollide && !Main.player[npc.target].dead) + { + if (npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) + npc.noTileCollide = false; + else if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + npc.noTileCollide = false; + } + // Jump + if (npc.ai[0] == 0f) + { if (npc.velocity.Y == 0f) { // Laser fire when head is dead @@ -10145,15 +10153,6 @@ namespace CalamityMod.NPCs } else { - // Fall through - if (!Main.player[npc.target].dead) - { - if ((Main.player[npc.target].position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (Main.player[npc.target].position.Y < npc.Bottom.Y && npc.velocity.Y < 0f)) - npc.noTileCollide = true; - else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height))) - npc.noTileCollide = false; - } - // Velocity when falling if (npc.position.X < Main.player[npc.target].position.X && npc.position.X + npc.width > Main.player[npc.target].position.X + Main.player[npc.target].width) { @@ -10195,9 +10194,9 @@ namespace CalamityMod.NPCs void CustomGravity() { float gravity = turboEnrage ? 0.9f : enrage ? 0.6f : (!flag41 && !flag42) ? 0.45f : 0.3f; - float maxFallSpeed = turboEnrage ? 30f : enrage ? 20f : (!flag41 && !flag42) ? 15f : 10f; + float maxFallSpeed = reduceFallSpeed ? 12f : turboEnrage ? 30f : enrage ? 20f : (!flag41 && !flag42) ? 15f : 10f; - if (calamityGlobalNPC.newAI[0] > 1f) + if (calamityGlobalNPC.newAI[0] > 1f && !reduceFallSpeed) maxFallSpeed *= calamityGlobalNPC.newAI[0]; npc.velocity.Y += gravity; @@ -10524,7 +10523,7 @@ namespace CalamityMod.NPCs if (enraged) turboEnrage = true; - if (turboEnrage) + if (turboEnrage && NPC.golemBoss >= 0) { npc.Calamity().DR = 0.9999f; npc.Calamity().unbreakableDR = true; diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 17678ec416..44be8f7587 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -23,6 +23,7 @@ using CalamityMod.NPCs.Crags; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.DraedonLabThings; using CalamityMod.NPCs.ExoMechs.Apollo; using CalamityMod.NPCs.ExoMechs.Artemis; using CalamityMod.NPCs.ExoMechs.Ares; @@ -53,19 +54,22 @@ using CalamityMod.Projectiles.Rogue; using CalamityMod.Projectiles.Summon; using CalamityMod.Projectiles.Typeless; using CalamityMod.UI; +using CalamityMod.Walls.DraedonStructures; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using Terraria; using Terraria.GameContent.Events; using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Utilities; using static Terraria.ModLoader.ModContent; -using CalamityMod.DataStructures; +using CalamityMod.NPCs.ExoMechs; namespace CalamityMod.NPCs { @@ -77,6 +81,8 @@ namespace CalamityMod.NPCs public int KillTime { get; set; } = 0; + public bool ShouldFallThroughPlatforms; + /// /// If this is set to true, the NPC's DR cannot be reduced via any means. This applies regardless of whether customDR is true or false. /// @@ -140,6 +146,7 @@ namespace CalamityMod.NPCs // Stuff used by the Boss Health UI public bool SplittingWorm = false; + public bool CanHaveBossHealthBar = false; // Timer for how long an NPC is immune to certain debuffs public const int slowingDebuffResistanceMin = 1800; @@ -226,6 +233,7 @@ namespace CalamityMod.NPCs public static int SCalCatastrophe = -1; public static int SCal = -1; public static int SCalWorm = -1; + public static int draedon = -1; public static int draedonExoMechWorm = -1; public static int draedonExoMechTwinRed = -1; public static int draedonExoMechTwinGreen = -1; @@ -730,6 +738,7 @@ namespace CalamityMod.NPCs ResetSavedIndex(ref SCal, NPCType()); ResetSavedIndex(ref SCalWorm, NPCType()); + ResetSavedIndex(ref draedon, NPCType()); ResetSavedIndex(ref draedonExoMechWorm, NPCType()); ResetSavedIndex(ref draedonExoMechTwinRed, NPCType()); ResetSavedIndex(ref draedonExoMechTwinGreen, NPCType()); @@ -741,6 +750,7 @@ namespace CalamityMod.NPCs // Reset the enraged state every frame. The expectation is that bosses will continuously set it back to true if necessary. CurrentlyEnraged = false; + CanHaveBossHealthBar = false; } #endregion @@ -1024,6 +1034,8 @@ namespace CalamityMod.NPCs #region Set Defaults public override void SetDefaults(NPC npc) { + ShouldFallThroughPlatforms = false; + for (int i = 0; i < maxPlayerImmunities; i++) dashImmunityTime[i] = 0; @@ -3922,9 +3934,55 @@ namespace CalamityMod.NPCs safeRangeX = (int)(1920 / 16 * 0.32); //0.52 } } - #endregion + #endregion + + #region Edit Spawn Pool + + internal static readonly FieldInfo MaxSpawnsField = typeof(NPC).GetField("maxSpawns", BindingFlags.NonPublic | BindingFlags.Static); + public static void AttemptToSpawnLabCritters(Player player) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + int spawnRate = 400; + int maxSpawnCount = (int)MaxSpawnsField.GetValue(null); + NPCLoader.EditSpawnRate(player, ref spawnRate, ref maxSpawnCount); + for (int i = 0; i < 18; i++) + { + int checkPositionX = (int)(player.Center.X / 16 + Main.rand.Next(30, 54) * Main.rand.NextBool(2).ToDirectionInt()); + int checkPositionY = (int)(player.Center.Y / 16 + Main.rand.Next(24, 45) * Main.rand.NextBool(2).ToDirectionInt()); + Vector2 checkPosition = new Vector2(checkPositionX, checkPositionY); + + Tile aboveSpawnTile = CalamityUtils.ParanoidTileRetrieval(checkPositionX, checkPositionY - 1); + bool nearLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.SunkenSeaLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.PlanetoidLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.HellLabCenter / 16f) < 180f; + nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.IceLabCenter / 16f) < 180f; + + bool isLabWall = aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType(); + isLabWall |= aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType() || aboveSpawnTile.wall == WallType(); + if (!isLabWall || !nearLab || Collision.SolidCollision((checkPosition - new Vector2(2f, 2f)).ToWorldCoordinates(), 4, 4) || player.activeNPCs >= maxSpawnCount || !Main.rand.NextBool(spawnRate)) + continue; + + WeightedRandom pool = new WeightedRandom(); + pool.Add(NPCID.None, 0f); + pool.Add(NPCType(), 0.5f); + + int typeToSpawn = pool.Get(); + if (typeToSpawn != NPCID.None) + { + int spawnedNPC = NPCLoader.SpawnNPC(typeToSpawn, checkPositionX, checkPositionY - 1); + if (Main.netMode == NetmodeID.Server && spawnedNPC < Main.maxNPCs) + { + Main.npc[spawnedNPC].position.Y -= 8f; + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, spawnedNPC); + return; + } + } + } + } - #region Edit Spawn Pool public override void EditSpawnPool(IDictionary pool, NPCSpawnInfo spawnInfo) { bool calamityBiomeZone = spawnInfo.player.Calamity().ZoneAbyss || diff --git a/NPCs/Crabulon/CrabulonIdle.cs b/NPCs/Crabulon/CrabulonIdle.cs index f3847667e7..3af7137de0 100644 --- a/NPCs/Crabulon/CrabulonIdle.cs +++ b/NPCs/Crabulon/CrabulonIdle.cs @@ -280,41 +280,49 @@ namespace CalamityMod.NPCs.Crabulon npc.velocity.X = (npc.velocity.X * 20f - num823) / 21f; } - int num854 = 80; - int num855 = 20; - Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); + if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height) && player.position.Y <= npc.position.Y + npc.height) + { + npc.noGravity = false; + npc.noTileCollide = false; + } + else + { + npc.noGravity = true; + npc.noTileCollide = true; - bool fallDownOnTopOfTarget = npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f; - if (fallDownOnTopOfTarget) - { - npc.velocity.Y += 0.5f; - } - else if (Collision.SolidCollision(position2, num854, num855)) - { - if (npc.velocity.Y > 0f) - npc.velocity.Y = 0f; + int num854 = 80; + int num855 = 20; + Vector2 position2 = new Vector2(npc.Center.X - (num854 / 2), npc.position.Y + npc.height - num855); - if (npc.velocity.Y > -0.2f) - npc.velocity.Y -= 0.025f; - else - npc.velocity.Y -= 0.2f; + bool fallDownOnTopOfTarget = npc.position.X < player.position.X && npc.position.X + npc.width > player.position.X + player.width && npc.position.Y + npc.height < player.position.Y + player.height - 16f; + if (fallDownOnTopOfTarget) + { + npc.velocity.Y += 0.5f; + } + else if (Collision.SolidCollision(position2, num854, num855)) + { + if (npc.velocity.Y > 0f) + npc.velocity.Y = 0f; - if (npc.velocity.Y < -4f) - npc.velocity.Y = -4f; - } - else - { - if (npc.velocity.Y < 0f) - npc.velocity.Y = 0f; + if (npc.velocity.Y > -0.2f) + npc.velocity.Y -= 0.025f; + else + npc.velocity.Y -= 0.2f; - if (npc.velocity.Y < 0.1f) - npc.velocity.Y += 0.025f; - else - npc.velocity.Y += 0.5f; - } + if (npc.velocity.Y < -4f) + npc.velocity.Y = -4f; + } + else + { + if (npc.velocity.Y < 0f) + npc.velocity.Y = 0f; - if (npc.ai[1] % 25f == 24f) - npc.netUpdate = true; + if (npc.velocity.Y < 0.1f) + npc.velocity.Y += 0.025f; + else + npc.velocity.Y += 0.5f; + } + } npc.ai[1] += 1f; if (npc.ai[1] >= (360f - (death ? 120f * (1f - lifeRatio) : 0f))) diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs new file mode 100644 index 0000000000..c01975ffba --- /dev/null +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -0,0 +1,313 @@ +using CalamityMod.Items.DraedonMisc; +using CalamityMod.Walls.DraedonStructures; +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.DraedonLabThings +{ + public class RepairUnitCritter : ModNPC + { + public enum BehaviorState + { + WalkAround, + WalkOnWalls, + SitAndRecharge + } + + public Vector2 PreviousStuckPosition = Vector2.Zero; + + public BehaviorState CurrentState + { + get => (BehaviorState)(int)npc.ai[0]; + set => npc.ai[0] = (int)value; + } + + public ref float StuckCount => ref npc.ai[1]; + + public bool Initialized + { + get => npc.ai[2] == 1f; + set => npc.ai[2] = value.ToInt(); + } + public bool WantsToClimbOnSomeWall + { + get => npc.ai[3] == 1f; + set => npc.ai[3] = value.ToInt(); + } + + public ref float CurrentFrame => ref npc.localAI[0]; + public ref float Time => ref npc.localAI[1]; + public ref float ClimbTime => ref npc.localAI[2]; + + public const float Gravity = 0.4f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Repair Unit"); + Main.npcFrameCount[npc.type] = 17; + } + + public override void SetDefaults() + { + npc.aiStyle = -1; + aiType = -1; + npc.damage = 0; + npc.width = 20; + npc.height = 22; + npc.lifeMax = 80; + npc.knockBackResist = 0f; + npc.noGravity = true; + npc.noTileCollide = false; + npc.HitSound = SoundID.NPCHit4; + npc.DeathSound = SoundID.NPCDeath44; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(Time); + writer.Write(ClimbTime); + writer.WriteVector2(PreviousStuckPosition); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + Time = reader.ReadSingle(); + ClimbTime = reader.ReadSingle(); + PreviousStuckPosition = reader.ReadVector2(); + } + + public override void AI() + { + if (!Initialized) + { + npc.velocity = Vector2.UnitX * Main.rand.NextBool(2).ToDirectionInt() * 1.5f; + Initialized = true; + } + + npc.Calamity().ShouldFallThroughPlatforms = false; + switch (CurrentState) + { + case BehaviorState.WalkAround: + WalkAroundOnGround(); + ClimbTime = 0f; + break; + case BehaviorState.WalkOnWalls: + WalkOnWalls(); + ClimbTime++; + break; + } + Time++; + } + + public void WalkAroundOnGround() + { + // Fall onto the ground if mid-air. + npc.frameCounter += npc.velocity.Length() + 0.4f; + + Tile tileBelow = CalamityUtils.ParanoidTileRetrieval((int)(npc.Bottom.X / 16), (int)(npc.Bottom.Y / 16) + 1); + bool onSolidGround = WorldGen.SolidTile(tileBelow) || (tileBelow.active() && Main.tileSolidTop[tileBelow.type]); + float directionSign = Math.Sign(npc.velocity.X); + if (directionSign == 0f) + directionSign = npc.spriteDirection; + if (Math.Abs(npc.velocity.X) > 0.5f && onSolidGround) + npc.velocity.X = MathHelper.Lerp(npc.velocity.X, directionSign * 5f, 0.05f); + + // Enforce gravity. + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + Gravity, -15f, 15f); + + // Handle directioning. + if (Math.Abs(npc.velocity.X) > 0.4f) + npc.spriteDirection = (npc.velocity.X > 0f).ToDirectionInt(); + + // Attempt to jump over gaps if they aren't too big. + Vector2 checkPosition = npc.Bottom + new Vector2(Math.Sign(npc.velocity.X) * 24f, 12f); + float? distanceToAheadBelowTile = CalamityUtils.DistanceToTileCollisionHit(checkPosition, Vector2.UnitX * directionSign); + if (onSolidGround && distanceToAheadBelowTile.HasValue && distanceToAheadBelowTile.Value >= 2 && distanceToAheadBelowTile.Value < 9) + { + Vector2 jumpDestination = npc.Center + Vector2.UnitX * npc.spriteDirection * (distanceToAheadBelowTile.Value * 16f + 8f); + npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 8.5f); + } + + // Attempt to jump over vertical obstacles. + bool obstacleInWay = !Collision.CanHit(npc.Center - Vector2.UnitX * directionSign * 8f, 2, 2, npc.Center + Vector2.UnitX * directionSign * 80f, 8, 8); + if (onSolidGround && obstacleInWay) + { + Vector2 jumpDestination = npc.Center + Vector2.UnitX * npc.spriteDirection * 132f; + float? distanceToObstacle = CalamityUtils.DistanceToTileCollisionHit(npc.Center, Vector2.UnitX * directionSign); + float obstacleHeight = 0f; + for (int i = 0; i < 15; i++) + { + if (WorldGen.SolidTile((int)(npc.Center.X / 16 + (distanceToObstacle ?? 0) * npc.spriteDirection), (int)(npc.Center.Y / 16) - i)) + obstacleHeight++; + } + npc.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(npc.Center, jumpDestination, Gravity, 9f + StuckCount * 0.7f + obstacleHeight * 0.4f); + + if (MathHelper.Distance(npc.position.X, npc.oldPosition.X) < 0.2f) + { + StuckCount++; + if (StuckCount > 1f && !WantsToClimbOnSomeWall) + WantsToClimbOnSomeWall = true; + if (StuckCount > 2f) + { + npc.velocity.X *= -0.56f; + StuckCount = 0f; + } + PreviousStuckPosition = npc.Center; + } + npc.netUpdate = true; + } + + bool closeObstacleInWay = !Collision.CanHit(npc.Center, 2, 2, npc.Center + Vector2.UnitX * directionSign * 34f, 8, 8); + if (onSolidGround && closeObstacleInWay) + { + npc.velocity.X *= -0.7f; + npc.netUpdate = true; + } + + // Reset the stuck counter if the NPC has become sufficiently far away from the previous stuck postion, indicating that + // it is in fact, no longer stuck. + if (!npc.WithinRange(PreviousStuckPosition, 180f) && StuckCount > 0f) + { + StuckCount = 0f; + npc.netUpdate = true; + } + + // Handle walking frames. + if (npc.frameCounter >= 11f && Math.Abs(npc.velocity.Y) < 1f) + { + CurrentFrame = (CurrentFrame + 1f) % 8f; + npc.frameCounter = 0; + } + + if (Time % 300f == 299f && !WantsToClimbOnSomeWall) + { + WantsToClimbOnSomeWall = true; + npc.netUpdate = true; + } + + // If there are walls to clime on and this NPC wants to climb on some, do so. + if (WantsToClimbOnSomeWall && CalamityUtils.ParanoidTileRetrieval((int)npc.Center.X / 16, (int)npc.Center.Y / 16).wall > 0) + { + CurrentState = BehaviorState.WalkOnWalls; + StuckCount = 0f; + WantsToClimbOnSomeWall = false; + npc.position.Y -= 10f; + npc.netUpdate = true; + } + } + + public void WalkOnWalls() + { + StuckCount = 0f; + WantsToClimbOnSomeWall = false; + npc.Calamity().ShouldFallThroughPlatforms = true; + + // Generate unusual movement patterns based on sines. + // When two periodic functions are summed, the resulting function is periodic if the + // ratio of the b/a is rational, given periodic functions f and g: + // f(a * x) + g(b * x). However, if the ratio is irrational, then the result has no period. + // This is desirable for somewhat random wavy fluctuations. + // In this case, pi/1 (or simply pi) is used, which is indeed an irrational number. + float offsetAngle = (float)(Math.Sin(Time / 360f) + Math.Sin(MathHelper.Pi * Time / 360f)) * 0.003f; + + Vector2 currentDirection = npc.velocity.SafeNormalize((npc.rotation - MathHelper.PiOver2).ToRotationVector2()); + + // Turn much more quickly if there's no wall ahead. + Vector2 aheadCheckPosition = npc.Center + currentDirection * 120f; + Tile aheadTile = CalamityUtils.ParanoidTileRetrieval((int)(aheadCheckPosition.X / 16), (int)(aheadCheckPosition.Y / 16)); + bool aboutToCollideWithSomething = CalamityUtils.DistanceToTileCollisionHit(npc.Center - currentDirection * 5f, currentDirection) < 6f; + bool almostReadyToWalkAgain = ClimbTime > 445f; + + if (((aheadTile.wall == WallID.None || WorldGen.SolidTile(aheadTile)) && !almostReadyToWalkAgain) || aboutToCollideWithSomething) + { + float distanceToCollisionLeft = CalamityUtils.DistanceToTileCollisionHit(npc.Center - currentDirection.RotatedBy(MathHelper.PiOver2) * 5f, currentDirection.RotatedBy(MathHelper.PiOver2)) ?? 10000f; + float distanceToCollisionRight = CalamityUtils.DistanceToTileCollisionHit(npc.Center - currentDirection.RotatedBy(-MathHelper.PiOver2) * 5f, currentDirection.RotatedBy(-MathHelper.PiOver2)) ?? 10000f; + float steerRotation = distanceToCollisionLeft > distanceToCollisionRight ? MathHelper.PiOver2 : -MathHelper.PiOver2; + Vector2 idealVelocity = npc.velocity.RotatedBy(steerRotation); + npc.velocity = npc.velocity.MoveTowards(idealVelocity, 0.95f); + } + else + npc.velocity = npc.velocity.RotatedBy(offsetAngle); + npc.velocity = npc.velocity.SafeNormalize(Vector2.Zero) * 1.56f; + + // Rebound on collision. + if (npc.collideX) + { + npc.velocity.X *= -0.8f; + npc.Center += npc.velocity * 2f; + } + if (npc.collideY) + { + npc.velocity.Y *= -0.8f; + npc.Center += npc.velocity * 2f; + } + + if (npc.velocity.Length() > 1.4f) + npc.rotation = npc.rotation.AngleLerp(npc.velocity.ToRotation() + MathHelper.PiOver2, 0.2f); + + if (Collision.SolidCollision(npc.position + Vector2.One * 24f, npc.width - 12, npc.height - 12)) + { + npc.velocity *= -1f; + npc.position.Y -= 5f; + } + + // Handle climbing frames. + npc.frameCounter++; + if (npc.frameCounter >= 4f) + { + if (CurrentFrame < 9) + CurrentFrame = 9f; + CurrentFrame++; + if (CurrentFrame >= Main.npcFrameCount[npc.type]) + CurrentFrame = 9f; + npc.frameCounter = 0; + } + + if (CalamityUtils.ParanoidTileRetrieval((int)(npc.Center.X / 16), (int)(npc.Center.Y / 16)).wall == WallID.None || ClimbTime > 620f) + { + CurrentState = BehaviorState.WalkAround; + npc.velocity = new Vector2(Main.rand.NextBool(2).ToDirectionInt() * 1.2f, 3f); + npc.rotation = 0f; + npc.netUpdate = true; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(npc.position, npc.width, npc.height, 226); + if (npc.life <= 0) + { + for (int i = 1; i <= 3; i++) + Gore.NewGorePerfect(npc.Center, npc.velocity.RotatedByRandom(0.3f) * Main.rand.NextFloat(0.7f, 1f), mod.GetGoreSlot($"Gores/DraedonLabCritters/RepairUnit{i}")); + } + } + + public override void NPCLoot() + { + DropHelper.DropItemChance(npc, ModContent.ItemType(), 2, 2, 4); + } + + public override void FindFrame(int frameHeight) + { + npc.frame.Y = (int)(CurrentFrame * frameHeight); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + Texture2D critterTexture = Main.npcTexture[npc.type]; + Texture2D glowmask = ModContent.GetTexture("CalamityMod/NPCs/DraedonLabThings/RepairUnitCritterGlowmask"); + Vector2 drawPosition = npc.Center - Main.screenPosition + Vector2.UnitY * npc.gfxOffY; + SpriteEffects direction = npc.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, npc.frame, npc.GetAlpha(drawColor), npc.rotation, npc.frame.Size() * 0.5f, npc.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, npc.frame, npc.GetAlpha(Color.White), npc.rotation, npc.frame.Size() * 0.5f, npc.scale, direction, 0f); + return false; + } + } +} diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.png b/NPCs/DraedonLabThings/RepairUnitCritter.png new file mode 100644 index 0000000000..a7ff5c8d1c Binary files /dev/null and b/NPCs/DraedonLabThings/RepairUnitCritter.png differ diff --git a/NPCs/DraedonLabThings/RepairUnitCritterGlowmask.png b/NPCs/DraedonLabThings/RepairUnitCritterGlowmask.png new file mode 100644 index 0000000000..adcc586aa3 Binary files /dev/null and b/NPCs/DraedonLabThings/RepairUnitCritterGlowmask.png differ diff --git a/NPCs/ExoMechs/Apollo/Apollo.cs b/NPCs/ExoMechs/Apollo/Apollo.cs index 3afaf4f50b..dfee0098da 100644 --- a/NPCs/ExoMechs/Apollo/Apollo.cs +++ b/NPCs/ExoMechs/Apollo/Apollo.cs @@ -131,10 +131,12 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo music = /*CalamityMod.Instance.GetMusicFromMusicMod("AdultEidolonWyrm") ??*/ MusicID.Boss3; bossBag = ModContent.ItemType(); } - + public override void BossHeadSlot(ref int index) { - if (npc.life / (float)npc.lifeMax < 0.6f) + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + else if (npc.life / (float)npc.lifeMax < 0.6f) index = phase2IconIndex; else index = phase1IconIndex; @@ -180,6 +182,8 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo CalamityGlobalNPC.draedonExoMechTwinGreen = npc.whoAmI; + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + // Difficulty modes bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; @@ -263,6 +267,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Phases bool phase2 = lifeRatio < 0.6f; + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); bool lastMechAlive = berserk && otherExoMechsAlive == 0; @@ -333,33 +338,31 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Distance where Apollo stops moving float movementDistanceGateValue = 100f; + float chargeLocationDistanceGateValue = 20f; // Velocity and acceleration values - float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; - float baseVelocity = 14f * baseVelocityMult; - float baseAcceleration = 1f; - if (berserk) - { - baseVelocity *= 1.5f; - baseAcceleration *= 1.5f; - } + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 18f * baseVelocityMult; // Charge variables float chargeVelocity = malice ? 90f : death ? 80f : revenge ? 75f : expertMode ? 70f : 60f; - float chargeDistance = 1500f; - float chargeDuration = chargeDistance / chargeVelocity; bool lineUpAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f; bool doBigAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f + timeToLineUpAttack; // Rocket phase variables float rocketPhaseDuration = lastMechAlive ? 60f : 90f; + // Default vector to fly to + float chargeComboXOffset = -500f; + float chargeComboYOffset = npc.ai[2] == 0f ? 400f : -400f; + Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + 1200f, player.Center.Y) : AIState == (float)Phase.LineUpChargeCombo ? new Vector2(player.Center.X + 750f, player.Center.Y + chargeComboYOffset) : new Vector2(player.Center.X + 750f, player.Center.Y); + // Rotation Vector2 predictionVector = player.velocity * predictionAmt; Vector2 aimedVector = player.Center + predictionVector - npc.Center; float rateOfRotation = 0.1f; Vector2 rotateTowards = player.Center - npc.Center; - bool stopRotatingAndSlowDown = AIState == (float)Phase.LineUpChargeCombo && calamityGlobalNPC.newAI[2] >= timeToLineUpAttack; + bool stopRotatingAndSlowDown = AIState == (float)Phase.LineUpChargeCombo && (Vector2.Distance(npc.Center, destination) <= chargeLocationDistanceGateValue || calamityGlobalNPC.newAI[2] > 0f); if (!stopRotatingAndSlowDown) { if (AIState == (int)Phase.ChargeCombo) @@ -401,11 +404,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo npc.localAI[2] = 0f; calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -433,10 +439,6 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo npc.netUpdate = true; } - // Default vector to fly to - float chargeComboYOffeset = npc.ai[2] == 0f ? 400f : -400f; - Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X + 1200f, player.Center.Y) : AIState == (float)Phase.LineUpChargeCombo ? new Vector2(player.Center.X + 750f, player.Center.Y + chargeComboYOffeset) : new Vector2(player.Center.X + 750f, player.Center.Y); - // Add a bit of randomness to the destination, but only in specific phases where it's necessary if (AIState == (float)Phase.Normal || AIState == (float)Phase.RocketBarrage || AIState == (float)Phase.PhaseTransition) { @@ -475,11 +477,19 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Spawn the other mechs if Artemis and Apollo are first if (otherExoMechsAlive == 0) { - if (npc.ai[3] == 0f) + if (spawnOtherExoMechs) { // Reset everything npc.ai[3] = 1f; SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.TargetClosest(); if (Main.netMode != NetmodeID.MultiplayerClient) @@ -499,6 +509,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo { // Tells Apollo to return to the battle in passive state and reset everything SecondaryAIState = (float)SecondaryPhase.Passive; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.TargetClosest(); } @@ -508,6 +526,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo { // Reset everything SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.TargetClosest(); } } @@ -517,11 +543,22 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Fire projectiles less often case (int)SecondaryPhase.Passive: + // Fire plasma while passive + AIState = (float)Phase.Normal; + // Enter passive and invincible phase if one of the other exo mechs is berserk if (otherMechIsBerserk) { // Reset everything SecondaryAIState = (float)SecondaryPhase.PassiveAndImmune; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.TargetClosest(); } @@ -529,6 +566,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (berserk) { // Reset everything + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.TargetClosest(); // Never be passive if berserk @@ -540,18 +585,37 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Fly above target and become immune case (int)SecondaryPhase.PassiveAndImmune: + // Do nothing while immune + AIState = (float)Phase.Normal; + // 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 || exoPrimeLifeRatio < 0.7f) && !otherMechIsBerserk) { // Tells Artemis and Apollo to return to the battle in passive state and reset everything // Return to normal phases if one or more mechs have been downed SecondaryAIState = totalOtherExoMechLifeRatio > 5f ? (float)SecondaryPhase.Nothing : (float)SecondaryPhase.Passive; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.TargetClosest(); } if (berserk) { // Reset everything + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + npc.TargetClosest(); // Never be passive if berserk @@ -561,14 +625,118 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo break; } - // Needs edits // Attacking phases - /*switch ((int)AIState) + switch ((int)AIState) { - // Fly above the target + // Fly to the right of the target case (int)Phase.Normal: - if (!targetDead) + // Inverse lerp returns the percentage of progress between A and B + float lerpValue2 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + + // Min velocity + float minVelocity2 = distanceFromDestination.Length(); + float minVelocityCap2 = baseVelocity; + if (minVelocity2 > minVelocityCap2) + minVelocity2 = minVelocityCap2; + + // Max velocity + Vector2 maxVelocity2 = distanceFromDestination / 24f; + float maxVelocityCap2 = minVelocityCap2 * 3f; + if (maxVelocity2.Length() > maxVelocityCap2) + maxVelocity2 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap2; + + npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity2, maxVelocity2, lerpValue2); + + // Default animation for 60 frames and then go to telegraph animation + // newAI[3] tells Apollo what animation state it's currently in + bool attacking = calamityGlobalNPC.newAI[3] >= 2f; + bool firingPlasma = attacking && calamityGlobalNPC.newAI[3] + 2f < attackPhaseGateValue; + + // Only increase attack timer if not in immune phase + if (SecondaryAIState != (float)SecondaryPhase.PassiveAndImmune) + calamityGlobalNPC.newAI[2] += 1f; + + if (calamityGlobalNPC.newAI[2] >= defaultAnimationDuration || attacking) + { + if (firingPlasma) + { + // Fire plasma + int numPlasmaOrbs = lastMechAlive ? 15 : 12; + float divisor = attackPhaseGateValue / numPlasmaOrbs; + float plasmaTimer = calamityGlobalNPC.newAI[3] - 2f; + if (plasmaTimer % divisor == 0f) + { + pickNewLocation = true; + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int type = ModContent.ProjectileType(); + int damage = npc.GetProjectileDamage(type); + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaCasterFire"), npc.Center); + Vector2 plasmaVelocity = Vector2.Normalize(aimedVector); + Vector2 offset = plasmaVelocity * 70f; + Projectile.NewProjectile(npc.Center + offset, plasmaVelocity, type, damage, 0f, Main.myPlayer, -1f); + } + } + } + else + calamityGlobalNPC.newAI[2] = 0f; + + // Enter rocket phase after a certain time has passed + // Enter charge phase if in phase 2 and the localAI[2] variable is set to do so + calamityGlobalNPC.newAI[3] += 1f; + if (lineUpAttack) + { + // Return to normal plasma phase if in passive state + if (SecondaryAIState == (float)SecondaryPhase.Passive) + { + pickNewLocation = true; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; + + npc.TargetClosest(); + } + else if (doBigAttack) + { + pickNewLocation = npc.localAI[2] == 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + + if (phase2) + AIState = npc.localAI[2] == 1f ? (float)Phase.LineUpChargeCombo : (float)Phase.RocketBarrage; + else + AIState = (float)Phase.RocketBarrage; + } + } + } + + break; + + // Charge + case (int)Phase.RocketBarrage: + + // Reset phase and variables + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= rocketPhaseDuration) + { + // Go back to normal phase + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.localAI[2] = berserk ? 1f : 0f; + calamityGlobalNPC.newAI[2] = 0f; + npc.TargetClosest(); + } + + break; + + // Get in position for the charge combo, don't do anything else until in position + // Fill up the charge location array with the positions Apollo will charge from + // Create telegraph beams between the charge location array positions + case (int)Phase.LineUpChargeCombo: + + if (!stopRotatingAndSlowDown) { // Inverse lerp returns the percentage of progress between A and B float lerpValue = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); @@ -587,107 +755,113 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity, maxVelocity, lerpValue); } - - if (berserk) + else { + // Save the charge locations + for (int i = 0; i < maxCharges; i++) + { + if (chargeLocations[i] == default) + { + switch (i) + { + case 0: + chargeLocations[i] = npc.Center; + break; + case 1: + chargeLocations[i] = chargeLocations[0] + new Vector2(chargeComboXOffset, -chargeComboYOffset * 2f); + break; + case 2: + chargeLocations[i] = chargeLocations[1] + new Vector2(chargeComboXOffset, chargeComboYOffset * 2f); + break; + case 3: + chargeLocations[i] = chargeLocations[2] + new Vector2(chargeComboXOffset, -chargeComboYOffset * 2f); + break; + default: + break; + } + } + } + + // Don't move + npc.velocity = Vector2.Zero; + + // Go to charge phase and reset calamityGlobalNPC.newAI[2] += 1f; - if (calamityGlobalNPC.newAI[2] > deathrayPhaseGateValue) + if (calamityGlobalNPC.newAI[2] >= timeToLineUpAttack) { + AIState = (float)Phase.ChargeCombo; 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: + // Charge to several locations almost instantly (Apollo doesn't teleport here, he's just moving very fast :D) + case (int)Phase.ChargeCombo: - if (!targetDead) + // Charge combo attack here + // Increase newAI[2] whenever a charge occurs + + // Reset phase and variables + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= maxCharges) { - if (distanceFromTarget > deathrayDistanceGateValue && calamityGlobalNPC.newAI[3] == 0f) - { - Vector2 desiredVelocity2 = Vector2.Normalize(distanceFromDestination) * baseVelocity; - npc.SimpleFlyMovement(desiredVelocity2, baseAcceleration); - } - else - { - calamityGlobalNPC.newAI[3] = 1f; - npc.velocity *= decelerationVelocityMult; + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.localAI[2] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + for (int i = 0; i < maxCharges; i++) + chargeLocations[i] = default; - int totalProjectiles = malice ? 12 : expertMode ? 10 : 8; - float radians = MathHelper.TwoPi / totalProjectiles; - Vector2 laserSpawnPoint = new Vector2(npc.Center.X, npc.Center.Y); - bool normalLaserRotation = npc.localAI[0] % 2f == 0f; - float velocity = 6f; - double angleA = radians * 0.5; - double angleB = MathHelper.ToRadians(90f) - angleA; - float velocityX2 = (float)(velocity * Math.Sin(angleA) / Math.Sin(angleB)); - Vector2 spinningPoint = normalLaserRotation ? new Vector2(0f, -velocity) : new Vector2(-velocityX2, -velocity); - spinningPoint.Normalize(); - - 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, which begin on frame 12 - // Reset the frame counter - npc.frameCounter = 0D; - - // X = 1 sets to frame 8 - frameX = 1; - - // Y = 4 sets to frame 12 - frameY = 4; - - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); - int type = ModContent.ProjectileType(); - Vector2 spawnPoint = npc.Center + new Vector2(-1f, 23f); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 laserVelocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(spawnPoint + Vector2.Normalize(laserVelocity) * 17f, laserVelocity, type, 0, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - else - { - // Fire deathrays - if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), npc.Center); - int type = ModContent.ProjectileType(); - int damage = npc.GetProjectileDamage(type); - Vector2 spawnPoint = npc.Center + new Vector2(-1f, 23f); - for (int k = 0; k < totalProjectiles; k++) - { - Vector2 laserVelocity = spinningPoint.RotatedBy(radians * k); - Projectile.NewProjectile(spawnPoint + Vector2.Normalize(laserVelocity) * 35f, laserVelocity, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); - } - } - } - } - - if (calamityGlobalNPC.newAI[2] >= deathrayTelegraphDuration + deathrayDuration) - { - AIState = (float)Phase.Normal; - calamityGlobalNPC.newAI[2] = 0f; - calamityGlobalNPC.newAI[3] = 0f; - npc.localAI[0] += 1f; - npc.TargetClosest(); - } - } + npc.TargetClosest(); } break; - }*/ + + // Phase transition animation, that's all this exists for + case (int)Phase.PhaseTransition: + + // Inverse lerp returns the percentage of progress between A and B + float lerpValue4 = Utils.InverseLerp(movementDistanceGateValue, 2400f, distanceFromDestination.Length(), true); + + // Min velocity + float minVelocity4 = distanceFromDestination.Length(); + float minVelocityCap4 = baseVelocity; + if (minVelocity4 > minVelocityCap4) + minVelocity4 = minVelocityCap4; + + // Max velocity + Vector2 maxVelocity4 = distanceFromDestination / 24f; + float maxVelocityCap4 = minVelocityCap4 * 3f; + if (maxVelocity4.Length() > maxVelocityCap4) + maxVelocity4 = distanceFromDestination.SafeNormalize(Vector2.Zero) * maxVelocityCap4; + + npc.velocity = Vector2.Lerp(distanceFromDestination.SafeNormalize(Vector2.Zero) * minVelocity4, maxVelocity4, lerpValue4); + + // Shoot lens gore at the target at the proper time + if (calamityGlobalNPC.newAI[2] == lensPopTime) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LargeWeaponFire"), npc.Center); + Vector2 goreVelocity = Vector2.Normalize(aimedVector); + Vector2 offset = goreVelocity * 70f; + Gore.NewGore(npc.Center + offset, goreVelocity * 24f, mod.GetGoreSlot("Gores/Apollo/ApolloTransitionGore"), 1f); + } + + // Reset phase and variables + calamityGlobalNPC.newAI[2] += 1f; + if (calamityGlobalNPC.newAI[2] >= phaseTransitionDuration) + { + pickNewLocation = true; + AIState = (float)Phase.Normal; + npc.localAI[0] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[2] = 0f; + calamityGlobalNPC.newAI[3] = 0f; + npc.TargetClosest(); + } + + break; + } } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -709,7 +883,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo if (dist4 < minDist) minDist = dist4; - return minDist <= 100f && npc.Opacity == 1f; + return minDist <= 100f && npc.Opacity == 1f && AIState == (float)Phase.ChargeCombo; } public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) => !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); @@ -720,14 +894,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo return null; } - // Needs edits - /*public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { - // Use telegraph frames when using deathrays + // Use telegraph frames before each attack + bool phase2 = npc.life / (float)npc.lifeMax < 0.6f; npc.frameCounter += 1D; - if (AIState == (float)Phase.Normal || npc.Calamity().newAI[3] == 0f) + if (AIState == (float)Phase.PhaseTransition) { - if (npc.frameCounter >= 10D) + if (npc.frameCounter >= 6D) { // Reset frame counter npc.frameCounter = 0D; @@ -735,41 +909,68 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo // Increment the Y frame frameY++; - // Reset the Y frame if greater than 8 + // Reset the Y frame if greater than 9 if (frameY == maxFramesY) { frameX++; frameY = 0; } - - // Reset the frames to frame 0 - if ((frameX * maxFramesY) + frameY > normalFrameLimit) - frameX = frameY = 0; } } else { - if (npc.frameCounter >= 10D) + if (AIState == (float)Phase.Normal) { - // Reset frame counter - npc.frameCounter = 0D; + int frameLimit = phase2 ? (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase2 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase2 : attackFrameLimit_Phase2) : + (npc.Calamity().newAI[3] == 0f ? normalFrameLimit_Phase1 : npc.Calamity().newAI[3] == 1f ? chargeUpFrameLimit_Phase1 : attackFrameLimit_Phase1); - // Increment the Y frame - frameY++; - - // Reset the Y frame if greater than 8 - if (frameY == maxFramesY) + if (npc.frameCounter >= 6D) { - frameX++; - frameY = 0; - } + // Reset frame counter + npc.frameCounter = 0D; - // Reset the frames to frame 36, the start of the deathray firing animation loop - if ((frameX * maxFramesY) + frameY > finalStageDeathrayChargeFrameLimit) - frameX = frameY = 4; + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + int currentFrame = (frameX * maxFramesY) + frameY; + if (currentFrame > frameLimit) + frameX = frameY = phase2 ? (npc.Calamity().newAI[3] == 0f ? 6 : npc.Calamity().newAI[3] == 1f ? 7 : 8) : (npc.Calamity().newAI[3] == 0f ? 0 : npc.Calamity().newAI[3] == 1f ? 1 : 2); + } + } + else if (AIState == (float)Phase.RocketBarrage || AIState == (float)Phase.LineUpChargeCombo || AIState == (float)Phase.ChargeCombo) + { + int frameLimit = phase2 ? attackFrameLimit_Phase2 : attackFrameLimit_Phase1; + if (npc.frameCounter >= 6D) + { + // Reset frame counter + npc.frameCounter = 0D; + + // Increment the Y frame + frameY++; + + // Reset the Y frame if greater than 9 + if (frameY == maxFramesY) + { + frameX++; + frameY = 0; + } + + // Reset the frames + int currentFrame = (frameX * maxFramesY) + frameY; + if (currentFrame > frameLimit) + frameX = frameY = phase2 ? 8 : 2; + } } } - }*/ + } public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { diff --git a/NPCs/ExoMechs/Ares/AresBody.cs b/NPCs/ExoMechs/Ares/AresBody.cs index a472205002..546832aabd 100644 --- a/NPCs/ExoMechs/Ares/AresBody.cs +++ b/NPCs/ExoMechs/Ares/AresBody.cs @@ -105,7 +105,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares bossBag = ModContent.ItemType(); } - public override void SendExtraAI(BinaryWriter writer) + public override void BossHeadSlot(ref int index) + { + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + } + + public override void SendExtraAI(BinaryWriter writer) { writer.Write(frameX); writer.Write(frameY); @@ -133,6 +139,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares CalamityGlobalNPC.draedonExoMechPrime = npc.whoAmI; + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + // Difficulty modes bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; @@ -242,6 +250,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares npc.ai[3] = 1f; // Phases + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); bool lastMechAlive = berserk && otherExoMechsAlive == 0; @@ -323,9 +332,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares calamityGlobalNPC.newAI[3] = 0f; npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -348,15 +357,10 @@ namespace CalamityMod.NPCs.ExoMechs.Ares Vector2 destination = SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune ? new Vector2(player.Center.X, player.Center.Y - 800f) : AIState != (float)Phase.Deathrays ? new Vector2(player.Center.X, player.Center.Y - 425f) : player.Center; // Velocity and acceleration values - float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; - float baseVelocity = 14f * baseVelocityMult; - float baseAcceleration = 1f; + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 18f * baseVelocityMult; + float baseAcceleration = berserk ? 1.5f : 1f; float decelerationVelocityMult = 0.85f; - if (berserk) - { - baseVelocity *= 1.5f; - baseAcceleration *= 1.5f; - } Vector2 distanceFromDestination = destination - npc.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination) * baseVelocity; @@ -378,7 +382,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares // Spawn the other mechs if Ares is first if (otherExoMechsAlive == 0) { - if (npc.ai[3] == 0f) + if (spawnOtherExoMechs) { // Reset everything npc.ai[3] = 1f; diff --git a/NPCs/ExoMechs/Ares/AresGaussNuke.cs b/NPCs/ExoMechs/Ares/AresGaussNuke.cs index b9c34def79..676ca04b77 100644 --- a/NPCs/ExoMechs/Ares/AresGaussNuke.cs +++ b/NPCs/ExoMechs/Ares/AresGaussNuke.cs @@ -103,6 +103,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) { npc.life = 0; @@ -222,9 +224,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares calamityGlobalNPC.newAI[2] = 0f; npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -247,10 +249,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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 + 560f, 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 = 16f * baseVelocityMult; - if (berserk) - baseVelocity *= 1.5f; + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 22f * baseVelocityMult; Vector2 distanceFromDestination = destination - npc.Center; diff --git a/NPCs/ExoMechs/Ares/AresLaserCannon.cs b/NPCs/ExoMechs/Ares/AresLaserCannon.cs index 89aff1c04a..c2c1942a35 100644 --- a/NPCs/ExoMechs/Ares/AresLaserCannon.cs +++ b/NPCs/ExoMechs/Ares/AresLaserCannon.cs @@ -101,6 +101,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) { npc.life = 0; @@ -213,9 +215,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares calamityGlobalNPC.newAI[2] = 0f; npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -238,14 +240,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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 - 560f, 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 = 16f * baseVelocityMult; - float baseAcceleration = 1f; - if (berserk) - { - baseVelocity *= 1.5f; - baseAcceleration *= 1.5f; - } + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 22f * baseVelocityMult; + float baseAcceleration = berserk ? 1.5f : 1f; Vector2 distanceFromDestination = destination - npc.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination) * baseVelocity; diff --git a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs index 5eb5958a3b..b2501f1689 100644 --- a/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs +++ b/NPCs/ExoMechs/Ares/AresPlasmaFlamethrower.cs @@ -101,6 +101,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) { npc.life = 0; @@ -220,9 +222,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares calamityGlobalNPC.newAI[2] = 0f; npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -245,10 +247,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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 = 16f * baseVelocityMult; - if (berserk) - baseVelocity *= 1.5f; + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 22f * baseVelocityMult; Vector2 distanceFromDestination = destination - npc.Center; diff --git a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs index 0212975f6b..bda09634a1 100644 --- a/NPCs/ExoMechs/Ares/AresTeslaCannon.cs +++ b/NPCs/ExoMechs/Ares/AresTeslaCannon.cs @@ -101,6 +101,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares { CalamityGlobalNPC calamityGlobalNPC = npc.Calamity(); + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) { npc.life = 0; @@ -220,9 +222,9 @@ namespace CalamityMod.NPCs.ExoMechs.Ares calamityGlobalNPC.newAI[2] = 0f; npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -245,10 +247,8 @@ namespace CalamityMod.NPCs.ExoMechs.Ares 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 = 16f * baseVelocityMult; - if (berserk) - baseVelocity *= 1.5f; + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 22f * baseVelocityMult; Vector2 distanceFromDestination = destination - npc.Center; @@ -472,7 +472,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares return false; } - + public override bool PreNPCLoot() => false; public override void HitEffect(int hitDirection, double damage) diff --git a/NPCs/ExoMechs/Artemis/Artemis.cs b/NPCs/ExoMechs/Artemis/Artemis.cs index 45e68697b1..1601f01f8d 100644 --- a/NPCs/ExoMechs/Artemis/Artemis.cs +++ b/NPCs/ExoMechs/Artemis/Artemis.cs @@ -142,7 +142,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis public override void BossHeadSlot(ref int index) { - if (npc.life / (float)npc.lifeMax < 0.6f) + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + else if (npc.life / (float)npc.lifeMax < 0.6f) index = phase2IconIndex; else index = phase1IconIndex; @@ -188,6 +190,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis CalamityGlobalNPC.draedonExoMechTwinRed = npc.whoAmI; + npc.frame = new Rectangle(npc.width * frameX, npc.height * frameY, npc.width, npc.height); + // Difficulty modes bool malice = CalamityWorld.malice || BossRushEvent.BossRushActive; bool death = CalamityWorld.death || malice; @@ -274,6 +278,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Phases bool phase2 = lifeRatio < 0.6f; + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); bool lastMechAlive = berserk && otherExoMechsAlive == 0; @@ -350,19 +355,13 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis float movementDistanceGateValue = 100f; // Velocity and acceleration values - float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; - float baseVelocity = 14f * baseVelocityMult; - float baseAcceleration = 1f; + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 18f * baseVelocityMult; float decelerationVelocityMult = 0.85f; - if (berserk) - { - baseVelocity *= 1.5f; - baseAcceleration *= 1.5f; - } // Charge variables float chargeVelocity = malice ? 60f : death ? 50f : revenge ? 45f : expertMode ? 40f : 30f; - float chargeDistance = 1800f; + float chargeDistance = 2000f; float chargeDuration = chargeDistance / chargeVelocity; bool lineUpAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f; bool doBigAttack = calamityGlobalNPC.newAI[3] >= attackPhaseGateValue + 2f + timeToLineUpAttack; @@ -421,9 +420,9 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = 0; npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -465,8 +464,8 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis Vector2 distanceFromDestination = destination - npc.Center; Vector2 desiredVelocity = Vector2.Normalize(distanceFromDestination) * baseVelocity; - // Velocity during deathray spin phase - float spinVelocity = baseVelocity * 0.25f; + // Duration of deathray spin to do a full circle + float spinTime = 120f - baseVelocity * 2.5f; // Set to transition to phase 2 if it hasn't happened yet if (phase2 && npc.localAI[3] == 0f) @@ -496,7 +495,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis // Note: Only Apollo spawns the mechs because the twins HP values are linked if (otherExoMechsAlive == 0) { - if (npc.ai[3] == 0f) + if (spawnOtherExoMechs) { // Reset everything npc.ai[3] = 1f; @@ -507,7 +506,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; rotationDirection = 0; - npc.TargetClosest(); } } else @@ -525,7 +523,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; rotationDirection = 0; - npc.TargetClosest(); } // Go passive and immune if one of the other mechs is berserk @@ -540,7 +537,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; rotationDirection = 0; - npc.TargetClosest(); } } @@ -563,7 +559,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; rotationDirection = 0; - npc.TargetClosest(); } // If Artemis and Apollo are the first mechs to go berserk @@ -576,7 +571,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; rotationDirection = 0; - npc.TargetClosest(); // Never be passive if berserk SecondaryAIState = (float)SecondaryPhase.Nothing; @@ -602,7 +596,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; rotationDirection = 0; - npc.TargetClosest(); } if (berserk) @@ -614,7 +607,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; rotationDirection = 0; - npc.TargetClosest(); // Never be passive if berserk SecondaryAIState = (float)SecondaryPhase.Nothing; @@ -706,7 +698,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; chargeVelocityNormalized = default; - npc.TargetClosest(); } else { @@ -725,16 +716,15 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (doBigAttack) { + calamityGlobalNPC.newAI[3] = 0f; if (phase2) { AIState = npc.localAI[2] == 1f ? (float)Phase.Deathray : (float)Phase.LaserShotgun; - calamityGlobalNPC.newAI[3] = 0f; } else { // Charge until a certain distance is reached and then return to normal phase AIState = (float)Phase.Charge; - calamityGlobalNPC.newAI[3] = 0f; npc.velocity = chargeVelocityNormalized * chargeVelocity; chargeVelocityNormalized = default; } @@ -761,7 +751,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis pickNewLocation = true; AIState = (float)Phase.Normal; calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); } } @@ -799,16 +788,20 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis int type = ModContent.ProjectileType(); int damage = npc.GetProjectileDamage(type); Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/LaserCannon"), npc.Center); + Vector2 laserVelocity = Vector2.Normalize(aimedVector) * 10f; - int spread = 3 + (int)(calamityGlobalNPC.newAI[2] / divisor2) * 3; + int spread = 15 + (int)(calamityGlobalNPC.newAI[2] / divisor2) * 15; float rotation = MathHelper.ToRadians(spread); float distanceFromTarget = Vector2.Distance(npc.Center, player.Center + predictionVector); + for (int i = 0; i < numLasersPerSpread + 1; i++) { - Vector2 perturbedSpeed = laserVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numLasersPerSpread - 1))); + Vector2 perturbedSpeed = laserVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numLasersPerSpread - 1))); Vector2 normalizedPerturbedSpeed = Vector2.Normalize(perturbedSpeed); + Vector2 offset = normalizedPerturbedSpeed * 70f; Vector2 newCenter = npc.Center + offset; + Projectile.NewProjectile(newCenter, newCenter + normalizedPerturbedSpeed * distanceFromTarget, type, damage, 0f, Main.myPlayer, 0f, npc.whoAmI); } } @@ -822,7 +815,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis AIState = (float)Phase.Normal; npc.localAI[2] = berserk ? 1f : 0f; calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); } break; @@ -865,7 +857,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis rotationDirection = player.direction; // Set spin velocity - npc.velocity.X = MathHelper.Pi * spinRadius / spinVelocity; + npc.velocity.X = MathHelper.Pi * spinRadius / spinTime; npc.velocity *= -rotationDirection; npc.netUpdate = true; @@ -880,7 +872,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis } } else - npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinVelocity * -rotationDirection); + npc.velocity = npc.velocity.RotatedBy(MathHelper.Pi / spinTime * -rotationDirection); } } else @@ -912,7 +904,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis AIState = (float)Phase.Normal; npc.localAI[2] = 0f; calamityGlobalNPC.newAI[2] = 0f; - npc.TargetClosest(); } break; @@ -956,7 +947,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis npc.localAI[1] = 0f; calamityGlobalNPC.newAI[2] = 0f; calamityGlobalNPC.newAI[3] = 0f; - npc.TargetClosest(); } break; @@ -982,7 +972,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis if (dist4 < minDist) minDist = dist4; - return minDist <= 100f && npc.Opacity == 1f; + return minDist <= 100f && npc.Opacity == 1f && AIState == (float)Phase.Charge; } public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) => !CalamityUtils.AntiButcher(npc, ref damage, 0.5f); diff --git a/NPCs/ExoMechs/Draedon.cs b/NPCs/ExoMechs/Draedon.cs new file mode 100644 index 0000000000..89c62c9f1b --- /dev/null +++ b/NPCs/ExoMechs/Draedon.cs @@ -0,0 +1,413 @@ +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Thanatos; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.IO; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +using ApolloBoss = CalamityMod.NPCs.ExoMechs.Apollo.Apollo; +using ArtemisBoss = CalamityMod.NPCs.ExoMechs.Artemis.Artemis; + +namespace CalamityMod.NPCs.ExoMechs +{ + public class Draedon : ModNPC + { + public float DefeatTimer; + public bool ShouldStartStandingUp; + public Vector2 HoverDestinationOffset + { + get => new Vector2(npc.ai[1], npc.ai[2]); + set + { + npc.ai[1] = value.X; + npc.ai[2] = value.Y; + } + } + public Player PlayerToFollow => Main.player[npc.target]; + public ref float TalkTimer => ref npc.ai[0]; + public ref float GeneralTimer => ref npc.ai[3]; + public bool ExoMechIsPresent + { + get + { + if (NPC.AnyNPCs(ModContent.NPCType())) + return true; + + if (NPC.AnyNPCs(ModContent.NPCType())) + return true; + + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + return true; + + return false; + } + } + public static readonly Color TextColor = new Color(155, 255, 255); + public static readonly Color TextColorEdgy = new Color(213, 4, 11); + public const int TeleportFadeinTime = 45; + public const int TalkDelay = 150; + public const int DelayPerDialogLine = 130; + public const int ExoMechChooseDelay = TalkDelay + DelayPerDialogLine * 4 + 10; + public const int ExoMechShakeTime = 100; + public const int DelayBeforeDefeatStandup = 30; + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Draedon"); + Main.npcFrameCount[npc.type] = 15; + } + + public override void SetDefaults() + { + npc.damage = 0; + npc.width = npc.height = 34; + npc.defense = 100; + npc.lifeMax = 16000; + npc.noGravity = true; + npc.noTileCollide = true; + npc.dontTakeDamage = true; + npc.aiStyle = aiType = -1; + npc.knockBackResist = 0f; + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(DefeatTimer); + writer.Write(ShouldStartStandingUp); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + DefeatTimer = reader.ReadSingle(); + ShouldStartStandingUp = reader.ReadBoolean(); + } + + public override void AI() + { + // Set the whoAmI variable. + CalamityGlobalNPC.draedon = npc.whoAmI; + + // Prevent stupid natural despawns. + npc.timeLeft = 3600; + + // Decide an initial target on the first frame. + if (TalkTimer == 0f) + npc.TargetClosest(false); + + // Pick someone else to pay attention to if the old target is gone. + if (PlayerToFollow.dead || !PlayerToFollow.active) + { + npc.TargetClosest(false); + + // Fuck off if no living target exists. + if (PlayerToFollow.dead || !PlayerToFollow.active) + { + npc.life = 0; + npc.checkDead(); + npc.active = false; + return; + } + } + + // Stay within the world. + npc.position.Y = MathHelper.Clamp(npc.position.Y, 150f, Main.maxTilesY * 16f - 150f); + + npc.Opacity = Utils.InverseLerp(0f, 8f, TalkTimer, true); + npc.spriteDirection = (PlayerToFollow.Center.X < npc.Center.X).ToDirectionInt(); + + // Play the stand up animation after teleportation. + if (TalkTimer == TeleportFadeinTime + 5f) + ShouldStartStandingUp = true; + + if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay) + { + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText1", TextColor); + npc.netUpdate = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine) + { + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText2", TextColor); + npc.netUpdate = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine * 2f) + { + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText3", TextColor); + npc.netUpdate = true; + } + + if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine * 3f) + { + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText4", TextColor); + npc.netUpdate = true; + } + + // Inform the player who summoned draedon they may choose the first mech and cause a selection UI to appear over their head. + if (Main.netMode != NetmodeID.MultiplayerClient && TalkTimer == TalkDelay + DelayPerDialogLine * 4f) + { + CalamityUtils.DisplayLocalizedText("Mods.CalamityMod.DraedonIntroductionText5", TextColorEdgy); + npc.netUpdate = true; + } + + // Wait for the player to select an exo mech. + if (TalkTimer >= ExoMechChooseDelay && TalkTimer < ExoMechChooseDelay + 8f && CalamityWorld.DraedonMechToSummon == ExoMech.None) + { + PlayerToFollow.Calamity().AbleToSelectExoMech = true; + TalkTimer = ExoMechChooseDelay; + } + + // Fly around once the exo mechs have been spawned. + if (ExoMechIsPresent || DefeatTimer > 0f) + { + FlyAroundInGamerChair(); + GeneralTimer++; + } + + // Make the screen rumble and summon the exo mechs. + if (TalkTimer > ExoMechChooseDelay + 8f && TalkTimer < ExoMechChooseDelay + ExoMechShakeTime) + { + Main.LocalPlayer.Calamity().GeneralScreenShakePower = Utils.InverseLerp(4200f, 1400f, Main.LocalPlayer.Distance(PlayerToFollow.Center), true) * 18f; + Main.LocalPlayer.Calamity().GeneralScreenShakePower *= Utils.InverseLerp(ExoMechChooseDelay + 5f, ExoMechChooseDelay + ExoMechShakeTime, TalkTimer, true); + } + + // Summon the selected exo mech. + if (TalkTimer == ExoMechChooseDelay + 10f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + SummonExoMech(); + + if (Main.netMode != NetmodeID.Server) + { + var sound = Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/FlareSound"), PlayerToFollow.Center); + + if (sound != null) + sound.Volume = MathHelper.Clamp(sound.Volume * 1.55f, 0f, 1f); + } + } + + if (TalkTimer > ExoMechChooseDelay + 10f && !ExoMechIsPresent) + { + HandleDefeatStuff(); + DefeatTimer++; + } + + TalkTimer++; + } + + // TODO - Make this work in conjunction with exo mech transitions. This requires that the exo mech AIs be finished. + public void FlyAroundInGamerChair() + { + // Define a hover destination offset if one hasn't been decided yet. + if (Main.netMode != NetmodeID.MultiplayerClient && HoverDestinationOffset == Vector2.Zero) + { + HoverDestinationOffset = -Vector2.UnitY * 700f; + npc.netUpdate = true; + } + + // Switch hover destinations from time to time. + if (Main.netMode != NetmodeID.MultiplayerClient && GeneralTimer % 480f == 479f) + { + Vector2 offsetDirection; + Vector2 directionToTarget = npc.SafeDirectionTo(PlayerToFollow.Center); + + // Reroll the offset direction if its direction noticably contrasts the current direction from the target. + // This is done to prevent Draedon from selecting a position to zoom to that would make him have to move + // close to the player. + do + offsetDirection = Main.rand.NextVector2Unit(); + while (Vector2.Dot(directionToTarget, offsetDirection) > 0.2f); + + HoverDestinationOffset = offsetDirection * Main.rand.NextFloat(750f, 1100f); + npc.netUpdate = true; + } + + // Always hover to the side of the target when defeated. + if (DefeatTimer > 5f) + HoverDestinationOffset = Vector2.UnitX * (PlayerToFollow.Center.X < npc.Center.X).ToDirectionInt() * 325f; + + Vector2 hoverDestination = PlayerToFollow.Center + HoverDestinationOffset; + + // Decide sprite direction based on movement if not close enough to the desination. + // Not deciding this here results in Draedon using the default of looking at the target he's following. + if (npc.WithinRange(hoverDestination, 300f)) + { + npc.velocity *= 0.96f; + + float moveSpeed = MathHelper.Lerp(2f, 8f, Utils.InverseLerp(45f, 275f, npc.Distance(hoverDestination), true)); + npc.Center = npc.Center.MoveTowards(hoverDestination, moveSpeed); + } + else + { + if (DefeatTimer < DelayBeforeDefeatStandup) + npc.spriteDirection = (npc.velocity.X < 0f).ToDirectionInt(); + + float flySpeed = DefeatTimer > 5f ? 14f : 32f; + Vector2 idealVelocity = npc.SafeDirectionTo(hoverDestination) * flySpeed; + npc.SimpleFlyMovement(idealVelocity, flySpeed / 400f); + npc.velocity = Vector2.Lerp(npc.velocity, idealVelocity, 0.045f); + } + } + + public void SummonExoMech() + { + switch (CalamityWorld.DraedonMechToSummon) + { + // Summon Thanatos underground. + case ExoMech.Destroyer: + Vector2 thanatosSpawnPosition = PlayerToFollow.Center + Vector2.UnitY * 2100f; + NPC thanatos = CalamityUtils.SpawnBossBetter(thanatosSpawnPosition, ModContent.NPCType()); + if (thanatos != null) + thanatos.velocity = thanatos.SafeDirectionTo(PlayerToFollow.Center) * 40f; + break; + + // Summon Ares in the sky, directly above the player. + case ExoMech.Prime: + Vector2 aresSpawnPosition = PlayerToFollow.Center - Vector2.UnitY * 1400f; + CalamityUtils.SpawnBossBetter(aresSpawnPosition, ModContent.NPCType()); + break; + + // Summon Apollo and Artemis above the player to their sides. + case ExoMech.Twins: + Vector2 artemisSpawnPosition = PlayerToFollow.Center + new Vector2(-1100f, -1600f); + Vector2 apolloSpawnPosition = PlayerToFollow.Center + new Vector2(1100f, -1600f); + CalamityUtils.SpawnBossBetter(artemisSpawnPosition, ModContent.NPCType()); + CalamityUtils.SpawnBossBetter(apolloSpawnPosition, ModContent.NPCType()); + break; + } + } + + public void HandleDefeatStuff() + { + // Become vulnerable after being defeated after a certain point. + npc.dontTakeDamage = DefeatTimer < 250f; + npc.Calamity().CanHaveBossHealthBar = !npc.dontTakeDamage; + + // Stand up in awe after a small amount of time has passed. + if (DefeatTimer > DelayBeforeDefeatStandup) + ShouldStartStandingUp = true; + + // TODO - This needs to be changed. + if (DefeatTimer == DelayBeforeDefeatStandup + 10f) + Main.NewText("Wait, what? How?", TextColor); + + if (DefeatTimer == DelayBeforeDefeatStandup + 80f) + Main.NewText("No", TextColor); + } + + // Draedon should not manually despawn. + public override bool CheckActive() => false; + + public override Color? GetAlpha(Color drawColor) + { + float teleportFade = Utils.InverseLerp(0f, TeleportFadeinTime, TalkTimer, true); + Color color = Color.Lerp(drawColor, Color.Cyan, 1f - (float)Math.Pow(teleportFade, 3D)); + color.A = (byte)(int)(teleportFade * 255f); + + return color * npc.Opacity; + } + + public override void FindFrame(int frameHeight) + { + npc.frame.Width = 102; + int xFrame = npc.frame.X / npc.frame.Width; + int yFrame = npc.frame.Y / npc.frame.Height; + int frame = xFrame * Main.npcFrameCount[npc.type] + yFrame; + + // Prepare to stand up if called for and not already doing so. + if (ShouldStartStandingUp && frame < 23) + frame = 23; + + int frameChangeDelay = 7; + bool shouldNotSitDown = DefeatTimer > DelayBeforeDefeatStandup; + + npc.frameCounter++; + if (npc.frameCounter >= frameChangeDelay) + { + frame++; + + if (!ShouldStartStandingUp && frame >= 23) + frame = 0; + + // Do the sit animation infinitely if Draedon should not sit down again. + if (shouldNotSitDown && frame >= 47) + frame = 36; + + if (frame >= 59) + { + frame = 0; + ShouldStartStandingUp = false; + } + + npc.frameCounter = 0; + } + + npc.frame.X = frame / Main.npcFrameCount[npc.type] * npc.frame.Width; + npc.frame.Y = frame % Main.npcFrameCount[npc.type] * npc.frame.Height; + } + + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) + { + npc.lifeMax = 16000; + } + + public override void HitEffect(int hitDirection, double damage) + { + if (npc.life > 0) + return; + + for (int i = 1; i <= 4; i++) + { + Vector2 goreSpawnOffset = Main.rand.NextVector2Circular(12f, 12f); + Vector2 draedonPieceVelocity = Main.rand.NextVector2CircularEdge(7f, 7f) - Vector2.UnitY * 8f; + Vector2 chairPieceVelocity = Vector2.UnitY.RotatedByRandom(0.13f) * Main.rand.NextFloat(4.45f, 5.4f); + Gore.NewGoreDirect(npc.Center + goreSpawnOffset, draedonPieceVelocity, mod.GetGoreSlot($"Gores/Draedon/Draedon{i}")); + + goreSpawnOffset = Main.rand.NextVector2Circular(18f, 18f); + Gore.NewGoreDirect(npc.Center + goreSpawnOffset, chairPieceVelocity, mod.GetGoreSlot($"Gores/Draedon/Chair{i}")); + } + } + + // Always instantly kill Draedon when he's vulnerable + public override bool StrikeNPC(ref double damage, int defense, ref float knockback, int hitDirection, ref bool crit) + { + damage *= 56D; + if (damage < npc.lifeMax) + damage = npc.lifeMax + Main.rand.NextFloat(50f, 750f); + crit = true; + return true; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) + { + spriteBatch.EnterShaderRegion(); + + Texture2D texture = Main.npcTexture[npc.type]; + Texture2D glowmask = ModContent.GetTexture("CalamityMod/NPCs/ExoMechs/DraedonGlowmask"); + Rectangle frame = npc.frame; + + Vector2 drawPosition = npc.Center - Main.screenPosition - Vector2.UnitY * 38f; + Vector2 origin = frame.Size() * 0.5f; + Color color = npc.GetAlpha(drawColor); + SpriteEffects direction = npc.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + GameShaders.Misc["CalamityMod:TeleportDisplacement"].UseOpacity(MathHelper.Clamp(1f - TalkTimer / TeleportFadeinTime, 0f, 1f) * 0.38f); + GameShaders.Misc["CalamityMod:TeleportDisplacement"].UseSecondaryColor(color); + GameShaders.Misc["CalamityMod:TeleportDisplacement"].UseSaturation(color.A / 255f); + GameShaders.Misc["CalamityMod:TeleportDisplacement"].Shader.Parameters["frameCount"].SetValue(new Vector2(2f, Main.npcFrameCount[npc.type])); + GameShaders.Misc["CalamityMod:TeleportDisplacement"].Apply(); + + spriteBatch.Draw(texture, drawPosition, frame, drawColor * npc.Opacity, npc.rotation, origin, npc.scale, direction, 0f); + + spriteBatch.ExitShaderRegion(); + + if (TalkTimer > TeleportFadeinTime) + spriteBatch.Draw(glowmask, drawPosition, frame, Color.White * npc.Opacity, npc.rotation, origin, npc.scale, direction, 0f); + + return false; + } + } +} diff --git a/NPCs/ExoMechs/Draedon.png b/NPCs/ExoMechs/Draedon.png new file mode 100644 index 0000000000..c0ec806a42 Binary files /dev/null and b/NPCs/ExoMechs/Draedon.png differ diff --git a/NPCs/ExoMechs/DraedonGlowmask.png b/NPCs/ExoMechs/DraedonGlowmask.png new file mode 100644 index 0000000000..5993dfe9cd Binary files /dev/null and b/NPCs/ExoMechs/DraedonGlowmask.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs index 2fdca2c136..5a96195aef 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody1.cs @@ -71,7 +71,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void BossHeadSlot(ref int index) { - if (vulnerable) + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) index = vulnerableIconIndex; else index = normalIconIndex; @@ -210,7 +212,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.Calamity().newAI[0] == 0f) npc.ai[3] += 1f; - double numSegmentsAbleToFire = malice ? 30D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge && !berserk) { float divisor = 120f; @@ -278,7 +280,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos else { // This is only used in deathray phase to prevent laser spam - float segmentDivisor = (float)Math.Round(numSegments / (berserk ? 5D : numSegmentsAbleToFire)); + float segmentDivisor = (float)Math.Round(numSegments / (berserk ? numSegmentsAbleToFire * 2f : numSegmentsAbleToFire)); float divisor = npc.localAI[2] * 3f; // Ranges from 3 to 300 if ((npc.ai[3] == divisor && npc.localAI[2] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) { diff --git a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs index 43f5d6c34d..e0fd2c5c98 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosBody2.cs @@ -71,7 +71,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void BossHeadSlot(ref int index) { - if (vulnerable) + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) index = vulnerableIconIndex; else index = normalIconIndex; @@ -210,7 +212,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.Calamity().newAI[0] == 0f) npc.ai[3] += 1f; - double numSegmentsAbleToFire = malice ? 30D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge && !berserk) { float divisor = 120f; @@ -278,7 +280,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos else { // This is only used in deathray phase to prevent laser spam - float segmentDivisor = (float)Math.Round(numSegments / (berserk ? 5D : numSegmentsAbleToFire)); + float segmentDivisor = (float)Math.Round(numSegments / (berserk ? numSegmentsAbleToFire * 2f : numSegmentsAbleToFire)); float divisor = npc.localAI[2] * 3f; // Ranges from 3 to 300 if ((npc.ai[3] == divisor && npc.localAI[2] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) { diff --git a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs index cdc64402f6..52d489cd99 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosHead.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosHead.cs @@ -78,7 +78,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos private const float defaultLifeRatio = 5f; // Base distance from the target for most attacks - private const float baseDistance = 800f; + private const float baseDistance = 400f; // Base distance from target location in order to continue turning private const float baseTurnDistance = 160f; @@ -139,7 +139,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void BossHeadSlot(ref int index) { - if (vulnerable) + if (SecondaryAIState == (float)SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) index = vulnerableIconIndex; else index = normalIconIndex; @@ -248,6 +250,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos npc.ai[3] = 1f; // Phases + bool spawnOtherExoMechs = lifeRatio < 0.7f && npc.ai[3] == 0f; bool berserk = lifeRatio < 0.4f || (otherExoMechsAlive == 0 && lifeRatio < 0.7f); bool lastMechAlive = berserk && otherExoMechsAlive == 0; @@ -372,9 +375,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos chargeVelocityScalar = 0f; npc.dontTakeDamage = true; - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) - npc.velocity.Y -= 2f; + npc.velocity.Y -= 1f; if ((double)npc.position.Y < Main.topWorld + 16f) { @@ -406,19 +409,14 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos float chargeLocationDistance = turnDistance * 0.2f; // Laser Barrage variables - float laserBarrageLocationBaseDistance = SecondaryAIState == (int)SecondaryPhase.PassiveAndImmune ? baseDistance * 1.5f : baseDistance; + float laserBarrageLocationBaseDistance = SecondaryAIState == (int)SecondaryPhase.PassiveAndImmune ? baseDistance * 2f : baseDistance; Vector2 laserBarrageLocation = new Vector2(0f, laserBarrageLocationBaseDistance); float laserBarrageLocationDistance = turnDistance * 3f; // Velocity and turn speed values - float baseVelocityMult = malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f; - float baseVelocity = 7f * baseVelocityMult; - float turnDegrees = baseVelocity * 0.11f; - if (berserk) - { - baseVelocity *= 1.5f; - turnDegrees *= 1.5f; - } + float baseVelocityMult = (berserk ? 0.5f : 0f) + (malice ? 1.3f : death ? 1.2f : revenge ? 1.15f : expertMode ? 1.1f : 1f); + float baseVelocity = 9f * baseVelocityMult; + float turnDegrees = baseVelocity * 0.11f * (berserk ? 1.5f : 1f); // Increase top velocity if target is dead if (targetDead) @@ -454,7 +452,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos // Spawn the other mechs if Thanatos is first if (otherExoMechsAlive == 0) { - if (npc.ai[3] == 0f) + if (spawnOtherExoMechs) { // Reset everything npc.ai[3] = 1f; diff --git a/NPCs/ExoMechs/Thanatos/ThanatosNormalHead.png b/NPCs/ExoMechs/Thanatos/ThanatosNormalHead.png index 9cd03281e6..a5503e05e0 100644 Binary files a/NPCs/ExoMechs/Thanatos/ThanatosNormalHead.png and b/NPCs/ExoMechs/Thanatos/ThanatosNormalHead.png differ diff --git a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs index eb650d31b0..eedf364347 100644 --- a/NPCs/ExoMechs/Thanatos/ThanatosTail.cs +++ b/NPCs/ExoMechs/Thanatos/ThanatosTail.cs @@ -70,7 +70,9 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos public override void BossHeadSlot(ref int index) { - if (vulnerable) + if (Main.npc[(int)npc.ai[2]].Calamity().newAI[1] == (float)ThanatosHead.SecondaryPhase.PassiveAndImmune) + index = -1; + else if (vulnerable) index = vulnerableIconIndex; else index = normalIconIndex; @@ -209,7 +211,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos if (npc.Calamity().newAI[0] == 0f) npc.ai[3] += 1f; - double numSegmentsAbleToFire = malice ? 30D : death ? 20D : revenge ? 17.5 : expertMode ? 15D : 10D; + double numSegmentsAbleToFire = malice ? 35D : death ? 30D : revenge ? 28D : expertMode ? 25D : 20D; if (calamityGlobalNPC_Head.newAI[0] == (float)ThanatosHead.Phase.Charge && !berserk) { float divisor = 120f; @@ -277,7 +279,7 @@ namespace CalamityMod.NPCs.ExoMechs.Thanatos else { // This is only used in deathray phase to prevent laser spam - float segmentDivisor = (float)Math.Round(numSegments / (berserk ? 5D : numSegmentsAbleToFire)); + float segmentDivisor = (float)Math.Round(numSegments / (berserk ? numSegmentsAbleToFire * 2f : numSegmentsAbleToFire)); float divisor = npc.localAI[2] * 3f; // Ranges from 3 to 300 if ((npc.ai[3] == divisor && npc.localAI[2] % segmentDivisor == 0f) || npc.Calamity().newAI[0] > 0f) { diff --git a/NPCs/Ravager/RavagerBody.cs b/NPCs/Ravager/RavagerBody.cs index 778a105e52..1e22acec8b 100644 --- a/NPCs/Ravager/RavagerBody.cs +++ b/NPCs/Ravager/RavagerBody.cs @@ -170,6 +170,8 @@ namespace CalamityMod.NPCs.Ravager bool immunePhase = headActive || rightClawActive || leftClawActive || rightLegActive || leftLegActive; bool finalPhase = !leftClawActive && !rightClawActive && !headActive && !leftLegActive && !rightLegActive && expertMode; + bool phase2 = npc.ai[0] == 2f; + bool reduceFallSpeed = npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y; if (immunePhase) { @@ -306,10 +308,16 @@ namespace CalamityMod.NPCs.Ravager } } - if (npc.ai[0] == 0f) - { - npc.noTileCollide = false; + if (npc.noTileCollide && !player.dead) + { + if (npc.velocity.Y > 0f && npc.Bottom.Y > player.Top.Y) + npc.noTileCollide = false; + else if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height)) + npc.noTileCollide = false; + } + if (npc.ai[0] == 0f) + { if (npc.velocity.Y == 0f) { npc.velocity.X *= 0.8f; @@ -335,10 +343,14 @@ namespace CalamityMod.NPCs.Ravager float jumpGateValue = 180f; if (npc.ai[1] >= jumpGateValue) - npc.ai[1] = -20f; - else if (npc.ai[1] == -1f) - { - npc.TargetClosest(); + { + npc.ai[1] = -20f; + } + else if (npc.ai[1] == -1f) + { + npc.noTileCollide = true; + + npc.TargetClosest(); bool shouldFall = player.position.Y >= npc.Bottom.Y; float velocityXBoost = death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio); @@ -353,7 +365,7 @@ namespace CalamityMod.NPCs.Ravager if (distanceBelowTarget > 0f) calamityGlobalNPC.newAI[1] += 1f + distanceBelowTarget * multiplier; - float speedMultLimit = malice ? 4f : 3f; + float speedMultLimit = malice ? 3f : 2f; if (calamityGlobalNPC.newAI[1] > speedMultLimit) calamityGlobalNPC.newAI[1] = speedMultLimit; @@ -363,7 +375,6 @@ namespace CalamityMod.NPCs.Ravager if (expertMode && !finalPhase) { - npc.noTileCollide = true; if (shouldFall) velocityY = 1f; @@ -382,19 +393,16 @@ namespace CalamityMod.NPCs.Ravager } if (finalPhase) - { - npc.noTileCollide = true; calamityGlobalNPC.newAI[2] = player.direction; - } float playerLocation = npc.Center.X - player.Center.X; npc.direction = playerLocation < 0 ? 1 : -1; npc.velocity.X = velocityX * npc.direction; - npc.velocity.Y = velocityY; + npc.velocity.Y = velocityY; - npc.ai[0] = finalPhase ? 2f : 1f; - npc.ai[1] = 0f; + npc.ai[0] = finalPhase ? 2f : 1f; + npc.ai[1] = 0f; } } @@ -460,22 +468,15 @@ namespace CalamityMod.NPCs.Ravager } else { - // Fall through - if (!player.dead && expertMode) - { - if ((player.position.Y > npc.Bottom.Y && npc.velocity.Y > 0f) || (player.position.Y < npc.Bottom.Y && npc.velocity.Y < 0f)) - npc.noTileCollide = true; - else if ((npc.velocity.Y > 0f && npc.Bottom.Y > Main.player[npc.target].Top.Y) || (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].Center, 1, 1) && !Collision.SolidCollision(npc.position, npc.width, npc.height))) - npc.noTileCollide = false; - } - Vector2 targetVector = player.position; float aimY = targetVector.Y - 640f; float distanceFromTargetPos = Math.Abs(npc.Top.Y - aimY); bool inRange = npc.Top.Y <= aimY + 160f && npc.Top.Y >= aimY - 16f; - if (npc.ai[0] == 2f && npc.ai[1] == 0f) + if (phase2 && npc.ai[1] == 0f) { + npc.noTileCollide = true; + calamityGlobalNPC.newAI[3] += 1f; if (inRange) @@ -492,7 +493,7 @@ namespace CalamityMod.NPCs.Ravager } float maxOffset = death ? 320f * (1f - lifeRatio) : 240f * (1f - lifeRatio); - float offset = npc.ai[0] == 2f ? maxOffset * calamityGlobalNPC.newAI[2] : 0f; + float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f; // Set offset to 0 if the target stops moving if (Math.Abs(player.velocity.X) < 0.5f) @@ -504,7 +505,7 @@ namespace CalamityMod.NPCs.Ravager { npc.damage = npc.defDamage; - if (npc.ai[0] == 2f) + if (phase2) { float stopBeforeFallTime = malice ? 25f : 30f; if (expertMode) @@ -565,7 +566,7 @@ namespace CalamityMod.NPCs.Ravager if (!leftLegActive) velocityX += 1f; - if (npc.ai[0] == 2f) + if (phase2) { npc.damage = 0; velocityXChange *= velocityMult; @@ -589,15 +590,15 @@ namespace CalamityMod.NPCs.Ravager void CustomGravity() { - float gravity = npc.ai[0] == 2f ? 0f : 0.45f; - float maxFallSpeed = npc.ai[0] == 2f ? 24f : 15f; - if (malice) + float gravity = phase2 ? 0f : 0.45f; + float maxFallSpeed = reduceFallSpeed ? 12f : phase2 ? 24f : 15f; + if (malice && !reduceFallSpeed) { gravity *= 1.25f; maxFallSpeed *= 1.25f; } - if (calamityGlobalNPC.newAI[1] > 1f) + if (calamityGlobalNPC.newAI[1] > 1f && !reduceFallSpeed) maxFallSpeed *= calamityGlobalNPC.newAI[1]; npc.velocity.Y += gravity; @@ -608,14 +609,14 @@ namespace CalamityMod.NPCs.Ravager player = Main.player[npc.target]; if (npc.target <= 0 || npc.target == 255 || player.dead || !player.active) { - npc.TargetClosest(true); + npc.TargetClosest(); player = Main.player[npc.target]; } int distanceFromTarget = 5600; if (Vector2.Distance(npc.Center, player.Center) > distanceFromTarget) { - npc.TargetClosest(true); + npc.TargetClosest(); player = Main.player[npc.target]; if (Vector2.Distance(npc.Center, player.Center) > distanceFromTarget) diff --git a/NPCs/SlimeGod/SlimeGod.cs b/NPCs/SlimeGod/SlimeGod.cs index 357538eb2a..b134405e8b 100644 --- a/NPCs/SlimeGod/SlimeGod.cs +++ b/NPCs/SlimeGod/SlimeGod.cs @@ -399,9 +399,9 @@ namespace CalamityMod.NPCs.SlimeGod else if (npc.ai[2] == 0f) { npc.noTileCollide = true; - npc.noGravity = true; } - npc.velocity.Y += 0.25f; + npc.noGravity = true; + npc.velocity.Y += 0.5f; float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; if (npc.velocity.Y > velocityLimit) { diff --git a/NPCs/SlimeGod/SlimeGodRun.cs b/NPCs/SlimeGod/SlimeGodRun.cs index cc18939b24..46062cbf5f 100644 --- a/NPCs/SlimeGod/SlimeGodRun.cs +++ b/NPCs/SlimeGod/SlimeGodRun.cs @@ -409,9 +409,9 @@ namespace CalamityMod.NPCs.SlimeGod else if (npc.ai[2] == 0f) { npc.noTileCollide = true; - npc.noGravity = true; } - npc.velocity.Y += 0.3f; + npc.noGravity = true; + npc.velocity.Y += 0.5f; float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; if (npc.velocity.Y > velocityLimit) { diff --git a/NPCs/SlimeGod/SlimeGodRunSplit.cs b/NPCs/SlimeGod/SlimeGodRunSplit.cs index 6030f25e74..23ca6bc4b7 100644 --- a/NPCs/SlimeGod/SlimeGodRunSplit.cs +++ b/NPCs/SlimeGod/SlimeGodRunSplit.cs @@ -383,9 +383,9 @@ namespace CalamityMod.NPCs.SlimeGod else if (npc.ai[2] == 0f) { npc.noTileCollide = true; - npc.noGravity = true; } - npc.velocity.Y += 0.3f; + npc.noGravity = true; + npc.velocity.Y += 0.5f; float velocityLimit = malice ? 22f : death ? 16f : revenge ? 15f : expertMode ? 14f : 13f; if (npc.velocity.Y > velocityLimit) { diff --git a/NPCs/SlimeGod/SlimeGodSplit.cs b/NPCs/SlimeGod/SlimeGodSplit.cs index c5d14625fe..3c4c228f54 100644 --- a/NPCs/SlimeGod/SlimeGodSplit.cs +++ b/NPCs/SlimeGod/SlimeGodSplit.cs @@ -380,9 +380,9 @@ namespace CalamityMod.NPCs.SlimeGod else if (npc.ai[2] == 0f) { npc.noTileCollide = true; - npc.noGravity = true; } - npc.velocity.Y += 0.25f; + npc.noGravity = true; + npc.velocity.Y += 0.5f; float velocityLimit = malice ? 20f : death ? 15f : revenge ? 14f : expertMode ? 13f : 12f; if (npc.velocity.Y > velocityLimit) { diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index e41177f379..0682c18212 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -1367,7 +1367,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num824 *= 0.5f; } @@ -1619,7 +1619,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num413 *= 0.5f; } @@ -1735,7 +1735,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.HeldItem; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num833 *= 0.5f; } @@ -2021,7 +2021,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num824 *= 0.5f; } @@ -2266,7 +2266,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num413 *= 0.5f; } @@ -2383,7 +2383,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // Reduce acceleration if target is holding a true melee weapon Item targetSelectedItem = player.inventory[player.selectedItem]; - if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || CalamityLists.trueMeleeProjectileList.Contains(targetSelectedItem.shoot))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num833 *= 0.5f; } diff --git a/NPCs/SupremeCalamitas/SupremeCataclysm.cs b/NPCs/SupremeCalamitas/SupremeCataclysm.cs index af55c1e4bf..d0e44b7c2f 100644 --- a/NPCs/SupremeCalamitas/SupremeCataclysm.cs +++ b/NPCs/SupremeCalamitas/SupremeCataclysm.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // 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))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num677 *= 0.5f; } diff --git a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs index 3f626975e3..c7e8334fa4 100644 --- a/NPCs/SupremeCalamitas/SupremeCatastrophe.cs +++ b/NPCs/SupremeCalamitas/SupremeCatastrophe.cs @@ -97,7 +97,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas // 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))) + if (targetSelectedItem.melee && (targetSelectedItem.shoot == ProjectileID.None || targetSelectedItem.Calamity().trueMelee)) { num677 *= 0.5f; } diff --git a/NPCs/TownNPCs/WITCH.cs b/NPCs/TownNPCs/WITCH.cs index 219026ada2..7c00caf758 100644 --- a/NPCs/TownNPCs/WITCH.cs +++ b/NPCs/TownNPCs/WITCH.cs @@ -5,9 +5,10 @@ using CalamityMod.Projectiles.Magic; using CalamityMod.UI.CalamitasEnchants; using CalamityMod.World; using Terraria; +using Terraria.GameContent.Events; using Terraria.ID; using Terraria.ModLoader; - +using Terraria.Utilities; using static Terraria.ModLoader.ModContent; using SCalBoss = CalamityMod.NPCs.SupremeCalamitas.SupremeCalamitas; @@ -53,7 +54,74 @@ namespace CalamityMod.NPCs.TownNPCs public override string TownNPCName() => "Calamitas"; - public override string GetChat() => "Mrrp is cringe."; + // The way this works is by having an RNG based on weights. + // With certain conditions (such as if a blood moon is happening) you can add possibilities + // to the RNG via textSelector.Add("text", weight); + // Text can always appear assuming the weight is greater than 0 and there's no if condition deciding whether it can. + // The higher the weight is, the more likely it is to be selected from all the choices. + // To give an example of this, assume you have two possibilities: + // "a" with a weight of 1, and "b" with a weight of 5. The chance of "a" being displayed would be + // 1/6, while "b" wold have a 5/6 chance of being displayed. + // If only one possibility exists it will be the only thing that is displayed, regardless of weight. + public override string GetChat() + { + WeightedRandom textSelector = new WeightedRandom(Main.rand); + + if (npc.homeless) + { + textSelector.Add("I'm considering moving back to that old cave of mine."); + textSelector.Add("I certainly can't return to the Tyrant's old dwellings now, have you got any places to stay?"); + } + else + { + textSelector.Add("I can't pay rent, but if you've got any dead relative you want me to try and... what? You don't?"); + textSelector.Add("One of these days, I was thinking of starting a garden with the flowers from the old capitol of hell." + + "I love the smell of brimstone in the morning."); + textSelector.Add("I think I've settled comfortably, thank you very much."); + textSelector.Add("Many seasons have gone by since I first met with the Tyrant, and only now did I break free." + + "I wish I'd been stronger..."); + textSelector.Add("If you've got any curses you want dispelled... well I'm not your person."); + + if (!Main.dayTime) + { + if (Main.bloodMoon) + { + textSelector.Add("Such an unnatural shade of red. Nothing like my brimstone flames.", 5.15); + textSelector.Add("I can't work with nights like these. The stars seem to have shrunk away in fear.", 5.15); + } + else + { + textSelector.Add("These undead are horrific, I can't stand to look at them. How could anyone be satisfied" + + "with such amateur work?", 2.8); + textSelector.Add("I don't think it's a stretch to say that astrology is utter nonsense... but it was a hobby" + + "of mine once.", 2.8); + } + } + + if (BirthdayParty.PartyIsUp) + textSelector.Add("If another person asks me if I can dance or not, I will light their hat on fire.", 5.5); + + if (NPC.AnyNPCs(NPCType())) + { + textSelector.Add("I cannot understand the Sea King. He does not seem to want me dead. That amount of compassion" + + "I just can't understand.", 1.45); + } + if (NPC.AnyNPCs(NPCType())) + { + textSelector.Add("That frosty old man... even if you ignore our brands of magic and our old alliances, I doubt I'd ever" + + "get along with him.", 1.45); + } + } + + // Select a possibility from the RNG and choose it as the thing that should be said. + string thingToSay = textSelector.Get(); + + // Have a flat chance (1/4444) to simply ignore the above selection and say something humorous instead. + if (Main.rand.NextBool(4444)) + thingToSay = "Mrrp is cringe."; + + return thingToSay; + } public override void SetChatButtons(ref string button, ref string button2) => button = "Enchant"; diff --git a/Projectiles/Boss/AresDeathBeamStart.cs b/Projectiles/Boss/AresDeathBeamStart.cs index 06d2972a3d..384861305e 100644 --- a/Projectiles/Boss/AresDeathBeamStart.cs +++ b/Projectiles/Boss/AresDeathBeamStart.cs @@ -97,7 +97,7 @@ namespace CalamityMod.Projectiles.Boss samplingPoint = vector78.Value; float[] array3 = new float[(int)num805]; - Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 2400f, array3); + Collision.LaserScan(samplingPoint, projectile.velocity, num806 * projectile.scale, 4800f, array3); float num807 = 0f; for (int num808 = 0; num808 < array3.Length; num808++) { @@ -108,7 +108,7 @@ namespace CalamityMod.Projectiles.Boss // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(Main.npc[(int)projectile.ai[1]].Center, 1, 1, Main.player[Main.npc[(int)projectile.ai[1]].target].Center, 1, 1)) { - num807 = 2400f; + num807 = 4800f; } float amount = 0.5f; diff --git a/Projectiles/Boss/AresDeathBeamTelegraph.cs b/Projectiles/Boss/AresDeathBeamTelegraph.cs index 014f80a945..169f679782 100644 --- a/Projectiles/Boss/AresDeathBeamTelegraph.cs +++ b/Projectiles/Boss/AresDeathBeamTelegraph.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Boss public Vector2 OldVelocity; public const float TelegraphTotalTime = 240f; public const float TelegraphFadeTime = 15f; - public const float TelegraphWidth = 4200f; + public const float TelegraphWidth = 4800f; public override void SetStaticDefaults() { diff --git a/Projectiles/Boss/AresPlasmaFireball.cs b/Projectiles/Boss/AresPlasmaFireball.cs index ea79f1db14..12fb3a8163 100644 --- a/Projectiles/Boss/AresPlasmaFireball.cs +++ b/Projectiles/Boss/AresPlasmaFireball.cs @@ -48,9 +48,12 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { - Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); - if (Vector2.Distance(targetLocation, projectile.Center) < 80f) - projectile.tileCollide = true; + if (projectile.ai[0] != -1f) + { + Vector2 targetLocation = new Vector2(projectile.ai[0], projectile.ai[1]); + if (Vector2.Distance(targetLocation, projectile.Center) < 80f) + projectile.tileCollide = true; + } int fadeInTime = 3; projectile.Opacity = MathHelper.Clamp(1f - ((projectile.timeLeft - (timeLeft - fadeInTime)) / (float)fadeInTime), 0f, 1f); @@ -157,6 +160,11 @@ namespace CalamityMod.Projectiles.Boss { // Plasma bolts int totalProjectiles = CalamityWorld.malice ? 12 : 8; + + // Reduce the total amount of projectiles by half if Apollo is shooting them + if (projectile.ai[0] == -1f) + totalProjectiles /= 2; + float radians = MathHelper.TwoPi / totalProjectiles; int type = ModContent.ProjectileType(); float velocity = projectile.velocity.Length(); diff --git a/Projectiles/Boss/AresTeslaOrb.cs b/Projectiles/Boss/AresTeslaOrb.cs index 8103fff1b5..e989a46b0e 100644 --- a/Projectiles/Boss/AresTeslaOrb.cs +++ b/Projectiles/Boss/AresTeslaOrb.cs @@ -1,3 +1,5 @@ +using CalamityMod.NPCs; +using CalamityMod.NPCs.ExoMechs.Ares; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -50,6 +52,9 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + if (projectile.velocity.Length() < 24f) + projectile.velocity *= 1.01f; + int fadeOutTime = 15; int fadeInTime = 3; if (projectile.timeLeft < fadeOutTime) @@ -137,9 +142,12 @@ namespace CalamityMod.Projectiles.Boss public Projectile GetOrbToAttachTo() { + if (CalamityGlobalNPC.draedonExoMechPrime < 0 || !Main.npc[CalamityGlobalNPC.draedonExoMechPrime].active) + return null; + for (int i = 0; i < Main.maxProjectiles; i++) { - if (Main.projectile[i].type != projectile.type || Main.projectile[i].ai[0] != Identity + 1f || !Main.projectile[i].active) + if (Main.projectile[i].type != projectile.type || Main.projectile[i].ai[0] != Identity + 1f || !Main.projectile[i].active || Main.npc[CalamityGlobalNPC.draedonExoMechPrime].Calamity().newAI[0] == (float)AresBody.Phase.Deathrays) continue; return Main.projectile[i]; diff --git a/Projectiles/Boss/ArtemisDeathrayTelegraph.cs b/Projectiles/Boss/ArtemisDeathrayTelegraph.cs index 4e7586d93a..84786d9d37 100644 --- a/Projectiles/Boss/ArtemisDeathrayTelegraph.cs +++ b/Projectiles/Boss/ArtemisDeathrayTelegraph.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Boss public Vector2 OldVelocity; public const float TelegraphTotalTime = 60f; public const float TelegraphFadeTime = 15f; - public const float TelegraphWidth = 4200f; + public const float TelegraphWidth = 4800f; public override void SetStaticDefaults() { diff --git a/Projectiles/Boss/ArtemisLaserBeamStart.cs b/Projectiles/Boss/ArtemisLaserBeamStart.cs index db7bfe3aad..0e1a085baf 100644 --- a/Projectiles/Boss/ArtemisLaserBeamStart.cs +++ b/Projectiles/Boss/ArtemisLaserBeamStart.cs @@ -75,7 +75,7 @@ namespace CalamityMod.Projectiles.Boss // The direction of the host NPC. Vector2 hostNPCDirection = Vector2.Normalize(ThingToAttachTo.velocity); - // Offset to move the beam forward so that it starts inside the NPC's mouth. + // Offset to move the beam forward so that it starts in Artemis' focus jewel thing. float beamStartForwardsOffset = -70f; // Set the starting location of the beam to the center of the NPC. @@ -105,7 +105,7 @@ namespace CalamityMod.Projectiles.Boss float arraySize = 3f; Vector2 samplingPoint = projectile.Center; float[] samples = new float[(int)arraySize]; - Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, 2400f, samples); + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, 4800f, samples); float laserLength = 0f; for (int i = 0; i < samples.Length; i++) { @@ -115,7 +115,7 @@ namespace CalamityMod.Projectiles.Boss // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(ThingToAttachTo.Center, 1, 1, Main.player[ThingToAttachTo.target].Center, 1, 1)) - laserLength = 2400f; + laserLength = 4800f; float amount = 0.5f; LengthOfLaser = MathHelper.Lerp(LengthOfLaser, laserLength, amount); diff --git a/Projectiles/Boss/DarkEnergyBall.cs b/Projectiles/Boss/DarkEnergyBall.cs index 7b03090f98..a270cbb957 100644 --- a/Projectiles/Boss/DarkEnergyBall.cs +++ b/Projectiles/Boss/DarkEnergyBall.cs @@ -33,6 +33,13 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } + if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) projectile.Kill(); diff --git a/Projectiles/Boss/DarkEnergyBall2.cs b/Projectiles/Boss/DarkEnergyBall2.cs index 506d0c91af..5ff7987d43 100644 --- a/Projectiles/Boss/DarkEnergyBall2.cs +++ b/Projectiles/Boss/DarkEnergyBall2.cs @@ -35,6 +35,13 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } + if (Vector2.Distance(projectile.Center, Main.npc[CalamityGlobalNPC.voidBoss].Center) < 80f) projectile.Kill(); diff --git a/Projectiles/Boss/DoGBeamPortal.cs b/Projectiles/Boss/DoGBeamPortal.cs index b77e467f51..58a5eeed39 100644 --- a/Projectiles/Boss/DoGBeamPortal.cs +++ b/Projectiles/Boss/DoGBeamPortal.cs @@ -45,6 +45,13 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + if (CalamityGlobalNPC.voidBoss < 0 || !Main.npc[CalamityGlobalNPC.voidBoss].active) + { + projectile.active = false; + projectile.netUpdate = true; + return; + } + Player player = Main.player[projectile.owner]; if (start) diff --git a/Projectiles/Boss/DraedonSummonLaser.cs b/Projectiles/Boss/DraedonSummonLaser.cs new file mode 100644 index 0000000000..5cd53e6515 --- /dev/null +++ b/Projectiles/Boss/DraedonSummonLaser.cs @@ -0,0 +1,101 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Boss +{ + public class DraedonSummonLaser : ModProjectile + { + public const float LaserLength = 3800f; + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public PrimitiveTrail RayDrawer = null; + private const int Lifetime = CalamityWorld.DraedonSummonCountdownMax - 60; + + public override void SetStaticDefaults() => DisplayName.SetDefault("Giant Fuck-off Deathray of Doom"); + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.hostile = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.hide = true; + projectile.timeLeft = Lifetime; + } + + public override bool CanDamage() => projectile.timeLeft < Lifetime - 30; + + public override void AI() + { + if (projectile.localAI[0] == 0f) + { + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/TeslaCannonFire"), projectile.Center); + for (int i = 0; i < 36; i++) + { + Dust exoDust = Dust.NewDustPerfect(projectile.BottomRight, 267); + exoDust.color = CalamityUtils.MulticolorLerp(i / 36f, CalamityUtils.ExoPalette); + exoDust.velocity = (MathHelper.TwoPi * i / 36f).ToRotationVector2() * new Vector2(3f, 1.45f) - Vector2.UnitY * 2f; + exoDust.scale = 2.8f; + exoDust.fadeIn = Main.rand.NextFloat(0.8f, 1.85f); + exoDust.noGravity = true; + } + + for (int i = 0; i < 10; i++) + { + Dust exoDust = Dust.NewDustPerfect(projectile.BottomRight, 267); + exoDust.color = CalamityUtils.MulticolorLerp(Main.rand.NextFloat(), CalamityUtils.ExoPalette); + exoDust.velocity = Main.rand.NextVector2Circular(2f, 2f); + exoDust.scale = 4f; + exoDust.fadeIn = 2f; + exoDust.noGravity = true; + } + projectile.localAI[0] = 1f; + } + + Lighting.AddLight(projectile.Center, Color.White.ToVector3()); + projectile.scale = Utils.InverseLerp(-1f, 15f, projectile.timeLeft, true) * Utils.InverseLerp(Lifetime + 1f, Lifetime - 15f, projectile.timeLeft, true); + } + + private float PrimitiveWidthFunction(float completionRatio) + { + return Utils.InverseLerp(1f, 0.96f, completionRatio, true) * Utils.InverseLerp(0f, 0.016f, completionRatio, true) * projectile.scale * 20f; + } + + private Color PrimitiveColorFunction(float completionRatio) + { + return CalamityUtils.MulticolorLerp((Main.GlobalTime * 0.67f - completionRatio * 3f) % 1f, CalamityUtils.ExoPalette) * 1.2f; + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (RayDrawer is null) + RayDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]); + + GameShaders.Misc["CalamityMod:Flame"].UseImage("Images/Misc/Perlin"); + + Vector2[] basePoints = new Vector2[8]; + for (int i = 0; i < basePoints.Length; i++) + basePoints[i] = projectile.Center - Vector2.UnitY * i / basePoints.Length * LaserLength; + + Vector2 overallOffset = projectile.Size * 0.5f - Main.screenPosition; + RayDrawer.Draw(basePoints, overallOffset, 92); + return false; + } + + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) + { + return Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center - Vector2.UnitY * LaserLength); + } + + public override void DrawBehind(int index, List drawCacheProjsBehindNPCsAndTiles, List drawCacheProjsBehindNPCs, List drawCacheProjsBehindProjectiles, List drawCacheProjsOverWiresUI) + { + drawCacheProjsBehindNPCsAndTiles.Add(index); + } + } +} diff --git a/Projectiles/Boss/ExoDestroyerBeamStart.cs b/Projectiles/Boss/ExoDestroyerBeamStart.cs index eed1a3bc8f..d6b5d73769 100644 --- a/Projectiles/Boss/ExoDestroyerBeamStart.cs +++ b/Projectiles/Boss/ExoDestroyerBeamStart.cs @@ -103,7 +103,7 @@ namespace CalamityMod.Projectiles.Boss float arraySize = 3f; Vector2 samplingPoint = projectile.Center; float[] samples = new float[(int)arraySize]; - Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, 2400f, samples); + Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, 3600f, samples); float laserLength = 0f; for (int i = 0; i < samples.Length; i++) { @@ -113,7 +113,7 @@ namespace CalamityMod.Projectiles.Boss // Fire laser through walls at max length if target cannot be seen if (!Collision.CanHitLine(ThingToAttachTo.Center, 1, 1, Main.player[ThingToAttachTo.target].Center, 1, 1)) - laserLength = 2400f; + laserLength = 3600f; float amount = 0.5f; LengthOfLaser = MathHelper.Lerp(LengthOfLaser, laserLength, amount); diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index a6b5708cd6..4babe3c05d 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -128,11 +128,50 @@ namespace CalamityMod.Projectiles #region SetDefaults public override void SetDefaults(Projectile projectile) { - if (CalamityLists.trueMeleeProjectileList.Contains(projectile.type)) - trueMelee = true; - switch (projectile.type) { + case ProjectileID.Spear: + case ProjectileID.Trident: + case ProjectileID.TheRottedFork: + case ProjectileID.Swordfish: + case ProjectileID.DarkLance: + case ProjectileID.CobaltNaginata: + case ProjectileID.PalladiumPike: + case ProjectileID.MythrilHalberd: + case ProjectileID.OrichalcumHalberd: + case ProjectileID.AdamantiteGlaive: + case ProjectileID.TitaniumTrident: + case ProjectileID.MushroomSpear: + case ProjectileID.Gungnir: + case ProjectileID.ObsidianSwordfish: + case ProjectileID.CobaltDrill: + case ProjectileID.MythrilDrill: + case ProjectileID.AdamantiteDrill: + case ProjectileID.PalladiumDrill: + case ProjectileID.OrichalcumDrill: + case ProjectileID.TitaniumDrill: + case ProjectileID.ChlorophyteDrill: + case ProjectileID.CobaltChainsaw: + case ProjectileID.MythrilChainsaw: + case ProjectileID.AdamantiteChainsaw: + case ProjectileID.PalladiumChainsaw: + case ProjectileID.OrichalcumChainsaw: + case ProjectileID.TitaniumChainsaw: + case ProjectileID.ChlorophyteChainsaw: + case ProjectileID.VortexDrill: + case ProjectileID.VortexChainsaw: + case ProjectileID.NebulaDrill: + case ProjectileID.NebulaChainsaw: + case ProjectileID.SolarFlareDrill: + case ProjectileID.SolarFlareChainsaw: + case ProjectileID.StardustDrill: + case ProjectileID.StardustChainsaw: + case ProjectileID.Hamdrax: + case ProjectileID.ChlorophyteJackhammer: + case ProjectileID.SawtoothShark: + trueMelee = true; + break; + case ProjectileID.Bullet: case ProjectileID.MeteorShot: case ProjectileID.BulletHighVelocity: @@ -203,10 +242,12 @@ namespace CalamityMod.Projectiles case ProjectileID.Arkhalis: case ProjectileID.ButchersChainsaw: + trueMelee = true; projectile.scale = 1.5f; break; case ProjectileID.MonkStaffT1: + trueMelee = true; projectile.scale = 3f; break; @@ -227,6 +268,7 @@ namespace CalamityMod.Projectiles break; case ProjectileID.MonkStaffT2: + trueMelee = true; projectile.idStaticNPCHitCooldown = 18; break; diff --git a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs index 02b81cda59..16b2386702 100644 --- a/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs +++ b/Projectiles/DraedonsArsenal/HydraulicVoltCrasherProjectile.cs @@ -29,6 +29,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.ownerHitCheck = true; projectile.melee = true; projectile.scale = 1.75f; + projectile.Calamity().trueMelee = true; } public override void AI() diff --git a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs index 165fcecad2..cca960c8ab 100644 --- a/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs +++ b/Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs @@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 7; + projectile.localNPCHitCooldown = 13; } // Vanilla Terraria doesn't sync projectile rotation, but it does sync velocity. diff --git a/Projectiles/Melee/CosmicShivBall.cs b/Projectiles/Melee/CosmicShivBall.cs index 5c69f79a4d..3263436039 100644 --- a/Projectiles/Melee/CosmicShivBall.cs +++ b/Projectiles/Melee/CosmicShivBall.cs @@ -10,10 +10,11 @@ namespace CalamityMod.Projectiles.Melee { public class CosmicShivBall : ModProjectile { + // TODO - Please for the love of god refactor this at some point. It is ancient. public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public NPC target = null; - public const float maxDistanceToTarget = 300f; + public const float maxDistanceToTarget = 540f; public bool initialized = false; public float startingVelocityY = 0f; public float randomAngleDelta = 0f; @@ -61,15 +62,15 @@ namespace CalamityMod.Projectiles.Melee } if (target != null) { - const float turnSpeed = 20f; - const float speedMult = 48f; - Vector2 distNorm = (target.Center - projectile.Center).SafeNormalize(Vector2.UnitX); - projectile.velocity = (projectile.velocity * (turnSpeed - 1f) + distNorm * speedMult) / turnSpeed; + float inertia = 35f; + float homingSpeed = 33.5f; + Vector2 idealVelocity = projectile.SafeDirectionTo(target.Center, Vector2.UnitX) * homingSpeed; + projectile.velocity = (projectile.velocity * (inertia - 1f) + idealVelocity) / inertia; } else { projectile.ai[0]++; - projectile.velocity.Y = startingVelocityY + (float)(16.0 * Math.Cos((double)projectile.ai[0] / 12.0 + (double)randomAngleDelta)); + projectile.velocity.Y = startingVelocityY + (float)(Math.Cos(projectile.ai[0] / 12D + randomAngleDelta) * 7D); } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Melee/DevilsSunriseProj.cs b/Projectiles/Melee/DevilsSunriseProj.cs index 6f943b40c1..36b7919c34 100644 --- a/Projectiles/Melee/DevilsSunriseProj.cs +++ b/Projectiles/Melee/DevilsSunriseProj.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Melee projectile.ownerHitCheck = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override void AI() diff --git a/Projectiles/Melee/DragonRageStaff.cs b/Projectiles/Melee/DragonRageStaff.cs index 57c21c93f0..8fa94959c9 100644 --- a/Projectiles/Melee/DragonRageStaff.cs +++ b/Projectiles/Melee/DragonRageStaff.cs @@ -31,6 +31,7 @@ namespace CalamityMod.Projectiles.Melee projectile.hide = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; + projectile.Calamity().trueMelee = true; } public override void AI() diff --git a/Projectiles/Melee/MarniteObliteratorProj.cs b/Projectiles/Melee/MarniteObliteratorProj.cs index ae875ee8fc..f685f7f62a 100644 --- a/Projectiles/Melee/MarniteObliteratorProj.cs +++ b/Projectiles/Melee/MarniteObliteratorProj.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Projectiles.Melee projectile.hide = true; projectile.ownerHitCheck = true; projectile.melee = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } } } diff --git a/Projectiles/Melee/MurasamaSlash.cs b/Projectiles/Melee/MurasamaSlash.cs index 80058e9f6c..ef161d7879 100644 --- a/Projectiles/Melee/MurasamaSlash.cs +++ b/Projectiles/Melee/MurasamaSlash.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Projectiles.Melee projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 21; projectile.frameCounter = 0; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) diff --git a/Projectiles/Melee/PrismRay.cs b/Projectiles/Melee/PrismRay.cs index 7d3b81c3bd..7633d8682d 100644 --- a/Projectiles/Melee/PrismRay.cs +++ b/Projectiles/Melee/PrismRay.cs @@ -1,15 +1,15 @@ -using CalamityMod.Items; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Melee { public class PrismRay : ModProjectile { public Vector2 StartingPosition; - public Color RayColor => CalamityUtils.MulticolorLerp(RayHue, CalamityGlobalItem.ExoPalette); + public Color RayColor => CalamityUtils.MulticolorLerp(RayHue, CalamityUtils.ExoPalette); public Color HueDownscaledRayColor => RayColor * 0.66f; public ref float RayHue => ref projectile.ai[0]; public ref float Time => ref projectile.localAI[1]; diff --git a/Projectiles/Melee/Spears/AmidiasTridentProj.cs b/Projectiles/Melee/Spears/AmidiasTridentProj.cs index e6ed3edefe..3beca2fd09 100644 --- a/Projectiles/Melee/Spears/AmidiasTridentProj.cs +++ b/Projectiles/Melee/Spears/AmidiasTridentProj.cs @@ -25,7 +25,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.penetrate = -1; projectile.ownerHitCheck = true; projectile.hide = true; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/AstralPikeProj.cs b/Projectiles/Melee/Spears/AstralPikeProj.cs index 4a9f04712d..94ca091c53 100644 --- a/Projectiles/Melee/Spears/AstralPikeProj.cs +++ b/Projectiles/Melee/Spears/AstralPikeProj.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/BansheeHookProj.cs b/Projectiles/Melee/Spears/BansheeHookProj.cs index 90d4974778..3b95119831 100644 --- a/Projectiles/Melee/Spears/BansheeHookProj.cs +++ b/Projectiles/Melee/Spears/BansheeHookProj.cs @@ -30,7 +30,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; projectile.alpha = 255; - //projectile.Calamity().trueMelee = true; } public override SpearType SpearAiType => SpearType.GhastlyGlaiveSpear; diff --git a/Projectiles/Melee/Spears/BrimlanceProj.cs b/Projectiles/Melee/Spears/BrimlanceProj.cs index 4d75f0be6e..e256a4389d 100644 --- a/Projectiles/Melee/Spears/BrimlanceProj.cs +++ b/Projectiles/Melee/Spears/BrimlanceProj.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.penetrate = -1; projectile.ownerHitCheck = true; projectile.hide = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/DiseasedPikeSpear.cs b/Projectiles/Melee/Spears/DiseasedPikeSpear.cs index c320e0737f..5dad1b6d03 100644 --- a/Projectiles/Melee/Spears/DiseasedPikeSpear.cs +++ b/Projectiles/Melee/Spears/DiseasedPikeSpear.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/EarthenPikeSpear.cs b/Projectiles/Melee/Spears/EarthenPikeSpear.cs index 6f70ba1bbd..7bb7360f06 100644 --- a/Projectiles/Melee/Spears/EarthenPikeSpear.cs +++ b/Projectiles/Melee/Spears/EarthenPikeSpear.cs @@ -26,7 +26,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs index ad14606432..52303501c0 100644 --- a/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs +++ b/Projectiles/Melee/Spears/ExsanguinationLanceProjectile.cs @@ -28,7 +28,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; public override float ReelbackSpeed => 2.4f; diff --git a/Projectiles/Melee/Spears/FulgurationHalberdProj.cs b/Projectiles/Melee/Spears/FulgurationHalberdProj.cs index 91551c48ee..67a26ee483 100644 --- a/Projectiles/Melee/Spears/FulgurationHalberdProj.cs +++ b/Projectiles/Melee/Spears/FulgurationHalberdProj.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/GildedProboscisProj.cs b/Projectiles/Melee/Spears/GildedProboscisProj.cs index 4526ffab88..a32f26c39c 100644 --- a/Projectiles/Melee/Spears/GildedProboscisProj.cs +++ b/Projectiles/Melee/Spears/GildedProboscisProj.cs @@ -26,7 +26,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ownerHitCheck = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 4; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } // These numbers sure are common, huh? yeah, they are diff --git a/Projectiles/Melee/Spears/GoldplumeSpearProjectile.cs b/Projectiles/Melee/Spears/GoldplumeSpearProjectile.cs index 49bd3f8949..784facd3d5 100644 --- a/Projectiles/Melee/Spears/GoldplumeSpearProjectile.cs +++ b/Projectiles/Melee/Spears/GoldplumeSpearProjectile.cs @@ -23,7 +23,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs index 2405eb9ebe..b7080ec2c9 100644 --- a/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs +++ b/Projectiles/Melee/Spears/HellionFlowerSpearProjectile.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/InsidiousImpalerProj.cs b/Projectiles/Melee/Spears/InsidiousImpalerProj.cs index ebca48c63d..dfec53513a 100644 --- a/Projectiles/Melee/Spears/InsidiousImpalerProj.cs +++ b/Projectiles/Melee/Spears/InsidiousImpalerProj.cs @@ -28,7 +28,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ownerHitCheck = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/MarniteSpearProjectile.cs b/Projectiles/Melee/Spears/MarniteSpearProjectile.cs index 6cbde975c3..4f8192da22 100644 --- a/Projectiles/Melee/Spears/MarniteSpearProjectile.cs +++ b/Projectiles/Melee/Spears/MarniteSpearProjectile.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/NadirSpear.cs b/Projectiles/Melee/Spears/NadirSpear.cs index 61e4138a06..2c3ba98ec3 100644 --- a/Projectiles/Melee/Spears/NadirSpear.cs +++ b/Projectiles/Melee/Spears/NadirSpear.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 4; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 5.5f; diff --git a/Projectiles/Melee/Spears/SausageMakerSpear.cs b/Projectiles/Melee/Spears/SausageMakerSpear.cs index c375b431af..d2f7c8499f 100644 --- a/Projectiles/Melee/Spears/SausageMakerSpear.cs +++ b/Projectiles/Melee/Spears/SausageMakerSpear.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/SpatialLanceProjectile.cs b/Projectiles/Melee/Spears/SpatialLanceProjectile.cs index bd0454caaa..37cae1e3fa 100644 --- a/Projectiles/Melee/Spears/SpatialLanceProjectile.cs +++ b/Projectiles/Melee/Spears/SpatialLanceProjectile.cs @@ -30,7 +30,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ownerHitCheck = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 7; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/StarnightLanceProjectile.cs b/Projectiles/Melee/Spears/StarnightLanceProjectile.cs index 2ffb51c4fb..083414ef43 100644 --- a/Projectiles/Melee/Spears/StarnightLanceProjectile.cs +++ b/Projectiles/Melee/Spears/StarnightLanceProjectile.cs @@ -25,7 +25,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/StreamGougeProj.cs b/Projectiles/Melee/Spears/StreamGougeProj.cs index 9096c3e3ee..c4a0b6fd58 100644 --- a/Projectiles/Melee/Spears/StreamGougeProj.cs +++ b/Projectiles/Melee/Spears/StreamGougeProj.cs @@ -30,7 +30,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.hide = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 5; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs index 755b3b173d..1713ccaee7 100644 --- a/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs +++ b/Projectiles/Melee/Spears/TenebreusTidesProjectile.cs @@ -27,7 +27,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 15; } diff --git a/Projectiles/Melee/Spears/TerraLanceProjectile.cs b/Projectiles/Melee/Spears/TerraLanceProjectile.cs index 1353d9b72c..7172dcf6ab 100644 --- a/Projectiles/Melee/Spears/TerraLanceProjectile.cs +++ b/Projectiles/Melee/Spears/TerraLanceProjectile.cs @@ -24,7 +24,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/UrchinSpearProjectile.cs b/Projectiles/Melee/Spears/UrchinSpearProjectile.cs index 0157170e2b..9401b5637c 100644 --- a/Projectiles/Melee/Spears/UrchinSpearProjectile.cs +++ b/Projectiles/Melee/Spears/UrchinSpearProjectile.cs @@ -25,7 +25,6 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/Spears/YateveoBloomSpear.cs b/Projectiles/Melee/Spears/YateveoBloomSpear.cs index 5220848d6b..9da2f9ca74 100644 --- a/Projectiles/Melee/Spears/YateveoBloomSpear.cs +++ b/Projectiles/Melee/Spears/YateveoBloomSpear.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Projectiles.Melee.Spears projectile.ignoreWater = true; projectile.penetrate = -1; projectile.ownerHitCheck = true; - //projectile.Calamity().trueMelee = true; + projectile.Calamity().trueMelee = true; } public override float InitialSpeed => 3f; diff --git a/Projectiles/Melee/TaintedBladeSlasher.cs b/Projectiles/Melee/TaintedBladeSlasher.cs index 30b8eace4f..e09d257afe 100644 --- a/Projectiles/Melee/TaintedBladeSlasher.cs +++ b/Projectiles/Melee/TaintedBladeSlasher.cs @@ -118,6 +118,7 @@ namespace CalamityMod.Projectiles.Melee projectile.timeLeft = 90000; projectile.usesLocalNPCImmunity = true; projectile.noEnchantments = true; + projectile.Calamity().trueMelee = true; } public override void SendExtraAI(BinaryWriter writer) => writer.Write(VerticalOffset); @@ -189,7 +190,8 @@ namespace CalamityMod.Projectiles.Melee projectile.Center += (destination - projectile.Center).SafeNormalize(Vector2.Zero) * MathHelper.Min(projectile.Distance(destination), 12f + Owner.velocity.Length()); // Ensure that the position is never too far from the destination. - CalamityUtils.DistanceClamp(ref projectile.position, ref destination, 50f); + if (!projectile.WithinRange(destination, 300f)) + projectile.Center = destination; Time++; } diff --git a/Projectiles/Ranged/PrismExplosionLarge.cs b/Projectiles/Ranged/PrismExplosionLarge.cs index c79abef3d0..0ba7cb62bd 100644 --- a/Projectiles/Ranged/PrismExplosionLarge.cs +++ b/Projectiles/Ranged/PrismExplosionLarge.cs @@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Ranged for (int i = 0; i < 36; i++) { Vector2 lightDrawPosition = drawPosition + (MathHelper.TwoPi * i / 36f + Main.GlobalTime * 5f).ToRotationVector2() * projectile.scale * 20f; - Color lightBurstColor = CalamityUtils.MulticolorLerp(projectile.timeLeft / 144f, Items.CalamityGlobalItem.ExoPalette); + Color lightBurstColor = CalamityUtils.MulticolorLerp(projectile.timeLeft / 144f, CalamityUtils.ExoPalette); lightBurstColor = Color.Lerp(lightBurstColor, Color.White, 0.4f) * projectile.Opacity * 0.04f; lightBurstColor.A = 0; spriteBatch.Draw(lightTexture, lightDrawPosition, null, lightBurstColor, 0f, lightTexture.Size() * 0.5f, projectile.scale * 4.5f, SpriteEffects.None, 0f); diff --git a/Projectiles/Rogue/TheAtomSplitterDuplicate.cs b/Projectiles/Rogue/TheAtomSplitterDuplicate.cs index aad20f8398..4f5042ac4a 100644 --- a/Projectiles/Rogue/TheAtomSplitterDuplicate.cs +++ b/Projectiles/Rogue/TheAtomSplitterDuplicate.cs @@ -1,4 +1,3 @@ -using CalamityMod.Items; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -54,7 +53,7 @@ namespace CalamityMod.Projectiles.Rogue if (Time <= 1f) return false; - Color drawColor = CalamityUtils.MulticolorLerp((Time / 35f + projectile.identity / 4f) % 1f, CalamityGlobalItem.ExoPalette); + Color drawColor = CalamityUtils.MulticolorLerp((Time / 35f + projectile.identity / 4f) % 1f, CalamityUtils.ExoPalette); drawColor.A = 0; CalamityUtils.DrawAfterimagesCentered(projectile, ProjectileID.Sets.TrailingMode[projectile.type], drawColor); return false; diff --git a/Projectiles/Rogue/TheAtomSplitterProjectile.cs b/Projectiles/Rogue/TheAtomSplitterProjectile.cs index 7207878374..7798a1947a 100644 --- a/Projectiles/Rogue/TheAtomSplitterProjectile.cs +++ b/Projectiles/Rogue/TheAtomSplitterProjectile.cs @@ -1,4 +1,3 @@ -using CalamityMod.Items; using Microsoft.Xna.Framework; using System; using System.IO; @@ -87,7 +86,7 @@ namespace CalamityMod.Projectiles.Rogue float dustVelocityArcOffset = 1.5f + (float)Math.Sin(MathHelper.TwoPi * projectile.timeLeft / 35f) * 0.25f; float colorInterpolant = (float)Math.Cos(MathHelper.TwoPi * projectile.timeLeft / 75f) * 0.5f + 0.5f; - Color dustColor = CalamityUtils.MulticolorLerp(colorInterpolant, CalamityGlobalItem.ExoPalette); + Color dustColor = CalamityUtils.MulticolorLerp(colorInterpolant, CalamityUtils.ExoPalette); Vector2 currentDirection = projectile.velocity.SafeNormalize(-Vector2.UnitY); Vector2 tipPosition = projectile.Center + currentDirection * (projectile.height * 0.67f - 3f); tipPosition += Main.rand.NextVector2CircularEdge(0.35f, 0.35f); @@ -139,7 +138,7 @@ namespace CalamityMod.Projectiles.Rogue for (float i = 0f; i < dustCount; i++) { - Color dustColor = CalamityUtils.MulticolorLerp(Main.rand.NextFloat(), CalamityGlobalItem.ExoPalette); + Color dustColor = CalamityUtils.MulticolorLerp(Main.rand.NextFloat(), CalamityUtils.ExoPalette); Dust explosionDust = Dust.NewDustDirect(spawnPosition, 0, 0, 267, 0f, 0f, 0, dustColor, 1f); explosionDust.position = spawnPosition; explosionDust.velocity = baseDustVelocity.RotatedBy(MathHelper.TwoPi * i / dustCount) * outwardFireSpeedFactor * Main.rand.NextFloat(0.8f, 1.2f); diff --git a/Projectiles/Typeless/CyanLabSeeker.cs b/Projectiles/Typeless/CyanLabSeeker.cs new file mode 100644 index 0000000000..41d77694d6 --- /dev/null +++ b/Projectiles/Typeless/CyanLabSeeker.cs @@ -0,0 +1,61 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class CyanLabSeeker : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Items/LabFinders/CyanSeekingMechanism"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeking Mechanism"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.timeLeft = 300; + } + + public override void AI() => RedLabSeeker.Behavior(projectile, CalamityWorld.SunkenSeaLabCenter, Color.Cyan, ref Time); + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + dust.color = Color.Cyan; + dust.scale = Main.rand.NextFloat(0.95f, 1.25f); + dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); + dust.velocity.Y -= 1.5f; + dust.fadeIn = 1.2f; + dust.noGravity = true; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + if (Time > 80f && projectile.ai[1] == 0f) + { + for (int i = 0; i < 24; i += 2) + { + Vector2 drawPosition = projectile.Center - projectile.velocity.SafeNormalize(Vector2.Zero) * i * Utils.InverseLerp(80f, 125f, Time, true) * 25f - Main.screenPosition; + spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor) * (1f - i / 24f), projectile.rotation, texture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + return true; + } + } +} diff --git a/Projectiles/Typeless/GreenLabSeeker.cs b/Projectiles/Typeless/GreenLabSeeker.cs new file mode 100644 index 0000000000..e4cecb13aa --- /dev/null +++ b/Projectiles/Typeless/GreenLabSeeker.cs @@ -0,0 +1,62 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class GreenLabSeeker : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Items/LabFinders/GreenSeekingMechanism"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeking Mechanism"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.timeLeft = 300; + } + + + public override void AI() => RedLabSeeker.Behavior(projectile, CalamityWorld.JungleLabCenter, Color.Green, ref Time); + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + dust.color = Color.Green; + dust.scale = Main.rand.NextFloat(0.95f, 1.25f); + dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); + dust.velocity.Y -= 1.5f; + dust.fadeIn = 1.2f; + dust.noGravity = true; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + if (Time > 80f && projectile.ai[1] == 0f) + { + for (int i = 0; i < 24; i += 2) + { + Vector2 drawPosition = projectile.Center - projectile.velocity.SafeNormalize(Vector2.Zero) * i * Utils.InverseLerp(80f, 125f, Time, true) * 25f - Main.screenPosition; + spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor) * (1f - i / 24f), projectile.rotation, texture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + return true; + } + } +} diff --git a/Projectiles/Typeless/PurpleLabSeeker.cs b/Projectiles/Typeless/PurpleLabSeeker.cs new file mode 100644 index 0000000000..2d906043c7 --- /dev/null +++ b/Projectiles/Typeless/PurpleLabSeeker.cs @@ -0,0 +1,61 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class PurpleLabSeeker : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Items/LabFinders/PurpleSeekingMechanism"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeking Mechanism"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.timeLeft = 300; + } + + public override void AI() => RedLabSeeker.Behavior(projectile, CalamityWorld.PlanetoidLabCenter, Color.Magenta, ref Time); + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + dust.color = Color.Magenta; + dust.scale = Main.rand.NextFloat(0.95f, 1.25f); + dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); + dust.velocity.Y -= 1.5f; + dust.fadeIn = 1.2f; + dust.noGravity = true; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + if (Time > 80f && projectile.ai[1] == 0f) + { + for (int i = 0; i < 24; i += 2) + { + Vector2 drawPosition = projectile.Center - projectile.velocity.SafeNormalize(Vector2.Zero) * i * Utils.InverseLerp(80f, 125f, Time, true) * 25f - Main.screenPosition; + spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor) * (1f - i / 24f), projectile.rotation, texture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + return true; + } + } +} diff --git a/Projectiles/Typeless/RedLabSeeker.cs b/Projectiles/Typeless/RedLabSeeker.cs new file mode 100644 index 0000000000..f7fceae72b --- /dev/null +++ b/Projectiles/Typeless/RedLabSeeker.cs @@ -0,0 +1,105 @@ +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.Typeless +{ + public class RedLabSeeker : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Items/LabFinders/RedSeekingMechanism"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeking Mechanism"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.timeLeft = 300; + } + + public static void Behavior(Projectile projectile, Vector2 destination, Color dustColor, ref float time) + { + projectile.ai[1] = 0f; + + if (time < 45f) + projectile.velocity = Vector2.UnitY * Utils.InverseLerp(0f, 25f, time, true) * Utils.InverseLerp(30f, 25f, time, true) * -4.5f; + else if (time < 80f) + projectile.rotation = (projectile.AngleTo(destination) + MathHelper.PiOver2) * Utils.InverseLerp(45f, 70f, time, true); + else + { + if (projectile.WithinRange(destination, 420f)) + { + projectile.ai[1] = 1f; + projectile.velocity = Vector2.Lerp(projectile.velocity, Vector2.UnitY * (float)Math.Sin((time - 80f) / 24f) * 2.5f, 0.15f); + + if (!projectile.WithinRange(destination, 30f)) + projectile.Center = projectile.Center.MoveTowards(destination, 10f); + projectile.rotation *= 0.95f; + projectile.Center = Vector2.Lerp(projectile.Center, destination, 0.1f); + } + // Release lingering dust. + else + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(8f, 8f), 267); + dust.velocity = Main.rand.NextVector2Circular(2f, 2f); + dust.noGravity = true; + dust.color = dustColor; + dust.scale = 1.6f; + dust.fadeIn = 1.45f; + } + } + + if (time > 80f && time < 120f) + projectile.velocity = (projectile.rotation - MathHelper.PiOver2).ToRotationVector2() * Utils.InverseLerp(80f, 105f, time, true) * 25f; + + // Reset afterimages before the charge. + if (time < 80f) + projectile.oldPos = new Vector2[projectile.oldPos.Length]; + + Lighting.AddLight(projectile.Center, Vector3.One * 0.8f); + time++; + } + + public override void AI() => Behavior(projectile, CalamityWorld.HellLabCenter, Color.Red, ref Time); + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + dust.color = Color.Red; + dust.scale = Main.rand.NextFloat(0.95f, 1.25f); + dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); + dust.velocity.Y -= 1.5f; + dust.fadeIn = 1.2f; + dust.noGravity = true; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + if (Time > 80f && projectile.ai[1] == 0f) + { + for (int i = 0; i < 24; i += 2) + { + Vector2 drawPosition = projectile.Center - projectile.velocity.SafeNormalize(Vector2.Zero) * i * Utils.InverseLerp(80f, 125f, Time, true) * 25f - Main.screenPosition; + spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor) * (1f - i / 24f), projectile.rotation, texture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + return true; + } + } +} diff --git a/Projectiles/Typeless/YanmeisKnifeSlash.cs b/Projectiles/Typeless/YanmeisKnifeSlash.cs index 346fbfc9d2..0ea7c02233 100644 --- a/Projectiles/Typeless/YanmeisKnifeSlash.cs +++ b/Projectiles/Typeless/YanmeisKnifeSlash.cs @@ -51,9 +51,6 @@ namespace CalamityMod.Projectiles.Typeless projectile.ownerHitCheck = true; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 20; - - // Not considered true melee to prevent Titan Scale from triggering. - // projectile.Calamity().trueMelee = true; } public override void AI() diff --git a/Projectiles/Typeless/YellowLabSeeker.cs b/Projectiles/Typeless/YellowLabSeeker.cs new file mode 100644 index 0000000000..c73af6ad85 --- /dev/null +++ b/Projectiles/Typeless/YellowLabSeeker.cs @@ -0,0 +1,61 @@ +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class YellowLabSeeker : ModProjectile + { + public ref float Time => ref projectile.ai[0]; + public override string Texture => "CalamityMod/Items/LabFinders/YellowSeekingMechanism"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Seeking Mechanism"); + ProjectileID.Sets.TrailingMode[projectile.type] = 1; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 20; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.friendly = true; + projectile.ignoreWater = true; + projectile.tileCollide = false; + projectile.timeLeft = 300; + } + + public override void AI() => RedLabSeeker.Behavior(projectile, CalamityWorld.IceLabCenter, Color.Yellow, ref Time); + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 8; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center + Main.rand.NextVector2Circular(16f, 16f), 267); + dust.color = Color.Yellow; + dust.scale = Main.rand.NextFloat(0.95f, 1.25f); + dust.velocity = Main.rand.NextVector2Circular(2.5f, 2.5f); + dust.velocity.Y -= 1.5f; + dust.fadeIn = 1.2f; + dust.noGravity = true; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture = Main.projectileTexture[projectile.type]; + if (Time > 80f && projectile.ai[1] == 0f) + { + for (int i = 0; i < 24; i += 2) + { + Vector2 drawPosition = projectile.Center - projectile.velocity.SafeNormalize(Vector2.Zero) * i * Utils.InverseLerp(80f, 125f, Time, true) * 25f - Main.screenPosition; + spriteBatch.Draw(texture, drawPosition, null, projectile.GetAlpha(lightColor) * (1f - i / 24f), projectile.rotation, texture.Size() * 0.5f, projectile.scale, SpriteEffects.None, 0f); + } + } + return true; + } + } +} diff --git a/TileEntities/TECodebreaker.cs b/TileEntities/TECodebreaker.cs new file mode 100644 index 0000000000..94bc3632f8 --- /dev/null +++ b/TileEntities/TECodebreaker.cs @@ -0,0 +1,412 @@ +using CalamityMod.CustomRecipes; +using CalamityMod.Items.DraedonMisc; +using CalamityMod.Tiles.DraedonSummoner; +using Microsoft.Xna.Framework; +using System; +using System.IO; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.IO; + +namespace CalamityMod.TileEntities +{ + public class TECodebreaker : ModTileEntity + { + public int InputtedCellCount; + public int InitialCellCountBeforeDecrypting; + public int HeldSchematicID; + + public int DecryptionCountdown; + public int DecryptionTotalTime + { + get + { + // Decryption takes 35 minutes typically. + int decryptTime = 126000; + + // However, if this codebreaker has a quantum cell, it only takes 1 minute. + if (ContainsCoolingCell) + decryptTime = 3600; + return decryptTime; + } + } + + public int DecryptionCellCost + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return 0; + + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return 500; + if (schematicType == ModContent.ItemType()) + return 950; + if (schematicType == ModContent.ItemType()) + return 1750; + if (schematicType == ModContent.ItemType()) + return 5000; + + return 0; + } + } + + public float DecryptionCompletion => 1f - DecryptionCountdown / (float)DecryptionTotalTime; + public bool ReadyToSummonDraedon => ContainsCoolingCell && DecryptionCountdown <= 0; + + public bool ContainsDecryptionComputer; + public bool ContainsSensorArray; + public bool ContainsAdvancedDisplay; + public bool ContainsVoltageRegulationSystem; + public bool ContainsCoolingCell; + + public bool CanDecryptHeldSchematic + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return false; + + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay; + if (schematicType == ModContent.ItemType()) + return ContainsDecryptionComputer && ContainsSensorArray && ContainsAdvancedDisplay && ContainsVoltageRegulationSystem; + + return false; + } + } + + public string UnderlyingSchematicText + { + get + { + // You can't decrypt nothing. + if (HeldSchematicID == 0 || !CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return string.Empty; + + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + if (schematicType == ModContent.ItemType()) + return "test1"; + if (schematicType == ModContent.ItemType()) + return "test2"; + if (schematicType == ModContent.ItemType()) + return "test3"; + if (schematicType == ModContent.ItemType()) + return "test4"; + + return string.Empty; + } + } + + public Vector2 Center => Position.ToWorldCoordinates(8f * CodebreakerTile.Width, 8f * CodebreakerTile.Height); + public const int MaxCellCapacity = 9999; + + // This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Codebreaker tile. + public override bool ValidTile(int i, int j) + { + Tile tile = CalamityUtils.ParanoidTileRetrieval(i, j); + return tile.active() && tile.type == ModContent.TileType() && tile.frameX == 0 && tile.frameY == 0; + } + + // This code is called as a hook when the player places the Codebreaker tile so that the tile entity may be placed. + public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction) + { + // If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That would mismatch IDs. + // Also tell the server that you placed the 5x8 tiles that make up the Codebreaker. + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendTileRange(Main.myPlayer, i, j, CodebreakerTile.Width, CodebreakerTile.Height); + NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type); + return -1; + } + + // If in single player, just place the tile entity, no problems. + return Place(i, j); + } + + // This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement. + // When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients. + // This will cause them to Place the tile entity locally at that position, all with exactly the same ID. + public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y); + + public override void Update() => UpdateTime(); + + public void DropConstituents(int x, int y) + { + if (ContainsDecryptionComputer) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsSensorArray) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsAdvancedDisplay) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsVoltageRegulationSystem) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + if (ContainsCoolingCell) + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType()); + + if (CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + Item.NewItem(x * 16, y * 16, 32, 32, CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]); + + while (InputtedCellCount > 0) + { + int totalCellsToDrop = InputtedCellCount; + if (totalCellsToDrop > 999) + totalCellsToDrop = 999; + InputtedCellCount -= totalCellsToDrop; + Item.NewItem(x * 16, y * 16, 32, 32, ModContent.ItemType(), totalCellsToDrop); + } + } + + public void SyncConstituents() + { + // Don't bother sending packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; + + ModPacket packet = mod.GetPacket(); + BitsByte containmentFlagWrapper = new BitsByte(); + containmentFlagWrapper[0] = ContainsDecryptionComputer; + containmentFlagWrapper[1] = ContainsSensorArray; + containmentFlagWrapper[2] = ContainsAdvancedDisplay; + containmentFlagWrapper[3] = ContainsVoltageRegulationSystem; + containmentFlagWrapper[4] = ContainsCoolingCell; + + packet.Write((byte)CalamityModMessageType.UpdateCodebreakerConstituents); + packet.Write(ID); + packet.Write(containmentFlagWrapper); + } + + public static void ReadConstituentsUpdateSync(Mod mod, BinaryReader reader) + { + int id = reader.ReadInt32(); + bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); + + // Continue reading to the end even if a tile entity with the given ID does not exist. + // Not doing this will cause errors/bugs. + BitsByte containmentFlagWrapper = reader.ReadByte(); + bool containsDecryptionComputer = containmentFlagWrapper[0]; + bool containsSensorArray = containmentFlagWrapper[1]; + bool containsAdvancedDisplay = containmentFlagWrapper[2]; + bool containsVoltageRegulationSystem = containmentFlagWrapper[3]; + bool containsCoolingCell = containmentFlagWrapper[4]; + + // After doing reading, check again to see if the tile entity is actually there. + // If it isn't don't bother doing anything else. + if (!exists) + return; + + // Furthermore, verify to ensure that the tile entity is a valid one. + if (!(tileEntity is TECodebreaker codebreakerTileEntity)) + return; + + codebreakerTileEntity.ContainsDecryptionComputer = containsDecryptionComputer; + codebreakerTileEntity.ContainsSensorArray = containsSensorArray; + codebreakerTileEntity.ContainsAdvancedDisplay = containsAdvancedDisplay; + codebreakerTileEntity.ContainsVoltageRegulationSystem = containsVoltageRegulationSystem; + codebreakerTileEntity.ContainsCoolingCell = containsCoolingCell; + } + + public void SyncContainedStuff() + { + // Don't bother sending packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; + + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.UpdateCodebreakerContainedStuff); + packet.Write(ID); + packet.Write(InputtedCellCount); + packet.Write(InitialCellCountBeforeDecrypting); + packet.Write(HeldSchematicID); + } + + public static void ReadContainmentSync(Mod mod, BinaryReader reader) + { + int id = reader.ReadInt32(); + bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); + + // Continue reading to the end even if a tile entity with the given ID does not exist. + // Not doing this will cause errors/bugs. + int cellCount = reader.ReadInt32(); + int cellCountBeforeDecrypting = reader.ReadInt32(); + int schematicID = reader.ReadInt32(); + + // After doing reading, check again to see if the tile entity is actually there. + // If it isn't don't bother doing anything else. + if (!exists) + return; + + // Furthermore, verify to ensure that the tile entity is a valid one. + if (!(tileEntity is TECodebreaker codebreakerTileEntity)) + return; + + codebreakerTileEntity.InputtedCellCount = cellCount; + codebreakerTileEntity.InitialCellCountBeforeDecrypting = cellCountBeforeDecrypting; + codebreakerTileEntity.HeldSchematicID = schematicID; + } + + public void SyncDecryptCountdown() + { + // Don't bother sending packets in singleplayer. + if (Main.netMode == NetmodeID.SinglePlayer) + return; + + ModPacket packet = mod.GetPacket(); + packet.Write((byte)CalamityModMessageType.UpdateCodebreakerDecryptCountdown); + packet.Write(ID); + packet.Write(DecryptionCountdown); + } + + public static void ReadDecryptCountdownSync(Mod mod, BinaryReader reader) + { + int id = reader.ReadInt32(); + bool exists = ByID.TryGetValue(id, out TileEntity tileEntity); + + // Continue reading to the end even if a tile entity with the given ID does not exist. + // Not doing this will cause errors/bugs. + int countdown = reader.ReadInt32(); + + // After doing reading, check again to see if the tile entity is actually there. + // If it isn't don't bother doing anything else. + if (!exists) + return; + + // Furthermore, verify to ensure that the tile entity is a valid one. + if (!(tileEntity is TECodebreaker codebreakerTileEntity)) + return; + + codebreakerTileEntity.DecryptionCountdown = countdown; + } + + public void UpdateTime() + { + if (DecryptionCountdown > 0) + { + DecryptionCountdown--; + + // Gradually consume cells. + if (DecryptionCountdown % 5 == 4) + { + InputtedCellCount = InitialCellCountBeforeDecrypting - (int)(DecryptionCellCost * DecryptionCompletion); + if (Main.netMode != NetmodeID.MultiplayerClient) + SyncContainedStuff(); + } + + if (DecryptionCountdown == 0) + { + // Reset the cell count prior to decrypting. + InitialCellCountBeforeDecrypting = 0; + + LearnFromHeldSchematic(out bool anythingChanged); + if (Main.netMode == NetmodeID.Server) + { + SyncDecryptCountdown(); + SyncContainedStuff(); + } + else if (anythingChanged) + CombatText.NewText(Main.LocalPlayer.Hitbox, Color.Cyan, "You learned how to create new things!", true); + } + } + } + + public void LearnFromHeldSchematic(out bool anythingChanged) + { + anythingChanged = false; + + // Do nothing if no valid schematic is inputted at the moment. + if (!CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(HeldSchematicID)) + return; + + int schematicType = CalamityLists.EncryptedSchematicIDRelationship[HeldSchematicID]; + + if (!RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT2ArsenalRecipes = true; + anythingChanged = true; + } + if (!RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT3ArsenalRecipes = true; + anythingChanged = true; + } + if (!RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT4ArsenalRecipes = true; + anythingChanged = true; + } + if (!RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes && schematicType == ModContent.ItemType()) + { + RecipeUnlockHandler.HasUnlockedT5ArsenalRecipes = true; + anythingChanged = true; + } + + if (Main.netMode == NetmodeID.Server && anythingChanged) + CalamityNetcode.SyncWorld(); + } + + public override TagCompound Save() + { + return new TagCompound + { + ["ContainsDecryptionComputer"] = ContainsDecryptionComputer, + ["ContainsSensorArray"] = ContainsSensorArray, + ["ContainsAdvancedDisplay"] = ContainsAdvancedDisplay, + ["ContainsVoltageRegulationSystem"] = ContainsVoltageRegulationSystem, + ["ContainsCoolingCell"] = ContainsCoolingCell, + ["InputtedCellCount"] = InputtedCellCount, + ["HeldSchematicID"] = HeldSchematicID, + ["DecryptionCountdown"] = DecryptionCountdown, + ["InitialCellCountBeforeDecrypting"] = InitialCellCountBeforeDecrypting + }; + } + + public override void Load(TagCompound tag) + { + ContainsDecryptionComputer = tag.GetBool("ContainsDecryptionComputer"); + ContainsSensorArray = tag.GetBool("ContainsSensorArray"); + ContainsAdvancedDisplay = tag.GetBool("ContainsAdvancedDisplay"); + ContainsVoltageRegulationSystem = tag.GetBool("ContainsVoltageRegulationSystem"); + ContainsCoolingCell = tag.GetBool("ContainsCoolingCell"); + InputtedCellCount = tag.GetInt("InputtedCellCount"); + HeldSchematicID = tag.GetInt("HeldSchematicID"); + DecryptionCountdown = tag.GetInt("DecryptionCountdown"); + InitialCellCountBeforeDecrypting = tag.GetInt("InitialCellCountBeforeDecrypting"); + } + + public override void NetSend(BinaryWriter writer, bool lightSend) + { + writer.Write(ContainsDecryptionComputer); + writer.Write(ContainsSensorArray); + writer.Write(ContainsAdvancedDisplay); + writer.Write(ContainsVoltageRegulationSystem); + writer.Write(ContainsCoolingCell); + writer.Write(InputtedCellCount); + writer.Write(HeldSchematicID); + writer.Write(DecryptionCountdown); + writer.Write(InitialCellCountBeforeDecrypting); + } + + public override void NetReceive(BinaryReader reader, bool lightReceive) + { + ContainsDecryptionComputer = reader.ReadBoolean(); + ContainsSensorArray = reader.ReadBoolean(); + ContainsAdvancedDisplay = reader.ReadBoolean(); + ContainsVoltageRegulationSystem = reader.ReadBoolean(); + ContainsCoolingCell = reader.ReadBoolean(); + InputtedCellCount = reader.ReadInt32(); + HeldSchematicID = reader.ReadInt32(); + DecryptionCountdown = reader.ReadInt32(); + InitialCellCountBeforeDecrypting = reader.ReadInt32(); + } + } +} diff --git a/TileEntities/TileEntityTimeHandler.cs b/TileEntities/TileEntityTimeHandler.cs index eadc860b7d..1c076e1428 100644 --- a/TileEntities/TileEntityTimeHandler.cs +++ b/TileEntities/TileEntityTimeHandler.cs @@ -19,6 +19,7 @@ namespace CalamityMod.TileEntities byte factoryType = ModContent.GetInstance().type; byte chargerType = ModContent.GetInstance().type; + byte codebreakerType = ModContent.GetInstance().type; var enumerator = TileEntity.ByID.Values.GetEnumerator(); do @@ -56,6 +57,13 @@ namespace CalamityMod.TileEntities // This makes sure they visually track targets in multiplayer. It will NOT fire projectiles; that code can only run server side. turret.UpdateAngle(); } + else if (te.type == codebreakerType) + { + // Specifically on multiplayer clients, manually update the time variables of the Codebreaker every frame. + // This is done so that clients can accurately gauge how complete decryptions are. + TECodebreaker codebreaker = (TECodebreaker)te; + codebreaker.UpdateTime(); + } } while (enumerator.MoveNext()); } } diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index c8971770ab..09dd4c1be5 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -8,6 +8,7 @@ using CalamityMod.Tiles.Astral; using CalamityMod.Tiles.AstralDesert; using CalamityMod.Tiles.Crags; using CalamityMod.Tiles.DraedonStructures; +using CalamityMod.Tiles.DraedonSummoner; using CalamityMod.Tiles.Ores; using CalamityMod.Tiles.SunkenSea; using CalamityMod.World; @@ -587,8 +588,10 @@ namespace CalamityMod.Tiles int[] invincibleTiles = new int[] { ModContent.TileType(), - ModContent.TileType() + ModContent.TileType(), + ModContent.TileType() }; + // Prevent tiles below invincible tiles from being destroyed. This is like chests in vanilla. if (CalamityUtils.ParanoidTileRetrieval(i, j - 1).active() && CalamityUtils.ParanoidTileRetrieval(i, j).type != diff --git a/Tiles/DraedonSummoner/CodebreakerAdvancedDisplay.png b/Tiles/DraedonSummoner/CodebreakerAdvancedDisplay.png new file mode 100644 index 0000000000..8853083806 Binary files /dev/null and b/Tiles/DraedonSummoner/CodebreakerAdvancedDisplay.png differ diff --git a/Tiles/DraedonSummoner/CodebreakerAuricQuantumCoolingCell.png b/Tiles/DraedonSummoner/CodebreakerAuricQuantumCoolingCell.png new file mode 100644 index 0000000000..e098482c31 Binary files /dev/null and b/Tiles/DraedonSummoner/CodebreakerAuricQuantumCoolingCell.png differ diff --git a/Tiles/DraedonSummoner/CodebreakerDecryptionComputer.png b/Tiles/DraedonSummoner/CodebreakerDecryptionComputer.png new file mode 100644 index 0000000000..a5a0642811 Binary files /dev/null and b/Tiles/DraedonSummoner/CodebreakerDecryptionComputer.png differ diff --git a/Tiles/DraedonSummoner/CodebreakerLongRangedSensorArray.png b/Tiles/DraedonSummoner/CodebreakerLongRangedSensorArray.png new file mode 100644 index 0000000000..07d8351f6d Binary files /dev/null and b/Tiles/DraedonSummoner/CodebreakerLongRangedSensorArray.png differ diff --git a/Tiles/DraedonSummoner/CodebreakerTile.cs b/Tiles/DraedonSummoner/CodebreakerTile.cs new file mode 100644 index 0000000000..fb383ea9fd --- /dev/null +++ b/Tiles/DraedonSummoner/CodebreakerTile.cs @@ -0,0 +1,194 @@ +using CalamityMod.Items.DraedonMisc; +using CalamityMod.TileEntities; +using CalamityMod.UI; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.DataStructures; +using Terraria.Enums; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; + +namespace CalamityMod.Tiles.DraedonSummoner +{ + public class CodebreakerTile : ModTile + { + public const int Width = 5; + public const int Height = 8; + public const int OriginOffsetX = 2; + public const int OriginOffsetY = 7; + public const int SheetSquare = 18; + public static Texture2D TileTexture; + public static Texture2D ComputerTexture; + public static Texture2D SensorTexture; + public static Texture2D DisplayTexture; + public static Texture2D VoltageRegulatorTexture; + public static Texture2D VoltageRegulatorTexture2; + public static Texture2D CoolingCellTexture; + + public override void SetDefaults() + { + if (!Main.dedServ) + { + TileTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerTile"); + ComputerTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerDecryptionComputer"); + SensorTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerLongRangedSensorArray"); + DisplayTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerAdvancedDisplay"); + VoltageRegulatorTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem"); + VoltageRegulatorTexture2 = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem2"); + CoolingCellTexture = ModContent.GetTexture("CalamityMod/Tiles/DraedonSummoner/CodebreakerAuricQuantumCoolingCell"); + } + + Main.tileLighted[Type] = true; + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileLavaDeath[Type] = false; + Main.tileWaterDeath[Type] = false; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2); + TileObjectData.newTile.Width = Width; + TileObjectData.newTile.Height = Height; + TileObjectData.newTile.Origin = new Point16(OriginOffsetX, OriginOffsetY); + TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0); + TileObjectData.newTile.CoordinateHeights = new int[Height]; + + // Initialize the coordinate heights of each frame based on the sheet area. The padding is shaved off. + for (int i = 0; i < Height; i++) + TileObjectData.newTile.CoordinateHeights[i] = SheetSquare - 2; + + TileObjectData.newTile.LavaDeath = false; + + TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(ModContent.GetInstance().Hook_AfterPlacement, -1, 0, true); + + TileObjectData.addTile(Type); + ModTranslation name = CreateMapEntryName(); + name.SetDefault("The Codebreaker"); + AddMapEntry(new Color(92, 107, 112), name); + animationFrameHeight = 144; + } + + public override bool CanExplode(int i, int j) => false; + + // Prevent the tile from being destroyed while it's busy decrypting. + // If it's destroyed the tile entity would be too and the resources used on decryption would be lost for nothing. + public override bool CanKillTile(int i, int j, ref bool blockDamaged) + { + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(i, j, Width, Height, SheetSquare); + if (codebreakerTileEntity is null) + return true; + if (codebreakerTileEntity.DecryptionCountdown > 0) + return false; + return true; + } + + public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) + { + r = 0.18f; + g = 0.8f; + b = 0.9f; + } + + public override bool CreateDust(int i, int j, ref int type) + { + Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 182); + return false; + } + + public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + // Drop the base of the codebreaker. + Item.NewItem(i * 16, j * 16, 32, 32, ModContent.ItemType()); + + Tile t = Main.tile[i, j]; + int left = i - t.frameX % (Width * SheetSquare) / SheetSquare; + int top = j - t.frameY % (Height * SheetSquare) / SheetSquare; + + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(i, j, Width, Height, SheetSquare); + + // Drop any any attached components. + codebreakerTileEntity?.DropConstituents(i, j); + + // And destroy the tile entity, if it exists. + codebreakerTileEntity?.Kill(left, top); + } + + public override bool HasSmartInteract() => true; + + public override bool NewRightClick(int i, int j) + { + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(i, j, Width, Height, SheetSquare); + Player player = Main.LocalPlayer; + player.CancelSignsAndChests(); + + // If this is the tile the player is currently looking at, the associated tile entity doesn't really exist, or it's simply not upgraded enough, close the GUI. + if (codebreakerTileEntity is null || codebreakerTileEntity.ID == CodebreakerUI.ViewedTileEntityID || !codebreakerTileEntity.ContainsDecryptionComputer) + { + // Create a warning if someone attempts to click on a codebreaker without a computer with which to open the UI. + if (!codebreakerTileEntity.ContainsDecryptionComputer) + CombatText.NewText(player.Hitbox, Color.Cyan, "No decryption computer installed"); + + CodebreakerUI.ViewedTileEntityID = -1; + Main.PlaySound(SoundID.MenuClose); + } + + // Otherwise, open the decryption interface when it exists. This can be either opening the GUI from nothing, or just opening a separate codebreaker. + else if (codebreakerTileEntity != null) + { + // Play a sound depending on whether the player had another codebreaker open previously. + Main.PlaySound(CodebreakerUI.ViewedTileEntityID == -1 ? SoundID.MenuOpen : SoundID.MenuTick); + CodebreakerUI.ViewedTileEntityID = codebreakerTileEntity.ID; + Main.playerInventory = true; + Main.recBigList = false; + } + + Recipe.FindRecipes(); + return true; + } + + // All tile drawcode is done manually because the tile's animation is controlled by a tile entity. + public override bool PreDraw(int i, int j, SpriteBatch spriteBatch) + { + // These offsets start as the tile offsets, i.e. which sub-tile of the FrameImportant structure this specific location is. + Tile t = Main.tile[i, j]; + int left = i - t.frameX % (Width * SheetSquare) / SheetSquare; + int frameXPos = t.frameX; + int frameYPos = t.frameY + Height * SheetSquare * (int)((Main.GlobalTime * 12f + left) % 8); + + // Grab the tile entity because it stores the information regarding what is actually attached. + TECodebreaker codebreakerTileEntity = CalamityUtils.FindTileEntity(i, j, Width, Height, SheetSquare); + + Vector2 offset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + if (t.halfBrick()) + offset.Y += 8f; + + Vector2 drawPosition = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + offset; + Color drawColor = Lighting.GetColor(i, j); + Rectangle frame = new Rectangle(frameXPos, frameYPos, 16, 16); + + if ((!t.halfBrick() && t.slope() == 0) || t.halfBrick()) + { + spriteBatch.Draw(TileTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + + // Place secondary parts. + if (codebreakerTileEntity != null) + { + if (codebreakerTileEntity.ContainsDecryptionComputer) + spriteBatch.Draw(ComputerTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + if (codebreakerTileEntity.ContainsVoltageRegulationSystem) + spriteBatch.Draw(VoltageRegulatorTexture2, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + if (codebreakerTileEntity.ContainsSensorArray) + spriteBatch.Draw(SensorTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + if (codebreakerTileEntity.ContainsCoolingCell) + spriteBatch.Draw(CoolingCellTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + if (codebreakerTileEntity.ContainsVoltageRegulationSystem) + spriteBatch.Draw(VoltageRegulatorTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + if (codebreakerTileEntity.ContainsAdvancedDisplay) + spriteBatch.Draw(DisplayTexture, drawPosition, frame, drawColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } + return false; + } + } +} diff --git a/Tiles/DraedonSummoner/CodebreakerTile.png b/Tiles/DraedonSummoner/CodebreakerTile.png new file mode 100644 index 0000000000..5b78410bec Binary files /dev/null and b/Tiles/DraedonSummoner/CodebreakerTile.png differ diff --git a/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem.png b/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem.png new file mode 100644 index 0000000000..86cffb899a Binary files /dev/null and b/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem.png differ diff --git a/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem2.png b/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem2.png new file mode 100644 index 0000000000..22bab29496 Binary files /dev/null and b/Tiles/DraedonSummoner/CodebreakerVoltageRegulationSystem2.png differ diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 565eabcaaf..516551a6cd 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -348,7 +348,7 @@ namespace CalamityMod.UI continue; bool isEoWSegment = Main.npc[i].type == NPCID.EaterofWorldsBody || Main.npc[i].type == NPCID.EaterofWorldsTail; - if ((Main.npc[i].IsABoss() && !isEoWSegment) || MinibossHPBarList.Contains(Main.npc[i].type)) + if ((Main.npc[i].IsABoss() && !isEoWSegment) || MinibossHPBarList.Contains(Main.npc[i].type) || Main.npc[i].Calamity().CanHaveBossHealthBar) AttemptToAddBar(i); } diff --git a/UI/CodebreakerUI.cs b/UI/CodebreakerUI.cs new file mode 100644 index 0000000000..7c713ddeb9 --- /dev/null +++ b/UI/CodebreakerUI.cs @@ -0,0 +1,465 @@ +using CalamityMod.Items.DraedonMisc; +using CalamityMod.NPCs.ExoMechs; +using CalamityMod.TileEntities; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Linq; +using System.Text; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.UI.Chat; + +namespace CalamityMod.UI +{ + public static class CodebreakerUI + { + public static int ViewedTileEntityID = -1; + public static bool AwaitingCloseConfirmation = false; + public static bool AwaitingDecryptionTextClose = false; + public static float VerificationButtonScale = 1f; + public static float CancelButtonScale = 0.75f; + public static float ContactButtonScale = 1f; + public static float MechIconScale = 1f; + public static Vector2 BackgroundCenter => new Vector2(500f, Main.screenHeight * 0.5f + 115f); + public static float GeneralScale => MathHelper.Lerp(1f, 0.7f, Utils.InverseLerp(1325f, 750f, Main.screenWidth, true)) * Main.UIScale; + + public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); + public static void Draw(SpriteBatch spriteBatch) + { + // If not viewing the specific tile entity's interface anymore, if the ID is for some reason invalid, or if the player is not equipped to continue viewing the UI + // don't do anything other than resetting necessary data. + if (!TileEntity.ByID.ContainsKey(ViewedTileEntityID) || !(TileEntity.ByID[ViewedTileEntityID] is TECodebreaker codebreakerTileEntity) || !Main.LocalPlayer.WithinRange(codebreakerTileEntity.Center, 270f) || !Main.playerInventory) + { + VerificationButtonScale = 1f; + CancelButtonScale = 0.75f; + ContactButtonScale = 1f; + ViewedTileEntityID = -1; + AwaitingCloseConfirmation = false; + MechIconScale = 1f; + return; + } + + // Draw the background. + Texture2D backgroundTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonDecrypterBackground"); + spriteBatch.Draw(backgroundTexture, BackgroundCenter, null, Color.White, 0f, backgroundTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); + + Rectangle backgroundArea = Utils.CenteredRectangle(BackgroundCenter, backgroundTexture.Size()); + if (MouseScreenArea.Intersects(backgroundArea)) + Main.blockMouse = Main.LocalPlayer.mouseInterface = true; + + bool canSummonDraedon = codebreakerTileEntity.ReadyToSummonDraedon && CalamityWorld.AbleToSummonDraedon; + Vector2 backgroundTopLeft = BackgroundCenter - backgroundTexture.Size() * GeneralScale * 0.5f; + + // Draw the cell payment slot icon. + Texture2D emptyCellIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Empty"); + Texture2D occupiedCellIconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/PowerCellSlot_Filled"); + Texture2D textPanelTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen"); + Texture2D cellTexture = codebreakerTileEntity.InputtedCellCount > 0 ? occupiedCellIconTexture : emptyCellIconTexture; + Vector2 cellDrawCenter = backgroundTopLeft + Vector2.One * GeneralScale * 60f; + + Vector2 schematicSlotDrawCenter = cellDrawCenter + Vector2.UnitY * GeneralScale * 70f; + Vector2 costDisplayLocation = schematicSlotDrawCenter + Vector2.UnitY * GeneralScale * 20f; + Vector2 costVerificationLocation = costDisplayLocation + Vector2.UnitY * GeneralScale * 60f; + Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width + textPanelTexture.Size() * GeneralScale * new Vector2(-0.5f, 0.5f); + Vector2 summonButtonCenter = backgroundTopLeft + new Vector2(58f, backgroundTexture.Height - 48f) * GeneralScale; + + // Display some error text if the codebreaker isn't strong enough to decrypt the schematic. + if (codebreakerTileEntity.HeldSchematicID != 0 && !codebreakerTileEntity.CanDecryptHeldSchematic) + DisplayNotStrongEnoughErrorText(schematicSlotDrawCenter + new Vector2(-24f, 30f)); + + // Handle decryption costs. + else if (codebreakerTileEntity.HeldSchematicID != 0 && codebreakerTileEntity.DecryptionCountdown == 0) + { + int cost = codebreakerTileEntity.DecryptionCellCost; + DisplayCostText(costDisplayLocation, cost); + + if (codebreakerTileEntity.InputtedCellCount >= cost) + { + if (canSummonDraedon) + { + costVerificationLocation.X -= 15f; + summonButtonCenter.X += 15f; + } + DrawCostVerificationButton(codebreakerTileEntity, costVerificationLocation); + } + } + else if (codebreakerTileEntity.DecryptionCountdown > 0) + { + if (!AwaitingCloseConfirmation) + DisplayDecryptCancelButton(codebreakerTileEntity, costVerificationLocation - Vector2.UnitY * 30f); + else + DisplayDecryptCancelButton(codebreakerTileEntity, textPanelCenter + Vector2.UnitY * 110f); + } + + if (canSummonDraedon) + HandleDraedonSummonButton(codebreakerTileEntity, summonButtonCenter); + + if (codebreakerTileEntity.DecryptionCountdown > 0 || AwaitingDecryptionTextClose) + HandleDecryptionStuff(codebreakerTileEntity, backgroundTexture, backgroundTopLeft, schematicSlotDrawCenter + Vector2.UnitY * 80f); + if (codebreakerTileEntity.DecryptionCountdown > 0 && AwaitingCloseConfirmation) + DrawDecryptCancelConfirmationText(textPanelCenter); + + // Draw the schematic icon. + Texture2D schematicIconBG = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/EncryptedSchematicSlotBackground"); + Texture2D schematicIconTexture = schematicIconBG; + int schematicType = 0; + + if (codebreakerTileEntity.HeldSchematicID > 0) + schematicType = CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID]; + + if (schematicType == ModContent.ItemType()) + schematicIconTexture = ModContent.GetTexture("CalamityMod/Items/DraedonMisc/EncryptedSchematicPlanetoid"); + if (schematicType == ModContent.ItemType()) + schematicIconTexture = ModContent.GetTexture("CalamityMod/Items/DraedonMisc/EncryptedSchematicJungle"); + if (schematicType == ModContent.ItemType()) + schematicIconTexture = ModContent.GetTexture("CalamityMod/Items/DraedonMisc/EncryptedSchematicHell"); + if (schematicType == ModContent.ItemType()) + schematicIconTexture = ModContent.GetTexture("CalamityMod/Items/DraedonMisc/EncryptedSchematicIce"); + + spriteBatch.Draw(schematicIconBG, schematicSlotDrawCenter, null, Color.White, 0f, schematicIconBG.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); + if (codebreakerTileEntity.HeldSchematicID != 0) + spriteBatch.Draw(schematicIconTexture, schematicSlotDrawCenter, null, Color.White, 0f, schematicIconTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); + HandleSchematicSlotInteractions(codebreakerTileEntity, schematicSlotDrawCenter, cellTexture.Size()); + + // Create a temporary item for drawing purposes. + // If cells are present, make the item reflect that. + Item temporaryPowerCell = new Item(); + temporaryPowerCell.SetDefaults(ModContent.ItemType()); + temporaryPowerCell.stack = codebreakerTileEntity.InputtedCellCount; + + CalamityUtils.DrawPowercellSlot(spriteBatch, temporaryPowerCell, cellDrawCenter, GeneralScale); + HandleCellSlotInteractions(codebreakerTileEntity, temporaryPowerCell, cellDrawCenter, cellTexture.Size()); + } + + public static void HandleCellSlotInteractions(TECodebreaker codebreakerTileEntity, Item temporaryItem, Vector2 cellIconCenter, Vector2 area) + { + Rectangle clickArea = Utils.CenteredRectangle(cellIconCenter, area); + + // If the mouse is not in the specific area don't do anything else. + if (!MouseScreenArea.Intersects(clickArea)) + return; + + ref Item playerHandItem = ref Main.mouseItem; + + if (!temporaryItem.IsAir) + Main.HoverItem = temporaryItem; + + if (Main.mouseLeft && Main.mouseLeftRelease && codebreakerTileEntity.DecryptionCountdown <= 0) + { + int powerCellID = ModContent.ItemType(); + short cellStackDiff = 0; + bool shouldPlaySound = true; + + // If the player is holding shift and has space for the power cells, just spawn all of them on his or her face, up to the max-stack limit. + if (Main.keyState.PressingShift() && Main.LocalPlayer.ItemSpace(temporaryItem)) + { + cellStackDiff = (short)-Math.Min(temporaryItem.stack, temporaryItem.maxStack); + DropHelper.DropItem(Main.LocalPlayer, powerCellID, -cellStackDiff); + + // Do not play a sound in this situation. The player is going to pick up the dropped cells in a few frames, which will make sound. + shouldPlaySound = false; + } + + // If the slot is normally clicked, behavior depends on whether the player is holding power cells. + else + { + bool holdingPowercell = playerHandItem.type == powerCellID; + + // If the player's held power cells can be stacked on top of what's already in the codeberaker, then stack them. + if (holdingPowercell && temporaryItem.stack < TECodebreaker.MaxCellCapacity) + { + int spaceLeft = TECodebreaker.MaxCellCapacity - temporaryItem.stack; + + // If the player has more cells than there is space left, insert as many as possible. Otherwise insert all the cells. + int cellsToInsert = Math.Min(playerHandItem.stack, spaceLeft); + cellStackDiff = (short)cellsToInsert; + playerHandItem.stack -= cellsToInsert; + if (playerHandItem.stack == 0) + playerHandItem.TurnToAir(); + AwaitingDecryptionTextClose = false; + } + + // If the player is holding nothing, then pick up all the power cells (if any exist), up to the max-stack limit. + else if (playerHandItem.IsAir && temporaryItem.stack > 0) + { + cellStackDiff = (short)-temporaryItem.stack; + if (cellStackDiff < -temporaryItem.maxStack) + cellStackDiff = (short)-temporaryItem.maxStack; + + playerHandItem.SetDefaults(temporaryItem.type); + playerHandItem.stack = -cellStackDiff; + temporaryItem.TurnToAir(); + AwaitingDecryptionTextClose = false; + } + } + + if (cellStackDiff != 0) + { + if (shouldPlaySound) + Main.PlaySound(SoundID.Grab); + AwaitingDecryptionTextClose = false; + codebreakerTileEntity.InputtedCellCount += cellStackDiff; + codebreakerTileEntity.SyncContainedStuff(); + } + } + + // Force the hover item to be drawn. + // Since HoverItem is active, we don't need to input anything into this method. + if (temporaryItem.stack > 0) + Main.instance.MouseTextHackZoom(string.Empty); + } + + public static void HandleSchematicSlotInteractions(TECodebreaker codebreakerTileEntity, Vector2 schematicIconCenter, Vector2 area) + { + Rectangle clickArea = Utils.CenteredRectangle(schematicIconCenter, area); + + // If the mouse is not in the specific area don't do anything else. + if (!MouseScreenArea.Intersects(clickArea)) + return; + + ref Item playerHandItem = ref Main.mouseItem; + + // Handle mouse click interactions. + if (Main.mouseLeft && Main.mouseLeftRelease) + { + // If the player's hand item is empty and the codebreaker has a schematic, grab it. + // This doesn't work if the Codebreaker is busy decrypting the schematic in question. + if (playerHandItem.IsAir && CalamityLists.EncryptedSchematicIDRelationship.ContainsKey(codebreakerTileEntity.HeldSchematicID) && codebreakerTileEntity.DecryptionCountdown <= 0) + { + playerHandItem.SetDefaults(CalamityLists.EncryptedSchematicIDRelationship[codebreakerTileEntity.HeldSchematicID]); + codebreakerTileEntity.HeldSchematicID = 0; + codebreakerTileEntity.DecryptionCountdown = 0; + codebreakerTileEntity.SyncContainedStuff(); + Main.PlaySound(SoundID.Grab); + + AwaitingDecryptionTextClose = false; + } + + // Otherwise, if the player has an encrypted schematic and the Codebreaker doesn't, insert it into the machine. + else if (CalamityLists.EncryptedSchematicIDRelationship.ContainsValue(playerHandItem.type)) + { + codebreakerTileEntity.HeldSchematicID = CalamityLists.EncryptedSchematicIDRelationship.First(i => i.Value == Main.mouseItem.type).Key; + playerHandItem.TurnToAir(); + codebreakerTileEntity.SyncContainedStuff(); + Main.PlaySound(SoundID.Grab); + + AwaitingDecryptionTextClose = false; + } + } + } + + public static void DisplayCostText(Vector2 drawPosition, int totalCellsCost) + { + // Display the cost text. + string text = "Cost: "; + drawPosition.X -= GeneralScale * 30f; + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, drawPosition.X, drawPosition.Y + GeneralScale * 20f, Color.White * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, GeneralScale); + + // And draw the cells to the right of the text. + Texture2D cellTexture = ModContent.GetTexture("CalamityMod/Items/DraedonMisc/PowerCell"); + Vector2 offsetDrawPosition = new Vector2(drawPosition.X + ChatManager.GetStringSize(Main.fontMouseText, text, Vector2.One, -1f).X + GeneralScale * 15f, drawPosition.Y + GeneralScale * 30f); + Main.spriteBatch.Draw(cellTexture, offsetDrawPosition, null, Color.White, 0f, cellTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); + + // Display the cell quantity numerically below the drawn cells. + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontItemStack, totalCellsCost.ToString(), offsetDrawPosition.X - 11f, offsetDrawPosition.Y, Color.White, Color.Black, new Vector2(0.3f), GeneralScale * 0.75f); + } + + public static void DrawCostVerificationButton(TECodebreaker codebreakerTileEntity, Vector2 drawPosition) + { + Texture2D confirmationTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DecryptIcon"); + Rectangle clickArea = Utils.CenteredRectangle(drawPosition, confirmationTexture.Size() * VerificationButtonScale); + + // Check if the mouse is hovering over the cost button area. + if (MouseScreenArea.Intersects(clickArea)) + { + // If so, cause the button to inflate a little bit. + VerificationButtonScale = MathHelper.Clamp(VerificationButtonScale + 0.035f, 1f, 1.35f); + + // If a click is done, begin the decryption process. + // This will "lock" various things and make the Codebreaker unbreakable, to prevent complications with lost items. + // Also play a cool sound. + if (Main.mouseLeft && Main.mouseLeftRelease) + { + Main.PlaySound(SoundID.Zombie, Main.LocalPlayer.Center, 67); + AwaitingDecryptionTextClose = true; + codebreakerTileEntity.InitialCellCountBeforeDecrypting = codebreakerTileEntity.InputtedCellCount; + codebreakerTileEntity.DecryptionCountdown = codebreakerTileEntity.DecryptionTotalTime; + codebreakerTileEntity.SyncContainedStuff(); + codebreakerTileEntity.SyncDecryptCountdown(); + } + } + + // Otherwise, if not hovering, cause the button to deflate back to its normal size. + else + VerificationButtonScale = MathHelper.Clamp(VerificationButtonScale - 0.05f, 1f, 1.35f); + + // Draw the confirmation icon. + Main.spriteBatch.Draw(confirmationTexture, drawPosition, null, Color.White, 0f, confirmationTexture.Size() * 0.5f, VerificationButtonScale * GeneralScale, SpriteEffects.None, 0f); + } + + public static void DisplayDecryptCancelButton(TECodebreaker codebreakerTileEntity, Vector2 drawPosition) + { + bool clickingMouse = Main.mouseLeft && Main.mouseLeftRelease; + Texture2D cancelTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DecryptCancelIcon"); + Rectangle clickArea = Utils.CenteredRectangle(drawPosition, cancelTexture.Size() * CancelButtonScale * 1.2f); + + // Check if the mouse is hovering over the decrypt button area. + if (MouseScreenArea.Intersects(clickArea)) + { + // If so, cause the button to inflate a little bit. + CancelButtonScale = MathHelper.Clamp(CancelButtonScale + 0.035f, 0.9f, 1.2f); + + // If a click is done, cancel the decryption process. + // This will cause already consumed cells to be lost. + if (clickingMouse) + { + if (AwaitingCloseConfirmation) + { + Main.PlaySound(SoundID.Item94, Main.LocalPlayer.Center); + + AwaitingDecryptionTextClose = false; + codebreakerTileEntity.InitialCellCountBeforeDecrypting = 0; + codebreakerTileEntity.DecryptionCountdown = 0; + codebreakerTileEntity.SyncContainedStuff(); + codebreakerTileEntity.SyncDecryptCountdown(); + AwaitingCloseConfirmation = false; + } + else + AwaitingCloseConfirmation = true; + } + } + + // Otherwise, if not hovering, cause the button to deflate back to its normal size. + else + { + CancelButtonScale = MathHelper.Clamp(CancelButtonScale - 0.05f, 0.9f, 1.2f); + if (clickingMouse) + AwaitingCloseConfirmation = false; + } + + // Draw the cancel icon. + Main.spriteBatch.Draw(cancelTexture, drawPosition, null, Color.White, 0f, cancelTexture.Size() * 0.5f, CancelButtonScale * GeneralScale, SpriteEffects.None, 0f); + } + + public static void DrawDecryptCancelConfirmationText(Vector2 drawPosition) + { + Texture2D textPanelTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen"); + Vector2 scale = new Vector2(1f, 0.3f) * GeneralScale; + Main.spriteBatch.Draw(textPanelTexture, drawPosition, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, scale, SpriteEffects.None, 0); + + string confirmationText = "Are you sure?"; + Vector2 confirmationTextPosition = drawPosition - Main.fontMouseText.MeasureString(confirmationText) * GeneralScale * 0.5f + Vector2.UnitY * GeneralScale * 4f; + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, confirmationText, confirmationTextPosition, Color.Red, 0f, Vector2.Zero, Vector2.One * GeneralScale); + } + + public static void HandleDecryptionStuff(TECodebreaker codebreakerTileEntity, Texture2D backgroundTexture, Vector2 backgroundTopLeft, Vector2 barCenter) + { + Texture2D textPanelTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonDecrypterScreen"); + Vector2 textPanelCenter = backgroundTopLeft + Vector2.UnitX * backgroundTexture.Width + textPanelTexture.Size() * new Vector2(-0.5f, 0.5f); + Main.spriteBatch.Draw(textPanelTexture, textPanelCenter, null, Color.White, 0f, textPanelTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0f); + + // Generate gibberish and use slowly insert the real text. + // When decryption is done the gibberish will go away and only the underlying text will remain. + int textPadding = 6; + string trueMessage = codebreakerTileEntity.UnderlyingSchematicText; + StringBuilder text = new StringBuilder(codebreakerTileEntity.DecryptionCountdown == 0 ? trueMessage : CalamityUtils.GenerateRandomAlphanumericString(500)); + + // Messing with whitespace characters so can cause the word-wrap to "jump" around. + // As a result, changes to whitespace characters in the true text do not stay. + for (int i = 0; i < trueMessage.Length; i++) + { + if (char.IsWhiteSpace(trueMessage[i])) + text[i] = trueMessage[i]; + } + + // Insert the necessary amount of true text. + for (int i = 0; i < (int)(trueMessage.Length * codebreakerTileEntity.DecryptionCompletion); i++) + text[i] = trueMessage[i]; + + // Define the initial text draw position. + Vector2 currentTextDrawPosition = backgroundTopLeft + new Vector2(backgroundTexture.Width - textPanelTexture.Width + textPadding, 6f); + + // Draw the lines of text. A maximum of 10 may be drawn and the vertical offset per line is 16 pixels. + foreach (string line in Utils.WordwrapString(text.ToString(), Main.fontMouseText, (int)(textPanelTexture.Width * 1.5 - textPadding * 2), 10, out _)) + { + // If a line is null or empty for some reason, don't attempt to draw it or move to the next line position. + if (string.IsNullOrEmpty(line)) + continue; + + ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontMouseText, line, currentTextDrawPosition, Color.Cyan, 0f, Vector2.Zero, new Vector2(0.6f) * GeneralScale); + currentTextDrawPosition.Y += 16; + } + + // Handle special drawing when decryption is ongoing. + // If it isn't, return; the below logic is unnecessary. + if (codebreakerTileEntity.DecryptionCountdown <= 0) + return; + + // Draw a small bar at the bottom to indicate how much work is left. + Texture2D borderTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CodebreakerDecyptionBar"); + Texture2D barTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CodebreakerDecyptionBarCharge"); + Main.spriteBatch.Draw(borderTexture, barCenter, null, Color.White, 0f, borderTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0); + Rectangle barRectangle = new Rectangle(0, 0, (int)(barTexture.Width * codebreakerTileEntity.DecryptionCompletion), barTexture.Width); + Main.spriteBatch.Draw(barTexture, barCenter, barRectangle, Color.White, 0f, barTexture.Size() * 0.5f, GeneralScale, SpriteEffects.None, 0); + + // Display a completion percentage below the bar as a more precise indicator. + string completionText = $"{codebreakerTileEntity.DecryptionCompletion * 100f:n2}%"; + Vector2 textDrawPosition = barCenter + new Vector2(-Main.fontMouseText.MeasureString(completionText).X * 0.5f, 10f) * GeneralScale; + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, completionText, textDrawPosition.X, textDrawPosition.Y, Color.Cyan * 1.2f, Color.Black, Vector2.Zero, GeneralScale); + } + + public static void HandleDraedonSummonButton(TECodebreaker codebreakerTileEntity, Vector2 drawPosition) + { + Texture2D contactButton = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/ContactIcon_THanos"); + + Rectangle clickArea = Utils.CenteredRectangle(drawPosition, contactButton.Size() * VerificationButtonScale); + + // Check if the mouse is hovering over the contact button area. + if (MouseScreenArea.Intersects(clickArea)) + { + // If so, cause the button to inflate a little bit. + ContactButtonScale = MathHelper.Clamp(ContactButtonScale + 0.035f, 1f, 1.35f); + + // If a click is done, do a check. + // Prepare the summoning process by defining the countdown and current summon position. The mech will be summoned by the Draedon NPC. + // Also play a cool sound. + if (Main.mouseLeft && Main.mouseLeftRelease) + { + Main.PlaySound(SoundID.Zombie, Main.LocalPlayer.Center, 67); + CalamityWorld.DraedonSummonCountdown = CalamityWorld.DraedonSummonCountdownMax; + CalamityWorld.DraedonSummonPosition = codebreakerTileEntity.Center + new Vector2(-8f, -100f); + + CalamityNetcode.SyncWorld(); + } + } + + // Otherwise, if not hovering, cause the button to deflate back to its normal size. + else + ContactButtonScale = MathHelper.Clamp(ContactButtonScale - 0.05f, 1f, 1.35f); + + // Draw the contact button. + Main.spriteBatch.Draw(contactButton, drawPosition, null, Color.White, 0f, contactButton.Size() * 0.5f, ContactButtonScale * GeneralScale, SpriteEffects.None, 0f); + + // And display a text indicator that describes the function of the button. + // The color of the text cycles through the exo mech crystal palette. + string contactText = "Contact"; + Color contactTextColor = CalamityUtils.MulticolorLerp((float)Math.Cos(Main.GlobalTime * 0.7f) * 0.5f + 0.5f, CalamityUtils.ExoPalette); + + // Center the draw position. + drawPosition.X -= Main.fontMouseText.MeasureString(contactText).X * GeneralScale * 0.5f; + drawPosition.Y += GeneralScale * 20f; + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, contactText, drawPosition.X, drawPosition.Y, contactTextColor, Color.Black, Vector2.Zero, GeneralScale); + } + + public static void DisplayNotStrongEnoughErrorText(Vector2 drawPosition) + { + string text = "Encryption unsolveable: Upgrades required."; + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, drawPosition.X, drawPosition.Y, Color.IndianRed * (Main.mouseTextColor / 255f), Color.Black, Vector2.Zero, GeneralScale); + } + } +} diff --git a/UI/ExoMechSelectionUI.cs b/UI/ExoMechSelectionUI.cs new file mode 100644 index 0000000000..13963df5a5 --- /dev/null +++ b/UI/ExoMechSelectionUI.cs @@ -0,0 +1,116 @@ +using CalamityMod.Items.DraedonMisc; +using CalamityMod.NPCs.ExoMechs; +using CalamityMod.TileEntities; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Linq; +using System.Text; +using Terraria; +using Terraria.DataStructures; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.UI.Chat; + +namespace CalamityMod.UI +{ + public static class ExoMechSelectionUI + { + public static float DestroyerIconScale = 1f; + public static float PrimeIconScale = 1f; + public static float TwinsIconScale = 1f; + public static readonly Color HoverTextColor = Draedon.TextColor; + public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); + public static void Draw(SpriteBatch spriteBatch) + { + Vector2 drawAreaVerticalOffset = Vector2.UnitY * 105f; + Vector2 baseDrawPosition = Main.LocalPlayer.Top + drawAreaVerticalOffset - Main.screenPosition; + Vector2 destroyerIconDrawOffset = new Vector2(-78f, -124f); + Vector2 primeIconDrawOffset = new Vector2(0f, -140f); + Vector2 twinsIconDrawOffset = new Vector2(78f, -124f); + + HandleInteractionWithButton(baseDrawPosition + destroyerIconDrawOffset, ExoMech.Destroyer); + HandleInteractionWithButton(baseDrawPosition + primeIconDrawOffset, ExoMech.Prime); + HandleInteractionWithButton(baseDrawPosition + twinsIconDrawOffset, ExoMech.Twins); + } + + public static bool HandleInteractionWithButton(Vector2 drawPosition, ExoMech exoMech) + { + float iconScale; + string description; + Texture2D iconMechTexture; + + switch (exoMech) + { + case ExoMech.Destroyer: + iconScale = DestroyerIconScale; + iconMechTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/HeadIcon_THanos"); + description = "Thanatos, a serpentine terror with impervious armor and innumerable laser turrets."; + break; + case ExoMech.Prime: + iconScale = PrimeIconScale; + iconMechTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/HeadIcon_Ares"); + description = "Ares, a heavyweight, diabolical monstrosity with four Exo superweapons."; + break; + default: + case ExoMech.Twins: + iconScale = TwinsIconScale; + iconMechTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/HeadIcon_ArtemisApollo"); + description = "Artemis and Apollo, a pair of extremely agile destroyers with pulse cannons."; + break; + } + + // Check for mouse collision/clicks. + Rectangle clickArea = Utils.CenteredRectangle(drawPosition, iconMechTexture.Size() * iconScale * 0.9f); + + // Check if the mouse is hovering over the contact button area. + bool hoveringOverIcon = MouseScreenArea.Intersects(clickArea); + if (hoveringOverIcon) + { + // If so, cause the button to inflate a little bit. + iconScale = MathHelper.Clamp(iconScale + 0.035f, 1f, 1.35f); + + // Make the selection known if a click is done. + if (Main.mouseLeft && Main.mouseLeftRelease) + { + CalamityWorld.DraedonMechToSummon = exoMech; + CalamityNetcode.SyncWorld(); + } + Main.blockMouse = Main.LocalPlayer.mouseInterface = true; + } + + // Otherwise, if not hovering, cause the button to deflate back to its normal size. + else + iconScale = MathHelper.Clamp(iconScale - 0.05f, 1f, 1.2f); + + // Draw the icon with the new scale. + Main.spriteBatch.Draw(iconMechTexture, drawPosition, null, Color.White, 0f, iconMechTexture.Size() * 0.5f, iconScale, SpriteEffects.None, 0f); + + // Draw the descrption if hovering over the icon. + if (hoveringOverIcon) + { + drawPosition.X -= Main.fontMouseText.MeasureString(description).X * 0.5f; + drawPosition.Y += 36f; + Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, description, drawPosition.X, drawPosition.Y, HoverTextColor, Color.Black, Vector2.Zero, 1f); + } + + // And update to reflect the new scale. + switch (exoMech) + { + case ExoMech.Destroyer: + DestroyerIconScale = iconScale; + break; + case ExoMech.Prime: + PrimeIconScale = iconScale; + break; + default: + case ExoMech.Twins: + TwinsIconScale = iconScale; + break; + } + return false; + } + } +} diff --git a/Utilities/CollisionUtils.cs b/Utilities/CollisionUtils.cs index 13537d71e1..7170919ac6 100644 --- a/Utilities/CollisionUtils.cs +++ b/Utilities/CollisionUtils.cs @@ -48,5 +48,34 @@ namespace CalamityMod return distanceToClosestPoint <= radius; } + + /// Determines the distance required before a ray in a given direction from a given starting position hits solid tiles. Gives up after a certain quantity of tiles, or when a world border is reached. + /// + /// The point to check from. + /// The direction in which tiles are checked. Will always be a unit vector. + public static float? DistanceToTileCollisionHit(Vector2 startingPoint, Vector2 checkDirection, int giveUpLimit = 500) + { + // Ensure that the check direction is normalized. + checkDirection = checkDirection.SafeNormalize(Vector2.Zero); + + for (int i = 1; i < giveUpLimit; i++) + { + Point checkPosition = startingPoint.ToTileCoordinates(); + checkPosition.X += (int)(checkDirection.X * i); + checkPosition.Y += (int)(checkDirection.Y * i); + + // Don't bother checking any further if the check has left the world. + if (!WorldGen.InWorld(checkPosition.X, checkPosition.Y, 2)) + return null; + + // If a solid tile is hit, return the distance. + // Since Terraria's tile coordinate system is discrete and does not care for more advanced concepts, + // the amount of tiles searched such far is a sufficient answer. + Tile tile = ParanoidTileRetrieval(checkPosition.X, checkPosition.Y); + if (WorldGen.SolidTile(tile) || (checkDirection.Y > 0f && tile.active() && Main.tileSolidTop[tile.type])) + return i; + } + return null; + } } } diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index a2c5d1d315..443b38586d 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -14,6 +14,18 @@ namespace CalamityMod { public static partial class CalamityUtils { + public static readonly Color[] ExoPalette = new Color[] + { + new Color(250, 255, 112), + new Color(211, 235, 108), + new Color(166, 240, 105), + new Color(105, 240, 220), + new Color(64, 130, 145), + new Color(145, 96, 145), + new Color(242, 112, 73), + new Color(199, 62, 62), + }; + #region Projectile Afterimages /// /// Draws a projectile as a series of afterimages. The first of these afterimages is centered on the center of the projectile's hitbox.
diff --git a/Utilities/NPCStats.cs b/Utilities/NPCStats.cs index c438832c01..b1710ab45f 100644 --- a/Utilities/NPCStats.cs +++ b/Utilities/NPCStats.cs @@ -808,7 +808,7 @@ namespace CalamityMod { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 712, 732, 1068 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 350, 528, 556, 572, 834 } }, - // { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 600, 632, 648, 948 } }, + { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 400, 600, 632, 648, 948 } }, // { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 450, 676, 712, 732, 1068 } }, { new Tuple(ModContent.NPCType(), ModContent.ProjectileType()), new int[] { 500, 752, 788, 808, 1182 } }, diff --git a/Utilities/StringUtils.cs b/Utilities/StringUtils.cs new file mode 100644 index 0000000000..1c08f38964 --- /dev/null +++ b/Utilities/StringUtils.cs @@ -0,0 +1,11 @@ +using System.Linq; +using Terraria; + +namespace CalamityMod +{ + public static partial class CalamityUtils + { + internal static readonly string AlphanumericCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + public static string GenerateRandomAlphanumericString(int length) => new string(Enumerable.Repeat(AlphanumericCharacters, length).Select(s => s[Main.rand.Next(s.Length)]).ToArray()); + } +} diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index 117c270abb..862d2bdf8b 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.CustomRecipes; using CalamityMod.DataStructures; using CalamityMod.Events; using CalamityMod.NPCs; @@ -11,6 +12,11 @@ using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs; +using CalamityMod.NPCs.ExoMechs.Apollo; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.NPCs.ExoMechs.Artemis; +using CalamityMod.NPCs.ExoMechs.Thanatos; using CalamityMod.NPCs.HiveMind; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.OldDuke; @@ -52,6 +58,7 @@ namespace CalamityMod.World public static int ArmoredDiggerSpawnCooldown = 0; public static int MoneyStolenByBandit = 0; public static int Reforges; + public static bool IsWorldAfterDraedonUpdate = false; // Boss Rush public static int bossRushHostileProjKillCounter = 0; @@ -155,6 +162,41 @@ namespace CalamityMod.World public static bool witchDoctorName = false; public static bool wizardName = false; + // Draedon Summoning stuff. + public static int DraedonSummonCountdown = 0; + public static ExoMech DraedonMechToSummon; + public static Vector2 DraedonSummonPosition = Vector2.Zero; + public static bool AbleToSummonDraedon + { + get + { + if (DraedonSummonCountdown > 0) + return false; + + if (NPC.AnyNPCs(ModContent.NPCType())) + return false; + + if (NPC.AnyNPCs(ModContent.NPCType())) + return false; + + if (NPC.AnyNPCs(ModContent.NPCType())) + return false; + + if (NPC.AnyNPCs(ModContent.NPCType()) || NPC.AnyNPCs(ModContent.NPCType())) + return false; + + return true; + } + } + public const int DraedonSummonCountdownMax = 260; + + // Draedon Lab Locations. + public static Vector2 SunkenSeaLabCenter; + public static Vector2 PlanetoidLabCenter; + public static Vector2 JungleLabCenter; + public static Vector2 HellLabCenter; + public static Vector2 IceLabCenter; + #region Downed Bools public static bool downedDesertScourge = false; public static bool downedCrabulon = false; @@ -471,24 +513,23 @@ namespace CalamityMod.World downed.Add("encounteredOldDuke"); if (HasGeneratedLuminitePlanetoids) downed.Add("HasGeneratedLuminitePlanetoids"); + downed.AddWithCondition("IsWorldAfterDraedonUpdate", IsWorldAfterDraedonUpdate); + + RecipeUnlockHandler.Save(downed); return new TagCompound { - { - "downed", downed - }, - { - "abyssChasmBottom", abyssChasmBottom - }, - { - "acidRainPoints", acidRainPoints - }, - { - "Reforges", Reforges - }, - { - "MoneyStolenByBandit", MoneyStolenByBandit - } + ["downed"] = downed, + ["abyssChasmBottom"] = abyssChasmBottom, + ["acidRainPoints"] = acidRainPoints, + ["Reforges"] = Reforges, + ["MoneyStolenByBandit"] = MoneyStolenByBandit, + + ["SunkenSeaLabCenter"] = SunkenSeaLabCenter, + ["PlanetoidLabCenter"] = PlanetoidLabCenter, + ["JungleLabCenter"] = JungleLabCenter, + ["HellLabCenter"] = HellLabCenter, + ["IceLabCenter"] = IceLabCenter, }; } #endregion @@ -578,11 +619,20 @@ namespace CalamityMod.World forcedDownpourWithTear = downed.Contains("forcedTear"); encounteredOldDuke = downed.Contains("encounteredOldDuke"); HasGeneratedLuminitePlanetoids = downed.Contains("HasGeneratedLuminitePlanetoids"); + IsWorldAfterDraedonUpdate = downed.Contains("IsWorldAfterDraedonUpdate"); + + RecipeUnlockHandler.Load(downed); abyssChasmBottom = tag.GetInt("abyssChasmBottom"); acidRainPoints = tag.GetInt("acidRainPoints"); Reforges = tag.GetInt("Reforges"); MoneyStolenByBandit = tag.GetInt("MoneyStolenByBandit"); + + SunkenSeaLabCenter = tag.Get("SunkenSeaLabCenter"); + PlanetoidLabCenter = tag.Get("PlanetoidLabCenter"); + JungleLabCenter = tag.Get("JungleLabCenter"); + HellLabCenter = tag.Get("HellLabCenter"); + IceLabCenter = tag.Get("IceLabCenter"); } #endregion @@ -832,10 +882,16 @@ namespace CalamityMod.World writer.Write(flags9); writer.Write(flags10); writer.Write(flags11); + + RecipeUnlockHandler.SendData(writer); + writer.Write(abyssChasmBottom); writer.Write(acidRainPoints); writer.Write(Reforges); writer.Write(MoneyStolenByBandit); + writer.Write(DraedonSummonCountdown); + writer.Write((int)DraedonMechToSummon); + writer.WriteVector2(DraedonSummonPosition); } #endregion @@ -943,6 +999,8 @@ namespace CalamityMod.World _ = flags10[6]; _ = flags10[7]; + RecipeUnlockHandler.ReceiveData(reader); + BitsByte flags11 = reader.ReadByte(); malice = flags11[0]; HasGeneratedLuminitePlanetoids = flags11[1]; @@ -953,6 +1011,9 @@ namespace CalamityMod.World acidRainPoints = reader.ReadInt32(); Reforges = reader.ReadInt32(); MoneyStolenByBandit = reader.ReadInt32(); + DraedonSummonCountdown = reader.ReadInt32(); + DraedonMechToSummon = (ExoMech)reader.ReadInt32(); + DraedonSummonPosition = reader.ReadVector2(); } #endregion @@ -990,6 +1051,10 @@ namespace CalamityMod.World { numAbyssIslands = 0; roxShrinePlaced = false; + + // This will only be applied at world-gen time to new worlds. + // Old worlds will never receive this marker naturally. + IsWorldAfterDraedonUpdate = true; } #endregion diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index f10e8a59d7..2f166f916f 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -227,7 +227,7 @@ namespace CalamityMod.World { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(2, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(2, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) { @@ -273,6 +273,7 @@ namespace CalamityMod.World { bool hasPlacedMurasama = false; PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref hasPlacedMurasama, new Action(FillHellLaboratoryChest)); + CalamityWorld.HellLabCenter = placementPoint.ToWorldCoordinates() + new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)) * 8f; break; } } @@ -298,7 +299,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) { @@ -345,6 +346,7 @@ namespace CalamityMod.World bool hasPlacedLogAndSchematic = false; PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(FillSunkenSeaLaboratoryChest)); + CalamityWorld.SunkenSeaLabCenter = placementPoint.ToWorldCoordinates() + new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)) * 8f; } #endregion @@ -365,7 +367,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } // If it's a frozen chest. if (type == TileID.Containers) @@ -424,6 +426,7 @@ namespace CalamityMod.World { bool hasPlacedLogAndSchematic = false; PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(FillIceLaboratoryChest)); + CalamityWorld.IceLabCenter = placementPoint.ToWorldCoordinates() + new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)) * 8f; break; } } @@ -448,7 +451,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) { @@ -503,6 +506,7 @@ namespace CalamityMod.World { bool hasPlacedLogAndSchematic = false; PlaceSchematic(mapKey, new Point(placementPoint.X, placementPoint.Y), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(FillPlagueLaboratoryChest)); + CalamityWorld.JungleLabCenter = placementPoint.ToWorldCoordinates() + new Vector2(TileMaps[mapKey].GetLength(0), TileMaps[mapKey].GetLength(1)) * 8f; break; } } @@ -541,7 +545,7 @@ namespace CalamityMod.World if (!hasPlacedLogAndSchematic) { contents.Insert(0, new ChestItem(ModContent.ItemType(), 1)); - contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); + contents.Insert(1, new ChestItem(ModContent.ItemType(), 1)); } for (int i = 0; i < contents.Count; i++) { diff --git a/World/Planets/MainPlanet.cs b/World/Planets/MainPlanet.cs index f2ec4f0f5e..2b82e2d855 100644 --- a/World/Planets/MainPlanet.cs +++ b/World/Planets/MainPlanet.cs @@ -109,6 +109,7 @@ namespace CalamityMod.World.Planets // TODO -- This should probably use PlacementAnchor.Center and just provide the center of the planetoid... bool hasPlacedLogAndSchematic = false; SchematicManager.PlaceSchematic("Planetoid Laboratory", new Point(origin.X - 33, origin.Y - 17), SchematicAnchor.TopLeft, ref hasPlacedLogAndSchematic, new Action(DraedonStructures.FillPlanetoidLaboratoryChest)); + CalamityWorld.PlanetoidLabCenter = origin.ToWorldCoordinates(); //PLACE BREAKABLE GRASS AND TREES WorldUtils.Gen(origin, new ModShapes.OuterOutline(mainShape, true, true), Actions.Chain(new GenAction[] diff --git a/World/WorldUpdateMiscEffects.cs b/World/WorldUpdateMiscEffects.cs index 12ad63b706..e20d4186d8 100644 --- a/World/WorldUpdateMiscEffects.cs +++ b/World/WorldUpdateMiscEffects.cs @@ -11,12 +11,14 @@ using CalamityMod.NPCs.Crabulon; using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.DesertScourge; using CalamityMod.NPCs.DevourerofGods; +using CalamityMod.NPCs.ExoMechs; 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.Projectiles.Boss; using CalamityMod.Tiles; using CalamityMod.Tiles.Abyss; using CalamityMod.Tiles.SunkenSea; @@ -36,6 +38,19 @@ namespace CalamityMod.World { public static void PerformWorldUpdates() { + // Reset the exo mech to summon if Draedon is absent. + if (Main.netMode != NetmodeID.MultiplayerClient && DraedonMechToSummon != ExoMech.None && CalamityGlobalNPC.draedon == -1) + { + DraedonMechToSummon = ExoMech.None; + CalamityNetcode.SyncWorld(); + } + + if (DraedonSummonCountdown > 0) + { + DraedonSummonCountdown--; + HandleDraedonSummoning(); + } + // Sunken Sea Location...duh SunkenSeaLocation = new Rectangle(WorldGen.UndergroundDesertLocation.Left, WorldGen.UndergroundDesertLocation.Bottom, WorldGen.UndergroundDesertLocation.Width, WorldGen.UndergroundDesertLocation.Height / 2); @@ -89,6 +104,16 @@ namespace CalamityMod.World if (!downedDesertScourge && Main.netMode != NetmodeID.MultiplayerClient && !Main.hardMode) CalamityUtils.StopSandstorm(); + // Attempt to summon lab critters manually since they refuse to exist when using vanilla's spawn methods. + // This needs to check all players since the method only runs server-side. + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Main.player[i].active || Main.player[i].dead) + continue; + + CalamityGlobalNPC.AttemptToSpawnLabCritters(Main.player[i]); + } + // Make the cultist countdown happen much more quickly. if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -101,6 +126,19 @@ namespace CalamityMod.World } } + #region Handle Draedon Summoning + + public static void HandleDraedonSummoning() + { + // Fire a giant laser into the sky. + if (Main.netMode != NetmodeID.MultiplayerClient && DraedonSummonCountdown == DraedonSummonCountdownMax - 45) + Projectile.NewProjectile(DraedonSummonPosition + Vector2.UnitY * 80f, Vector2.Zero, ModContent.ProjectileType(), 70, 0f); + + if (DraedonSummonCountdown == 0) + NPC.NewNPC((int)DraedonSummonPosition.X, (int)DraedonSummonPosition.Y, ModContent.NPCType(), 0, 0f, (int)DraedonMechToSummon); + } + #endregion Handle Draedon Summoning + #region Handle Tile Growing public static void HandleTileGrowth()