diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 8a5f761583..a71279bb79 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -908,7 +908,6 @@ namespace CalamityMod.CalPlayer public bool brimseeker = false; public bool necrosteocytesDudes = false; public bool gammaHead = false; - public List GammaCanisters = new List(); public bool rustyDrone = false; public bool tundraFlameBlossom = false; public bool starSwallowerPetFroge = false; @@ -4414,7 +4413,6 @@ namespace CalamityMod.CalPlayer } #endregion - // Currently not used due to god slayer and silva armor changes #region Use Time Mult public override float UseTimeMultiplier(Item item) { @@ -5159,7 +5157,7 @@ namespace CalamityMod.CalPlayer } if (item.type == ItemID.TitaniumSword) { - int knockbackAdd = (int)(damage * 0.25 * (1f - target.knockBackResist)); + int knockbackAdd = (int)(damage * 0.15 * (1f - target.knockBackResist)); damage += knockbackAdd; } if (item.type == ItemID.AntlionClaw || item.type == ItemID.BoneSword || item.type == ItemID.BreakerBlade) @@ -6935,7 +6933,7 @@ namespace CalamityMod.CalPlayer num79 *= num80; float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f; float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f; - int p = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * 0.15), knockBack * 0.5f, player.whoAmI); + int p = Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, (int)(damage * 0.065), knockBack * 0.5f, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().forceRogue = true; //in case melee/rogue variants bug out if (item.type == ModContent.ItemType()) @@ -7258,8 +7256,15 @@ namespace CalamityMod.CalPlayer if (CalamityWorld.revenge && CalamityConfig.Instance.Rippers && shatteredCommunity && rageGainCooldown == 0) { float HPRatio = (float)damage / player.statLifeMax2; + float rageConversionRatio = 0.8f; + // Damage to rage conversion is half as effective while Rage Mode is active. - float rageConversionRatio = rageModeActive ? 0.4f : 0.8f; + if (rageModeActive) + rageConversionRatio *= 0.5f; + // If Rage is over 100%, damage to rage conversion scales down asymptotically based on how full Rage is. + if (rage >= rageMax) + rageConversionRatio *= 3f / (3f + rage / rageMax); + rage += rageMax * HPRatio * rageConversionRatio; rageGainCooldown = DefaultRageGainCooldown; // Rage capping is handled in MiscEffects diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index be2a23b1ff..7cc03843e5 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -53,6 +53,14 @@ namespace CalamityMod.CalPlayer // No category + // Give the player some jump speed boost at base while wings or balloons are equipped + if (player.wingsLogic > 0 || player.jumpBoost) + player.jumpSpeedBoost += 1.2f; + + // Reduce balloon jump boosts because they'd be too powerful when stacked with wings + if (player.jumpBoost) + player.jumpSpeedBoost -= 0.75f; + // Decrease the counter on Fearmonger set turbo regeneration if (modPlayer.fearmongerRegenFrames > 0) modPlayer.fearmongerRegenFrames--; @@ -541,6 +549,10 @@ namespace CalamityMod.CalPlayer (modPlayer.cShard ? 50 : 0) + (modPlayer.starBeamRye ? 50 : 0); + // Shield of Cthulhu immunity frame nerf, nerfed from 10 to 6 + if (player.eocDash > 6 && player.dashDelay > 0) + player.eocDash = 6; + // Life Steal nerf // Reduces normal mode life steal recovery rate from 0.6/s to 0.5/s // Reduces expert mode life steal recovery rate from 0.5/s to 0.35/s @@ -980,7 +992,7 @@ namespace CalamityMod.CalPlayer { if (!tentaclesPresent[i]) { - int damage = (int)(500 * player.AverageDamage()); + int damage = (int)(390 * player.AverageDamage()); Vector2 vel = new Vector2(Main.rand.Next(-13, 14), Main.rand.Next(-13, 14)) * 0.25f; Projectile.NewProjectile(player.Center, vel, ModContent.ProjectileType(), damage, 8f, Main.myPlayer, Main.rand.Next(120), i); } @@ -1363,7 +1375,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.absorber) { player.moveSpeed += 0.06f; - player.jumpSpeedBoost += player.autoJump ? 0.3f : 1.2f; + player.jumpSpeedBoost += player.autoJump ? 0.15f : 0.6f; player.thorns += 0.5f; player.endurance += 0.05f; @@ -2536,9 +2548,6 @@ namespace CalamityMod.CalPlayer player.lavaMax += 240; } - if (modPlayer.eQuiver) - player.magicQuiver = true; - if (modPlayer.bloodPactBoost) { player.allDamage += 0.05f; @@ -2791,7 +2800,7 @@ namespace CalamityMod.CalPlayer if (modPlayer.bounding) { - player.jumpSpeedBoost += 0.5f; + player.jumpSpeedBoost += 0.25f; Player.jumpHeight += 10; player.extraFall += 25; } @@ -4004,7 +4013,7 @@ namespace CalamityMod.CalPlayer modPlayer.wingFlightTimeStat = player.wingTimeMax / 60f; float trueJumpSpeedBoost = player.jumpSpeedBoost + (player.wereWolf ? 0.2f : 0f) + - (player.jumpBoost ? 1.5f : 0f); + (player.jumpBoost ? 0.75f : 0f); modPlayer.jumpSpeedStat = trueJumpSpeedBoost * 20f; modPlayer.rageDamageStat = (int)(100D * modPlayer.RageDamageBoost); modPlayer.adrenalineDamageStat = (int)(100D * modPlayer.GetAdrenalineDamage()); diff --git a/CalPlayer/CalamityPlayerNetcode.cs b/CalPlayer/CalamityPlayerNetcode.cs index 99942f33bc..add54032ae 100644 --- a/CalPlayer/CalamityPlayerNetcode.cs +++ b/CalPlayer/CalamityPlayerNetcode.cs @@ -250,14 +250,14 @@ namespace CalamityMod.CalPlayer internal void HandleRage(BinaryReader reader) { - rage = reader.ReadInt32(); + rage = reader.ReadSingle(); if (Main.netMode == NetmodeID.Server) SyncRage(true); } internal void HandleAdrenaline(BinaryReader reader) { - adrenaline = reader.ReadInt32(); + adrenaline = reader.ReadSingle(); if (Main.netMode == NetmodeID.Server) SyncAdrenaline(true); } diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index f4400b693b..dc7f1ac2b2 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -110,24 +110,6 @@ namespace CalamityMod.CalPlayer modPlayer.bloodflareMeleeHits++; } } - if (CalamityWorld.revenge && CalamityConfig.Instance.Rippers) - { - int stressGain = (int)(damage * 0.1); - int stressMaxGain = 10; - if (stressGain < 1) - { - stressGain = 1; - } - if (stressGain > stressMaxGain) - { - stressGain = stressMaxGain; - } - modPlayer.rage += stressGain; - if (modPlayer.rage >= modPlayer.rageMax) - { - modPlayer.rage = modPlayer.rageMax; - } - } } } } @@ -237,27 +219,6 @@ namespace CalamityMod.CalPlayer modPlayer.bloodflareMeleeHits++; } } - if (CalamityWorld.revenge && CalamityConfig.Instance.Rippers) - { - if (modProj.trueMelee) - { - int stressGain = (int)(proj.damage * 0.1); - int stressMaxGain = 10; - if (stressGain < 1) - { - stressGain = 1; - } - if (stressGain > stressMaxGain) - { - stressGain = stressMaxGain; - } - modPlayer.rage += stressGain; - if (modPlayer.rage >= modPlayer.rageMax) - { - modPlayer.rage = modPlayer.rageMax; - } - } - } } } #endregion diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 03a21f1c0c..2ce1e78807 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -114,6 +114,16 @@ namespace CalamityMod [Header("General Gameplay Changes")] + [Label("Early Hardmode Progression Rework")] + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + [Tooltip("Demon Altars no longer spawn ores and crimson/corruption blocks when broken.\n" + + "Wall of Flesh spawns Cobalt and Palladium ore on first kill.\n" + + "The first mech boss you fight has 20% less HP and damage and spawns Mythril and Orichalcum ore on first kill.\n" + + "The second mech boss you fight has 10% less HP and damage and spawns Adamantite and Titanium ore on first kill.\n" + + "The third mech boss spawns Hallowed Ore on first kill")] + public bool EarlyHardmodeProgressionRework { get; set; } + [Label("Lethal Lava")] [BackgroundColor(192, 54, 64, 192)] [DefaultValue(true)] diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 9343d1ec9a..43d9e7a4c4 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Effects public static Effect TentacleShader; public static Effect LightDistortionShader; public static Effect PhaseslayerRipShader; - public static Effect FabstaffRayShader; + public static Effect FadedUVMapStreakShader; public static Effect ScarletDevilShader; public static Effect BordernadoFireShader; public static Effect PrismCrystalShader; @@ -27,10 +27,10 @@ namespace CalamityMod.Effects TentacleShader = CalamityMod.Instance.GetEffect("Effects/TentacleShader"); LightDistortionShader = CalamityMod.Instance.GetEffect("Effects/DistortionShader"); PhaseslayerRipShader = CalamityMod.Instance.GetEffect("Effects/PhaseslayerRipShader"); - FabstaffRayShader = CalamityMod.Instance.GetEffect("Effects/FabstaffStreak"); ScarletDevilShader = CalamityMod.Instance.GetEffect("Effects/ScarletDevilStreak"); BordernadoFireShader = CalamityMod.Instance.GetEffect("Effects/BordernadoFire"); PrismCrystalShader = CalamityMod.Instance.GetEffect("Effects/PrismCrystalStreak"); + FadedUVMapStreakShader = CalamityMod.Instance.GetEffect("Effects/FadedUVMapStreak"); Filters.Scene["CalamityMod:Astral"] = new Filter(new AstralScreenShaderData(new Ref(AstralFogShader), "AstralPass").UseColor(0.18f, 0.08f, 0.24f), EffectPriority.VeryHigh); @@ -40,7 +40,7 @@ namespace CalamityMod.Effects GameShaders.Misc["CalamityMod:SubsumingTentacle"] = new MiscShaderData(new Ref(TentacleShader), "BurstPass"); GameShaders.Misc["CalamityMod:LightDistortion"] = new MiscShaderData(new Ref(LightDistortionShader), "DistortionPass"); GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"] = new MiscShaderData(new Ref(PhaseslayerRipShader), "TrailPass"); - GameShaders.Misc["CalamityMod:FabstaffRay"] = new MiscShaderData(new Ref(FabstaffRayShader), "TrailPass"); + GameShaders.Misc["CalamityMod:TrailStreak"] = new MiscShaderData(new Ref(FadedUVMapStreakShader), "TrailPass"); GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"] = new MiscShaderData(new Ref(ScarletDevilShader), "TrailPass"); GameShaders.Misc["CalamityMod:Bordernado"] = new MiscShaderData(new Ref(BordernadoFireShader), "TrailPass"); GameShaders.Misc["CalamityMod:PrismaticStreak"] = new MiscShaderData(new Ref(PrismCrystalShader), "TrailPass"); diff --git a/Effects/FadedUVMapStreak.fx b/Effects/FadedUVMapStreak.fx new file mode 100644 index 0000000000..497063c9da --- /dev/null +++ b/Effects/FadedUVMapStreak.fx @@ -0,0 +1,72 @@ +sampler uImage0 : register(s0); +sampler uImage1 : register(s1); +float3 uColor; +float3 uSecondaryColor; +float uOpacity; +float uSaturation; +float uRotation; +float uTime; +float4 uSourceRect; +float2 uWorldPosition; +float uDirection; +float3 uLightSource; +float2 uImageSize0; +float2 uImageSize1; +matrix uWorldViewProjection; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output = (VertexShaderOutput)0; + float4 pos = mul(input.Position, uWorldViewProjection); + output.Position = pos; + + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + + return output; +} + +// The X coordinate is the trail completion, the Y coordinate is the same as any other. +// This is simply how the primitive TextCoord is layed out in the C# code. +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + // Read the fade map as a streak. + float4 fadeMapColor = tex2D(uImage1, float2(frac(coords.x - uTime * 2.5), coords.y)); + float opacity = fadeMapColor.r; + + // Fade out at the edges of the trail to give a blur effect. + // This is very important. + float power = lerp(3, 10, coords.x); + opacity = lerp(pow(sin(coords.y * 3.141), power), opacity, coords.x); + + // Fade out at the end of the streak. + if (coords.x > 0.7) + opacity *= pow(1 - (coords.x - 0.7) / 0.3, 6); + return color * opacity * 1.5; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/FadedUVMapStreak.xnb b/Effects/FadedUVMapStreak.xnb new file mode 100644 index 0000000000..45b95d5d3f Binary files /dev/null and b/Effects/FadedUVMapStreak.xnb differ diff --git a/ExtraTextures/TelluricGlareStreak.png b/ExtraTextures/TelluricGlareStreak.png new file mode 100644 index 0000000000..7793d1e456 Binary files /dev/null and b/ExtraTextures/TelluricGlareStreak.png differ diff --git a/ILEditing/ILChanges.cs b/ILEditing/ILChanges.cs index ed6959381d..7f72437e48 100644 --- a/ILEditing/ILChanges.cs +++ b/ILEditing/ILChanges.cs @@ -36,10 +36,10 @@ namespace CalamityMod.ILEditing private static int aLabDoorOpen = -1; private static int aLabDoorClosed = -1; - /// - /// Loads all IL Editing changes in the mod. - /// - internal static void Load() + /// + /// Loads all IL Editing changes in the mod. + /// + internal static void Load() { // Wrap the vanilla town NPC spawning function in a delegate so that it can be tossed around and called at will. var updateTime = typeof(Main).GetMethod("UpdateTime_SpawnTownNPCs", BindingFlags.Static | BindingFlags.NonPublic); @@ -58,6 +58,7 @@ namespace CalamityMod.ILEditing BlockLivingTreesNearOcean(); LabDoorFixes(); AlterTownNPCSpawnRate(); + DisableDemonAltarGeneration(); } /// @@ -202,10 +203,19 @@ namespace CalamityMod.ILEditing Main.worldRate = oldWorldRate; }; } - #endregion - #region IL Editing Injected/Hooked Functions - private static void BossRushLifeBytes(On.Terraria.Main.orig_InitLifeBytes orig) + private static void DisableDemonAltarGeneration() + { + IL.Terraria.WorldGen.SmashAltar += (il) => + { + var cursor = new ILCursor(il); + cursor.Emit(OpCodes.Ret); + }; + } + #endregion + + #region IL Editing Injected/Hooked Functions + private static void BossRushLifeBytes(On.Terraria.Main.orig_InitLifeBytes orig) { orig(); foreach (int npcType in NeedsFourLifeBytes) diff --git a/Items/Accessories/AeroStone.cs b/Items/Accessories/AeroStone.cs index 2d496cff8a..a275514903 100644 --- a/Items/Accessories/AeroStone.cs +++ b/Items/Accessories/AeroStone.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Aero Stone"); Tooltip.SetDefault("One of the ancient relics\n" + - "Increases movement speed by 10%, jump speed by 20%, and all damage by 3%"); + "Increases movement speed by 10%, jump speed by 10% and all damage by 3%"); Main.RegisterItemAnimation(item.type, new DrawAnimationVertical(4, 8)); } @@ -28,7 +28,7 @@ namespace CalamityMod.Items.Accessories public override void ModifyTooltips(List list) { bool autoJump = Main.player[Main.myPlayer].autoJump; - string jumpAmt = autoJump ? "5" : "20"; + string jumpAmt = autoJump ? "2.5" : "10"; foreach (TooltipLine line2 in list) { if (line2.mod == "Terraria" && line2.Name == "Tooltip1") @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Accessories { Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0f, 0.425f, 0.425f); player.moveSpeed += 0.1f; - player.jumpSpeedBoost += player.autoJump ? 0.25f : 1f; + player.jumpSpeedBoost += player.autoJump ? 0.125f : 0.5f; player.allDamage += 0.03f; } } diff --git a/Items/Accessories/AmbrosialAmpoule.cs b/Items/Accessories/AmbrosialAmpoule.cs index 46e77f0ff2..4286e66c63 100644 --- a/Items/Accessories/AmbrosialAmpoule.cs +++ b/Items/Accessories/AmbrosialAmpoule.cs @@ -61,7 +61,7 @@ namespace CalamityMod.Items.Accessories recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); @@ -71,7 +71,7 @@ namespace CalamityMod.Items.Accessories recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 15); - recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Accessories/ElementalQuiver.cs b/Items/Accessories/ElementalQuiver.cs index 51e18ed2b2..9d28759915 100644 --- a/Items/Accessories/ElementalQuiver.cs +++ b/Items/Accessories/ElementalQuiver.cs @@ -12,10 +12,9 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Elemental Quiver"); - Tooltip.SetDefault("Ranged projectiles have a chance to split\n" + - "15% increased ranged damage, 5% increased ranged critical strike chance, and 20% reduced ammo usage\n" + + Tooltip.SetDefault("15% increased ranged damage, 5% increased ranged critical strike chance, and 20% reduced ammo usage\n" + "5 increased defense, 2 increased life regen, and 15% increased pick speed\n" + - "Greatly increases arrow speed and grants a 20% chance to not consume arrows"); + "Greatly increases arrow speed and grants a 20% chance to not consume arrows"); } public override void SetDefaults() @@ -29,14 +28,15 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { - CalamityPlayer modPlayer = player.Calamity(); - modPlayer.eQuiver = true; - modPlayer.rangedAmmoCost *= 0.8f; player.rangedDamage += 0.15f; player.rangedCrit += 5; player.lifeRegen += 2; player.statDefense += 5; player.pickSpeed -= 0.15f; + player.magicQuiver = true; + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.eQuiver = true; // Since splitting was removed, this has no effect. + modPlayer.rangedAmmoCost *= 0.8f; } public override void AddRecipes() diff --git a/Items/Accessories/GrandGelatin.cs b/Items/Accessories/GrandGelatin.cs index d212af04e7..e1f1cd258e 100644 --- a/Items/Accessories/GrandGelatin.cs +++ b/Items/Accessories/GrandGelatin.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Grand Gelatin"); Tooltip.SetDefault("10% increased movement speed\n" + - "24% increased jump speed\n" + + "12% increased jump speed\n" + "+20 max life and mana\n" + "Standing still boosts life and mana regen"); } @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories public override void ModifyTooltips(List list) { bool autoJump = Main.player[Main.myPlayer].autoJump; - string jumpAmt = autoJump ? "6" : "24"; + string jumpAmt = autoJump ? "3" : "12"; foreach (TooltipLine line2 in list) { if (line2.mod == "Terraria" && line2.Name == "Tooltip1") @@ -40,7 +40,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.moveSpeed += 0.1f; - player.jumpSpeedBoost += player.autoJump ? 0.3f : 1.2f; + player.jumpSpeedBoost += player.autoJump ? 0.15f : 0.6f; player.statLifeMax2 += 20; player.statManaMax2 += 20; if (Math.Abs(player.velocity.X) < 0.05f && Math.Abs(player.velocity.Y) < 0.05f && player.itemAnimation == 0) diff --git a/Items/Accessories/HeartoftheElements.cs b/Items/Accessories/HeartoftheElements.cs index af7f2e9501..228ee70ec6 100644 --- a/Items/Accessories/HeartoftheElements.cs +++ b/Items/Accessories/HeartoftheElements.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Accessories DisplayName.SetDefault("Heart of the Elements"); Tooltip.SetDefault("The heart of the world\n" + "Increases max life by 20, life regen by 1 and all damage by 5%\n" + - "Increases jump speed by 24%\n" + + "Increases jump speed by 12%\n" + "Increases damage reduction and movement speed by 5%\n" + "Increases max mana by 50 and reduces mana usage by 5%\n" + "You grow flowers on the grass beneath you, chance to grow very random dye plants on grassless dirt\n" + @@ -52,7 +52,7 @@ namespace CalamityMod.Items.Accessories string lifeAmt = hideVisual ? "25" : "20"; string lifeRegenAmt = hideVisual ? "2" : "1"; string damageAmt = hideVisual ? "7" : "5"; - string jumpAmt = hideVisual ? (autoJump ? "6" : "24") : (autoJump ? "5" : "20"); + string jumpAmt = hideVisual ? (autoJump ? "3" : "12") : (autoJump ? "2.5" : "10"); string damageReductionAndMoveSpeedAmt = hideVisual ? "6" : "5"; string manaAmt = hideVisual ? "60" : "50"; string manaUsageAmt = hideVisual ? "7" : "5"; @@ -91,7 +91,7 @@ namespace CalamityMod.Items.Accessories player.lifeRegen += hideVisual ? 2 : 1; player.statLifeMax2 += hideVisual ? 25 : 20; player.moveSpeed += hideVisual ? 0.06f : 0.05f; - player.jumpSpeedBoost += hideVisual ? (player.autoJump ? 0.3f : 1.2f) : (player.autoJump ? 0.25f : 1f); + player.jumpSpeedBoost += hideVisual ? (player.autoJump ? 0.15f : 0.6f) : (player.autoJump ? 0.125f : 0.5f); player.endurance += hideVisual ? 0.06f : 0.05f; player.statManaMax2 += hideVisual ? 60 : 50; player.manaCost *= hideVisual ? 0.93f : 0.95f; diff --git a/Items/Accessories/ShatteredCommunity.cs b/Items/Accessories/ShatteredCommunity.cs index 5878f6285b..f26df095ed 100644 --- a/Items/Accessories/ShatteredCommunity.cs +++ b/Items/Accessories/ShatteredCommunity.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Items.Accessories private static long CumulativeLevelCost(int level) => (BaseLevelCost / 2L) * level * (level + 1); private const int MaxLevel = 60; - internal int rageLevel = 0; + internal int level = 0; internal long totalRageDamage = 0L; public override void SetStaticDefaults() @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Accessories { var clone = (ShatteredCommunity)base.Clone(); clone.everInInventory = everInInventory; - clone.rageLevel = rageLevel; + clone.level = level; clone.totalRageDamage = totalRageDamage; return clone; } @@ -70,7 +70,7 @@ namespace CalamityMod.Items.Accessories { var clone = (ShatteredCommunity)base.Clone(); clone.everInInventory = everInInventory; - clone.rageLevel = rageLevel; + clone.level = level; clone.totalRageDamage = totalRageDamage; return clone; } @@ -92,17 +92,14 @@ namespace CalamityMod.Items.Accessories player.moveSpeed += 0.2f; // Shattered Community provides a stacking +1% Rage Mode damage per level. - modPlayer.RageDamageBoost += rageLevel * 0.01; + modPlayer.RageDamageBoost += level * 0.01; } // Community and Shattered Community are mutually exclusive public override bool CanEquipAccessory(Player player, int slot) => !player.Calamity().community; public override bool CanUseItem(Player player) => false; - public override void UpdateInventory(Player player) - { - everInInventory = true; - } + public override void UpdateInventory(Player player) => everInInventory = true; // Produces purple light while in the world. public override void PostUpdate() @@ -136,16 +133,33 @@ namespace CalamityMod.Items.Accessories sc.totalRageDamage += damage; // Level up if applicable. - if (sc.totalRageDamage > CumulativeLevelCost(sc.rageLevel + 1)) + if (sc.level < MaxLevel && sc.totalRageDamage > CumulativeLevelCost(sc.level + 1)) { - ++sc.rageLevel; + ++sc.level; sc.LevelUpEffects(player); } } private void LevelUpEffects(Player player) { - // TODO -- it should probably do something fancy involving dust or whatever + // Spawn the purple laser beam from failing the Dungeon Defenders event. + int projID = ProjectileID.DD2ElderWins; + Vector2 offset = new Vector2(0f, 800f); // The effect is extremely tall, so start it very low down + Projectile fx = Projectile.NewProjectileDirect(player.Center + offset, Vector2.Zero, projID, 0, 0f, player.whoAmI); + fx.friendly = false; + fx.hostile = false; + // On the 108th update, crystal debris is spawned, so we avoid that. + fx.timeLeft = 107; + fx.MaxUpdates = 2; // Make the animation play at double speed. + + // Play a weird dimensional lightning sound simultaneously. + var extraSound = SoundID.DD2_EtherianPortalDryadTouch.WithVolume(1.4f); + Main.PlaySound(extraSound, player.Center); + + // Display a level up text notification. + Rectangle textArea = new Rectangle((int)player.Center.X, (int)player.Center.Y, 1, 1); + Color textColor = new Color(236, 209, 236); + CombatText.NewText(textArea, textColor, "The Community cracks...", false, false); } public override void ModifyTooltips(List tooltips) @@ -165,17 +179,17 @@ namespace CalamityMod.Items.Accessories // Line 6: Current level sb.Append("Current level: "); - sb.Append(rageLevel); + sb.Append(level); sb.Append(" (+"); - sb.Append(rageLevel); + sb.Append(level); sb.Append("% Rage Mode damage)"); tooltips.Add(new TooltipLine(mod, "Tooltip6", sb.ToString())); sb.Clear(); - if (rageLevel < MaxLevel) + if (level < MaxLevel) { - long progressToNextLevel = totalRageDamage - CumulativeLevelCost(rageLevel); - long totalToNextLevel = LevelCost(rageLevel + 1); + long progressToNextLevel = totalRageDamage - CumulativeLevelCost(level); + long totalToNextLevel = LevelCost(level + 1); double ratio = (double)progressToNextLevel / totalToNextLevel; string percent = (100D * ratio).ToString("0.00"); @@ -198,7 +212,7 @@ namespace CalamityMod.Items.Accessories TagCompound tag = new TagCompound { { "real", everInInventory }, - { "level", rageLevel }, + { "level", level }, { "totalDamage", totalRageDamage } }; return tag; @@ -207,21 +221,21 @@ namespace CalamityMod.Items.Accessories public override void Load(TagCompound tag) { everInInventory = tag.GetBool("real"); - rageLevel = tag.GetInt("level"); + level = tag.GetInt("level"); totalRageDamage = tag.GetLong("totalDamage"); } public override void NetSend(BinaryWriter writer) { writer.Write(everInInventory); - writer.Write(rageLevel); + writer.Write(level); writer.Write(totalRageDamage); } public override void NetRecieve(BinaryReader reader) { everInInventory = reader.ReadBoolean(); - rageLevel = reader.ReadInt32(); + level = reader.ReadInt32(); totalRageDamage = reader.ReadInt64(); } diff --git a/Items/Accessories/StatisBeltOfCurses.cs b/Items/Accessories/StatisBeltOfCurses.cs index d91fb2a84a..766d3c4197 100644 --- a/Items/Accessories/StatisBeltOfCurses.cs +++ b/Items/Accessories/StatisBeltOfCurses.cs @@ -12,7 +12,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Statis' Void Sash"); - Tooltip.SetDefault("24% increased jump speed and allows constant jumping\n" + + Tooltip.SetDefault("12% increased jump speed and allows constant jumping\n" + "Grants immunity to fall damage\n" + "Can climb walls, dash, and dodge attacks\n" + "The dodge has a 60 second cooldown\n" + @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); player.autoJump = true; - player.jumpSpeedBoost += 1.2f; + player.jumpSpeedBoost += 0.6f; player.noFallDmg = true; player.blackBelt = true; modPlayer.dashMod = 7; diff --git a/Items/Accessories/StatisNinjaBelt.cs b/Items/Accessories/StatisNinjaBelt.cs index b72a659846..714d8d8e73 100644 --- a/Items/Accessories/StatisNinjaBelt.cs +++ b/Items/Accessories/StatisNinjaBelt.cs @@ -10,7 +10,7 @@ namespace CalamityMod.Items.Accessories public override void SetStaticDefaults() { DisplayName.SetDefault("Statis' Ninja Belt"); - Tooltip.SetDefault("12% increased jump speed and allows constant jumping\n" + + Tooltip.SetDefault("6% increased jump speed and allows constant jumping\n" + "Increased fall damage resistance by 35 blocks\n" + "Can climb walls, dash, and dodge attacks\n" + "The dodge has a 60 second cooldown\n" + @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.autoJump = true; - player.jumpSpeedBoost += 0.6f; + player.jumpSpeedBoost += 0.3f; player.extraFall += 35; player.blackBelt = true; player.dash = 1; diff --git a/Items/Accessories/TheAbsorber.cs b/Items/Accessories/TheAbsorber.cs index 5531b023fb..4c7cae6156 100644 --- a/Items/Accessories/TheAbsorber.cs +++ b/Items/Accessories/TheAbsorber.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("The Absorber"); Tooltip.SetDefault("6% increased movement speed\n" + - "24% increased jump speed\n" + + "12% increased jump speed\n" + "+20 max life and mana\n" + "Standing still boosts life and mana regen\n" + "Increased defense, movement speed and damage reduction while submerged in liquid\n" + @@ -38,7 +38,7 @@ namespace CalamityMod.Items.Accessories public override void ModifyTooltips(List list) { bool autoJump = Main.player[Main.myPlayer].autoJump; - string jumpAmt = autoJump ? "6" : "24"; + string jumpAmt = autoJump ? "3" : "12"; foreach (TooltipLine line2 in list) { if (line2.mod == "Terraria" && line2.Name == "Tooltip1") diff --git a/Items/Accessories/VitalJelly.cs b/Items/Accessories/VitalJelly.cs index 8ad044dc71..3b4d0b1c2f 100644 --- a/Items/Accessories/VitalJelly.cs +++ b/Items/Accessories/VitalJelly.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Accessories { DisplayName.SetDefault("Vital Jelly"); Tooltip.SetDefault("10% increased movement speed\n" + - "24% increased jump speed"); + "12% increased jump speed"); } public override void SetDefaults() @@ -26,7 +26,7 @@ namespace CalamityMod.Items.Accessories public override void ModifyTooltips(List list) { bool autoJump = Main.player[Main.myPlayer].autoJump; - string jumpAmt = autoJump ? "6" : "24"; + string jumpAmt = autoJump ? "3" : "12"; foreach (TooltipLine line2 in list) { if (line2.mod == "Terraria" && line2.Name == "Tooltip1") @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.moveSpeed += 0.1f; - player.jumpSpeedBoost += player.autoJump ? 0.3f : 1.2f; + player.jumpSpeedBoost += player.autoJump ? 0.15f : 0.6f; } } } diff --git a/Items/Accessories/Wings/HadarianWings.cs b/Items/Accessories/Wings/HadarianWings.cs index 4684f8ede5..49d82defdd 100644 --- a/Items/Accessories/Wings/HadarianWings.cs +++ b/Items/Accessories/Wings/HadarianWings.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories.Wings "Acceleration multiplier: 1.75\n" + "Good vertical speed\n" + "Flight time: 120\n" + - "10% increased movement speed and 8% increased jump speed while wearing the Astral Armor"); + "10% increased movement speed and 4% increased jump speed while wearing the Astral Armor"); } public override void SetDefaults() @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Accessories.Wings if (player.armor[0].type == ModContent.ItemType() && player.armor[1].type == ModContent.ItemType() && player.armor[2].type == ModContent.ItemType()) { player.moveSpeed += 0.1f; - player.jumpSpeedBoost += 0.4f; + player.jumpSpeedBoost += 0.2f; } if (player.controlJump && player.wingTime > 0f && !player.jumpAgainCloud && player.jump == 0) diff --git a/Items/Accessories/Wings/MOAB.cs b/Items/Accessories/Wings/MOAB.cs index 29e32bbe78..6e80b83afc 100644 --- a/Items/Accessories/Wings/MOAB.cs +++ b/Items/Accessories/Wings/MOAB.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Accessories.Wings "Acceleration multiplier: 1\n" + "Good vertical speed\n" + "Flight time: 75\n" + - "20% increased jump speed and allows auto-jump\n" + + "10% increased jump speed and allows auto-jump\n" + "Grants the player cloud, blizzard, and sandstorm mid-air jumps"); } @@ -92,7 +92,7 @@ namespace CalamityMod.Items.Accessories.Wings player.jumpBoost = true; player.autoJump = true; player.noFallDmg = true; - player.jumpSpeedBoost += 1f; + player.jumpSpeedBoost += 0.5f; player.wingTimeMax = 75; } diff --git a/Items/Accessories/Wings/SkylineWings.cs b/Items/Accessories/Wings/SkylineWings.cs index 37d79fb1e5..8c6c9cd3f1 100644 --- a/Items/Accessories/Wings/SkylineWings.cs +++ b/Items/Accessories/Wings/SkylineWings.cs @@ -15,8 +15,8 @@ namespace CalamityMod.Items.Accessories.Wings Tooltip.SetDefault("Horizontal speed: 6.25\n" + "Acceleration multiplier: 1\n" + "Average vertical speed\n" + - "Flight time: 60\n" + - "5% increased jump speed while wearing the Aerospec armor"); + "Flight time: 80\n" + + "2.5% increased jump speed while wearing the Aerospec armor"); } public override void SetDefaults() @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Accessories.Wings player.armor[0].type == ModContent.ItemType()) && player.armor[1].type == ModContent.ItemType() && player.armor[2].type == ModContent.ItemType()) { - player.jumpSpeedBoost += 0.25f; + player.jumpSpeedBoost += 0.125f; } - player.wingTimeMax = 60; + player.wingTimeMax = 80; player.noFallDmg = true; } diff --git a/Items/Ammo/ArcticArrow.cs b/Items/Ammo/ArcticArrow.cs index 1fcc381fd4..6c58499897 100644 --- a/Items/Ammo/ArcticArrow.cs +++ b/Items/Ammo/ArcticArrow.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Ammo public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.IceMachine); recipe.SetResult(this, 250); recipe.AddRecipe(); diff --git a/Items/Ammo/FrostsparkBullet.cs b/Items/Ammo/FrostsparkBullet.cs index 63b410b212..5c18d18d28 100644 --- a/Items/Ammo/FrostsparkBullet.cs +++ b/Items/Ammo/FrostsparkBullet.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Ammo { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ItemID.MusketBall, 150); - recipe.AddIngredient(ModContent.ItemType()); + recipe.AddIngredient(ModContent.ItemType()); recipe.AddTile(TileID.IceMachine); recipe.SetResult(this, 150); recipe.AddRecipe(); diff --git a/Items/Armor/OmegaBlueHelmet.cs b/Items/Armor/OmegaBlueHelmet.cs index 91baf10650..ac04adc501 100644 --- a/Items/Armor/OmegaBlueHelmet.cs +++ b/Items/Armor/OmegaBlueHelmet.cs @@ -51,14 +51,14 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { string hotkey = CalamityMod.TarraHotKey.TooltipHotkeyString(); - player.setBonus = "Increases armor penetration by 25\n" + + player.setBonus = "Increases armor penetration by 15\n" + "10% increased damage and critical strike chance and +2 max minions\n" + "Short-ranged tentacles heal you by sucking enemy life\n" + "Press " + hotkey + " to activate abyssal madness for 5 seconds\n" + "Abyssal madness increases damage, critical strike chance, and tentacle aggression/range\n" + "This effect has a 25 second cooldown"; - player.armorPenetration += 25; + player.armorPenetration += 15; player.Calamity().wearingRogueArmor = true; player.maxMinions += 2; diff --git a/Items/Armor/ReaverVisage.cs b/Items/Armor/ReaverVisage.cs index ac6e94cf21..5c86455414 100644 --- a/Items/Armor/ReaverVisage.cs +++ b/Items/Armor/ReaverVisage.cs @@ -14,7 +14,7 @@ namespace CalamityMod.Items.Armor public override void SetStaticDefaults() { DisplayName.SetDefault("Reaver Visage"); - Tooltip.SetDefault("20% increased jump speed and 25% increased movement speed"); + Tooltip.SetDefault("10% increased jump speed and 25% increased movement speed"); } public override void SetDefaults() @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Armor public override void ModifyTooltips(List list) { bool autoJump = Main.player[Main.myPlayer].autoJump; - string jumpAmt = autoJump ? "5" : "20"; + string jumpAmt = autoJump ? "2.5" : "10"; foreach (TooltipLine line2 in list) { if (line2.mod == "Terraria" && line2.Name == "Tooltip0") @@ -65,7 +65,7 @@ namespace CalamityMod.Items.Armor public override void UpdateEquip(Player player) { - player.jumpSpeedBoost += player.autoJump ? 0.25f : 1f; + player.jumpSpeedBoost += player.autoJump ? 0.125f : 0.5f; player.moveSpeed += 0.25f; } diff --git a/Items/Armor/StatigelCap.cs b/Items/Armor/StatigelCap.cs index 87d5f63de0..8a77d51f91 100644 --- a/Items/Armor/StatigelCap.cs +++ b/Items/Armor/StatigelCap.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - string jumpSpeedBonus = player.autoJump ? "7.5" : "30"; + string jumpSpeedBonus = player.autoJump ? "4" : "16"; player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + "Grants an extra jump and increased jump height\n" + jumpSpeedBonus + "% increased jump speed"; @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Armor modPlayer.statigelSet = true; modPlayer.statigelJump = true; Player.jumpHeight += 5; - player.jumpSpeedBoost += player.autoJump ? 0.375f : 1.5f; + player.jumpSpeedBoost += player.autoJump ? 0.2f : 0.8f; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/StatigelHeadgear.cs b/Items/Armor/StatigelHeadgear.cs index 503bf6a603..b436faef0a 100644 --- a/Items/Armor/StatigelHeadgear.cs +++ b/Items/Armor/StatigelHeadgear.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - string jumpSpeedBonus = player.autoJump ? "7.5" : "30"; + string jumpSpeedBonus = player.autoJump ? "4" : "16"; player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + "Grants an extra jump and increased jump height\n" + jumpSpeedBonus + "% increased jump speed"; @@ -41,7 +41,7 @@ namespace CalamityMod.Items.Armor modPlayer.statigelSet = true; modPlayer.statigelJump = true; Player.jumpHeight += 5; - player.jumpSpeedBoost += player.autoJump ? 0.375f : 1.5f; + player.jumpSpeedBoost += player.autoJump ? 0.2f : 0.8f; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/StatigelHelm.cs b/Items/Armor/StatigelHelm.cs index 7f7c518b74..9105992172 100644 --- a/Items/Armor/StatigelHelm.cs +++ b/Items/Armor/StatigelHelm.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - string jumpSpeedBonus = player.autoJump ? "7.5" : "30"; + string jumpSpeedBonus = player.autoJump ? "4" : "16"; player.setBonus = "Enemies are more likely to target you\n" + "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + "Grants an extra jump and increased jump height\n" + @@ -42,7 +42,7 @@ namespace CalamityMod.Items.Armor modPlayer.statigelSet = true; modPlayer.statigelJump = true; Player.jumpHeight += 5; - player.jumpSpeedBoost += player.autoJump ? 0.375f : 1.5f; + player.jumpSpeedBoost += player.autoJump ? 0.2f : 0.8f; player.aggro += 400; } diff --git a/Items/Armor/StatigelHood.cs b/Items/Armor/StatigelHood.cs index 2a8981afc1..d9ea556891 100644 --- a/Items/Armor/StatigelHood.cs +++ b/Items/Armor/StatigelHood.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - string jumpSpeedBonus = player.autoJump ? "7.5" : "30"; + string jumpSpeedBonus = player.autoJump ? "4" : "16"; player.setBonus = "18% increased minion damage and +1 max minion\n" + "Summons a mini slime god to fight for you, the type depends on what world evil you have\n" + "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Armor modPlayer.slimeGod = true; modPlayer.statigelJump = true; Player.jumpHeight += 5; - player.jumpSpeedBoost += player.autoJump ? 0.375f : 1.5f; + player.jumpSpeedBoost += player.autoJump ? 0.2f : 0.8f; player.minionDamage += 0.18f; player.maxMinions++; if (player.whoAmI == Main.myPlayer) diff --git a/Items/Armor/StatigelMask.cs b/Items/Armor/StatigelMask.cs index 2d45e5522c..104462a94b 100644 --- a/Items/Armor/StatigelMask.cs +++ b/Items/Armor/StatigelMask.cs @@ -33,7 +33,7 @@ namespace CalamityMod.Items.Armor public override void UpdateArmorSet(Player player) { - string jumpSpeedBonus = player.autoJump ? "7.5" : "30"; + string jumpSpeedBonus = player.autoJump ? "4" : "16"; player.setBonus = "When you take over 100 damage in one hit you become immune to damage for an extended period of time\n" + "Grants an extra jump and increased jump height\n" + jumpSpeedBonus + "% increased jump speed\n" + @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Armor modPlayer.rogueStealthMax += 1f; modPlayer.wearingRogueArmor = true; Player.jumpHeight += 5; - player.jumpSpeedBoost += player.autoJump ? 0.375f : 1.5f; + player.jumpSpeedBoost += player.autoJump ? 0.2f : 0.8f; } public override void UpdateEquip(Player player) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index a2718cae1a..bebd759c94 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -1264,7 +1264,7 @@ namespace CalamityMod.Items foreach (TooltipLine line2 in tooltips) { if (line2.mod == "Terraria" && line2.Name == "Tooltip0") - line2.text = ""; + line2.text += "\nDemon Altars no longer spawn ores when destroyed"; } } if (item.type == ItemID.BlackBelt) @@ -2118,6 +2118,9 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } } + if (item.type == ItemID.DD2ElderCrystal) + tooltips.FirstOrDefault(line => line.mod == "Terraria" && line.Name == "Tooltip0").text += "\nOnce placed you can right click the crystal to skip waves or increase the spawn rate of the invaders"; + if (item.type == ItemID.MagicQuiver) { foreach (TooltipLine line2 in tooltips) @@ -2350,7 +2353,7 @@ Grants immunity to fire blocks, and temporary immunity to lava"; "Flight time: 100\n" + "Gills effect and you can move freely through liquids\n" + "You fall faster while submerged in liquid\n" + - "15% increased movement speed and 36% increased jump speed"; + "15% increased movement speed and 18% increased jump speed"; } } } @@ -2412,7 +2415,7 @@ Grants immunity to fire blocks, and temporary immunity to lava"; "Average vertical speed\n" + "Flight time: 140\n" + "At night or during an eclipse, you will gain the following boosts:\n" + - "10% increased movement speed, 20% increased jump speed,\n" + + "10% increased movement speed, 10% increased jump speed,\n" + "7% increased damage and 3% increased critical strike chance"; } } @@ -2508,7 +2511,7 @@ Grants immunity to fire blocks, and temporary immunity to lava"; "Average vertical speed\n" + "Flight time: 160\n" + "+5 defense, 5% increased damage,\n" + - "10% increased movement speed and 24% increased jump speed"; + "10% increased movement speed and 12% increased jump speed"; } } } @@ -2905,6 +2908,19 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } } + if (item.type == ItemID.StaticHook) + { + foreach (TooltipLine line2 in tooltips) + { + if (line2.mod == "Terraria" && line2.Name == "Equipable") + { + line2.text = "Equipable\n" + + "Reach: 37.5\n" + + "Launch Velocity: 16\n" + + "Pull Velocity: 24"; + } + } + } if (item.accessory) { if (item.prefix == PrefixID.Brisk) @@ -3236,6 +3252,9 @@ Grants immunity to fire blocks, and temporary immunity to lava"; } } + if (item.type == ItemID.FrogLeg) + player.jumpSpeedBoost -= 1.2f; + if (item.type == ItemID.FireGauntlet) { player.meleeDamage += 0.04f; @@ -3258,7 +3277,7 @@ Grants immunity to fire blocks, and temporary immunity to lava"; else if (item.type == ItemID.FinWings) // Boosted water abilities, faster fall in water { player.moveSpeed += 0.15f; - player.jumpSpeedBoost += 1.8f; + player.jumpSpeedBoost += 0.9f; player.gills = true; player.ignoreWater = true; player.noFallDmg = true; @@ -3291,7 +3310,7 @@ Grants immunity to fire blocks, and temporary immunity to lava"; player.noFallDmg = true; if (!Main.dayTime || Main.eclipse) { - player.jumpSpeedBoost += 1f; + player.jumpSpeedBoost += 0.5f; player.allDamage += 0.07f; modPlayer.AllCritBoost(3); player.moveSpeed += 0.1f; @@ -3320,7 +3339,7 @@ Grants immunity to fire blocks, and temporary immunity to lava"; player.statDefense += 5; player.allDamage += 0.05f; player.moveSpeed += 0.1f; - player.jumpSpeedBoost += 1.2f; + player.jumpSpeedBoost += 0.6f; player.noFallDmg = true; } else if (item.type == ItemID.FrozenWings) // Bonus to melee and ranged stats while wearing frost armor diff --git a/Items/Materials/CryoBar.cs b/Items/Materials/CryoBar.cs deleted file mode 100644 index 196b16a402..0000000000 --- a/Items/Materials/CryoBar.cs +++ /dev/null @@ -1,34 +0,0 @@ -using CalamityMod.Tiles; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Materials -{ - public class CryoBar : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Frigid Bar"); - Tooltip.SetDefault("Cold to the touch"); - } - - public override void SetDefaults() - { - item.createTile = ModContent.TileType(); - item.width = 30; - item.height = 24; - item.maxStack = 999; - item.value = Item.buyPrice(0, 3, 0, 0); - item.rare = ItemRarityID.Pink; - item.useStyle = ItemUseStyleID.SwingThrow; - item.useTurn = true; - item.useAnimation = 15; - item.useTime = 10; - item.autoReuse = true; - item.consumable = true; - } - } -} diff --git a/Items/Materials/CryoBar.png b/Items/Materials/CryoBar.png deleted file mode 100644 index a26ccbab74..0000000000 Binary files a/Items/Materials/CryoBar.png and /dev/null differ diff --git a/Items/Potions/BoundingPotion.cs b/Items/Potions/BoundingPotion.cs index ada2b5dda6..e2a87ed16a 100644 --- a/Items/Potions/BoundingPotion.cs +++ b/Items/Potions/BoundingPotion.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Potions public override void SetStaticDefaults() { DisplayName.SetDefault("Bounding Potion"); - Tooltip.SetDefault("Grants 10% increased jump speed, 25 extra blocks of fall damage resistance, and increased jump height"); + Tooltip.SetDefault("Grants 5% increased jump speed, 25 extra blocks of fall damage resistance, and increased jump height"); } public override void SetDefaults() diff --git a/Items/Tools/ClimateChange/Cosmolight.cs b/Items/Tools/ClimateChange/Cosmolight.cs index c91107af80..d8f9b10a8f 100644 --- a/Items/Tools/ClimateChange/Cosmolight.cs +++ b/Items/Tools/ClimateChange/Cosmolight.cs @@ -1,4 +1,5 @@ using CalamityMod.CalPlayer; +using CalamityMod.Items.Materials; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -51,9 +52,11 @@ namespace CalamityMod.Items.Tools.ClimateChange public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType()); - recipe.AddTile(TileID.MythrilAnvil); + recipe.AddIngredient(ItemID.SoulofLight, 7); + recipe.AddIngredient(ItemID.SoulofNight, 7); + recipe.AddIngredient(ItemID.HellstoneBar, 5); + recipe.AddIngredient(ModContent.ItemType(), 5); + recipe.AddTile(TileID.MythrilAnvil); recipe.SetResult(this); recipe.AddRecipe(); } diff --git a/Items/Tools/ClimateChange/Daylight.cs b/Items/Tools/ClimateChange/Daylight.cs deleted file mode 100644 index 26897075b1..0000000000 --- a/Items/Tools/ClimateChange/Daylight.cs +++ /dev/null @@ -1,53 +0,0 @@ -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools.ClimateChange -{ - public class Daylight : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Daylight"); - Tooltip.SetDefault("Summons the sun"); - } - - public override void SetDefaults() - { - item.width = 20; - item.height = 20; - item.rare = ItemRarityID.Pink; - item.useAnimation = 20; - item.useTime = 20; - item.useStyle = ItemUseStyleID.HoldingUp; - item.UseSound = SoundID.Item60; - item.consumable = false; - } - - public override bool CanUseItem(Player player) - { - return !Main.dayTime && !CalamityPlayer.areThereAnyDamnBosses; - } - - public override bool UseItem(Player player) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.dayTime = true; - CalamityNetcode.SyncWorld(); - } - return true; - } - - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SoulofLight, 7); - recipe.AddIngredient(ItemID.HellstoneBar, 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } -} diff --git a/Items/Tools/ClimateChange/Daylight.png b/Items/Tools/ClimateChange/Daylight.png deleted file mode 100644 index 7889c347a1..0000000000 Binary files a/Items/Tools/ClimateChange/Daylight.png and /dev/null differ diff --git a/Items/Tools/ClimateChange/Moonlight.cs b/Items/Tools/ClimateChange/Moonlight.cs deleted file mode 100644 index 73358c6436..0000000000 --- a/Items/Tools/ClimateChange/Moonlight.cs +++ /dev/null @@ -1,54 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.CalPlayer; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Tools.ClimateChange -{ - public class Moonlight : ModItem - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Moonlight"); - Tooltip.SetDefault("Summons the moon"); - } - - public override void SetDefaults() - { - item.width = 20; - item.height = 20; - item.rare = ItemRarityID.Pink; - item.useAnimation = 20; - item.useTime = 20; - item.useStyle = ItemUseStyleID.HoldingUp; - item.UseSound = SoundID.Item60; - item.consumable = false; - } - - public override bool CanUseItem(Player player) - { - return Main.dayTime && !CalamityPlayer.areThereAnyDamnBosses; - } - - public override bool UseItem(Player player) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - Main.dayTime = false; - CalamityNetcode.SyncWorld(); - } - return true; - } - - public override void AddRecipes() - { - ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ItemID.SoulofNight, 7); - recipe.AddIngredient(ModContent.ItemType(), 5); - recipe.AddTile(TileID.MythrilAnvil); - recipe.SetResult(this); - recipe.AddRecipe(); - } - } -} diff --git a/Items/Tools/ClimateChange/Moonlight.png b/Items/Tools/ClimateChange/Moonlight.png deleted file mode 100644 index 5490d86e60..0000000000 Binary files a/Items/Tools/ClimateChange/Moonlight.png and /dev/null differ diff --git a/Items/TreasureBags/CryogenBag.cs b/Items/TreasureBags/CryogenBag.cs index bf7911f2e7..46cc2e4270 100644 --- a/Items/TreasureBags/CryogenBag.cs +++ b/Items/TreasureBags/CryogenBag.cs @@ -46,7 +46,6 @@ namespace CalamityMod.Items.TreasureBags player.TryGettingDevArmor(); // Materials - DropHelper.DropItem(player, ModContent.ItemType(), 20, 40); DropHelper.DropItem(player, ModContent.ItemType(), 5, 9); DropHelper.DropItem(player, ItemID.FrostCore); diff --git a/Items/Weapons/Magic/DivineRetribution.cs b/Items/Weapons/Magic/DivineRetribution.cs index c78077d2d3..752aa7861d 100644 --- a/Items/Weapons/Magic/DivineRetribution.cs +++ b/Items/Weapons/Magic/DivineRetribution.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 49; + item.damage = 42; item.magic = true; item.mana = 15; item.width = 66; diff --git a/Items/Weapons/Magic/FatesReveal.cs b/Items/Weapons/Magic/FatesReveal.cs index 511e6af166..1e74e5475a 100644 --- a/Items/Weapons/Magic/FatesReveal.cs +++ b/Items/Weapons/Magic/FatesReveal.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 50; + item.damage = 120; item.magic = true; item.mana = 20; item.width = 80; diff --git a/Items/Weapons/Magic/IceBarrage.cs b/Items/Weapons/Magic/IceBarrage.cs index 7b5b3ee361..15f58b9403 100644 --- a/Items/Weapons/Magic/IceBarrage.cs +++ b/Items/Weapons/Magic/IceBarrage.cs @@ -72,7 +72,7 @@ namespace CalamityMod.Items.Weapons.Magic recipe.AddIngredient(ItemID.IceRod); recipe.AddIngredient(ModContent.ItemType()); recipe.AddIngredient(ModContent.ItemType(), 23); - recipe.AddIngredient(ModContent.ItemType(), 18); + recipe.AddIngredient(ModContent.ItemType(), 18); recipe.AddTile(TileID.LunarCraftingStation); recipe.SetResult(this); recipe.AddRecipe(); diff --git a/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs b/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs index 28426def58..159170ac99 100644 --- a/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs +++ b/Items/Weapons/Magic/MadAlchemistsCocktailGlove.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Magic item.UseSound = SoundID.Item106; item.autoReuse = true; item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; + item.shootSpeed = 19f; item.value = CalamityGlobalItem.Rarity11BuyPrice; item.rare = ItemRarityID.Purple; diff --git a/Items/Weapons/Magic/ShadowboltStaff.cs b/Items/Weapons/Magic/ShadowboltStaff.cs index dfaf5ae33e..1734433b95 100644 --- a/Items/Weapons/Magic/ShadowboltStaff.cs +++ b/Items/Weapons/Magic/ShadowboltStaff.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 120; + item.damage = 250; item.magic = true; item.mana = 20; item.width = 58; diff --git a/Items/Weapons/Magic/Thunderstorm.cs b/Items/Weapons/Magic/Thunderstorm.cs index 93a83d6dd4..ffdcc3b237 100644 --- a/Items/Weapons/Magic/Thunderstorm.cs +++ b/Items/Weapons/Magic/Thunderstorm.cs @@ -15,7 +15,7 @@ namespace CalamityMod.Items.Weapons.Magic public override void SetDefaults() { - item.damage = 180; + item.damage = 165; item.mana = 50; item.magic = true; item.width = 48; diff --git a/Items/Weapons/Melee/FlarefrostBlade.cs b/Items/Weapons/Melee/FlarefrostBlade.cs index 05c47b1558..ce6fe1e356 100644 --- a/Items/Weapons/Melee/FlarefrostBlade.cs +++ b/Items/Weapons/Melee/FlarefrostBlade.cs @@ -37,7 +37,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 8); + recipe.AddIngredient(ModContent.ItemType(), 8); recipe.AddIngredient(ItemID.HellstoneBar, 8); recipe.AddIngredient(ItemID.HallowedBar, 4); recipe.AddTile(TileID.MythrilAnvil); diff --git a/Items/Weapons/Melee/NeptunesBounty.cs b/Items/Weapons/Melee/NeptunesBounty.cs index 7215068ab9..a3095c0180 100644 --- a/Items/Weapons/Melee/NeptunesBounty.cs +++ b/Items/Weapons/Melee/NeptunesBounty.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee { item.width = 122; item.height = 122; - item.damage = 228; + item.damage = 251; item.melee = true; item.useAnimation = 22; item.useTime = 22; diff --git a/Items/Weapons/Melee/TemporalFloeSword.cs b/Items/Weapons/Melee/TemporalFloeSword.cs index de4ccff951..6700d5f9b6 100644 --- a/Items/Weapons/Melee/TemporalFloeSword.cs +++ b/Items/Weapons/Melee/TemporalFloeSword.cs @@ -46,7 +46,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { ModRecipe recipe = new ModRecipe(mod); - recipe.AddIngredient(ModContent.ItemType(), 15); + recipe.AddIngredient(ModContent.ItemType(), 15); recipe.AddIngredient(ItemID.Ectoplasm, 5); recipe.AddTile(TileID.IceMachine); recipe.SetResult(this); diff --git a/Items/Weapons/Melee/TheLastMourning.cs b/Items/Weapons/Melee/TheLastMourning.cs index 4c5c52bcf3..f7fa845cff 100644 --- a/Items/Weapons/Melee/TheLastMourning.cs +++ b/Items/Weapons/Melee/TheLastMourning.cs @@ -1,5 +1,6 @@ using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; +using CalamityMod.NPCs.DevourerofGods; using CalamityMod.Projectiles.Melee; using Microsoft.Xna.Framework; using Terraria; @@ -22,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Melee item.height = 94; item.scale = 1.5f; item.melee = true; - item.damage = 288; + item.damage = 360; item.knockBack = 8.5f; item.useAnimation = 20; item.useTime = 20; @@ -41,8 +42,14 @@ namespace CalamityMod.Items.Weapons.Melee public override void OnHitNPC(Player player, NPC target, int damage, float knockback, bool crit) { int projDamage = (int)(item.damage * player.MeleeDamage()); - CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, projDamage, knockback, 0, ModContent.ProjectileType()); - CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, projDamage, knockback, 1); + bool isDoGSegment = target.type == ModContent.NPCType() || + target.type == ModContent.NPCType() || + target.type == ModContent.NPCType(); + if (!isDoGSegment || Main.rand.NextBool(3)) + { + CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, projDamage, knockback, 0, ModContent.ProjectileType()); + CalamityPlayerOnHit.HorsemansBladeOnHit(player, target.whoAmI, projDamage, knockback, 1); + } } public override void OnHitPvp(Player player, Player target, int damage, bool crit) diff --git a/Items/Weapons/Ranged/AstrealDefeat.cs b/Items/Weapons/Ranged/AstrealDefeat.cs index 7198257293..5cf4379c51 100644 --- a/Items/Weapons/Ranged/AstrealDefeat.cs +++ b/Items/Weapons/Ranged/AstrealDefeat.cs @@ -7,15 +7,15 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class AstrealDefeat : ModItem + public class AstrealDefeat : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Astreal Defeat"); Tooltip.SetDefault("Ethereal bow of the tyrant king's mother\n" + - "The mother strongly discouraged acts of violence throughout her life\n" + - "Though she kept this bow close, to protect her family in times of great disaster\n" + - "Converts wooden arrows into astreal arrows that emit flames as they travel"); + "The mother strongly discouraged acts of violence throughout her life\n" + + "Though she kept this bow close, to protect her family in times of great disaster\n" + + "All arrows are converted to Astreal Arrows that emit flames as they travel"); } public override void SetDefaults() @@ -40,22 +40,18 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - Vector2 velocity = new Vector2(speedX, speedY); - if (velocity.Length() > 8f) - { - velocity.Normalize(); - velocity *= 8f; - } + Vector2 velocity = new Vector2(speedX, speedY); + float speed = velocity.Length(); + if (speed > 8f) + velocity *= 8f / speed; - if (type == ProjectileID.WoodenArrowFriendly) - { - float ai0 = Main.rand.Next(4); - Projectile.NewProjectile(position.X, position.Y, velocity.X, velocity.Y, ModContent.ProjectileType(), damage, knockBack, player.whoAmI, ai0, 0f); - } - else - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI); + // Always fires Astreal Arrows, regardless of ammo chosen. + // Normally we like to allow bows to fire normal arrows but this weapon is incredibly overpowered when that is allowed. + type = item.shoot; + float aiVar = Main.rand.Next(4); - return false; + Projectile.NewProjectile(position, velocity, type, damage, knockBack, player.whoAmI, aiVar); + return false; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/BloodBoiler.cs b/Items/Weapons/Ranged/BloodBoiler.cs index 8564d5354e..5bd7b17508 100644 --- a/Items/Weapons/Ranged/BloodBoiler.cs +++ b/Items/Weapons/Ranged/BloodBoiler.cs @@ -14,8 +14,7 @@ namespace CalamityMod.Items.Weapons.Ranged { DisplayName.SetDefault("Blood Boiler"); Tooltip.SetDefault("Fires a stream of lifestealing bloodfire\n" + - "Must be used in 10 second bursts\n" + - "Uses your life as ammo"); + "Uses your health as ammo\n" + "25% chance to not consume ammo"); } public override void SetDefaults() @@ -25,33 +24,31 @@ namespace CalamityMod.Items.Weapons.Ranged item.width = 60; item.height = 30; item.useTime = 5; - item.useAnimation = 600; + item.useAnimation = 15; + item.autoReuse = true; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 4f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.autoReuse = true; + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; item.shootSpeed = 12f; item.shoot = ModContent.ProjectileType(); } - public override Vector2? HoldoutOffset() - { - return new Vector2(-5, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-5, 0); public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - //using this weapon once will subtract 120 health in total - player.statLife -= 1; + if (Main.rand.NextFloat() > 0.75f) + --player.statLife; if (player.statLife <= 0) { - player.KillMe(PlayerDeathReason.ByCustomReason(Main.rand.NextBool(2) ? player.name + " suffered from severe anemia." : player.name + " was unable to obtain a blood transfusion."), 1000.0, 0, false); + PlayerDeathReason pdr = PlayerDeathReason.ByCustomReason(Main.rand.NextBool(2) ? player.name + " suffered from severe anemia." : player.name + " was unable to obtain a blood transfusion."); + player.KillMe(pdr, 1000.0, 0, false); + return false; } - Projectile.NewProjectile(position.X, position.Y, speedX, speedY, type, damage, knockBack, player.whoAmI, 0.0f, 0.0f); - return false; + return true; } public override void AddRecipes() diff --git a/Items/Weapons/Ranged/FetidEmesis.cs b/Items/Weapons/Ranged/FetidEmesis.cs index 0bc196ded9..462de59b1e 100644 --- a/Items/Weapons/Ranged/FetidEmesis.cs +++ b/Items/Weapons/Ranged/FetidEmesis.cs @@ -16,7 +16,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 120; + item.damage = 129; item.ranged = true; item.width = 76; item.height = 46; diff --git a/Items/Weapons/Ranged/HalleysInferno.cs b/Items/Weapons/Ranged/HalleysInferno.cs index 26e52522f5..319326f475 100644 --- a/Items/Weapons/Ranged/HalleysInferno.cs +++ b/Items/Weapons/Ranged/HalleysInferno.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 1000; + item.damage = 1150; item.knockBack = 5f; item.ranged = true; item.useTime = item.useAnimation = 30; diff --git a/Items/Weapons/Ranged/Monsoon.cs b/Items/Weapons/Ranged/Monsoon.cs index 76e43db0e3..86061bf902 100644 --- a/Items/Weapons/Ranged/Monsoon.cs +++ b/Items/Weapons/Ranged/Monsoon.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetDefaults() { - item.damage = 85; + item.damage = 90; item.ranged = true; item.width = 46; item.height = 78; @@ -28,8 +28,8 @@ namespace CalamityMod.Items.Weapons.Ranged item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; item.knockBack = 2.5f; - item.value = Item.buyPrice(1, 40, 0, 0); - item.Calamity().customRarity = (CalamityRarity)13; + item.value = CalamityGlobalItem.Rarity13BuyPrice; + item.Calamity().customRarity = CalamityRarity.PureGreen; item.UseSound = SoundID.Item5; item.autoReuse = true; item.shoot = ProjectileID.WoodenArrowFriendly; diff --git a/Items/Weapons/Ranged/PristineFury.cs b/Items/Weapons/Ranged/PristineFury.cs index 55b5fc6d18..9c24c25258 100644 --- a/Items/Weapons/Ranged/PristineFury.cs +++ b/Items/Weapons/Ranged/PristineFury.cs @@ -11,7 +11,7 @@ namespace CalamityMod.Items.Weapons.Ranged { public int frameCounter = 0; public int frame = 0; - public static int BaseDamage = 89; + public static int BaseDamage = 96; public override void SetStaticDefaults() { diff --git a/Items/Weapons/Ranged/SepticSkewer.cs b/Items/Weapons/Ranged/SepticSkewer.cs index 7ea6a5e2a1..eafb4117c4 100644 --- a/Items/Weapons/Ranged/SepticSkewer.cs +++ b/Items/Weapons/Ranged/SepticSkewer.cs @@ -1,23 +1,22 @@ using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; -using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Items.Weapons.Ranged { - public class SepticSkewer : ModItem + public class SepticSkewer : ModItem { public override void SetStaticDefaults() { DisplayName.SetDefault("Septic Skewer"); Tooltip.SetDefault("Launches a spiky harpoon infested with toxins\n" + - "Releases bacteria when returning to the player"); + "Releases bacteria when returning to the player"); } public override void SetDefaults() { - item.damage = 300; + item.damage = 272; item.ranged = true; item.width = 46; item.height = 24; @@ -35,9 +34,6 @@ namespace CalamityMod.Items.Weapons.Ranged item.Calamity().customRarity = CalamityRarity.PureGreen; } - public override Vector2? HoldoutOffset() - { - return new Vector2(-10, 0); - } + public override Vector2? HoldoutOffset() => new Vector2(-10, 0); } } diff --git a/Items/Weapons/Ranged/TelluricGlare.cs b/Items/Weapons/Ranged/TelluricGlare.cs index 47758d0b45..e73b4c60e5 100644 --- a/Items/Weapons/Ranged/TelluricGlare.cs +++ b/Items/Weapons/Ranged/TelluricGlare.cs @@ -11,38 +11,47 @@ namespace CalamityMod.Items.Weapons.Ranged public override void SetStaticDefaults() { DisplayName.SetDefault("Telluric Glare"); - Tooltip.SetDefault("Converts wooden arrows into extremely fast energy arrows"); + Tooltip.SetDefault("Fires volleys of four colossal radiant arrows which can pass through walls"); } public override void SetDefaults() { - item.damage = 60; + item.damage = 160; item.ranged = true; item.width = 54; item.height = 92; - item.useTime = 15; - item.useAnimation = 15; + item.useTime = 5; + item.useAnimation = 20; + item.reuseDelay = 23; + item.knockBack = 7.5f; item.useStyle = ItemUseStyleID.HoldingOut; item.noMelee = true; - item.knockBack = 4f; - item.value = CalamityGlobalItem.Rarity12BuyPrice; - item.rare = ItemRarityID.Purple; - item.Calamity().customRarity = CalamityRarity.Turquoise; - item.UseSound = SoundID.Item5; + + item.value = CalamityGlobalItem.Rarity12BuyPrice; + item.rare = ItemRarityID.Purple; + item.Calamity().customRarity = CalamityRarity.Turquoise; + + item.UseSound = SoundID.Item102; item.autoReuse = true; - item.shoot = ModContent.ProjectileType(); - item.shootSpeed = 12f; + item.shoot = ModContent.ProjectileType(); + item.shootSpeed = 18f; item.useAmmo = AmmoID.Arrow; } + public override Vector2? HoldoutOffset() => new Vector2(-14f, 0f); + public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - if (type == ProjectileID.WoodenArrowFriendly) - Projectile.NewProjectile(position, new Vector2(speedX, speedY), ModContent.ProjectileType(), damage, knockBack, player.whoAmI); - else - Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); + // Always fires Radiant Arrows regardless of ammo used + type = item.shoot; - return false; + // The arrow appears from a random location "on the bow". + // They are also moved backwards so that they have some time to build up past positions. This helps make them not appear out of thin air. + Vector2 velocity = new Vector2(speedX, speedY); + Vector2 offset = Vector2.Normalize(velocity.RotatedBy(MathHelper.PiOver2)); + position += offset * Main.rand.NextFloat(-19f, 19f); + position -= 3f * velocity; + return true; } } } diff --git a/Items/Weapons/Rogue/FrostcrushValari.cs b/Items/Weapons/Rogue/FrostcrushValari.cs index 3bdf9cab02..02f6fa661a 100644 --- a/Items/Weapons/Rogue/FrostcrushValari.cs +++ b/Items/Weapons/Rogue/FrostcrushValari.cs @@ -76,7 +76,7 @@ Stealth strikes throw three short ranged boomerangs along with a spread of icicl { ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType()); - recipe.AddIngredient(ModContent.ItemType(), 6); + recipe.AddIngredient(ModContent.ItemType(), 6); recipe.AddIngredient(ModContent.ItemType(), 40); recipe.AddIngredient(ModContent.ItemType(), 5); recipe.AddTile(TileID.MythrilAnvil); diff --git a/Items/Weapons/Rogue/JawsOfOblivion.cs b/Items/Weapons/Rogue/JawsOfOblivion.cs index 3a5da1cbfe..daa85d4e50 100644 --- a/Items/Weapons/Rogue/JawsOfOblivion.cs +++ b/Items/Weapons/Rogue/JawsOfOblivion.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Items.Weapons.Rogue if (player.Calamity().StealthStrikeAvailable()) { - int p = Projectile.NewProjectile(position, currentDirection, type, (int)(damage * 0.67), knockBack * 2f, player.whoAmI); + int p = Projectile.NewProjectile(position, currentDirection, type, damage, knockBack + 6f, player.whoAmI); if (p.WithinBounds(Main.maxProjectiles)) Main.projectile[p].Calamity().stealthStrike = true; } diff --git a/Items/Weapons/Rogue/KelvinCatalyst.cs b/Items/Weapons/Rogue/KelvinCatalyst.cs index e32215ea38..411e73a055 100644 --- a/Items/Weapons/Rogue/KelvinCatalyst.cs +++ b/Items/Weapons/Rogue/KelvinCatalyst.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Rogue ModRecipe recipe = new ModRecipe(mod); recipe.AddIngredient(ModContent.ItemType(), 200); recipe.AddIngredient(ItemID.FrozenKey); - recipe.AddIngredient(ModContent.ItemType(), 20); + recipe.AddIngredient(ModContent.ItemType(), 20); recipe.AddIngredient(ModContent.ItemType(), 10); recipe.AddIngredient(ModContent.ItemType(), 2); recipe.AddIngredient(ModContent.ItemType(), 2); diff --git a/Items/Weapons/Summon/AbandonedSlimeStaff.cs b/Items/Weapons/Summon/AbandonedSlimeStaff.cs index 425fbe0d47..3f8910ad1f 100644 --- a/Items/Weapons/Summon/AbandonedSlimeStaff.cs +++ b/Items/Weapons/Summon/AbandonedSlimeStaff.cs @@ -18,7 +18,7 @@ namespace CalamityMod.Items.Weapons.Summon "Consumes all of the remaining minion slots on use\n" + "Must be used from the hotbar\n" + "Increased power and size based on the number of minion slots used\n" + - "Holding this weapon grants 20% increased jump speed"); + "Holding this weapon grants 10% increased jump speed"); } public override void SetDefaults() @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void ModifyTooltips(List list) { bool autoJump = Main.player[Main.myPlayer].autoJump; - string jumpAmt = autoJump ? "5" : "20"; + string jumpAmt = autoJump ? "2.5" : "10"; foreach (TooltipLine line2 in list) { if (line2.mod == "Terraria" && line2.Name == "Tooltip4") @@ -58,7 +58,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void HoldItem(Player player) { //same boost as Aero Stone - player.jumpSpeedBoost += player.autoJump ? 0.25f : 1f; + player.jumpSpeedBoost += player.autoJump ? 0.125f : 0.5f; double minionCount = 0; for (int j = 0; j < Main.projectile.Length; j++) diff --git a/Items/Weapons/Summon/DazzlingStabberStaff.cs b/Items/Weapons/Summon/DazzlingStabberStaff.cs index ba7a2b5750..8d98d10338 100644 --- a/Items/Weapons/Summon/DazzlingStabberStaff.cs +++ b/Items/Weapons/Summon/DazzlingStabberStaff.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Summon item.UseSound = SoundID.DD2_DarkMageHealImpact; item.summon = true; item.mana = 12; - item.damage = 120; + item.damage = 56; item.knockBack = 2f; item.autoReuse = true; item.useTime = item.useAnimation = 15; diff --git a/Items/Weapons/Summon/DragonbloodDisgorger.cs b/Items/Weapons/Summon/DragonbloodDisgorger.cs index fce7c624f1..326dbbca83 100644 --- a/Items/Weapons/Summon/DragonbloodDisgorger.cs +++ b/Items/Weapons/Summon/DragonbloodDisgorger.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetDefaults() { - item.damage = 195; + item.damage = 170; item.mana = 30; item.width = 64; item.height = 62; diff --git a/Items/Weapons/Summon/GammaHeart.cs b/Items/Weapons/Summon/GammaHeart.cs index 3572886146..b72784fbb9 100644 --- a/Items/Weapons/Summon/GammaHeart.cs +++ b/Items/Weapons/Summon/GammaHeart.cs @@ -11,8 +11,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void SetStaticDefaults() { DisplayName.SetDefault("Gamma Heart"); - Tooltip.SetDefault("Summons radioactive heads that are bound by your body\n" + - "If the entity already exists, using this item again will cause it to gain more heads"); + Tooltip.SetDefault("Summons radioactive heads that are bound by your body"); } public override void SetDefaults() @@ -24,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Summon item.UseSound = SoundID.Item42; item.summon = true; item.mana = 16; - item.damage = 72; + item.damage = 216; item.knockBack = 3f; item.autoReuse = true; item.useTime = item.useAnimation = 15; @@ -38,9 +37,7 @@ namespace CalamityMod.Items.Weapons.Summon public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (player.altFunctionUse != 2) - { Projectile.NewProjectileDirect(player.Center, Vector2.Zero, type, damage, knockBack, player.whoAmI); - } return false; } } diff --git a/Items/Weapons/Typeless/AethersWhisper.cs b/Items/Weapons/Typeless/AethersWhisper.cs index 038b8125ff..c5141383e9 100644 --- a/Items/Weapons/Typeless/AethersWhisper.cs +++ b/Items/Weapons/Typeless/AethersWhisper.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Weapons.Typeless public override void SetDefaults() { - item.damage = 560; + item.damage = 504; item.knockBack = 5.5f; item.useTime = item.useAnimation = 24; item.shootSpeed = 12f; diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 6db44b37dc..748971b1d2 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -320,7 +320,7 @@ namespace CalamityMod BossDifficulty.TryGetValue("Cryogen", out float order); int type = NPCType(); int summon = ItemType(); - List loot = new List() { ItemType(), ItemType(), ItemType(), ItemID.FrostCore, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.FrozenKey, ItemID.GreaterHealingPotion }; + List loot = new List() { ItemType(), ItemType(), ItemID.FrostCore, ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemType(), ItemID.FrozenKey, ItemID.GreaterHealingPotion }; List collection = new List() { ItemType(), ItemType(), ItemType() }; string instructions = $"Use a [i:{summon}] in the Snow Biome"; string despawn = CalamityUtils.ColorMessage("Cryogen drifts away, carried on a freezing wind.", new Color(0x00, 0xFF, 0xFF)); diff --git a/NPCs/AcidRain/AcidEel.cs b/NPCs/AcidRain/AcidEel.cs index d50512893d..1f25d972ac 100644 --- a/NPCs/AcidRain/AcidEel.cs +++ b/NPCs/AcidRain/AcidEel.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Materials; @@ -8,11 +9,13 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.StatDebuffs; + namespace CalamityMod.NPCs.AcidRain { public class AcidEel : ModNPC { + public Player Target => Main.player[npc.target]; + public ref float DirectionRedecideTimer => ref npc.ai[0]; public override void SetStaticDefaults() { DisplayName.SetDefault("Acid Eel"); @@ -35,7 +38,7 @@ namespace CalamityMod.NPCs.AcidRain { npc.DR_NERD(0.05f); npc.damage = 100; - npc.lifeMax = 6000; + npc.lifeMax = 3300; npc.defense = 20; npc.knockBackResist = 0.7f; } @@ -60,70 +63,15 @@ namespace CalamityMod.NPCs.AcidRain { npc.TargetClosest(false); + // Play a slither sound from time to time. if (Main.rand.NextBool(480)) - Main.PlaySound(SoundID.Zombie, npc.Center, 32); // Slither sound + Main.PlaySound(SoundID.Zombie, npc.Center, 32); - if (npc.ai[2] == 0f && !npc.wet) - { - npc.netUpdate = true; - npc.ai[2] = 1f; - } - if (npc.ai[2] == 1f && npc.wet) - { - npc.netUpdate = true; - npc.ai[2] = 0f; - } - - if (npc.ai[2] == 0f) - { - npc.ai[1] += 1f; - if (npc.ai[1] % 150f == 0f || npc.direction == 0) - { - npc.direction = (Main.player[npc.target].position.X > npc.position.X).ToDirectionInt(); - } - float acceleration = 0.3f; - float yAcceleration = 0.08f; - float maxSpeedX = 15f; - float maxSpeedY = 4f; - if (CalamityWorld.downedPolterghast) - { - acceleration = 0.6f; - yAcceleration = 0.15f; - maxSpeedX = 20f; - maxSpeedY = 7f; - } - npc.velocity.X += npc.direction * acceleration; - - if (npc.collideX) - npc.direction *= -1; - - npc.spriteDirection = npc.direction; - - npc.velocity.Y += (Main.player[npc.target].position.Y > npc.position.Y).ToDirectionInt() * yAcceleration; - if (npc.velocity.X > maxSpeedX) - { - npc.velocity.X = maxSpeedX; - npc.netUpdate = true; - } - if (npc.velocity.X < -maxSpeedX) - { - npc.velocity.X = -maxSpeedX; - npc.netUpdate = true; - } - if (npc.velocity.Y > maxSpeedY) - { - npc.velocity.Y = maxSpeedY; - npc.netUpdate = true; - } - if (npc.velocity.Y < -maxSpeedY) - { - npc.velocity.Y = -maxSpeedY; - npc.netUpdate = true; - } - npc.rotation = npc.velocity.X * 0.02f; - } + if (npc.wet) + SwimTowardsTarget(); else { + // Do nothing on land. npc.rotation = npc.rotation.AngleLerp(0f, 0.1f); npc.velocity.X *= 0.95f; if (npc.velocity.Y < 14f) @@ -131,6 +79,42 @@ namespace CalamityMod.NPCs.AcidRain } } + public void SwimTowardsTarget() + { + DirectionRedecideTimer++; + if (DirectionRedecideTimer % 150f == 0f || npc.direction == 0) + { + npc.direction = (Target.position.X > npc.position.X).ToDirectionInt(); + npc.netUpdate = true; + } + + float horizontalAcceleration = 0.3f; + float verticalAcceleration = 0.08f; + float maxSpeedX = 15f; + float maxSpeedY = 4f; + if (CalamityWorld.downedPolterghast) + { + horizontalAcceleration = 0.6f; + verticalAcceleration = 0.15f; + maxSpeedX = 20f; + maxSpeedY = 7f; + } + + npc.velocity.X += npc.direction * horizontalAcceleration; + + if (Main.netMode != NetmodeID.MultiplayerClient && npc.collideX) + { + npc.direction *= -1; + npc.netUpdate = true; + } + + npc.spriteDirection = npc.direction; + + npc.velocity.Y += (Target.position.Y > npc.position.Y).ToDirectionInt() * verticalAcceleration; + npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-maxSpeedX, -maxSpeedY), new Vector2(maxSpeedX, maxSpeedY)); + npc.rotation = npc.velocity.X * 0.02f; + } + public override void NPCLoot() { DropHelper.DropItemChance(npc, ModContent.ItemType(), 2 * (CalamityWorld.downedAquaticScourge ? 6 : 1), 1, 3); @@ -145,9 +129,7 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = 0; - } } } @@ -155,32 +137,23 @@ namespace CalamityMod.NPCs.AcidRain { CalamityGlobalNPC.DrawGlowmask(npc, spriteBatch, ModContent.GetTexture(Texture + "Glow")); if (npc.velocity.Length() > 1.5f) - { CalamityGlobalNPC.DrawAfterimage(npc, spriteBatch, drawColor, Color.Transparent, directioning: true); - } } public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 8; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/AcidEelGore"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/AcidEelGore2"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/AcidEelGore3"), npc.scale); for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/NPCs/AcidRain/CragmawMire.cs b/NPCs/AcidRain/CragmawMire.cs index 9d34066ccb..6920dfb8e9 100644 --- a/NPCs/AcidRain/CragmawMire.cs +++ b/NPCs/AcidRain/CragmawMire.cs @@ -17,6 +17,21 @@ namespace CalamityMod.NPCs.AcidRain { public class CragmawMire : ModNPC { + public Player Target => Main.player[npc.target]; + public ref float Time => ref npc.ai[0]; + public bool HasMadeShellBreakGore + { + get => npc.localAI[0] == 1f; + set => npc.localAI[0] = value.ToInt(); + } + public bool InPhase2 + { + get + { + float phase2CeilingRatio = CalamityWorld.revenge ? 0.85f : 0.7f; + return npc.life / (float)npc.lifeMax < phase2CeilingRatio && CalamityWorld.downedPolterghast; + } + } public override void SetStaticDefaults() { DisplayName.SetDefault("Cragmaw Mire"); @@ -38,7 +53,7 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { npc.damage = 160; - npc.lifeMax = 146600; + npc.lifeMax = 80630; npc.defense = 80; } @@ -50,41 +65,32 @@ namespace CalamityMod.NPCs.AcidRain npc.HitSound = SoundID.NPCHit1; npc.DeathSound = SoundID.NPCDeath1; } - public bool Phase2 - { - get - { - float ratio = CalamityWorld.revenge ? 0.85f : 0.7f; - return npc.life / (float)npc.lifeMax < ratio && CalamityWorld.downedPolterghast; - } - } + public override void AI() { + Time++; npc.TargetClosest(false); - Player player = Main.player[npc.target]; - - npc.ai[0]++; // Summons a spinning spiral of dust and a dust telegraph - if (npc.ai[0] % 420f > 240f && npc.ai[0] % 420f < 300f) + if (Time % 420f > 240f && Time % 420f < 300f) { - float vectorRotationAngle = (npc.ai[0] % 420f - 240f) / 60f * MathHelper.Pi * 4f; + float vectorRotationAngle = (Time % 420f - 240f) / 60f * MathHelper.Pi * 4f; for (int i = 0; i < 25; i++) { float angle = MathHelper.TwoPi * i / 25f; float y = (float)Math.Sin(angle) * (float)Math.Log(Math.Abs(Math.Cos(angle))); if (!float.IsNaN(y)) { - Vector2 velocity = new Vector2((float)Math.Cos(angle), y) * MathHelper.Lerp(2.4f, 4.2f, (npc.ai[0] - 240f) / 60f); + Vector2 velocity = new Vector2((float)Math.Cos(angle), y) * MathHelper.Lerp(2.4f, 4.2f, (Time - 240f) / 60f); Dust dust = Dust.NewDustPerfect(npc.Center, (int)CalamityDusts.SulfurousSeaAcid); dust.velocity = velocity.RotatedBy(vectorRotationAngle); dust.noGravity = true; - dust.scale = MathHelper.Lerp(1.2f, 2.5f, (npc.ai[0] - 240f) / 60f); + dust.scale = MathHelper.Lerp(1.2f, 2.5f, (Time - 240f) / 60f); } } - float length = MathHelper.Lerp(20f, 1200f, (npc.ai[0] % 420f - 240f) / 60f); - float outwardness = 1f - (npc.ai[0] % 420f - 240f) / 60f; + float length = MathHelper.Lerp(20f, 1200f, (Time % 420f - 240f) / 60f); + float outwardness = 1f - (Time % 420f - 240f) / 60f; for (float i = npc.Top.Y + 4f; i >= npc.Top.Y + 4f - length; i -= 6f) { float angle = i / 32f; @@ -96,18 +102,17 @@ namespace CalamityMod.NPCs.AcidRain dust.noGravity = true; } } - // Release a laser beam and create an explosion - if (npc.ai[0] % 420f == 300f) + + // Release a laser beam upward and create an explosion. + if (Time % 420f == 300f) { - npc.ai[1] = Main.rand.NextFloat(3f); - npc.ai[2] = Main.rand.NextFloat(4f); - npc.netUpdate = true; if (Main.netMode != NetmodeID.MultiplayerClient) { - Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 104); // Moon lord beam sound + Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 104); int damage = CalamityWorld.downedPolterghast ? 120 : 40; Projectile.NewProjectile(npc.Center, -Vector2.UnitY, ModContent.ProjectileType(), damage, 4f, Main.myPlayer, 0f, npc.whoAmI); } + Vector2 circlePointVector = -Vector2.UnitY; float lerpStart = Main.rand.Next(12, 16); float lerpEnd = Main.rand.Next(3, 6); @@ -134,133 +139,162 @@ namespace CalamityMod.NPCs.AcidRain circlePointVector = circlePointVector.RotatedBy(MathHelper.TwoPi / 9f); } } + npc.netUpdate = true; } - else if (npc.ai[0] % 420f > 300f && npc.ai[0] % 7f == 6f && CalamityWorld.downedPolterghast) + + // Release acid into the air. + else if (Time % 420f > 300f && Time % 7f == 6f && CalamityWorld.downedPolterghast) { if (Main.netMode != NetmodeID.MultiplayerClient) - { Projectile.NewProjectile(npc.Center, -Vector2.UnitY.RotatedByRandom(0.6f) * Main.rand.NextFloat(10f, 15f), ModContent.ProjectileType(), 69, 4f, Main.myPlayer, 0f, npc.whoAmI); - } } - if (!Phase2) - { - npc.Calamity().DR = 0.3f; - if (!player.wet) - npc.Calamity().DR = 0.5f; - npc.HitSound = SoundID.NPCHit42; - if (npc.ai[0] % 420f < 240f) - { - float bubbleShootTimer = CalamityWorld.downedPolterghast ? 24f : 50f; - if (npc.ai[0] % bubbleShootTimer == bubbleShootTimer - 1f && Main.netMode != NetmodeID.MultiplayerClient) - { - int damage = CalamityWorld.downedPolterghast ? 47 : 30; - int idx = Projectile.NewProjectile(npc.Top + new Vector2(0f, 5f), -Vector2.UnitY.RotatedByRandom(0.25f) * 4f, ModContent.ProjectileType(), damage, 1f); - Main.projectile[idx].timeLeft = Main.rand.Next(120, 180); - Main.projectile[idx].netUpdate = true; - } - if (npc.ai[0] % 50f == 49f && Main.rand.NextBool(4)) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - List possibleEnemies = new List(); - if (CalamityWorld.downedPolterghast) - { - possibleEnemies.Add(ModContent.NPCType()); - possibleEnemies.Add(ModContent.NPCType()); - possibleEnemies.Add(ModContent.NPCType()); - } - else - { - possibleEnemies.Add(ModContent.NPCType()); - possibleEnemies.Add(ModContent.NPCType()); - } - - Vector2 spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -360f, 360f); - int attempts = 0; - while (!WorldGen.InWorld((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16)) - { - spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -460f, 460f); - attempts++; - if (attempts > 200) - return; - } - attempts = 0; - - while (CalamityUtils.TileSelectionSolidSquare((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16, 8, 8) || - CalamityUtils.ParanoidTileRetrieval((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16).liquid != 255) - { - spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -620f, 620f); - attempts++; - if (attempts > 300) - return; - } - - NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, Utils.SelectRandom(Main.rand, possibleEnemies.ToArray())); - } - } - } - } + if (InPhase2) + DoPhase2AI(); else + DoPhase1AI(); + } + + public void DoPhase1AI() + { + // Become harder to damage to if the target is not in water. + npc.Calamity().DR = Target.wet ? 0.3f : 0.5f; + + // Use a rock-like hit sound. + npc.HitSound = SoundID.NPCHit42; + + if (Time % 420f < 240f) { - if (npc.localAI[0] == 0f) + float bubbleShootRate = CalamityWorld.downedPolterghast ? 24f : 50f; + if (Main.netMode != NetmodeID.MultiplayerClient && Time % bubbleShootRate == bubbleShootRate - 1f) { - Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore"), npc.scale); - Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore2"), npc.scale); - Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore3"), npc.scale); - npc.localAI[0] = 1f; - } - npc.Calamity().DR = CalamityWorld.revenge ? 0.125f : 0f; - npc.HitSound = SoundID.NPCHit1; - if (Main.netMode != NetmodeID.MultiplayerClient) - { - if (npc.ai[0] % 600f == 20f) + int damage = CalamityWorld.downedPolterghast ? 47 : 30; + Vector2 bubbleSpawnPosition = npc.Top + Vector2.UnitY * 5f; + Vector2 bubbleShootVelocity = -Vector2.UnitY.RotatedByRandom(0.25f) * 4f; + int bubble = Projectile.NewProjectile(bubbleSpawnPosition, bubbleShootVelocity, ModContent.ProjectileType(), damage, 1f); + + if (Main.projectile.IndexInRange(bubble)) { - Projectile.NewProjectile(npc.Center, Vector2.UnitY, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.target); + Main.projectile[bubble].timeLeft = Main.rand.Next(120, 180); + Main.projectile[bubble].netUpdate = true; } - if (npc.ai[0] % 600f == 240f) + } + + // Summon enemies from time to time. + if (Time % 50f == 49f && Main.rand.NextBool(4)) + { + List possibleEnemies = new List(); + if (CalamityWorld.downedPolterghast) { - int damage = CalamityWorld.downedPolterghast ? 52 : 33; - for (int i = 0; i < 16; i++) - { - float angle = MathHelper.TwoPi / 16f * i; - float angleDelta = Main.rand.NextFloat(MathHelper.TwoPi / 16f) * 0.6f; - angle += angleDelta - angleDelta / 2f; - Projectile.NewProjectile(npc.Center, angle.ToRotationVector2() * 6f, ModContent.ProjectileType(), damage, 4f); - } + possibleEnemies.Add(ModContent.NPCType()); + possibleEnemies.Add(ModContent.NPCType()); + possibleEnemies.Add(ModContent.NPCType()); + } + else + { + possibleEnemies.Add(ModContent.NPCType()); + possibleEnemies.Add(ModContent.NPCType()); + } + + SummonEnemyNearSelf(possibleEnemies); + } + } + } + + public void DoPhase2AI() + { + // Release shell gore the first frame this enemy is in the second phase. + if (!HasMadeShellBreakGore) + { + Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore"), npc.scale); + Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore2"), npc.scale); + Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP1Gore3"), npc.scale); + HasMadeShellBreakGore = true; + } + + // Have DR depend on the current mode. + npc.Calamity().DR = CalamityWorld.revenge ? 0.125f : 0f; + + // And use the squishy slime hit sound. + npc.HitSound = SoundID.NPCHit1; + + // Release a tether that attempts to grab the target and then release spikes upward a bit afterwards. + if (Main.netMode != NetmodeID.MultiplayerClient) + { + if (Time % 600f == 20f) + Projectile.NewProjectile(npc.Center, Vector2.UnitY, ModContent.ProjectileType(), 0, 0f, Main.myPlayer, npc.whoAmI, npc.target); + if (Time % 600f == 240f) + { + int damage = CalamityWorld.downedPolterghast ? 52 : 33; + for (int i = 0; i < 16; i++) + { + float shootDirectionAngle = MathHelper.TwoPi / 16f * i; + float offsetAngle = Main.rand.NextFloatDirection() * MathHelper.TwoPi / 27f; + shootDirectionAngle += offsetAngle; + Projectile.NewProjectile(npc.Center, shootDirectionAngle.ToRotationVector2() * 6f, ModContent.ProjectileType(), damage, 4f); } } } } + + public void SummonEnemyNearSelf(IList possibleEnemies) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + int attempts = 0; + Vector2 spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -360f, 360f); + + // Ensure that the potential spawn position is actually in the world. + while (!WorldGen.InWorld((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16)) + { + spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -460f, 460f); + attempts++; + if (attempts > 200) + return; + } + + attempts = 0; + + // As well as an open tile wiht water. + while (CalamityUtils.TileSelectionSolidSquare((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16, 8, 8) || + CalamityUtils.ParanoidTileRetrieval((int)spawnPosition.X / 16, (int)spawnPosition.Y / 16).liquid != 255) + { + spawnPosition = npc.Center + Utils.RandomVector2(Main.rand, -620f, 620f); + attempts++; + if (attempts > 300) + return; + } + + NPC.NewNPC((int)spawnPosition.X, (int)spawnPosition.Y, Main.rand.Next(possibleEnemies)); + } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); npc.damage = (int)(npc.damage * 0.85f); } + public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { - Texture2D texture = Phase2 ? ModContent.GetTexture("CalamityMod/NPCs/AcidRain/CragmawMire2") : ModContent.GetTexture("CalamityMod/NPCs/AcidRain/CragmawMire"); + Texture2D texture = InPhase2 ? ModContent.GetTexture("CalamityMod/NPCs/AcidRain/CragmawMire2") : ModContent.GetTexture("CalamityMod/NPCs/AcidRain/CragmawMire"); CalamityMod.DrawTexture(spriteBatch, texture, 0, npc, drawColor, true); return false; } + public override void FindFrame(int frameHeight) { npc.frameCounter++; if (npc.frameCounter % 6 == 5) - { npc.frame.Y += frameHeight; - } if (npc.frame.Y >= frameHeight * 2) - { npc.frame.Y = 0; - } } + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP2Gore"), npc.scale); @@ -268,10 +302,9 @@ namespace CalamityMod.NPCs.AcidRain Gore.NewGore(npc.position, -Vector2.UnitY.RotatedByRandom(0.4f) * 4f, mod.GetGoreSlot("Gores/AcidRain/CragmawMireP2Gore3"), npc.scale); } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } + + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 300); + public override void NPCLoot() { DropHelper.DropItemChance(npc, ModContent.ItemType(), CalamityWorld.downedPolterghast ? 0.1f : 1f); diff --git a/NPCs/AcidRain/FlakCrab.cs b/NPCs/AcidRain/FlakCrab.cs index a599bffc02..f02e6167ae 100644 --- a/NPCs/AcidRain/FlakCrab.cs +++ b/NPCs/AcidRain/FlakCrab.cs @@ -10,10 +10,19 @@ using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.AcidRain { public class FlakCrab : ModNPC { + public Player Target => Main.player[npc.target]; + public ref float ChasabilityTimer => ref npc.ai[0]; + public ref float AcidShootTimer => ref npc.ai[1]; + public ref float HopTimer => ref npc.ai[2]; + public ref float HopCounter => ref npc.ai[3]; + public ref float FleeCountdownTimer => ref npc.localAI[0]; + public ref float TotalHits => ref npc.localAI[1]; + public const int TotalHitsNeededToDoDamage = 10; public override void SetStaticDefaults() { DisplayName.SetDefault("Flak Crab"); @@ -32,7 +41,7 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { - npc.lifeMax = 7500; + npc.lifeMax = 4125; npc.DR_NERD(0.2f); } @@ -49,78 +58,69 @@ namespace CalamityMod.NPCs.AcidRain public override void SendExtraAI(BinaryWriter writer) { - writer.Write(npc.localAI[0]); - writer.Write(npc.localAI[1]); + writer.Write(FleeCountdownTimer); + writer.Write(TotalHits); } public override void ReceiveExtraAI(BinaryReader reader) { - npc.localAI[0] = reader.ReadSingle(); - npc.localAI[1] = reader.ReadSingle(); + FleeCountdownTimer = reader.ReadSingle(); + TotalHits = reader.ReadSingle(); } public override void AI() { - // Enables expert scaling, if damage is 0 in set defaults expert scaling will not happen + // Enables expert scaling, if damage is 0 in set defaults expert scaling will not happen. npc.damage = 0; - Player closest = Main.player[Player.FindClosest(npc.Top, 0, 0)]; - npc.ai[0]++; - npc.defense = npc.localAI[1] < 10f ? 999999 : 20; + ChasabilityTimer++; + npc.defense = TotalHits < TotalHitsNeededToDoDamage ? 999999 : 20; if (npc.justHit) { - npc.localAI[0] = 240; + FleeCountdownTimer = 240; npc.netUpdate = true; } - if (npc.localAI[0] == 0f || npc.localAI[1] < 10f) + + if (FleeCountdownTimer == 0f || TotalHits < TotalHitsNeededToDoDamage) { - if (npc.ai[0] < 300f) + if (ChasabilityTimer < 300f) { npc.chaseable = false; npc.knockBackResist = 0f; } - if (Math.Abs(closest.Center.X - npc.Center.X) < 320f && - closest.Center.Y - npc.Top.Y < -60f && - npc.ai[1]++ >= Main.rand.Next(90, 135)) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float speed = CalamityWorld.downedPolterghast ? 29f : 17f; - speed *= Main.rand.NextFloat(0.8f, 1.2f); - int damage = Main.expertMode ? CalamityWorld.downedPolterghast ? 32 : 18 : CalamityWorld.downedPolterghast ? 42 : 23; - Projectile.NewProjectile(npc.Top + Vector2.UnitY * 6f, npc.DirectionTo(closest.Center).RotatedByRandom(0.25f) * speed, - ModContent.ProjectileType(), damage, 2f); - npc.ai[1] = 0; - } - } + + AcidShootTimer++; + Player closestTargetToTop = Main.player[Player.FindClosest(npc.Top, 0, 0)]; + if (Math.Abs(closestTargetToTop.Center.X - npc.Center.X) < 320f && closestTargetToTop.Center.Y - npc.Top.Y < -60f && AcidShootTimer >= Main.rand.Next(90, 135)) + ShootFlakAcidAtTarget(closestTargetToTop); + npc.velocity.X *= 0.97f; } else { - npc.localAI[0]--; - npc.chaseable = true; + FleeCountdownTimer--; if (npc.velocity.Y == 0f) { + HopTimer++; npc.knockBackResist = 0.6f; npc.TargetClosest(true); npc.velocity.X *= 0.85f; - npc.ai[2]++; - float hopRate = 10f + 15f * (npc.life / (float)npc.lifeMax); + + float hopRate = MathHelper.Lerp(25f, 10f, 1f - npc.life / (float)npc.lifeMax); float lungeForwardSpeed = 10f; float jumpSpeed = 9f; - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { + if (Collision.CanHit(npc.Center, 1, 1, Target.Center, 1, 1)) lungeForwardSpeed *= 1.5f; - } - if (npc.ai[2] > hopRate) + + if (Main.netMode != NetmodeID.MultiplayerClient && HopTimer > hopRate) { - npc.ai[3] += 1f; - if (npc.ai[3] >= 3f) - { - npc.ai[3] = 0f; + HopCounter++; + + // Make a bigger leap every 3 hops. + if (HopCounter % 3f == 2f) lungeForwardSpeed *= 1.5f; - } - npc.ai[2] = 0f; + + HopTimer = 0f; npc.velocity.Y -= jumpSpeed; npc.velocity.X = lungeForwardSpeed * -npc.direction; npc.netUpdate = true; @@ -131,17 +131,34 @@ namespace CalamityMod.NPCs.AcidRain npc.knockBackResist = 0.2f; npc.velocity.X *= 0.995f; } - } - if (npc.ai[0] >= 300f && !npc.chaseable) - { npc.chaseable = true; } + + if (ChasabilityTimer >= 300f && !npc.chaseable) + npc.chaseable = true; + } + + public void ShootFlakAcidAtTarget(Player closestTargetToTop) + { + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + float speed = CalamityWorld.downedPolterghast ? 29f : 17f; + speed *= Main.rand.NextFloat(0.8f, 1.2f); + + int damage = Main.expertMode ? CalamityWorld.downedPolterghast ? 32 : 18 : CalamityWorld.downedPolterghast ? 42 : 23; + Vector2 spawnPosition = npc.Top + Vector2.UnitY * 6f; + Vector2 shootVelocity = (closestTargetToTop.Center - spawnPosition).SafeNormalize(Vector2.UnitY).RotatedByRandom(0.25f) * speed; + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), damage, 2f); + + AcidShootTimer = 0; + npc.netUpdate = true; } public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { - // Don't draw the bar if in stealth mode - if (npc.localAI[0] == 0f || npc.localAI[1] < 10f) + // Don't draw the bar if in stealth mode. + if (FleeCountdownTimer == 0f || TotalHits < TotalHitsNeededToDoDamage) return false; return null; } @@ -154,12 +171,13 @@ namespace CalamityMod.NPCs.AcidRain public override void FindFrame(int frameHeight) { - if (npc.localAI[1] < 10f) + if (TotalHits < TotalHitsNeededToDoDamage) { npc.frame.Y = 0; return; } - if (npc.localAI[0] > 0f) + + if (FleeCountdownTimer > 0f) { if (npc.frameCounter++ % 6 == 5) { @@ -169,13 +187,11 @@ namespace CalamityMod.NPCs.AcidRain { npc.frame.Y = frameHeight * 3; // Frames 1 and 2 are for transitioning. Frame 0 is sitting still, and the rest are walking frames } - if (npc.localAI[0] <= 8) + if (FleeCountdownTimer <= 8) npc.frame.Y = frameHeight; } else - { npc.frame.Y = 0; - } } public override void HitEffect(int hitDirection, double damage) @@ -194,7 +210,9 @@ namespace CalamityMod.NPCs.AcidRain Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FlakCrab2"), 1f); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/FlakCrab3"), 1f); } - npc.localAI[1]++; + + TotalHits++; + npc.netUpdate = true; } } } diff --git a/NPCs/AcidRain/GammaSlime.cs b/NPCs/AcidRain/GammaSlime.cs index 299cd55a6e..48873cc830 100644 --- a/NPCs/AcidRain/GammaSlime.cs +++ b/NPCs/AcidRain/GammaSlime.cs @@ -6,22 +6,22 @@ using CalamityMod.Projectiles.Enemy; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; -using System.Collections.Generic; -using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.AcidRain { - public abstract class CalamityBoss : ModNPC - { - public abstract List Loot { get; } - } - public class GammaSlime : ModNPC { - public float angularMultiplier1; - public float angularMultiplier2; + public float DustAngleMultiplier1; + public float DustAngleMultiplier2; + public Player Target => Main.player[npc.target]; + public float LaserTelegraphPower => Utils.InverseLerp(540f, 480f, LaserShootCountdown, true); + public float LaserTelegraphLength => MathHelper.Lerp(20f, 550f, LaserTelegraphPower); + public float LaserTelegraphOpacity => MathHelper.Lerp(0.3f, 0.9f, LaserTelegraphPower); + public ref float GammaAcidShootTimer => ref npc.ai[0]; + public ref float LaserShootCountdown => ref npc.ai[1]; public override void SetStaticDefaults() { @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.AcidRain npc.height = 44; npc.damage = 110; - npc.lifeMax = 9200; + npc.lifeMax = 5060; npc.DR_NERD(0.15f); npc.defense = 25; @@ -54,98 +54,95 @@ namespace CalamityMod.NPCs.AcidRain bannerItem = ModContent.ItemType(); } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(angularMultiplier1); - writer.Write(angularMultiplier2); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - angularMultiplier1 = reader.ReadSingle(); - angularMultiplier2 = reader.ReadSingle(); - } - public override void AI() { - Lighting.AddLight((int)((npc.position.X + (float)(npc.width / 2)) / 16f), (int)((npc.position.Y + (float)(npc.height / 2)) / 16f), 0.6f, 0.8f, 0.6f); + // Release green light at the position of the slime. + Lighting.AddLight((int)npc.Center.X / 16, (int)npc.Center.Y / 16, 0.6f, 0.8f, 0.6f); + npc.TargetClosest(false); - Player player = Main.player[npc.target]; - if (npc.velocity.Y == 0f && npc.ai[3] <= 0f && !player.npcTypeNoAggro[npc.type]) + + if (npc.velocity.Y == 0f && LaserShootCountdown <= 0f && !Target.npcTypeNoAggro[npc.type]) { npc.velocity.X *= 0.8f; - if (npc.ai[0]++ >= 30f) + + GammaAcidShootTimer++; + + // Jump into the air and release gamma acid upward. + if (GammaAcidShootTimer % 30f == 29f) { - npc.velocity.Y -= MathHelper.Clamp(Math.Abs(player.Center.Y - npc.Center.Y) / 16f, 5f, 15f); - npc.velocity.X = npc.DirectionTo(player.Center).X * 16f; - npc.ai[0] = 0f; - npc.ai[1]++; + npc.velocity.Y -= MathHelper.Clamp(Math.Abs(Target.Center.Y - npc.Center.Y) / 16f, 5f, 15f); + npc.velocity.X = npc.DirectionTo(Target.Center).X * 16f; + if (Main.netMode != NetmodeID.MultiplayerClient) { for (int i = 0; i < 5; i++) { - float angle = MathHelper.TwoPi / 5f * i + (npc.ai[1] % 2) * MathHelper.PiOver2; - Projectile.NewProjectile(npc.Center, angle.ToRotationVector2() * 7f, ModContent.ProjectileType(), - Main.expertMode ? 36 : 45, 3f); + float angle = MathHelper.TwoPi / 5f * i; + if (GammaAcidShootTimer % 60f == 58f) + angle += MathHelper.PiOver2; + Projectile.NewProjectile(npc.Center, angle.ToRotationVector2() * 7f, ModContent.ProjectileType(), Main.expertMode ? 36 : 45, 3f); } } npc.netUpdate = true; } } else - { npc.velocity.X *= 0.9935f; - } - if (npc.ai[3] > 0f) - npc.ai[3]--; - if (npc.ai[3] > 240f) + + if (LaserShootCountdown > 0f) + LaserShootCountdown--; + + // Stop moving for a bit after the laser. + if (LaserShootCountdown > 240f) { npc.velocity.X *= 0.95f; npc.velocity.Y += 0.2f; } + // Hold energy for laser - if (npc.ai[3] > 480f) + if (LaserShootCountdown > 480f) { - float scale = npc.ai[3] < 530 ? 2.25f : 1.65f; + float scale = LaserShootCountdown < 530f ? 2.25f : 1.65f; Vector2 destination = npc.Top + new Vector2(0f, 6f); - Dust dust = Dust.NewDustPerfect(destination + new Vector2(0f, 12f).RotatedByRandom(MathHelper.TwoPi), (int)CalamityDusts.SulfurousSeaAcid); + Dust dust = Dust.NewDustPerfect(destination + Main.rand.NextVector2CircularEdge(12f, 12f), (int)CalamityDusts.SulfurousSeaAcid); dust.velocity = Vector2.Normalize(destination - dust.position) * 3f; dust.scale = scale; dust.noGravity = true; - if (npc.ai[3] <= 540f) + + if (LaserShootCountdown <= 540f) { - float length = MathHelper.Lerp(20f, 550f, (npc.ai[3] - 480f) / 60f); - float outwardness = MathHelper.Lerp(1f, 0f, (npc.ai[3] - 480f) / 60f); - for (float i = npc.Top.Y + 4f; i >= npc.Top.Y + 4f - length; i -= 8f) + for (float i = npc.Top.Y + 4f; i >= npc.Top.Y + 4f - LaserTelegraphLength; i -= 8f) { float angle = i / 24f; Vector2 spawnPosition = new Vector2(npc.Center.X, i); dust = Dust.NewDustPerfect(spawnPosition, (int)CalamityDusts.SulfurousSeaAcid); dust.scale = 1.5f; - dust.velocity = Vector2.UnitX * (float)Math.Cos(angle) * 4f * outwardness; + dust.velocity = Vector2.UnitX * (float)Math.Cos(angle) * (1f - LaserTelegraphPower) * 4f; dust.noGravity = true; } } } - // Release laser - if (npc.ai[3] == 480f) + + // Release a gamma laser upward. + if (LaserShootCountdown == 480f) { - angularMultiplier1 = Main.rand.NextFloat(3f); - angularMultiplier2 = Main.rand.NextFloat(4f); - npc.netUpdate = true; + DustAngleMultiplier1 = Main.rand.NextFloat(3f); + DustAngleMultiplier2 = Main.rand.NextFloat(4f); if (Main.netMode != NetmodeID.MultiplayerClient) { - Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 104); // Moon lord beam sound + Main.PlaySound(SoundID.Zombie, (int)npc.position.X, (int)npc.position.Y, 104); Projectile.NewProjectile(npc.Center, -Vector2.UnitY, ModContent.ProjectileType(), Main.expertMode ? 96 : 120, 4f, Main.myPlayer, 0f, npc.whoAmI); } + npc.netUpdate = true; } + // Very complex particle effects while releasing the beam - else if (npc.ai[3] >= 300f) + else if (LaserShootCountdown >= 300f) { - float angle = (npc.ai[3] / 30f) % MathHelper.TwoPi; - float x = (float)Math.Sin(angle * angularMultiplier1) * (float)Math.Cos(angle); - float y = (float)Math.Cos(angle * angularMultiplier1) * (float)Math.Sin(angle); - Vector2 velocity = new Vector2(x * 4.5f, y * 2f); + float angle = LaserShootCountdown / 30f % MathHelper.TwoPi; + float horizontalSpeed = (float)Math.Sin(angle * DustAngleMultiplier1) * (float)Math.Cos(angle) * 4.5f; + float verticalSpeed = (float)Math.Cos(angle * DustAngleMultiplier1) * (float)Math.Sin(angle) * 2f; + Vector2 velocity = new Vector2(horizontalSpeed, verticalSpeed); Dust dust = Dust.NewDustPerfect(npc.Center + angle.ToRotationVector2() * 8f, (int)CalamityDusts.SulfurousSeaAcid); dust.velocity = velocity; dust.scale = (float)Math.Cos(angle) + 2f; @@ -156,12 +153,12 @@ namespace CalamityMod.NPCs.AcidRain dust.scale = (float)Math.Cos(angle) + 2f; dust.noGravity = true; } - if (Math.Abs(player.Center.X - npc.Center.X) < 250f && - player.Center.X - npc.Center.X < 0f && - npc.ai[3] == 0f && - Main.rand.NextBool(110) && !player.npcTypeNoAggro[npc.type]) + + // Randomly prepare to shoot a laser. + if (Main.netMode != NetmodeID.MultiplayerClient && Math.Abs(Target.Center.X - npc.Center.X) < 250f && Target.Center.X < npc.Center.X && + LaserShootCountdown == 0f && Main.rand.NextBool(110) && !Target.npcTypeNoAggro[npc.type]) { - npc.ai[3] = 600f; + LaserShootCountdown = 600f; npc.netUpdate = true; } } @@ -169,15 +166,11 @@ namespace CalamityMod.NPCs.AcidRain public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 10; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/GammaSlimeGore"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/GammaSlimeGore2"), npc.scale); } @@ -185,23 +178,17 @@ namespace CalamityMod.NPCs.AcidRain public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { - if (npc.ai[3] >= 480f && npc.ai[3] <= 540f) + if (LaserShootCountdown >= 480f && LaserShootCountdown <= 540f) { - float length = MathHelper.Lerp(20f, 550f, (npc.ai[3] - 480f) / 60f); - float opacity = MathHelper.Lerp(0.3f, 0.9f, (npc.ai[3] - 480f) / 60f); - Utils.DrawLine(spriteBatch, npc.Top + new Vector2(0f, 4f), npc.Top + new Vector2(0f, 4f) - Vector2.UnitY * length, Color.Lerp(Color.Lime, Color.Transparent, opacity)); + Vector2 laserBottom = npc.Top + Vector2.UnitY * 4f; + Vector2 laserTop = laserBottom - Vector2.UnitY * LaserTelegraphLength; + Utils.DrawLine(spriteBatch, laserBottom, laserTop, Color.Lerp(Color.Lime, Color.Transparent, LaserTelegraphOpacity)); } CalamityGlobalNPC.DrawGlowmask(npc, spriteBatch, ModContent.GetTexture(Texture + "Glow")); } - public override void NPCLoot() - { - DropHelper.DropItemChance(npc, ModContent.ItemType(), 30); - } + public override void NPCLoot() => DropHelper.DropItemChance(npc, ModContent.ItemType(), 30); - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 300); } } diff --git a/NPCs/AcidRain/NuclearTerror.cs b/NPCs/AcidRain/NuclearTerror.cs index 6d676ee1b2..94e3037136 100644 --- a/NPCs/AcidRain/NuclearTerror.cs +++ b/NPCs/AcidRain/NuclearTerror.cs @@ -15,15 +15,52 @@ namespace CalamityMod.NPCs.AcidRain { public class NuclearTerror : ModNPC { + public enum SpecialAttackState + { + DivergingBullets, + ConeStreamOfBullets, + ShotgunBurstOfBullets + } + public int AttackIndex = 0; public int DelayTime = 0; public bool Dying = false; public bool Walking = false; public float JumpTimer = 0f; public Vector2 ShootPosition; - public static readonly int[] PhaseArray = new int[] + public Player Target => Main.player[npc.target]; + public ref float AttackTime => ref npc.ai[0]; + public ref float TeleportCountdown => ref npc.ai[1]; + public Vector2 TeleportLocation + { + get => new Vector2(npc.ai[2], npc.ai[3]); + set + { + npc.ai[2] = value.X; + npc.ai[3] = value.Y; + } + } + public ref float HorizontalCollisionCounterDelay => ref npc.localAI[0]; + public ref float HorizontalCollisionSpamCounter => ref npc.localAI[1]; + public static readonly SpecialAttackState[] PhaseArray = new SpecialAttackState[] { - 2, 0, 1, 1, 2, 1, 0, 2, 1, 1, 0, 1, 2, 1, 0, 2, 1 + SpecialAttackState.ShotgunBurstOfBullets, + SpecialAttackState.DivergingBullets, + SpecialAttackState.ConeStreamOfBullets, + SpecialAttackState.ConeStreamOfBullets, + SpecialAttackState.ShotgunBurstOfBullets, + SpecialAttackState.ConeStreamOfBullets, + SpecialAttackState.DivergingBullets, + SpecialAttackState.ShotgunBurstOfBullets, + SpecialAttackState.ConeStreamOfBullets, + SpecialAttackState.ConeStreamOfBullets, + SpecialAttackState.DivergingBullets, + SpecialAttackState.ConeStreamOfBullets, + SpecialAttackState.ShotgunBurstOfBullets, + SpecialAttackState.ConeStreamOfBullets, + SpecialAttackState.DivergingBullets, + SpecialAttackState.ShotgunBurstOfBullets, + SpecialAttackState.ConeStreamOfBullets }; public const int AttackCycleTime = 520; public const int SpecialAttackTime = 240; @@ -46,7 +83,7 @@ namespace CalamityMod.NPCs.AcidRain npc.height = 138; npc.aiStyle = aiType = -1; - npc.lifeMax = 360420; + npc.lifeMax = 198230; npc.defense = 50; npc.knockBackResist = 0f; @@ -78,144 +115,109 @@ namespace CalamityMod.NPCs.AcidRain JumpTimer = reader.ReadSingle(); ShootPosition = reader.ReadVector2(); } + public override void AI() { Lighting.AddLight(npc.Center, (Dying ? Color.Lime.ToVector3() : Color.White.ToVector3()) * 2f); if (Dying) return; + bool phase2 = npc.life / (float)npc.lifeMax < 0.5f; if (DelayTime > 0) { DelayTime--; npc.velocity.X *= 0.9f; if (npc.velocity.Y < 18f) - { npc.velocity.Y += 0.35f; - } return; } + if (npc.target < 0 || npc.target >= 255 || Main.player[npc.target].dead || !Main.player[npc.target].active) { npc.TargetClosest(false); npc.netUpdate = true; } - if (npc.ai[1] > -TeleportCooldown) - { + + if (TeleportCountdown > -TeleportCooldown) TeleportEffects(); - } - Player player = Main.player[npc.target]; + npc.defDamage = 170; npc.damage = Dying ? 0 : npc.defDamage; - TeleportCheck(player); - npc.ai[0]++; + TeleportCheck(); + + AttackTime++; + float wrappedAttackTime = AttackTime % AttackCycleTime; + Walking = false; - // For teleporting if constantly spam-colliding + + // Teleport if spam-collisions are done, they are pretty good indicators of being stuck. if (npc.collideX) { - if (npc.localAI[0] > 0) - { - npc.localAI[1]++; - } - npc.localAI[0] = 20f; + if (HorizontalCollisionCounterDelay > 0) + HorizontalCollisionSpamCounter++; + HorizontalCollisionCounterDelay = 20f; } - if (npc.localAI[0] > 0) - { - npc.localAI[0]--; - } - if (npc.ai[0] % AttackCycleTime < 240f) + + if (HorizontalCollisionCounterDelay > 0) + HorizontalCollisionCounterDelay--; + + if (wrappedAttackTime < 240f) { if (npc.velocity.Y == 0f) { + JumpTimer++; npc.velocity.X *= 0.8f; - if (JumpTimer++ >= 70f || !Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height)) + + // Jump towards the target if enough time has passed or they're not in this enemy's line of sight. + if (JumpTimer >= 70f || !Collision.CanHit(npc.position, npc.width, npc.height, Target.position, Target.width, Target.height)) { - npc.velocity.Y -= MathHelper.Clamp(Math.Abs(player.Center.Y - npc.Center.Y) / 12.5f, 8f, 18f); - npc.velocity.X = npc.DirectionTo(player.Center).X * 18f; JumpTimer = 0f; + npc.velocity.Y -= MathHelper.Clamp(Math.Abs(Target.Center.Y - npc.Center.Y) / 12.5f, 8f, 18f); + npc.velocity.X = npc.DirectionTo(Target.Center).X * 18f; npc.netUpdate = true; } else { - bool wasWalking = Walking; - if (wasWalking != Math.Abs(npc.velocity.X) > 4f) + if (Walking != Math.Abs(npc.velocity.X) > 4f) { Walking = Math.Abs(npc.velocity.X) > 4f; npc.netUpdate = true; } + + // Force a jump the next frame to overcome any horizontal obstacles if they exist. if (npc.collideX) { - JumpTimer = 50; // Force a jump the next frame to overcome the obstacle + JumpTimer = 50; npc.netUpdate = true; } - else if (Math.Abs(player.Center.X - npc.Center.X) > 125f) + + // Otherwise walk towards the target if they're not super close. + else if (Math.Abs(Target.Center.X - npc.Center.X) > 125f) { - npc.velocity.X += Math.Sign(npc.DirectionTo(player.Center).X) * 3f; + npc.velocity.X += Math.Sign(npc.DirectionTo(Target.Center).X) * 3f; npc.velocity.X = MathHelper.Clamp(npc.velocity.X, -28f, 28f); } + + // If they are close though, slow down horizontally. else - { npc.velocity.X *= 0.99f; - } } } npc.spriteDirection = (npc.velocity.X < 0).ToDirectionInt(); } else { - if (npc.ai[0] % AttackCycleTime == 255f) + npc.velocity.X *= 0.96f; + if (wrappedAttackTime == 255f) { - ShootPosition = player.Center; + ShootPosition = Target.Center; npc.netUpdate = true; npc.spriteDirection = (ShootPosition.X - npc.Center.X < 0).ToDirectionInt(); } - switch (PhaseArray[AttackIndex]) - { - // Tightly packed, diverging bullets - case 0: - npc.velocity.X *= 0.9f; - if (((npc.ai[0] % AttackCycleTime >= AttackCycleTime - SpecialAttackTime + 20f && npc.ai[0] % AttackCycleTime <= AttackCycleTime - SpecialAttackTime + 32f) || - (npc.ai[0] % AttackCycleTime >= AttackCycleTime - SpecialAttackTime + 50f && npc.ai[0] % AttackCycleTime <= AttackCycleTime - SpecialAttackTime + 62f) || - (npc.ai[0] % AttackCycleTime >= AttackCycleTime - SpecialAttackTime + 80f && npc.ai[0] % AttackCycleTime <= AttackCycleTime - SpecialAttackTime + 92f) || - (npc.ai[0] % AttackCycleTime >= AttackCycleTime - SpecialAttackTime + 110f && npc.ai[0] % AttackCycleTime <= AttackCycleTime - SpecialAttackTime + 122f) || - (npc.ai[0] % AttackCycleTime >= AttackCycleTime - SpecialAttackTime + 140f && npc.ai[0] % AttackCycleTime <= AttackCycleTime - SpecialAttackTime + 152f)) && npc.ai[0] % 3f == 0f) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - float angle = (npc.ai[0] % AttackCycleTime - (AttackCycleTime - SpecialAttackTime + 20f)) % 12f / 12f * MathHelper.ToRadians(15f) - MathHelper.ToRadians(7.5f); - int idx = Projectile.NewProjectile(npc.Center, npc.DirectionTo(ShootPosition).RotatedBy(angle) * 14f, ModContent.ProjectileType(), 48, 4f); - Main.projectile[idx].localAI[0] = angle; - } - Main.PlaySound(SoundID.NPCDeath13, npc.Center); - } - if (npc.ai[0] % AttackCycleTime >= (AttackCycleTime - SpecialAttackTime + 35f) && npc.ai[0] % 10f == 9f) - { - Projectile.NewProjectile(npc.Center, npc.DirectionTo(player.Center) * 12f, ModContent.ProjectileType(), 48, 3f); - } - break; - // Cone of bullets - case 1: - npc.velocity.X *= 0.9f; - if (npc.ai[0] % AttackCycleTime >= AttackCycleTime - SpecialAttackTime + 35f && npc.ai[0] % 4f == 3f) - { - float angle = MathHelper.Lerp(MathHelper.ToRadians(35f), MathHelper.ToRadians(5f), (npc.ai[0] % AttackCycleTime - (AttackCycleTime - SpecialAttackTime + 35f)) / (SpecialAttackTime + 35f)); - Projectile.NewProjectile(npc.Center, npc.DirectionTo(player.Center).RotatedBy(angle) * 16f, ModContent.ProjectileType(), 48, 4.5f); - Projectile.NewProjectile(npc.Center, npc.DirectionTo(player.Center).RotatedBy(-angle) * 16f, ModContent.ProjectileType(), 48, 4.5f); - } - break; - // Shotgun bursts of bullets - case 2: - npc.velocity.X *= 0.9f; - if (npc.ai[0] % AttackCycleTime >= AttackCycleTime - SpecialAttackTime + 35f && npc.ai[0] % 20f == 19f) - { - for (int i = 0; i < 3; i++) - { - float angle = MathHelper.Lerp(-0.5f, 0.5f, i / 3f); - Projectile.NewProjectile(npc.Center, npc.DirectionTo(ShootPosition).RotatedBy(angle) * 13f, ModContent.ProjectileType(), 48, 4f); - } - } - break; - } - if (npc.ai[0] % AttackCycleTime == AttackCycleTime - 1f) + + PerformSpecialAttack(wrappedAttackTime); + + if (wrappedAttackTime == AttackCycleTime - 1f) { DelayTime = phase2 ? 45 : 75; AttackIndex++; @@ -223,83 +225,83 @@ namespace CalamityMod.NPCs.AcidRain } } } - public void TeleportCheck(Player player) + public void TeleportCheck() { - if (npc.ai[1] <= -TeleportCooldown) + float distanceFromTarget = npc.Distance(Target.Center); + bool targetIsFarOff = distanceFromTarget > 900f; + bool targetNotInLineOfSight = !Collision.CanHit(npc.position, npc.width, npc.height, Target.position, Target.width, Target.height); + if (TeleportCountdown <= -TeleportCooldown) { - if (npc.Distance(player.Center) > 2700f || - (!Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height) && npc.Distance(player.Center) > 900f) || - StuckOnPlatform(player) || - npc.wet || - npc.localAI[1] > 5f) + if (distanceFromTarget <= 2700f && !(targetIsFarOff && targetNotInLineOfSight) && !StuckOnPlatform() && !npc.wet && HorizontalCollisionSpamCounter <= 5f) + return; + + Point playerPositionTileCoords = Target.position.ToTileCoordinates(); + Point npcPositionTileCoords = npc.position.ToTileCoordinates(); + + for (int tries = 0; tries < 250; tries++) { - Point playerPositionTileCoords = player.position.ToTileCoordinates(); - Point npcPositionTileCoords = npc.position.ToTileCoordinates(); - int tries = 0; - int maxTeleportDistance = 20; - bool cannotTeleport = false; - while (!cannotTeleport && tries < 250) + int maxTeleportDistance = 30 + tries / 3; + int x = Main.rand.Next(playerPositionTileCoords.X - maxTeleportDistance, playerPositionTileCoords.X + maxTeleportDistance); + int yStart = Main.rand.Next(playerPositionTileCoords.Y - maxTeleportDistance, playerPositionTileCoords.Y + maxTeleportDistance); + + // Have a downward bias for the teleport if stuck on a platform above the target. + if (StuckOnPlatform()) + yStart = Main.rand.Next(playerPositionTileCoords.Y, playerPositionTileCoords.Y + maxTeleportDistance * 4); + + for (int y = yStart; y < playerPositionTileCoords.Y + maxTeleportDistance; y++) { - tries++; - int x = Main.rand.Next(playerPositionTileCoords.X - maxTeleportDistance, playerPositionTileCoords.X + maxTeleportDistance); - int yStart = Main.rand.Next(playerPositionTileCoords.Y - maxTeleportDistance, playerPositionTileCoords.Y + maxTeleportDistance); - if (StuckOnPlatform(player)) + Tile tileBelow = CalamityUtils.ParanoidTileRetrieval(x, y - 1); + bool veryCloseToTarget = Math.Abs(y - playerPositionTileCoords.Y) < 12 || Math.Abs(x - playerPositionTileCoords.X) < 12; + bool veryCloseToSelf = Math.Abs(y - npcPositionTileCoords.Y) < 12 || Math.Abs(x - npcPositionTileCoords.X) < 12; + bool solidGround = (Main.tileSolid[tileBelow.type] || Main.tileSolidTop[tileBelow.type]) && tileBelow.active(); + if (!veryCloseToTarget && !veryCloseToSelf && solidGround) { - yStart = Main.rand.Next(playerPositionTileCoords.Y, playerPositionTileCoords.Y + 4 * maxTeleportDistance); - } - for (int y = yStart; y < playerPositionTileCoords.Y + maxTeleportDistance; y++) - { - if ((y < playerPositionTileCoords.Y - 12 || y > playerPositionTileCoords.Y + 12 || x < playerPositionTileCoords.X - 12 || x > playerPositionTileCoords.X + 12) - && (y < npcPositionTileCoords.Y - 8 || y > npcPositionTileCoords.Y + 8 || x < npcPositionTileCoords.X - 7 || x > npcPositionTileCoords.X + 7) - && CalamityUtils.ParanoidTileRetrieval(x, y).nactive()) + // If the below tile has lava, skip it. + if (CalamityUtils.ParanoidTileRetrieval(x, y - 1).lava()) + continue; + + // If there's any tiles in the way, skip it. + if (Collision.SolidTiles(x - 12, x + 12, y - 7, y - 7)) + continue; + + // If there's any liquid near the tile, skip it. + for (int dy = y - 8; dy <= y + 8; dy++) { - bool canTeleport = true; - if (CalamityUtils.ParanoidTileRetrieval(x, y - 1).lava()) - { - canTeleport = false; - } - if (canTeleport && - Main.tileSolid[CalamityUtils.ParanoidTileRetrieval(x, y).type] && - !Collision.SolidTiles(x - 12, x + 12, y - 7, y - 7)) - { - for (int dy = y - 5; dy <= y; dy++) - { - if (CalamityUtils.ParanoidTileRetrieval(x, dy).liquid > 0) - { - continue; - } - } - npc.ai[1] = TeleportTime; - npc.ai[2] = x; - npc.ai[3] = y - 3; - cannotTeleport = true; - npc.localAI[1] = 0f; - break; - } + if (CalamityUtils.ParanoidTileRetrieval(x, dy).liquid > 0) + goto Continue; } + + TeleportCountdown = TeleportTime; + TeleportLocation = new Vector2(x, y - 6f); + HorizontalCollisionSpamCounter = 0f; + npc.netUpdate = true; + + return; + Continue: + continue; } } - npc.netUpdate = true; } } } + public void TeleportEffects() { - if (npc.ai[1] > TeleportTime) - npc.ai[1] = TeleportTime; - npc.ai[1]--; - if (npc.ai[1] >= 0f) + if (TeleportCountdown > TeleportTime) + TeleportCountdown = TeleportTime; + TeleportCountdown--; + if (TeleportCountdown >= 0f) { - if (npc.ai[1] == 0f && npc.ai[2] != 0f && npc.ai[3] != 0f) + if (TeleportCountdown == 0f && TeleportLocation != Vector2.Zero) { - npc.position.X = npc.ai[2] * 16f - npc.width / 2 + 8f; - npc.position.Y = npc.ai[3] * 16f - npc.height; + npc.position = TeleportLocation.ToWorldCoordinates(8f, 0f) - npc.Size; npc.netUpdate = true; npc.velocity = Vector2.Zero; } else { - npc.alpha = (int)MathHelper.Lerp(0f, 255f, 1f - npc.ai[1] / TeleportTime); + npc.Opacity = TeleportCountdown / TeleportTime; + int totalDust = (int)(30 * npc.alpha / 255f); for (int i = 0; i < totalDust; i++) { @@ -308,18 +310,20 @@ namespace CalamityMod.NPCs.AcidRain dust.velocity = npc.DirectionFrom(dust.position) * 2f; dust.scale = 1.6f; } + + // Fall and slow down horizontally. npc.velocity.X *= 0.95f; if (npc.velocity.Y < 18f) - { npc.velocity.Y += 0.35f; - } } return; } - else if (npc.ai[1] >= -TeleportFadeinTime) + + // Release some dust before going back to normal. + if (TeleportCountdown >= -TeleportFadeinTime) { - npc.alpha = (int)MathHelper.Lerp(255f, 0f, npc.ai[1] / -TeleportFadeinTime); - if (npc.ai[1] == -TeleportFadeinTime) + npc.Opacity = TeleportCountdown / -TeleportFadeinTime; + if (TeleportCountdown == -TeleportFadeinTime) { for (int i = 0; i < 48; i++) { @@ -331,16 +335,79 @@ namespace CalamityMod.NPCs.AcidRain } } } - public bool StuckOnPlatform(Player player) + + public bool StuckOnPlatform() { - for (int i = 0; i < 18; i++) + for (int i = -12; i < 12; i++) { Point bottom = (npc.Bottom + Vector2.UnitY * i).ToTileCoordinates(); - if (TileID.Sets.Platforms[CalamityUtils.ParanoidTileRetrieval(bottom.X, bottom.Y).type] && player.Top.Y > npc.Bottom.Y + 48) + if (TileID.Sets.Platforms[CalamityUtils.ParanoidTileRetrieval(bottom.X, bottom.Y).type] && Target.Top.Y > npc.Bottom.Y + 48) return true; } return false; } + + public void PerformSpecialAttack(float wrappedAttackTime) + { + Vector2 mouthPosition = npc.Center - Vector2.UnitY * 26f; + mouthPosition.X += npc.spriteDirection * -54f; + + TeleportCountdown = -TeleportCooldown; + Vector2 directionToTarget = (Target.Center - mouthPosition).SafeNormalize(Vector2.UnitX * npc.spriteDirection); + Vector2 directionToShootPosition = (ShootPosition - mouthPosition).SafeNormalize(Vector2.UnitX * npc.spriteDirection); + switch (PhaseArray[AttackIndex]) + { + case SpecialAttackState.DivergingBullets: + npc.velocity.X *= 0.9f; + float shootAdjustedTime = wrappedAttackTime - (AttackCycleTime - SpecialAttackTime); + bool shouldShoot = shootAdjustedTime >= 20f; + shouldShoot &= (shootAdjustedTime - 20f) % 30f < 12f; + shouldShoot &= shootAdjustedTime <= 152f; + shouldShoot &= shootAdjustedTime % 3f == 0f; + + if (shouldShoot) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float angle = (wrappedAttackTime - (AttackCycleTime - SpecialAttackTime + 20f)) % 12f / 12f * MathHelper.ToRadians(15f) - MathHelper.ToRadians(7.5f); + int bullet = Projectile.NewProjectile(mouthPosition, directionToShootPosition.RotatedBy(angle) * 14f, ModContent.ProjectileType(), 48, 4f); + Main.projectile[bullet].localAI[0] = angle; + } + npc.spriteDirection = (ShootPosition.X - npc.Center.X < 0).ToDirectionInt(); + Main.PlaySound(SoundID.NPCDeath13, mouthPosition); + } + if (wrappedAttackTime >= (AttackCycleTime - SpecialAttackTime + 35f) && AttackTime % 10f == 9f) + Projectile.NewProjectile(mouthPosition, directionToTarget * 12f, ModContent.ProjectileType(), 48, 3f); + break; + case SpecialAttackState.ConeStreamOfBullets: + if (wrappedAttackTime >= AttackCycleTime - SpecialAttackTime + 35f && AttackTime % 4f == 3f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + float angle = MathHelper.Lerp(MathHelper.ToRadians(35f), MathHelper.ToRadians(5f), (wrappedAttackTime - (AttackCycleTime - SpecialAttackTime + 35f)) / (SpecialAttackTime + 35f)); + Projectile.NewProjectile(mouthPosition, directionToTarget.RotatedBy(angle) * 16f, ModContent.ProjectileType(), 48, 4.5f); + Projectile.NewProjectile(mouthPosition, directionToTarget.RotatedBy(-angle) * 16f, ModContent.ProjectileType(), 48, 4.5f); + } + npc.spriteDirection = (Target.Center.X - npc.Center.X < 0).ToDirectionInt(); + } + break; + case SpecialAttackState.ShotgunBurstOfBullets: + if (wrappedAttackTime >= AttackCycleTime - SpecialAttackTime + 35f && AttackTime % 20f == 19f) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + for (int i = 0; i < 3; i++) + { + float angle = MathHelper.Lerp(-0.5f, 0.5f, i / 3f); + Projectile.NewProjectile(mouthPosition, directionToShootPosition.RotatedBy(angle) * 13f, ModContent.ProjectileType(), 48, 4f); + } + } + npc.spriteDirection = (ShootPosition.X - npc.Center.X < 0).ToDirectionInt(); + } + break; + } + } + public override void ScaleExpertStats(int numPlayers, float bossLifeScale) { npc.lifeMax = (int)(npc.lifeMax * 0.8f * bossLifeScale); @@ -349,12 +416,13 @@ namespace CalamityMod.NPCs.AcidRain public override void FindFrame(int frameHeight) { npc.frameCounter++; - int framesNeeded = Dying ? 7 : 6; + int frameChangeRate = Dying ? 7 : 6; + + // Walk faster the faster this thing is moving. if (Walking) - { - framesNeeded = 8 - (int)Math.Ceiling(Math.Abs(npc.velocity.X) / 5f); // Walk faster the faster we're moving - } - if (npc.frameCounter >= framesNeeded) + frameChangeRate = 8 - (int)Math.Ceiling(Math.Abs(npc.velocity.X) / 5f); + + if (npc.frameCounter >= frameChangeRate) { npc.frame.Y += frameHeight; npc.frameCounter = 0; @@ -382,14 +450,10 @@ namespace CalamityMod.NPCs.AcidRain npc.frame.Y = frameHeight * 8; } if (npc.frame.Y >= frameHeight * Main.npcFrameCount[npc.type]) - { npc.StrikeNPCNoInteraction(9999, 0f, 0); - } } else if (npc.frame.Y >= (Walking ? 8 : 4) * frameHeight) - { npc.frame.Y = Walking ? 4 * frameHeight : 0; - } } public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { @@ -402,31 +466,30 @@ namespace CalamityMod.NPCs.AcidRain } return false; } + public override bool CheckDead() { if (!Dying) { + Dying = true; npc.active = true; npc.life = 1; npc.dontTakeDamage = true; - Dying = true; npc.velocity = Vector2.Zero; npc.netUpdate = true; return false; } return Dying; } + public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 10; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } - } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); } + + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 300); + public override void NPCLoot() { DropHelper.DropItemChance(npc, ModContent.ItemType(), 3); diff --git a/NPCs/AcidRain/NuclearToad.cs b/NPCs/AcidRain/NuclearToad.cs index dcd092969a..d31261d687 100644 --- a/NPCs/AcidRain/NuclearToad.cs +++ b/NPCs/AcidRain/NuclearToad.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Projectiles.Enemy; using CalamityMod.Items.Placeables.Banners; @@ -7,11 +8,12 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.StatDebuffs; + namespace CalamityMod.NPCs.AcidRain { public class NuclearToad : ModNPC { + public Player Target => Main.player[npc.target]; public override void SetStaticDefaults() { DisplayName.SetDefault("Nuclear Toad"); @@ -33,7 +35,7 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { npc.damage = 80; - npc.lifeMax = 5000; + npc.lifeMax = 2750; npc.defense = 15; } else if (CalamityWorld.downedAquaticScourge) @@ -56,43 +58,39 @@ namespace CalamityMod.NPCs.AcidRain public override void AI() { npc.TargetClosest(false); - Player player = Main.player[npc.target]; - // Slow down over time on the X axis (to prevent endless sliding as a result of KB) + // Slow down over time on the X axis (to prevent endless sliding as a result of KB). npc.velocity.X *= 0.96f; - // Hover on the top of the water + // Bob on the top of the water. if (npc.wet) { if (npc.velocity.Y > 2f) - { npc.velocity.Y *= 0.9f; - } npc.velocity.Y -= 0.16f; if (npc.velocity.Y < -4f) - { npc.velocity.Y = -4f; - } } else { if (npc.velocity.Y < -2f) - { npc.velocity.Y *= 0.9f; - } npc.velocity.Y += 0.16f; if (npc.velocity.Y > 3f) - { npc.velocity.Y = 3f; - } npc.ai[0] = 5f; } + + // Make a frog croak sound from time to time. if (Main.rand.NextBool(480)) - Main.PlaySound(SoundID.Zombie, npc.Center, 13); // Ribbit sound + Main.PlaySound(SoundID.Zombie, npc.Center, 13); + float explodeDistance = CalamityWorld.downedAquaticScourge ? 295f : 195f; if (CalamityWorld.downedPolterghast) explodeDistance = 470f; - if (npc.Distance(player.Center) < explodeDistance) + + // Explode if a player gets too close. + if (npc.WithinRange(Target.Center, explodeDistance)) { if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -103,11 +101,9 @@ namespace CalamityMod.NPCs.AcidRain speed *= 1.8f; damage = Main.expertMode ? 36 : 45; } + for (int i = 0; i < 7; i++) - { - float angle = Main.rand.NextFloat(MathHelper.TwoPi); - Projectile.NewProjectile(npc.Center, angle.ToRotationVector2() * speed, ModContent.ProjectileType(), damage, 1f); - } + Projectile.NewProjectile(npc.Center, Main.rand.NextVector2CircularEdge(speed, speed), ModContent.ProjectileType(), damage, 1f); } Main.PlaySound(SoundID.DD2_KoboldExplosion, npc.Center); npc.life = 0; @@ -125,18 +121,15 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = 0; - } } } public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 8; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } + if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/NuclearToadGore1"), npc.scale); @@ -144,20 +137,12 @@ namespace CalamityMod.NPCs.AcidRain Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/NuclearToadGore3"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/NuclearToadGore4"), npc.scale); for (int i = 0; i < 25; i++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, Main.rand.NextFloat(-2f, 2f), -1f, 0, default, 1f); - } } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 300); - public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) - { - CalamityGlobalNPC.DrawGlowmask(npc, spriteBatch, ModContent.GetTexture(Texture + "Glow"), true); - } + public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) => CalamityGlobalNPC.DrawGlowmask(npc, spriteBatch, ModContent.GetTexture(Texture + "Glow"), true); } } diff --git a/NPCs/AcidRain/Orthocera.cs b/NPCs/AcidRain/Orthocera.cs index 0e34e7a0a5..8157990f5e 100644 --- a/NPCs/AcidRain/Orthocera.cs +++ b/NPCs/AcidRain/Orthocera.cs @@ -1,3 +1,4 @@ +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Materials; @@ -9,11 +10,24 @@ using Terraria; using Terraria.ID; using Terraria.ModLoader; using Microsoft.Xna.Framework; -using CalamityMod.Buffs.StatDebuffs; + namespace CalamityMod.NPCs.AcidRain { public class Orthocera : ModNPC { + public ref float FallDelay => ref npc.ai[0]; + public ref float Time => ref npc.ai[1]; + public ref float HorizontalSpeed => ref npc.ai[2]; + public bool PerformingJump + { + get => npc.ai[3] == 1f; + set + { + if (Main.netMode == NetmodeID.Server && value != PerformingJump) + npc.netUpdate = true; + npc.ai[3] = value.ToInt(); + } + } public override void SetStaticDefaults() { DisplayName.SetDefault("Orthocera"); @@ -34,7 +48,7 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { npc.damage = 120; - npc.lifeMax = 7000; + npc.lifeMax = 3850; npc.defense = 35; npc.DR_NERD(0.15f); } @@ -52,110 +66,116 @@ namespace CalamityMod.NPCs.AcidRain public override void AI() { + Time++; npc.TargetClosest(false); - npc.ai[1] += 1f; float maxSpeed = CalamityWorld.downedPolterghast ? 12.8f : 10.5f; - if (npc.target >= 0 && npc.target < 255) + if (!Main.player.IndexInRange(npc.target)) + return; + + Player player = Main.player[npc.target]; + + // Swim. + if (Time % 250f < 180f) { - Player player = Main.player[npc.target]; - // Swim - if (npc.ai[1] % 250f < 180f) + if (npc.wet) { - if (npc.wet) - { - // Reset so we can jum again. - npc.ai[3] = 0f; + // Reset to allow a jumps. + if (PerformingJump) + PerformingJump = false; - // Swim towards the player if we're not too close. - // If we're close, simply resume our current movement. - if (npc.Distance(player.Center) > 150f) + // Swim towards the player if we're not too close. + // If close, simply resume current movement. + if (!npc.WithinRange(player.Center, 150f)) + { + npc.velocity = (npc.velocity * 17f + npc.DirectionTo(player.Center) * maxSpeed) / 18f; + if (FallDelay != 12f) { - npc.velocity = (npc.velocity * 17f + npc.DirectionTo(player.Center) * maxSpeed) / 18f; - if (npc.ai[0] != 12f) - { - npc.ai[0] = 12f; - npc.netUpdate = true; - } + FallDelay = 12f; + npc.netUpdate = true; } - // Variable for X movement later. - // It seems to slow down for some dumb reason in the jump phase without this value - npc.ai[2] = npc.velocity.X; - - // Make sure the value isn't 0 since we're relying on multiplication - if (npc.ai[2] == 0f) - npc.ai[2] = 0.1f; - - if (Math.Abs(npc.ai[2]) < 7f) - npc.ai[2] = Math.Abs(npc.ai[2]) * 7f; - if (Math.Abs(npc.ai[2]) > 16f) - npc.ai[2] = Math.Abs(npc.ai[2]) * 16f; - npc.ai[2] = Math.Abs(npc.ai[2]) * (player.Center.X - npc.Center.X > 0).ToDirectionInt(); } + + // Store for horizontal movement for later. + // It seems to slow down for some dumb reason in the jump phase without this value. + HorizontalSpeed = npc.velocity.X; + + // Make sure the value isn't 0 since we're relying on multiplication + if (HorizontalSpeed == 0f) + HorizontalSpeed = 0.1f; + + if (Math.Abs(HorizontalSpeed) < 7f) + HorizontalSpeed = Math.Abs(HorizontalSpeed) * 7f; + if (Math.Abs(HorizontalSpeed) > 16f) + HorizontalSpeed = Math.Abs(HorizontalSpeed) * 16f; + HorizontalSpeed = Math.Abs(HorizontalSpeed) * (player.Center.X - npc.Center.X > 0).ToDirectionInt(); + } + else + { + if (FallDelay <= 0f) + npc.velocity.Y += 0.2f; else - { - if (npc.ai[0] <= 0f) - npc.velocity.Y += 0.2f; - else - npc.ai[0] -= 1f; - } - npc.direction = npc.spriteDirection = (npc.velocity.X > 0).ToDirectionInt(); + FallDelay--; } - // And jump/shoot - else if (npc.ai[1] % 220f > 180f) - { - float yAcceleration = CalamityWorld.downedPolterghast ? 0.07f : 0.05f; - if (npc.ai[1] % 220f < 200f) - { - npc.velocity.Y -= yAcceleration; - } - else - { - npc.velocity.Y += yAcceleration; - } - if (npc.ai[1] % 220f == 219f) - npc.ai[3] = 1f; - if (!npc.wet) - npc.velocity.X = npc.ai[2]; - } - // Don't jump mid-air - if (npc.ai[1] % 220f > 180f && npc.ai[3] == 1f) - { - npc.ai[1] = 0f; - npc.netUpdate = true; - } - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver4 + MathHelper.PiOver2 + MathHelper.Pi; - - if (npc.spriteDirection == -1) - npc.rotation -= MathHelper.PiOver2; - // If sitting on land, slow down and, if in the middle of a jump, release a stream of acid. - if (!npc.wet) - { - npc.velocity.X *= 0.92f; - // Spit out a stream of acid based on our rotation - if (npc.ai[1] % 220f == 195f) - { - float rotation = npc.rotation - MathHelper.Pi - MathHelper.PiOver2 - MathHelper.PiOver4; - if (npc.spriteDirection == -1) - rotation += MathHelper.PiOver2; - - int damage = CalamityWorld.downedPolterghast ? 40 : CalamityWorld.downedAquaticScourge ? 26 : 18; - if (Main.expertMode) - damage = (int)Math.Round(damage * 0.8); - - if (CalamityWorld.downedPolterghast) - { - for (int i = 0; i < 2; i++) - { - float angle = MathHelper.Lerp(-0.3f, 0.3f, i / 2f); - Projectile.NewProjectile(npc.Center, (rotation + angle).ToRotationVector2() * 10f, ModContent.ProjectileType(), damage, 2f); - } - } - Projectile.NewProjectile(npc.Center, rotation.ToRotationVector2() * 12f, ModContent.ProjectileType(), damage, 2f); - } - } - // Prevent yeeting into the sky at the speed of light - npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-maxSpeed), new Vector2(maxSpeed)); + npc.direction = npc.spriteDirection = (npc.velocity.X > 0).ToDirectionInt(); } + // And jump/shoot. + else if (Time % 220f > 180f) + { + float verticalAcceleration = CalamityWorld.downedPolterghast ? 0.07f : 0.05f; + if (Time % 220f < 200f) + npc.velocity.Y -= verticalAcceleration; + else + npc.velocity.Y += verticalAcceleration; + + if (Time % 220f == 219f) + PerformingJump = true; + if (!npc.wet) + npc.velocity.X = HorizontalSpeed; + } + + // Don't jump mid-air. + if (Time % 220f > 180f && PerformingJump) + { + Time = 0f; + npc.netUpdate = true; + } + + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver4 + MathHelper.PiOver2 + MathHelper.Pi; + + if (npc.spriteDirection == -1) + npc.rotation -= MathHelper.PiOver2; + + // If sitting on land, slow down and, if in the middle of a jump, release a stream of acid. + if (!npc.wet) + { + npc.velocity.X *= 0.92f; + + // Spit out a stream of acid based on the rotation of this NPC. + if (Main.netMode != NetmodeID.MultiplayerClient && Time % 220f == 195f) + { + float spitDirection = npc.rotation - MathHelper.TwoPi * 0.875f; + if (npc.spriteDirection == -1) + spitDirection += MathHelper.PiOver2; + + int damage = CalamityWorld.downedPolterghast ? 40 : CalamityWorld.downedAquaticScourge ? 26 : 18; + if (Main.expertMode) + damage = (int)Math.Round(damage * 0.8); + + // Spit two extra streams of acid at the target post-Polterghast. + if (CalamityWorld.downedPolterghast) + { + for (int i = 0; i < 2; i++) + { + float offsetAngle = MathHelper.Lerp(-0.3f, 0.3f, i / 2f); + Projectile.NewProjectile(npc.Center, (spitDirection + offsetAngle).ToRotationVector2() * 10f, ModContent.ProjectileType(), damage, 2f); + } + } + Projectile.NewProjectile(npc.Center, spitDirection.ToRotationVector2() * 12f, ModContent.ProjectileType(), damage, 2f); + } + } + + // Prevent yeeting into the sky at the speed of light. + npc.velocity = Vector2.Clamp(npc.velocity, new Vector2(-maxSpeed), new Vector2(maxSpeed)); } public override void NPCLoot() @@ -172,32 +192,23 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = 0; - } } } public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 5; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/OrthoceraGore"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/OrthoceraGore2"), npc.scale); for (int k = 0; k < 10; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, DustID.Blood, hitDirection, -1f, 0, default, 1f); - } } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/NPCs/AcidRain/Skyfin.cs b/NPCs/AcidRain/Skyfin.cs index 8eb2ff0767..45df423cec 100644 --- a/NPCs/AcidRain/Skyfin.cs +++ b/NPCs/AcidRain/Skyfin.cs @@ -2,6 +2,7 @@ using CalamityMod.Dusts; using CalamityMod.Items.Placeables.Banners; using CalamityMod.Items.Materials; using CalamityMod.Items.Weapons.Rogue; +using CalamityMod.Buffs.StatDebuffs; using CalamityMod.World; using Microsoft.Xna.Framework; using System; @@ -9,15 +10,20 @@ using System.IO; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.StatDebuffs; + namespace CalamityMod.NPCs.AcidRain { public class Skyfin : ModNPC { + public bool Flying = false; + public Player Target => Main.player[npc.target]; + public ref float Time => ref npc.ai[0]; + public ref float DiveTimer => ref npc.ai[1]; + public ref float HorizontalDiveSpeed => ref npc.ai[2]; + public ref float WaitBeforeFlyingMovement => ref npc.ai[3]; public const float DiveDelay = 120f; public const float DiveTime = 90f; - public const float TotalTime = DiveDelay + DiveTime; - public bool Flying = false; + public const float TotalDiveTime = DiveDelay + DiveTime; public override void SetStaticDefaults() { @@ -40,7 +46,7 @@ namespace CalamityMod.NPCs.AcidRain { npc.knockBackResist = 0.8f; npc.damage = 88; - npc.lifeMax = 5500; + npc.lifeMax = 3025; npc.defense = 18; npc.DR_NERD(0.05f); } @@ -60,163 +66,150 @@ namespace CalamityMod.NPCs.AcidRain bannerItem = ModContent.ItemType(); } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Flying); - } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(Flying); - public override void ReceiveExtraAI(BinaryReader reader) - { - Flying = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) => Flying = reader.ReadBoolean(); public override void AI() { npc.TargetClosest(false); - Player player = Main.player[npc.target]; - if (!Flying) - { - npc.ai[0] += 1f; - if (npc.ai[1] > 0f) - npc.ai[1] -= 1f; - if (npc.wet) - { - // Swim around, moving towards the player - bool canSwimToPlayer = Collision.CanHit(npc.position, npc.width, npc.height, player.position, player.width, player.height); - if (canSwimToPlayer) - { - if (npc.ai[0] % 55f == 54f) - { - float horizontalSchoolingSpeed = 9f; - if (CalamityWorld.downedAquaticScourge) - { - horizontalSchoolingSpeed = 15f; - } - if (CalamityWorld.downedPolterghast) - { - horizontalSchoolingSpeed = 24f; - } - npc.velocity = Vector2.UnitX * (player.Center.X - npc.Center.X > 0).ToDirectionInt() * horizontalSchoolingSpeed; - } - if ((Math.Abs(player.Center.Y - npc.Center.Y) > 50f && player.wet) || (!player.wet && npc.ai[1] <= 0f)) - { - float speedY = CalamityWorld.downedPolterghast ? 10f : 6f; - npc.velocity.Y = (player.Center.Y - npc.Center.Y > 0).ToDirectionInt() * speedY; - } - if (Math.Abs(npc.velocity.X) < 6f) - npc.velocity.X *= 1.04f; - } - else if (!canSwimToPlayer && Math.Abs(npc.velocity.Y) < 4f) - { - npc.velocity.Y *= 0.97f; - } - // Turn around if we hit a tile on the X axis - if (!canSwimToPlayer && npc.collideX) - { - npc.velocity.X *= -1f; - } - // Check if we can dive - if (player.Center.Y < npc.Top.Y - 10f && - npc.ai[1] <= 0f) - { - if (Main.rand.NextBool(10)) - { - npc.ai[1] = TotalTime; - } - npc.ai[2] = (player.Center.X - npc.Center.X > 0).ToDirectionInt() * 10f; - } - } - else + if (Flying) + FlyTowardsTarget(); + else + DoSwimMovement(); + int idealDirection = (npc.velocity.X > 0).ToDirectionInt(); + npc.direction = npc.spriteDirection = idealDirection; + if (idealDirection != npc.direction) + npc.netUpdate = true; + + npc.rotation = npc.velocity.ToRotation() + (npc.direction > 0).ToInt() * MathHelper.Pi; + } + + public void FlyTowardsTarget() + { + npc.noTileCollide = true; + Time++; + if (Time % 300f >= 180f) + { + // Rise upward. + if (Time % 300f <= 205f) + npc.velocity.Y = MathHelper.Lerp(npc.velocity.Y, -6.5f, 0.07f); + + // And fly towards the target. + if (Time % 300f == 235f) { - // Consistently update the enemy. - if (npc.ai[3] % 40f == 39f) - { - npc.netUpdate = true; - } - // Dive upward in an attempt to hit to the player - if (npc.ai[1] > TotalTime - DiveTime) - { - npc.velocity.X = npc.ai[2]; - if (npc.ai[1] > TotalTime - DiveTime * 0.5f) - { - float flySpeed = CalamityWorld.downedAquaticScourge ? 0.115f : 0.085f; - if (CalamityWorld.downedPolterghast) - { - flySpeed = 0.135f; - } - npc.velocity.Y -= flySpeed; - } - else - { - npc.ai[1] = TotalTime - DiveTime; - npc.velocity.Y += 0.2f; - } - } - else - { - // Don't fall too fast because of wings - npc.ai[1] = TotalTime - DiveTime; - npc.velocity.Y += 0.1f; - npc.ai[3]++; - if (npc.ai[3] > 420f) - { - npc.ai[0] = npc.ai[1] = npc.ai[2] = npc.ai[3] = 0f; - Flying = true; - npc.netUpdate = true; - } - } - } - // If sitting on land, rotate in a way that looks like we're stuck on the ground - if (!npc.wet) - { - npc.velocity.X *= 0.92f; + float chargeSpeed = 8f; + if (CalamityWorld.downedAquaticScourge) + chargeSpeed = 14f; + if (CalamityWorld.downedPolterghast) + chargeSpeed = 18f; + npc.velocity = npc.DirectionTo(Target.Center) * chargeSpeed; } } else { - npc.noTileCollide = true; - npc.ai[0]++; - if (npc.ai[0] % 300f >= 180f) + if (Math.Abs(Target.Center.X - npc.Center.X) > 320f) + npc.velocity.X = MathHelper.Lerp(npc.velocity.X, (Target.Center.X - npc.Center.X > 0).ToDirectionInt() * 10f, 0.05f); + if (Math.Abs(Target.Center.Y - npc.Center.Y) > 50f) + npc.velocity.Y = npc.DirectionTo(Target.Center).Y * 9f; + } + } + + public void DoSwimMovement() + { + Time++; + if (DiveTimer > 0f) + DiveTimer -= 1f; + if (npc.wet) + { + // Swim around, moving towards the player. + bool canSwimToPlayer = Collision.CanHit(npc.position, npc.width, npc.height, Target.position, Target.width, Target.height); + if (canSwimToPlayer) { - if (npc.ai[0] % 300f == 205f) + if (Time % 55f == 54f) { - npc.velocity.Y = -6.5f; - } - if (npc.ai[0] % 300f == 235f) - { - float chargeSpeed = 8f; + float horizontalSchoolingSpeed = 9f; if (CalamityWorld.downedAquaticScourge) - { - chargeSpeed = 14f; - } + horizontalSchoolingSpeed = 15f; if (CalamityWorld.downedPolterghast) - { - chargeSpeed = 18f; - } - npc.velocity = npc.DirectionTo(player.Center) * chargeSpeed; + horizontalSchoolingSpeed = 24f; + npc.velocity = Vector2.UnitX * (Target.Center.X - npc.Center.X > 0).ToDirectionInt() * horizontalSchoolingSpeed; + } + if ((Math.Abs(Target.Center.Y - npc.Center.Y) > 50f && Target.wet) || (!Target.wet && DiveTimer <= 0f)) + { + float verticalSwimSpeed = CalamityWorld.downedPolterghast ? 10f : 6f; + npc.velocity.Y = (Target.Center.Y - npc.Center.Y > 0).ToDirectionInt() * verticalSwimSpeed; + } + + // Speed up if there is little horizontal movement. + if (Math.Abs(npc.velocity.X) < 6f) + npc.velocity.X *= 1.04f; + } + + // Slow down increasingly vertically if it's already low. + else if (!canSwimToPlayer && Math.Abs(npc.velocity.Y) < 4f) + npc.velocity.Y *= 0.97f; + + // Turn around if we hit a tile on the X axis + if (!canSwimToPlayer && npc.collideX) + npc.velocity.X *= -1f; + + // Check if a dive is possible. + if (Target.Center.Y < npc.Top.Y - 10f && DiveTimer <= 0f) + { + if (Main.netMode != NetmodeID.MultiplayerClient && Main.rand.NextBool(10)) + { + DiveTimer = TotalDiveTime; + npc.netUpdate = true; + } + + HorizontalDiveSpeed = (Target.Center.X - npc.Center.X > 0).ToDirectionInt() * 10f; + } + } + else + { + // Dive upward in an attempt to hit to the player. + if (DiveTimer > TotalDiveTime - DiveTime) + { + npc.velocity.X = HorizontalDiveSpeed; + if (DiveTimer > TotalDiveTime - DiveTime * 0.5f) + { + float upwardDiveSpeed = CalamityWorld.downedAquaticScourge ? 0.115f : 0.085f; + if (CalamityWorld.downedPolterghast) + upwardDiveSpeed = 0.135f; + npc.velocity.Y -= upwardDiveSpeed; + } + else + { + DiveTimer = TotalDiveTime - DiveTime; + npc.velocity.Y += 0.2f; } } else { - if (Math.Abs(player.Center.X - npc.Center.X) > 320f) + // Don't fall too fast because of wings + DiveTimer = TotalDiveTime - DiveTime; + npc.velocity.Y += 0.1f; + WaitBeforeFlyingMovement++; + + // Consistently sync the enemy. + if (WaitBeforeFlyingMovement % 40f == 39f) + npc.netUpdate = true; + + if (WaitBeforeFlyingMovement > 180f) { - npc.velocity.X = MathHelper.Lerp(npc.velocity.X, (player.Center.X - npc.Center.X > 0).ToDirectionInt() * 10f, 0.05f); - } - if (Math.Abs(player.Center.Y - npc.Center.Y) > 50f) - { - npc.velocity.Y = npc.DirectionTo(player.Center).Y * 9f; + Time = DiveTimer = HorizontalDiveSpeed = WaitBeforeFlyingMovement = 0f; + Flying = true; + npc.netUpdate = true; } } } - int idealDirection = (npc.velocity.X > 0).ToDirectionInt(); - npc.direction = npc.spriteDirection = idealDirection; - if (idealDirection != npc.direction) + // If sitting on land, rotate in a way that looks like we're stuck on the ground + if (!npc.wet) { - npc.netUpdate = true; + npc.velocity.X *= 0.92f; } - npc.rotation = npc.velocity.ToRotation() + - (npc.direction > 0).ToInt() * MathHelper.Pi; } public override void FindFrame(int frameHeight) @@ -227,9 +220,7 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = 0; - } } } @@ -242,24 +233,17 @@ namespace CalamityMod.NPCs.AcidRain public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 8; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } if (npc.life <= 0) { Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/SkyfinGore"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/SkyfinGore2"), npc.scale); Gore.NewGore(npc.position, npc.velocity, mod.GetGoreSlot("Gores/AcidRain/SkyfinGore3"), npc.scale); for (int k = 0; k < 20; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } } } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 180); - } + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 180); } } diff --git a/NPCs/AcidRain/SulfurousSkater.cs b/NPCs/AcidRain/SulfurousSkater.cs index 2847e6cea1..930d5fdc27 100644 --- a/NPCs/AcidRain/SulfurousSkater.cs +++ b/NPCs/AcidRain/SulfurousSkater.cs @@ -18,6 +18,8 @@ namespace CalamityMod.NPCs.AcidRain public class SulfurousSkater : ModNPC { public bool Flying = false; + public Player Target => Main.player[npc.target]; + public ref float JumpTimer => ref npc.ai[0]; public override void SetStaticDefaults() { @@ -27,15 +29,9 @@ namespace CalamityMod.NPCs.AcidRain NPCID.Sets.TrailCacheLength[npc.type] = 6; } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(Flying); - } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(Flying); - public override void ReceiveExtraAI(BinaryReader reader) - { - Flying = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) => Flying = reader.ReadBoolean(); public override void SetDefaults() { @@ -49,7 +45,7 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { npc.damage = 85; - npc.lifeMax = 7000; + npc.lifeMax = 3850; npc.defense = 15; } @@ -69,102 +65,119 @@ namespace CalamityMod.NPCs.AcidRain public override void AI() { npc.TargetClosest(false); - Player player = Main.player[npc.target]; if (!Flying) + JumpToDestination(); + else + DoFlyMovement(); + } + + public void JumpToDestination() + { + npc.knockBackResist = 0.8f; + npc.DR_NERD(0.35f); + npc.noGravity = false; + Projectile closestBubble = SearchForNearestBubble(out float distanceToBubbele); + + Vector2 destination = Target.Center; + + // Jump towards any nearby bubbles if they exist. + if (closestBubble != null) + destination = closestBubble.Center; + + // Stay on water instead of falling into it + if (npc.wet && npc.velocity.Y >= 0f) + npc.velocity.Y = -3f; + + // If close to the bubble, try to fall onto it. + if (closestBubble != null && distanceToBubbele < 200f) { - npc.knockBackResist = 0.8f; - npc.DR_NERD(0.35f); - npc.noGravity = false; - float minimumDistance = float.PositiveInfinity; - Projectile closestBubble = null; - for (int i = 0; i < Main.npc.Length; i++) - { - if (Main.projectile[i].type == ModContent.ProjectileType() && Main.projectile[i].active) - { - if (Math.Abs(npc.Center.X - Main.projectile[i].Center.X) < minimumDistance && - Collision.CanHit(npc.position, npc.width, npc.height, Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height) && - Main.projectile[i].Center.Y > npc.Bottom.Y) - { - minimumDistance = npc.Distance(Main.projectile[i].Center); - closestBubble = Main.projectile[i]; - } - } - } - if (minimumDistance >= 2400f) - { - closestBubble = null; - } + npc.velocity.Y += 0.2f; - Vector2 destination = player.Center; - - if (closestBubble != null) + if (closestBubble.Hitbox.Intersects(npc.Hitbox)) { - destination = closestBubble.Center; - } - // Stay on water instead of falling into it - if (npc.wet) - { - if (npc.velocity.Y >= 0f) - { - npc.velocity.Y = -3f; - } - } - - if (closestBubble != null && minimumDistance < 200f) - { - npc.velocity.Y += 0.2f; - - if (closestBubble.Hitbox.Intersects(npc.Hitbox)) - { - Flying = true; - closestBubble.Kill(); - npc.netSpam = 0; - npc.netUpdate = true; - } - } - if (npc.velocity.Y == 0f || npc.wet) - { - npc.TargetClosest(false); - npc.velocity.X *= 0.85f; - npc.ai[1]++; - float lungeForwardSpeed = 15f; - float jumpSpeed = 4f; - if (Collision.CanHit(npc.Center, 1, 1, Main.player[npc.target].Center, 1, 1)) - { - lungeForwardSpeed *= 1.2f; - } - if (npc.ai[1] >= 17) - { - npc.ai[1] = 0f; - npc.velocity.Y -= jumpSpeed; - npc.velocity.X = lungeForwardSpeed * (npc.Center.X - destination.X < 0).ToDirectionInt(); - npc.spriteDirection = (npc.Center.X - destination.X > 0).ToDirectionInt(); - npc.netSpam = 0; - npc.netUpdate = true; - } - } - else - { - npc.knockBackResist = 0f; + Flying = true; + npc.netSpam = 0; + npc.netUpdate = true; + closestBubble.Kill(); } } - else + + // Wait for a small amount of time and jump if there is little motion. + if (npc.velocity.Y == 0f || npc.wet) { - npc.knockBackResist = 0.5f; - npc.DR_NERD(0f); - float speed = CalamityWorld.downedPolterghast ? 17f : 14f; - float inertia = CalamityWorld.downedPolterghast ? 20f : 24.5f; - if (npc.Distance(player.Center) < 200f) - inertia *= 0.667f; - npc.velocity = (npc.velocity * inertia + npc.DirectionTo(player.Center) * speed) / (inertia + 1f); - npc.spriteDirection = (npc.velocity.X < 0).ToDirectionInt(); - if (npc.Distance(player.Center) < player.Size.Length()) + npc.TargetClosest(false); + + // Rapidly zero out horizontal movement. + npc.velocity.X *= 0.85f; + + JumpTimer++; + float lungeForwardSpeed = 15f; + float jumpSpeed = 4f; + if (Collision.CanHit(npc.Center, 1, 1, Target.Center, 1, 1)) + lungeForwardSpeed *= 1.2f; + + // Jump after a short amount of time. + if (JumpTimer >= 17) { - Flying = false; + JumpTimer = 0f; + npc.velocity.Y -= jumpSpeed; + npc.velocity.X = lungeForwardSpeed * (npc.Center.X - destination.X < 0).ToDirectionInt(); + npc.spriteDirection = (npc.Center.X - destination.X > 0).ToDirectionInt(); npc.netSpam = 0; npc.netUpdate = true; } } + else + npc.knockBackResist = 0f; + } + + public void DoFlyMovement() + { + npc.knockBackResist = 0.5f; + npc.DR_NERD(0f); + + float flySpeed = CalamityWorld.downedPolterghast ? 17f : 14f; + float flyInertia = CalamityWorld.downedPolterghast ? 20f : 24.5f; + + // Fly more sharply if close to the target. + if (npc.WithinRange(Target.Center, 200f)) + flyInertia *= 0.667f; + npc.velocity = (npc.velocity * flyInertia + npc.DirectionTo(Target.Center) * flySpeed) / (flyInertia + 1f); + npc.spriteDirection = (npc.velocity.X < 0).ToDirectionInt(); + + // Have the bubble pop and stop flying if within the circular hitbox area of the player. + if (npc.WithinRange(Target.Center, Target.Size.Length())) + { + Flying = false; + npc.netSpam = 0; + npc.netUpdate = true; + } + } + + public Projectile SearchForNearestBubble(out float distanceToBubble) + { + int bubbleType = ModContent.ProjectileType(); + float minimumDistance = 2400f; + Projectile closestBubble = null; + + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (Main.projectile[i].type != bubbleType || !Main.projectile[i].active) + continue; + + if (Math.Abs(npc.Center.X - Main.projectile[i].Center.X) >= minimumDistance || + Main.projectile[i].Center.Y <= npc.Bottom.Y || + !Collision.CanHit(npc.position, npc.width, npc.height, Main.projectile[i].position, Main.projectile[i].width, Main.projectile[i].height)) + { + continue; + } + + minimumDistance = npc.Distance(Main.projectile[i].Center); + closestBubble = Main.projectile[i]; + } + + distanceToBubble = minimumDistance; + return closestBubble; } public override void FindFrame(int frameHeight) @@ -179,9 +192,7 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = frameHeight; - } } } } @@ -212,9 +223,6 @@ namespace CalamityMod.NPCs.AcidRain DropHelper.DropItemChance(npc, ModContent.ItemType(), 20); } - public override void OnHitPlayer(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } + public override void OnHitPlayer(Player target, int damage, bool crit) => target.AddBuff(ModContent.BuffType(), 120); } } diff --git a/NPCs/AcidRain/Trilobite.cs b/NPCs/AcidRain/Trilobite.cs index ee1f397bdb..86cc206618 100644 --- a/NPCs/AcidRain/Trilobite.cs +++ b/NPCs/AcidRain/Trilobite.cs @@ -14,9 +14,9 @@ namespace CalamityMod.NPCs.AcidRain { public class Trilobite : ModNPC { - // When the abs(velocity) is less than this, lunge in the water + public Player Target => Main.player[npc.target]; + public ref float SpikeShootCountdown => ref npc.ai[0]; public const float MinSpeedLungePrompt = 0.5f; - public const float MinYDriftSpeed = 0.9f; public override void SetStaticDefaults() { @@ -40,7 +40,7 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { npc.damage = 80; - npc.lifeMax = 7500; + npc.lifeMax = 4125; npc.defense = 30; } @@ -60,68 +60,71 @@ namespace CalamityMod.NPCs.AcidRain npc.TargetClosest(false); if (!npc.wet) { - if (npc.ai[0] > 0) - npc.ai[0]--; - npc.rotation += npc.velocity.X * 0.1f; - if (npc.velocity.Y == 0f) + GetStuckOnLand(); + return; + } + + // If this NPC doesn't have enough momentum, lunge towards its target. + if (npc.velocity.Length() < MinSpeedLungePrompt) + { + npc.TargetClosest(); + float lungeSpeed = CalamityWorld.downedPolterghast ? 18.5f : 15f; + + npc.velocity = npc.DirectionTo(Target.Center) * lungeSpeed; + npc.velocity.X *= 1.6f; + npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; + npc.netUpdate = true; + return; + } + + // Accelerate quickly through the water horizontally. + if (Math.Abs(npc.velocity.X) < 20f) + npc.velocity.X += npc.direction * 0.02f; + + npc.rotation = npc.velocity.X * 0.4f; + + // Slow down in terms of horizontal speed if there is little vertical speed. + if (Math.Abs(npc.velocity.Y) < 0.9f) + npc.velocity.X *= 0.96f; + + // Lunge towards the target if there is little horizontal speed but also a little bit of vertical speed. + else if (Main.netMode != NetmodeID.MultiplayerClient && Math.Abs(npc.velocity.X) < 3.5f) + { + float speedX = 18f; + float speedY = 9f; + if (CalamityWorld.downedPolterghast) { - npc.velocity.X *= 0.99f; - if (Math.Abs(npc.velocity.X) < 0.01f) - { - npc.velocity.X = 0f; - } - npc.netUpdate = true; - } - npc.velocity.Y += 0.3f; - if (npc.velocity.Y > 13f) - { - npc.velocity.Y = 13f; - npc.netUpdate = true; + speedX = 22f; + speedY = 11f; } + npc.velocity = npc.DirectionTo(Target.Center) * new Vector2(speedX, speedY); + npc.netUpdate = true; + } + npc.velocity.Y *= 0.98f; + } + + public void GetStuckOnLand() + { + if (SpikeShootCountdown > 0) + SpikeShootCountdown--; + npc.rotation += npc.velocity.X * 0.1f; + + // If not moving vertically, slow down hotizontally. + if (npc.velocity.Y == 0f) + { + npc.velocity.X *= 0.99f; + if (Math.Abs(npc.velocity.X) < 0.01f) + npc.velocity.X = 0f; + } + + // Fall and cap the vertical speed. + if (npc.velocity.Y > 13f) + { + npc.velocity.Y = 13f; + npc.netUpdate = true; } else - { - Player player = Main.player[npc.target]; - if (npc.velocity.Length() < MinSpeedLungePrompt) - { - npc.TargetClosest(true); - float speed = 15f; - if (CalamityWorld.downedPolterghast) - { - speed = 18.5f; - } - - npc.velocity = npc.DirectionTo(player.Center) * speed; - npc.velocity.X *= 1.6f; - npc.rotation = npc.velocity.ToRotation() + MathHelper.PiOver2; - npc.netUpdate = true; - } - else - { - if (Math.Abs(npc.velocity.X) < 20f) - { - npc.velocity.X += npc.direction * 0.02f; - } - npc.rotation = npc.velocity.X * 0.4f; - if (Math.Abs(npc.velocity.Y) < MinYDriftSpeed) - { - npc.velocity.X *= 0.96f; - } - else if (Math.Abs(npc.velocity.X) < 3.5f) - { - float speedX = 18f; - float speedY = 9f; - if (CalamityWorld.downedPolterghast) - { - speedX = 22f; - speedY = 11f; - } - npc.velocity = npc.DirectionTo(player.Center) * new Vector2(speedX, speedY); - npc.netUpdate = true; - } - npc.velocity.Y *= 0.98f; - } - } + npc.velocity.Y += 0.3f; } public override void NPCLoot() @@ -132,28 +135,23 @@ namespace CalamityMod.NPCs.AcidRain public override void PostDraw(SpriteBatch spriteBatch, Color drawColor) { if (npc.velocity.Length() > 0.5f) - { CalamityGlobalNPC.DrawAfterimage(npc, spriteBatch, drawColor, Color.Transparent, directioning: true); - } } public override void ModifyHitByProjectile(Projectile projectile, ref int damage, ref float knockback, ref bool crit, ref int hitDirection) { - if (Main.netMode != NetmodeID.MultiplayerClient) + // No need for a netmode check- this code is only called by 1 client, the owner of the projectile that hit the NPC. + if (SpikeShootCountdown <= 0f) { - if (npc.ai[0] <= 0f) - { - Main.PlaySound(SoundID.NPCDeath11, npc.Center); - int projDamage = CalamityWorld.downedPolterghast ? 35 : CalamityWorld.downedAquaticScourge ? 29 : 21; - if (Main.expertMode) - projDamage = (int)Math.Round(projDamage * 0.8); + Main.PlaySound(SoundID.NPCDeath11, npc.Center); + int projDamage = CalamityWorld.downedPolterghast ? 35 : CalamityWorld.downedAquaticScourge ? 29 : 21; + if (Main.expertMode) + projDamage = (int)Math.Round(projDamage * 0.8); - Projectile.NewProjectile(npc.Center + Utils.NextVector2Unit(Main.rand) * npc.Size * 0.7f, - -npc.velocity.RotatedByRandom(MathHelper.ToRadians(10f)), ModContent.ProjectileType(), - projDamage, 3f); - npc.ai[0] = Main.rand.Next(50, 65); - npc.netUpdate = true; - } + Vector2 spikeVelocity = -npc.velocity.RotatedByRandom(0.18f); + Projectile.NewProjectile(npc.Center + Main.rand.NextVector2Unit() * npc.Size * 0.7f, spikeVelocity, ModContent.ProjectileType(), projDamage, 3f); + SpikeShootCountdown = Main.rand.Next(50, 65); + npc.netUpdate = true; } } @@ -165,9 +163,7 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = 0; - } } } diff --git a/NPCs/AcidRain/WaterLeech.cs b/NPCs/AcidRain/WaterLeech.cs index 55e1ac8611..c6f5ae2a28 100644 --- a/NPCs/AcidRain/WaterLeech.cs +++ b/NPCs/AcidRain/WaterLeech.cs @@ -6,7 +6,6 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; -using CalamityMod.Buffs.StatDebuffs; using System.IO; using CalamityMod.Buffs.DamageOverTime; @@ -14,6 +13,13 @@ namespace CalamityMod.NPCs.AcidRain { public class WaterLeech : ModNPC { + public Player Target => Main.player[npc.target]; + public bool LatchingOntoTarget + { + get => npc.ai[0] == 1f; + set => npc.ai[0] = value.ToInt(); + } + public ref float LackOfWaterDeathTimer => ref npc.ai[2]; public const float ChasePromptDistance = 55f; public const float ChaseMaxDistance = 140f; @@ -33,13 +39,11 @@ namespace CalamityMod.NPCs.AcidRain if (CalamityWorld.downedPolterghast) { - npc.lifeMax = 2250; + npc.lifeMax = 1235; npc.defense = 10; } else if (CalamityWorld.downedAquaticScourge) - { npc.lifeMax = 90; - } npc.value = Item.buyPrice(0, 0, 2, 5); npc.lavaImmune = false; @@ -51,86 +55,53 @@ namespace CalamityMod.NPCs.AcidRain bannerItem = ModContent.ItemType(); } - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(npc.dontTakeDamage); - } + public override void SendExtraAI(BinaryWriter writer) => writer.Write(npc.dontTakeDamage); - public override void ReceiveExtraAI(BinaryReader reader) - { - npc.dontTakeDamage = reader.ReadBoolean(); - } + public override void ReceiveExtraAI(BinaryReader reader) => npc.dontTakeDamage = reader.ReadBoolean(); public override void AI() { if (npc.localAI[0] == 0f) { - npc.TargetClosest(false); + npc.TargetClosest(); npc.localAI[0] = 1f; } - // Anti-sticky movement and player targeting detection (only one leech and attack the player at once) - Player player = Main.player[npc.target]; bool playerAlreadyTargeted = false; float antiStickyAcceleration = 0.25f; - for (int i = 0; i < Main.npc.Length; i++) + + // Repel other leeches from this one. Also determine if one is already targeting a player. + // Only one leech is allowed to target one player at a time. + for (int i = 0; i < Main.maxNPCs; i++) { - if (Main.npc[i].type == npc.type && - Main.npc[i].whoAmI != npc.whoAmI && - Main.npc[i].active) - { - if (Main.npc[i].target == npc.target && !playerAlreadyTargeted) - { - playerAlreadyTargeted = true; - } - if (Main.npc[i].Hitbox.Intersects(npc.Hitbox)) - { - npc.velocity += npc.DirectionFrom(Main.npc[i].Center) * antiStickyAcceleration; - } - } + if (Main.npc[i].type != npc.type || !Main.npc[i].active || Main.npc[i].whoAmI == npc.whoAmI) + continue; + + if (Main.npc[i].target == npc.target && !playerAlreadyTargeted) + playerAlreadyTargeted = true; + if (Main.npc[i].Hitbox.Intersects(npc.Hitbox)) + npc.velocity += npc.DirectionFrom(Main.npc[i].Center) * antiStickyAcceleration; } - if (!playerAlreadyTargeted || player.Calamity().waterLeechTarget == -1) - { - player.Calamity().waterLeechTarget = npc.whoAmI; - } + if (!playerAlreadyTargeted || Target.Calamity().waterLeechTarget == -1) + Target.Calamity().waterLeechTarget = npc.whoAmI; - // Latch onto player - if (npc.ai[0] == 1f) + if (LatchingOntoTarget) { - if (npc.dontTakeDamage) - { - npc.dontTakeDamage = false; - npc.netUpdate = true; - } - if (npc.Distance(player.Top) >= 140f) - { - npc.ai[0] = 0f; - npc.netUpdate = true; - return; - } - Vector2 destination = ((player.gravDir == 1f) ? player.Top : player.Bottom) + player.direction * 4 * Vector2.UnitX; - float speed = Utils.SmoothStep(10f, ChaseMaxDistance, npc.Distance(destination)) * 16f; - npc.velocity = npc.DirectionTo(destination) * (speed + 7f); - if (npc.Distance(destination) < 45f) - { - player.AddBuff(BuffID.Bleeding, 180, true); - player.AddBuff(ModContent.BuffType(), 30, true); - } - else if (!npc.wet && npc.Distance(destination) > 85f) - { - npc.ai[0] = 0f; - npc.netUpdate = true; - } + LatchOntoTarget(); return; } + npc.direction = npc.spriteDirection = (npc.velocity.X > 0).ToDirectionInt(); + + // If the leech is not in water, fall and quickly cease horizontal movement. + // After some time, if still not in water, die due to a lack of water. if (!npc.wet) { npc.velocity.X *= 0.97f; - npc.velocity.Y += 0.5f; - npc.ai[2] += 1f; - if (npc.ai[2] >= 300f) + npc.velocity.Y = MathHelper.Clamp(npc.velocity.Y + 0.4f, -4f, 16f); + LackOfWaterDeathTimer++; + if (LackOfWaterDeathTimer >= 300f) { npc.life = 0; npc.HitEffect(); @@ -138,28 +109,69 @@ namespace CalamityMod.NPCs.AcidRain npc.netUpdate = true; } } - else if (player.wet && player.Calamity().waterLeechTarget == npc.whoAmI) + + // Swim towards the target if they are in water. + else if (Target.wet && Target.Calamity().waterLeechTarget == npc.whoAmI) { - float speed = player.wet ? 23f : 17f; + float swimSpeed = Target.wet ? 23f : 17f; float swimIntertia = 24f; if (CalamityWorld.downedPolterghast) { - speed *= 1.6f; + swimSpeed *= 1.6f; swimIntertia = 17f; } - npc.velocity = (npc.velocity * (swimIntertia - 1f) + npc.DirectionTo(player.Center) * speed) / swimIntertia; - } - else if (!player.wet) - { - npc.velocity *= 0.9f; + npc.velocity = (npc.velocity * (swimIntertia - 1f) + npc.DirectionTo(Target.Center) * swimSpeed) / swimIntertia; } - if (npc.Distance(player.Top) < ChasePromptDistance && player.active && !player.dead) + // Rapidly slow down if the target is not in water. + else if (!Target.wet) + npc.velocity *= 0.9f; + + if (npc.WithinRange(Target.Top, ChasePromptDistance) && Target.active && !Target.dead) { - npc.ai[0] = 1f; + LatchingOntoTarget = true; + npc.netUpdate = true; + } + + // If the target is not in water, become invincible. + bool shouldNotTakeDamage = !Target.wet; + if (Main.netMode != NetmodeID.MultiplayerClient && npc.dontTakeDamage != shouldNotTakeDamage) + { + npc.dontTakeDamage = shouldNotTakeDamage; + npc.netUpdate = true; + } + } + + public void LatchOntoTarget() + { + if (Main.netMode != NetmodeID.MultiplayerClient && npc.dontTakeDamage) + { + npc.dontTakeDamage = false; + npc.netUpdate = true; + } + + // If the target moved far enough away, stop attempting to attach to them. + if (!npc.WithinRange(Target.Center, ChaseMaxDistance)) + { + LatchingOntoTarget = false; + npc.netUpdate = true; + return; + } + Vector2 destination = (Target.gravDir == 1f ? Target.Top : Target.Bottom) + Target.direction * Vector2.UnitX * 4f; + float speed = MathHelper.Lerp(7f, 23f, Utils.InverseLerp(10f, ChaseMaxDistance, npc.Distance(destination), true)); + npc.velocity = npc.DirectionTo(destination) * speed; + if (npc.WithinRange(destination, 45f)) + { + Target.AddBuff(BuffID.Bleeding, 180, true); + Target.AddBuff(ModContent.BuffType(), 30, true); + } + + // Stop searching if the target is not in water anymore and they're not close. + else if (!npc.wet && !npc.WithinRange(destination, 85f)) + { + LatchingOntoTarget = false; npc.netUpdate = true; } - npc.dontTakeDamage = !player.wet; } public override void FindFrame(int frameHeight) @@ -170,27 +182,22 @@ namespace CalamityMod.NPCs.AcidRain npc.frameCounter = 0; npc.frame.Y += frameHeight; if (npc.frame.Y >= Main.npcFrameCount[npc.type] * frameHeight) - { npc.frame.Y = 0; - } } } public override float SpawnChance(NPCSpawnInfo spawnInfo) { if (spawnInfo.playerSafe || !spawnInfo.player.Calamity().ZoneSulphur || !Main.raining) - { return 0f; - } + return 0.115f; } public override void HitEffect(int hitDirection, double damage) { for (int k = 0; k < 8; k++) - { Dust.NewDust(npc.position, npc.width, npc.height, (int)CalamityDusts.SulfurousSeaAcid, hitDirection, -1f, 0, default, 1f); - } } public override void NPCLoot() diff --git a/NPCs/CalamityAI.cs b/NPCs/CalamityAI.cs index cc19d3e89e..3ed6f97029 100644 --- a/NPCs/CalamityAI.cs +++ b/NPCs/CalamityAI.cs @@ -1168,7 +1168,7 @@ namespace CalamityMod.NPCs lifeRatio = calamityGlobalNPC.killTimeRatio_IncreasedAggression; // Spawn phase 2 Cal - if (lifeRatio <= 0.75f && Main.netMode != NetmodeID.MultiplayerClient && !phase2) + if (npc.life / (float)npc.lifeMax <= 0.75f && Main.netMode != NetmodeID.MultiplayerClient && !phase2) { NPC.NewNPC((int)npc.Center.X, (int)npc.position.Y + npc.height, ModContent.NPCType(), npc.whoAmI); string key = "Mods.CalamityMod.CalamitasBossText"; diff --git a/NPCs/CalamityGlobalAI.cs b/NPCs/CalamityGlobalAI.cs index 204732372e..59fbaedd96 100644 --- a/NPCs/CalamityGlobalAI.cs +++ b/NPCs/CalamityGlobalAI.cs @@ -6,14 +6,17 @@ using CalamityMod.NPCs.NormalNPCs; using CalamityMod.Projectiles.Boss; using CalamityMod.World; using Microsoft.Xna.Framework; +using ReLogic.Utilities; using System; using System.Collections.Generic; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; using Terraria.Enums; using Terraria.GameContent; using Terraria.GameContent.Events; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; namespace CalamityMod.NPCs @@ -25570,8 +25573,195 @@ namespace CalamityMod.NPCs } return false; } - #endregion + #endregion - #endregion + #endregion + + #region DD2 Event AIs + public static int DD2EventEnemySpawnRate + { + get + { + int enemySpawnRateSpeedup = 0; + if (Main.npc.IndexInRange(CalamityGlobalNPC.DD2CrystalIndex) && Main.npc[CalamityGlobalNPC.DD2CrystalIndex].active) + enemySpawnRateSpeedup = (int)Main.npc[CalamityGlobalNPC.DD2CrystalIndex].ai[2]; + return Utils.Clamp(DD2Event.LaneSpawnRate - enemySpawnRateSpeedup, 15, DD2Event.LaneSpawnRate); + } + } + + public static void DD2PortalAI(NPC npc) + { + // Idly emit light if the portal has completely faded in. + if (npc.alpha == 0) + Lighting.AddLight(npc.Center, 0.5f, 0.1f, 0.3f); + + ref float enemySpawnTimer = ref npc.ai[0]; + ref float fadeOutTimer = ref npc.ai[2]; + ref float fadeInTimer = ref npc.localAI[0]; + ref float idlePlaySoundId = ref npc.localAI[3]; + if (npc.ai[1] == 0f) + { + // Play the portal opening sound at the moment of the portal's creation. + if (fadeInTimer == 0f) + { + Main.PlayTrackedSound(SoundID.DD2_EtherianPortalOpen, npc.Center); + idlePlaySoundId = SlotId.Invalid.ToFloat(); + } + + if (fadeInTimer > 150f && Main.GetActiveSound(SlotId.FromFloat(idlePlaySoundId)) == null) + idlePlaySoundId = Main.PlayTrackedSound(SoundID.DD2_EtherianPortalIdleLoop, npc.Center).ToFloat(); + + if (!DD2Event.EnemySpawningIsOnHold) + enemySpawnTimer++; + + if (enemySpawnTimer >= DD2EventEnemySpawnRate) + { + if (enemySpawnTimer >= DD2EventEnemySpawnRate * 3) + enemySpawnTimer = 0f; + + if (Main.netMode != NetmodeID.MultiplayerClient && (int)enemySpawnTimer % DD2EventEnemySpawnRate == 0) + { + DD2Event.SpawnMonsterFromGate(npc.Bottom); + + // If enemy spawning is on hold, add 1 to the spawn timer to ensure that the above + // modulo doesn't get activated every single frame due to no other change above. + if (DD2Event.EnemySpawningIsOnHold) + enemySpawnTimer++; + } + npc.netUpdate = true; + } + + fadeInTimer++; + + // Begin to fade out of existence if the crystal is gone and the portal is done doing fade-in effects. + if (Main.netMode != NetmodeID.MultiplayerClient && !NPC.AnyNPCs(NPCID.DD2EterniaCrystal) && fadeInTimer >= 180f) + { + npc.ai[1] = 1f; + enemySpawnTimer = 0f; + npc.dontTakeDamage = true; + npc.netUpdate = true; + } + } + + // Fade-out effects. + else if (npc.ai[1] == 1f) + { + fadeOutTimer++; + npc.scale = MathHelper.Lerp(1f, 0.05f, Utils.InverseLerp(500f, 600f, fadeOutTimer, true)); + + // Reset the idle play sound if it didn't get activated before for some reason. + if (Main.GetActiveSound(SlotId.FromFloat(idlePlaySoundId)) == null) + idlePlaySoundId = Main.PlayTrackedSound(SoundID.DD2_EtherianPortalIdleLoop, npc.Center).ToFloat(); + + ActiveSound activeSound = Main.GetActiveSound(SlotId.FromFloat(idlePlaySoundId)); + if (activeSound != null) + activeSound.Volume = npc.scale; + + // Kill the portal after enough time has passed. + if (fadeOutTimer >= 550f) + { + npc.dontTakeDamage = false; + npc.life = 0; + npc.checkDead(); + npc.netUpdate = true; + if (activeSound != null) + { + activeSound.Stop(); + return; + } + } + } + } + + public static void DD2CrystalExtraAI(NPC npc) + { + CalamityGlobalNPC.DD2CrystalIndex = npc.whoAmI; + + ref float initialClickDelay = ref npc.localAI[3]; + ref float enemySpawnRateSpeedup = ref npc.ai[2]; + ref float animationCountdown = ref npc.ai[3]; + + if (animationCountdown > 0f) + animationCountdown--; + + // This is done to ensure that the initial click on the pedestal is not registered as a click to the crystal itself. + initialClickDelay++; + + bool clickingOnCrystal = Main.mouseRight && Main.mouseRightRelease && CalamityUtils.MouseHitbox.Intersects(npc.Hitbox) && initialClickDelay > 25f; + + // Reset the spawn rate speed-up after the wave is over. + if (Main.netMode != NetmodeID.MultiplayerClient && DD2Event.TimeLeftBetweenWaves > 1 && enemySpawnRateSpeedup != 0f) + { + enemySpawnRateSpeedup = 0f; + npc.netUpdate = true; + } + + if (clickingOnCrystal && npc.WithinRange(Main.LocalPlayer.Center, 285f)) + { + bool changeOccured = false; + + // If the event is waiting for time to pass and a player clicks on the crystal skip the wait. + if (DD2Event.TimeLeftBetweenWaves > 1) + { + DD2Event.TimeLeftBetweenWaves = 1; + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.CrystalInvasionSendWaitTime, -1, -1, null, DD2Event.TimeLeftBetweenWaves); + changeOccured = true; + } + + // Otherwise speed up the portal spawn rate for this wave. + else + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int oldSpawnRate = DD2EventEnemySpawnRate; + enemySpawnRateSpeedup += 8f; + + // Release a circle of dust if a change was made to show that changes are indeed being done + // since the animation might be ongoing when this action is performed. + if (!Main.dedServ && oldSpawnRate != DD2EventEnemySpawnRate) + { + for (int i = 0; i < 55; i++) + { + for (float speed = 6f; speed < 13f; speed += 4f) + { + Vector2 shootDirection = (MathHelper.TwoPi * i / 55f).ToRotationVector2() * new Vector2(1f, 0.6f); + Dust etherealLight = Dust.NewDustPerfect(npc.Center - Vector2.UnitY * 20f + shootDirection * 12f, 264); + etherealLight.velocity = shootDirection * speed; + etherealLight.fadeIn = 0f; + etherealLight.scale = 2.3f; + etherealLight.noGravity = true; + etherealLight.noLight = true; + } + } + changeOccured = true; + } + npc.netUpdate = true; + } + } + + // Play an animation to accompany the change. + if (changeOccured) + { + if (animationCountdown <= 0f) + animationCountdown = 120f; + Main.PlaySound(SoundID.DD2_DarkMageHealImpact); + } + + // As well as some indicator text. + if (changeOccured) + { + bool dramaticText = DD2EventEnemySpawnRate <= 25; + Color textColor = dramaticText ? Color.DeepPink : Color.Pink; + string[] potentialTexts = new string[] + { + "The invasion hastens!", + "The ethereal invaders march ever-faster!" + }; + CombatText.NewText(npc.Hitbox, textColor, Main.rand.Next(potentialTexts), dramaticText); + } + } + } + #endregion DD2 Event AIs } } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index dff3b11c42..eac962fcff 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -52,6 +52,7 @@ using System.Collections.Generic; using System.Linq; using Terraria; using Terraria.GameContent.Events; +using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; using static Terraria.ModLoader.ModContent; @@ -150,6 +151,7 @@ namespace CalamityMod.NPCs // whoAmI Variables public static int[] bobbitWormBottom = new int[5]; + public static int DD2CrystalIndex = -1; public static int hiveMind = -1; public static int perfHive = -1; public static int slimeGodPurple = -1; @@ -478,6 +480,7 @@ namespace CalamityMod.NPCs for (int i = 0; i < bobbitWormBottom.Length; i++) ResetSavedIndex(ref bobbitWormBottom[i], NPCType()); + ResetSavedIndex(ref DD2CrystalIndex, NPCID.DD2EterniaCrystal); ResetSavedIndex(ref hiveMind, NPCType()); ResetSavedIndex(ref perfHive, NPCType()); ResetSavedIndex(ref slimeGodPurple, NPCType(), NPCType()); @@ -1675,9 +1678,6 @@ namespace CalamityMod.NPCs { float DRScalar = !GetDownedBossVariable(npc.type) || CalamityConfig.Instance.FullPowerReactiveBossDR ? 1.5f : 1f; - /*if (Main.masterMode) - DRScalar = 5f;*/ - // Boost Providence timed DR during the night, Destroyer, Aquatic Scourge, Astrum Deus, Storm Weaver and DoG body timed DR if (npc.type == NPCType() && !Main.dayTime) DRScalar = 10f; @@ -2554,6 +2554,12 @@ namespace CalamityMod.NPCs return CalamityGlobalAI.BuffedSporeAI(npc, mod); } + if (npc.type == NPCID.DD2LanePortal) + { + CalamityGlobalAI.DD2PortalAI(npc); + return false; + } + return true; } #endregion @@ -3125,6 +3131,9 @@ namespace CalamityMod.NPCs else if (slowed > 0 || tesla > 0) npc.velocity *= 0.9f; } + + if (npc.type == NPCID.DD2EterniaCrystal) + CalamityGlobalAI.DD2CrystalExtraAI(npc); } #endregion @@ -3404,9 +3413,9 @@ namespace CalamityMod.NPCs // Other projectile resists if (npc.type == NPCType()) { - // 5% resist to Time Bolt + // 10% resist to Time Bolt if (projectile.type == ProjectileType()) - damage = (int)(damage * 0.95); + damage = (int)(damage * 0.9); } else if (npc.type == NPCType()) { @@ -3447,10 +3456,13 @@ namespace CalamityMod.NPCs if (projectile.IsSummon() || projectile.aiStyle == 99) return; - if (projectile.penetrate == -1) - damage = (int)(damage * 0.5); - else if (projectile.penetrate > 1) - damage = (int)MathHelper.Clamp(damage * (float)Math.Pow(0.9, projectile.penetrate), damage * 0.5f, damage); + if (projectile.penetrate == -1) + damage = (int)(damage * 0.5); + else if (projectile.penetrate > 1) + { + float newBaseDamage = damage * (float)Math.Pow(0.9, projectile.penetrate) / projectile.Calamity().ResistDamagePenaltyHarshness; + damage = (int)MathHelper.Clamp(newBaseDamage, damage * projectile.Calamity().ResistDamagePenaltyMinCapFactor, damage); + } } #endregion @@ -4409,6 +4421,31 @@ namespace CalamityMod.NPCs Main.spriteBatch.Draw(Main.npcTexture[npc.type], new Vector2(position9.X - Main.screenPosition.X + npc.width / 2 - Main.npcTexture[npc.type].Width * npc.scale / 2f + vector11.X * npc.scale, position9.Y - Main.screenPosition.Y + npc.height - Main.npcTexture[npc.type].Height * npc.scale / Main.npcFrameCount[npc.type] + 4f + vector11.Y * npc.scale + num66 + npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(npc.frame), alpha15, npc.rotation, vector11, npc.scale, spriteEffects, 0f); } } + + // Draw a pillar of light and fade the background as an animation when skipping things in the DD2 event. + if (npc.type == NPCID.DD2EterniaCrystal) + { + float animationTime = 120f - npc.ai[3]; + animationTime /= 120f; + + if (!Main.dedServ) + { + if (!Filters.Scene["CrystalDestructionColor"].IsActive()) + Filters.Scene.Activate("CrystalDestructionColor"); + + Filters.Scene["CrystalDestructionColor"].GetShader().UseIntensity((float)Math.Sin(animationTime * MathHelper.Pi) * 0.4f); + } + + Vector2 drawPosition = npc.Center - Main.screenPosition + Vector2.UnitY * 60f; + for (int i = 0; i < 4; i++) + { + float intensity = MathHelper.Clamp(animationTime * 2f - i / 3f, 0f, 1f); + Vector2 origin = new Vector2(Main.magicPixel.Width / 2f, Main.magicPixel.Height); + Vector2 scale = new Vector2((float)Math.Sqrt(intensity) * 50f, intensity * 4f); + Color beamColor = new Color(0.4f, 0.17f, 0.4f, 0f) * (intensity * (1f - MathHelper.Clamp((animationTime - 0.8f) / 0.2f, 0f, 1f))) * 0.5f; + spriteBatch.Draw(Main.magicPixel, drawPosition, null, beamColor, 0f, origin, scale, SpriteEffects.None, 0f); + } + } return true; } diff --git a/NPCs/Cryogen/Cryogen.cs b/NPCs/Cryogen/Cryogen.cs index 87724430de..9b7d2e31da 100644 --- a/NPCs/Cryogen/Cryogen.cs +++ b/NPCs/Cryogen/Cryogen.cs @@ -1041,7 +1041,6 @@ namespace CalamityMod.NPCs.Cryogen if (!Main.expertMode) { // Materials - DropHelper.DropItem(npc, ModContent.ItemType(), 15, 25); DropHelper.DropItemSpray(npc, ModContent.ItemType(), 4, 8); DropHelper.DropItem(npc, ItemID.FrostCore); diff --git a/NPCs/DevourerofGods/DevourerofGodsHead.cs b/NPCs/DevourerofGods/DevourerofGodsHead.cs index fb20de02d1..c1a6915a8b 100644 --- a/NPCs/DevourerofGods/DevourerofGodsHead.cs +++ b/NPCs/DevourerofGods/DevourerofGodsHead.cs @@ -980,10 +980,10 @@ namespace CalamityMod.NPCs.DevourerofGods player.AddBuff(ModContent.BuffType(), 300, true); player.AddBuff(ModContent.BuffType(), 420, true); player.AddBuff(BuffID.Frostburn, 300, true); - if (CalamityWorld.death && !player.Calamity().lol) + /*if (CalamityWorld.death && !player.Calamity().lol) { player.KillMe(PlayerDeathReason.ByCustomReason(player.name + "'s essence was consumed by the devourer."), 1000.0, 0, false); - } + }*/ if (player.Calamity().dogTextCooldown <= 0) { diff --git a/NPCs/Yharon/DetonatingFlare.cs b/NPCs/Yharon/DetonatingFlare.cs index b2a149dd4e..4eb8b8b234 100644 --- a/NPCs/Yharon/DetonatingFlare.cs +++ b/NPCs/Yharon/DetonatingFlare.cs @@ -23,14 +23,14 @@ namespace CalamityMod.NPCs.Yharon public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; aiType = -1; - npc.GetNPCDamage(); - npc.width = 50; + npc.GetNPCDamage(); + npc.width = 50; npc.height = 50; - npc.defense = 50; - npc.lifeMax = 10000; + npc.lifeMax = 3000; + npc.defense = 20; npc.knockBackResist = 0f; npc.noGravity = true; npc.noTileCollide = true; @@ -166,9 +166,9 @@ namespace CalamityMod.NPCs.Yharon npc.localAI[0] = 0f; if (Collision.CanHit(npc.position, npc.width, npc.height, Main.player[npc.target].position, Main.player[npc.target].width, Main.player[npc.target].height)) { - int type = ProjectileID.CultistBossFireBall; - int damage = npc.GetProjectileDamage(type); - Projectile.NewProjectile(vector.X, vector.Y, num4, num5, type, damage, 0f, Main.myPlayer, 0f, 0f); + int type = ProjectileID.CultistBossFireBall; + int damage = npc.GetProjectileDamage(type); + Projectile.NewProjectile(vector.X, vector.Y, num4, num5, type, damage, 0f, Main.myPlayer, 0f, 0f); } } int num10 = (int)npc.position.X + npc.width / 2; @@ -241,53 +241,53 @@ namespace CalamityMod.NPCs.Yharon return new Color(255, Main.DiscoG, 53, 0); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - SpriteEffects spriteEffects = SpriteEffects.None; - if (npc.spriteDirection == 1) - spriteEffects = SpriteEffects.FlipHorizontally; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (npc.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = new Color(255, Main.DiscoG, 53, 0); - float amount9 = 0.5f; - int num153 = 10; + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = new Color(255, Main.DiscoG, 53, 0); + float amount9 = 0.5f; + int num153 = 10; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, spriteEffects, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, spriteEffects, 0f); - return false; - } + return false; + } - public override bool CanHitPlayer(Player target, ref int cooldownSlot) + public override bool CanHitPlayer(Player target, ref int cooldownSlot) { cooldownSlot = 1; return true; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 240, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 240, true); + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; diff --git a/NPCs/Yharon/DetonatingFlare2.cs b/NPCs/Yharon/DetonatingFlare2.cs index 6485929fab..06bc9ba4f0 100644 --- a/NPCs/Yharon/DetonatingFlare2.cs +++ b/NPCs/Yharon/DetonatingFlare2.cs @@ -6,9 +6,10 @@ using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.NPCs.Yharon { - public class DetonatingFlare2 : ModNPC + public class DetonatingFlare2 : ModNPC { float randomSpeed = 0f; @@ -16,24 +17,24 @@ namespace CalamityMod.NPCs.Yharon { DisplayName.SetDefault("Detonating Flame"); Main.npcFrameCount[npc.type] = 5; - NPCID.Sets.TrailingMode[npc.type] = 1; - } + NPCID.Sets.TrailingMode[npc.type] = 1; + } public override void SetDefaults() { - npc.Calamity().canBreakPlayerDefense = true; - npc.aiStyle = -1; + npc.Calamity().canBreakPlayerDefense = true; + npc.aiStyle = -1; aiType = -1; - npc.GetNPCDamage(); - npc.width = 50; + npc.GetNPCDamage(); + npc.width = 50; npc.height = 50; - npc.defense = 75; - npc.lifeMax = 13000; + npc.lifeMax = 3900; + npc.defense = 26; npc.knockBackResist = 0f; npc.noGravity = true; npc.noTileCollide = true; npc.canGhostHeal = false; - npc.HitSound = SoundID.NPCHit52; + npc.HitSound = SoundID.NPCHit52; npc.DeathSound = SoundID.NPCDeath55; npc.alpha = 255; } @@ -76,36 +77,36 @@ namespace CalamityMod.NPCs.Yharon return new Color(255, Main.DiscoG, 53, 0); } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - Texture2D texture2D15 = Main.npcTexture[npc.type]; - Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); - Color color36 = new Color(255, Main.DiscoG, 53, 0); - float amount9 = 0.5f; - int num153 = 10; + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + Texture2D texture2D15 = Main.npcTexture[npc.type]; + Vector2 vector11 = new Vector2((float)(Main.npcTexture[npc.type].Width / 2), (float)(Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type] / 2)); + Color color36 = new Color(255, Main.DiscoG, 53, 0); + float amount9 = 0.5f; + int num153 = 10; - if (CalamityConfig.Instance.Afterimages) - { - for (int num155 = 1; num155 < num153; num155 += 2) - { - Color color38 = lightColor; - color38 = Color.Lerp(color38, color36, amount9); - color38 = npc.GetAlpha(color38); - color38 *= (float)(num153 - num155) / 15f; - Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; - vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); - } - } + if (CalamityConfig.Instance.Afterimages) + { + for (int num155 = 1; num155 < num153; num155 += 2) + { + Color color38 = lightColor; + color38 = Color.Lerp(color38, color36, amount9); + color38 = npc.GetAlpha(color38); + color38 *= (float)(num153 - num155) / 15f; + Vector2 vector41 = npc.oldPos[num155] + new Vector2((float)npc.width, (float)npc.height) / 2f - Main.screenPosition; + vector41 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector41 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector41, npc.frame, color38, npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); + } + } - Vector2 vector43 = npc.Center - Main.screenPosition; - vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; - vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); - spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); + Vector2 vector43 = npc.Center - Main.screenPosition; + vector43 -= new Vector2((float)texture2D15.Width, (float)(texture2D15.Height / Main.npcFrameCount[npc.type])) * npc.scale / 2f; + vector43 += vector11 * npc.scale + new Vector2(0f, 4f + npc.gfxOffY); + spriteBatch.Draw(texture2D15, vector43, npc.frame, npc.GetAlpha(lightColor), npc.rotation, vector11, npc.scale, SpriteEffects.None, 0f); - return false; - } + return false; + } public override bool CanHitPlayer(Player target, ref int cooldownSlot) { @@ -113,12 +114,12 @@ namespace CalamityMod.NPCs.Yharon return true; } - public override void OnHitPlayer(Player player, int damage, bool crit) - { - player.AddBuff(ModContent.BuffType(), 240, true); - } + public override void OnHitPlayer(Player player, int damage, bool crit) + { + player.AddBuff(ModContent.BuffType(), 240, true); + } - public override void FindFrame(int frameHeight) + public override void FindFrame(int frameHeight) { npc.frameCounter += 0.15f; npc.frameCounter %= Main.npcFrameCount[npc.type]; diff --git a/NPCs/Yharon/Yharon.cs b/NPCs/Yharon/Yharon.cs index 0b233cf2ea..3f1a89e6b8 100644 --- a/NPCs/Yharon/Yharon.cs +++ b/NPCs/Yharon/Yharon.cs @@ -48,7 +48,6 @@ namespace CalamityMod.NPCs.Yharon private const float ai2GateValue = 0.55f; public static float normalDR = 0.22f; - public static float ChargeTelegraph_DR = 0.4f; public static float EnragedDR = 0.9f; public override void SetStaticDefaults() @@ -381,7 +380,7 @@ namespace CalamityMod.NPCs.Yharon // Set DR based on protection boost (aka enrage) bool chargeTelegraph = (npc.ai[0] == 0f || npc.ai[0] == 6f || npc.ai[0] == 13f) && npc.localAI[1] > 0f; bool bulletHell = npc.ai[0] == 8f || npc.ai[0] == 15f; - calamityGlobalNPC.DR = protectionBoost ? EnragedDR : ((chargeTelegraph || bulletHell) ? ChargeTelegraph_DR : normalDR); + calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; if (bulletHell) npc.damage = 0; @@ -969,7 +968,7 @@ namespace CalamityMod.NPCs.Yharon int totalProjectiles = 38 - ringReduction; // 36 for first ring, 22 for last ring DoFlareDustBulletHell(0, flareDustSpawnDivisor, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, 0f, 0f, false); - // Fire a flame towards every player, with a limit of 10 + // Fire a flame towards every player, with a limit of 5 if (expertMode) { List targets = new List(); @@ -983,7 +982,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * 12f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 12f; int type = ModContent.ProjectileType(); Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); } @@ -1331,8 +1330,8 @@ namespace CalamityMod.NPCs.Yharon { DoFlareDustBulletHell(1, flareDustPhaseTimer, npc.GetProjectileDamage(ModContent.ProjectileType()), 8, 12f, 3.6f, false); - // Fire a flame towards every player, with a limit of 10 - if (expertMode) + // Fire a flame towards every player, with a limit of 5 + if (expertMode && npc.ai[2] % (flareDustSpawnDivisor3 * 2) == 0f) { List targets = new List(); for (int p = 0; p < Main.maxPlayers; p++) @@ -1345,7 +1344,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * 12f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 12f; int type = ModContent.ProjectileType(); Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); } @@ -1620,7 +1619,7 @@ namespace CalamityMod.NPCs.Yharon // Set DR based on protection boost (aka enrage) bool chargeTelegraph = npc.ai[0] < 2f && npc.localAI[1] > 0f; bool bulletHell = npc.ai[0] == 5f; - calamityGlobalNPC.DR = protectionBoost ? EnragedDR : ((chargeTelegraph || bulletHell) ? ChargeTelegraph_DR : normalDR); + calamityGlobalNPC.DR = protectionBoost ? EnragedDR : normalDR; if (bulletHell) npc.damage = 0; @@ -1999,7 +1998,7 @@ namespace CalamityMod.NPCs.Yharon } case 7: //fast charge { - Vector2 vector = npc.DirectionTo(targetData.Center); + Vector2 vector = secondPhasePhase == 4 ? Vector2.Normalize(targetData.Center + targetData.velocity * 20f - vectorCenter) : npc.DirectionTo(targetData.Center); npc.spriteDirection = (vector.X > 0f) ? 1 : -1; npc.rotation = vector.ToRotation(); @@ -2174,7 +2173,7 @@ namespace CalamityMod.NPCs.Yharon DoFlareDustBulletHell(1, spinPhaseTimer, npc.GetProjectileDamage(ModContent.ProjectileType()), totalProjectiles, projectileVelocity, radialOffset, true); // Fire a flame towards every player, with a limit of 10 - if (expertMode) + if (expertMode && npc.ai[2] % (flareDustSpawnDivisor2 * 2) == 0f) { List targets = new List(); for (int p = 0; p < Main.maxPlayers; p++) @@ -2187,7 +2186,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * 12f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 12f; int type = ModContent.ProjectileType(); Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); } @@ -2216,7 +2215,7 @@ namespace CalamityMod.NPCs.Yharon } foreach (int t in targets) { - Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center - flareDustBulletHellSpawn) * 12f; + Vector2 velocity2 = Vector2.Normalize(Main.player[t].Center + Main.player[t].velocity * 20f - flareDustBulletHellSpawn) * 12f; int type = ModContent.ProjectileType(); Projectile.NewProjectile(flareDustBulletHellSpawn, velocity2, type, npc.GetProjectileDamage(ModContent.ProjectileType()), 0f, Main.myPlayer, 2f, 0f); } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index e745b777c8..076120603d 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -53,6 +53,8 @@ namespace CalamityMod.Projectiles // Damage Adjusters private bool setDamageValues = true; public float spawnedPlayerMinionDamageValue = 1f; + public float ResistDamagePenaltyHarshness = 1f; + public float ResistDamagePenaltyMinCapFactor = 0.5f; public int spawnedPlayerMinionProjectileDamageValue = 0; public int defDamage = 0; @@ -1163,26 +1165,6 @@ namespace CalamityMod.Projectiles if (!projectile.npcProj && !projectile.trap && projectile.friendly && projectile.damage > 0) { - if (modPlayer.eQuiver && projectile.ranged && CalamityLists.rangedProjectileExceptionList.TrueForAll(x => projectile.type != x)) - { - if (Main.player[projectile.owner].miscCounter % 60 == 0 && projectile.FinalExtraUpdate()) - { - float spread = 180f * 0.0174f; - double startAngle = Math.Atan2(projectile.velocity.X, projectile.velocity.Y) - spread / 2; - if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[projectile.type] < 50) - { - int projectile1 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(Math.Sin(startAngle) * 8f), (float)(Math.Cos(startAngle) * 8f), projectile.type, (int)(projectile.damage * 0.15), projectile.knockBack, projectile.owner, 0f, 0f); - int projectile2 = Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, (float)(-Math.Sin(startAngle) * 8f), (float)(-Math.Cos(startAngle) * 8f), projectile.type, (int)(projectile.damage * 0.15), projectile.knockBack, projectile.owner, 0f, 0f); - Main.projectile[projectile1].ranged = false; - Main.projectile[projectile2].ranged = false; - Main.projectile[projectile1].timeLeft = 60; - Main.projectile[projectile2].timeLeft = 60; - Main.projectile[projectile1].noDropItem = true; - Main.projectile[projectile2].noDropItem = true; - } - } - } - if (modPlayer.fungalSymbiote && trueMelee) { if (Main.player[projectile.owner].miscCounter % 6 == 0 && projectile.FinalExtraUpdate()) @@ -1218,24 +1200,26 @@ namespace CalamityMod.Projectiles if (rogue) { - if (modPlayer.nanotech && rogue && projectile.type != ProjectileType() && projectile.type != ProjectileType()) + if (modPlayer.nanotech && projectile.type != ProjectileType() && projectile.type != ProjectileType()) { if (Main.player[projectile.owner].miscCounter % 30 == 0 && projectile.FinalExtraUpdate()) { if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileType()] < 25) { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), (int)(projectile.damage * 0.15), 0f, projectile.owner, 0f, 0f); + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), (int)(projectile.damage * 0.7), 0f, projectile.owner, 0f, 0f); } } } // Moon Crown gets overridden by Nanotech - else if (modPlayer.moonCrown) + else if (modPlayer.moonCrown && projectile.type != ProjectileType() && projectile.type != ProjectileType()) { - // Summon moon sigils infrequently - if (Main.rand.NextBool(300) && projectile.type != ProjectileType() && projectile.type != ProjectileType()) - { - Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), (int)(projectile.damage * 0.2), 0, projectile.owner); - } + if (Main.player[projectile.owner].miscCounter % 300 == 0 && projectile.FinalExtraUpdate()) + { + if (projectile.owner == Main.myPlayer && player.ownedProjectileCounts[ProjectileType()] < 15) + { + Projectile.NewProjectile(projectile.Center, Vector2.Zero, ProjectileType(), (int)(projectile.damage * 0.2), 0, projectile.owner); + } + } } if (modPlayer.dragonScales && projectile.type != ProjectileType() && projectile.type != ProjectileType()) { diff --git a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs index 73b122ed85..01eaccc70e 100644 --- a/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs +++ b/Projectiles/DraedonsArsenal/StarSwallowerSummon.cs @@ -245,19 +245,11 @@ namespace CalamityMod.Projectiles.DraedonsArsenal Main.myPlayer == projectile.owner) { Vector2 spawnPosition = projectile.Center + Vector2.UnitX * 8f * projectile.spriteDirection; - - float shootSpeed = 14f; - float gravity = -StarSwallowerAcid.Gravity; - float distance = Vector2.Distance(spawnPosition, potentialTarget.Center); - float angle = 0.5f * (float)Math.Asin(MathHelper.Clamp(gravity * distance / (float)Math.Pow(shootSpeed, 2), -1f, 1f)); - - Vector2 velocity = new Vector2(0f, -shootSpeed).RotatedBy(angle).RotatedByRandom(0.015f); - velocity.X *= (potentialTarget.Center.X - projectile.Center.X < 0).ToDirectionInt(); - projectile.spriteDirection = (potentialTarget.Center.X - projectile.Center.X > 0).ToDirectionInt(); + Vector2 fireVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(spawnPosition, potentialTarget.Center, StarSwallowerAcid.Gravity, 14f); Projectile.NewProjectile(spawnPosition, - velocity, + fireVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, diff --git a/Projectiles/Magic/GhastlyBlast.cs b/Projectiles/Magic/GhastlyBlast.cs index 7d81ae12e0..cc72fbc243 100644 --- a/Projectiles/Magic/GhastlyBlast.cs +++ b/Projectiles/Magic/GhastlyBlast.cs @@ -9,6 +9,10 @@ namespace CalamityMod.Projectiles.Magic { public class GhastlyBlast : ModProjectile { + private const float DriftVelocity = 10f; + private const float FramesBeforeSlowing = 8f; + private const float MaximumWaitFrames = 360f; + public override void SetStaticDefaults() { DisplayName.SetDefault("Ghast Blast"); @@ -23,30 +27,35 @@ namespace CalamityMod.Projectiles.Magic projectile.friendly = true; projectile.alpha = 255; projectile.penetrate = 6; - projectile.extraUpdates = 1; + projectile.extraUpdates = 2; projectile.tileCollide = false; projectile.ignoreWater = true; projectile.magic = true; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 8; + projectile.localNPCHitCooldown = 12; } public override void AI() { projectile.ai[0] += 1f; - int num1013 = 0; - if (projectile.velocity.Length() <= 8f) //4 - { - num1013 = 1; - } + bool goingSlow = projectile.velocity.Length() <= DriftVelocity; + bool currentlyHoming = projectile.ai[1] > 0f; + + // Rapidly fade in when the projectile starts existing projectile.alpha -= 15; if (projectile.alpha < 0) { projectile.alpha = 0; } - if (num1013 == 0) + + // Moving faster than drift velocity, but not homing. + // This way, when the projectile speeds back up upon homing, it doesn't suddenly lose its homing again. + if (!goingSlow && !currentlyHoming) { + // Spin at a certain rate projectile.rotation -= 0.104719758f; + + // Dust, randomly if (Main.rand.NextBool(3)) { if (Main.rand.NextBool(2)) @@ -72,9 +81,11 @@ namespace CalamityMod.Projectiles.Magic dust29.customData = projectile; } } - if (projectile.ai[0] >= 30f) + + // Grow and slow down + if (projectile.ai[0] >= FramesBeforeSlowing * projectile.MaxUpdates) { - projectile.velocity *= 0.98f; + projectile.velocity *= 0.977f; projectile.scale += 0.00744680827f; if (projectile.scale > 1.2f) { @@ -82,16 +93,23 @@ namespace CalamityMod.Projectiles.Magic } projectile.rotation -= 0.0174532924f; } - if (projectile.velocity.Length() < 8.2f) //4.1 + + // Set velocity to the drift velocity exactly after slowing down enough and reset the time counter. + float speed = projectile.velocity.Length(); + if (speed < 1.02f * DriftVelocity) { - projectile.velocity.Normalize(); - projectile.velocity *= 4f; + projectile.velocity *= DriftVelocity / speed; projectile.ai[0] = 0f; } } - else if (num1013 == 1) + + // Either moving at or below drift velocity, or currently homing. Either case runs this AI path. + else { + // Spin at the exact same rate anyway projectile.rotation -= 0.104719758f; + + // Excessively complicated dust int num3; for (int num1014 = 0; num1014 < 1; num1014 = num3 + 1) { @@ -127,11 +145,16 @@ namespace CalamityMod.Projectiles.Magic } num3 = num1014; } + + // Every so many frames, spawn a sub blast. if (projectile.ai[0] % 30f == 0f && projectile.ai[0] < 241f && Main.myPlayer == projectile.owner) { Vector2 vector144 = Vector2.UnitY.RotatedByRandom(6.2831854820251465) * 12f; Projectile.NewProjectile(projectile.Center.X, projectile.Center.Y, vector144.X, vector144.Y, ModContent.ProjectileType(), projectile.damage, 0f, projectile.owner, 0f, (float)projectile.whoAmI); } + + // Undocumented, unrefactored homing. Will not home through walls. + // Apparently has two different homing distances. Vector2 vector145 = projectile.Center; float num1015 = 800f; bool flag59 = false; @@ -195,11 +218,14 @@ namespace CalamityMod.Projectiles.Magic projectile.velocity.Y = (projectile.velocity.Y * (float)(HomingN - 1) + dy) / (float)HomingN; } } + + // If the projectile is solid enough, add light. if (projectile.alpha < 150) { Lighting.AddLight(projectile.Center, 0.9f, 0f, 0.1f); } - if (projectile.ai[0] >= 600f) + + if (projectile.ai[0] >= MaximumWaitFrames * projectile.MaxUpdates) { projectile.Kill(); } diff --git a/Projectiles/Magic/GhastlyVisageProj.cs b/Projectiles/Magic/GhastlyVisageProj.cs index fa46444dae..334bf83eef 100644 --- a/Projectiles/Magic/GhastlyVisageProj.cs +++ b/Projectiles/Magic/GhastlyVisageProj.cs @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Magic if (flag15 && Main.myPlayer == projectile.owner) { int num42 = ModContent.ProjectileType(); - float scaleFactor11 = 6f; + float coreVelocity = 11.5f; int weaponDamage2 = player.GetWeaponDamage(player.ActiveItem()); float weaponKnockback2 = player.ActiveItem().knockBack; if (flag16) @@ -169,7 +169,7 @@ namespace CalamityMod.Projectiles.Magic projectile.netUpdate = true; } projectile.velocity = value19 * 0.55f; - Vector2 vector20 = Vector2.Normalize(projectile.velocity) * scaleFactor11 * (0.6f + Main.rand.NextFloat() * 0.8f); + Vector2 vector20 = Vector2.Normalize(projectile.velocity) * coreVelocity; if (float.IsNaN(vector20.X) || float.IsNaN(vector20.Y)) { vector20 = -Vector2.UnitY; diff --git a/Projectiles/Magic/Shadowbolt.cs b/Projectiles/Magic/Shadowbolt.cs index ff7e9cf4e5..77bbc6fea5 100644 --- a/Projectiles/Magic/Shadowbolt.cs +++ b/Projectiles/Magic/Shadowbolt.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; + projectile.ignoreWater = true; projectile.penetrate = 6; projectile.extraUpdates = 100; projectile.timeLeft = 300; diff --git a/Projectiles/Magic/VisceraBeam.cs b/Projectiles/Magic/VisceraBeam.cs index aabe62360b..35a097f117 100644 --- a/Projectiles/Magic/VisceraBeam.cs +++ b/Projectiles/Magic/VisceraBeam.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Magic projectile.height = 4; projectile.friendly = true; projectile.magic = true; + projectile.ignoreWater = true; projectile.penetrate = 9; projectile.extraUpdates = 100; projectile.timeLeft = 300; diff --git a/Projectiles/Ranged/BloodBoilerFire.cs b/Projectiles/Ranged/BloodBoilerFire.cs index 92c4932108..f6ff4b2105 100644 --- a/Projectiles/Ranged/BloodBoilerFire.cs +++ b/Projectiles/Ranged/BloodBoilerFire.cs @@ -31,6 +31,8 @@ namespace CalamityMod.Projectiles.Ranged projectile.usesIDStaticNPCImmunity = true; projectile.idStaticNPCHitCooldown = 5; projectile.timeLeft = 300; + projectile.Calamity().ResistDamagePenaltyMinCapFactor = 0.33f; + projectile.Calamity().ResistDamagePenaltyHarshness = 1.55f; } public override void AI() diff --git a/Projectiles/Ranged/TelluricGlareArrow.cs b/Projectiles/Ranged/TelluricGlareArrow.cs new file mode 100644 index 0000000000..f23a879cc9 --- /dev/null +++ b/Projectiles/Ranged/TelluricGlareArrow.cs @@ -0,0 +1,135 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.Graphics.Shaders; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Ranged +{ + public class TelluricGlareArrow : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public PrimitiveTrail TrailDrawer = null; + private const int Lifetime = 180; + private static Color ShaderColorOne = new Color(237, 194, 66); + private static Color ShaderColorTwo = new Color(235, 227, 117); + private static Color ShaderEndColor = new Color(199, 153, 26); + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Radiant Arrow"); + // While this projectile doesn't have afterimages, it keeps track of old positions for its primitive drawcode. + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 21; + } + + public override void SetDefaults() + { + projectile.width = projectile.height = 24; + projectile.arrow = true; + projectile.friendly = true; + projectile.ranged = true; + projectile.tileCollide = false; + projectile.ignoreWater = true; + projectile.timeLeft = Lifetime; + projectile.MaxUpdates = 3; + projectile.penetrate = 2; // Can hit up to two enemies. Will explode extremely soon after hitting the first, though. + projectile.usesLocalNPCImmunity = true; + projectile.localNPCHitCooldown = -1; + } + + public override bool CanDamage() => projectile.timeLeft < Lifetime - 4; + + public override void AI() => Lighting.AddLight(projectile.Center, ShaderColorOne.ToVector3()); + + private void RestrictLifetime() + { + if (projectile.timeLeft > 8) + projectile.timeLeft = 8; + } + + public override void OnHitPlayer(Player target, int damage, bool crit) + { + RestrictLifetime(); + target.AddBuff(ModContent.BuffType(), 240); + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + RestrictLifetime(); + target.AddBuff(ModContent.BuffType(), 240); + } + + private float PrimitiveWidthFunction(float completionRatio) + { + float arrowheadCutoff = 0.36f; + float width = 39f; + float minHeadWidth = 0.02f; + float maxHeadWidth = width; + if (completionRatio <= arrowheadCutoff) + width = MathHelper.Lerp(minHeadWidth, maxHeadWidth, Utils.InverseLerp(0f, arrowheadCutoff, completionRatio, true)); + return width; + } + + private Color PrimitiveColorFunction(float completionRatio) + { + float endFadeRatio = 0.41f; + + float completionRatioFactor = 2.7f; + float globalTimeFactor = 5.3f; + float endFadeFactor = 3.2f; + float endFadeTerm = Utils.InverseLerp(0f, endFadeRatio * 0.5f, completionRatio, true) * endFadeFactor; + float cosArgument = completionRatio * completionRatioFactor - Main.GlobalTime * globalTimeFactor + endFadeTerm; + float startingInterpolant = (float)Math.Cos(cosArgument) * 0.5f + 0.5f; + + float colorLerpFactor = 0.6f; + Color startingColor = Color.Lerp(ShaderColorOne, ShaderColorTwo, startingInterpolant * colorLerpFactor); + + return Color.Lerp(startingColor, ShaderEndColor, MathHelper.SmoothStep(0f, 1f, Utils.InverseLerp(0f, endFadeRatio, completionRatio, true))); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) + { + if (TrailDrawer is null) + TrailDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]); + + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.GetTexture("CalamityMod/ExtraTextures/TelluricGlareStreak")); + Vector2 overallOffset = projectile.Size * 0.5f - Main.screenPosition; + overallOffset += projectile.velocity * 1.4f; + TrailDrawer.Draw(projectile.oldPos, overallOffset, 92); // 58 + return false; + } + + public override void Kill(int timeLeft) + { + Main.PlaySound(SoundID.Item14, projectile.position); + + // Explode into a bunch of holy fire on death. + for (int i = 0; i < 10; i++) + { + Dust holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, (int)CalamityDusts.ProfanedFire, 0f, 0f, 100, default, 2f); + holyFire.velocity *= 3f; + + if (Main.rand.NextBool(2)) + { + holyFire.scale = 0.5f; + holyFire.fadeIn = Main.rand.NextFloat(1f, 2f); + } + } + for (int i = 0; i < 20; i++) + { + Dust holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 246, 0f, 0f, 100, default, 3f); + holyFire.noGravity = true; + holyFire.velocity *= 5f; + + holyFire = Dust.NewDustDirect(projectile.position, projectile.width, projectile.height, 246, 0f, 0f, 100, default, 2f); + holyFire.velocity *= 2f; + } + } + } +} diff --git a/Projectiles/Ranged/TelluricGlareProj.png b/Projectiles/Ranged/TelluricGlareArrow.png similarity index 100% rename from Projectiles/Ranged/TelluricGlareProj.png rename to Projectiles/Ranged/TelluricGlareArrow.png diff --git a/Projectiles/Ranged/TelluricGlareProj.cs b/Projectiles/Ranged/TelluricGlareProj.cs deleted file mode 100644 index ed68a7a951..0000000000 --- a/Projectiles/Ranged/TelluricGlareProj.cs +++ /dev/null @@ -1,77 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class TelluricGlareProj : ModProjectile - { - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Glare"); - } - - public override void SetDefaults() - { - projectile.width = 10; - projectile.height = 10; - projectile.extraUpdates = 30; - projectile.friendly = true; - projectile.ranged = true; - projectile.penetrate = -1; - projectile.aiStyle = 1; - projectile.timeLeft = 300; - projectile.arrow = true; - aiType = ProjectileID.WoodenArrowFriendly; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 10; - } - - public override void AI() - { - projectile.localAI[0] += 1f; - if (projectile.localAI[0] > 4f) - { - for (int num468 = 0; num468 < 2; num468++) - { - int num469 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 1.7f); - Main.dust[num469].noGravity = true; - Main.dust[num469].velocity *= 0f; - } - } - } - - public override void Kill(int timeLeft) - { - projectile.position = projectile.Center; - projectile.width = projectile.height = 32; - projectile.position.X = projectile.position.X - (float)(projectile.width / 2); - projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); - Main.PlaySound(SoundID.Item14, projectile.position); - for (int num621 = 0; num621 < 10; num621++) - { - int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); - Main.dust[num622].velocity *= 3f; - if (Main.rand.NextBool(2)) - { - Main.dust[num622].scale = 0.5f; - Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; - } - } - for (int num623 = 0; num623 < 20; num623++) - { - int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 3f); - Main.dust[num624].noGravity = true; - Main.dust[num624].velocity *= 5f; - num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 246, 0f, 0f, 100, default, 2f); - Main.dust[num624].velocity *= 2f; - } - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 120); - } - } -} diff --git a/Projectiles/Rogue/NightsGazeProjectile.cs b/Projectiles/Rogue/NightsGazeProjectile.cs index 98570e8fe8..947e7fb52a 100644 --- a/Projectiles/Rogue/NightsGazeProjectile.cs +++ b/Projectiles/Rogue/NightsGazeProjectile.cs @@ -29,6 +29,8 @@ namespace CalamityMod.Projectiles.Rogue projectile.Calamity().rogue = true; } + private int SplitProjDamage => (int)(projectile.damage * (projectile.Calamity().stealthStrike ? 1f : 0.75f)); + public override void AI() { if (projectile.ai[0] == 0f) @@ -40,11 +42,12 @@ namespace CalamityMod.Projectiles.Rogue { if (Main.rand.NextBool(8)) { - int projectileDamage = (int)(projectile.damage * 0.75f); - int projectileType = ModContent.ProjectileType(); + int projID = ModContent.ProjectileType(); + int starDamage = SplitProjDamage; + float starKB = 5f; Vector2 velocity = projectile.velocity; - int p = Projectile.NewProjectile(projectile.Center, velocity, projectileType, projectileDamage, 5f, projectile.owner, 1f, 0f); + int p = Projectile.NewProjectile(projectile.Center, velocity, projID, starDamage, starKB, projectile.owner, 1f, 0f); Main.projectile[p].penetrate = 1; } } @@ -53,33 +56,31 @@ namespace CalamityMod.Projectiles.Rogue public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), projectile.timeLeft); - OnHitEffects(); + OnHitEffects(); } public override void OnHitPvp(Player target, int damage, bool crit) { target.AddBuff(ModContent.BuffType(), projectile.timeLeft); - OnHitEffects(); - } + OnHitEffects(); + } - private void OnHitEffects() - { - int starCount = 6; - int starFrequency = 3; + private void OnHitEffects() + { + int onHitCount = 6; + int chanceOfStar = 2; float spread = 20f; - for (int i = 0; i < starCount; i++) + int projectileDamage = SplitProjDamage; + float kb = 5f; + int sparkID = ModContent.ProjectileType(); + int starID = ModContent.ProjectileType(); + for (int i = 0; i < onHitCount; i++) { - int projectileDamage = (int)(projectile.damage * 0.75f); - int projectileType = ModContent.ProjectileType(); - if (Main.rand.Next(starCount) < starFrequency) - { - projectileType = ModContent.ProjectileType(); - } + int projID = Main.rand.NextBool(chanceOfStar) ? starID : sparkID; Vector2 velocity = projectile.oldVelocity.RotateRandom(MathHelper.ToRadians(spread)); float speed = Main.rand.NextFloat(1.5f, 2f); float moveDuration = Main.rand.Next(5, 15); - - Projectile.NewProjectile(projectile.Center, velocity * speed, projectileType, projectileDamage, 5f, projectile.owner, 0f, moveDuration); + Projectile.NewProjectile(projectile.Center, velocity * speed, projID, projectileDamage, kb, projectile.owner, 0f, moveDuration); } Main.PlaySound(SoundID.Item, (int)projectile.position.X, (int)projectile.position.Y, 62, 0.6f); @@ -103,8 +104,8 @@ namespace CalamityMod.Projectiles.Rogue public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) { - Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/NightsGazeGlow"); - Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / 2f); + Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Weapons/Rogue/NightsGazeGlow"); + Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / 2f); spriteBatch.Draw(texture, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, origin, 1f, SpriteEffects.None, 0f); } @@ -112,12 +113,12 @@ namespace CalamityMod.Projectiles.Rogue { for (int i = 0; i < 5; i++) { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 109, - 111, - 132 - }); + int dustType = Utils.SelectRandom(Main.rand, new int[] + { + 109, + 111, + 132 + }); int dust = Dust.NewDust(projectile.Center, 1, 1, dustType, projectile.velocity.X / 3f, projectile.velocity.Y / 3f, 0, default, 1.5f); Main.dust[dust].noGravity = true; diff --git a/Projectiles/Rogue/PhantasmalRuinProj.cs b/Projectiles/Rogue/PhantasmalRuinProj.cs index d1de1db628..edafe36ff9 100644 --- a/Projectiles/Rogue/PhantasmalRuinProj.cs +++ b/Projectiles/Rogue/PhantasmalRuinProj.cs @@ -82,8 +82,10 @@ namespace CalamityMod.Projectiles.Rogue { // Each pair of souls has randomized player homing strength float ai1 = Main.rand.NextFloat() + 0.5f; - Projectile.NewProjectile(projectile.Center, velocity, projID, soulDamage, soulKB, projectile.owner, 0f, ai1); - Projectile.NewProjectile(projectile.Center, -velocity, projID, soulDamage, soulKB, projectile.owner, 0f, ai1); + if (Main.rand.NextBool(2)) + Projectile.NewProjectile(projectile.Center, velocity, projID, soulDamage, soulKB, projectile.owner, 0f, ai1); + if (Main.rand.NextBool(2)) + Projectile.NewProjectile(projectile.Center, -velocity, projID, soulDamage, soulKB, projectile.owner, 0f, ai1); // Rotate direction for the next pair of souls. velocity = velocity.RotatedBy(MathHelper.TwoPi / numSouls); diff --git a/Projectiles/Rogue/ReaperProjectile.cs b/Projectiles/Rogue/ReaperProjectile.cs index b0c1f71a8b..947291b71d 100644 --- a/Projectiles/Rogue/ReaperProjectile.cs +++ b/Projectiles/Rogue/ReaperProjectile.cs @@ -24,11 +24,11 @@ namespace CalamityMod.Projectiles.Rogue projectile.height = 70; projectile.friendly = true; projectile.tileCollide = false; - projectile.penetrate = 12; + projectile.penetrate = 30; projectile.timeLeft = 1080; projectile.extraUpdates = 3; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 40; // can't hit too fast, but can hit many many times + projectile.localNPCHitCooldown = 32; // can't hit too fast, but can hit many many times projectile.Calamity().rogue = true; } diff --git a/Projectiles/Rogue/ValedictionBoomerang.cs b/Projectiles/Rogue/ValedictionBoomerang.cs index 3419450543..b835b7262a 100644 --- a/Projectiles/Rogue/ValedictionBoomerang.cs +++ b/Projectiles/Rogue/ValedictionBoomerang.cs @@ -2,7 +2,6 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -11,7 +10,7 @@ namespace CalamityMod.Projectiles.Rogue { public class ValedictionBoomerang : ModProjectile { - public override string Texture => "CalamityMod/Items/Weapons/Rogue/Valediction"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/Valediction"; public override void SetStaticDefaults() { @@ -133,7 +132,8 @@ namespace CalamityMod.Projectiles.Rogue private void OnHitEffects() { int typhoonAmt = 3; - if (projectile.owner == Main.myPlayer && projectile.Calamity().stealthStrike) + int typhoonDamage = (int)(projectile.damage * 1.6f); + if (projectile.owner == Main.myPlayer && projectile.numHits < 1 && projectile.Calamity().stealthStrike) { Main.PlaySound(SoundID.Item84, projectile.position); for (int typhoonCount = 0; typhoonCount < typhoonAmt; typhoonCount++) @@ -145,7 +145,7 @@ namespace CalamityMod.Projectiles.Rogue } velocity.Normalize(); velocity *= (float)Main.rand.Next(70, 101) * 0.1f; - Projectile typhoon = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), projectile.damage / 2, 0f, projectile.owner); + Projectile typhoon = Projectile.NewProjectileDirect(projectile.Center, velocity, ModContent.ProjectileType(), typhoonDamage, 0f, projectile.owner); if (typhoon.whoAmI.WithinBounds(Main.maxProjectiles)) { typhoon.Calamity().forceRogue = true; diff --git a/Projectiles/Summon/DazzlingStabber.cs b/Projectiles/Summon/DazzlingStabber.cs index 5eb8d4bce0..1a5af418d3 100644 --- a/Projectiles/Summon/DazzlingStabber.cs +++ b/Projectiles/Summon/DazzlingStabber.cs @@ -1,33 +1,24 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Summon { - public class DazzlingStabber : ModProjectile + public class DazzlingStabber : ModProjectile { - public float NPCTargetTimer - { - get => projectile.ai[0]; - set => projectile.ai[0] = value; - } - public float IdleOffsetAngle - { - get => projectile.ai[1]; - set => projectile.ai[1] = value; - } - public const float DistanceToCheck = 1500f; - public const float TeleportSlice = 40f; - public static readonly float TeleportSliceAngleMax = MathHelper.ToRadians(23f); + public Player Owner => Main.player[projectile.owner]; + public ref float AttackDelay => ref projectile.ai[0]; + public ref float RestOffsetAngle => ref projectile.ai[1]; public override void SetStaticDefaults() { DisplayName.SetDefault("Dazzling Stabber"); Main.projFrames[projectile.type] = 4; + ProjectileID.Sets.TrailingMode[projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[projectile.type] = 25; ProjectileID.Sets.MinionSacrificable[projectile.type] = true; ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true; } @@ -40,128 +31,146 @@ namespace CalamityMod.Projectiles.Summon projectile.friendly = true; projectile.ignoreWater = true; projectile.minionSlots = 1f; - projectile.timeLeft = 18000; + projectile.timeLeft = 90000; projectile.penetrate = -1; projectile.tileCollide = false; - projectile.timeLeft *= 5; projectile.minion = true; + projectile.light = 1f; projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 12; + projectile.localNPCHitCooldown = 10; } public override void AI() { Lighting.AddLight(projectile.Center, Color.White.ToVector3()); - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + + ApplyPlayerBuffs(); + AdjustDamageDynamically(); + UpdateFrames(); + + NPC potentialTarget = projectile.Center.MinionHoming(1100f, Owner); + + if (potentialTarget != null) + SliceTarget(potentialTarget); + else + ReturnToRestingPosition(); + } + + public void ApplyPlayerBuffs() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (projectile.type == ModContent.ProjectileType()) + { + if (Owner.dead) + Owner.Calamity().providenceStabber = false; + if (Owner.Calamity().providenceStabber) + projectile.timeLeft = 2; + } + } + + public void AdjustDamageDynamically() + { if (projectile.localAI[0] == 0f) { - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; projectile.localAI[0] = 1f; } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) + if (Owner.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) { - int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); + int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / projectile.Calamity().spawnedPlayerMinionDamageValue * Owner.MinionDamage()); projectile.damage = trueDamage; } - bool isProperProjectile = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (isProperProjectile) - { - if (player.dead) - { - modPlayer.providenceStabber = false; - } - if (modPlayer.providenceStabber) - { - projectile.timeLeft = 2; - } - } + } - NPC potentialTarget = projectile.Center.MinionHoming(DistanceToCheck, player); - - if (projectile.frameCounter++ > 6) - { + public void UpdateFrames() + { + projectile.frameCounter++; + if (projectile.frameCounter % 6 == 0) projectile.frame = (projectile.frame + 1) % Main.projFrames[projectile.type]; - projectile.frameCounter = 0; - } - - if (potentialTarget is null) - { - projectile.rotation = projectile.rotation.AngleTowards(IdleOffsetAngle, 0.05f); - Vector2 destination = player.Center + new Vector2(0f, -120f).RotatedBy(IdleOffsetAngle); - projectile.velocity = (destination - projectile.Center) / 15f; - } - else - { - NPCTargetTimer++; - // Alternate between normal charge and slower charge/knife summon - if (NPCTargetTimer % 160f < 100f) - { - ChargeAttack(potentialTarget); - } - // Teleport onto the target and just the rotation for a slice. - else if (NPCTargetTimer % 160f == 160f - TeleportSlice) - { - TeleportOntoTarget(potentialTarget); - } - // Slice the target and don't move. - else if (NPCTargetTimer % 160f > 160f - TeleportSlice) - { - projectile.rotation -= TeleportSliceAngleMax * 2f / TeleportSlice; - } - } - projectile.direction = projectile.spriteDirection = (projectile.velocity.X > 0).ToDirectionInt(); } - public void ChargeAttack(NPC target) + public void SliceTarget(NPC target) { - if (NPCTargetTimer % 160f < 30f) + // Don't do anything if the attack delay is still passing. + if (AttackDelay > -60f) { - projectile.velocity *= 0.99f; - projectile.rotation = projectile.rotation.AngleLerp(projectile.AngleTo(target.Center) + MathHelper.PiOver2, 0.25f); + AttackDelay--; + if (AttackDelay > 0f) + return; } - else if (NPCTargetTimer % 160f == 30f) + + // Don't do anything if very close to the target. + if (projectile.WithinRange(target.Center, 60f)) + return; + + // Reset the velocity to fly upward if there is very little motion to ensure + // that the summon does not get stuck. + if (projectile.velocity.Length() < 1.6f) + projectile.velocity = Vector2.UnitY * 5f; + + // If close to the target, slow down dramatically. + if (projectile.velocity.Length() > 5f && projectile.WithinRange(target.Center, 90f)) + projectile.velocity *= 0.8f; + + // Otherwise, if not close, speed up dramatically. + else if (projectile.velocity.Length() < 40f) + projectile.velocity *= 1.03f; + + float angularTurnSpeed = 0.35f; + float angleToTargetCoords = projectile.AngleTo(target.Center); + + projectile.velocity = projectile.velocity.ToRotation().AngleTowards(angleToTargetCoords, angularTurnSpeed).ToRotationVector2() * projectile.velocity.Length(); + + // If not super close to the target but the target is very much in the line of sight of the summon, charge. + if (!projectile.WithinRange(target.Center, 75f) && Vector2.Dot(projectile.DirectionTo(target.Center), projectile.velocity.SafeNormalize(Vector2.Zero)) > 0.85f) { - projectile.velocity = projectile.DirectionTo(target.Center) * 20f; + projectile.velocity = projectile.DirectionTo(target.Center) * 36f; + AttackDelay = 15f; + projectile.netUpdate = true; } - else if (NPCTargetTimer % 160f < 60f) - { - projectile.velocity *= 0.99f; - projectile.rotation = projectile.rotation.AngleLerp(projectile.AngleTo(target.Center) + MathHelper.PiOver2, 0.25f); - } - else if (NPCTargetTimer % 160f == 60f) - { - projectile.velocity = projectile.DirectionTo(target.Center) * 16f; - for (int i = 0; i < 3; i++) - { - float angle = MathHelper.Lerp(-0.3f, 0.3f, i / 3f); - Projectile.NewProjectile(projectile.Center, projectile.velocity.RotatedBy(angle), ModContent.ProjectileType(), (int)(projectile.damage * 0.25), 1f, projectile.owner); - } - } - else projectile.velocity *= 0.99f; + + projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; } - public void TeleportOntoTarget(NPC target) + public void ReturnToRestingPosition() { - // Spawn a spiral of holy flame dust. - float angleStart = Main.rand.NextFloat(MathHelper.TwoPi); - for (int i = 0; i < 30; i++) + projectile.rotation = projectile.rotation.AngleTowards(RestOffsetAngle, 0.25f); + + // Rapidly approach the resting position. + Vector2 destination = Owner.Center + Vector2.UnitY.RotatedBy(RestOffsetAngle) * -120f; + projectile.velocity = (destination - projectile.Center) / 10f; + } + + public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + { + for (int i = 1; i < projectile.oldPos.Length; i++) + CalamityUtils.DistanceClamp(ref projectile.oldPos[i - 1], ref projectile.oldPos[i], 6f); + + Texture2D trailSegmentTexture = ModContent.GetTexture("CalamityMod/Projectiles/StarProj"); + for (int i = 2; i < projectile.oldPos.Length; i++) { - float angle = MathHelper.TwoPi / 30f * i + angleStart; - Dust dust = Dust.NewDustPerfect(projectile.Center + angle.ToRotationVector2() * 10f, (int)CalamityDusts.ProfanedFire); - dust.velocity = angle.ToRotationVector2() * 5f * MathHelper.Lerp(1f, 0f, i % 6f / 6f); + float completionRatio = i / (float)projectile.oldPos.Length; + float rotation = (projectile.oldPos[i - 1] - projectile.oldPos[i]).ToRotation() + MathHelper.PiOver2; + float scale = MathHelper.Lerp(0.7f, 0.1f, completionRatio) * projectile.scale; + Color color = Color.Lerp(Color.LightPink, Color.Goldenrod, completionRatio * 3f % 1f) * 1.5f; + + // Become dimmer the slower the projectile is moving. + color *= Utils.InverseLerp(1f, 8f, projectile.velocity.Length(), true); + + // As well as how close the projectile is to pointing away from its rotation. + color *= Utils.InverseLerp(0.65f, 0.45f, projectile.velocity.AngleBetween(-(projectile.rotation + MathHelper.PiOver2).ToRotationVector2()) / MathHelper.Pi, true); + + spriteBatch.Draw(trailSegmentTexture, + projectile.oldPos[i] + projectile.Size * 0.5f + new Vector2(0f, 8f).RotatedBy(projectile.rotation) - Main.screenPosition, + null, + color, + rotation, + trailSegmentTexture.Size() * 0.5f, + scale, + SpriteEffects.None, + 0f); } - - Vector2 teleportOffset = Utils.RandomVector2(Main.rand, -12f, 12f); - - projectile.Center = target.Center + teleportOffset; - projectile.rotation = projectile.AngleTo(target.Center) + MathHelper.PiOver2 + TeleportSliceAngleMax; - projectile.velocity = Vector2.Zero; - projectile.netUpdate = true; } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) diff --git a/Projectiles/Summon/DazzlingStabberKnife.cs b/Projectiles/Summon/DazzlingStabberKnife.cs deleted file mode 100644 index b3cfa88bfd..0000000000 --- a/Projectiles/Summon/DazzlingStabberKnife.cs +++ /dev/null @@ -1,59 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class DazzlingStabberKnife : ModProjectile - { - public const float HomingSpeed = 17f; - public const float HomingInertia = 20f; - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Knife"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } - - public override void SetDefaults() - { - projectile.width = 14; - projectile.height = 24; - projectile.friendly = true; - projectile.minion = true; - projectile.minionSlots = 0f; - projectile.ignoreWater = true; - projectile.penetrate = 1; - projectile.timeLeft = 600; - } - public override void AI() - { - Lighting.AddLight(projectile.Center, Color.White.ToVector3()); - projectile.rotation = projectile.velocity.ToRotation() + MathHelper.PiOver2; - NPC potentialTarget = projectile.Center.MinionHoming(750f, Main.player[projectile.owner]); - if (potentialTarget != null) - { - if (projectile.Distance(potentialTarget.Center) > 70f) - { - projectile.velocity = (projectile.velocity * (HomingInertia - 1f) + projectile.DirectionTo(potentialTarget.Center) * HomingSpeed) / HomingInertia; - } - } - } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 2); - return false; - } - - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } - - public override void OnHitPvp(Player target, int damage, bool crit) - { - target.AddBuff(ModContent.BuffType(), 60); - } - } -} diff --git a/Projectiles/Summon/DazzlingStabberKnife.png b/Projectiles/Summon/DazzlingStabberKnife.png deleted file mode 100644 index 35d51ec4d1..0000000000 Binary files a/Projectiles/Summon/DazzlingStabberKnife.png and /dev/null differ diff --git a/Projectiles/Summon/EndoHydraHead.cs b/Projectiles/Summon/EndoHydraHead.cs index 1e3eef0a40..664a2756cc 100644 --- a/Projectiles/Summon/EndoHydraHead.cs +++ b/Projectiles/Summon/EndoHydraHead.cs @@ -169,6 +169,7 @@ namespace CalamityMod.Projectiles.Summon projectile.MinionAntiClump(0.15f); AdjustOldVelocityArray(); } + public void AdjustOldVelocityArray() { for (int i = OldVelocities.Length - 1; i > 0; i--) @@ -177,6 +178,7 @@ namespace CalamityMod.Projectiles.Summon } OldVelocities[0] = projectile.velocity; } + public override void Kill(int timeLeft) { for (int i = 0; i < 10; i++) diff --git a/Projectiles/Summon/GammaBullet.cs b/Projectiles/Summon/GammaBullet.cs deleted file mode 100644 index 5da5edb652..0000000000 --- a/Projectiles/Summon/GammaBullet.cs +++ /dev/null @@ -1,70 +0,0 @@ -using CalamityMod.Buffs.DamageOverTime; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class GammaBullet : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/Enemy/NuclearBulletMedium"; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gamma Bullet"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } - - public override void SetDefaults() - { - projectile.width = 24; - projectile.height = 12; - projectile.friendly = true; - projectile.minion = true; - projectile.minionSlots = 0f; - projectile.alpha = 255; - projectile.timeLeft = 180; - projectile.tileCollide = true; - projectile.ignoreWater = true; - } - public override void AI() - { - Lighting.AddLight(projectile.Center, Color.White.ToVector3() * 1.25f); - projectile.ai[1]++; - if (projectile.ai[1] <= 20f) - { - projectile.alpha = (int)MathHelper.Lerp(255, 0, projectile.ai[1] / 20f); - } - if (projectile.ai[1] % 10f == 9f) - { - for (int i = 0; i < 24; i++) - { - float angle = MathHelper.TwoPi / 24f * i; - Dust dust = Dust.NewDustPerfect(projectile.Center + angle.ToRotationVector2().RotatedBy(projectile.rotation) * new Vector2(7f, 4f), (int)CalamityDusts.SulfurousSeaAcid); - dust.scale = 0.9f; - dust.alpha = projectile.alpha; - dust.noGravity = true; - } - } - projectile.velocity *= 1.03f; - projectile.rotation = projectile.velocity.ToRotation(); - } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 240); - } - public override void Kill(int timeLeft) - { - for (int i = 0; i <= 2; i++) - { - int idx = Dust.NewDust(projectile.position, 8, 8, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 0.75f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - idx = Dust.NewDust(projectile.position, 8, 8, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 0.75f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - } - } - } -} diff --git a/Projectiles/Summon/GammaCanister.cs b/Projectiles/Summon/GammaCanister.cs index c997d37fc3..7c45c9affb 100644 --- a/Projectiles/Summon/GammaCanister.cs +++ b/Projectiles/Summon/GammaCanister.cs @@ -1,14 +1,13 @@ -using CalamityMod.Dusts; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Summon { public class GammaCanister : ModProjectile { + public const float Gravity = 0.2f; public override void SetStaticDefaults() { DisplayName.SetDefault("Gamma Canister"); @@ -19,75 +18,38 @@ namespace CalamityMod.Projectiles.Summon { projectile.width = 20; projectile.height = 28; - projectile.friendly = projectile.hostile = false; + projectile.friendly = true; projectile.minion = true; projectile.minionSlots = 0f; + projectile.alpha = 255; projectile.timeLeft = 300; projectile.tileCollide = true; projectile.ignoreWater = true; } public override void AI() { - if (!Main.player[projectile.owner].Calamity().GammaCanisters.Contains(projectile.whoAmI)) + NPC potentialTarget = projectile.Center.MinionHoming(1450f, Main.player[projectile.owner]); + if (projectile.timeLeft >= 180) + projectile.velocity.Y += Gravity; + + else if (potentialTarget != null) { - Main.player[projectile.owner].Calamity().GammaCanisters.Add(projectile.whoAmI); + // This looks quite stupid but the weapon is going to be useless otherwise and I'm not reworking this thing a 3rd time. + projectile.velocity = Vector2.Lerp(projectile.velocity, projectile.DirectionTo(potentialTarget.Center) * 18f, 0.18f); } - projectile.ai[1]++; - if (projectile.ai[1] == 80f) - { - for (int i = 0; i < 36; i++) - { - Vector2 velocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(3f, 8f); - Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.SulfurousSeaAcid); - dust.velocity = velocity; - dust.noGravity = true; - dust.scale = Main.rand.NextFloat(1.3f, 1.7f); - } - } - projectile.velocity = Vector2.UnitY * (float)Math.Sin(projectile.ai[1] / 40f * MathHelper.TwoPi) * 0.5f; - } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - const float totalRotations = 3f; - const float outwardPositionDeltaStart = 8f; - float angle = MathHelper.TwoPi * projectile.ai[1] / totalRotations / 80f; - float outwardPositionDelta = outwardPositionDeltaStart; - if (projectile.ai[1] < 80f && projectile.ai[1] > 55f) - { - outwardPositionDelta = MathHelper.Lerp(outwardPositionDeltaStart, 0f, (projectile.ai[1] - 55f) / 35f); - } - if (projectile.ai[1] >= 80f) - { - outwardPositionDelta = 0f; - } - for (int i = 0; i < 3; i++) - { - angle += MathHelper.TwoPi / 3f * i; - spriteBatch.Draw(ModContent.GetTexture(Texture), - projectile.Center + angle.ToRotationVector2() * outwardPositionDelta + Vector2.UnitY * (float)Math.Cos(angle) * 3f - Main.screenPosition, - null, - Color.White, - projectile.rotation, - projectile.Size * 0.5f, - projectile.scale, - SpriteEffects.None, - 0f); - } - return false; + projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; + projectile.alpha = Utils.Clamp(projectile.alpha - 22, 0, 255); } + public override void Kill(int timeLeft) { - Main.player[projectile.owner].Calamity().GammaCanisters.Clear(); - for (int i = 0; i < 12; i++) + if (Main.myPlayer != projectile.owner) + return; + + for (int i = 0; i < 6; i++) { - int idx = Dust.NewDust(projectile.position, 8, 8, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 0.75f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = 1.8f; - idx = Dust.NewDust(projectile.position, 8, 8, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 0.75f); - Main.dust[idx].noGravity = true; - Main.dust[idx].velocity *= 3f; - Main.dust[idx].scale = 1.8f; + Vector2 shootVelocity = (MathHelper.TwoPi * i / 12f).ToRotationVector2() * Main.rand.NextFloat(6f, 17f); + Projectile.NewProjectile(projectile.Center + shootVelocity * 2f, shootVelocity, ModContent.ProjectileType(), projectile.damage / 2, projectile.knockBack * 0.4f, projectile.owner); } } } diff --git a/Projectiles/Summon/GammaDeathray.cs b/Projectiles/Summon/GammaDeathray.cs deleted file mode 100644 index a2fefb5628..0000000000 --- a/Projectiles/Summon/GammaDeathray.cs +++ /dev/null @@ -1,199 +0,0 @@ -using CalamityMod.Buffs.StatDebuffs; -using CalamityMod.Dusts; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.IO; -using Terraria; -using Terraria.ID; -using Terraria.Enums; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Summon -{ - public class GammaDeathray : ModProjectile - { - public override string Texture => "CalamityMod/Projectiles/Enemy/CragmawBeam"; - - public float MaximumLength => projectile.Distance(Main.MouseWorld); - // How fat the laser is - public const float LaserSize = 1.35f; - // Pretty self explanatory - public const int TotalFadeoutTime = 45; - - public override void SetStaticDefaults() - { - DisplayName.SetDefault("Gamma Ray"); - ProjectileID.Sets.MinionShot[projectile.type] = true; - } - - public override void SetDefaults() - { - projectile.width = 22; - projectile.height = 22; - projectile.friendly = true; - projectile.minion = true; - projectile.penetrate = -1; - projectile.tileCollide = false; - projectile.timeLeft = 10000; - projectile.usesLocalNPCImmunity = true; - projectile.localNPCHitCooldown = 7; - } - - // Netcode for sending and receiving shit - // localAI[0] is the timer, localAI[1] is the laser length - - public override void SendExtraAI(BinaryWriter writer) - { - writer.Write(projectile.localAI[0]); - writer.Write(projectile.localAI[1]); - } - - public override void ReceiveExtraAI(BinaryReader reader) - { - projectile.localAI[0] = reader.ReadSingle(); - projectile.localAI[1] = reader.ReadSingle(); - } - - public override void AI() - { - Projectile owner = Main.projectile[(int)projectile.ai[0]]; - if (!owner.active || owner.type != ModContent.ProjectileType()) - projectile.Kill(); - - if (Main.myPlayer == projectile.owner) - { - projectile.velocity = projectile.AngleTo(Main.MouseWorld).ToRotationVector2(); - projectile.rotation = projectile.velocity.ToRotation() - MathHelper.PiOver2; - - // Since the logic for this can only be run by one client, it must constantly be synced. - projectile.netUpdate = true; - projectile.netSpam = 0; - } - - if (owner.active) - { - projectile.Center = owner.Center + projectile.AngleTo(Main.MouseWorld).ToRotationVector2() * 12f; - } - projectile.localAI[0] += 1f; - - // Fadein/out. The timeleft varies, so this must be done manually. - if (projectile.localAI[0] < TotalFadeoutTime) - { - projectile.scale = MathHelper.Lerp(0.01f, LaserSize, projectile.localAI[0] / TotalFadeoutTime); - } - - if (projectile.timeLeft < TotalFadeoutTime) - { - projectile.scale = MathHelper.Lerp(LaserSize, 0f, 1f - (projectile.timeLeft / (float)TotalFadeoutTime)); - } - - for (int i = 0; i < 6; i++) - { - Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.SulfurousSeaAcid); - dust.velocity = projectile.velocity.RotatedBy(MathHelper.Pi * 0.75f) * (i >= 3).ToDirectionInt(); - dust.velocity = dust.velocity.RotatedByRandom(0.3f); - dust.noGravity = true; - dust.scale = 1f / (float)Math.Cos(i / 6f * MathHelper.PiOver2) / (float)Math.Sqrt(i + 1); - } - - Vector2 samplingPoint = projectile.Center; - - float[] samples = new float[3]; - - float determinedLength = 0f; - Collision.LaserScan(samplingPoint, projectile.velocity, projectile.width * projectile.scale, MaximumLength, samples); - for (int i = 0; i < samples.Length; i++) - { - determinedLength += samples[i]; - } - determinedLength /= samples.Length; - - determinedLength = MathHelper.Clamp(determinedLength, MaximumLength * 0.5f, MaximumLength); - - float lerpDelta = 0.5f; - projectile.localAI[1] = MathHelper.Lerp(projectile.localAI[1], determinedLength, lerpDelta); - Vector2 beamEndPosiiton = projectile.Center + projectile.velocity * (projectile.localAI[1] - 6f); - - // Draw acid green light across the laser - DelegateMethods.v3_1 = new Vector3(0.62f, 0.94f, 0.38f); - Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CastLight)); - } - public override void Kill(int timeLeft) - { - Main.projectile[(int)projectile.ai[0]].ai[0] = 0f; // Detach this laser from its owner. - Main.projectile[(int)projectile.ai[0]].netUpdate = true; - } - public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) - { - if (projectile.velocity == Vector2.Zero) - { - return false; - } - Texture2D laserTailTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/GammaBeamBegin"); - Texture2D laserBodyTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/GammaBeamMid"); - Texture2D laserHeadTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/Lasers/GammaBeamEnd"); - float laserLength = projectile.localAI[1]; - Color drawColor = new Color(1f, 1f, 1f) * 0.9f; - - // Laser tail logic - - Main.spriteBatch.Draw(laserTailTexture, projectile.Center - Main.screenPosition, null, drawColor, projectile.rotation, laserTailTexture.Size() / 2f, projectile.scale, SpriteEffects.None, 0f); - - // Laser body logic - - laserLength -= (laserTailTexture.Height / 2 + laserHeadTexture.Height) * projectile.scale; - Vector2 centerDelta = projectile.Center; - centerDelta += projectile.velocity * projectile.scale * (float)laserTailTexture.Height / 2f; - if (laserLength > 0f) - { - float laserLengthDelta = 0f; - Rectangle sourceRectangle = new Rectangle(0, 16 * (projectile.timeLeft / 3 % 5), laserBodyTexture.Width, 16); - while (laserLengthDelta + 1f < laserLength) - { - if (laserLength - laserLengthDelta < sourceRectangle.Height) - { - sourceRectangle.Height = (int)(laserLength - laserLengthDelta); - } - Main.spriteBatch.Draw(laserBodyTexture, centerDelta - Main.screenPosition, new Rectangle?(sourceRectangle), drawColor, projectile.rotation, new Vector2(sourceRectangle.Width / 2f, 0f), projectile.scale, SpriteEffects.None, 0f); - laserLengthDelta += sourceRectangle.Height * projectile.scale; - centerDelta += projectile.velocity * sourceRectangle.Height * projectile.scale; - sourceRectangle.Y += 16; - if (sourceRectangle.Y + sourceRectangle.Height > laserBodyTexture.Height) - { - sourceRectangle.Y = 0; - } - } - } - - // Laser head logic - - Main.spriteBatch.Draw(laserHeadTexture, centerDelta - Main.screenPosition, null, drawColor, projectile.rotation, laserHeadTexture.Frame(1, 1, 0, 0).Top(), projectile.scale, SpriteEffects.None, 0f); - return false; - } - - public override void CutTiles() - { - DelegateMethods.tilecut_0 = TileCuttingContext.AttackProjectile; - Vector2 unit = projectile.velocity; - Utils.PlotTileLine(projectile.Center, projectile.Center + unit * projectile.localAI[1], (float)projectile.width * projectile.scale, new Utils.PerLinePoint(DelegateMethods.CutTiles)); - } - - public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) - { - if (projHitbox.Intersects(targetHitbox)) - { - return true; - } - float value = 0f; - if (Collision.CheckAABBvLineCollision(targetHitbox.TopLeft(), targetHitbox.Size(), projectile.Center, projectile.Center + projectile.velocity * projectile.localAI[1], 22f * projectile.scale, ref value)) - { - return true; - } - return false; - } - public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) - { - target.AddBuff(ModContent.BuffType(), 300); - } - } -} diff --git a/Projectiles/Summon/GammaHead.cs b/Projectiles/Summon/GammaHead.cs index 9677b86323..39baa1a432 100644 --- a/Projectiles/Summon/GammaHead.cs +++ b/Projectiles/Summon/GammaHead.cs @@ -1,10 +1,11 @@ using CalamityMod.Buffs.Summon; +using CalamityMod.DataStructures; using CalamityMod.Dusts; -using CalamityMod.CalPlayer; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -13,14 +14,20 @@ namespace CalamityMod.Projectiles.Summon { public class GammaHead : ModProjectile { - public Vector2 DeltaPosition; - public int BulletShootCounter; - public float AngularMultiplier1; - public float AngularMultiplier2; - public const int MaximumLaserCount = 6; // Otherwise intense lag ensues. - public const float AttackStartWait = 30f; - public const float SuperchargeTimeMax = 540f; - public const float DistanceToCheck = 1000f; + public Vector2 CurrentPositionOffset; + public Vector2 IdealPositionOffset; + public Vector2[] OldVelocities = new Vector2[20]; + public Player Owner => Main.player[projectile.owner]; + public ref float Time => ref projectile.ai[0]; + public Vector2 DrawStartPosition + { + get + { + if (projectile.owner < 0 || projectile.owner >= Main.player.Length) + return Vector2.Zero; + return Main.player[projectile.owner].Top + Vector2.UnitY * 8f; + } + } public override void SetStaticDefaults() { DisplayName.SetDefault("Gamma Head"); @@ -42,278 +49,216 @@ namespace CalamityMod.Projectiles.Summon projectile.tileCollide = false; projectile.timeLeft *= 5; projectile.minion = true; - projectile.coldDamage = true; - } - public Vector2 DrawStartPosition - { - get - { - if (projectile.owner < 0 || projectile.owner >= Main.player.Length) - return Vector2.Zero; - return Main.player[projectile.owner].Top + Vector2.UnitY * 8f; - } - } - public override void ReceiveExtraAI(BinaryReader reader) - { - BulletShootCounter = reader.ReadInt32(); - AngularMultiplier1 = reader.ReadSingle(); - AngularMultiplier2 = reader.ReadSingle(); - DeltaPosition = reader.ReadVector2(); } + public override void SendExtraAI(BinaryWriter writer) { - writer.Write(BulletShootCounter); - writer.Write(AngularMultiplier1); - writer.Write(AngularMultiplier2); - writer.WriteVector2(DeltaPosition); + writer.WritePackedVector2(CurrentPositionOffset); + writer.WritePackedVector2(IdealPositionOffset); } + + public override void ReceiveExtraAI(BinaryReader reader) + { + CurrentPositionOffset = reader.ReadPackedVector2(); + IdealPositionOffset = reader.ReadPackedVector2(); + } + public override void AI() { - Player player = Main.player[projectile.owner]; - CalamityPlayer modPlayer = player.Calamity(); + Vector2 returnPosition = DrawStartPosition + CurrentPositionOffset; - if (DeltaPosition == Vector2.Zero) + if (projectile.localAI[0] == 0f) { - int totalHeads = CalamityUtils.CountProjectiles(projectile.type); - DeltaPosition = new Vector2(Main.rand.NextFloat(-42f - 6f * totalHeads, 42f + 6f * totalHeads), -Main.rand.NextFloat(8f, 64f + 7f * totalHeads)); - - projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage(); - projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; - - AngularMultiplier1 = Main.rand.NextFloat(3f); - AngularMultiplier2 = Main.rand.NextFloat(3f); - projectile.netUpdate = true; + PerformInitializationEffects(); projectile.localAI[0] = 1f; - } - - bool isProperProjectile = projectile.type == ModContent.ProjectileType(); - player.AddBuff(ModContent.BuffType(), 3600); - if (isProperProjectile) - { - if (player.dead) - { - modPlayer.gammaHead = false; - } - if (modPlayer.gammaHead) - { - projectile.timeLeft = 2; - } } - if (modPlayer.GammaCanisters.Count > 0) - { - for (int i = 0; i < modPlayer.GammaCanisters.Count; i++) - { - if (projectile.Hitbox.Intersects(Main.projectile[modPlayer.GammaCanisters[i]].Hitbox) && - Main.projectile[modPlayer.GammaCanisters[i]].active) - { - int laserCount = 0; - for (int j = 0; j < Main.projectile.Length; j++) - { - if (laserCount < MaximumLaserCount) - { - if (Main.projectile[j].type == projectile.type && Main.projectile[j].owner == projectile.owner && - Main.projectile[j].ai[0] == 0f && Main.projectile[j].active && Main.projectile[j].ai[1] <= 0) - { - Main.projectile[j].ai[0] = Projectile.NewProjectile(projectile.Center, Vector2.UnitY, ModContent.ProjectileType(), - (int)(projectile.damage * 1.2f), projectile.knockBack, projectile.owner, Main.projectile[j].whoAmI); + ApplyMinionBuffs(); - Main.projectile[j].ai[1] = SuperchargeTimeMax; - Main.projectile[j].netUpdate = true; - laserCount++; - } - } - else - { - Main.projectile[j].ai[1] = SuperchargeTimeMax; - Main.projectile[j].netUpdate = true; - } - } + projectile.direction = projectile.spriteDirection = Owner.direction; - // Kill removes the respective canister from the list. No need to do this manually. - for (int j = 0; j < modPlayer.GammaCanisters.Count; j++) - { - Main.projectile[modPlayer.GammaCanisters[i]].Kill(); - } - break; - } - } - } - - // Spawn gamma canisters - else if (player.ownedProjectileCounts[projectile.type] >= 7) - { - int ownedGammaHeads = player.ownedProjectileCounts[projectile.type]; - int canisterSpawnChance = 520 - (int)(200 * (1 - 1f / (ownedGammaHeads + 6f))); - if (Main.rand.NextBool(canisterSpawnChance * ownedGammaHeads)) - { - Vector2 spawnPosition = player.Center + new Vector2(Main.screenWidth / 2, Main.screenHeight / 2) * Main.rand.NextFloat(-1f, 1f); - Projectile.NewProjectileDirect(spawnPosition, Vector2.Zero, ModContent.ProjectileType(), 0, 0f, projectile.owner); - } - } - - // Omega-complex dust. - projectile.localAI[1]++; - if (projectile.localAI[1] < 60f) - { - for (int i = 0; i < 5; i++) - { - float angle = projectile.localAI[1] / 60f * MathHelper.TwoPi; - float x = (float)Math.Sin(angle * AngularMultiplier1) * (float)Math.Cos(angle); - float y = (float)Math.Cos(angle * (float)Math.Cos(MathHelper.PiOver2 * AngularMultiplier2 + angle * 2f)) * (float)Math.Sin(angle); - Vector2 velocity = new Vector2(x * 4f, y * 4f) + player.velocity; - velocity = velocity.RotatedBy(MathHelper.TwoPi / 5f * i); - - Dust dust = Dust.NewDustPerfect(projectile.Center + angle.ToRotationVector2() * 8f, (int)CalamityDusts.SulfurousSeaAcid); - dust.velocity = velocity; - dust.scale = (float)Math.Cos(angle) + 1.3f; - dust.noGravity = true; - } - } - // Explosion - if (projectile.localAI[1] == 60f) - { - for (int i = 0; i < 60; i++) - { - float angle = MathHelper.TwoPi / 60f * i; - angle += projectile.AngleFrom(player.Center) / 60f; - angle += (float)Math.Sin(angle) * MathHelper.PiOver2; - Dust dust = Dust.NewDustPerfect(projectile.Center + angle.ToRotationVector2() * 8f, (int)CalamityDusts.SulfurousSeaAcid); - dust.velocity = angle.ToRotationVector2() * new Vector2(4f, 3f * (float)Math.Cos(angle)) * 3f; - dust.scale = 1.3f; - dust.noGravity = true; - } - } - if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue) - { - int trueDamage = (int)(projectile.Calamity().spawnedPlayerMinionProjectileDamageValue / - projectile.Calamity().spawnedPlayerMinionDamageValue * - player.MinionDamage()); - projectile.damage = trueDamage; - } - - Vector2 returnPosition = DrawStartPosition + (player.direction > 0).ToDirectionInt() * 6f * Vector2.UnitX + DeltaPosition; - - NPC potentialTarget = projectile.Center.MinionHoming(DistanceToCheck, player); - - // Kill laser when done - if (projectile.ai[1] == GammaDeathray.TotalFadeoutTime && projectile.ai[0] != 0f) - { - for (int i = 0; i < Main.projectile.Length; i++) - { - if (Main.projectile[i].active && Main.projectile[i].ai[1] >= 0f && Main.projectile[i].type == projectile.type && Main.projectile[i].owner == projectile.owner) - { - Main.projectile[i].spriteDirection = 1; - Main.projectile[i].ai[1] = 0f; - Main.projectile[i].netUpdate = true; - Main.projectile[(int)Main.projectile[i].ai[0]].timeLeft = GammaDeathray.TotalFadeoutTime; - } - } - } - // Bullet/deathray - if (projectile.ai[1] > 0) - { - projectile.direction = projectile.spriteDirection = 1; - projectile.rotation = projectile.AngleTo(Main.MouseWorld); - projectile.ai[1]--; - } - else if (potentialTarget != null) - { - if (projectile.Distance(player.Center) < DistanceToCheck && - Collision.CanHit(projectile.Center, 1, 1, player.Center, 1, 1) && - Main.myPlayer == projectile.owner) - { - BulletShootCounter++; - if (BulletShootCounter % 20f == 14f) - { - Projectile bullet = Projectile.NewProjectileDirect(projectile.Center, - projectile.DirectionTo(potentialTarget.Center) * 8f, - ModContent.ProjectileType(), projectile.damage, 2f, projectile.owner); - bullet.ai[0] = potentialTarget.whoAmI; - } - - if (BulletShootCounter % 20f >= 17f) - projectile.frame = Main.projFrames[projectile.type] - 1; - else if (BulletShootCounter % 20f >= 11f) - projectile.frame = Main.projFrames[projectile.type] - 2; - else if (BulletShootCounter % 20f >= 6f) - projectile.frame = Main.projFrames[projectile.type] - 3; - - projectile.direction = projectile.spriteDirection = (potentialTarget.Center.X - projectile.Center.X > 0).ToDirectionInt(); - returnPosition.X -= 48f * (player.Center.X - projectile.Center.X > 0).ToDirectionInt(); - } - else - { - projectile.direction = projectile.spriteDirection = (player.Center.X - projectile.Center.X > 0).ToDirectionInt(); - projectile.frame = 0; - } - projectile.rotation = projectile.rotation.AngleTowards(0f, 0.05f); - } + float idealRotation = 0f; + NPC potentialTarget = projectile.Center.MinionHoming(950f, Owner); + if (potentialTarget != null) + NoticeTarget(potentialTarget, ref returnPosition, ref idealRotation); else - { - projectile.direction = projectile.spriteDirection = (player.Center.X - projectile.Center.X > 0).ToDirectionInt(); - projectile.rotation = projectile.rotation.AngleTowards(0f, 0.05f); projectile.frame = 0; + + projectile.rotation = projectile.rotation.AngleLerp(idealRotation, 0.15f); + projectile.rotation = projectile.rotation.AngleTowards(idealRotation, 0.15f); + + projectile.Center = new Vector2(projectile.Center.X, MathHelper.Clamp(projectile.Center.Y, 1f, returnPosition.Y - 8f)); + MoveTowardsDestination(returnPosition); + AdjustOldVelocityArray(); + + Time++; + } + + public void PerformInitializationEffects() + { + int totalHeads = CalamityUtils.CountProjectiles(projectile.type); + CurrentPositionOffset = IdealPositionOffset = new Vector2(Main.rand.NextFloat(-72f - 8f * totalHeads, 72f + 8f * totalHeads), -Main.rand.NextFloat(8f, 84f + 4f * totalHeads)); + projectile.Calamity().spawnedPlayerMinionDamageValue = Owner.MinionDamage(); + projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage; + + projectile.netUpdate = true; + + if (Main.dedServ) + return; + + // Release a circle of sulphuric dust. + for (int i = 0; i < 18; i++) + { + Dust dust = Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.SulfurousSeaAcid); + dust.velocity = new Vector2(0f, -5f).RotatedBy(i / 18f * MathHelper.TwoPi); + dust.noGravity = true; + dust.scale = 1.35f; + } + } + + public void ApplyMinionBuffs() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + if (projectile.type == ModContent.ProjectileType()) + { + if (Owner.dead) + Owner.Calamity().gammaHead = false; + if (Owner.Calamity().gammaHead) + projectile.timeLeft = 2; + } + } + + public void NoticeTarget(NPC target, ref Vector2 returnPosition, ref float idealRotation) + { + // Reel back a bit if a valid target has been located. + returnPosition -= (target.Center - projectile.Center).SafeNormalize(Vector2.Zero) * 16f; + + // And release canisters from time to time. + int canisterShootRate = 100; + + // Open the mouth prior to firing. + if (Time % canisterShootRate > canisterShootRate - 20) + projectile.frame = (int)(Main.projFrames[projectile.type] * Utils.InverseLerp(canisterShootRate - 20, canisterShootRate - 4, Time % canisterShootRate, true)); + projectile.frame %= Main.projFrames[projectile.type]; + + Vector2 spawnPosition = projectile.Center; + float shootSpeed = MathHelper.Lerp(8f, 20f, Utils.InverseLerp(90f, 850f, target.Distance(spawnPosition), true)); + Vector2 shootVelocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(spawnPosition, target.Center, GammaCanister.Gravity, shootSpeed, projectile.DirectionTo(target.Center)); + float fireAngle = shootVelocity.ToRotation(); + + // Direction affecting. + if (target.Center.X - spawnPosition.X < 0) + fireAngle += MathHelper.Pi; + idealRotation = fireAngle; + + // Shoot the actual canister. + if (Main.myPlayer == projectile.owner && Time % canisterShootRate == canisterShootRate - 1) + Projectile.NewProjectile(spawnPosition, shootVelocity, ModContent.ProjectileType(), projectile.damage, projectile.knockBack, projectile.owner); + } + + public void MoveTowardsDestination(Vector2 returnPosition) + { + float distanceFromTarget = projectile.Distance(returnPosition); + if (distanceFromTarget > 7f) + { + float flySpeed = MathHelper.Lerp(2f, 17f, Utils.InverseLerp(10f, 70f, distanceFromTarget, true)); + projectile.velocity = (projectile.velocity * 9f + projectile.DirectionTo(returnPosition) * flySpeed) / 10f; } - if (projectile.Distance(returnPosition) > 28f) - { - projectile.velocity += new Vector2(Math.Sign(returnPosition.X - projectile.Center.X), Math.Sign(returnPosition.Y - projectile.Center.Y)) * new Vector2(0.015f, 0.025f) * Main.rand.NextFloat(0.98f, 1.02f); - if (Math.Abs(projectile.velocity.X) > 2.5f) - { - projectile.velocity.X = 2.1f * Math.Sign(projectile.velocity.X); - } - if (Math.Abs(projectile.velocity.Y) > 1.6f) - { - projectile.velocity.Y = 1.4f * Math.Sign(projectile.velocity.Y); - } - projectile.velocity += (returnPosition - projectile.Center) / 10f; - } - else projectile.velocity *= 0.98f; - projectile.Center = new Vector2(projectile.Center.X, MathHelper.Clamp(projectile.Center.Y, 1f, returnPosition.Y - 8f)); + int totalHeads = CalamityUtils.CountProjectiles(projectile.type); + int moveRate = 40 + totalHeads * 4; + + // Reset the ideal offset from time to time. + if (Time % moveRate == moveRate - 1f) + IdealPositionOffset = new Vector2(Main.rand.NextFloat(-72f - 8f * totalHeads, 72f + 8f * totalHeads), -Main.rand.NextFloat(8f, 84f + 4f * totalHeads)); + + if (Vector2.Distance(IdealPositionOffset, CurrentPositionOffset) > 0.2f) + CurrentPositionOffset = Vector2.Lerp(CurrentPositionOffset, IdealPositionOffset, 0.125f); + + // Clamp the Y position. + if (projectile.Center.Y > Owner.Top.Y - 46f) + projectile.Center = new Vector2(projectile.Center.X, Owner.Top.Y - 46f); + + // Clamp the center so that it does not go too far from the return position. + if (projectile.Distance(returnPosition) > 120f) + projectile.Center = returnPosition + projectile.DirectionFrom(returnPosition) * 120f; + + // Disallow heads from getting too close to each other. + projectile.MinionAntiClump(0.15f); } + + public void AdjustOldVelocityArray() + { + for (int i = OldVelocities.Length - 1; i > 0; i--) + OldVelocities[i] = OldVelocities[i - 1]; + + OldVelocities[0] = projectile.velocity; + } + public override void Kill(int timeLeft) { + if (Main.dedServ) + return; + for (int i = 0; i < 10; i++) - { - Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.SulfurousSeaAcid, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * 4f).noGravity = true; - } + Dust.NewDustPerfect(projectile.Center, (int)CalamityDusts.SulfurousSeaAcid, Main.rand.NextVector2CircularEdge(4f, 4f)).noGravity = true; } - public override void PostDraw(SpriteBatch spriteBatch, Color lightColor) + + public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { - Player player = Main.player[projectile.owner]; - Texture2D chain = ModContent.GetTexture("CalamityMod/Projectiles/Summon/GammaHeadChain"); - Vector2 start = projectile.Center + (projectile.spriteDirection == -1).ToInt() * 10f * Vector2.UnitX; - Vector2 end = DrawStartPosition - projectile.DirectionTo(DrawStartPosition) * 11f; - Vector2 bodyTop = DrawStartPosition + new Vector2(player.direction == 1 ? 6f : -6f, 0f); + Vector2 end = projectile.Center + (projectile.spriteDirection == 1).ToInt() * 10 * Vector2.UnitX; - for (int i = 0; i <= (int)projectile.Distance(end) / 10 + 1; i++) + List controlPoints = new List { - float ratio = i / (projectile.Distance(end) / 10 + 1); - Vector2 positionAtPoint = start + (bodyTop - start) * ratio; - if (projectile.Distance(positionAtPoint) > 9) - { - float angleAtPoint = (start - positionAtPoint).ToRotation(); - if (i < (int)projectile.Distance(end) / 10 + 1) - { - float nextRatio = (i + 1f) / (projectile.Distance(end) / 10 + 1); - Vector2 nextPositionAtPoint = start + (bodyTop - start) * nextRatio; - - angleAtPoint = (nextPositionAtPoint - positionAtPoint).ToRotation(); - } - angleAtPoint += MathHelper.PiOver2; - spriteBatch.Draw(chain, - positionAtPoint - Main.screenPosition, - null, - Color.Lerp(Color.White, Color.Transparent, 0.5f), - angleAtPoint, - chain.Size() / 2f, - 1f, - SpriteEffects.None, - 0f); - } + DrawStartPosition + }; + for (int i = 0; i < OldVelocities.Length; i++) + { + // Incorporate the past movement into neck turns, giving it rubber band-like movment. + // Become less responsive at the neck ends. Having the ends have typical movement can look strange sometimes. + float swayResponsiveness = Utils.InverseLerp(0f, 6f, i, true) * Utils.InverseLerp(OldVelocities.Length, OldVelocities.Length - 6f, i, true); + Vector2 swayTotalOffset = OldVelocities[i] * swayResponsiveness; + controlPoints.Add(Vector2.Lerp(DrawStartPosition, end, i / (float)OldVelocities.Length) + swayTotalOffset); } + controlPoints.Add(end); + + int chainPointCount = (int)(Vector2.Distance(controlPoints.First(), controlPoints.Last()) / 5f); + if (chainPointCount < 12) + chainPointCount = 12; + BezierCurve bezierCurve = new BezierCurve(controlPoints.ToArray()); + List chainPoints = bezierCurve.GetPoints(chainPointCount); + + for (int i = 0; i < chainPoints.Count; i++) + { + Vector2 positionAtPoint = chainPoints[i]; + if (Vector2.Distance(positionAtPoint, projectile.Center) < 10f) + continue; + float angleAtPoint = i == chainPoints.Count - 1 ? (end - chainPoints[i]).ToRotation() : (chainPoints[i + 1] - chainPoints[i]).ToRotation(); + angleAtPoint += MathHelper.PiOver2; + spriteBatch.Draw(chain, + positionAtPoint - Main.screenPosition, + null, + Color.Lerp(Color.White, Color.Transparent, 0.6f), + angleAtPoint, + chain.Size() / 2f, + 1f, + SpriteEffects.None, + 0f); + } + + Texture2D headTexture = ModContent.GetTexture(Texture); + spriteBatch.Draw(headTexture, + projectile.Center - Main.screenPosition + Vector2.UnitY * projectile.gfxOffY, + headTexture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame), + lightColor, + projectile.rotation, + projectile.Size * 0.5f, + projectile.scale, + projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None, + 0f); + + return false; } public override bool CanDamage() => false; } diff --git a/Projectiles/Summon/HomingGammaBullet.cs b/Projectiles/Summon/HomingGammaBullet.cs new file mode 100644 index 0000000000..61e6d97f7b --- /dev/null +++ b/Projectiles/Summon/HomingGammaBullet.cs @@ -0,0 +1,60 @@ +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Dusts; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class HomingGammaBullet : ModProjectile + { + public override string Texture => "CalamityMod/Projectiles/Enemy/NuclearBulletMedium"; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Gamma Bullet"); + ProjectileID.Sets.MinionShot[projectile.type] = true; + } + + public override void SetDefaults() + { + projectile.width = 24; + projectile.height = 12; + projectile.friendly = true; + projectile.minion = true; + projectile.minionSlots = 0f; + projectile.alpha = 255; + projectile.timeLeft = 360; + projectile.tileCollide = true; + projectile.ignoreWater = true; + } + + public override void AI() + { + projectile.alpha = Utils.Clamp(projectile.alpha - 35, 0, 255); + projectile.rotation = projectile.velocity.ToRotation(); + + NPC potentialTarget = projectile.Center.MinionHoming(1000f, Main.player[projectile.owner]); + if (potentialTarget != null && !projectile.WithinRange(potentialTarget.Center, 100f) && projectile.timeLeft < 290) + projectile.velocity = (projectile.velocity * 6f + projectile.DirectionTo(potentialTarget.Center) * 15f) / 7f; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) => target.AddBuff(ModContent.BuffType(), 240); + + public override void Kill(int timeLeft) + { + if (Main.dedServ) + return; + + for (int i = 0; i < 3; i++) + { + Dust sulphuricAcid = Dust.NewDustDirect(projectile.position, 8, 8, (int)CalamityDusts.SulfurousSeaAcid, 0, 0, 0, default, 0.75f); + sulphuricAcid.noGravity = true; + sulphuricAcid.velocity *= 1.8f; + + sulphuricAcid = Dust.CloneDust(sulphuricAcid); + sulphuricAcid.velocity *= -1f; + } + } + } +} diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 2689422ef0..f7a0466c2e 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -573,9 +573,6 @@ namespace CalamityMod.Tiles public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged) { - if (type == TileID.DemonAltar) - return false; - int[] invincibleTiles = new int[] { ModContent.TileType(), diff --git a/Tiles/FrigidBar.cs b/Tiles/FrigidBar.cs deleted file mode 100644 index 58ae26f2d5..0000000000 --- a/Tiles/FrigidBar.cs +++ /dev/null @@ -1,54 +0,0 @@ -using CalamityMod.Items.Materials; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ModLoader; -using Terraria.ObjectData; - -namespace CalamityMod.Tiles -{ - public class FrigidBar : ModTile - { - public override void SetDefaults() - { - Main.tileShine[Type] = 1000; - Main.tileSolid[Type] = true; - Main.tileSolidTop[Type] = true; - Main.tileFrameImportant[Type] = true; - - TileObjectData.newTile.CopyFrom(TileObjectData.Style1x1); - TileObjectData.newTile.StyleHorizontal = true; - TileObjectData.newTile.LavaDeath = false; - TileObjectData.addTile(Type); - - dustType = 67; - drop = ModContent.ItemType(); - - AddMapEntry(new Color(229, 141, 246)); - } - - public override bool CreateDust(int i, int j, ref int type) - { - if (Main.rand.NextBool(2)) - { - type = 67; - } - else - { - type = 68; - } - return true; - } - - public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) - { - WorldGen.Check1x1(i, j, Type); - return true; - } - - public override void PlaceInWorld(int i, int j, Item item) - { - Main.tile[i, j].frameX = 0; - Main.tile[i, j].frameY = 0; - } - } -} diff --git a/Tiles/FrigidBar.png b/Tiles/FrigidBar.png deleted file mode 100644 index 26c6de9bae..0000000000 Binary files a/Tiles/FrigidBar.png and /dev/null differ diff --git a/Utilities/CalamityRecipes.cs b/Utilities/CalamityRecipes.cs index 81b158ddb3..c6df7ba8a8 100644 --- a/Utilities/CalamityRecipes.cs +++ b/Utilities/CalamityRecipes.cs @@ -30,6 +30,8 @@ namespace CalamityMod EditLeatherRecipe(); EditTerraBladeRecipe(); EditFireGauntletRecipe(); + EditMechBossSummonRecipes(); + EditWingRecipes(); AstralAlternatives(); AddPotionRecipes(); @@ -165,8 +167,26 @@ namespace CalamityMod }); } - #region Astral Alternatives - private static void AstralAlternatives() + private static void EditMechBossSummonRecipes() + { + List rec = Main.recipe.ToList(); + rec.Where(x => x.createItem.type == ItemID.MechanicalWorm || x.createItem.type == ItemID.MechanicalEye || x.createItem.type == ItemID.MechanicalSkull).ToList().ForEach(s => + { + s.requiredTile[0] = TileID.Anvils; + }); + } + + private static void EditWingRecipes() + { + List rec = Main.recipe.ToList(); + rec.Where(x => x.createItem.type == ItemID.AngelWings || x.createItem.type == ItemID.DemonWings).ToList().ForEach(s => + { + s.requiredTile[0] = TileID.Anvils; + }); + } + + #region Astral Alternatives + private static void AstralAlternatives() { //Bowl ModRecipe r = GetNewRecipe(); @@ -866,7 +886,7 @@ namespace CalamityMod r.AddIngredient(ItemID.SoulofMight, 10); r.AddIngredient(ItemID.SoulofLight, 5); r.AddIngredient(ItemID.SoulofNight, 5); - r.AddIngredient(ModContent.ItemType(), 3); + r.AddIngredient(ModContent.ItemType(), 3); r.AddTile(TileID.MythrilAnvil); r.SetResult(ItemID.CelestialMagnet); r.AddRecipe(); @@ -889,30 +909,6 @@ namespace CalamityMod r.SetResult(ItemID.MagicQuiver); r.AddRecipe(); - // Frost Helmet w/ Frigid Bars - r = GetNewRecipe(); - r.AddIngredient(ModContent.ItemType(), 6); - r.AddIngredient(ItemID.FrostCore); - r.AddTile(TileID.IceMachine); - r.SetResult(ItemID.FrostHelmet); - r.AddRecipe(); - - // Frost Breastplate w/ Frigid Bars - r = GetNewRecipe(); - r.AddIngredient(ModContent.ItemType(), 10); - r.AddIngredient(ItemID.FrostCore); - r.AddTile(TileID.IceMachine); - r.SetResult(ItemID.FrostBreastplate); - r.AddRecipe(); - - // Frost Leggings w/ Frigid Bars - r = GetNewRecipe(); - r.AddIngredient(ModContent.ItemType(), 8); - r.AddIngredient(ItemID.FrostCore); - r.AddTile(TileID.IceMachine); - r.SetResult(ItemID.FrostLeggings); - r.AddRecipe(); - // Terra Blade w/ True Bloody Edge r = GetNewRecipe(); r.AddIngredient(ModContent.ItemType()); diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index 2653142ec5..b1c56729ec 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -269,10 +269,7 @@ namespace CalamityMod /// /// The shader to bind the texture to. /// The texture to bind. - public static void SetShaderTexture(this MiscShaderData shader, Texture2D texture) - { - UImageField.SetValue(shader, new Ref(texture)); - } + public static void SetShaderTexture(this MiscShaderData shader, Texture2D texture) => UImageField.SetValue(shader, new Ref(texture)); public static void EnterShaderRegion(this SpriteBatch spriteBatch) { diff --git a/Utilities/MathematicalUtils.cs b/Utilities/MathematicalUtils.cs index f2d0727683..cb8c3e5a02 100644 --- a/Utilities/MathematicalUtils.cs +++ b/Utilities/MathematicalUtils.cs @@ -28,6 +28,37 @@ namespace CalamityMod /// The value to convert. public static float Convert01To010(float value) => (float)Math.Sin(MathHelper.Pi * MathHelper.Clamp(value, 0f, 1f)); + /// + /// Uses a rewritten horizontal range formula to determine the direction to fire a projectile in order for it to hit a destination. Falls back on a certain value if no such direction can exist. If no fallback is provided, a clamp is used. + /// + /// The starting position of the projectile. + /// The destination for the projectile to land at. + /// The gravity of the projectile. + /// The magnitude + /// The direction to fall back to if the calculations result in any NaNs. If nothing is specified, a clamp is performed to prevent any chance of NaNs at all. + public static Vector2 GetProjectilePhysicsFiringVelocity(Vector2 shootingPosition, Vector2 destination, float gravity, float shootSpeed, Vector2? nanFallback = null) + { + // Ensure that the gravity has the right sign for Terraria's coordinate system. + gravity = -Math.Abs(gravity); + + float horizontalRange = MathHelper.Distance(shootingPosition.X, destination.X); + float fireAngleSine = gravity * horizontalRange / (float)Math.Pow(shootSpeed, 2); + + // Clamp the sine if no fallback is provided. + if (nanFallback is null) + fireAngleSine = MathHelper.Clamp(fireAngleSine, -1f, 1f); + + float fireAngle = (float)Math.Asin(fireAngleSine) * 0.5f; + + // Get out of here if no valid firing angle exists. This can only happen if a fallback does indeed exist. + if (float.IsNaN(fireAngle)) + return nanFallback.Value * shootSpeed; + + Vector2 fireVelocity = new Vector2(0f, -shootSpeed).RotatedBy(fireAngle); + fireVelocity.X *= (destination.X - shootingPosition.X < 0).ToDirectionInt(); + return fireVelocity; + } + // REMOVE THIS IN CALAMITY 1.4, it's a 1.4 World.cs function. // Due to its temporary state, this method will not receive an XML documentation comment. public static Rectangle ClampToWorld(Rectangle tileRectangle) diff --git a/World/CalamityWorld.cs b/World/CalamityWorld.cs index ab4381055c..7310eb4aa2 100644 --- a/World/CalamityWorld.cs +++ b/World/CalamityWorld.cs @@ -1606,19 +1606,6 @@ namespace CalamityMod.World } } - if (Main.dayTime && Main.hardMode) - { - if (player.townNPCs >= 2f) - { - if (Main.rand.NextBool(2000)) - { - int steamGril = NPC.FindFirstNPC(NPCID.Steampunker); - if (steamGril == -1 && Main.netMode != NetmodeID.MultiplayerClient) - NPC.SpawnOnPlayer(closestPlayer, NPCID.Steampunker); //Steampunker has awoken! - } - } - } - if (modPlayer.ZoneAbyss) { if (player.chaosState)