diff --git a/Backgrounds/SunkenSeaBurrowsBG.cs b/Backgrounds/SunkenSeaBurrowsBG.cs index 3763a35b6a..986d2134c2 100644 --- a/Backgrounds/SunkenSeaBurrowsBG.cs +++ b/Backgrounds/SunkenSeaBurrowsBG.cs @@ -5,11 +5,18 @@ using Microsoft.Xna.Framework.Graphics; using System; using ReLogic.Content; using Terraria.ID; +using CalamityMod.Graphics; +using System.Reflection; +using Terraria.Graphics.Shaders; namespace CalamityMod.Backgrounds { public class SunkenSeaBurrowsBG : ModSystem { + private static ManagedRenderTarget WaterDistortionTarget; + + private static bool CurrentlyRendering { get; set; } + public override void Load() { if (Main.dedServ) @@ -17,7 +24,10 @@ namespace CalamityMod.Backgrounds return; } + On_Main.CheckMonoliths += DrawToTarget; On_Main.DrawBackgroundBlackFill += On_Main_DrawBackgroundBlackFill; + + Main.QueueMainThreadAction(() => WaterDistortionTarget = new(true, ManagedRenderTarget.CreateScreenSizedTarget)); } /// @@ -48,6 +58,31 @@ namespace CalamityMod.Backgrounds } } + private void DrawToTarget(On_Main.orig_CheckMonoliths orig) + { + if (Main.gameMenu) + { + orig(); + return; + } + + CurrentlyRendering = true; + WaterDistortionTarget.SwapTo(); + + // 13MAY2025: fryzahh: Note that when other Sunken Sea backgrounds are implemented they should use this same system. + // Leaving this here for other programmers, in case I don't get to doing this myself. + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + + DrawBurrowsBG(); + + Main.spriteBatch.End(); + + Main.graphics.GraphicsDevice.SetRenderTarget(null); + CurrentlyRendering = false; + + orig(); + } + private void On_Main_DrawBackgroundBlackFill(On_Main.orig_DrawBackgroundBlackFill orig, Main self) { if (Main.gameMenu || Main.screenPosition.Y + Main.screenHeight < ((int)Main.worldSurface) * 16f) @@ -58,7 +93,30 @@ namespace CalamityMod.Backgrounds orig(self); - DrawBurrowsBG(); + // This won't render if the Wave Quality setting isn't turned off unfortunately, so don't bother running any of the shader + // rendering code if that setting is on. + if (Main.WaveQuality > 0 || !CalamityClientConfig.Instance.SunkenSeaBackgroundDistortion) + { + DrawBurrowsBG(); + } + else + { + MiscShaderData distortionShader = GameShaders.Misc["CalamityMod:BasicTextureDistortion"]; + Asset distortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Swirls"); + + // Apply a distortion shader to the Sunken Sea backgrounds to give them an underwater ripple-like effect. + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, distortionShader.Shader, CalamityUtils.BackgroundMatrix); + + distortionShader.Shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + distortionShader.Shader.Parameters["distortionXSpeed"].SetValue(-0.012f); + distortionShader.Shader.Parameters["distortionYSpeed"].SetValue(0.02f); + distortionShader.Shader.Parameters["distortionStrength"].SetValue(0.035f); + distortionShader.Shader.Parameters["noiseScale"].SetValue(0.075f); + distortionShader.SetShaderTexture(distortionTexture); + + Main.spriteBatch.Draw(WaterDistortionTarget.Target, new Rectangle(16, 16, Main.screenWidth, Main.screenHeight), Color.White); + } } public static float Transparency; diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 561290d4d8..031f4c3272 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -125,7 +125,7 @@ namespace CalamityMod.CalPlayer public bool noLifeRegen = false; public bool reducedDaybrokenDamage = false; public bool reducedNightwitherDamage = false; - public float rangedAmmoCost = 1f; + public float ammoCost = 1f; public float healingPotionMultiplier = 1f; /// /// Tracks whether or not the player is currently holding Gael's Greatsword.
@@ -727,15 +727,13 @@ namespace CalamityMod.CalPlayer public bool theBee = false; public bool arcFlashRing = false; public bool arcFlashRingVisual = false; + public int generalBandCooldown = 0; public bool bGlassBand = false; // Obsidian band public bool bGlassBandVisual = false; - public int bGlassbandCooldown = 0; public bool batholithBangle = false; // Granite band public bool batholithBangleVisual = false; - public int batholithBangleCooldown = 0; public bool protolithBangle = false; // Marble band public bool protolithBangleVisual = false; - public int protolithBangleCooldown = 0; /// Used to prevent dodges from triggering The Bee's full health damage reduction cooldown. public bool shouldTriggerBeeCooldown = false; public int theBeeCooldown = 0; @@ -807,6 +805,12 @@ namespace CalamityMod.CalPlayer public int transformerCooldown = 0; public int transformerDelay = 0; public int transformerStoredKills = 0; + public bool bloomStone = false; + public bool bloomStoneHookVisuals = false; + public int bloomStoneHealInc = 0; + public int bloomStoneTotalHeal = 0; + public int bloomStoneHealTimer = 0; + public int bloomStoneDR = 0; public bool hideOfDeus = false; public bool dAmulet = false; public bool rampartOfDeities = false; @@ -2177,6 +2181,10 @@ namespace CalamityMod.CalPlayer arcFlashRingVisual = false; bGlassBand = false; bGlassBandVisual = false; + batholithBangle = false; // Granite band + batholithBangleVisual = false; + protolithBangle = false; // Marble band + protolithBangleVisual = false; aFossil = false; aPowder = false; fallingBlockProtection = false; @@ -2196,6 +2204,8 @@ namespace CalamityMod.CalPlayer ilSpark = false; transformer = false; transformerVisual = false; + bloomStone = false; + bloomStoneHookVisuals = false; hideOfDeus = false; dAmulet = false; rampartOfDeities = false; @@ -2335,7 +2345,7 @@ namespace CalamityMod.CalPlayer lunicCorpsSet = false; lunicCorpsLegs = false; - rangedAmmoCost = 1f; + ammoCost = 1f; healingPotionMultiplier = 1f; avertorBonus = false; @@ -2857,6 +2867,10 @@ namespace CalamityMod.CalPlayer auralisAurora = 0; necroReviveCounter = -1; hideOfDeusTimer = 0; + bloomStoneHealInc = 0; + bloomStoneTotalHeal = 0; + bloomStoneHealTimer = 0; + bloomStoneDR = 0; murasamaHitCooldown = 0; RustyMedallionCooldown = 0; SulphWaterPoisoningLevel = 0f; @@ -3078,7 +3092,7 @@ namespace CalamityMod.CalPlayer bloodfinTimer = 0; healCounter = 300; danceOfLightCharge = 0; - rangedAmmoCost = 1f; + ammoCost = 1f; healingPotionMultiplier = 1f; avertorBonus = false; divineBless = false; @@ -4368,6 +4382,17 @@ namespace CalamityMod.CalPlayer } } + //Star in a Bottle gives Mana Regeneration instead of it's usual effect when you don't already have Mana Regeneration + if (!Player.manaRegenBuff && Player.HasBuff(BuffID.StarInBottle)) + { + //Cancel out Star In A Bottle's normal effect + Player.manaRegenDelayBonus -= 0.5f; + Player.manaRegenBonus -= 10; + //Apply Mana Regen Potion effect + Player.manaRegenBuff = true; + + } + ForceVariousEffects(); } #endregion @@ -4542,6 +4567,8 @@ namespace CalamityMod.CalPlayer public override void GetHealLife(Item item, bool quickHeal, ref int healValue) { healValue = (int)(healValue * healingPotionMultiplier); + if (bloomStone) + healValue = 0; } #endregion diff --git a/CalPlayer/CalamityPlayerDrawEffects.cs b/CalPlayer/CalamityPlayerDrawEffects.cs index 5bc10fb6f8..b5470a17e4 100644 --- a/CalPlayer/CalamityPlayerDrawEffects.cs +++ b/CalPlayer/CalamityPlayerDrawEffects.cs @@ -4,6 +4,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer.DrawLayers; +using CalamityMod.Dusts; using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Ranged; using CalamityMod.Particles; @@ -327,6 +328,20 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(Plus); } } + if (calamityPlayer.bloomStoneDR > 0 && drawInfo.shadow == 0f) + { + if (Main.rand.NextBool(10)) + { + MediumMistParticle pollenCloud = new(Player.Center, Main.rand.NextVector2Circular(1f, 1f), Color.Yellow, Color.Gold, 0.85f, 100f); + GeneralParticleHandler.SpawnParticle(pollenCloud); + } + if (Main.rand.NextBool(4)) + { + Dust pollenDust = Dust.NewDustDirect(Player.position, Player.width, Player.height, ModContent.DustType(), newColor: Color.Gold, Scale: 0.4f); + pollenDust.noLightEmittence = true; + pollenDust.noGravity = true; + } + } if (calamityPlayer.bloodfinBoost && drawInfo.shadow == 0f) { if (Main.rand.NextBool(3)) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e30f935372..b7f7da69a7 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -78,6 +78,7 @@ using Terraria.GameContent.Events; using Terraria.GameInput; using Terraria.Graphics.Shaders; using Terraria.ID; +using Terraria.Localization; using Terraria.ModLoader; using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; @@ -392,7 +393,10 @@ namespace CalamityMod.CalPlayer Projectile.NewProjectile(Player.GetSource_FromThis(), Player.Center + Player.velocity * 1.5f, Vector2.Zero, ModContent.ProjectileType(), damage, 0, Player.whoAmI); } if (Player.dashDelay == -1) + { Player.endurance += 0.1f; + Player.noKnockback = true; + } } @@ -917,7 +921,7 @@ namespace CalamityMod.CalPlayer // Create a direct strike to hit this specific NPC. var source = Player.GetSource_Accessory(FindAccessory(ModContent.ItemType())); - Projectile sigilStrike = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sigilDamage, 0f, Player.whoAmI, target.whoAmI); + Projectile sigilStrike = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ModContent.ProjectileType(), sigilDamage, 0f, Player.whoAmI, target.whoAmI, 255f); // Enable crits by setting the sigil's damage class to be whatever the player's strongest damage class is. sigilStrike.DamageType = Player.GetBestClass(); @@ -1338,10 +1342,16 @@ namespace CalamityMod.CalPlayer } else { - if (Player.mount.Type == MountID.Slime || Player.mount.Type == MountID.PogoStick) + if (Player.mount.Type == MountID.Slime) Player.velocity.X *= 0.91f; else if (Player.mount.Type == MountID.QueenSlime) Player.velocity.X *= 0.95f; + else if (Player.mount.Type == MountID.PogoStick) + { + if (Player.velocity.X > 10 || Player.velocity.X < -10) + Player.velocity.X *= 0.99f; //Stops infinite high-speed movement, but allows fun pogo movement tech still + Player.maxFallSpeed *= 0.75f; // 1.5x fall speed instead of 2x to counterbalance + } } // Increase Rope climb velocities, if enabled @@ -2052,12 +2062,8 @@ namespace CalamityMod.CalPlayer VoidCooldown--; if (ursaSergeantCooldown > 0) ursaSergeantCooldown--; - if (bGlassbandCooldown > 0) - bGlassbandCooldown--; - if (batholithBangleCooldown > 0) - batholithBangleCooldown--; - if (protolithBangleCooldown > 0) - protolithBangleCooldown--; + if (generalBandCooldown > 0) + generalBandCooldown--; if (AlchFlaskCooldown > 0) AlchFlaskCooldown--; if (tarraRangedCooldown > 0) @@ -2076,6 +2082,43 @@ namespace CalamityMod.CalPlayer jetPackDash--; if (theBeeCooldown > 0) theBeeCooldown--; + + if (bloomStoneHealTimer > 0) + { + if (bloomStone && bloomStoneHealTimer % 40 == 0) + { + Player.HealPlayer(Math.Min(bloomStoneHealInc, bloomStoneTotalHeal)); + // Special specifically programmed interaction with Chalice of the Blood God: Healing over time clears bits of the bleedout buffer. + if (chaliceOfTheBloodGod && chaliceBleedoutBuffer > 0D) + { + float amountOfBleedToClear = ChaliceOfTheBloodGod.HealingPotionRatioForBufferClear * bloomStoneHealInc; + chaliceBleedoutBuffer -= amountOfBleedToClear; + // Display text indicating that healing was applied to the bleedout buffer. + if (!Main.dedServ) + { + string text = $"(+{amountOfBleedToClear})"; + Rectangle location = new Rectangle((int)Player.position.X + 4, (int)Player.position.Y - 3, Player.width - 4, Player.height - 4); + CombatText.NewText(location, ChaliceOfTheBloodGod.BleedoutBufferDamageTextColor, Language.GetTextValue(text), dot: true); + } + } + + bloomStoneTotalHeal -= bloomStoneHealInc; + if (bloomStoneTotalHeal < 0) + bloomStoneTotalHeal = 0; + } + bloomStoneHealTimer--; + } + else + { + bloomStoneTotalHeal = 0; + bloomStoneHealInc = 0; + } + if (bloomStoneDR > 0) + { + Player.endurance += bloomStoneHealTimer > 0 ? 0.12f : 0.06f; + bloomStoneDR--; + } + if (summonProjCooldown > 0f) summonProjCooldown -= 1f; if (ataxiaDmg > 0f) diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 2be664548c..f91dcf823d 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -10,7 +10,6 @@ using CalamityMod.Dusts; using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.Reaver; using CalamityMod.Items.Fishing.AstralCatches; -using CalamityMod.Items.Potions.Alcohol; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; @@ -26,12 +25,10 @@ using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; -using Mono.Cecil; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; -using static System.Net.Mime.MediaTypeNames; using static Terraria.ModLoader.ModContent; namespace CalamityMod.CalPlayer @@ -146,14 +143,46 @@ namespace CalamityMod.CalPlayer // Ursa Sergeant slash cooldown is reset on kill if (ursaSergeant && target.life <= 0 && target.realLife == -1) ursaSergeantCooldown = (int)MathHelper.Clamp(ursaSergeantCooldown - 180, 0, 300); - if (bGlassBand && bGlassbandCooldown == 0) + + + if (generalBandCooldown == 0) { - var source = item.GetSource_FromThis(); - int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); - Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; - Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); - bGlassbandCooldown = BlackGlassBand.cooldown; + int cooldown = 0; + if (bGlassBand) + { + var source = item.GetSource_FromThis(); + int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); + Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; + Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); + if (cooldown < BlackGlassBand.cooldown) + cooldown = BlackGlassBand.cooldown; + } + if (protolithBangle && item.DamageType == DamageClass.Ranged) + { + var source = item.GetSource_FromThis(); + int damage = (int)Player.GetBestClassDamage().ApplyTo(ProtolithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Ranged; + if (cooldown < ProtolithBangle.cooldown) + cooldown = ProtolithBangle.cooldown; + } + if (batholithBangle && item.DamageType == DamageClass.Magic) + { + var source = item.GetSource_FromThis(); + int damage = (int)Player.GetBestClassDamage().ApplyTo(BatholithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Magic; + if (cooldown < BatholithBangle.cooldown) + cooldown = BatholithBangle.cooldown; + } + + if (cooldown > 0) // Check if a band effect went off, and apply the highest cooldown + { + generalBandCooldown = cooldown; + Player.AddCooldown(Cooldowns.GenericBandCooldown.ID, cooldown); + } } + if (luxorsGift) luxorHit = true; @@ -316,14 +345,47 @@ namespace CalamityMod.CalPlayer // Ursa Sergeant slash cooldown is reset on kill if (ursaSergeant && target.life <= 0 && target.realLife == -1) ursaSergeantCooldown = (int)MathHelper.Clamp(ursaSergeantCooldown - UrsaSergeant.CooldownReducedPerKill, 0, UrsaSergeant.MaxCooldown); - if (bGlassBand && bGlassbandCooldown == 0) + + if (generalBandCooldown == 0) { - var source = proj.GetSource_FromThis(); - int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); - Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; - Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); - bGlassbandCooldown = BlackGlassBand.cooldown; + int cooldown = 0; + // NOTE: Apparently Pulse Pistol/Pulse Rifle projectiles will set spawned projectiles here to inherit the proj ID??? + // No clue why this happens or how to fix it, but it just breaks using multiple band types together on these two weapons + if (bGlassBand) + { + var source = proj.GetSource_FromThis(); + int damage = (int)Player.GetBestClassDamage().ApplyTo(BlackGlassBand.damage); + Vector2 launchVel = Utils.DirectionTo(Player.Center, target.Center) * 6; + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI, launchVel.X, launchVel.Y); + if (cooldown < BlackGlassBand.cooldown) + cooldown = BlackGlassBand.cooldown; + } + if (protolithBangle && proj.DamageType == DamageClass.Ranged) + { + var source = proj.GetSource_FromThis(); + int damage = (int)Player.GetBestClassDamage().ApplyTo(ProtolithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Ranged; + if (cooldown < ProtolithBangle.cooldown) + cooldown = ProtolithBangle.cooldown; + } + if (batholithBangle && proj.DamageType == DamageClass.Magic) + { + var source = proj.GetSource_FromThis(); + int damage = (int)Player.GetBestClassDamage().ApplyTo(BatholithBangle.damage); + Projectile band = Projectile.NewProjectileDirect(source, target.Center, Vector2.Zero, ProjectileType(), damage, -1, Player.whoAmI, target.whoAmI); + band.DamageType = DamageClass.Magic; + if (cooldown < BatholithBangle.cooldown) + cooldown = BatholithBangle.cooldown; + } + + if (cooldown > 0) // Check if a band effect went off, and apply the highest cooldown + { + generalBandCooldown = cooldown; + Player.AddCooldown(Cooldowns.GenericBandCooldown.ID, cooldown); + } } + if (luxorsGift && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType() && proj.type != ModContent.ProjectileType()) luxorHit = true; diff --git a/CalPlayer/DrawLayers/HatExtensionLayer.cs b/CalPlayer/DrawLayers/HatExtensionLayer.cs index 7b512ea262..2a194db088 100644 --- a/CalPlayer/DrawLayers/HatExtensionLayer.cs +++ b/CalPlayer/DrawLayers/HatExtensionLayer.cs @@ -16,16 +16,19 @@ namespace CalamityMod.CalPlayer.DrawLayers protected override void Draw(ref PlayerDrawSet drawInfo) { - //Todo : Make this work even for accessories by somehow checking for the players.head equipslot's item instead of the head item. Player drawPlayer = drawInfo.drawPlayer; - Item headItem = drawPlayer.armor[0]; - if (drawPlayer.armor[10].type > ItemID.None) - headItem = drawPlayer.armor[10]; + if (drawPlayer.head == -1) + return; - if (ModContent.GetModItem(headItem.type) is IExtendedHat extendedHatDrawer) + if (EquipLoader.GetEquipTexture(EquipType.Head, drawPlayer.head) == null) + return; + + ModItem headItem = EquipLoader.GetEquipTexture(EquipType.Head, drawPlayer.head).Item; + + if (headItem is IExtendedHat extendedHatDrawer) { - string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.ModItem.Name; + string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.Name; int equipSlot = EquipLoader.GetEquipSlot(Mod, equipSlotName, EquipType.Head); if (extendedHatDrawer.PreDrawExtension(drawInfo) && !drawInfo.drawPlayer.dead && equipSlot == drawPlayer.head) diff --git a/CalamityConditions.cs b/CalamityConditions.cs index 7d7f2705c8..13b295e844 100644 --- a/CalamityConditions.cs +++ b/CalamityConditions.cs @@ -42,7 +42,7 @@ namespace CalamityMod // public static readonly Condition DownedDesertScourge = Create("Drops.DownedDS", () => DownedBossSystem.downedDesertScourge); - public static readonly Condition DownedCrabulon = Create("Drops.DownedCrabulon", () => DownedBossSystem.downedDesertScourge); + public static readonly Condition DownedCrabulon = Create("Drops.DownedCrabulon", () => DownedBossSystem.downedCrabulon); public static readonly Condition DownedHiveMind = Create("Drops.DownedHM", () => DownedBossSystem.downedHiveMind); public static readonly Condition DownedPerforator = Create("Drops.DownedPerfs", () => DownedBossSystem.downedPerforator); public static readonly Condition DownedSlimeGod = Create("Drops.DownedSG", () => DownedBossSystem.downedSlimeGod); diff --git a/CalamityConfig.cs b/CalamityConfig.cs index 7db9709350..82b26299a2 100644 --- a/CalamityConfig.cs +++ b/CalamityConfig.cs @@ -76,6 +76,10 @@ namespace CalamityMod [DefaultValue(true)] public bool EnableVanillaTextureEdits { get; set; } + [BackgroundColor(192, 54, 64, 192)] + [DefaultValue(true)] + public bool SunkenSeaBackgroundDistortion { get; set; } + private const int MinParticleLimit = 500; private const int MaxParticleLimit = 10000; diff --git a/Cooldowns/GenericBandCooldown.cs b/Cooldowns/GenericBandCooldown.cs new file mode 100644 index 0000000000..eccf24955e --- /dev/null +++ b/Cooldowns/GenericBandCooldown.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.Localization; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Cooldowns +{ + public class GenericBandCooldown : CooldownHandler + { + public static new string ID => "BandCooldown"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/GenericBandCooldown"; + public override Color OutlineColor => Color.White; + public override Color CooldownStartColor => Color.SlateGray; + public override Color CooldownEndColor => Color.Gray; + } +} diff --git a/Cooldowns/GenericBandCooldown.png b/Cooldowns/GenericBandCooldown.png new file mode 100644 index 0000000000..afdfd5d97a Binary files /dev/null and b/Cooldowns/GenericBandCooldown.png differ diff --git a/Cooldowns/GenericBandCooldownOutline.png b/Cooldowns/GenericBandCooldownOutline.png new file mode 100644 index 0000000000..ece251f504 Binary files /dev/null and b/Cooldowns/GenericBandCooldownOutline.png differ diff --git a/Cooldowns/GenericBandCooldownOverlay.png b/Cooldowns/GenericBandCooldownOverlay.png new file mode 100644 index 0000000000..f89301304d Binary files /dev/null and b/Cooldowns/GenericBandCooldownOverlay.png differ diff --git a/Effects/BasicTextureDistortionShader.fx b/Effects/BasicTextureDistortionShader.fx new file mode 100644 index 0000000000..084d452391 --- /dev/null +++ b/Effects/BasicTextureDistortionShader.fx @@ -0,0 +1,26 @@ +sampler baseTexture : register(s0); +sampler distortionTexture : register(s1); + +float time; +float distortionXSpeed; +float distortionYSpeed; +float distortionStrength; +float noiseScale; + +float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0 +{ + float2 distortedCoords = coords + float2(time * distortionXSpeed, time * distortionYSpeed); + distortedCoords *= noiseScale; + float distortion = tex2D(distortionTexture, distortedCoords).r; + + float4 returnColor = tex2D(baseTexture, coords + distortion * distortionStrength); + return returnColor * sampleColor.a; +} + +technique Technique1 +{ + pass DistortionPass + { + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} diff --git a/Effects/BasicTextureDistortionShader.xnb b/Effects/BasicTextureDistortionShader.xnb new file mode 100644 index 0000000000..7d0177e650 Binary files /dev/null and b/Effects/BasicTextureDistortionShader.xnb differ diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index 5d9a73271a..1b283d531c 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -210,6 +210,14 @@ namespace CalamityMod.Effects internal static Effect FlipScreenShader; #endregion + // + // All below shaders were created by fryzahh + // + #region fryzahh's Shaders + // A simple shader which distorts an image using a provided texture of choice. + internal static Effect BasicTextureDistortionShader; + #endregion + public override void PostSetupContent() { AssetRepository calAss = CalamityMod.Instance.Assets; @@ -417,6 +425,11 @@ namespace CalamityMod.Effects FlipScreenShader = LoadShader("ScreenShaders/FlipScreen"); RegisterScreenShader(FlipScreenShader, "FlipTheScreen", "FlipScreen",EffectPriority.VeryHigh); #endregion + + #region Loading fryzahh's Shaders + BasicTextureDistortionShader = LoadShader("BasicTextureDistortionShader"); + RegisterMiscShader(BasicTextureDistortionShader, "DistortionPass", "BasicTextureDistortion"); + #endregion } // Shorthand to register a loaded shader in Terraria's graphics engine diff --git a/Events/AcidRainEvent.cs b/Events/AcidRainEvent.cs index d408942aa2..5963ba605b 100644 --- a/Events/AcidRainEvent.cs +++ b/Events/AcidRainEvent.cs @@ -181,7 +181,7 @@ namespace CalamityMod.Events ///
public static void TryStartEvent(bool forceRain = false) { - if (AcidRainEventIsOngoing || (!NPC.downedBoss1 && !Main.hardMode && !DownedBossSystem.downedAquaticScourge) || BossRushEvent.BossRushActive) + if (AcidRainEventIsOngoing || (!NPC.downedBoss1 && !Main.hardMode && !DownedBossSystem.downedAquaticScourge && !DownedBossSystem.downedPolterghast) || BossRushEvent.BossRushActive || Terraria.GameContent.Creative.CreativePowerManager.Instance.GetPower().Enabled) return; int playerCount = Main.CurrentFrameFlags.ActivePlayersCount; diff --git a/ExtraTextures/GreyscaleGradients/Pebbles.png b/ExtraTextures/GreyscaleGradients/Pebbles.png new file mode 100644 index 0000000000..5f05401249 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/Pebbles.png differ diff --git a/ExtraTextures/GreyscaleGradients/Smudges2.png b/ExtraTextures/GreyscaleGradients/Smudges2.png new file mode 100644 index 0000000000..fcdefedba1 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/Smudges2.png differ diff --git a/ExtraTextures/GreyscaleGradients/Swirls.png b/ExtraTextures/GreyscaleGradients/Swirls.png new file mode 100644 index 0000000000..da2c4380b0 Binary files /dev/null and b/ExtraTextures/GreyscaleGradients/Swirls.png differ diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index d9b9212975..70666e8415 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -652,7 +652,8 @@ namespace CalamityMod.ILEditing if (modPlayer is null) return; - if (modPlayer.chaliceOfTheBloodGod && modPlayer.chaliceBleedoutBuffer > 0D) + // CIT 17MAY2025: Bleedout clear has a special interaction with Bloom Stone handled elsewhere; do not run this if wearing Bloom Stone + if (modPlayer.chaliceOfTheBloodGod && modPlayer.chaliceBleedoutBuffer > 0D && !modPlayer.bloomStone) { // 20FEB2024: Ozzatron: to prevent abuse, buffer clearing is now 50% of the potion instead of 50% of your buffer float amountOfBleedToClear = ChaliceOfTheBloodGod.HealingPotionRatioForBufferClear * player.GetHealLife(potion, true); diff --git a/Items/Accessories/BatholithBangle.cs b/Items/Accessories/BatholithBangle.cs new file mode 100644 index 0000000000..ef0d8c630f --- /dev/null +++ b/Items/Accessories/BatholithBangle.cs @@ -0,0 +1,39 @@ +using CalamityMod.CalPlayer; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class BatholithBangle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public static int cooldown = 600; + public static int damage = 225; + public override void SetDefaults() + { + Item.width = 36; + Item.height = 28; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.batholithBangle = true; + modPlayer.batholithBangleVisual = !hideVisual; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddRecipeGroup("Boss2Material", 15). + AddIngredient(ItemID.Granite, 45). + AddIngredient(ItemID.Amber, 3). + AddIngredient(ItemID.FallenStar, 5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/BatholithBangle.png b/Items/Accessories/BatholithBangle.png new file mode 100644 index 0000000000..bd19ef3e43 Binary files /dev/null and b/Items/Accessories/BatholithBangle.png differ diff --git a/Items/Accessories/BlackGlassBand.cs b/Items/Accessories/BlackGlassBand.cs index e5bd9dc238..ff767add74 100644 --- a/Items/Accessories/BlackGlassBand.cs +++ b/Items/Accessories/BlackGlassBand.cs @@ -8,8 +8,8 @@ namespace CalamityMod.Items.Accessories public class BlackGlassBand : ModItem, ILocalizedModType { public new string LocalizationCategory => "Items.Accessories"; - public static int cooldown = 420; - public static int damage = 40; + public static int cooldown = 300; + public static int damage = 32; public override void SetDefaults() { Item.width = 30; @@ -27,9 +27,9 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { CreateRecipe(). - AddRecipeGroup("AnyGoldBar", 5). - AddIngredient(ItemID.Diamond, 2). - AddIngredient(ItemID.Obsidian, 25). + AddRecipeGroup("AnyGoldBar", 8). + AddIngredient(ItemID.Diamond, 3). + AddIngredient(ItemID.Obsidian, 35). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Accessories/BlazingCore.cs b/Items/Accessories/BlazingCore.cs index c7e084615f..d77f390a86 100644 --- a/Items/Accessories/BlazingCore.cs +++ b/Items/Accessories/BlazingCore.cs @@ -40,6 +40,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().blazingCore = true; + player.noKnockback = true; } public static void HandleStars(Player player) diff --git a/Items/Accessories/BloodflareCore.cs b/Items/Accessories/BloodflareCore.cs index 0cc9b6c92a..d045c257a9 100644 --- a/Items/Accessories/BloodflareCore.cs +++ b/Items/Accessories/BloodflareCore.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.bloodflareCore = true; + player.noKnockback = true; } } } diff --git a/Items/Accessories/BloomStone.cs b/Items/Accessories/BloomStone.cs index 6858aaff91..bd36d30f54 100644 --- a/Items/Accessories/BloomStone.cs +++ b/Items/Accessories/BloomStone.cs @@ -22,101 +22,10 @@ namespace CalamityMod.Items.Accessories CalamityPlayer modPlayer = player.Calamity(); Lighting.AddLight((int)player.Center.X / 16, (int)player.Center.Y / 16, 0.25f, 0.4f, 0.2f); - // Provide life benefits if the player is standing on ground and has typical gravity. - int x = (int)player.Center.X / 16; - int y = (int)(player.Bottom.Y - 1f) / 16; - Tile groundTile = CalamityUtils.ParanoidTileRetrieval(x, y + 1); - bool groundTileIsSolid = groundTile.HasUnactuatedTile && (Main.tileSolid[groundTile.TileType] || Main.tileSolidTop[groundTile.TileType]); - if (groundTileIsSolid && player.gravDir == 1f) - modPlayer.BloomStoneRegen = true; - - // Flower boots effects. - if (player.whoAmI == Main.myPlayer && player.velocity.Y == 0f && player.grappling[0] == -1) - { - Tile walkTile = CalamityUtils.ParanoidTileRetrieval(x, y); - if (!walkTile.HasTile && walkTile.LiquidAmount == 0 && groundTile != null && WorldGen.SolidTile(groundTile)) - { - walkTile.TileFrameY = 0; - walkTile.Get().Slope = SlopeType.Solid; - walkTile.Get().IsHalfBlock = false; - // On dirt blocks, there's a small chance to grow a dye plant. - if (groundTile.TileType == TileID.Dirt) - { - if (Main.rand.NextBool(1000)) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.DyePlants; - walkTile.TileFrameX = (short)(34 * Main.rand.Next(0, 13)); - while (walkTile.TileFrameX == 144) - walkTile.TileFrameX = (short)(34 * Main.rand.Next(0, 13)); - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - - // On grass, grow flowers. - if (groundTile.TileType == TileID.Grass) - { - if (Main.rand.NextBool()) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.Plants; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 11)); - - while (walkTile.TileFrameX == 144) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 11)); - } - else - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.Plants2; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 21)); - - while (walkTile.TileFrameX == 144) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(6, 21)); - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - - // On hallowed grass, grow hallowed flowers. - else if (groundTile.TileType == TileID.HallowedGrass) - { - if (Main.rand.NextBool()) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.HallowedPlants; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(4, 7)); - while (walkTile.TileFrameX == 90) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(4, 7)); - } - else - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.HallowedPlants2; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(2, 8)); - while (walkTile.TileFrameX == 90) - walkTile.TileFrameX = (short)(18 * Main.rand.Next(2, 8)); - } - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - - // On jungle grass, grow jungle flowers. - else if (groundTile.TileType == TileID.JungleGrass) - { - walkTile.Get().HasTile = true; - walkTile.TileType = TileID.JunglePlants2; - walkTile.TileFrameX = (short)(18 * Main.rand.Next(9, 17)); - - if (Main.netMode == NetmodeID.MultiplayerClient) - NetMessage.SendTileSquare(-1, x, y, 1, TileChangeType.None); - } - } - } + modPlayer.healingPotionMultiplier += 0.5f; + modPlayer.bloomStone = true; + modPlayer.bloomStoneHookVisuals = true; } + public override void UpdateVanity(Player player) => player.Calamity().bloomStoneHookVisuals = true; } } diff --git a/Items/Accessories/DarkSunRing.cs b/Items/Accessories/DarkSunRing.cs index 030506fa76..ab510a8525 100644 --- a/Items/Accessories/DarkSunRing.cs +++ b/Items/Accessories/DarkSunRing.cs @@ -39,6 +39,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.darkSunRing = true; + player.noKnockback = true; } public override void AddRecipes() diff --git a/Items/Accessories/DeadshotBrooch.cs b/Items/Accessories/DeadshotBrooch.cs index d017624cdf..16e3459913 100644 --- a/Items/Accessories/DeadshotBrooch.cs +++ b/Items/Accessories/DeadshotBrooch.cs @@ -22,7 +22,7 @@ namespace CalamityMod.Items.Accessories public override void UpdateAccessory(Player player, bool hideVisual) { player.Calamity().deadshotBrooch = true; - player.Calamity().rangedAmmoCost *= 0.8f; + player.Calamity().ammoCost *= 0.8f; player.GetDamage() += 0.12f; player.GetCritChance() += 7; } diff --git a/Items/Accessories/DraedonsHeart.cs b/Items/Accessories/DraedonsHeart.cs index abbe1e35a3..356c9384cb 100644 --- a/Items/Accessories/DraedonsHeart.cs +++ b/Items/Accessories/DraedonsHeart.cs @@ -57,6 +57,7 @@ namespace CalamityMod.Items.Accessories modPlayer.adrenaline = 0f; modPlayer.draedonsHeart = true; + player.noKnockback = true; modPlayer.hadNanomachinesLastFrame = true; modPlayer.AdrenalineDuration = NanomachinesDuration; modPlayer.contactDamageReduction += ContactDamageReduction; diff --git a/Items/Accessories/FlameLickedShell.cs b/Items/Accessories/FlameLickedShell.cs index 4637cba6cc..4cf105a720 100644 --- a/Items/Accessories/FlameLickedShell.cs +++ b/Items/Accessories/FlameLickedShell.cs @@ -32,6 +32,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.flameLickedShell = true; + player.noKnockback = true; } public static void handleParry(Player player) diff --git a/Items/Accessories/GladiatorsLocket.cs b/Items/Accessories/GladiatorsLocket.cs index c7b583cea5..104e8933bc 100644 --- a/Items/Accessories/GladiatorsLocket.cs +++ b/Items/Accessories/GladiatorsLocket.cs @@ -1,8 +1,4 @@ using System; -using CalamityMod.Buffs.Summon; -using CalamityMod.CalPlayer; -using CalamityMod.Projectiles.Typeless; -using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -14,8 +10,8 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void SetDefaults() { - Item.width = 42; - Item.height = 36; + Item.width = 48; + Item.height = 54; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; diff --git a/Items/Accessories/GladiatorsLocket.png b/Items/Accessories/GladiatorsLocket.png index d2e1c67d65..372792ae48 100644 Binary files a/Items/Accessories/GladiatorsLocket.png and b/Items/Accessories/GladiatorsLocket.png differ diff --git a/Items/Accessories/OldDukeScales.cs b/Items/Accessories/OldDukeScales.cs index 9e38022feb..0a7355d763 100644 --- a/Items/Accessories/OldDukeScales.cs +++ b/Items/Accessories/OldDukeScales.cs @@ -29,6 +29,7 @@ namespace CalamityMod.Items.Accessories { OldDukeScalesPlayer modPlayer = player.GetModPlayer(); modPlayer.OldDukeScalesOn = true; + player.noKnockback = true; } } diff --git a/Items/Accessories/PlanebreakersPouch.cs b/Items/Accessories/PlanebreakersPouch.cs index 20902eceda..5bd2fdf625 100644 --- a/Items/Accessories/PlanebreakersPouch.cs +++ b/Items/Accessories/PlanebreakersPouch.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Accessories player.magicQuiver = true; CalamityPlayer modPlayer = player.Calamity(); modPlayer.deadshotBrooch = true; - modPlayer.rangedAmmoCost *= 0.8f; + modPlayer.ammoCost *= 0.8f; } public override void ModifyTooltips(List tooltips) => tooltips.IntegrateHotkey(CalamityKeybinds.AmmoCycleHotkey); diff --git a/Items/Accessories/ProtolithBangle.cs b/Items/Accessories/ProtolithBangle.cs new file mode 100644 index 0000000000..4c51e063a3 --- /dev/null +++ b/Items/Accessories/ProtolithBangle.cs @@ -0,0 +1,40 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Items.Weapons.Ranged; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class ProtolithBangle : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public static int cooldown = 420; + public static int damage = 68; + public override void SetDefaults() + { + Item.width = 34; + Item.height = 34; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + public override void UpdateAccessory(Player player, bool hideVisual) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.protolithBangle = true; + modPlayer.protolithBangleVisual = !hideVisual; + } + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddRecipeGroup("Boss2Material", 15). + AddIngredient(ItemID.Marble, 45). + AddIngredient(ItemID.Ruby, 3). + AddIngredient(ItemID.Lens, 5). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Accessories/ProtolithBangle.png b/Items/Accessories/ProtolithBangle.png new file mode 100644 index 0000000000..0fc9477145 Binary files /dev/null and b/Items/Accessories/ProtolithBangle.png differ diff --git a/Items/Accessories/StatMeter.cs b/Items/Accessories/StatMeter.cs index 7bce076402..931dd0c47e 100644 --- a/Items/Accessories/StatMeter.cs +++ b/Items/Accessories/StatMeter.cs @@ -153,13 +153,13 @@ namespace CalamityMod.Items.Accessories } } - // If ranged, or any direct subclass thereof, display ranged ammo consumption - if (dc == DamageClass.Ranged || dc.GetModifierInheritance(DamageClass.Ranged).Equals(StatInheritanceData.Full)) - stats2 += "\n" + this.GetLocalization("RangedStats").Format(TwoPlaces(100f * player.GetRangedAmmoCostReduction())); + // If held item uses ammo, display ammo consumption + if (heldItem.useAmmo > 0) + stats2 += "\n" + this.GetLocalization("AmmoStats").Format(OnePlace(100f * player.GetAmmoCostReduction())); - // If magic, or any direct subclass thereof, display mana stats - if (dc == DamageClass.Magic || dc == DamageClass.MagicSummonHybrid || dc.GetModifierInheritance(DamageClass.Magic).Equals(StatInheritanceData.Full)) - stats2 += "\n" + this.GetLocalization("MagicStats").Format(TwoPlaces(100f * player.manaCost), player.manaRegen); + // If held item uses mana, display mana stats + if (heldItem.mana > 0) + stats2 += "\n" + this.GetLocalization("ManaStats").Format(OnePlace(100f * player.manaCost), player.manaRegen); // If summon, or any direct subclass thereof, AND NOT A WHIP, display minion/sentry slots if (dc != DamageClass.SummonMeleeSpeed && (dc == DamageClass.Summon || dc.GetModifierInheritance(DamageClass.Summon).Equals(StatInheritanceData.Full))) @@ -168,7 +168,7 @@ namespace CalamityMod.Items.Accessories // If whip, show whip range float whipRange = player.whipRangeMultiplier - 1f; if (dc == DamageClass.SummonMeleeSpeed || dc.GetModifierInheritance(DamageClass.SummonMeleeSpeed).Equals(StatInheritanceData.Full)) - stats2 += "\n" + this.GetLocalization("WhipStats").Format(Sign(whipRange) + TwoPlaces(100f * whipRange)); + stats2 += "\n" + this.GetLocalization("WhipStats").Format(Sign(whipRange) + OnePlace(100f * whipRange)); // If throwing or rogue, display rogue stats. float rogueVelocity = modPlayer.rogueVelocity - 1f; @@ -178,7 +178,7 @@ namespace CalamityMod.Items.Accessories (int)(100f * modPlayer.rogueStealthMax), TwoPlaces(60f * player.GetStandingStealthRegen()), TwoPlaces(60f * player.GetMovingStealthRegen()), - Sign(rogueVelocity) + TwoPlaces(100f * rogueVelocity)); + Sign(rogueVelocity) + OnePlace(100f * rogueVelocity)); } // If tool, add tool range diff --git a/Items/Accessories/TheCamper.cs b/Items/Accessories/TheCamper.cs index b6f793c7e2..ff7b09897f 100644 --- a/Items/Accessories/TheCamper.cs +++ b/Items/Accessories/TheCamper.cs @@ -62,7 +62,7 @@ namespace CalamityMod.Items.Accessories { if (npc.IsAnEnemy() && !npc.dontTakeDamage && Vector2.Distance(player.Center, npc.Center) <= range) { - int campingFireDamage = (int)player.GetBestClassDamage().ApplyTo(Main.rand.Next(20, 41)); + int campingFireDamage = (int)player.GetBestClassDamage().ApplyTo(Main.rand.Next(100, 121)); Projectile.NewProjectile(source, npc.Center, Vector2.Zero, ModContent.ProjectileType(), campingFireDamage, 0f, player.whoAmI, npc.whoAmI); } } diff --git a/Items/Accessories/TheSponge.cs b/Items/Accessories/TheSponge.cs index b37ec798aa..6b7a9e6cae 100644 --- a/Items/Accessories/TheSponge.cs +++ b/Items/Accessories/TheSponge.cs @@ -87,6 +87,7 @@ namespace CalamityMod.Items.Accessories { CalamityPlayer modPlayer = player.Calamity(); modPlayer.sponge = true; + player.noKnockback = true; modPlayer.spongeShieldVisible = !hideVisual; if (modPlayer.SpongeShieldDurability > 0) diff --git a/Items/Accessories/TheTransformer.cs b/Items/Accessories/TheTransformer.cs index 4c5043b3ba..9a5304b9f9 100644 --- a/Items/Accessories/TheTransformer.cs +++ b/Items/Accessories/TheTransformer.cs @@ -20,8 +20,8 @@ namespace CalamityMod.Items.Accessories public new string LocalizationCategory => "Items.Accessories"; public override void ModifyTooltips(List list) { - list.IntegrateHotkey(CalamityKeybinds.TransformerHotKey); list.FindAndReplace("[GFB]", Lang.SupportGlyphs(this.GetLocalizedValue(Main.zenithWorld ? "TooltipGFB" : "TooltipNormal"))); + list.IntegrateHotkey(CalamityKeybinds.TransformerHotKey); } public override void SetStaticDefaults() { diff --git a/Items/Accessories/UnstableGraniteCore.cs b/Items/Accessories/UnstableGraniteCore.cs index c6c5779487..178ce5ca83 100644 --- a/Items/Accessories/UnstableGraniteCore.cs +++ b/Items/Accessories/UnstableGraniteCore.cs @@ -18,8 +18,8 @@ namespace CalamityMod.Items.Accessories public override void SetDefaults() { - Item.width = 40; - Item.height = 44; + Item.width = 46; + Item.height = 48; Item.value = CalamityGlobalItem.RarityOrangeBuyPrice; Item.rare = ItemRarityID.Orange; Item.accessory = true; diff --git a/Items/Accessories/UnstableGraniteCore.png b/Items/Accessories/UnstableGraniteCore.png index 309d3cfa45..02230f0bca 100644 Binary files a/Items/Accessories/UnstableGraniteCore.png and b/Items/Accessories/UnstableGraniteCore.png differ diff --git a/Items/Accessories/WulfrumAcrobaticsPack.cs b/Items/Accessories/WulfrumAcrobaticsPack.cs index b1339b3a06..aab707da5b 100644 --- a/Items/Accessories/WulfrumAcrobaticsPack.cs +++ b/Items/Accessories/WulfrumAcrobaticsPack.cs @@ -46,9 +46,9 @@ namespace CalamityMod.Items.Accessories public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.Chain, 2). - AddIngredient(6). + AddIngredient(5). AddIngredient(). + AddIngredient(ItemID.Chain, 2). AddTile(TileID.Anvils). Register(); } @@ -132,7 +132,7 @@ namespace CalamityMod.Items.Accessories if (!Grappled) return false; - if (!PlayerOnGround) + if (!PlayerOnGround || !obeyGravity) return false; if ((Player.Center - Main.projectile[Grapple].Center).Length() > SwingLength) @@ -142,6 +142,8 @@ namespace CalamityMod.Items.Accessories } } + public bool obeyGravity => !(Player.miscEquips[4].type == ItemID.AntiGravityHook); + public bool strongerReel => Player.miscEquips[4].type == ItemID.StaticHook; public Vector2 CurrentPosition; public Vector2 OldPosition; public List Segments; @@ -280,7 +282,10 @@ namespace CalamityMod.Items.Accessories } hookCache = -1; - + if (!obeyGravity) + { + Player.gravity = -1f; //Disable player gravity with Anti-Grav hook + } if (Grappled) { if ((Main.projectile[Grapple].Center - Player.Center).Length() > SwingLength + 80f) @@ -299,7 +304,7 @@ namespace CalamityMod.Items.Accessories public void SimulateMovement(Projectile grapple) { - Segments = VerletSimulatedSegment.SimpleSimulation(Segments, SwingLength / SimulationResolution, 50, 0.3f * Player.gravDir); + Segments = VerletSimulatedSegment.SimpleSimulation(Segments, SwingLength / SimulationResolution, 50, (obeyGravity ? 0.3f * Player.gravDir : 0)); Vector2 CurrentPosition; @@ -313,40 +318,83 @@ namespace CalamityMod.Items.Accessories } if (!GrappleMovementDisabled) { - CurrentPosition = Segments[SimulationResolution].position; - Player.velocity = CurrentPosition - Player.Center; - - //let the player swing themselves around if they are under the hook. - if (Player.gravDir * (Player.Center.Y - Segments[0].position.Y) > 0) + if (obeyGravity) { - float swing = 0; - if (Math.Sign(Player.velocity.X) < 0) + + CurrentPosition = Segments[SimulationResolution].position; + Player.velocity = CurrentPosition - Player.Center; + + //let the player swing themselves around if they are under the hook. + if (Player.gravDir * (Player.Center.Y - Segments[0].position.Y) > 0) { - if (Player.controlLeft) - swing -= 0.1f; + float swing = 0; - else if (Player.controlRight) - swing += 0.1f; + if (Math.Sign(Player.velocity.X) < 0) + { + if (Player.controlLeft) + swing -= 0.1f; + + else if (Player.controlRight) + swing += 0.1f; + } + + else if (Math.Sign(Player.velocity.X) > 0) + { + if (Player.controlRight) + swing += 0.1f; + + else if (Player.controlLeft) + swing -= 0.1f; + } + + Player.velocity.X += swing; } - else if (Math.Sign(Player.velocity.X) > 0) + else if (Math.Abs(Player.Center.X - Segments[0].position.X) < 30f && Math.Abs(Player.velocity.X) < 1) { - if (Player.controlRight) - swing += 0.1f; - - else if (Player.controlLeft) - swing -= 0.1f; + Player.velocity.X = Player.velocity.X == 0 ? 1.5f : 1.5f * Math.Sign(Player.velocity.X); } - - Player.velocity.X += swing * (Player.miscEquips[4].type == ItemID.AntiGravityHook ? 1.75f : 1); } - - else if (Math.Abs(Player.Center.X - Segments[0].position.X) < 30f && Math.Abs(Player.velocity.X) < 1) + + else { - Player.velocity.X = Player.velocity.X == 0 ? 1.5f : 1.5f * Math.Sign(Player.velocity.X); - } + if (Player.grappling[0] > -1) + { + var Hook = Main.projectile[Player.grappling[0]]; + if (Hook != null) + { + + if (Player.controlRight) + Player.velocity.X += 0.3f; + else if (Player.controlLeft) + Player.velocity.X -= 0.3f; + Player.velocity -= Player.Center.DirectionTo(Hook.Center); + var estimatedPos = Player.Center + Player.velocity; + var estimatedDir = Hook.Center.DirectionTo(estimatedPos); + var goalPos = Hook.Center + estimatedDir * SwingLength; + var estimatedPosLocked = Hook.Center + Hook.Center.DirectionTo(Player.Center) * SwingLength; + if (estimatedPosLocked.Distance(estimatedPos) < 2) + { + estimatedPos = estimatedPosLocked; + } + var dis = Hook.Center.Distance(estimatedPos); + if (dis > SwingLength && dis < 1000f) + { + var dis2 = Math.Min(Player.Center.Distance(goalPos), SwingLength*3f); + if (dis2 > 0) + { + Player.velocity = Player.Center.DirectionTo(goalPos) * dis2; + } + } + + + if (Player.velocity.Length() < 1.5f) + Player.direction = Hook.Center.X > Player.Center.X ? 1 : -1; + } + } + } } if (Grappled) @@ -512,7 +560,7 @@ namespace CalamityMod.Items.Accessories } if (Grappled && triggersSet.Up) { - SwingLength -= (Player.miscEquips[4].type == ItemID.StaticHook ? StaticHookReelSpeed : ReelSpeed); + SwingLength -= (strongerReel ? StaticHookReelSpeed : ReelSpeed); Player.controlUp = false; //This is required to stop the player from bouncing off platforms when falling down and reeling in. Also prevents gravity swapping while hooked. } if (triggersSet.Down) //Static Hook doesn't effect this speed because it would be faster than your fall speed and feel janky. diff --git a/Items/Accessories/YharimsGift.cs b/Items/Accessories/YharimsGift.cs index 83d180aa84..700c009808 100644 --- a/Items/Accessories/YharimsGift.cs +++ b/Items/Accessories/YharimsGift.cs @@ -29,6 +29,7 @@ namespace CalamityMod.Items.Accessories var source = player.GetSource_Accessory(Item); player.moveSpeed += 0.15f; player.GetDamage() += 0.15f; + player.noKnockback = true; if (!player.StandingStill()) { dragonTimer--; diff --git a/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs b/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs index bc1b1eaadc..f67aa39d0f 100644 --- a/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs +++ b/Items/Armor/MarniteArchitect/MarniteArchitectSet.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Armor.MarniteArchitect Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 1; + Item.defense = 4; } private void ActivateLift(Terraria.On_Player.orig_QuickMount orig, Player self) @@ -155,7 +155,7 @@ namespace CalamityMod.Items.Armor.MarniteArchitect Item.height = 18; Item.value = CalamityGlobalItem.RarityBlueBuyPrice; Item.rare = ItemRarityID.Blue; - Item.defense = 2; + Item.defense = 5; } public override void UpdateEquip(Player player) diff --git a/Items/Armor/Wulfrum/WulfrumSet.cs b/Items/Armor/Wulfrum/WulfrumSet.cs index 69987f14d2..2b9dcc9d35 100644 --- a/Items/Armor/Wulfrum/WulfrumSet.cs +++ b/Items/Armor/Wulfrum/WulfrumSet.cs @@ -298,7 +298,7 @@ namespace CalamityMod.Items.Armor.Wulfrum public override void AddRecipes() { CreateRecipe(). - AddIngredient(12). + AddIngredient(10). AddIngredient(). AddTile(TileID.Anvils). Register(); diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 549516ccc4..08330443d3 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -293,7 +293,7 @@ namespace CalamityMod.Items } // Increase how much health Mushrooms heal. - if (item.type == ItemID.Mushroom && item.healLife == 15) + if (item.type == ItemID.Mushroom && item.healLife < 25) item.healLife = 25; // Allow Beam Sword to change direction when it fires, because vanilla disables it for some reason. @@ -658,6 +658,8 @@ namespace CalamityMod.Items public override bool? UseItem(Item item, Player player) { + var modPlayer = player.Calamity(); + if (Main.zenithWorld && item.type == ItemID.RodOfHarmony) { if (NPC.AnyNPCs(ModContent.NPCType())) @@ -671,6 +673,18 @@ namespace CalamityMod.Items if (item.type == ItemID.Mushroom && player.Calamity().fungalSymbiote) player.AddBuff(ModContent.BuffType(), 3600); + // Trigger Bloom Stone's heal over time from healing items + if (item.healLife > 0 && modPlayer.bloomStone) + { + // Temporarily disable Bloom Stone so that GetHealLife doesn't return 0 + modPlayer.bloomStone = false; + modPlayer.bloomStoneTotalHeal = player.GetHealLife(item); + modPlayer.bloomStone = true; + + modPlayer.bloomStoneHealInc = modPlayer.bloomStoneTotalHeal / 15; + modPlayer.bloomStoneHealTimer = (int)Math.Ceiling(modPlayer.bloomStoneTotalHeal / (double)modPlayer.bloomStoneHealInc) * 40; + } + // Staff/Axe of Regrowth growing Calamity grass if (item.type == ItemID.StaffofRegrowth || item.type == ItemID.AcornAxe) { @@ -976,14 +990,13 @@ namespace CalamityMod.Items } #endregion - #region ModifyHitNPC + #region Hit NPC public override void ModifyHitNPC(Item item, Player player, NPC target, ref NPC.HitModifiers modifiers) { // This assume all items with a damage hit is a weapon. There appears to be no edge cases for this thus far if (player.Calamity().oldFashioned) modifiers.SourceDamage *= OldFashioned.DamageReductionMultiplier; } - #endregion public override void OnHitNPC(Item item, Player player, NPC target, NPC.HitInfo hit, int damageDone) { @@ -1009,6 +1022,7 @@ namespace CalamityMod.Items } } } + #endregion #region Armor Set Changes public override string IsArmorSet(Item head, Item body, Item legs) @@ -1553,7 +1567,7 @@ namespace CalamityMod.Items #endregion #region Ammo - public override bool CanConsumeAmmo(Item weapon, Item ammo, Player player) => Main.rand.NextFloat() <= player.Calamity().rangedAmmoCost; + public override bool CanConsumeAmmo(Item weapon, Item ammo, Player player) => Main.rand.NextFloat() <= player.Calamity().ammoCost; public static bool HasEnoughAmmo(Player player, Item item, int ammoConsumed) { @@ -1626,7 +1640,7 @@ namespace CalamityMod.Items dontConsumeAmmo = true; if (player.ammoCost75 && Main.rand.NextBool(4)) dontConsumeAmmo = true; - if (Main.rand.NextFloat() > player.Calamity().rangedAmmoCost) + if (Main.rand.NextFloat() > player.Calamity().ammoCost) dontConsumeAmmo = true; if (!dontConsumeAmmo && itemAmmo.consumable) diff --git a/Items/CalamityGlobalItemTweaks.cs b/Items/CalamityGlobalItemTweaks.cs index cb454cbecc..ccac4c3858 100644 --- a/Items/CalamityGlobalItemTweaks.cs +++ b/Items/CalamityGlobalItemTweaks.cs @@ -211,7 +211,7 @@ namespace CalamityMod.Items { ItemID.PygmyStaff, Do(AutoReuse, UseExact(20), DamageExact(70)) }, { ItemID.QuadBarrelShotgun, Do(PointBlank, DamageExact(11)) }, { ItemID.RainbowGun, Do(DamageExact(60), ManaExact(40)) }, - { ItemID.RainbowRod, Do(DamageExact(40), ManaExact(13)) }, + { ItemID.RainbowRod, Do(DamageExact(40), ManaExact(13), KnockbackExact(8f)) }, { ItemID.Rally, Do(AutoReuse, DamageExact(18)) }, { ItemID.RavenStaff, Do(AutoReuse, UseExact(20), DamageExact(36)) }, { ItemID.RazorbladeTyphoon, Do(DamageExact(103)) }, @@ -333,7 +333,7 @@ namespace CalamityMod.Items #endregion #region CATEGORY 3: Tool Balancing - { ItemID.AcornAxe, Do(AxePower(125)) }, // Axe of Regrowth + { ItemID.AcornAxe, Do(AxePower(100)) }, // Axe of Regrowth { ItemID.AdamantiteChainsaw, Do(TrueMeleeNoSpeed, AxePower(90), UseTimeExact(4), TileBoostExact(+0), DamageExact(75)) }, { ItemID.AdamantiteDrill, Do(TrueMeleeNoSpeed, PickPower(180), UseTimeExact(4), TileBoostExact(+1), DamageExact(32)) }, { ItemID.AdamantitePickaxe, Do(PickPower(180), UseTimeExact(8), TileBoostExact(+1)) }, @@ -596,28 +596,9 @@ namespace CalamityMod.Items #endregion #region CATEGORY 9: Sell Prices - { ItemID.Apple, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Apricot, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Banana, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.BlackCurrant, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.BloodOrange, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Cherry, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Coconut, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Dragonfruit, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Elderberry, Do(Value(Item.sellPrice(copper: 40))) }, { ItemID.EncumberingStone, Do(Worthless) }, { ItemID.GlowingMushroom, Do(Worthless) }, - { ItemID.Grapefruit, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Lemon, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Mango, Do(Value(Item.sellPrice(copper: 40))) }, { ItemID.Mushroom, Do(Worthless) }, - { ItemID.Peach, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Pineapple, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Plum, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Pomegranate, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Rambutan, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.SpicyPepper, Do(Value(Item.sellPrice(copper: 40))) }, - { ItemID.Starfruit, Do(Value(Item.sellPrice(copper: 40))) }, { ItemID.PortableStool, Do(Value(Item.sellPrice(copper: 20))) }, // Step Stool { ItemID.UncumberingStone, Do(Worthless) }, { ItemID.ViciousMushroom, Do(Worthless) }, diff --git a/Items/Fishing/FishingRods/WulfrumRod.cs b/Items/Fishing/FishingRods/WulfrumRod.cs index d7309b4449..c004f3137f 100644 --- a/Items/Fishing/FishingRods/WulfrumRod.cs +++ b/Items/Fishing/FishingRods/WulfrumRod.cs @@ -34,7 +34,7 @@ namespace CalamityMod.Items.Fishing.FishingRods public override void AddRecipes() { CreateRecipe(). - AddIngredient(6). + AddIngredient(5). AddTile(TileID.Anvils). Register(); } diff --git a/Items/PermanentBoosters/NimbleBounder.cs b/Items/PermanentBoosters/NimbleBounder.cs index e4919d1dfb..81ace67013 100644 --- a/Items/PermanentBoosters/NimbleBounder.cs +++ b/Items/PermanentBoosters/NimbleBounder.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.PermanentBoosters // Same price as Frog Leg, which is used to shimmer into it Item.value = Item.sellPrice(gold: 1); Item.rare = ModContent.RarityType(); - Item.stack = Item.CommonMaxStack; + Item.maxStack = Item.CommonMaxStack; Item.Calamity().devItem = true; } diff --git a/Items/Placeables/Furniture/WulfrumLureItem.cs b/Items/Placeables/Furniture/WulfrumLureItem.cs index 4d0318c02b..8f62916f19 100644 --- a/Items/Placeables/Furniture/WulfrumLureItem.cs +++ b/Items/Placeables/Furniture/WulfrumLureItem.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Placeables.Furniture { CreateRecipe(). AddIngredient(5). - AddIngredient(). + AddIngredient(). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Potions/Alcohol/RedWine.cs b/Items/Potions/Alcohol/RedWine.cs index 15c37e5d1a..df301e6121 100644 --- a/Items/Potions/Alcohol/RedWine.cs +++ b/Items/Potions/Alcohol/RedWine.cs @@ -13,7 +13,7 @@ namespace CalamityMod.Items.Potions.Alcohol public static int HealValue = 200; public static int RegenLoss = 1; - public static int SecondDuration = 15; + public static int SecondDuration = 30; public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(RegenLoss.ToRegenPerSecond(), SecondDuration); public override void SetStaticDefaults() diff --git a/Items/Tools/FellerofEvergreens.cs b/Items/Tools/FellerofEvergreens.cs index 4d95f705b3..ed226d2ac1 100644 --- a/Items/Tools/FellerofEvergreens.cs +++ b/Items/Tools/FellerofEvergreens.cs @@ -30,7 +30,7 @@ namespace CalamityMod.Items.Tools { CreateRecipe(). AddRecipeGroup("AnySilverBar", 18). - AddRecipeGroup("Wood", 18). + AddIngredient(ItemID.RichMahogany, 18). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/WulfrumDiggingTurtle.cs b/Items/Tools/WulfrumDiggingTurtle.cs index 76181d9eeb..828c7d88a9 100644 --- a/Items/Tools/WulfrumDiggingTurtle.cs +++ b/Items/Tools/WulfrumDiggingTurtle.cs @@ -76,9 +76,9 @@ namespace CalamityMod.Items.Tools public override void AddRecipes() { - CreateRecipe(3). - AddIngredient(ItemID.Gel, 5). //Gel is a default combustible item to fuel the motors of the lil guys + CreateRecipe(15). AddIngredient(3). + AddIngredient(). Register(); } } diff --git a/Items/Tools/WulfrumDrill.cs b/Items/Tools/WulfrumDrill.cs index 0d829fad72..99ac145eee 100644 --- a/Items/Tools/WulfrumDrill.cs +++ b/Items/Tools/WulfrumDrill.cs @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Tools public override void AddRecipes() { CreateRecipe(). - AddIngredient(8). + AddIngredient(5). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Tools/WulfrumTreasurePinger.cs b/Items/Tools/WulfrumTreasurePinger.cs index 165d179cd3..504ab951c3 100644 --- a/Items/Tools/WulfrumTreasurePinger.cs +++ b/Items/Tools/WulfrumTreasurePinger.cs @@ -281,7 +281,7 @@ namespace CalamityMod.Items.Tools { //Intentionally craftable anywhere. CreateRecipe(). - AddIngredient(6). + AddIngredient(5). Register() .DisableDecraft(); } diff --git a/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs b/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs index 983ac2f023..eb5436ff16 100644 --- a/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs +++ b/Items/TreasureBags/MiscGrabBags/FleshyGeode.cs @@ -55,8 +55,8 @@ namespace CalamityMod.Items.TreasureBags.MiscGrabBags expertPlus.Add(ModContent.ItemType(), 1, 1, 3); expertPlus.Add(ModContent.ItemType(), 1, 1, 3); expertPlus.Add(ModContent.ItemType(), 1, 1, 3); - normalOnly.Add(ModContent.ItemType(), 2); - normalOnly.Add(ModContent.ItemType(), 3); + expertPlus.Add(ModContent.ItemType(), 2); + expertPlus.Add(ModContent.ItemType(), 3); } } } diff --git a/Items/Weapons/Magic/AcidGun.cs b/Items/Weapons/Magic/AcidGun.cs index 1332539641..fea1b480a5 100644 --- a/Items/Weapons/Magic/AcidGun.cs +++ b/Items/Weapons/Magic/AcidGun.cs @@ -63,8 +63,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void AddRecipes() { CreateRecipe(). - AddIngredient(35). - AddIngredient(10). + AddIngredient(15). + AddIngredient(12). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Magic/FlareBolt.cs b/Items/Weapons/Magic/FlareBolt.cs index 3168b9b7ef..2dfac6fc97 100644 --- a/Items/Weapons/Magic/FlareBolt.cs +++ b/Items/Weapons/Magic/FlareBolt.cs @@ -57,9 +57,8 @@ namespace CalamityMod.Items.Weapons.Magic public override void AddRecipes() { CreateRecipe(). - AddIngredient(ItemID.HellstoneBar, 6). - AddIngredient(ItemID.Obsidian, 9). - AddIngredient(ItemID.Fireblossom, 2). + AddIngredient(ItemID.HellstoneBar, 10). + AddIngredient(ItemID.Fireblossom, 5). AddIngredient(ItemID.Ruby). AddTile(TileID.Bookcases). Register(); diff --git a/Items/Weapons/Magic/GloriousEnd.cs b/Items/Weapons/Magic/GloriousEnd.cs index fcf8c4aeb8..fa31df187f 100644 --- a/Items/Weapons/Magic/GloriousEnd.cs +++ b/Items/Weapons/Magic/GloriousEnd.cs @@ -1,4 +1,5 @@ using CalamityMod.Projectiles.Magic; +using CalamityMod.Projectiles.Summon; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -30,6 +31,8 @@ namespace CalamityMod.Items.Weapons.Magic Item.Calamity().donorItem = true; } + public override bool? CanAutoReuseItem(Player player) => player.ownedProjectileCounts[ModContent.ProjectileType()] > 0; + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; diff --git a/Items/Weapons/Magic/HellwingStaff.cs b/Items/Weapons/Magic/HellwingStaff.cs index 4e98d6301c..11717fe7c5 100644 --- a/Items/Weapons/Magic/HellwingStaff.cs +++ b/Items/Weapons/Magic/HellwingStaff.cs @@ -89,7 +89,7 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(ItemID.HellstoneBar, 10). - AddIngredient(ItemID.AshWood, 7). + AddIngredient(ItemID.AshWood, 10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Magic/ParasiticSceptor.cs b/Items/Weapons/Magic/ParasiticSceptor.cs index 3713f53c6e..52190729cf 100644 --- a/Items/Weapons/Magic/ParasiticSceptor.cs +++ b/Items/Weapons/Magic/ParasiticSceptor.cs @@ -96,7 +96,7 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(15). - AddIngredient(18). + AddIngredient(12). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Magic/PhantasmalFury.cs b/Items/Weapons/Magic/PhantasmalFury.cs index fd35188709..194bc9e44f 100644 --- a/Items/Weapons/Magic/PhantasmalFury.cs +++ b/Items/Weapons/Magic/PhantasmalFury.cs @@ -24,7 +24,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.height = 60; Item.damage = 190; Item.DamageType = DamageClass.Magic; - Item.mana = 60; + Item.mana = 80; Item.useTime = 3; Item.useAnimation = 45; Item.reuseDelay = 75; diff --git a/Items/Weapons/Magic/ShadowboltStaff.cs b/Items/Weapons/Magic/ShadowboltStaff.cs index 41015f2517..c3c932f9a3 100644 --- a/Items/Weapons/Magic/ShadowboltStaff.cs +++ b/Items/Weapons/Magic/ShadowboltStaff.cs @@ -20,7 +20,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 58; Item.height = 56; - Item.damage = 230; + Item.damage = 205; Item.DamageType = DamageClass.Magic; Item.mana = 10; Item.useTime = 12; diff --git a/Items/Weapons/Magic/ShiftingSands.cs b/Items/Weapons/Magic/ShiftingSands.cs index ad97b003f3..6c97761796 100644 --- a/Items/Weapons/Magic/ShiftingSands.cs +++ b/Items/Weapons/Magic/ShiftingSands.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Magic Item.rare = ItemRarityID.Lime; } - public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool CanUseItem(Player player) => !player.channel; public override void AddRecipes() { diff --git a/Items/Weapons/Magic/VenusianTrident.cs b/Items/Weapons/Magic/VenusianTrident.cs index fcfb75c37a..ea4d77de37 100644 --- a/Items/Weapons/Magic/VenusianTrident.cs +++ b/Items/Weapons/Magic/VenusianTrident.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 70; Item.height = 68; - Item.damage = 3333; + Item.damage = 2800; Item.DamageType = DamageClass.Magic; Item.mana = 40; Item.useTime = 65; diff --git a/Items/Weapons/Magic/WulfrumProsthesis.cs b/Items/Weapons/Magic/WulfrumProsthesis.cs index 08f1946933..1028f4af5a 100644 --- a/Items/Weapons/Magic/WulfrumProsthesis.cs +++ b/Items/Weapons/Magic/WulfrumProsthesis.cs @@ -145,7 +145,6 @@ namespace CalamityMod.Items.Weapons.Magic { CreateRecipe(). AddIngredient(10). - AddIngredient(). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Melee/Basher.cs b/Items/Weapons/Melee/Basher.cs index e050f25e6f..a880589f9f 100644 --- a/Items/Weapons/Melee/Basher.cs +++ b/Items/Weapons/Melee/Basher.cs @@ -2,6 +2,7 @@ using CalamityMod.Items.BaseItems; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; +using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Projectiles.Melee; using Terraria; using Terraria.ID; @@ -35,7 +36,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(). + AddIngredient(15). AddIngredient(12). AddTile(TileID.Anvils). Register(); diff --git a/Items/Weapons/Melee/BrokenBiomeBlade.cs b/Items/Weapons/Melee/BrokenBiomeBlade.cs index 2da5be69b2..02a837769c 100644 --- a/Items/Weapons/Melee/BrokenBiomeBlade.cs +++ b/Items/Weapons/Melee/BrokenBiomeBlade.cs @@ -324,8 +324,8 @@ namespace CalamityMod.Items.Weapons.Melee { CreateRecipe(). AddRecipeGroup("AnyWoodenSword"). - AddIngredient(ItemType(), 5). - AddIngredient(ItemID.HellstoneBar, 5). + AddIngredient(ItemType(), 10). + AddIngredient(ItemID.HellstoneBar, 10). AddIngredient(ItemID.DirtBlock, 50). AddIngredient(ItemID.StoneBlock, 50). AddTile(TileID.Anvils). diff --git a/Items/Weapons/Melee/BurningRevelation.cs b/Items/Weapons/Melee/BurningRevelation.cs index b4523d58ba..c0bdd8753b 100644 --- a/Items/Weapons/Melee/BurningRevelation.cs +++ b/Items/Weapons/Melee/BurningRevelation.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void SetDefaults() { Item.width = 40; - Item.height = 38; + Item.height = 48; Item.DamageType = DamageClass.MeleeNoSpeed; Item.damage = 300; Item.knockBack = 7.5f; diff --git a/Items/Weapons/Melee/MirrorBlade.cs b/Items/Weapons/Melee/MirrorBlade.cs index beda17aa01..76675010f7 100644 --- a/Items/Weapons/Melee/MirrorBlade.cs +++ b/Items/Weapons/Melee/MirrorBlade.cs @@ -1,47 +1,128 @@ using CalamityMod.Projectiles.Melee; +using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Rarities; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using CalamityMod.Systems.Collections; +using System; +using Terraria.Localization; +using Terraria.Audio; namespace CalamityMod.Items.Weapons.Melee { - public class MirrorBlade : ModItem, ILocalizedModType + public class MirrorBlade : BaseSwordHoldoutItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Melee"; - private int baseDamage = 100; + public override int ProjectileType => ModContent.ProjectileType(); + + public int reflectTimer = 0; + + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 5)); + ItemID.Sets.AnimatesAsSoul[Type] = true; + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + base.SetStaticDefaults(); + } public override void SetDefaults() { - Item.width = 72; - Item.height = 72; - Item.damage = baseDamage; - Item.DamageType = DamageClass.Melee; - Item.useAnimation = 12; - Item.useTime = 12; + Item.width = 114; + Item.height = 128; + Item.damage = 1000; + Item.DamageType = TrueMeleeDamageClass.Instance; + Item.useAnimation = 40; + Item.useTime = 40; Item.useTurn = true; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 7f; - Item.UseSound = SoundID.Item1; Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityTurquoiseBuyPrice; Item.rare = ModContent.RarityType(); Item.shootSpeed = 9f; Item.shoot = ModContent.ProjectileType(); + base.SetDefaults(); } - public override void OnHitNPC(Player player, NPC target, NPC.HitInfo hit, int damageDone) + public override void UpdateInventory(Player player) { - int conDamage = target.damage + baseDamage; - if (conDamage < baseDamage) + if (reflectTimer > 0) { - conDamage = baseDamage; + if (reflectTimer <= 50) + { + + float coneLength = 80f; + float maximumAngle = 0.8f; + float coneRotation = player.DirectionTo(Main.MouseWorld).ToRotation(); + var shardCount = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && (proj.ModProjectile as MirrorBlast).isShard) + { + shardCount++; + } + } + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.hostile && proj.damage > 0 && proj.Hitbox.IntersectsConeSlowMoreAccurate(player.Center, coneLength, coneRotation, maximumAngle)) + { + if (shardCount >= 10) + { + player.SetImmuneTimeForAllTypes(player.longInvince ? 60 : 30); + } + proj.Calamity().multiplicativeDR += shardCount / 10f; + proj.Calamity().multiplicativeDRTimer = 60; + foreach (var proj2 in Main.projectile) + { + if (proj2.active && proj2.type == ModContent.ProjectileType() && proj2.owner == player.whoAmI && (proj2.ModProjectile as MirrorBlast).isShard) + { + proj2.damage = (int)(proj2.damage * (shardCount >= 10 ? 3f : 2f)); + (proj2.ModProjectile as MirrorBlast).shardShield = 0; + (proj2.ModProjectile as MirrorBlast).shardNum = 11; + proj2.netUpdate = true; + } + } + if (shardCount > 0) + SoundEngine.PlaySound(SoundID.DD2_WitherBeastDeath,player.Center); + reflectTimer = 0; + return; + } + } + } + reflectTimer--; } - if (conDamage > 400) + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse == 2) { - conDamage = 400; + bool alreadyReflecting = reflectTimer > 0; + bool hasShard = false; + reflectTimer = 60; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == player.whoAmI && (proj.ModProjectile as MirrorBlast).isShard) + { + (proj.ModProjectile as MirrorBlast).shardShield = 60; + proj.netUpdate = true; + hasShard = true; + } + } + + if (!alreadyReflecting && hasShard) + SoundEngine.PlaySound(SoundID.DD2_EtherianPortalSpawnEnemy,player.Center); + return false; } - Item.damage = conDamage; + return base.Shoot(player, source, position, velocity, type, damage, knockback); + } + + public override bool AltFunctionUse(Player player) + { + return true; } } } diff --git a/Items/Weapons/Melee/MirrorBlade.png b/Items/Weapons/Melee/MirrorBlade.png index 5247456d75..3af0672f28 100644 Binary files a/Items/Weapons/Melee/MirrorBlade.png and b/Items/Weapons/Melee/MirrorBlade.png differ diff --git a/Items/Weapons/Melee/SeekingScorcher.cs b/Items/Weapons/Melee/SeekingScorcher.cs index b84e6481c7..f3fb9c7c19 100644 --- a/Items/Weapons/Melee/SeekingScorcher.cs +++ b/Items/Weapons/Melee/SeekingScorcher.cs @@ -21,7 +21,7 @@ namespace CalamityMod.Items.Weapons.Melee { Item.width = 86; Item.height = 64; - Item.damage = 718; + Item.damage = 1100; Item.DamageType = DamageClass.MeleeNoSpeed; Item.useAnimation = Item.useTime = 55; Item.knockBack = 8.5f; diff --git a/Items/Weapons/Melee/TerrorBlade.cs b/Items/Weapons/Melee/TerrorBlade.cs index e85ba3366f..4d786f1baf 100644 --- a/Items/Weapons/Melee/TerrorBlade.cs +++ b/Items/Weapons/Melee/TerrorBlade.cs @@ -1,4 +1,5 @@ -using CalamityMod.Projectiles.Melee; +using System.Collections.Generic; +using CalamityMod.Projectiles.Melee; using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -37,6 +38,16 @@ namespace CalamityMod.Items.Weapons.Melee { Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request("CalamityMod/Items/Weapons/Melee/TerrorBladeGlow").Value); } + public override void UpdateInventory(Player player) + { + if (Main.zenithWorld) + Item.SetNameOverride(this.GetLocalizedValue("GFBName")); + } + public override void ModifyTooltips(List tooltips) + { + string GFBflavour = this.GetLocalizedValue("GFB"); + tooltips.FindAndReplace("[STATUS]", Main.zenithWorld ? "\n" + GFBflavour : ""); + } public override void MeleeEffects(Player player, Rectangle hitbox) { diff --git a/Items/Weapons/Melee/Violence.cs b/Items/Weapons/Melee/Violence.cs index a4e12b4d79..1d0ded5ccb 100644 --- a/Items/Weapons/Melee/Violence.cs +++ b/Items/Weapons/Melee/Violence.cs @@ -19,7 +19,7 @@ namespace CalamityMod.Items.Weapons.Melee Item.noMelee = true; Item.useTurn = true; Item.noUseGraphic = true; - Item.useAnimation = 25; + Item.useAnimation = 60; Item.useTime = 25; Item.useStyle = ItemUseStyleID.Shoot; Item.knockBack = 9f; @@ -27,16 +27,28 @@ namespace CalamityMod.Items.Weapons.Melee Item.autoReuse = true; Item.value = CalamityGlobalItem.RarityVioletBuyPrice; Item.rare = ModContent.RarityType(); - Item.channel = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 15f; + Item.channel = true; } - public override bool CanUseItem(Player player) => player.altFunctionUse == 2 || player.ownedProjectileCounts[Item.shoot] <= 0; + public override bool AltFunctionUse(Player player) + { + return true; + } + + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { - Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, velocity.ToRotation()); + if (player.altFunctionUse == 2) + { + ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true; + player.itemAnimation = player.itemAnimationMax = player.itemTime = player.itemTimeMax = 60; + Projectile.NewProjectile(source, position, velocity*1.6666f, type, (int)(damage * 20), knockback, player.whoAmI, 0f, velocity.ToRotation(), 0); + } + else + Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, velocity.ToRotation(), 1); return false; } } diff --git a/Items/Weapons/Melee/WulfrumScrewdriver.cs b/Items/Weapons/Melee/WulfrumScrewdriver.cs index 74a3d5142f..2fc8fc039a 100644 --- a/Items/Weapons/Melee/WulfrumScrewdriver.cs +++ b/Items/Weapons/Melee/WulfrumScrewdriver.cs @@ -85,8 +85,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void AddRecipes() { CreateRecipe(). - AddIngredient(12). - AddIngredient(). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Ranged/BulletFilledShotgun.cs b/Items/Weapons/Ranged/BulletFilledShotgun.cs index 4bee81bf6d..eda730ce49 100644 --- a/Items/Weapons/Ranged/BulletFilledShotgun.cs +++ b/Items/Weapons/Ranged/BulletFilledShotgun.cs @@ -23,7 +23,7 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useAnimation = Item.useTime = 75; Item.knockBack = 0.25f; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 9f; + Item.shootSpeed = 18f; Item.useAmmo = AmmoID.Bullet; Item.UseSound = SoundID.Item38; @@ -47,7 +47,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { type = Item.shoot; - int bulletAmt = 30; + int bulletAmt = 40; for (int i = 0; i < bulletAmt; i++) { float newSpeedX = velocity.X + Main.rand.NextFloat(-15f, 15f); diff --git a/Items/Weapons/Ranged/FirestormCannon.cs b/Items/Weapons/Ranged/FirestormCannon.cs index 51ecdc5739..766db7e7b6 100644 --- a/Items/Weapons/Ranged/FirestormCannon.cs +++ b/Items/Weapons/Ranged/FirestormCannon.cs @@ -92,6 +92,7 @@ namespace CalamityMod.Items.Weapons.Ranged CreateRecipe(). AddIngredient(ItemID.FlareGun). AddIngredient(ItemID.HellstoneBar, 10). + AddIngredient(ItemID.IllegalGunParts). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Ranged/Starfleet.cs b/Items/Weapons/Ranged/Starfleet.cs index 1c00b9b89b..48e4980900 100644 --- a/Items/Weapons/Ranged/Starfleet.cs +++ b/Items/Weapons/Ranged/Starfleet.cs @@ -1,6 +1,7 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Ores; using CalamityMod.Projectiles.Ranged; +using CalamityMod.Rarities; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -23,8 +24,8 @@ namespace CalamityMod.Items.Weapons.Ranged Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 15f; - Item.value = CalamityGlobalItem.RarityPurpleBuyPrice; - Item.rare = ItemRarityID.Purple; + Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + Item.rare = ModContent.RarityType(); Item.UseSound = SoundID.Item92; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); diff --git a/Items/Weapons/Ranged/Toxibow.cs b/Items/Weapons/Ranged/Toxibow.cs index 51ad67d868..87580560b6 100644 --- a/Items/Weapons/Ranged/Toxibow.cs +++ b/Items/Weapons/Ranged/Toxibow.cs @@ -1,5 +1,6 @@ using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables; +using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Projectiles.Ranged; using Microsoft.Xna.Framework; using Terraria; @@ -45,8 +46,8 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(). - AddIngredient(15). + AddIngredient(15). + AddIngredient(12). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Ranged/WulfrumBlunderbuss.cs b/Items/Weapons/Ranged/WulfrumBlunderbuss.cs index 5b74101f5d..caa91297a0 100644 --- a/Items/Weapons/Ranged/WulfrumBlunderbuss.cs +++ b/Items/Weapons/Ranged/WulfrumBlunderbuss.cs @@ -185,7 +185,7 @@ namespace CalamityMod.Items.Weapons.Ranged public override void AddRecipes() { CreateRecipe(). - AddIngredient(9). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/BlazingStar.cs b/Items/Weapons/Rogue/BlazingStar.cs index 5f608b05d3..cd545b0e47 100644 --- a/Items/Weapons/Rogue/BlazingStar.cs +++ b/Items/Weapons/Rogue/BlazingStar.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.height = 1; Item.damage = 75; Item.DamageType = RogueDamageClass.Instance; + Item.autoReuse = true; Item.noMelee = true; Item.noUseGraphic = true; Item.useTime = 15; diff --git a/Items/Weapons/Rogue/CobaltKunai.cs b/Items/Weapons/Rogue/CobaltKunai.cs index 1fbc6ca7a2..68c8965605 100644 --- a/Items/Weapons/Rogue/CobaltKunai.cs +++ b/Items/Weapons/Rogue/CobaltKunai.cs @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.DamageType = RogueDamageClass.Instance; } - public override float StealthDamageMultiplier => 1.85f; + public override float StealthDamageMultiplier => 1.4f; public override float StealthVelocityMultiplier => 0.9f; public override float StealthKnockbackMultiplier => 0.5f; @@ -35,9 +35,9 @@ namespace CalamityMod.Items.Weapons.Rogue { if (player.Calamity().StealthStrikeAvailable()) { - for (int i = -1; i <= 1; i++) + for (float i = -1.5f; i <= 1.5f; i++) { - Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * 9f)); + Vector2 perturbedSpeed = velocity.RotatedBy(MathHelper.ToRadians(i * 7f)); int stealth = Projectile.NewProjectile(source, position, perturbedSpeed, ModContent.ProjectileType(), damage, knockback, player.whoAmI); if (stealth.WithinBounds(Main.maxProjectiles)) Main.projectile[stealth].Calamity().stealthStrike = true; diff --git a/Items/Weapons/Rogue/FishboneBoomerang.cs b/Items/Weapons/Rogue/FishboneBoomerang.cs index a6d0facb12..fac499e9df 100644 --- a/Items/Weapons/Rogue/FishboneBoomerang.cs +++ b/Items/Weapons/Rogue/FishboneBoomerang.cs @@ -19,9 +19,9 @@ namespace CalamityMod.Items.Weapons.Rogue Item.damage = 27; Item.noMelee = true; Item.noUseGraphic = true; - Item.useAnimation = 15; + Item.useAnimation = 30; Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 15; + Item.useTime = 30; Item.knockBack = 5.5f; Item.UseSound = null; Item.value = CalamityGlobalItem.RarityGreenBuyPrice; @@ -32,10 +32,7 @@ namespace CalamityMod.Items.Weapons.Rogue Item.autoReuse = true; } - public override bool CanUseItem(Player player) - { - return !Main.projectile.Any(n => n.active && n.owner == player.whoAmI && n.type == ModContent.ProjectileType()); - } + public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] < 3; public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { diff --git a/Items/Weapons/Rogue/InfernalKris.cs b/Items/Weapons/Rogue/InfernalKris.cs index eacb33e1bc..13ec831929 100644 --- a/Items/Weapons/Rogue/InfernalKris.cs +++ b/Items/Weapons/Rogue/InfernalKris.cs @@ -45,7 +45,7 @@ namespace CalamityMod.Items.Weapons.Rogue { CreateRecipe(). AddIngredient(ItemID.HellstoneBar, 10). - AddIngredient(ItemID.Obsidian, 9). + AddIngredient(ItemID.AshWood, 10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Rogue/SandDollar.cs b/Items/Weapons/Rogue/SandDollar.cs index f873ac1eba..cb65e3f227 100644 --- a/Items/Weapons/Rogue/SandDollar.cs +++ b/Items/Weapons/Rogue/SandDollar.cs @@ -14,12 +14,11 @@ namespace CalamityMod.Items.Weapons.Rogue { Item.width = 30; Item.height = 28; - Item.damage = 26; + Item.damage = 20; Item.DamageType = RogueDamageClass.Instance; Item.noMelee = true; Item.noUseGraphic = true; - Item.useTime = 15; - Item.useAnimation = 15; + Item.useTime = Item.useAnimation = 28; Item.useStyle = ItemUseStyleID.Swing; Item.knockBack = 3.5f; Item.autoReuse = true; @@ -27,34 +26,17 @@ namespace CalamityMod.Items.Weapons.Rogue Item.value = CalamityGlobalItem.RarityGreenBuyPrice; Item.rare = ItemRarityID.Green; Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 14f; - } - - public override bool CanUseItem(Player player) - { - if (player.ownedProjectileCounts[Item.shoot] >= 2 && !player.Calamity().StealthStrikeAvailable()) - { - return false; - } - else - { - return true; - } + Item.shootSpeed = 8f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.Calamity().StealthStrikeAvailable()) //setting the stealth strike { - int spread = 2; - for (int i = 0; i < 2; i++) - { - Vector2 perturbedspeed = new Vector2(velocity.X + Main.rand.Next(-2, 3), velocity.Y + Main.rand.Next(-2, 3)).RotatedBy(MathHelper.ToRadians(spread)); - int stealth = Projectile.NewProjectile(source, position.X, position.Y, perturbedspeed.X * 1.5f, perturbedspeed.Y * 1.5f, ModContent.ProjectileType(), damage, knockback, player.whoAmI); - if (stealth.WithinBounds(Main.maxProjectiles)) - Main.projectile[stealth].Calamity().stealthStrike = true; - spread -= Main.rand.Next(1, 3); - } + int stealth = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); + if (stealth.WithinBounds(Main.maxProjectiles)) + Main.projectile[stealth].Calamity().stealthStrike = true; + return false; } return true; diff --git a/Items/Weapons/Rogue/WulfrumKnife.cs b/Items/Weapons/Rogue/WulfrumKnife.cs index 57a97d0e19..440167f3fd 100644 --- a/Items/Weapons/Rogue/WulfrumKnife.cs +++ b/Items/Weapons/Rogue/WulfrumKnife.cs @@ -91,7 +91,7 @@ namespace CalamityMod.Items.Weapons.Rogue public override void AddRecipes() { CreateRecipe(). - AddIngredient(9). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } diff --git a/Items/Weapons/Summon/AresExoskeleton.cs b/Items/Weapons/Summon/AresExoskeleton.cs index 5b822be2c0..f3c3d7e3fc 100644 --- a/Items/Weapons/Summon/AresExoskeleton.cs +++ b/Items/Weapons/Summon/AresExoskeleton.cs @@ -86,6 +86,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.DamageType = DamageClass.Summon; } + public override bool? CanAutoReuseItem(Player player) => false; + public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { Texture2D texture = ModContent.Request("CalamityMod/Items/Weapons/Summon/AresExoskeleton").Value; diff --git a/Items/Weapons/Summon/FlamsteedRing.cs b/Items/Weapons/Summon/FlamsteedRing.cs index 9f7230b417..c9078ba8ce 100644 --- a/Items/Weapons/Summon/FlamsteedRing.cs +++ b/Items/Weapons/Summon/FlamsteedRing.cs @@ -67,6 +67,8 @@ namespace CalamityMod.Items.Weapons.Summon Item.Calamity().CannotBeEnchanted = true; } + public override bool? CanAutoReuseItem(Player player) => false; + public static bool SpaceForLargeMech(Player player, bool visuals = true) { bool sufficientSpace = true; diff --git a/Items/Weapons/Summon/WulfrumController.cs b/Items/Weapons/Summon/WulfrumController.cs index 8aae13745f..9dff85b70b 100644 --- a/Items/Weapons/Summon/WulfrumController.cs +++ b/Items/Weapons/Summon/WulfrumController.cs @@ -55,7 +55,7 @@ namespace CalamityMod.Items.Weapons.Summon public override void AddRecipes() { CreateRecipe(). - AddIngredient(9). + AddIngredient(10). AddTile(TileID.Anvils). Register(); } diff --git a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson index 83678e425a..44fffe4fd3 100644 --- a/Localization/en-US/Mods.CalamityMod.Bestiary.hjson +++ b/Localization/en-US/Mods.CalamityMod.Bestiary.hjson @@ -136,6 +136,7 @@ PrismBack: Far too slow and bulky to hunt normally, these turtles subsist on a d PrismaticGuppy: Is it a crystal? Is it a candy? No, it's a little Guppy! Thanks to the unique prismatic sheen of their scales and their striking geometric shapes, these fish can camouflage as Sea Prisms to escape pursuing predators. Probesnout: One of just a few known seahorse species who miraculously survived the Incineration. Its efficient snout allows it to streamline nutrients from the abundant sponge in the reefs that it lives in. SandProwler: These colorful sea serpents prowl through the sand, looking for the gleam of an unsuspecting Guppy to snack on. Due to this creature’s habit of mistakenly capturing dropped coins, Ilmerians fond of avarice began to share the namesake. +Scavenger: This odd species of crab migrated to Ilmeris after its fateful incineration. Gifted with a remarkable sense of ownership and value, they hoard any scavenged treasures as a display of social status. Trade is not a foreign concept to their tribe, and they value Pearls above all else. SeaFloaty: Flatworms can be found in many seas and oceans across the world, and are exceptional at fitting through cracks or crevices to find kelp due to their thin bodies. These particular flatworms are incredibly skittish, and thus fled with plenty of time to be spared from the infernal carnage. SeaMinnow: Large schools of Sea Minnows were one of the most beautiful things one could witness during the days when Ilmeris was unsundered. Though the kingdom's grandeur has been lost like ashes in the wind, the tranquil fish continue to swim at peace, a breathtaking reminder that not all was lost. Searslug: A distant cousin of the Slugbuns which can withstand the extreme heat of molten basalt. Their skin is scalding to the touch, a side effect of their adaptations to the many lava dips needed to squirm around the regions it lives in. diff --git a/Localization/en-US/Mods.CalamityMod.Biomes.hjson b/Localization/en-US/Mods.CalamityMod.Biomes.hjson index fe35c7b3ef..85d0d89c43 100644 --- a/Localization/en-US/Mods.CalamityMod.Biomes.hjson +++ b/Localization/en-US/Mods.CalamityMod.Biomes.hjson @@ -72,7 +72,7 @@ SunkenSeaBiome: { } AstralUnderground: { - DisplayName: Astral Underground + DisplayName: Underground Astral TownNPCDialogueName: Underground Astral Infection } diff --git a/Localization/en-US/Mods.CalamityMod.Configs.hjson b/Localization/en-US/Mods.CalamityMod.Configs.hjson index c086e50426..e1ae0e199d 100644 --- a/Localization/en-US/Mods.CalamityMod.Configs.hjson +++ b/Localization/en-US/Mods.CalamityMod.Configs.hjson @@ -347,6 +347,16 @@ CalamityClientConfig: { ''' } + SunkenSeaBackgroundDistortion: { + Label: "[i:CalamityMod/SeaRemains] Sunken Sea Background Distortion" + Tooltip: + ''' + Whether or not the Sunken Sea's custom backgrounds should have an additional distortion shader applied to them to give the + illusion of underwater distortion. + [c/FF232C:Note that this will ONLY work if your "Wave Quality" setting is turned off.] + ''' + } + VanillaCooldownDisplay: { Label: "[i:HealingPotion] Display Vanilla Cooldowns" Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 60db5438ab..5525cb5e24 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -284,12 +284,25 @@ Baroclaw: { ''' } +BatholithBangle: { + DisplayName: Batholith Bangle + Tooltip: + ''' + Magic enemy hits create a powerful granite flash that always critically strikes + This effect has a 10 second cooldown, but is halved if the flash kills an enemy + Visual and audio effects are reduced if visibility is disabled + [c/0189D7:'The solid granite radiates energy throughout your body'] + ''' +} + BlackGlassBand: { DisplayName: Black Glass Band Tooltip: ''' - Enemy hits create an obsidian blast that always critically strikes - This effect has a 7 second cooldown, but is halved if the blast kills an enemy + Enemy hits create an obsidian flash that always critically strikes + This effect has a 5 second cooldown, but is halved if the flash kills an enemy + Visual and audio effects are reduced if visibility is disabled + [c/655DC5:'A shining band with boundless potential'] ''' } @@ -297,6 +310,7 @@ BlazingCore: { DisplayName: Blazing Core Tooltip: ''' + Grants immunity to knockback The searing core of the Profaned Goddess Pressing [KEY] will activate a parry, encasing you in luminous profaned crystal Being hit shortly after encasement will shatter the crystal @@ -311,6 +325,7 @@ BloodflareCore: { DisplayName: Bloodflare Core Tooltip: ''' + Grants immunity to knockback Recovering defense damage heals you, each defense recovered gives 1 HP Taking damage converts at least half of your total defense in defense damage ''' @@ -345,11 +360,10 @@ BloomStone: { DisplayName: Bloom Stone Tooltip: ''' - Grants between +1 HP/s and +3 HP/s life regen depending on time of day - Accelerates life regen based on time of day - Both of these effects are maximized from noon to sunset - Flowers grow on the grass you walk on - Random dye plants will grow while standing on grassless dirt + Healing Potions are 50% more effective, but provide their healing over time + Grappling hooks retract and pull the player 50% faster, and grow a flower at hookpoints + Touching a flower makes it burst into pollen which gives a temporary 6% damage reduction boost + The damage reduction boost increases to 12% while receiving healing over time 'One of the ancient relics' ''' } @@ -532,6 +546,7 @@ DarkSunRing: { DisplayName: Dark Sun Ring Tooltip: ''' + Grants immunity to knockback 12% increased damage +0.5 HP/s life regen and +2 max minions Increased minion knockback @@ -600,6 +615,7 @@ DraedonsHeart: { Tooltip: ''' {0}% reduced contact damage from enemies + Grants immunity to knockback [NANODESC] With full Nanomachines, press [KEY] to heal {1} health over {2} {^2:second;seconds} While healing, you take [DR]% less damage @@ -769,6 +785,7 @@ FlameLickedShell: { DisplayName: Flame-Licked Shell Tooltip: ''' + Grants immunity to knockback Pressing [KEY] will activate a parry, encasing you in rocks Being hit shortly after encasement will implode the rocks Upon implosion, a ring of brimstone hellfire is launched outwards and you receive 90% DR for that hit @@ -1232,6 +1249,7 @@ OldDukeScales: { DisplayName: Old Duke's Scales Tooltip: ''' + Grants immunity to knockback 10% increased damage reduction, max movement speed, and acceleration 25% increased dash velocity and length Adds a stamina tracker to the cooldown rack @@ -1362,6 +1380,17 @@ ProfanedSoulCrystal: { ''' } +ProtolithBangle: { + DisplayName: Protolith Bangle + Tooltip: + ''' + Ranged enemy hits create a marble flash that always critically strikes and can hit multiple enemies + This effect has a 7 second cooldown, but is halved if the flash kills the first enemy it hits + Visual and audio effects are reduced if visibility is disabled + [c/C5B965:'The cold marble against your wrist puts your mind at ease'] + ''' +} + QuiverofNihility: { DisplayName: Quiver of Nihility Tooltip: @@ -1621,8 +1650,9 @@ SlagsplitterPauldron: { DisplayName: Slagsplitter Pauldron Tooltip: ''' - You gain 10% damage reduction while dashing, and enemies are inflicted with Armor Crunch - Your dashes are empowered by fire, shredding enemies near you with violent explosions + Your dashes become empowered by flame, erupting on contact with enemies + Grants immunity to knockback and 10% damage reduction while dashing + Enemies hit by your dashes have their armor crushed Visual effects are reduced if visibility is disabled ''' } @@ -1762,8 +1792,8 @@ StatMeter: { AttackSpeed: Attack Speed: {0}% WhipMeleeInheritance: " [{0}% from melee]" // Class stats - RangedStats: Ammo Consumption Chance: {0} - MagicStats: Mana Usage: {0}% | Mana Regen: {1} + AmmoStats: Ammo Consumption Chance: {0}% + ManaStats: Mana Usage: {0}% | Mana Regen: {1} SummonStats: Minion Slots: {0} | Sentry Slots: {1} WhipStats: Whip Range: {0}% RogueStats: @@ -1868,7 +1898,7 @@ TheCamper: { DisplayName: The Camper Tooltip: ''' - You deal 90% less damage unless stationary + You deal 50% less damage unless stationary Standing still grants buffs depending on held item, and creates a damaging aura around you While moving, you regenerate health as if standing still {$Common.AbyssLightLevel1} @@ -1918,6 +1948,7 @@ TheSponge: { DisplayName: The Sponge Tooltip: ''' + Grants immunity to knockback Gain a barrier with 180 health The barrier grants 20 defense and 10% damage reduction while active [ADREN] @@ -2066,6 +2097,7 @@ WulfrumAcrobaticsPack: { ''' Provides a wulfrum slingshot grappling hook This slingshot's stats scale with your equipped hook + If the hook has special effects, the slingshot also benefits from them The slingshot allows for advanced rope-swinging physics Hold UP or DOWN to retract or extend the slingshot's rope Automatically grapples nearby walls if a lethal fall is detected @@ -2089,6 +2121,7 @@ YharimsGift: { DisplayName: Yharim's Gift Tooltip: ''' + Grants immunity to knockback Flaming meteors rain down after getting hit Volatile dragon dust trails behind you Increases damage and movement speed by 15% diff --git a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson index 91905b3659..08fb1ba71e 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Armor.Hardmode.hjson @@ -481,7 +481,7 @@ ReaverHeadMobility: { ''' Grants immunity to fall damage and allows constant jumping 10% increased flight time and horizontal wing speed - Hooks fly out and retract 10% faster + Hooks fly out and retract 50% faster Reduces the cooldown of dashes ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson index 5f816345ed..36c98c064f 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Melee.hjson @@ -793,7 +793,11 @@ Lacerator: { Tooltip: ''' {$Common.YoyoStatsInfinite} - Accelerates natural life regeneration on hits with the yoyo + Striking enemies conjures a bloody saw to shred them + The saw does more damage the more often the yoyo hits, and fades away when not striking enemies + Enemies touching the edge of the sawblade get blood orbs torn out of them + Picking up these blood orbs reduces the duration of [Potion Sickness] + The direction of the saw's spin depends on which direction you originally threw the yoyo [GFB] ''' TooltipNormal: Someone thought this was a viable weapon against DoG at one point lol @@ -848,8 +852,12 @@ MirrorBlade: { DisplayName: Mirror Blade Tooltip: ''' - The amount of contact damage an enemy does is added to this weapons' damage - You must hit an enemy with the blade to trigger this effect + Striking an enemy or a hostile projectile spawns mirror shards + You can have up to 10 mirror shards at once, and excess shards are launched at enemies + to form your shards into a mirror shield + Each shard redues the damage of a projectile that hit the shield by 10% + The shield shatters after one projectile, launching the shards at enemies with increasd damage + With all 10 shards, you gain a brief period of invulnerability when shattering the shield ''' } @@ -1286,11 +1294,13 @@ Terratomere: { TerrorBlade: { DisplayName: Terror Blade + GFBName: TERROR BLADD4 Tooltip: ''' Fires a terror beam that bounces off tiles - On every bounce it emits an explosion + On every bounce it emits an explosion[STATUS] ''' + GFB: "'Ignore my spelling.'" } TheBurningSky: { @@ -1461,7 +1471,12 @@ UltimusCleaver: { UrchinMace: { DisplayName: Urchin Mace - Tooltip: Throws out a whirlpool when released + Tooltip: + ''' + Throws out a whirlpool when released + [c/5C95A1:'The people of the sea were adept hunters, but they abhorred unnecessary violence.] + [c/5C95A1:Unfortunately, neighboring nations were brutish, so they fashioned their tools for war.'] + ''' } VanishingPoint: { @@ -1480,7 +1495,12 @@ VeinBurster: { Violence: { DisplayName: Violence - Tooltip: Releases a blazing fork which stays near the mouse and shreds enemies + Tooltip: + ''' + A demonic pitchfork, cursed to cause endless bloodshed + commands the trident to follow your cursor and shred enemies with devastating speed + throws the trident, violently tearing through enemies with immense power and inflicting Vulnerability Hex + ''' } Virulence: { diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson index 7eb72efa6d..1350fd856a 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Ranged.hjson @@ -232,6 +232,7 @@ BulletFilledShotgun: { Tooltip: ''' Fires a massive spread of bouncing bullets + Bullets attempt to bounce towards enemies after bouncing twice Consumes five bullets per-use 'Aim? What's that?' ''' diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 5705ad96cd..7274743e98 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -137,7 +137,7 @@ Cinquedea: { CobaltKunai: { DisplayName: Cobalt Kunai - Tooltip: Stealth strikes fire three homing cobalt energy bolts + Tooltip: Stealth strikes fire four homing cobalt energy bolts } ConsecratedWater: { @@ -948,8 +948,9 @@ SandDollar: { DisplayName: Sand Dollar Tooltip: ''' - Throws up to 2 returning sand dollars - Stealth strikes throw 2 long ranged sand dollars that explode into coral shards on enemy hits + Throws gliding sand dollars which can pierce enemies or bounce off floors + After bouncing, sand dollars lose their pierce but split into damaging shards on impact + Stealth strikes linger in place after bouncing, creating a small sandstorm around them ''' } diff --git a/Localization/en-US/Mods.CalamityMod.Misc.hjson b/Localization/en-US/Mods.CalamityMod.Misc.hjson index 0f5d537a95..95cd1221f7 100644 --- a/Localization/en-US/Mods.CalamityMod.Misc.hjson +++ b/Localization/en-US/Mods.CalamityMod.Misc.hjson @@ -1,21 +1,22 @@ -// Recipe Groups +# Recipe Groups +# {$LegacyMisc.37} is the vanilla localization used in recipe groups, that reads "Any" in English. RecipeGroup: { - HardmodeAnvil: Any Hardmode Anvil - HardmodeForge: Any Hardmode Forge - AnyLargeGem: Any Large Gem - AnyFood: Any Food Item - AnyEvilBar: Any Evil Bar - AnyEvilPowder: Any Evil Powder + HardmodeAnvil: "{$LegacyMisc.37} Hardmode Anvil" + HardmodeForge: "{$LegacyMisc.37} Hardmode Forge" + AnyLargeGem: "{$LegacyMisc.37} Large Gem" + AnyFood: "{$LegacyMisc.37} Food Item" + AnyEvilBar: "{$LegacyMisc.37} Evil Bar" + AnyEvilPowder: "{$LegacyMisc.37} Evil Powder" Boss2Material: Shadow Scale or Tissue Sample CursedFlameIchor: Cursed Flame or Ichor - AnyEvilWater: Any Evil Water - AnyEvilFlask: Any Evil Flask - AnyEvilBlock: Any Evil Block - AnyGoodBlock: Any Good Block - LunarPickaxe: Any Lunar Pickaxe - LunarHamaxe: Any Lunar Hamaxe - AnyQuiver: Any Quiver - AnyWings: Any Wings + AnyEvilWater: "{$LegacyMisc.37} Evil Water" + AnyEvilFlask: "{$LegacyMisc.37} Evil Flask" + AnyEvilBlock: "{$LegacyMisc.37} Evil Block" + AnyGoodBlock: "{$LegacyMisc.37} Good Block" + LunarPickaxe: "{$LegacyMisc.37} Lunar Pickaxe" + LunarHamaxe: "{$LegacyMisc.37} Lunar Hamaxe" + AnyQuiver: "{$LegacyMisc.37} Quiver" + AnyWings: "{$LegacyMisc.37} Wings" } // Status diff --git a/Localization/en-US/Mods.CalamityMod.NPCs.hjson b/Localization/en-US/Mods.CalamityMod.NPCs.hjson index f376f08317..906f6e26e7 100644 --- a/Localization/en-US/Mods.CalamityMod.NPCs.hjson +++ b/Localization/en-US/Mods.CalamityMod.NPCs.hjson @@ -305,6 +305,7 @@ RadiantPrismaticGuppy: Radiant Prismatic Guppy RadiantSlugbun: Radiant Slugbun SandProwler.DisplayName: Sand Prowler SandProwlerNested.DisplayName: Sand Prowler +Scavenger.DisplayName: Scavenger SeaFloaty.DisplayName: Sea Floaty SeaMinnow.DisplayName: Sea Minnow SeaMinnowGold.DisplayName: Gold Sea Minnow diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson index 29e9cdd627..58bcdbcfba 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Melee.hjson @@ -305,3 +305,4 @@ WulfrumScrewdriverProj.DisplayName: Wulfrum Screwdriver YinYoDark.DisplayName: Dark Shard YinYoLight.DisplayName: Light Shard MutilatorSwordProj.DisplayName: The Mutilator +MirrorBladeProjectile.DisplayName: Mirror Blade diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson index 97efe5b804..f1b18a5670 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Ranged.hjson @@ -206,7 +206,6 @@ SicknessRound.DisplayName: Round SicknessRound2.DisplayName: Round SlagRound.DisplayName: Slag Round SlimeBolt.DisplayName: Slime Bolt -SmallCoral.DisplayName: Small Coral SparkSpreaderFire.DisplayName: Sparked Flames SpeedBlasterShot.DisplayName: Splatter Shot SporeBomb.DisplayName: Spore Bomb diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index 1e0746c5cd..5328e2d17b 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -207,6 +207,8 @@ ProfanedPartisanSpear.DisplayName: Profaned Spear RadiantExplosion.DisplayName: Radiant Explosion RadiantStar2.DisplayName: Radiant Star RadiantStarKnife.DisplayName: Radiant Star +RadiationBurst.DisplayName: Radiation Burst +RadiationRain.DisplayName: Radiation Rain RealityRuptureLance.DisplayName: Lance of Reality RealityRuptureMini.DisplayName: Reality Shard RealityRuptureStealth.DisplayName: Ruptured Reality @@ -214,14 +216,17 @@ ReaperProjectile.DisplayName: The Old Reaper ReboundingRainbowProj.DisplayName: Rebounding Rainbow ReboundingRainbowSplit.DisplayName: Rebounding Rainbow RefractionRotorProjectile.DisplayName: Prism Shuriken +RefractionRotorSlashCreator.DisplayName: Refraction Rotor Slash Creator +RefractionSlash.DisplayName: Refraction Slash RegulusEnergy.DisplayName: Regulus Energy RegulusRiotProj.DisplayName: Regulus Riot RotBallProjectile.DisplayName: Rot Ball SacrificeProjectile.DisplayName: Sacrificial Dagger SamsaraSlicerProjectile.DisplayName: Samsara Slicer SamsaraSlicerSmallDisk.DisplayName: Samsara Slicer +SandDollarFrag.DisplayName: Sand Dollar Frag SandDollarProj.DisplayName: Sand Dollar -SandDollarStealth.DisplayName: Sand Dollar +SandDollarStealth.DisplayName: Sand Dollar Duststorm ScarletBlast.DisplayName: Scarlet Blast ScarletDevilBullet.DisplayName: Gungnir Bullet ScarletDevilProjectile.DisplayName: Spear the Gungnir @@ -263,6 +268,8 @@ SphereBladed.DisplayName: Bladed Sphere SphereBlue.DisplayName: Blue Thruster Sphere SphereSpiked.DisplayName: Spiked Sphere SphereYellow.DisplayName: Yellow Thruster Sphere +SporeKnifeBud.DisplayName: Spore Knife Bud +SporeKnifeProj.DisplayName: Spore Knife StealthNimbus.DisplayName: Nimbus StealthNimbusCloud.DisplayName: Nimbus StealthRain.DisplayName: Rain @@ -315,9 +322,3 @@ WrathwingCinder.DisplayName: Wrathwing Eruption WrathwingFireball.DisplayName: Wrathwing Fireball WrathwingSpear.DisplayName: Wrathwing WulfrumKnifeProj.DisplayName: Wulfrum Knife -RadiationBurst.DisplayName: Radiation Burst -RadiationRain.DisplayName: Radiation Rain -RefractionRotorSlashCreator.DisplayName: Refraction Rotor Slash Creator -RefractionSlash.DisplayName: Refraction Slash -SporeKnifeProj.DisplayName: Spore Knife -SporeKnifeBud.DisplayName: Spore Knife Bud diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 943d8902cc..ec59c3406c 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -23,6 +23,7 @@ BlazingSun2.DisplayName: Blazing Sun BlissfulBombardierDustProjectile.DisplayName: Dust BloodBomb.DisplayName: Bomb BloodBombExplosion.DisplayName: Explosion +BloomStoneFlower.DisplayName: Bloom Stone Flower BlunderBoosterAura.DisplayName: Red Lightning Aura BobbitHead.DisplayName: Bobbit Head BossRushEffectThing.DisplayName: Boss Rush Effect Thing @@ -105,6 +106,7 @@ PauldronExplosion.DisplayName: Pauldron Explosion PearlAuraShard.DisplayName: Prism Shard PlaguePulse.DisplayName: Plague Pulse PoisonousSeawater.DisplayName: Seawater +ProtolithBangleProjectile.DisplayName: Marble Shatter PscTransformAnimation.DisplayName: Psc Transform Animation PscTransformRocks.DisplayName: Psc Transform Rocks PuddleSplash.DisplayName: Puddle Splash @@ -158,3 +160,4 @@ YellowLabSeeker.DisplayName: Seeking Mechanism VoidofExtinctionCrit.DisplayName: Void of Extinction Crit XykDeathAnim.DisplayName: Xyk Death Animation XykWings.DisplayName: Xyk Wings +BatholithBangleProjectile.DisplayName: Batholith Bangle Projectile diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index f08117bbfe..0691f76312 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -94,6 +94,7 @@ Cooldowns: { FleshTotem: Contact Damage Halving Cooldown FuryFuel: Crystal Powder GaelsRage: Gael's Greatsword Rage Cooldown + BandCooldown: Band Cooldown GlobalDodge: Dodge Cooldown GodSlayerDash: God Slayer Dash Cooldown HellbornShots: Hellborn Shots @@ -589,8 +590,11 @@ Lecherous: { Disenchant: Disenchant // Worldgen Tasks -BetterUnderworld: Creating a smoother underworld -AshIslandLavaRemoval: Removing lava from ash island +BetterUnderworld: Creating a smoother Underworld +UnderworldStructures: Remnants of an Azafurian and Demonic war +UnderworldPillars: Constructing Underworld pillars +UnderworldTreesAndGrass: Growing Underworld flora +UnderworldGeyserTraps: Adding an Underworld minefield EvilIslandCorrupt: Adding a putrid floating island EvilIslandCrimson: Adding a grotesque floating island AstralChest: Placing an astral chest diff --git a/NPCs/AstrumAureus/AstrumAureus.cs b/NPCs/AstrumAureus/AstrumAureus.cs index 0055865a5b..ab27b1d31a 100644 --- a/NPCs/AstrumAureus/AstrumAureus.cs +++ b/NPCs/AstrumAureus/AstrumAureus.cs @@ -1,4 +1,5 @@ -using System.IO; +using System.Collections.Generic; +using System.IO; using System.Threading; using CalamityMod.BiomeManagers; using CalamityMod.Buffs.DamageOverTime; @@ -413,7 +414,8 @@ namespace CalamityMod.NPCs.AstrumAureus // Relic npcLoot.DefineConditionalDropSet(DropHelper.RevAndMaster).Add(ModContent.ItemType()); - // GFB Crab Banner drop + // GFB troll drops: Crab Banners and a random item which uses Luminite Bars + // Luminite Bar item drop is handled in a separate mod system var GFBOnly = npcLoot.DefineConditionalDropSet(DropHelper.GFB); { GFBOnly.Add(DropHelper.PerPlayer(ItemID.CrabBanner, 1, 1, 9999), true); @@ -584,4 +586,25 @@ namespace CalamityMod.NPCs.AstrumAureus target.AddBuff(ModContent.BuffType(), 360); } } + + // This ModSystem is used to allow Aureus to drop a random item which uses Luminite Bars in its recipe in Get fixed boi. + // This cannot be placed in ModifyNPCLoot, because ModifyNPCLoot is run before modded recipes are initialized. Thus, placing it there would only drop vanilla items. + // As a funny side effect, this also allows for dropping items from other mods which use Luminite Bars in their recipes. + public class AddAureusGFBDrop : ModSystem + { + public override void PostSetupRecipes() + { + // Iterate through all recipes, and list the items which use Luminite Bars in their recipes. + List luminiteStuff = []; + for (int i = 0; i < Main.recipe.Length; i++) + { + if (Main.recipe[i].ContainsIngredient(ItemID.LunarBar) && !luminiteStuff.Contains(Main.recipe[i].createItem.type)) + luminiteStuff.Add(Main.recipe[i].createItem.type); + } + // Define the conditional for GFB. + LeadingConditionRule GFBOnly = new LeadingConditionRule(DropHelper.GFB); + GFBOnly.OnSuccess(ItemDropRule.OneFromOptionsNotScalingWithLuck(1, luminiteStuff.ToArray())); + Main.ItemDropsDB.RegisterToNPCNetId(ModContent.NPCType(), GFBOnly); + } + } } diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 3272ef8c44..bc5a595419 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -6468,7 +6468,7 @@ namespace CalamityMod.NPCs { CalamityPlayer modPlayer = player.Calamity(); if (modPlayer.camper && !player.StandingStill()) - modifiers.SourceDamage *= 0.1f; + modifiers.SourceDamage *= 0.5f; if (IsArmored()) //Hide combat text so we can draw our own for armored NPCs { @@ -6479,9 +6479,9 @@ namespace CalamityMod.NPCs if (EaterOfWorldsIDList.Includes(npc.type) || npc.type == NPCID.Creeper || PerforatorWormIDList.Includes(npc.type) || AquaticScourgeIDList.Includes(npc.type) || DestroyerIDList.Includes(npc.type) || AstrumDeusIDList.Includes(npc.type) || StormWeaverIDList.Includes(npc.type) || ThanatosIDList.Includes(npc.type) || npc.type == NPCType() || - npc.type == NPCType() || npc.type == NPCType()) + npc.type == NPCType() || npc.type == NPCType() || npc.type == NPCType()) { - float damageMult = ThanatosIDList.Includes(npc.type) ? 0.35f : 0.5f; + float damageMult = ThanatosIDList.Includes(npc.type) ? 0.35f : npc.type == NPCType() ? 0.8f : 0.5f; if (item.CountsAsClass() && item.type != ItemType()) modifiers.SourceDamage *= damageMult; } @@ -6631,7 +6631,7 @@ namespace CalamityMod.NPCs // True Vulnerability Hex causes enemies to take 1.15x damage, 2.5x from Calamity itself if (trueVulnerabilityHex > 0) - modifiers.SourceDamage *= (projectile.type == ProjectileType() && projectile.ai[1] == 1f) ? 2.5f : 1.15f; + modifiers.SourceDamage *= (projectile.type == ProjectileType() && projectile.ai[1] == 255f) ? 2.5f : 1.15f; } // Any weapons that shoot projectiles from anywhere other than the player's center aren't affected by point-blank shot damage boost. @@ -6664,7 +6664,7 @@ namespace CalamityMod.NPCs } if (modPlayer.camper && !player.StandingStill()) - modifiers.SourceDamage *= 0.1f; + modifiers.SourceDamage *= 0.5f; if ((projectile.minion || ProjectileID.Sets.MinionShot[projectile.type] || projectile.sentry || ProjectileID.Sets.SentryShot[projectile.type]) && (player.ownedProjectileCounts[ProjectileType()] > 0 || player.ownedProjectileCounts[ProjectileType()] > 0 || (player.Calamity().rOfResilienceCooldown == 0 && player.HeldItem.type == ItemType()))) modifiers.SourceDamage *= 0.1f; @@ -7405,8 +7405,8 @@ namespace CalamityMod.NPCs DeerclopsAI.hasTargetBeenInRange = false; DeerclopsAI.borderDelay = 7f * 60f; DeerclopsAI.borderScalar = 0f; - DeerclopsAI.innerBorder = DeerclopsAI.maxDRIncreaseDistance * 5f; - DeerclopsAI.outerBorder = DeerclopsAI.maxDRIncreaseDistance * 5f; + DeerclopsAI.innerBorder = DeerclopsAI.MaxDRIncreaseDistance * 5f; + DeerclopsAI.outerBorder = DeerclopsAI.MaxDRIncreaseDistance * 5f; } // Despawn Blazing Wheels and Spike Balls when a boss spawns so they're not annoying and stay in the arena diff --git a/NPCs/CalamityGlobalTownNPC.cs b/NPCs/CalamityGlobalTownNPC.cs index 2058a665ac..c50caa0208 100644 --- a/NPCs/CalamityGlobalTownNPC.cs +++ b/NPCs/CalamityGlobalTownNPC.cs @@ -216,6 +216,7 @@ namespace CalamityMod.NPCs "Faith", // <@!509050283871961123> (toasty1007) "Xsiana", // <@!625780237489143839> (lokistic) "Lain", // <@!655201622863118337> (literallyadeerfr) + "Hamis", // <@!608455754093035521> (haefer) }; private static readonly string[] TavernkeepNames = { diff --git a/NPCs/DesertScourge/DesertNuisanceHead.cs b/NPCs/DesertScourge/DesertNuisanceHead.cs index fbb606fc63..b12922cb56 100644 --- a/NPCs/DesertScourge/DesertNuisanceHead.cs +++ b/NPCs/DesertScourge/DesertNuisanceHead.cs @@ -319,7 +319,7 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.velocity.Y += 0.15f; + NPC.velocity.Y += (death ? 0.125f : 0.1f); if (NPC.velocity.Y > 0f && Math.Abs(NPC.Center.Y - Main.player[NPC.target].Center.Y) > 180f) NPC.velocity.Y += 0.05f; diff --git a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs index 814c36893e..69bd6158db 100644 --- a/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs +++ b/NPCs/DesertScourge/DesertNuisanceHeadYoung.cs @@ -363,7 +363,7 @@ namespace CalamityMod.NPCs.DesertScourge if (!shouldFly) { - NPC.velocity.Y += 0.15f; + NPC.velocity.Y += 0.1f; if (NPC.velocity.Y > maxChaseSpeed) NPC.velocity.Y = maxChaseSpeed; diff --git a/NPCs/DesertScourge/DesertScourgeHead.cs b/NPCs/DesertScourge/DesertScourgeHead.cs index 09e689fb5f..3659112078 100644 --- a/NPCs/DesertScourge/DesertScourgeHead.cs +++ b/NPCs/DesertScourge/DesertScourgeHead.cs @@ -662,7 +662,7 @@ namespace CalamityMod.NPCs.DesertScourge } else if (!shouldFly) { - NPC.velocity.Y += 0.15f; + NPC.velocity.Y += (death ? 0.125f : 0.1f); if (NPC.Center.Y - player.Center.Y < -180f) { NPC.velocity.Y += 0.05f; diff --git a/NPCs/HiveMind/HiveMind.cs b/NPCs/HiveMind/HiveMind.cs index 191cabdc62..8e18fc78ad 100644 --- a/NPCs/HiveMind/HiveMind.cs +++ b/NPCs/HiveMind/HiveMind.cs @@ -385,17 +385,19 @@ namespace CalamityMod.NPCs.HiveMind switch (choice) { case 0: + type = !NPC.AnyNPCs(NPCID.EaterofSouls) ? NPCID.EaterofSouls : 0; + break; + case 1: - type = NPC.CountNPCS(NPCID.EaterofSouls) < 2 ? NPCID.EaterofSouls : 0; + type = !NPC.AnyNPCs(NPCID.DevourerHead) ? NPCID.DevourerHead : 0; break; case 2: - type = NPC.CountNPCS(NPCID.DevourerHead) < 2 ? NPCID.DevourerHead : 0; + type = !NPC.AnyNPCs(ModContent.NPCType()) ? ModContent.NPCType() : 0; break; case 3: - case 4: - type = NPC.CountNPCS(ModContent.NPCType()) < 2 ? ModContent.NPCType() : 0; + type = (!NPC.AnyNPCs(NPCID.Corruptor) && death) ? NPCID.Corruptor : 0; break; default: @@ -629,7 +631,7 @@ namespace CalamityMod.NPCs.HiveMind if (Main.netMode != NetmodeID.MultiplayerClient) { - int maxSpawns = bossRush ? 10 : death ? 5 : revenge ? 4 : expertMode ? Main.rand.Next(3, 5) : Main.rand.Next(2, 4); + int maxSpawns = bossRush ? 16 : death ? 8 : revenge ? 6 : expertMode ? Main.rand.Next(4, 6) : Main.rand.Next(3, 5); int maxDankSpawns = bossRush ? 4 : death ? Main.rand.Next(2, 4) : revenge ? 2 : expertMode ? Main.rand.Next(1, 3) : 1; for (int i = 0; i < maxSpawns; i++) @@ -1115,13 +1117,6 @@ namespace CalamityMod.NPCs.HiveMind { phase2timer = 0; NPC.ai[0] += 1f; - if (Main.netMode != NetmodeID.MultiplayerClient && Collision.CanHit(NPC.Center, 1, 1, player.position, player.width, player.height)) - { - int maxEaters = revenge ? 3 : 2; - if (NPC.CountNPCS(NPCID.EaterofSouls) < maxEaters && NPC.Distance(Main.player[NPC.target].Center) > 80f) - NPC.NewNPC(NPC.GetSource_FromAI(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.EaterofSouls); - } - if (NPC.ai[0] == 6f) { NPC.velocity = NPC.velocity.RotatedBy(MathHelper.Pi / arcTime * -rotationDirection); @@ -1362,19 +1357,20 @@ namespace CalamityMod.NPCs.HiveMind { if (Main.netMode != NetmodeID.MultiplayerClient) { - if (Main.rand.NextBool(30)) + if (Main.rand.NextBool(15)) { - if (NPC.CountNPCS(NPCID.EaterofSouls) < 3) + int hiveBlobCount = NPC.CountNPCS(ModContent.NPCType()) + NPC.CountNPCS(ModContent.NPCType()); + if (hiveBlobCount < 3) NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, Main.rand.NextBool() ? ModContent.NPCType() : ModContent.NPCType()); } - if (Main.rand.NextBool(60)) + if (Main.rand.NextBool(30)) { if (NPC.CountNPCS(NPCID.EaterofSouls) < 2) NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.EaterofSouls); } - if (Main.rand.NextBool(150)) + if (Main.rand.NextBool(45)) { if (!NPC.AnyNPCs(NPCID.DevourerHead)) NPC.NewNPC(NPC.GetSource_FromThis(), (int)NPC.Center.X, (int)NPC.Center.Y, NPCID.DevourerHead); diff --git a/NPCs/Perforator/PerforatorHeadLarge.cs b/NPCs/Perforator/PerforatorHeadLarge.cs index d829991d28..600cdb43e7 100644 --- a/NPCs/Perforator/PerforatorHeadLarge.cs +++ b/NPCs/Perforator/PerforatorHeadLarge.cs @@ -171,31 +171,39 @@ namespace CalamityMod.NPCs.Perforator // Spit attack in Rev // Spit ichor blobs in Death - float spitDistance = 800f; - float tooCloseToSpitDistance = 160f; - bool canSpit = (NPC.Distance(player.Center) <= spitDistance && NPC.Distance(player.Center) > tooCloseToSpitDistance && - (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation() && - Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) || NPC.Calamity().newAI[1] == 1f; + float spitDistance = 960f; + float tooCloseToSpitDistance = 320f; + bool isInRangeToSpit = NPC.Distance(player.Center) <= spitDistance && NPC.Distance(player.Center) > tooCloseToSpitDistance; + bool headIsTurnedTowardsTarget = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY).ToRotation().AngleTowards(NPC.velocity.ToRotation(), MathHelper.PiOver4) == NPC.velocity.ToRotation(); + bool canHitTarget = Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + bool alwaysAbleToSpit = NPC.Calamity().newAI[1] == 1f; + bool canSpit = (isInRangeToSpit && headIsTurnedTowardsTarget && canHitTarget) || alwaysAbleToSpit; if (canSpit) { - NPC.Calamity().newAI[0] += 1f; - float spitGateValue = 180f; - bool spit = NPC.Calamity().newAI[0] >= spitGateValue; + float spitGateValue = 120f; + if (NPC.Calamity().newAI[0] < spitGateValue) + NPC.Calamity().newAI[0] += 1f; + + // Only spit if all the conditions are met, in order to make the attack actually dangerous + bool spit = NPC.Calamity().newAI[0] >= spitGateValue && isInRangeToSpit && headIsTurnedTowardsTarget && canHitTarget; + + // Telegraph for half a second, or for however long it takes for the spit conditions to be met float telegraphSpitGateValue = spitGateValue - 30f; bool telegraphSpit = NPC.Calamity().newAI[0] >= telegraphSpitGateValue; + + // Spit from the mouth hole thing...yeah Vector2 spitLocation = NPC.Center + NPC.velocity.SafeNormalize(Vector2.UnitY) * 20f; if (telegraphSpit) { NPC.Calamity().newAI[1] = 1f; - Vector2 dustVelocity = spitLocation - spitLocation; int dustType = Main.rand.NextBool() ? DustID.Ichor : DustID.Blood; for (int k = 0; k < 10; k++) { - int dust = Dust.NewDust(spitLocation, 0, 0, dustType); + int dust = Dust.NewDust(spitLocation, 1, 1, dustType); Main.dust[dust].position = spitLocation + Main.rand.NextVector2CircularEdge(25f, 25f); - Main.dust[dust].velocity = spitLocation - Main.dust[dust].position; - Main.dust[dust].scale = dustType == DustID.Ichor ? 1f : 3f; + Main.dust[dust].velocity = (spitLocation - Main.dust[dust].position).SafeNormalize(Vector2.UnitY) * 2f; + Main.dust[dust].scale = dustType == DustID.Ichor ? 1f : 2f; Main.dust[dust].noGravity = true; } } @@ -210,7 +218,7 @@ namespace CalamityMod.NPCs.Perforator if (Main.netMode != NetmodeID.MultiplayerClient) { int spitProjectileAmount = 8; - float spitProjectileBaseVelocity = 12f; + float spitProjectileBaseVelocity = 16f; float spitProjectileRandomVelocityLimit = 3f; for (int i = 0; i < spitProjectileAmount; i++) { diff --git a/NPCs/Perforator/PerforatorHeadSmall.cs b/NPCs/Perforator/PerforatorHeadSmall.cs index 2b77994911..b0120e825c 100644 --- a/NPCs/Perforator/PerforatorHeadSmall.cs +++ b/NPCs/Perforator/PerforatorHeadSmall.cs @@ -141,14 +141,14 @@ namespace CalamityMod.NPCs.Perforator // Percent life remaining float lifeRatio = NPC.life / (float)NPC.lifeMax; - float speed = 0.15f; - float turnSpeed = 0.1f; + float speed = revenge ? 0.2f : 0.15f; + float turnSpeed = revenge ? 0.15f : 0.1f; if (expertMode) { - float velocityScale = (death ? 0.15f : 0.1f) * enrageScale; + float velocityScale = (death ? 0.2f : 0.14f) * enrageScale; speed += velocityScale * (1f - lifeRatio); - float accelerationScale = (death ? 0.1f : 0.07f) * enrageScale; + float accelerationScale = (death ? 0.15f : 0.1f) * enrageScale; turnSpeed += accelerationScale * (1f - lifeRatio); } diff --git a/NPCs/Perforator/PerforatorHive.cs b/NPCs/Perforator/PerforatorHive.cs index 54525678bc..144a0ed936 100644 --- a/NPCs/Perforator/PerforatorHive.cs +++ b/NPCs/Perforator/PerforatorHive.cs @@ -114,6 +114,7 @@ namespace CalamityMod.NPCs.Perforator writer.Write(small); writer.Write(medium); writer.Write(large); + writer.Write(NPC.localAI[2]); } public override void ReceiveExtraAI(BinaryReader reader) @@ -123,6 +124,7 @@ namespace CalamityMod.NPCs.Perforator small = reader.ReadBoolean(); medium = reader.ReadBoolean(); large = reader.ReadBoolean(); + NPC.localAI[2] = reader.ReadSingle(); } public override void AI() @@ -153,7 +155,7 @@ namespace CalamityMod.NPCs.Perforator // Phases based on life percentage bool phase2 = lifeRatio < 0.7f; - bool phase3 = lifeRatio < 0.4f && revenge; + bool phase3 = medium && revenge; // Enrage if ((!player.ZoneCrimson || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush) @@ -201,17 +203,17 @@ namespace CalamityMod.NPCs.Perforator else if (NPC.timeLeft < 1800) NPC.timeLeft = 1800; - //GFB seed shenanigans: Behavior during the suck + // GFB seed shenanigans: Behavior during the suck if (NPC.localAI[1] >= 6f) { - //Leak projectiles everywhere and start healing + // Leak projectiles everywhere and start healing int type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); int spread = Main.rand.Next(-45, 46); Vector2 baseVelocity = Vector2.UnitY * Main.rand.NextFloat(-12.5f, -5f); Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, baseVelocity.RotatedBy(MathHelper.ToRadians(spread)), type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); - //Heals 10 times per second for 0.1% of its health each = 1% per second + // Heals 10 times per second for 0.1% of its health each = 1% per second if (Main.netMode != NetmodeID.MultiplayerClient) { int healAmt = (int)(NPC.lifeMax / 1000); @@ -240,6 +242,11 @@ namespace CalamityMod.NPCs.Perforator else wormsAlive = 0; + // Do not spit from side mouth while the large worm is alive + // Death Mode ignores this + if (largeWormAlive && !death) + phase3 = false; + NPC.Calamity().DR = wormsAlive * 0.3f; if (NPC.ai[3] == 0f && NPC.life > 0) @@ -401,21 +408,66 @@ namespace CalamityMod.NPCs.Perforator return; } - if (Main.netMode != NetmodeID.MultiplayerClient) + // Side mouth starts spitting when it opens + if (phase3) { - // Side mouth starts spitting when it opens (WIP) - if (phase3) + NPC.localAI[2] += 1f; + if (NPC.frame.Y / (TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type]) == 5 && NPC.localAI[2] >= 0f) { - NPC.localAI[2] += 1f; - if (NPC.frame.Y / (TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type]) == 5 && NPC.localAI[2] >= 0f) - { - // Ensure it only spits once - NPC.localAI[2] = -10f; + // Ensure it only spits once + // Spits half as much while the medium worm is alive + NPC.localAI[2] = mediumWormAlive ? -70f : -10f; - //SoundEngine.PlaySound(SoundID.Item17, ); + Vector2 centerOffset = new Vector2(NPC.direction == 1 ? 52f : -52f, -4f); + Vector2 mouthLocation = NPC.Center + centerOffset; + Vector2 spitVelocity = (mouthLocation + (Vector2.UnitX * 100f * NPC.direction) - mouthLocation).SafeNormalize(Vector2.UnitY) * 6f; + + SoundEngine.PlaySound(SoundID.Item17, mouthLocation); + + if (Main.netMode != NetmodeID.MultiplayerClient) + { + int maxProjectiles = 3; + Vector2 dustSpawnBox = new Vector2(12f, 12f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; + for (int i = 0; i < maxProjectiles; i++) + { + bool ichor = Main.rand.NextBool(); + int type = ichor ? ModContent.ProjectileType() : ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type); + Vector2 randomizedProjectileSpawnLocation = mouthLocation + Main.rand.NextVector2CircularEdge(4f, 4f); + Vector2 randomizedProjectileVelocity = spitVelocity + Main.rand.NextVector2CircularEdge(1.5f, 1.5f); + Projectile.NewProjectile(NPC.GetSource_FromAI(), randomizedProjectileSpawnLocation, randomizedProjectileVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y); + + float dustSpeed = Main.rand.NextFloat(3.0f, 9.0f); + float angleRandom = 0.05f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0.0f).RotatedBy(randomizedProjectileVelocity.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2.0f * angleRandom); + + if (ichor) + { + for (int j = 0; j < 4; j++) + { + int ichorDust = Dust.NewDust(randomizedProjectileSpawnLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, DustID.Ichor); + Main.dust[ichorDust].velocity = dustVelocity; + } + } + else + { + for (int j = 0; j < 4; j++) + { + int bloodDust = Dust.NewDust(randomizedProjectileSpawnLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, DustID.Blood); + Main.dust[bloodDust].velocity = dustVelocity; + Main.dust[bloodDust].scale = 2f; + } + } + } } } + } + if (Main.netMode != NetmodeID.MultiplayerClient) + { NPC.localAI[0] += 1f; if (NPC.localAI[0] >= (revenge ? 200f : 250f) + wormsAlive * 150f && NPC.position.Y + NPC.height < player.position.Y && Vector2.Distance(player.Center, NPC.Center) > 80f) { @@ -436,6 +488,8 @@ namespace CalamityMod.NPCs.Perforator Vector2 destination = wormsAlive > 0 ? player.Center : NPC.Center - Vector2.UnitY * 100f; Vector2 projectileVelocity = new Vector2(Vector2.Normalize(destination - NPC.Center).X * velocity, -velocity); float rotation = MathHelper.ToRadians(spread); + Vector2 dustSpawnBox = new Vector2(12f, 12f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); @@ -443,23 +497,27 @@ namespace CalamityMod.NPCs.Perforator Vector2 projectileSpawnLocation = NPC.Center + Vector2.Normalize(perturbedSpeed) * 50f; Vector2 projectileVelocityRandomized = perturbedSpeed + randomVelocity; + float dustSpeed = Main.rand.NextFloat(3.0f, 9.0f); + float angleRandom = 0.05f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0.0f).RotatedBy(projectileVelocityRandomized.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2.0f * angleRandom); + if (ichor) { for (int j = 0; j < 4; j++) { - int ichorDust = Dust.NewDust(NPC.position, 12, 12, DustID.Ichor); - Main.dust[ichorDust].position = projectileSpawnLocation; - Main.dust[ichorDust].velocity = projectileVelocityRandomized; + int ichorDust = Dust.NewDust(projectileSpawnLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, DustID.Ichor); + Main.dust[ichorDust].velocity = dustVelocity; } } else { for (int j = 0; j < 4; j++) { - int bloodDust = Dust.NewDust(NPC.position, 12, 12, DustID.Blood); - Main.dust[bloodDust].position = projectileSpawnLocation; - Main.dust[bloodDust].velocity = projectileVelocityRandomized; - Main.dust[bloodDust].scale = 3f; + int bloodDust = Dust.NewDust(projectileSpawnLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, DustID.Blood); + Main.dust[bloodDust].velocity = dustVelocity; + Main.dust[bloodDust].scale = 2f; } } diff --git a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs index d610636e8d..3e312cbf39 100644 --- a/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs +++ b/NPCs/PrimordialWyrm/PrimordialWyrmHead.cs @@ -1482,6 +1482,13 @@ namespace CalamityMod.NPCs.PrimordialWyrm potionType = ModContent.ItemType(); } + public override void OnKill() + { + // Mark Primordial Wyrm as dead + DownedBossSystem.downedPrimordialWyrm = true; + CalamityNetcode.SyncWorld(); + } + public override void ModifyNPCLoot(NPCLoot npcLoot) { npcLoot.Add(ModContent.ItemType()); diff --git a/NPCs/SlimeGod/CorruptSlimeSpawn.cs b/NPCs/SlimeGod/CorruptSlimeSpawn.cs index e677e317fd..9d19bc6ba6 100644 --- a/NPCs/SlimeGod/CorruptSlimeSpawn.cs +++ b/NPCs/SlimeGod/CorruptSlimeSpawn.cs @@ -32,8 +32,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.defense = 6; NPC.lifeMax = BossRushEvent.BossRushActive ? 10000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 360 : 180; NPC.knockBackResist = 0.7f; - AnimationType = 121; - NPC.Opacity = 0.8f; + AnimationType = NPCID.Slimer; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -60,6 +59,12 @@ namespace CalamityMod.NPCs.SlimeGod }); } + public override void AI() + { + Vector3 light = new Vector3(0.5f, 0.1f, 0.5f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + } + public override void HitEffect(NPC.HitInfo hit) { if (Main.netMode != NetmodeID.MultiplayerClient && NPC.life <= 0) @@ -70,10 +75,9 @@ namespace CalamityMod.NPCs.SlimeGod Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } public override void OnKill() { diff --git a/NPCs/SlimeGod/CorruptSlimeSpawn2.cs b/NPCs/SlimeGod/CorruptSlimeSpawn2.cs index ff4ec21caf..e8df94c69d 100644 --- a/NPCs/SlimeGod/CorruptSlimeSpawn2.cs +++ b/NPCs/SlimeGod/CorruptSlimeSpawn2.cs @@ -33,7 +33,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.lifeMax = BossRushEvent.BossRushActive ? 5000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 180 : 90; NPC.knockBackResist = 0.9f; AnimationType = NPCID.CorruptSlime; - NPC.Opacity = 0.8f; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -49,6 +48,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.5f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + NPC.damage = (NPC.velocity.Y == 0f || NPC.velocity.Length() < 3f) ? 0 : NPC.defDamage; } @@ -56,16 +58,14 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } } diff --git a/NPCs/SlimeGod/CrimsonSlimeSpawn.cs b/NPCs/SlimeGod/CrimsonSlimeSpawn.cs index b037980269..4cb9744c71 100644 --- a/NPCs/SlimeGod/CrimsonSlimeSpawn.cs +++ b/NPCs/SlimeGod/CrimsonSlimeSpawn.cs @@ -32,7 +32,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.lifeMax = BossRushEvent.BossRushActive ? 10000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 220 : 110; NPC.knockBackResist = 0.8f; AnimationType = NPCID.CorruptSlime; - NPC.Opacity = 0.8f; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -61,6 +60,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.1f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + NPC.damage = (NPC.velocity.Y == 0f || NPC.velocity.Length() < 3f) ? 0 : NPC.defDamage; } @@ -68,16 +70,14 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } } diff --git a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs index 10079952a5..9f321b1817 100644 --- a/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs +++ b/NPCs/SlimeGod/CrimsonSlimeSpawn2.cs @@ -17,7 +17,9 @@ namespace CalamityMod.NPCs.SlimeGod public class CrimsonSlimeSpawn2 : ModNPC { public float spikeTimer = 60f; + public override LocalizedText DisplayName => CalamityUtils.GetText("NPCs.CrimsonSlimeSpawn.DisplayName"); + public override void SetStaticDefaults() { Main.npcFrameCount[Type] = 5; @@ -36,7 +38,6 @@ namespace CalamityMod.NPCs.SlimeGod NPC.defense = 6; NPC.lifeMax = BossRushEvent.BossRushActive ? 12000 : (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 260 : 130; NPC.knockBackResist = 0.7f; - NPC.Opacity = 0.8f; NPC.lavaImmune = false; NPC.noGravity = false; NPC.noTileCollide = false; @@ -61,13 +62,18 @@ namespace CalamityMod.NPCs.SlimeGod public override void FindFrame(int frameHeight) { + Vector3 light = new Vector3(0.5f, 0.1f, 0.1f); + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + int frameY = 1; if (!Main.dedServ) { if (TextureAssets.Npc[Type].Value is null) return; + frameY = TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type]; } + int aiState = 0; if (NPC.aiAction == 0) aiState = NPC.velocity.Y >= 0f ? (NPC.velocity.Y <= 0f ? (NPC.velocity.X == 0f ? 0 : 1) : 3) : 2; @@ -79,6 +85,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.frameCounter++; if (aiState == 4) NPC.frameCounter++; + if (NPC.frameCounter >= 8f) { NPC.frame.Y += frameY; @@ -96,9 +103,8 @@ namespace CalamityMod.NPCs.SlimeGod int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); if (Main.zenithWorld) - { type = Main.rand.NextBool() ? ModContent.ProjectileType() : ModContent.ProjectileType(); - } + if (!NPC.wet) { Vector2 faceDirection = new Vector2(NPC.position.X + (float)NPC.width * 0.5f, NPC.position.Y + (float)NPC.height * 0.5f); @@ -109,9 +115,8 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) - { NPC.velocity.X = NPC.velocity.X * 0.9f; - } + if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { int projcount = Main.zenithWorld ? 12 : 5; @@ -131,9 +136,8 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.ai[0] = -40f; if (NPC.velocity.Y == 0f) - { NPC.velocity.X = NPC.velocity.X * 0.9f; - } + if (Main.netMode != NetmodeID.MultiplayerClient && spikeTimer == 0f) { targetY = Main.player[NPC.target].position.Y - faceDirection.Y - (float)Main.rand.Next(0, 200); @@ -152,16 +156,14 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { for (int k = 0; k < 20; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); } } diff --git a/NPCs/SlimeGod/CrimulanPaladin.cs b/NPCs/SlimeGod/CrimulanPaladin.cs index 672195c5f0..b4947f9b8a 100644 --- a/NPCs/SlimeGod/CrimulanPaladin.cs +++ b/NPCs/SlimeGod/CrimulanPaladin.cs @@ -20,6 +20,8 @@ namespace CalamityMod.NPCs.SlimeGod private float bossLife; private float addedStretch = 0f; private float landingRecoil = 0f; + private const int Width = 206; + private const int Height = 156; public override void SetStaticDefaults() { @@ -30,9 +32,8 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); - NPC.width = 206; - NPC.height = 156; - NPC.scale = 1.1f; + NPC.width = Width; + NPC.height = Height; NPC.defense = 12; NPC.LifeMaxNERB(7500, 9000, 160000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; @@ -75,6 +76,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(1f, 0.2f, 0.2f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); CalamityGlobalNPC.slimeGodRed = NPC.whoAmI; @@ -85,8 +89,11 @@ namespace CalamityMod.NPCs.SlimeGod float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Reset defense and damage NPC.defense = NPC.defDefense; int setDamage = NPC.defDamage; + + // Boost defense and damage while buffed by the Slime God if (NPC.localAI[1] == 1f) { NPC.defense = NPC.defDefense + 24; @@ -104,8 +111,13 @@ namespace CalamityMod.NPCs.SlimeGod addedStretch = -landingRecoil; + // Used for teleporting float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; + + // Used for how fast the slime animates NPC.aiAction = 0; + + // Reset tile collide and gravity NPC.noTileCollide = false; NPC.noGravity = false; @@ -115,6 +127,7 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; + // Despawn if (NPC.ai[0] != 3f) { if (player.dead || !player.active) @@ -135,8 +148,10 @@ namespace CalamityMod.NPCs.SlimeGod NPC.timeLeft = 1800; } + // Split into smaller slimes and fire spikes at half HP if (lifeRatio <= 0.5f && Main.netMode != NetmodeID.MultiplayerClient && expertMode) { + // Spread of random globs in meme mode if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) { int type = ModContent.ProjectileType(); @@ -144,18 +159,21 @@ namespace CalamityMod.NPCs.SlimeGod Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center.X, NPC.Center.Y, (float)Main.rand.Next(-1499, 1500) * 0.01f, (float)Main.rand.Next(-1499, 1500) * 0.01f, type, 35, 0f); } + // Spawn split slimes SoundEngine.PlaySound(SoundID.NPCDeath1, NPC.Center); Vector2 spawnAt = NPC.Center + new Vector2(0f, NPC.height / 2f); NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnAt.X - 80, (int)spawnAt.Y, ModContent.NPCType(), 0, 0f, 0f, 0f); NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnAt.X + 80, (int)spawnAt.Y, ModContent.NPCType(), 0, 0f, 0f, 45f); - if (Main.zenithWorld && NPC.CountNPCS(ModContent.NPCType()) < 3) // Split into 3 slimes if the other large slime hasn't split yet. + + // Split into 3 additional slimes if the other large slime hasn't split yet + if (Main.zenithWorld && NPC.CountNPCS(ModContent.NPCType()) < 3) NPC.NewNPC(NPC.GetSource_FromAI(), (int)spawnAt.X, (int)spawnAt.Y - 80, ModContent.NPCType(), 0, 0f, 0f, 90f); - // Calculate stretch here so that the spike spread looks more natural. + // Calculate stretch here so that the spike spread looks more natural float stretch = NPC.velocity.Y * 0.03f; stretch = Math.Abs(stretch) + addedStretch; - // Stretch rapidly if about to jump or teleport, stretch normally while idle. + // Stretch rapidly if about to jump or teleport, stretch normally while idle if (NPC.velocity.Y == 0f) stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * (NPC.aiAction == 1 ? 15f : 2f)) / 2f + 0.5f); @@ -164,25 +182,48 @@ namespace CalamityMod.NPCs.SlimeGod Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; - // Spread of spikes. + // Spread of spikes float projectileVelocity = 2f; int type2 = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type2); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + Vector2 spawnLocation = new Vector2(NPC.Center.X, NPC.Center.Y + 50f * NPC.scale); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; int numProj = 9; float rotation = MathHelper.ToRadians(100); float maxVelocity = death ? 18f : revenge ? 16f : 14f; float acceleration = death ? 1.03f : revenge ? 1.025f : 1.02f; int spikeType = 0; + int dustType = DustID.TintableDust; + Color dustColor = Color.Crimson; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(40f, 40f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { spikeType = numProj - 1 - i; + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 20f * scaleStretch, perturbedSpeed, type2, damage, 0f, Main.myPlayer, maxVelocity, acceleration, spikeType); + Vector2 projectileLocation = spawnLocation + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 70f * scaleStretch; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 32; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type2, damage, 0f, Main.myPlayer, maxVelocity, acceleration, spikeType); } + // Die NPC.life = 0; NPC.HitEffect(); NPC.active = false; @@ -273,7 +314,8 @@ namespace CalamityMod.NPCs.SlimeGod // Get ready to teleport by increasing ai[3] if (calamityGlobalNPC.newAI[0] < teleportGateValue) { - if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) + float teleportFasterDistance = 500f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > teleportFasterDistance) calamityGlobalNPC.newAI[0] += death ? 3f : 2f; else calamityGlobalNPC.newAI[0] += 1f; @@ -283,7 +325,9 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[0] == 0f) { - bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > 2400f || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + // Catch up to the target if too far away + float catchUpDistance = 1600f; + bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > catchUpDistance || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); if (Main.netMode != NetmodeID.MultiplayerClient && phaseThroughTilesToReachTarget) { // Set damage @@ -436,12 +480,9 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noTileCollide = true; NPC.noGravity = true; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.TargetClosest(); Vector2 targetCenter = player.Center; targetCenter.Y -= 350f; @@ -450,8 +491,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - targetDist = player.Center - NPC.Center; - targetDist.Normalize(); + targetDist = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; @@ -472,7 +512,7 @@ namespace CalamityMod.NPCs.SlimeGod return; } - targetDist.Normalize(); + targetDist = targetDist.SafeNormalize(Vector2.UnitY); targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } @@ -500,38 +540,58 @@ namespace CalamityMod.NPCs.SlimeGod SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); if (Main.netMode != NetmodeID.MultiplayerClient) { - // Eruption of slime balls that fall down - float projectileVelocity = 8f; - int type = ModContent.ProjectileType(); - int damage = NPC.GetProjectileDamage(type); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + // Calculate stretch here so that the spike spread looks more natural + float stretch = NPC.velocity.Y * 0.03f; + stretch = Math.Abs(stretch) + addedStretch; + + // Stretch rapidly if about to jump or teleport, stretch normally while idle + if (NPC.velocity.Y == 0f) + stretch += MathHelper.Lerp(0f, 0.16f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * (NPC.aiAction == 1 ? 15f : 2f)) / 2f + 0.5f); + + if (stretch > 0.5f) + stretch = 0.5f; + + Vector2 scaleStretch = new Vector2(1f - stretch, 1f + stretch) * NPC.scale; + + // Spread of spikes + float projectileVelocity = 2f; + int type2 = ModContent.ProjectileType(); + int damage = NPC.GetProjectileDamage(type2); + Vector2 spawnLocation = new Vector2(NPC.Center.X, NPC.Center.Y + 50f * NPC.scale); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; - int numProj = 5; - float rotation = MathHelper.ToRadians(45); + int numProj = 9; + float rotation = MathHelper.ToRadians(100); + float maxVelocity = death ? 18f : revenge ? 16f : 14f; + float acceleration = death ? 1.03f : revenge ? 1.025f : 1.02f; + int spikeType = 0; + int dustType = DustID.TintableDust; + Color dustColor = Color.Crimson; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(40f, 40f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { + spikeType = numProj - 1 - i; + Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed * 1.5f, type, damage, 0f, Main.myPlayer, 1f, 0f); - } + Vector2 projectileLocation = spawnLocation + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 70f * scaleStretch; - // Fire slime balls directly at players with a max of 2 - if (enraged && expertMode) - { - List targets = new List(); - foreach (Player plr in Main.ActivePlayers) - { - if (!plr.dead) - targets.Add(plr.whoAmI); + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); - if (targets.Count > 1) - break; - } - foreach (int t in targets) + for (int j = 0; j < 32; j++) { - Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type2, damage, 0f, Main.myPlayer, maxVelocity, acceleration, spikeType); } } @@ -555,6 +615,8 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.velocity.Y > velocityLimit) NPC.velocity.Y = velocityLimit; } + + // Jump in quick succession else if (NPC.ai[0] == 2f) { if (NPC.velocity.Y == 0f) @@ -646,20 +708,19 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + // Catch up to the target if too far away else if (NPC.ai[0] == 4f) { // Avoid cheap bullshit NPC.damage = setDamage; - if (NPC.velocity.X > 0f) - NPC.direction = 1; - else - NPC.direction = -1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.noTileCollide = true; NPC.noGravity = true; NPC.knockBackResist = 0f; + Vector2 distanceFromTarget = player.Center - NPC.Center; distanceFromTarget.Y -= 16f; if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromTarget.Length() < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && @@ -675,14 +736,18 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } - if (distanceFromTarget.Length() > 12f) + float movementSpeed = 16f; + if (distanceFromTarget.Length() > movementSpeed) { - distanceFromTarget.Normalize(); - distanceFromTarget *= 12f; + distanceFromTarget = distanceFromTarget.SafeNormalize(Vector2.UnitY); + distanceFromTarget *= movementSpeed; } - NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; + float inertia = 25f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + distanceFromTarget) / inertia; } + + // Teleport shit else if (NPC.ai[0] == 5f) { // Avoid cheap bullshit @@ -712,7 +777,7 @@ namespace CalamityMod.NPCs.SlimeGod dustColor.A = 150; for (int i = 0; i < 10; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } @@ -746,7 +811,7 @@ namespace CalamityMod.NPCs.SlimeGod dustColor.A = 150; for (int i = 0; i < 10; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } @@ -756,6 +821,7 @@ namespace CalamityMod.NPCs.SlimeGod if (landingRecoil > 0.36f) landingRecoil = 0.36f; + // Slime spawning and scale logic if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -767,11 +833,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio; - NPC.width = (int)(206f * NPC.scale); - NPC.height = (int)(156f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -782,12 +848,11 @@ namespace CalamityMod.NPCs.SlimeGod if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int slimeType = ModContent.NPCType(); - if (Main.rand.NextBool(3)) - slimeType = ModContent.NPCType(); + int offset = 32; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset)); + int slimeType = Main.rand.NextBool(3) ? ModContent.NPCType() : ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; @@ -795,7 +860,7 @@ namespace CalamityMod.NPCs.SlimeGod Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); Main.npc[slimeSpawn].ai[1] = 0f; if (Main.dedServ && slimeSpawn < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn); } } } @@ -854,17 +919,43 @@ namespace CalamityMod.NPCs.SlimeGod return false; } - public static float SlimeRotationFactor(NPC npc) - { - return MathHelper.ToRadians(npc.velocity.X * (-npc.velocity.Y / 10)); - } + public static float SlimeRotationFactor(NPC npc) => MathHelper.ToRadians(npc.velocity.X * (-npc.velocity.Y * 0.1f)); public override void HitEffect(NPC.HitInfo hit) { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, 4, hit.HitDirection, -1f, 0, dustColor, 1f); + + if (NPC.life <= 0) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(160f * NPC.scale); + NPC.position.X = NPC.position.X - (float)(NPC.width / 2); + NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); + + for (int i = 0; i < 40; i++) + { + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 80; j++) + { + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; + } + } } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index b93f13907b..4aa40da436 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -22,6 +22,8 @@ namespace CalamityMod.NPCs.SlimeGod private float addedStretch = 0f; private int wingFrameDrawn = 0; private const int TotalWingFrames = 8; + private const int Width = 134; + private const int Height = 150; public static Asset WingTexture; @@ -37,9 +39,8 @@ namespace CalamityMod.NPCs.SlimeGod { NPC.Calamity().canBreakPlayerDefense = true; NPC.GetNPCDamage(); - NPC.width = 134; - NPC.height = 150; - NPC.scale = 1.1f; + NPC.width = Width; + NPC.height = Height; NPC.defense = 10; NPC.LifeMaxNERB(8000, 9600, 220000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; @@ -79,6 +80,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(1f, 0.2f, 1f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); CalamityGlobalNPC.slimeGodPurple = NPC.whoAmI; @@ -231,13 +235,69 @@ namespace CalamityMod.NPCs.SlimeGod Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y + 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; float rotation = MathHelper.ToRadians(80); + int dustType = DustID.TintableDust; + Color dustColor = Color.Lavender; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProjectiles; i++) { if (CalamityWorld.LegendaryMode) destination *= Main.rand.NextFloat() + 0.5f; Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProjectiles - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Vector2 projectileLocation = NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type, damage, 0f, Main.myPlayer); + } + + // Fire slime balls directly at players with a max of 2 + if (enraged && expertMode) + { + List targets = new List(); + foreach (Player plr in Main.ActivePlayers) + { + if (!plr.dead) + targets.Add(plr.whoAmI); + + if (targets.Count > 1) + break; + } + foreach (int t in targets) + { + Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; + Vector2 projectileLocation = NPC.Center + projFireDirection.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(projFireDirection.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, projFireDirection, type, damage, 0f, Main.myPlayer); + } } } @@ -295,7 +355,28 @@ namespace CalamityMod.NPCs.SlimeGod int damage = NPC.GetProjectileDamage(type); Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y + 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + destination.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale, destination, type, damage, 0f, Main.myPlayer, 1f); + int dustType = DustID.TintableDust; + Color dustColor = Color.Lavender; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; + Vector2 projectileLocation = NPC.Center + destination.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(destination.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, destination, type, damage, 0f, Main.myPlayer, 1f); } SoundEngine.PlaySound(SlimeGodCore.ShotSound, NPC.Center); @@ -319,11 +400,11 @@ namespace CalamityMod.NPCs.SlimeGod else if (NPC.ai[0] == 3f) { // Distance required to charge - float minChargeSafeDistance = 550f; + float minChargeSafeDistance = 650f; // Charge variables float chargeVelocityMult = 0.1f; - float maxChargeVelocity = (bossRush || enraged) ? 21f : death ? 18f : revenge ? 16.5f : expertMode ? 15f : 12f; + float maxChargeVelocity = (bossRush || enraged) ? 12f : death ? 10f : revenge ? 9f : expertMode ? 8f : 6f; if (Main.getGoodWorld) maxChargeVelocity *= 1.15f; if (CalamityWorld.LegendaryMode && revenge) @@ -376,7 +457,7 @@ namespace CalamityMod.NPCs.SlimeGod float slowDownDurationAfterCharge = revenge ? 90f : 120f; NPC.ai[2] = slowDownDurationAfterCharge; NPC.localAI[2] = 0f; - NPC.velocity /= 2f; + NPC.velocity *= 0.5f; NPC.netUpdate = true; } else @@ -470,11 +551,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio; - NPC.width = (int)(134f * NPC.scale); - NPC.height = (int)(150f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -488,8 +569,9 @@ namespace CalamityMod.NPCs.SlimeGod int randSlimeAmt = Main.rand.Next(1, 3); for (int j = 0; j < randSlimeAmt; j++) { - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); + int offset = 16; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset)); int slimeType = ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); @@ -703,8 +785,37 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + + if (NPC.life <= 0) + { + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(160f * NPC.scale); + NPC.position.X = NPC.position.X - (float)(NPC.width / 2); + NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); + + for (int i = 0; i < 40; i++) + { + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; + if (Main.rand.NextBool()) + { + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + } + } + + for (int j = 0; j < 80; j++) + { + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; + } + } } public override void ApplyDifficultyAndPlayerScaling(int numPlayers, float balance, float bossAdjustment) diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index dacc2f1f2a..8e702a3dd7 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -36,6 +36,13 @@ namespace CalamityMod.NPCs.SlimeGod [AutoloadBossHead] public class SlimeGodCore : ModNPC { + private enum PaladinSlimeTypes + { + None, + Ebonian, + Crimulan + } + private bool slimesSpawned = false; private int buffedSlime = 0; @@ -132,7 +139,7 @@ namespace CalamityMod.NPCs.SlimeGod { if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active) { - if ((npc.ModNPC as SlimeGodCore).buffedSlime == 1) + if ((npc.ModNPC as SlimeGodCore).buffedSlime == (int)PaladinSlimeTypes.Ebonian) Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 1f; else Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 0f; @@ -155,7 +162,7 @@ namespace CalamityMod.NPCs.SlimeGod { if (Main.npc[CalamityGlobalNPC.slimeGodRed].active) { - if ((npc.ModNPC as SlimeGodCore).buffedSlime == 2) + if ((npc.ModNPC as SlimeGodCore).buffedSlime == (int)PaladinSlimeTypes.Crimulan) Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 1f; else Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 0f; @@ -192,6 +199,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.5f, 0.5f, 0.5f) * NPC.Opacity; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); CalamityGlobalNPC.slimeGod = NPC.whoAmI; @@ -410,27 +420,27 @@ namespace CalamityMod.NPCs.SlimeGod NPC.rotation += NPC.direction * 0.3f; - if (buffedSlime == 0) + if (buffedSlime == (int)PaladinSlimeTypes.None) { SoundEngine.PlaySound(PossessionSound, NPC.Center); if (purpleSlimeAlive && redSlimeAlive) buffedSlime = Main.rand.Next(2) + 1; else if (purpleSlimeAlive) - buffedSlime = 1; + buffedSlime = (int)PaladinSlimeTypes.Ebonian; else if (redSlimeAlive) - buffedSlime = 2; + buffedSlime = (int)PaladinSlimeTypes.Crimulan; } Vector2 purpleSlimeVector = new Vector2(calamityGlobalNPC.newAI[0], calamityGlobalNPC.newAI[1]); Vector2 redSlimeVector = new Vector2(NPC.ai[1], NPC.ai[2]); - Vector2 goToVector = buffedSlime == 1 ? purpleSlimeVector : redSlimeVector; + Vector2 goToVector = buffedSlime == (int)PaladinSlimeTypes.Ebonian ? purpleSlimeVector : redSlimeVector; Vector2 goToPosition = goToVector - NPC.Center; - NPC.velocity = Vector2.Normalize(goToPosition) * 24f; + NPC.velocity = goToPosition.SafeNormalize(Vector2.UnitY) * 24f; // Reduce velocity to 0 to avoid spastic movement when inside big slime. - float stickPositionAdjustment = buffedSlime == 1 ? 16f : 32f; + float stickPositionAdjustment = buffedSlime == (int)PaladinSlimeTypes.Ebonian ? 16f : 32f; if (Vector2.Distance(NPC.Center, goToVector) < 80f + stickPositionAdjustment) { NPC.velocity = Vector2.Zero; @@ -500,7 +510,7 @@ namespace CalamityMod.NPCs.SlimeGod float projectileVelocity = 4f + (aggressionLevel - 1) * 2f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 velocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; + Vector2 velocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 0f, Main.myPlayer); } else @@ -508,7 +518,7 @@ namespace CalamityMod.NPCs.SlimeGod float projectileVelocity = 8f + (aggressionLevel - 1) * 2f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 velocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; + Vector2 velocity = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center, velocity, type, damage, 0f, Main.myPlayer); } } @@ -519,7 +529,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.Opacity > 0.8f) NPC.Opacity = 0.8f; - buffedSlime = 0; + buffedSlime = (int)PaladinSlimeTypes.None; float flySpeed = death ? 15f : revenge ? 13.5f : expertMode ? 12f : 9f; flySpeed += aggressionLevel; @@ -649,7 +659,7 @@ namespace CalamityMod.NPCs.SlimeGod float sc = 1f; if (!ShouldDespawn(NPC)) { - if (buffedSlime != 0f) + if (buffedSlime != (int)PaladinSlimeTypes.None) { NPC.scale = MathHelper.Lerp(NPC.scale, 0f, 0.2f); NPC.Opacity = MathHelper.Lerp(NPC.Opacity, 0.7f, 0.4f); @@ -662,7 +672,7 @@ namespace CalamityMod.NPCs.SlimeGod } SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Color drawColorAlpha = (buffedSlime != 0f && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); + Color drawColorAlpha = (buffedSlime != (int)PaladinSlimeTypes.None && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); Vector2 origin = NPC.frame.Size() * 0.5f; Vector2 halfSize = NPC.Size * 0.5f; @@ -725,7 +735,7 @@ namespace CalamityMod.NPCs.SlimeGod } // Reset the color - drawColorAlpha = (buffedSlime != 0f && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); + drawColorAlpha = (buffedSlime != (int)PaladinSlimeTypes.None && !ShouldDespawn(NPC)) ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); // Draw the base texture spriteBatch.Draw(texture, NPC.Center - screenPos + new Vector2(0f, NPC.gfxOffY), NPC.frame, drawColorAlpha, NPC.rotation, origin, NPC.scale, spriteEffects, 0f); diff --git a/NPCs/SlimeGod/SplitCrimulanPaladin.cs b/NPCs/SlimeGod/SplitCrimulanPaladin.cs index 3a7fe26a17..cbf6b5c86c 100644 --- a/NPCs/SlimeGod/SplitCrimulanPaladin.cs +++ b/NPCs/SlimeGod/SplitCrimulanPaladin.cs @@ -21,6 +21,8 @@ namespace CalamityMod.NPCs.SlimeGod private float bossLife; private float addedStretch = 0f; private float landingRecoil = 0f; + private const int Width = 166; + private const int Height = 114; public override void SetStaticDefaults() { @@ -41,9 +43,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(1875, 2250, 80000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.GetNPCDamage(); - NPC.width = 166; - NPC.height = 114; - NPC.scale = 0.8f; + NPC.width = Width; + NPC.height = Height; NPC.defense = 10; NPC.knockBackResist = 0f; NPC.value = Item.buyPrice(0, 1, 0, 0); @@ -90,6 +91,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.75f, 0.15f, 0.15f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + if (CalamityGlobalNPC.slimeGodRed < 0 || !Main.npc[CalamityGlobalNPC.slimeGodRed].active) CalamityGlobalNPC.slimeGodRed = NPC.whoAmI; @@ -100,8 +104,11 @@ namespace CalamityMod.NPCs.SlimeGod float lifeRatio = NPC.life / (float)NPC.lifeMax; + // Reset defense and damage NPC.defense = NPC.defDefense; int setDamage = NPC.defDamage; + + // Boost defense and damage while buffed by the Slime God if (NPC.localAI[1] == 1f) { NPC.defense = NPC.defDefense + 20; @@ -119,8 +126,13 @@ namespace CalamityMod.NPCs.SlimeGod addedStretch = -landingRecoil; + // Used for teleporting float scale = (CalamityWorld.LegendaryMode && CalamityWorld.revenge) ? 0.6f : Main.getGoodWorld ? 0.8f : 1f; + + // Used for how fast the slime animates NPC.aiAction = 0; + + // Reset tile collide and gravity NPC.noTileCollide = false; NPC.noGravity = false; @@ -130,6 +142,7 @@ namespace CalamityMod.NPCs.SlimeGod Player player = Main.player[NPC.target]; + // Despawn if (NPC.ai[0] != 3f) { if (player.dead || !player.active) @@ -233,7 +246,8 @@ namespace CalamityMod.NPCs.SlimeGod // This only occurs in Rev and Death for the split Slime Gods if (NPC.ai[3] < teleportGateValue && revenge) { - if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) + float teleportFasterDistance = 500f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > teleportFasterDistance) NPC.ai[3] += death ? 3f : 2f; else NPC.ai[3] += 1f; @@ -243,7 +257,9 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[0] == 0f) { - bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > 2400f || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + // Catch up to the target if too far away + float catchUpDistance = 1600f; + bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > catchUpDistance || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); if (Main.netMode != NetmodeID.MultiplayerClient && phaseThroughTilesToReachTarget) { // Set damage @@ -388,12 +404,9 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noTileCollide = true; NPC.noGravity = true; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.TargetClosest(); Vector2 targetCenter = player.Center; targetCenter.Y -= 350f; @@ -402,8 +415,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - targetDist = player.Center - NPC.Center; - targetDist.Normalize(); + targetDist = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); targetDist *= death ? 11f : revenge ? 10f : expertMode ? 9f : 8f; NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; @@ -424,7 +436,7 @@ namespace CalamityMod.NPCs.SlimeGod return; } - targetDist.Normalize(); + targetDist = targetDist.SafeNormalize(Vector2.UnitY); targetDist *= (death ? 13f : revenge ? 12f : expertMode ? 11f : 10f) + distanceSpeedBoost; NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } @@ -456,15 +468,35 @@ namespace CalamityMod.NPCs.SlimeGod float projectileVelocity = 8f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; int numProj = 3; float rotation = MathHelper.ToRadians(45); + int dustType = DustID.TintableDust; + Color dustColor = Color.Crimson; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed * 1.5f, type, damage, 0f, Main.myPlayer, 1f, 0f); + Vector2 projectileLocation = NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed * 1.5f, type, damage, 0f, Main.myPlayer, 1f, 0f); } // Fire slime balls directly at players with a max of 2 @@ -481,8 +513,24 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = (Main.player[t].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; + Vector2 projectileLocation = NPC.Center + projFireDirection.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(projFireDirection.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -506,6 +554,8 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.velocity.Y > velocityLimit) NPC.velocity.Y = velocityLimit; } + + // Jump in quick succession else if (NPC.ai[0] == 2f) { if (NPC.velocity.Y == 0f) @@ -596,20 +646,19 @@ namespace CalamityMod.NPCs.SlimeGod NPC.velocity.X *= 0.98f; } + // Catch up to the target if too far away else if (NPC.ai[0] == 4f) { // Set damage NPC.damage = setDamage; - if (NPC.velocity.X > 0f) - NPC.direction = 1; - else - NPC.direction = -1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.noTileCollide = true; NPC.noGravity = true; NPC.knockBackResist = 0f; + Vector2 distanceFromTarget = player.Center - NPC.Center; distanceFromTarget.Y -= 16f; if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromTarget.Length() < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && @@ -624,14 +673,18 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } - if (distanceFromTarget.Length() > 12f) + float movementSpeed = 16f; + if (distanceFromTarget.Length() > movementSpeed) { - distanceFromTarget.Normalize(); - distanceFromTarget *= 12f; + distanceFromTarget = distanceFromTarget.SafeNormalize(Vector2.UnitY); + distanceFromTarget *= movementSpeed; } - NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; + float inertia = 20f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + distanceFromTarget) / inertia; } + + // Teleport shit else if (NPC.ai[0] == 5f) { // Avoid cheap bullshit @@ -659,9 +712,9 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } @@ -693,9 +746,9 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Crimson; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int crimsonDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[crimsonDust].noGravity = true; Main.dust[crimsonDust].velocity *= 0.5f; } @@ -705,6 +758,7 @@ namespace CalamityMod.NPCs.SlimeGod if (landingRecoil > 0.36f) landingRecoil = 0.36f; + // Slime spawning and scale logic if (bossLife == 0f && NPC.life > 0) bossLife = NPC.lifeMax; @@ -716,11 +770,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio * 0.75f; - NPC.width = (int)(166f * NPC.scale); - NPC.height = (int)(114f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -731,12 +785,11 @@ namespace CalamityMod.NPCs.SlimeGod if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); - int slimeType = ModContent.NPCType(); - if (Main.rand.NextBool(3)) - slimeType = ModContent.NPCType(); + int offset = 16; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset)); + int slimeType = Main.rand.NextBool(3) ? ModContent.NPCType() : ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); Main.npc[slimeSpawn].velocity.X = (float)Main.rand.Next(-15, 16) * 0.1f; @@ -744,7 +797,7 @@ namespace CalamityMod.NPCs.SlimeGod Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); Main.npc[slimeSpawn].ai[1] = 0f; if (Main.dedServ && slimeSpawn < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn); } } } @@ -820,21 +873,20 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Crimson; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(80f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 40; i++) + + for (int i = 0; i < 20; i++) { - int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); Main.dust[crimDust].velocity *= 3f; if (Main.rand.NextBool()) { @@ -842,12 +894,13 @@ namespace CalamityMod.NPCs.SlimeGod Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int j = 0; j < 70; j++) + + for (int j = 0; j < 40; j++) { - int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 3f); + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); Main.dust[crimDust2].noGravity = true; Main.dust[crimDust2].velocity *= 5f; - crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); Main.dust[crimDust2].velocity *= 2f; } } diff --git a/NPCs/SlimeGod/SplitEbonianPaladin.cs b/NPCs/SlimeGod/SplitEbonianPaladin.cs index eea5d83c45..9a0213d635 100644 --- a/NPCs/SlimeGod/SplitEbonianPaladin.cs +++ b/NPCs/SlimeGod/SplitEbonianPaladin.cs @@ -21,6 +21,8 @@ namespace CalamityMod.NPCs.SlimeGod private float bossLife; private float addedStretch = 0f; private float landingRecoil = 0f; + private const int Width = 166; + private const int Height = 114; public override void SetStaticDefaults() { @@ -41,9 +43,8 @@ namespace CalamityMod.NPCs.SlimeGod NPC.LifeMaxNERB(2000, 2400, 110000); NPC.BossBar = Main.BigBossProgressBar.NeverValid; NPC.GetNPCDamage(); - NPC.width = 166; - NPC.height = 114; - NPC.scale = 0.8f; + NPC.width = Width; + NPC.height = Height; NPC.defense = 8; NPC.aiStyle = -1; AIType = -1; @@ -90,6 +91,9 @@ namespace CalamityMod.NPCs.SlimeGod public override void AI() { + Vector3 light = new Vector3(0.75f, 0.15f, 0.75f) * NPC.scale; + Lighting.AddLight(NPC.Center, light.X, light.Y, light.Z); + if (CalamityGlobalNPC.slimeGodPurple < 0 || !Main.npc[CalamityGlobalNPC.slimeGodPurple].active) CalamityGlobalNPC.slimeGodPurple = NPC.whoAmI; @@ -231,7 +235,8 @@ namespace CalamityMod.NPCs.SlimeGod // This only occurs in Rev and Death for the split Slime Gods if (NPC.ai[3] < teleportGateValue && revenge) { - if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > 320f) + float teleportFasterDistance = 500f; + if (!Collision.CanHitLine(NPC.Center, 0, 0, player.Center, 0, 0) || Math.Abs(NPC.Top.Y - player.Bottom.Y) > teleportFasterDistance) NPC.ai[3] += death ? 3f : 2f; else NPC.ai[3] += 1f; @@ -241,7 +246,9 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[0] == 0f) { - bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > 2400f || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); + // Catch up to the target if too far away + float catchUpDistance = 1600f; + bool phaseThroughTilesToReachTarget = Vector2.Distance(player.Center, NPC.Center) > catchUpDistance || !Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height); if (Main.netMode != NetmodeID.MultiplayerClient && phaseThroughTilesToReachTarget) { // Set damage @@ -431,12 +438,9 @@ namespace CalamityMod.NPCs.SlimeGod NPC.noTileCollide = true; NPC.noGravity = true; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.TargetClosest(); Vector2 targetCenter = player.Center; targetCenter.Y -= 350f; @@ -445,8 +449,7 @@ namespace CalamityMod.NPCs.SlimeGod if (NPC.ai[2] == 1f) { NPC.ai[1] += 1f; - targetDist = player.Center - NPC.Center; - targetDist.Normalize(); + targetDist = (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY); targetDist *= death ? 10f : revenge ? 9f : expertMode ? 8f : 7f; NPC.velocity = (NPC.velocity * 4f + targetDist) / 5f; @@ -467,7 +470,7 @@ namespace CalamityMod.NPCs.SlimeGod return; } - targetDist.Normalize(); + targetDist = targetDist.SafeNormalize(Vector2.UnitY); targetDist *= (death ? 12f : revenge ? 11f : expertMode ? 10f : 9f) + distanceSpeedBoost; NPC.velocity = (NPC.velocity * 5f + targetDist) / 6f; } @@ -499,18 +502,38 @@ namespace CalamityMod.NPCs.SlimeGod float projectileVelocity = 4f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); - Vector2 destination = new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center; - destination.Normalize(); + Vector2 destination = (new Vector2(NPC.Center.X, NPC.Center.Y - 100f) - NPC.Center).SafeNormalize(Vector2.UnitY); destination *= projectileVelocity; int numProj = 9; float rotation = MathHelper.ToRadians(90); + int dustType = DustID.TintableDust; + Color dustColor = Color.Lavender; + dustColor.A = 150; + Vector2 dustSpawnBox = new Vector2(30f, 30f); + Vector2 dustSpawnOffset = dustSpawnBox * 0.5f; for (int i = 0; i < numProj; i++) { // Spawn projectiles 0, 1, 2, 6, 7 and 8 if (i < 3 || i > 5) { Vector2 perturbedSpeed = destination.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1))); - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 30f * NPC.scale + Vector2.Normalize(perturbedSpeed) * 30f * NPC.scale, perturbedSpeed, type, damage, 0f, Main.myPlayer); + Vector2 projectileLocation = NPC.Center + perturbedSpeed.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(perturbedSpeed.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, perturbedSpeed, type, damage, 0f, Main.myPlayer); } } @@ -528,8 +551,24 @@ namespace CalamityMod.NPCs.SlimeGod } foreach (int t in targets) { - Vector2 projFireDirection = Vector2.Normalize(Main.player[t].Center - NPC.Center) * projectileVelocity; - Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(projFireDirection) * 30f * NPC.scale, projFireDirection, type, damage, 0f, Main.myPlayer); + Vector2 projFireDirection = (Main.player[t].Center - NPC.Center).SafeNormalize(Vector2.UnitY) * projectileVelocity; + Vector2 projectileLocation = NPC.Center + projFireDirection.SafeNormalize(Vector2.UnitY) * 30f * NPC.scale; + + float dustSpeed = Main.rand.NextFloat(2f, 4f); + float angleRandom = 0.1f; + Vector2 dustVelocity = new Vector2(dustSpeed, 0f).RotatedBy(projFireDirection.ToRotation()); + dustVelocity = dustVelocity.RotatedBy(-angleRandom); + dustVelocity = dustVelocity.RotatedByRandom(2f * angleRandom); + + for (int j = 0; j < 24; j++) + { + int slimeDust = Dust.NewDust(projectileLocation - dustSpawnOffset, (int)dustSpawnBox.X, (int)dustSpawnBox.Y, dustType); + Main.dust[slimeDust].velocity = dustVelocity; + Main.dust[slimeDust].color = dustColor; + Main.dust[slimeDust].noGravity = true; + } + + Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileLocation, projFireDirection, type, damage, 0f, Main.myPlayer); } } } @@ -648,15 +687,13 @@ namespace CalamityMod.NPCs.SlimeGod // Set damage NPC.damage = setDamage; - if (NPC.velocity.X > 0f) - NPC.direction = 1; - else - NPC.direction = -1; - + NPC.direction = NPC.velocity.X < 0f ? -1 : 1; NPC.spriteDirection = NPC.direction; + NPC.noTileCollide = true; NPC.noGravity = true; NPC.knockBackResist = 0f; + Vector2 distanceFromTarget = player.Center - NPC.Center; distanceFromTarget.Y -= 16f; if (Main.netMode != NetmodeID.MultiplayerClient && distanceFromTarget.Length() < 500f && !Collision.SolidCollision(NPC.position, NPC.width, NPC.height) && @@ -671,13 +708,15 @@ namespace CalamityMod.NPCs.SlimeGod NPC.netUpdate = true; } - if (distanceFromTarget.Length() > 12f) + float movementSpeed = 16f; + if (distanceFromTarget.Length() > movementSpeed) { - distanceFromTarget.Normalize(); - distanceFromTarget *= 12f; + distanceFromTarget = distanceFromTarget.SafeNormalize(Vector2.UnitY); + distanceFromTarget *= movementSpeed; } - NPC.velocity = (NPC.velocity * 4f + distanceFromTarget) / 5f; + float inertia = 25f; + NPC.velocity = (NPC.velocity * (inertia - 1f) + distanceFromTarget) / inertia; } else if (NPC.ai[0] == 6f) { @@ -706,9 +745,9 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[corruptDust].noGravity = true; Main.dust[corruptDust].velocity *= 0.5f; } @@ -740,9 +779,9 @@ namespace CalamityMod.NPCs.SlimeGod // Emit teleport dust Color dustColor = Color.Lavender; dustColor.A = 150; - for (int i = 0; i < 10; i++) + for (int i = 0; i < 5; i++) { - int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, NPC.alpha, dustColor, 2f); + int corruptDust = Dust.NewDust(NPC.position + Vector2.UnitX * -20f, NPC.width + 40, NPC.height, DustID.TintableDust, NPC.velocity.X, NPC.velocity.Y, 0, dustColor, 2f); Main.dust[corruptDust].noGravity = true; Main.dust[corruptDust].velocity *= 0.5f; } @@ -763,11 +802,11 @@ namespace CalamityMod.NPCs.SlimeGod if (scaleRatio != NPC.scale) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); + NPC.position.X = NPC.Center.X; NPC.position.Y = NPC.position.Y + (float)NPC.height; NPC.scale = scaleRatio * 0.75f; - NPC.width = (int)(166f * NPC.scale); - NPC.height = (int)(114f * NPC.scale); + NPC.width = (int)(Width * NPC.scale); + NPC.height = (int)(Height * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)NPC.height; } @@ -778,8 +817,10 @@ namespace CalamityMod.NPCs.SlimeGod if ((float)(NPC.life + slimeSpawnThreshold) < bossLife) { bossLife = (float)NPC.life; - int x = (int)(NPC.position.X + (float)Main.rand.Next(NPC.width - 32)); - int y = (int)(NPC.position.Y + (float)Main.rand.Next(NPC.height - 32)); + + int offset = 16; + int x = (int)(NPC.position.X + offset + (float)Main.rand.Next(NPC.width - offset)); + int y = (int)(NPC.position.Y + offset + (float)Main.rand.Next(NPC.height - offset)); int slimeType = ModContent.NPCType(); int slimeSpawn = NPC.NewNPC(NPC.GetSource_FromAI(), x, y, slimeType); Main.npc[slimeSpawn].SetDefaults(slimeType); @@ -788,7 +829,7 @@ namespace CalamityMod.NPCs.SlimeGod Main.npc[slimeSpawn].ai[0] = (float)(-1000 * Main.rand.Next(3)); Main.npc[slimeSpawn].ai[1] = 0f; if (Main.dedServ && slimeSpawn < Main.maxNPCs) - NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn, 0f, 0f, 0f, 0, 0, 0); + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, slimeSpawn); } } } @@ -864,35 +905,35 @@ namespace CalamityMod.NPCs.SlimeGod { Color dustColor = Color.Lavender; dustColor.A = 150; + for (int k = 0; k < 5; k++) - { - Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, NPC.alpha, dustColor, 1f); - } + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, hit.HitDirection, -1f, 0, dustColor, 1f); + if (NPC.life <= 0) { - NPC.position.X = NPC.position.X + (float)(NPC.width / 2); - NPC.position.Y = NPC.position.Y + (float)(NPC.height / 2); - NPC.width = 50; - NPC.height = 50; + NPC.position = NPC.Center; + NPC.width = NPC.height = (int)(80f * NPC.scale); NPC.position.X = NPC.position.X - (float)(NPC.width / 2); NPC.position.Y = NPC.position.Y - (float)(NPC.height / 2); - for (int i = 0; i < 40; i++) + + for (int i = 0; i < 20; i++) { - int corruptionDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[corruptionDust].velocity *= 3f; + int crimDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust].velocity *= 3f; if (Main.rand.NextBool()) { - Main.dust[corruptionDust].scale = 0.5f; - Main.dust[corruptionDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; + Main.dust[crimDust].scale = 0.5f; + Main.dust[crimDust].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } - for (int j = 0; j < 70; j++) + + for (int j = 0; j < 40; j++) { - int corruptionDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 3f); - Main.dust[corruptionDust2].noGravity = true; - Main.dust[corruptionDust2].velocity *= 5f; - corruptionDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, NPC.alpha, dustColor, 2f); - Main.dust[corruptionDust2].velocity *= 2f; + int crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 3f); + Main.dust[crimDust2].noGravity = true; + Main.dust[crimDust2].velocity *= 5f; + crimDust2 = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.TintableDust, 0f, 0f, 0, dustColor, 2f); + Main.dust[crimDust2].velocity *= 2f; } } } diff --git a/NPCs/StormWeaver/StormWeaverHead.cs b/NPCs/StormWeaver/StormWeaverHead.cs index 7dd6078c43..e2488b3a43 100644 --- a/NPCs/StormWeaver/StormWeaverHead.cs +++ b/NPCs/StormWeaver/StormWeaverHead.cs @@ -555,6 +555,11 @@ namespace CalamityMod.NPCs.StormWeaver // Charge if (!phase4) { + if (calamityGlobalNPC.newAI[0] == chargePhaseGateValue - 70) + { + Vector2 soundCenter = Main.player[NPC.target].Center; + SoundEngine.PlaySound(CommonCalamitySounds.LightningTelegraph, soundCenter); + } if (calamityGlobalNPC.newAI[0] >= chargePhaseGateValue) { NPC.localAI[3] = 60f; diff --git a/NPCs/SunkenSea/Clam.cs b/NPCs/SunkenSea/Clam.cs index ce98ff3c77..e7eccea2f6 100644 --- a/NPCs/SunkenSea/Clam.cs +++ b/NPCs/SunkenSea/Clam.cs @@ -308,7 +308,7 @@ namespace CalamityMod.NPCs.SunkenSea if (Main.netMode != NetmodeID.MultiplayerClient) { - Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, velocity, ModContent.ProjectileType(), NPC.damage, 1); + Projectile.NewProjectile(NPC.GetSource_FromThis(), NPC.Center, velocity, ModContent.ProjectileType(), NPC.damage / 2, 1); } for (int i = 0; i < 9; i++) { diff --git a/NPCs/SunkenSea/Scavenger.cs b/NPCs/SunkenSea/Scavenger.cs new file mode 100644 index 0000000000..882329c24e --- /dev/null +++ b/NPCs/SunkenSea/Scavenger.cs @@ -0,0 +1,895 @@ +using CalamityMod.BiomeManagers; +using CalamityMod.Enums; +using CalamityMod.Items.Accessories; +using CalamityMod.Items.Critters; +using CalamityMod.Items.Fishing.SunkenSeaCatches; +using CalamityMod.Items.Materials; +using CalamityMod.Items.Placeables.SunkenSea; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Items.Weapons.Melee; +using CalamityMod.NPCs.NormalNPCs; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using System.Collections.Generic; +using System.IO; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ModLoader.Utilities; +using Terraria.Utilities; + +namespace CalamityMod.NPCs.SunkenSea +{ + public class Scavenger : SunkenSeaNPC + { + public record ScavengerItem(int itemID, int minimum, int maximum, Func condition); + + public static Asset walkTexture; + + public static Asset inspectTexture; + + public static Asset giveTexture; + + public static Dictionary> ScavengerLoot = new Dictionary>() + { + { ItemID.WhitePearl, new WeightedRandom() }, + { ItemID.BlackPearl, new WeightedRandom() }, + { ItemID.PinkPearl, new WeightedRandom() }, + { ItemID.GalaxyPearl, new WeightedRandom() }, + { ModContent.ItemType(), new WeightedRandom() }, + }; + + public enum PhaseType + { + Idle = 0, + FoundItem = 1, + Bartering = 2 + } + + // The in world index of the item the crab is going after + public int HeldItemIndex + { + get => (int)NPC.ai[1] - 1; + set => NPC.ai[1] = value + 1; + } + + // The type of currency the crab is currently holding + public int HeldItemType + { + get => (int)NPC.ai[2]; + set => NPC.ai[2] = value; + } + + // The crab's current behaviour + public ref float Phase => ref NPC.ai[0]; + + // Used during trading and as a cooldown + public ref float TradeTimer => ref NPC.ai[3]; + + public ref float WalkTimer => ref NPC.Calamity().newAI[0]; + + public ref float TurnTimer => ref NPC.Calamity().newAI[1]; + + public ref float WalkOrStand => ref NPC.Calamity().newAI[2]; + + public ref float StackMin => ref NPC.localAI[0]; + + public ref float StackMax => ref NPC.localAI[1]; + + public ref float OldItemType => ref NPC.localAI[2]; + + public bool ShouldUseWalkingFrames => NPC.velocity.X != 0 && ((WalkOrStand == 1 && Phase == (int)PhaseType.Idle) || (Phase == (int)PhaseType.FoundItem)); + + public bool ShouldUseInspectionFrames => Phase == (int)PhaseType.Bartering && TradeTimer < 80; + + public bool ShouldUseGivingFrames => Phase == (int)PhaseType.Bartering && TradeTimer >= 80; + + protected override SunkenSeaBiomeFlags BiomeDesignation => SunkenSeaBiomeFlags.TimelessShores; + + protected override List PreyIDs => new List + { + + }; + + protected override List PredatorIDs => new List + { + ModContent.NPCType(), + ModContent.NPCType() + }; + + public override void SetStaticDefaults() + { + base.SetStaticDefaults(); + Main.npcFrameCount[NPC.type] = 1; + NPCID.Sets.CantTakeLunchMoney[Type] = true; + Main.npcFrameCount[Type] = 7; + + InitializeScavengerLoot(); + + if (!Main.dedServ) + { + walkTexture = ModContent.Request(Texture + "Walking"); + inspectTexture = ModContent.Request(Texture + "Inspecting"); + giveTexture = ModContent.Request(Texture + "Giving"); + } + } + + #region Trades + + public static void InitializeScavengerLoot() + { + int white = ItemID.WhitePearl; + int black = ItemID.BlackPearl; + int pink = ItemID.PinkPearl; + int minBlock = 6; + int maxBlock = 17; + float coralBlockChance = 0.1f; + + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ModContent.ItemType(), minBlock, maxBlock, coralBlockChance); + AddScavengerItem(white, ItemID.WoodenCrate, 1, () => !Main.hardMode, 0.1f); + AddScavengerItem(white, ItemID.WoodenCrateHard, 1, () => Main.hardMode, 0.1f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.1f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.1f); + AddScavengerItem(white, ItemID.ScarabBomb, 3, 10, 0.1f); + AddScavengerItem(white, ItemID.Coral, 3, 10, 0.2f); + AddScavengerItem(white, ItemID.Starfish, 3, 10, 0.2f); + AddScavengerItem(white, ItemID.Seashell, 3, 10, 0.2f); + // Critters. Golds, Radiants, Pearlpods and any Basalt Gully/Timeless Shore critters are to be excluded + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.05f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.01f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.02f); + + AddScavengerItem(black, ModContent.ItemType(), 1, () => !Main.hardMode, 0.1f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.PirateMap, 1, () => Main.hardMode, 0.05f); + AddScavengerItem(black, ItemID.IronCrate, 1, () => !Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.IronCrateHard, 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.GoldenCrate, 1, () => !Main.hardMode, 0.02f); + AddScavengerItem(black, ItemID.GoldenCrateHard, 1, () => Main.hardMode, 0.02f); + AddScavengerItem(black, ItemID.WaterWalkingBoots, 1, 0.05f); + AddScavengerItem(black, ItemID.JellyfishNecklace, 1, 0.05f); + AddScavengerItem(white, ModContent.ItemType(), 1, 0.05f); + //AddScavengerItem(black, ItemID.Nachos, 1, 0.05f); insert food item + AddScavengerItem(black, ModContent.ItemType(), 1, () => DownedBossSystem.downedDesertScourge, 0.3f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => DownedBossSystem.downedDesertScourge, 0.3f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ModContent.ItemType(), 1, () => Main.hardMode, 0.1f); + AddScavengerItem(black, ItemID.FinWings, 1, () => Main.hardMode, 0.1f); + + AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + AddScavengerItem(pink, ModContent.ItemType(), 1); + AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + //AddScavengerItem(pink, ModContent.ItemType(), 1); + AddScavengerItem(white, ModContent.ItemType(), 1, () => Main.hardMode); + AddScavengerItem(white, ModContent.ItemType(), 1, () => Main.hardMode); + + ScavengerLoot[ItemID.GalaxyPearl] = ScavengerLoot[white]; // Gives 1-2x the amount of white items + ScavengerLoot[ModContent.ItemType()] = ScavengerLoot[pink]; // Gives 2 pink items + + } + + #region Loot adding methods + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// The minimum amount to drop + /// The maximum amount to drop + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int min, int max, float weight = 1) + { + AddScavengerItem(currency, itemID, min, max, () => true, weight); + } + + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// How much should drop + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int amount, float weight = 1) + { + AddScavengerItem(currency, itemID, amount, amount, () => true, weight); + } + + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// How much should drop + /// A condition + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int amount, Func condition, float weight = 1) + { + AddScavengerItem(currency, itemID, amount, amount, condition, weight); + } + + /// + /// Adds an item to the Scavenger's loot pool + /// + /// The item type required to be traded + /// The loot item + /// The minimum amount to drop + /// The maximum amount to drop + /// A condition + /// The weight of the item drop. Lower numbers means lower chances + public static void AddScavengerItem(int currency, int itemID, int min, int max, Func condition, float weight = 1) + { + if (ScavengerLoot.ContainsKey(currency)) + { + ScavengerLoot[currency].Add(new ScavengerItem(itemID, min, max, condition), weight); + } + else + { + ScavengerLoot.Add(currency, new WeightedRandom()); + ScavengerLoot[currency].Add(new ScavengerItem(itemID, min, max, condition), weight); + } + } + #endregion + #endregion + + public override void SetDefaults() + { + base.SetDefaults(); + NPC.damage = 20; + NPC.width = 48; + NPC.height = 48; + NPC.defense = 5; + NPC.lifeMax = 350; + NPC.aiStyle = -1; + AIType = -1; + NPC.value = Item.buyPrice(0, 0, 5, 0); + NPC.HitSound = SoundID.NPCHit38; + NPC.DeathSound = SoundID.NPCDeath1; + NPC.knockBackResist = 0.15f; + //Banner = NPC.type; + //BannerItem = ModContent.ItemType(); + NPC.chaseable = false; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = true; + NPC.Calamity().VulnerableToElectricity = true; + NPC.Calamity().VulnerableToWater = false; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] + { + new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Scavenger") + }); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + NPC.localAI[0] = reader.ReadSingle(); + NPC.localAI[1] = reader.ReadSingle(); + NPC.localAI[2] = reader.ReadSingle(); + NPC.Calamity().newAI[0] = reader.ReadSingle(); + NPC.Calamity().newAI[1] = reader.ReadSingle(); + NPC.Calamity().newAI[2] = reader.ReadSingle(); + } + + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(NPC.localAI[0]); + writer.Write(NPC.localAI[1]); + writer.Write(NPC.localAI[2]); + writer.Write(NPC.Calamity().newAI[0]); + writer.Write(NPC.Calamity().newAI[1]); + writer.Write(NPC.Calamity().newAI[2]); + } + + public override void AI() + { + // Check to make sure the target item still exists + if (HeldItemIndex > 0) + { + Item targetItem = Main.item[HeldItemIndex]; + // If the item doesn't exist, reset its held item + if (targetItem == null || !targetItem.active) + { + HeldItemIndex = -1; + } + } + + // Initialize its direction + if (NPC.direction == 0) + NPC.direction = Main.rand.NextBool() ? -1 : 1; + + switch (Phase) + { + // Do idle stuff, actual behavior not determined rn + case (int)PhaseType.Idle: + { + // Decide if it should walk or sit + float movementSpeed = CurrentPrey != null || CurrentPredator != null ? 2 : 1; + bool startMovement = false; + if (WalkTimer <= 0) + { + WalkTimer = Main.rand.Next(180, 340); + WalkOrStand = WalkOrStand <= 0 ? 1 : -1; + if (WalkOrStand == 1 && Main.rand.NextBool() && CurrentPrey == null) + { + NPC.direction *= -1; + } + if (CurrentPrey != null) + { + NPC.direction = (int)(CurrentPrey.Center.X - NPC.Center.X); + } + startMovement = true; + } + bool lookingAtPredator = CurrentPredator != null && NPC.direction == Math.Sign(CurrentPredator.Center.X - NPC.Center.X); + bool waterCheck = WaterCheck(16); + // If it bumps into something, jump or turn around + if ((!startMovement && TurnTimer <= 0 && (NPC.velocity.X == 0 || waterCheck) && WalkOrStand == 1) || lookingAtPredator) + { + // Jump if there are a couple tiles and a space above + if (!waterCheck && JumpCheck() && NPC.velocity.Y == 0 && !lookingAtPredator) + { + NPC.velocity.Y -= 7; + NPC.velocity.X = movementSpeed * NPC.direction; + WalkOrStand = 1; + TurnTimer = 10; + } + // Turn around if it can't jump up or a pit/water is in the way + else + { + NPC.direction *= -1; + TurnTimer = 30; + } + } + // Move + if (!NPC.justHit) + { + if (WalkOrStand == 1) + NPC.velocity.X = MathHelper.Lerp(NPC.velocity.X, NPC.direction * movementSpeed, 0.05f); + else if (NPC.velocity.Y == 0) + NPC.velocity.X *= 0.95f; + } + else if (WalkOrStand == -1) + { + WalkTimer = 0; + if (CurrentPredator != null) + { + WalkOrStand = 1; + WalkTimer = Main.rand.Next(180, 340); + } + } + CalamityUtils.StepUpBlocks(NPC); + + // If the trade timer is 0 and the crab isn't looking ofr an item, look for an item + if (TradeTimer >= 0 && HeldItemIndex <= -1 && CurrentPredator == null) + { + float curDist = 0; + bool superRare = false; + foreach (Item i in Main.ActiveItems) + { + if (!i.active) + continue; + if (i.beingGrabbed) + continue; + float distance = i.Distance(NPC.Center); + if (distance > 460) + continue; + if (!NPC.HasSight(i.Center)) + continue; + if (Math.Abs(NPC.Center.Y - i.Center.Y) > 100) + continue; + + // Check if the item is a valid currency and is the closest possible currency + if (ScavengerLoot.ContainsKey(i.type)) + { + if (distance < curDist || curDist == 0) + { + HeldItemIndex = i.whoAmI; + superRare = i.type > ItemID.PinkPearl ? true : false; + } + curDist = distance; + } + } + // If an item was found, go after it + if (curDist != 0) + { + NPC.netUpdate = true; + Phase = (int)PhaseType.FoundItem; + TurnTimer = 0; + WalkTimer = 0; + if (NPC.velocity.Y == 0) + NPC.velocity.Y = -5; + NPC.direction = NPC.DirectionTo(Main.item[HeldItemIndex].Center).X.DirectionalSign(); + + SoundEngine.PlaySound(SoundID.NPCHit51 with { Pitch = -0.4f }, NPC.Center); + + EmoteExpressionParticle.EmoteType eType = superRare ? EmoteExpressionParticle.EmoteType.DoubleExclamation : EmoteExpressionParticle.EmoteType.Exclamation; + + var emoteDirection = -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(2f, 3f); + Particle emote = new EmoteExpressionParticle( + NPC.Center + emoteDirection * 2f, + emoteDirection, + 2.2f, + Color.YellowGreen, + Main.rand.Next(30, 46), + eType); + GeneralParticleHandler.SpawnParticle(emote); + } + } + // Increment the trade timer back to zero if it is below zero + if (TradeTimer < 0) + TradeTimer++; + } + break; + // Go to the item + case (int)PhaseType.FoundItem: + { + // If the item is no longer valid, go back to idle behaviour + if (HeldItemIndex <= -1 || CurrentPredator != null) + { + NPC.netUpdate = true; + Phase = (int)PhaseType.Idle; + HeldItemIndex = -1; + TurnTimer = 0; + WalkTimer = 0; + return; + } + + // If the item is suddenly no longer valid for some reason, go back to idle behaviur + Item targetItem = Main.item[HeldItemIndex]; + if (!targetItem.active || !ScavengerLoot.ContainsKey(targetItem.type)) + { + NPC.netUpdate = true; + targetItem.noGrabDelay = 0; + HeldItemIndex = -1; + NPC.velocity = Vector2.Zero; + Phase = (int)PhaseType.Idle; + TurnTimer = 0; + WalkTimer = 0; + break; + } + + // Once the jump anim is done, go to the pearl + if (WalkTimer > 0) + { + float movementSpeed = 3; + bool waterCheck = WaterCheck(16); + // If it bumps into something, jump or turn around + if (TurnTimer <= 0 && (NPC.velocity.X == 0 || waterCheck) && NPC.velocity.Y == 0) + { + // Jump if there are a couple tiles and a space above + if (!waterCheck && JumpCheck()) + { + NPC.velocity.Y -= 8; + NPC.velocity.X = movementSpeed * NPC.direction; + TurnTimer = 10; + } + // Turn around if it can't jump up or a pit/water is in the way + else + { + NPC.direction *= -1; + TurnTimer = 30; + NPC.netUpdate = true; + targetItem.noGrabDelay = 0; + HeldItemIndex = -1; + Phase = (int)PhaseType.Idle; + TurnTimer = 0; + WalkTimer = 0; + } + } + // Change direction if the item position changed + bool itemOnRight = targetItem.Center.X > NPC.Center.X; + if (itemOnRight && NPC.direction == -1) + { + NPC.direction *= -1; + } + else if (!itemOnRight && NPC.direction == 0) + { + NPC.direction *= -1; + } + TurnTimer--; + + NPC.velocity.X = NPC.direction * movementSpeed; + CalamityUtils.StepUpBlocks(NPC); + } + // While the jump animation is occurring, slow down horizontally + else + { + NPC.velocity.X *= 0.95f; + } + // Marks if the jump animation is finished + if (NPC.velocity.Y == 0) + { + WalkTimer++; + } + + // Pull the item if close enough + if (targetItem.Distance(NPC.Center) < 120) + { + targetItem.noGrabDelay = 10000; + targetItem.velocity = targetItem.DirectionTo(NPC.Center) * 5; + } + // Grab the item if close enough + if (targetItem.Distance(NPC.Center) < 10) + { + NPC.netUpdate = true; + Phase = (int)PhaseType.Bartering; + // If the item's stack is 1, despawn the item. Otherwise decrement its stack by 1. + if (targetItem.stack == 1) + targetItem.active = false; + else + targetItem.stack--; + // Set the crab's held item type + HeldItemType = targetItem.type; + TurnTimer = 0; + WalkTimer = 0; + } + } + break; + // Ponder the held item then give a reward back + case (int)PhaseType.Bartering: + { + if (CurrentPredator != null) + { + Item.NewItem(NPC.GetSource_FromThis(), NPC.getRect(), HeldItemType); + + NPC.netUpdate = true; + HeldItemIndex = -1; + Phase = (int)PhaseType.Idle; + TurnTimer = 0; + WalkTimer = 0; + OldItemType = 0; + StackMin = 0; + StackMax = 0; + + SoundEngine.PlaySound(SoundID.NPCHit51 with { Pitch = -0.3f }, NPC.Center); + + EmoteExpressionParticle.EmoteType eType = EmoteExpressionParticle.EmoteType.Exclamation; + + var emoteDirection = -Vector2.UnitY.RotatedByRandom(MathHelper.PiOver4) * Main.rand.NextFloat(2f, 3f); + Particle emote = new EmoteExpressionParticle( + NPC.Center + emoteDirection * 2f, + emoteDirection, + 2.2f, + Color.Red, + Main.rand.Next(30, 46), + eType); + GeneralParticleHandler.SpawnParticle(emote); + return; + } + NPC.velocity.X *= NPC.velocity.Y != 0 ? 0.96f : 0.9f; + TradeTimer++; + // Calculate the reward + if (TradeTimer == 132) + { + NPC.netUpdate = true; + OldItemType = HeldItemType; + HeldItemType = CalculateReward(out int min, out int max); + StackMin = min; + StackMax = max; + } + + // After some time, spit out a reward and go back to idle with a cooldown + if (TradeTimer > 160) + { + NPC.netUpdate = true; + HeldItemIndex = -1; + Phase = (int)PhaseType.Idle; + // This timer increments during its idle phase so it's set to a negative value + // Once the value hits zero, the crab will be able to trade again + TradeTimer = -CalamityUtils.SecondsToFrames(8); + + // Spawn the reward + if (HeldItemType > 0) + { + float stackMult = 1; + int dropAmt = 1; + if (ContentSamples.ItemsByType[HeldItemType].maxStack > 1) + { + if (OldItemType == ModContent.ItemType()) + stackMult *= 2; + if (OldItemType == ItemID.GalaxyPearl) + stackMult *= Main.rand.NextFloat(1.2f, 2f); + } + else + { + if (OldItemType == ModContent.ItemType()) + dropAmt *= 2; + if (OldItemType == ItemID.GalaxyPearl) + dropAmt *= 2; + } + for (int i = 0; i < dropAmt; i++) + { + SpawnItem(HeldItemType, stackMult); + } + } + HeldItemType = 0; + OldItemType = 0; + StackMin = 0; + StackMax = 0; + } + } + break; + } + + if (Phase != (int)PhaseType.FoundItem && WalkTimer > 0) + WalkTimer--; + + if (TurnTimer > 0) + TurnTimer--; + + NPC.spriteDirection = NPC.direction; + } + + public void SpawnItem(int ID, float stackMult = 1f) + { + int stack = 1; + if (NPC.localAI[0] != NPC.localAI[1]) + { + stack = Main.rand.Next((int)NPC.localAI[0], (int)NPC.localAI[1] + 1); + } + stack = (int)(stack * stackMult); + int i = Item.NewItem(NPC.GetSource_FromThis(), new Rectangle((int)NPC.Center.X + NPC.direction * 20, (int)NPC.Center.Y - 20, NPC.width, NPC.height), ID, Stack: stack); + Main.item[i].velocity = new Vector2(NPC.direction * Main.rand.NextFloat(3.7f, 4.3f), -Main.rand.NextFloat(-1.2f, 0.8f)); + } + + // Checks if the horizontal position in front of it has water or is a pit so that the crab can avoid it + public bool WaterCheck(int height) + { + Point startPos = NPC.direction == 1 ? NPC.Right.ToTileCoordinates() : NPC.Left.ToTileCoordinates(); + for (int i = 1; i < height; i++) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(startPos.X + NPC.direction, startPos.Y + i); + Tile above = CalamityUtils.ParanoidTileRetrieval(startPos.X + NPC.direction, startPos.Y + i - 1); + // If there's a tile, wegud + if (t.HasTile) + return false; + // If there's liquid or a pit, we not gud + if (t.LiquidAmount > 0 && !above.HasTile) + return true; + + } + return true; + } + + // Checks if the horizontal position in front of the crab can be jumped up + public bool JumpCheck() + { + Point startPos = NPC.direction == 1 ? NPC.BottomRight.ToTileCoordinates() : NPC.BottomLeft.ToTileCoordinates(); + bool canJump = false; + int add = NPC.direction == 1 ? 0 : -1; + int jumpHeight = 6; + for (int i = jumpHeight; i > 0; i--) + { + Tile t = CalamityUtils.ParanoidTileRetrieval(startPos.X + add, startPos.Y - i); + // If there are tiles obfuscating the jump position, return false + if (i > (jumpHeight - 2) && t.HasTile) + return false; + // If there is a tile to jump on, return true + if (t.HasTile) + { + canJump = true; + break; + } + } + return canJump; + } + + public int CalculateReward(out int min, out int max) + { + min = 0; + max = 0; + // Make sure the held item type is valid + if (ScavengerLoot.TryGetValue(HeldItemType, out WeightedRandom value)) + { + // If the held item has no roll value, immediately return + if (value == null) + return 0; + + int tries = 100; + for (int i = 0; i < tries; i++) + { + var v = value.Get(); + if (v.condition.Invoke()) + { + min = v.minimum; + max = v.maximum; + return v.itemID; + } + } + + return 0; + } + else + { + return 0; + } + } + + public static bool IsPassableTile(int x, int y) + { + return (!Main.tile[x, y].HasUnactuatedTile || + !Main.tileSolid[(int)Main.tile[x, y].TileType] || Main.tileSolidTop[(int)Main.tile[x, y].TileType]); + } + + public void StepUp() + { + Vector2 position = NPC.position; + position.X += NPC.velocity.X; + int x = (int)((position.X + (float)(NPC.width / 2) + (float)((NPC.width / 2 + 1)) * NPC.direction) / 16f); + int y = (int)((position.Y + (float)NPC.height - 1f) / 16f); + + if ((float)(x * 16) >= position.X + (float)NPC.width || (float)(x * 16 + 16) <= position.X) + return; + + bool nextTileValid = Main.tile[x, y].HasUnactuatedTile && !Main.tile[x, y].TopSlope && !Main.tile[x, y - 1].TopSlope && Main.tileSolid[(int)Main.tile[x, y].TileType] && !Main.tileSolidTop[(int)Main.tile[x, y].TileType]; + bool aboveTileHalfBlock = Main.tile[x, y - 1].IsHalfBlock && Main.tile[x, y - 1].HasUnactuatedTile; + bool aboveTileHasRoom = Main.tile[x, y - 1].IsHalfBlock && IsPassableTile(x, y - 4); + bool aboveTileEmpty = !Main.tile[x, y - 1].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x, y - 1].TileType] || Main.tileSolidTop[(int)Main.tile[x, y - 1].TileType] || aboveTileHasRoom; + bool tile3AbovePassable = !Main.tile[x - NPC.direction, y - 3].HasUnactuatedTile || !Main.tileSolid[(int)Main.tile[x - NPC.direction, y - 3].TileType]; + + if ((nextTileValid || aboveTileHalfBlock) && aboveTileEmpty && IsPassableTile(x, y - 2) && IsPassableTile(x, y - 3) && tile3AbovePassable) + { + float npcBottom = (float)(y * 16); + if (Main.tile[x, y].IsHalfBlock) + { + npcBottom += 8f; + } + if (Main.tile[x, y - 1].IsHalfBlock) + { + npcBottom -= 8f; + } + if (npcBottom < position.Y + (float)NPC.height) + { + float percentageTileRisen = position.Y + (float)NPC.height - npcBottom; + if (percentageTileRisen <= 16.1f) + { + NPC.gfxOffY += NPC.position.Y + (float)NPC.height - npcBottom; + NPC.position.Y = npcBottom - (float)NPC.height; + if (percentageTileRisen < 9f) + { + NPC.stepSpeed = 1f; + } + else + { + NPC.stepSpeed = 2f; + } + } + } + } + } + + public override void FindFrame(int frameHeight) + { + float frameCount = Main.npcFrameCount[Type] - 1; + + if (ShouldUseWalkingFrames) + frameCount = 5; + else if (ShouldUseInspectionFrames) + frameCount = 23; + else if (ShouldUseGivingFrames) + frameCount = 12; + + NPC.frameCounter++; + if (NPC.frameCounter > 6) + { + NPC.frame.Y++; + NPC.frameCounter = 0; + } + + // Reset frame when transitioning to giving animation + if (NPC.frame.Y >= frameCount || (Phase == (int)PhaseType.Bartering && TradeTimer == 80)) + { + NPC.frame.Y = 0; + NPC.frameCounter = 0; + } + } + + public override bool CanBeHitByNPC(NPC attacker) => PredatorIDs.Contains(attacker.type); + + public override float SpawnChance(NPCSpawnInfo spawnInfo) + { + if (spawnInfo.Player.Calamity().ZoneTimelessShores && !spawnInfo.Water && !spawnInfo.Player.Calamity().clamity) + { + return SpawnCondition.Cavern.Chance * 0.4f; + } + return 0f; + + //fuck this + //if (spawnInfo.Player.Calamity().ZoneSunkenSeaShores && !spawnInfo.Player.Calamity().clamity && tile.WallType == ModContent.WallType()) + //{ + // return 0.05f; + //} + //return 0f; + } + + public override void HitEffect(NPC.HitInfo hit) + { + for (int k = 0; k < 2; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, Color.DarkGray * 0.2f, 1f); + } + if (NPC.life <= 0) + { + for (int k = 0; k < 10; k++) + { + Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, hit.HitDirection, -1f, 0, Color.DarkGray * 0.2f, 1f); + } + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + SpriteEffects spriteEffects = SpriteEffects.None; + if (NPC.spriteDirection == 1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Texture2D texture = TextureAssets.Npc[NPC.type].Value; + int frameCount = Main.npcFrameCount[Type]; + float extraPosOffset = 0; + if (ShouldUseWalkingFrames) + { + texture = walkTexture.Value; + frameCount = 6; + } + else if (ShouldUseInspectionFrames) + { + texture = inspectTexture.Value; + frameCount = 24; + extraPosOffset = 6; + } + else if (ShouldUseGivingFrames) + { + texture = giveTexture.Value; + frameCount = 13; + } + Vector2 origin = new Vector2(texture.Width / 2, texture.Height / frameCount / 2); + Vector2 npcOffset = NPC.Center - screenPos + Vector2.UnitY * extraPosOffset; + npcOffset -= new Vector2(texture.Width, texture.Height / frameCount) * NPC.scale / 2f; + npcOffset += origin * NPC.scale + new Vector2(0f, NPC.gfxOffY); + spriteBatch.Draw(texture, npcOffset, texture.Frame(1, frameCount, 0, NPC.frame.Y), NPC.GetAlpha(drawColor), NPC.rotation, origin, NPC.scale, spriteEffects, 0f); + + // my dreams devoured + // legacy code for visually holding an item + /*Texture2D item = TextureAssets.Item[HeldItemType].Value; + Vector2 itemOffset = new Vector2(NPC.direction == 1 ? 8 : -8, 20); + if (TradeTimer < 80) + spriteBatch.Draw(item, npcOffset + itemOffset, null, drawColor, 0, new Vector2(item.Width / 2, item.Height), 1f, spriteEffects, 0); + */ + return false; + } + } +} diff --git a/NPCs/SunkenSea/Scavenger.png b/NPCs/SunkenSea/Scavenger.png new file mode 100644 index 0000000000..7e3f646f0d Binary files /dev/null and b/NPCs/SunkenSea/Scavenger.png differ diff --git a/NPCs/SunkenSea/ScavengerGiving.png b/NPCs/SunkenSea/ScavengerGiving.png new file mode 100644 index 0000000000..cd08777d65 Binary files /dev/null and b/NPCs/SunkenSea/ScavengerGiving.png differ diff --git a/NPCs/SunkenSea/ScavengerInspecting.png b/NPCs/SunkenSea/ScavengerInspecting.png new file mode 100644 index 0000000000..7db93e9712 Binary files /dev/null and b/NPCs/SunkenSea/ScavengerInspecting.png differ diff --git a/NPCs/SunkenSea/ScavengerWalking.png b/NPCs/SunkenSea/ScavengerWalking.png new file mode 100644 index 0000000000..229cc451c6 Binary files /dev/null and b/NPCs/SunkenSea/ScavengerWalking.png differ diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 2ab010ca66..6849d231a9 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -2267,7 +2267,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas GeneralParticleHandler.SpawnParticle(spark2); } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && attackPause == 0) { Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, gigablastDamage, 0f, Main.myPlayer, 0f, 2f); NPC.netUpdate = true; @@ -2286,7 +2286,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas GeneralParticleHandler.SpawnParticle(spark2); } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && attackPause == 0) { Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawn, projectileVelocity, randomShot, fireblastDamage, 0f, Main.myPlayer, 0f, 2f); NPC.netUpdate = true; @@ -2308,7 +2308,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas GeneralParticleHandler.SpawnParticle(orb); } - if (Main.netMode != NetmodeID.MultiplayerClient) + if (Main.netMode != NetmodeID.MultiplayerClient && attackPause == 0) { float projectileVelocityToPass = projectileVelocity.Length() * 1.3f; Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, j / (float)(numProj - 1))); @@ -3556,7 +3556,9 @@ namespace CalamityMod.NPCs.SupremeCalamitas float _ = 0f; bool collidingWithShield = Collision.CheckAABBvLineCollision(target.TopLeft, target.Size, shieldTop, shieldBottom, 64f, ref _) && shieldOpacity > 0.55f; - return collidingWithShield || NPC.Hitbox.Intersects(target.Hitbox); + // CIT 16MAY2025: SCal must have contact damage set on the first frame to preserve difficulty mode stat scaling, sometimes leading to people getting hit if on top of her. + // Thus, also check if the arena has spawned, since that will not be true on the first frame. + return (collidingWithShield || NPC.Hitbox.Intersects(target.Hitbox)) && spawnArena; } public override void FindFrame(int frameHeight) diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs index e981b3ac3c..ddaa634383 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/DeerclopsAI.cs @@ -16,8 +16,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { public static bool shouldDrawEnrageBorder = true; public static bool hasTargetBeenInRange = true; - public const float increaseDRTriggerDistance = 750f; - public const float maxDRIncreaseDistance = 1200f; + public const float IncreaseDRTriggerDistance = 750f; + public const float MaxDRIncreaseDistance = 1200f; public static float borderDelay = 10f * 60f; public static float innerBorder = 750f; public static float outerBorder = 1200f; @@ -60,8 +60,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses // Damage resistance based on distance from target float distanceFromTarget = npc.Distance(targetData.Center); - bool triggerDRIncrease = distanceFromTarget >= increaseDRTriggerDistance; - float resistDamageAmount = MathHelper.Clamp((distanceFromTarget - increaseDRTriggerDistance) / (maxDRIncreaseDistance - increaseDRTriggerDistance), 0f, 1f); + bool triggerDRIncrease = distanceFromTarget >= IncreaseDRTriggerDistance; + float resistDamageAmount = MathHelper.Clamp((distanceFromTarget - IncreaseDRTriggerDistance) / (MaxDRIncreaseDistance - IncreaseDRTriggerDistance), 0f, 1f); npc.localAI[3] = MathHelper.Lerp(0f, 30f, resistDamageAmount); float dustAndDRScalar = Utils.Remap(npc.localAI[3], 0f, 30f, 0f, 1f); calamityGlobalNPC.DR = MathHelper.Lerp(0.05f, 0.9f, dustAndDRScalar); @@ -85,14 +85,14 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (borderDelay > 120f) borderDelay = 120f; } - if (innerBorder != increaseDRTriggerDistance || maxDRIncreaseDistance != outerBorder) + if (innerBorder != IncreaseDRTriggerDistance || MaxDRIncreaseDistance != outerBorder) { // Adjust the border IF the new value is lower (helps prevent jumping if you enter the border early while it's on screen but not finished zooming in) var LerpValue = Utils.GetLerpValue(hasTargetBeenInRange ? 120f : 180f, 0f, borderDelay, true); - var newInner = MathHelper.Lerp(maxDRIncreaseDistance * 5f, increaseDRTriggerDistance, LerpValue); + var newInner = MathHelper.Lerp(MaxDRIncreaseDistance * 5f, IncreaseDRTriggerDistance, LerpValue); if (newInner < innerBorder) innerBorder = newInner; - var newOuter = MathHelper.Lerp(maxDRIncreaseDistance * 5f, maxDRIncreaseDistance, LerpValue); + var newOuter = MathHelper.Lerp(MaxDRIncreaseDistance * 5f, MaxDRIncreaseDistance, LerpValue); if (newOuter < outerBorder) outerBorder = newOuter; } @@ -127,9 +127,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.homeTileX = (int)npc.ai[2]; npc.homeTileY = (int)npc.ai[3]; - // Spawn Shadow Hands - if (Main.netMode != NetmodeID.MultiplayerClient) - SpawnPassiveShadowHands(npc, lifeRatio, shadowHand, shadowHandDamage, death); + // Spawn Shadow Hands if the player enters the shadows + if (Main.netMode != NetmodeID.MultiplayerClient && hasTargetBeenInRange) + SpawnBorderShadowHands(npc, lifeRatio, shadowHand, shadowHandDamage, death); // AI states switch ((int)npc.ai[0]) @@ -167,46 +167,69 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 distanceFromTarget2 = closestTargetPoint - relativeCenter; (closestTargetPoint - npc.Center).Length(); float distanceCheckMultiplier = 0.6f; + bool useFrontIceSpikeAttack = Math.Abs(distanceFromTarget2.X) >= Math.Abs(distanceFromTarget2.Y) * distanceCheckMultiplier || distanceFromTarget2.Length() < 48f; bool useEitherIceSpikeAttack = distanceFromTarget2.Y <= (float)(100 + targetData.Height) && distanceFromTarget2.Y >= -200f; - if (Math.Abs(distanceFromTarget2.X) < 120f && useEitherIceSpikeAttack && npc.velocity.Y == 0f && npc.localAI[1] >= 2f) + + // Can only use ice spikes a maximum of twice in a row before doing something else + float iceSpikeAttackLimit = 2f; + bool doNotUseIceSpikes = calamityGlobalNPC.newAI[1] >= iceSpikeAttackLimit; + if (!doNotUseIceSpikes) { - npc.velocity.X = 0f; - npc.ai[0] = 4f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] -= 1f; - npc.SyncExtraAI(); - npc.netUpdate = true; - break; + // Deerclops must be this close to its target on the X axis to do the ice spike attack + // This distance increases at lower HP because the ice spikes get bigger + float iceSpikesDistanceGateValue = 120f + MathHelper.Lerp(0f, 120f, 1f - lifeRatio); + if (Math.Abs(distanceFromTarget2.X) < iceSpikesDistanceGateValue && useEitherIceSpikeAttack && npc.velocity.Y == 0f && npc.localAI[1] >= 2f) + { + npc.velocity.X = 0f; + npc.ai[0] = 4f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] -= 1f; + calamityGlobalNPC.newAI[1] += 1f; + npc.SyncExtraAI(); + npc.netUpdate = true; + break; + } + + if (Math.Abs(distanceFromTarget2.X) < iceSpikesDistanceGateValue && useEitherIceSpikeAttack && npc.velocity.Y == 0f && useFrontIceSpikeAttack) + { + npc.velocity.X = 0f; + npc.ai[0] = 1f; + npc.ai[1] = 0f; + npc.localAI[1] += 1f; + calamityGlobalNPC.newAI[0] -= 1f; + calamityGlobalNPC.newAI[1] += 1f; + npc.SyncExtraAI(); + npc.netUpdate = true; + break; + } } - if (Math.Abs(distanceFromTarget2.X) < 120f && useEitherIceSpikeAttack && npc.velocity.Y == 0f && useFrontIceSpikeAttack) + // Can only use rubble a maximum of thrice in a row before doing something else + // This also takes into account the ice spike limit + float rubbleAttackLimit = 3f; + bool doNotUseRubble = calamityGlobalNPC.newAI[1] >= rubbleAttackLimit; + float rubbleGateValue = death ? 160f : 200f; + if (!doNotUseRubble) { - npc.velocity.X = 0f; - npc.ai[0] = 1f; - npc.ai[1] = 0f; - npc.localAI[1] += 1f; - calamityGlobalNPC.newAI[0] -= 1f; - npc.SyncExtraAI(); - npc.netUpdate = true; - break; + bool useRubbleAttack = npc.ai[1] >= rubbleGateValue; + if (npc.velocity.Y == 0f && npc.velocity.X != 0f && useRubbleAttack) + { + npc.velocity.X = 0f; + npc.ai[0] = 2f; + npc.ai[1] = 0f; + npc.localAI[1] = 0f; + calamityGlobalNPC.newAI[0] -= 1f; + calamityGlobalNPC.newAI[1] += 1f; + npc.SyncExtraAI(); + npc.netUpdate = true; + break; + } } - bool useRubbleAttack = npc.ai[1] >= 240f; - if (npc.velocity.Y == 0f && npc.velocity.X != 0f && useRubbleAttack) - { - npc.velocity.X = 0f; - npc.ai[0] = 2f; - npc.ai[1] = 0f; - npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] -= 1f; - npc.SyncExtraAI(); - npc.netUpdate = true; - break; - } - - bool useShadowHandAttack = npc.ai[1] >= 90f; + float shadowHandGateValue = death ? 60f : 75f; + bool useShadowHandAttack = npc.ai[1] >= shadowHandGateValue; if (npc.velocity.Y == 0f && npc.velocity.X == 0f && useShadowHandAttack) { npc.velocity.X = 0f; @@ -214,24 +237,34 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.ai[1] = 0f; npc.localAI[1] = 0f; calamityGlobalNPC.newAI[0] -= 1f; + calamityGlobalNPC.newAI[1] = 0f; npc.SyncExtraAI(); npc.netUpdate = true; break; } // This replaced the slow debuff infliction - bool useSecondShadowHandAttack = npc.ai[1] >= 120f; + // Must use 4 different attacks before being able to use this attack again + float secondShadowHandAttackCooldown = 4f; + float secondShadowHandGateValue = death ? 80f : 100f; + bool useSecondShadowHandAttack = npc.ai[1] >= secondShadowHandGateValue; if (npc.velocity.Y == 0f && useSecondShadowHandAttack && Math.Abs(distanceFromTarget2.X) > 100f && calamityGlobalNPC.newAI[0] <= 0f) { npc.velocity.X = 0f; npc.ai[0] = 3f; npc.ai[1] = 0f; npc.localAI[1] = 0f; - calamityGlobalNPC.newAI[0] = 5f; + calamityGlobalNPC.newAI[0] = secondShadowHandAttackCooldown; + calamityGlobalNPC.newAI[1] = 0f; npc.SyncExtraAI(); npc.netUpdate = true; } + // If Deerclops has been taking a while to attack, stop moving on the X axis to force a shadow hand attack + float haltMovementGateValue = doNotUseRubble ? (secondShadowHandGateValue + 20f) : doNotUseIceSpikes ? (rubbleGateValue + 20f) : 240f; + if (distanceFromTarget2.Length() < IncreaseDRTriggerDistance) + haltMovement = npc.ai[1] >= haltMovementGateValue; + break; // Create spikes in front of Deerclops @@ -314,7 +347,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.TargetClosest(); if (Main.netMode != NetmodeID.MultiplayerClient) { - int totalProjectiles = (death ? 7 : 5) + (int)MathHelper.Lerp(0f, 11f, 1f - lifeRatio); + int totalProjectiles = (death ? 11 : 9) + (int)MathHelper.Lerp(0f, 7f, 1f - lifeRatio); float velocityMultIncrement = ((totalProjectiles + 1) / (float)totalProjectiles) - 1f; float randomRadialOffset = MathHelper.ToRadians(MathHelper.Lerp(0f, death ? 270f : 180f, 1f - lifeRatio)); float radians = MathHelper.TwoPi / totalProjectiles + randomRadialOffset; @@ -324,7 +357,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { Vector2 actualVelocity = spinningPoint.RotatedBy(radians * k); float velocityMultiplier = 1f - k * velocityMultIncrement; - Projectile.NewProjectile(npc.GetSource_FromAI(), Main.player[npc.target].Center + Vector2.Normalize(actualVelocity) * 450f, actualVelocity * velocityMultiplier * -1f, shadowHand, shadowHandDamage, 0f, Main.myPlayer); + Projectile.NewProjectile(npc.GetSource_FromAI(), Main.player[npc.target].Center + Vector2.Normalize(actualVelocity) * 550f, actualVelocity * velocityMultiplier * -1f, shadowHand, shadowHandDamage, 0f, Main.myPlayer); } } } @@ -356,7 +389,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses break; - // Spawn shadow hands around the target with randomized AI + // Spawn shadow hands around the target (literally just a different variant of the other shadow hand attack with more spread and more velocity) case 5: if (npc.ai[1] == 30f) @@ -375,11 +408,17 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.TargetClosest(); if (Main.netMode != NetmodeID.MultiplayerClient) { - int handAmount = (int)MathHelper.Lerp(death ? 5f : 3f, death ? 12f : 10f, 1f - lifeRatio); - for (int i = 0; i < handAmount; i++) + int totalProjectiles = (death ? 11 : 9) + (int)MathHelper.Lerp(0f, 7f, 1f - lifeRatio); + float velocityMultIncrement = ((totalProjectiles + 1) / (float)totalProjectiles) - 1f; + float randomRadialOffset = MathHelper.ToRadians(MathHelper.Lerp(0f, death ? 360f : 270f, 1f - lifeRatio)); + float radians = MathHelper.TwoPi / totalProjectiles + randomRadialOffset; + float velocity = (death ? 10.5f : 8f) + MathHelper.Lerp(0f, 4f, 1f - lifeRatio); + Vector2 spinningPoint = new Vector2(0f, -velocity); + for (int k = 0; k < totalProjectiles; k++) { - RandomizeInsanityShadowFor(Main.player[npc.target], death, isHostile: true, out var spawnposition, out var spawnvelocity, out var ai, out var ai2); - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnposition, spawnvelocity, shadowHand, shadowHandDamage, 0f, Main.myPlayer, ai, ai2); + Vector2 actualVelocity = spinningPoint.RotatedBy(radians * k); + float velocityMultiplier = 1f - k * velocityMultIncrement; + Projectile.NewProjectile(npc.GetSource_FromAI(), Main.player[npc.target].Center + Vector2.Normalize(actualVelocity) * 550f, actualVelocity * velocityMultiplier * -1f, shadowHand, shadowHandDamage, 0f, Main.myPlayer); } } } @@ -541,9 +580,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses return false; } - private static void SpawnPassiveShadowHands(NPC npc, float lifeRatio, int shadowHand, int shadowHandDamage, bool death) + private static void SpawnBorderShadowHands(NPC npc, float lifeRatio, int shadowHand, int shadowHandDamage, bool death) { - int shadowHandSpawnRate = (int)Utils.Remap(lifeRatio, 1f, 0f, death ? 60f : 80f, death ? 30f : 40f); + int shadowHandSpawnRate = death ? 15 : 20; npc.localAI[2] += 1f; int shadowHandTimer = (int)npc.localAI[2]; if (shadowHandTimer % shadowHandSpawnRate != 0) @@ -555,85 +594,20 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses foreach (Player player in Main.ActivePlayers) { - if (npc.Boss_CanShootExtraAt(player.whoAmI, rotation % 3, 3, 1200f, alwaysSkipMainTarget: false)) + // Spawn hands to cut the player off and force them back towards Deerclops + // This only happens if the player is triggering Deerclops' increased DR + float minShadowHandSpawnDistanceFromPlayer = 360f; + float playerDistanceFromDeerclops = Vector2.Distance(npc.Center, player.Center); + if (playerDistanceFromDeerclops >= IncreaseDRTriggerDistance && playerDistanceFromDeerclops <= MaxDRIncreaseDistance) { - // Normal shadow hand spawn behavior - // Modified to make the shadow hand spawns fair - RandomizeInsanityShadowFor(player, death, isHostile: true, out var spawnPosition, out var spawnVelocity, out var ai, out var ai2); - - // Spawn hands to cut the player off and force them back towards Deerclops - // This only happens if the player is triggering Deerclops' increased DR - float minShadowHandSpawnDistanceFromPlayer = 450f; - float playerDistanceFromDeerclops = Vector2.Distance(npc.Center, player.Center); - if (playerDistanceFromDeerclops >= 450f) - { - spawnPosition = (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * (playerDistanceFromDeerclops + minShadowHandSpawnDistanceFromPlayer); - spawnVelocity = (player.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * spawnVelocity.Length(); - } - - Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition, spawnVelocity, shadowHand, shadowHandDamage, 0f, Main.myPlayer, ai, ai2); + Vector2 spawnPosition = npc.Center + (player.Center - npc.Center).SafeNormalize(Vector2.UnitY) * (playerDistanceFromDeerclops + minShadowHandSpawnDistanceFromPlayer); + float shadowHandVelocity = death ? 6f : 5f; + Vector2 spawnVelocity = (player.Center - spawnPosition).SafeNormalize(Vector2.UnitY) * shadowHandVelocity; + Projectile.NewProjectile(npc.GetSource_FromAI(), spawnPosition, spawnVelocity, shadowHand, shadowHandDamage, 0f, Main.myPlayer); } } } - private static void RandomizeInsanityShadowFor(Entity targetEntity, bool death, bool isHostile, out Vector2 spawnPosition, out Vector2 spawnVelocity, out float ai0, out float ai1) - { - int spawnDirection = Main.rand.NextBool() ? 1 : -1; - int shadowHandType = Main.rand.Next(4); - float spawnDistance = (isHostile ? 450f : 225f); - float velocityDivisor = (isHostile ? 30 : 20); - float velocityOffset = (isHostile ? 30 : 0); - float randomRotation = Main.rand.NextFloatDirection() * (float)Math.PI * 0.125f; - if (isHostile && targetEntity.velocity.X * (float)spawnDirection > 0f) - spawnDirection *= -1; - - if (shadowHandType == 0 && isHostile) - velocityDivisor += 10f; - - spawnPosition = targetEntity.Center + targetEntity.velocity * velocityOffset + new Vector2((float)spawnDirection * (0f - spawnDistance), 0f).RotatedBy(randomRotation); - spawnVelocity = new Vector2((float)spawnDirection * spawnDistance / velocityDivisor, 0f).RotatedBy(randomRotation); - ai0 = 0f; - ai1 = 0f; - - int velocityAdd = death ? 2 : 0; - if (shadowHandType == 1) - { - float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); - spawnPosition = targetEntity.Center - rotation.ToRotationVector2() * spawnDistance; - ai0 = 180f; - ai1 = rotation - (float)Math.PI / 2f; - spawnVelocity = rotation.ToRotationVector2() * (isHostile ? (4 + velocityAdd) : 2); - } - else if (shadowHandType == 2) - { - float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); - spawnPosition = targetEntity.Center - rotation.ToRotationVector2() * spawnDistance; - ai0 = 300f; - ai1 = rotation; - spawnVelocity = rotation.ToRotationVector2() * (isHostile ? (4 + velocityAdd) : 2); - } - else if (shadowHandType == 3) - { - float rotation = (float)Math.PI * 2f * Main.rand.NextFloat(); - float distance = (isHostile ? 150 : 75); - float spawnVelocityRotation = (float)Math.PI / 2f / distance * Main.rand.NextFloatDirection(); - spawnPosition = targetEntity.Center + targetEntity.velocity * distance; - if (Vector2.Distance(spawnPosition, targetEntity.Center) < spawnDistance) - spawnPosition = (spawnPosition - targetEntity.Center).SafeNormalize(Vector2.UnitY) * spawnDistance; - - Vector2 vector = rotation.ToRotationVector2() * (isHostile ? (8 + velocityAdd) : 3); - for (int i = 0; (float)i < distance; i++) - { - spawnPosition -= vector; - vector = vector.RotatedBy(0f - spawnVelocityRotation); - } - - spawnVelocity = vector; - ai0 = 390f; - ai1 = spawnVelocityRotation; - } - } - private static void ShootRubbleUp(NPC npc, ref Point sourceTileCoords, int howMany, int distancedByThisManyTiles, int whichOne, int rubble, int rubbleDamage, float lifeRatio, bool death) { // Loop to spawn rubble @@ -657,9 +631,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses Vector2 rubbleVelocity = new Vector2(0f, -1f).RotatedBy((float)(whichOne * npc.direction) * 0.7f * ((float)Math.PI / 4f / (float)howMany)); int ai1_FrameToUse = Main.rand.Next(Main.projFrames[rubble] * 4); ai1_FrameToUse = 6 + Main.rand.Next(6); - float delay = (int)MathHelper.Lerp(death ? 8f : 10f, death ? 16f : 20f, lifeRatio); - float ai2_DelayBeforeGoingUp = whichOne * delay; - Projectile.NewProjectile(npc.GetSource_FromAI(), new Vector2(posX * 16 + 8, posY * 16 - 8), rubbleVelocity * 0.01f, rubble, rubbleDamage, 0f, Main.myPlayer, 0f, ai1_FrameToUse, ai2_DelayBeforeGoingUp); + float delay = death ? 24f : 30f; + float ai2_DelayBeforeGoingUp = (whichOne + 1) * delay; + float velocityMultiplier = MathHelper.Lerp(0.01f, 0.015f, 1f - lifeRatio); + Projectile.NewProjectile(npc.GetSource_FromAI(), new Vector2(posX * 16 + 8, posY * 16 - 8), rubbleVelocity * velocityMultiplier, rubble, rubbleDamage, 0f, Main.myPlayer, 0f, ai1_FrameToUse, ai2_DelayBeforeGoingUp); } private static void MakeSpikesForward(NPC npc, int AISLOT_PhaseCounter, NPCAimedTarget targetData, int iceSpike, int iceSpikeDamage, float lifeRatio, bool death) @@ -671,7 +646,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!(npc.ai[AISLOT_PhaseCounter] < (float)iceSpikeGateValue)) { Point sourceTileCoords = npc.Bottom.ToTileCoordinates(); - int numIceSpikes = lifeRatio < 0.5f ? 15 : 20; + int numIceSpikes = 20; int xOffsetMult = 1; sourceTileCoords.X += npc.direction * 3; int screenShakeGateValue = (int)npc.ai[AISLOT_PhaseCounter] - iceSpikeGateValue; @@ -686,12 +661,12 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (screenShakeGateValue % 4 != 0) iceSpikeLimit = iceSpikeStart; + // Ice spikes get fucking gigantic later on in the fight + float iceSpikeScaleIncrease = MathHelper.Lerp(1f, 2f, 1f - lifeRatio); for (int i = iceSpikeStart; i < iceSpikeLimit && i < numIceSpikes; i++) { - int xOffset = i * xOffsetMult; + int xOffset = (int)Math.Round(i * xOffsetMult * iceSpikeScaleIncrease); TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, i, xOffset, iceSpike, iceSpikeDamage, lifeRatio, death); - if (lifeRatio < 0.5f) - TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, i, xOffset * 2, iceSpike, iceSpikeDamage, lifeRatio, death); } } } @@ -705,7 +680,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (!(npc.ai[AISLOT_PhaseCounter] < (float)iceSpikeGateValue)) { Point sourceTileCoords = npc.Bottom.ToTileCoordinates(); - int numIceSpikes = lifeRatio < 0.5f ? 12 : 15; + int numIceSpikes = 15; int xOffsetMult = 1; int screenShakeGateValue = (int)npc.ai[AISLOT_PhaseCounter] - iceSpikeGateValue; if (screenShakeGateValue == 0) @@ -719,16 +694,13 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (screenShakeGateValue % 2 != 0) iceSpikeLimit = iceSpikeStart; + // Ice spikes get fucking gigantic later on in the fight + float iceSpikeScaleIncrease = MathHelper.Lerp(1f, 2f, 1f - lifeRatio); for (int iceSpikeIndex = iceSpikeStart; iceSpikeIndex >= 0 && iceSpikeIndex < iceSpikeLimit && iceSpikeIndex < numIceSpikes; iceSpikeIndex++) { - int xOffset = iceSpikeIndex * xOffsetMult; + int xOffset = (int)Math.Round(iceSpikeIndex * xOffsetMult * iceSpikeScaleIncrease); TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, iceSpikeDamage, lifeRatio, death); TryMakingSpike(npc, ref sourceTileCoords, -npc.direction, numIceSpikes, -iceSpikeIndex, xOffset, iceSpike, iceSpikeDamage, lifeRatio, death); - if (lifeRatio < 0.5f) - { - TryMakingSpike(npc, ref sourceTileCoords, npc.direction, numIceSpikes, -iceSpikeIndex, xOffset * 2, iceSpike, iceSpikeDamage, lifeRatio, death); - TryMakingSpike(npc, ref sourceTileCoords, -npc.direction, numIceSpikes, -iceSpikeIndex, xOffset * 2, iceSpike, iceSpikeDamage, lifeRatio, death); - } } } } @@ -741,8 +713,8 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses { Vector2 iceSpikeSpawnPos = new Vector2(posX * 16 + 8, posY * 16 - 8); Vector2 iceSpikeVelocity = new Vector2(0f, -1f).RotatedBy((float)(whichOne * dir) * 0.7f * ((float)Math.PI / 4f / (float)howMany)); - float scaleIncrease = MathHelper.Lerp(0f, 0.55f, 1f - lifeRatio); - Projectile.NewProjectile(npc.GetSource_FromAI(), iceSpikeSpawnPos, iceSpikeVelocity, iceSpike, iceSpikeDamage, 0f, Main.myPlayer, 0f, 0.1f + Main.rand.NextFloat() * 0.1f + (float)xOffset * (1.1f + scaleIncrease) / (float)howMany); + float iceSpikeScale = 0.1f + Main.rand.NextFloat() * 0.1f + (float)xOffset * 1.1f / (float)howMany; + Projectile.NewProjectile(npc.GetSource_FromAI(), iceSpikeSpawnPos, iceSpikeVelocity, iceSpike, iceSpikeDamage, 0f, Main.myPlayer, 0f, iceSpikeScale); } } @@ -833,7 +805,7 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses if (stopMoving) { - npc.velocity.X *= 0.9f; + npc.velocity.X *= 0.8f; if ((double)npc.velocity.X > -0.1 && (double)npc.velocity.X < 0.1) npc.velocity.X = 0f; } diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs index 79474e1803..eb52a49218 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/QueenBeeAI.cs @@ -207,13 +207,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses while (phase == npc.ai[1] || phase == 1 || (phase == 2 && phase4) || (death && phase6 && phase == 3)); bool charging = phase == 0; + bool stingerArcs = phase == 4; + bool beenadeVomit = phase == 5; // 5 is stinger arc and charge - if (phase == 4) + if (stingerArcs) phase = 5; // 6 is beenade vomit - if (phase == 5) + if (beenadeVomit) phase = 6; CalamityUtils.CalamityTargeting(npc, CalamityTargetingParameters.BossDefaults); @@ -317,15 +319,15 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.localAI[0] = 0f; float chargeVelocityX = (phase4 ? 24f : phase2 ? 20f : 16f) + 8f * enrageScale; float chargeVelocityY = (phase4 ? 18f : phase2 ? 15f : 12f) + 6f * enrageScale; - float chargeAccelerationX = (phase4 ? 0.9f : phase2 ? 0.7f : 0.5f) + 0.25f * enrageScale; - float chargeAccelerationY = (phase4 ? 0.45f : phase2 ? 0.35f : 0.25f) + 0.125f * enrageScale; + float chargeAccelerationX = (phase4 ? 0.7f : phase2 ? 0.6f : 0.5f) + 0.25f * enrageScale; + float chargeAccelerationY = (phase4 ? 0.35f : phase2 ? 0.3f : 0.25f) + 0.125f * enrageScale; if (death) { chargeVelocityX += 2f; chargeVelocityY += 4f; - chargeAccelerationX += 0.15f; - chargeAccelerationY += 0.3f; + chargeAccelerationX += 0.1f; + chargeAccelerationY += 0.2f; } // Velocity calculations @@ -925,11 +927,11 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.direction = playerLocation < 0 ? 1 : -1; npc.spriteDirection = npc.direction; - float beenadeAttackSpeed = 20f + 4f * enrageScale; - float beenadeAttackAccel = 0.75f; - Vector2 targetVector = Main.player[npc.target].Center + Vector2.UnitY * 240f; + float beenadeAttackSpeed = 16f + 4f * enrageScale; + float beenadeAttackAccel = 0.5f; + Vector2 targetVector = Main.player[npc.target].Center - Vector2.UnitY * 240f; - if (npc.Distance(targetVector) > 80f) + if (npc.Distance(targetVector) > 160f) npc.SimpleFlyMovement(npc.SafeDirectionTo(targetVector) * beenadeAttackSpeed, beenadeAttackAccel); else npc.velocity *= 0.8f; diff --git a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs index d182231f38..7634c94155 100644 --- a/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs +++ b/NPCs/VanillaNPCAIOverrides/Bosses/SkeletronAI.cs @@ -410,9 +410,9 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses npc.damage = 0; calamityGlobalNPC.newAI[1] += 1f; - float chargePhaseChangeRateBoost = phase5 ? (death ? 24f : 14f) : phase4 ? (death ? 8f : 6f) : ((death ? 6f : 4f) * ((1f - lifeRatio) / (1f - phase4LifeRatio))); + float chargePhaseChangeRateBoost = phase5 ? (death ? 24f : 8f) : phase4 ? (death ? 6f : 4f) : ((death ? 4.5f : 3f) * ((1f - lifeRatio) / (1f - phase4LifeRatio))); if (!handsDead) - chargePhaseChangeRateBoost *= 0.5f; + chargePhaseChangeRateBoost *= 0.25f; float chargePhaseChangeRate = chargePhaseChangeRateBoost + 1f; npc.ai[2] += chargePhaseChangeRate; @@ -494,6 +494,10 @@ namespace CalamityMod.NPCs.VanillaNPCAIOverrides.Bosses else npc.rotation = npc.velocity.X / 15f; + // Force net updates every frame during this movement to avoid despawning in multiplayer + // I'm doing this because npc.ai[2] changes every frame and that's used to calculate Skeletron's velocity here + npc.ForceNetUpdate(); + return false; } diff --git a/Particles/CustomPulse.cs b/Particles/CustomPulse.cs index cebbf59dee..31fd7a91dc 100644 --- a/Particles/CustomPulse.cs +++ b/Particles/CustomPulse.cs @@ -23,8 +23,9 @@ namespace CalamityMod.Particles private bool FadeOut; private Vector2 Squish; private Color BaseColor; + private float MakeLight; - public CustomPulse(Vector2 position, Vector2 velocity, Color color, string texture, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime, bool UseAdditiveBlend = true, float baseOpacity = 1f, bool fade = true) + public CustomPulse(Vector2 position, Vector2 velocity, Color color, string texture, Vector2 squish, float rotation, float originalScale, float finalScale, int lifeTime, bool UseAdditiveBlend = true, float baseOpacity = 1f, bool fade = true, float makeLight = 1) { Position = position; Velocity = velocity; @@ -39,6 +40,7 @@ namespace CalamityMod.Particles Squish = squish; Rotation = rotation; UseAltVisual = UseAdditiveBlend; + MakeLight = makeLight; } public override void Update() @@ -49,7 +51,8 @@ namespace CalamityMod.Particles opacity = (FadeOut ? (float)Math.Sin(MathHelper.PiOver2 + LifetimeCompletion * MathHelper.PiOver2) : 1f) * BaseOpacity; Color = BaseColor * opacity; - Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f); + if (MakeLight > 0) + Lighting.AddLight(Position, (Color.R / 255f) * MakeLight, (Color.G / 255f) * MakeLight, (Color.B / 255f) * MakeLight); Velocity *= 0.95f; } @@ -64,7 +67,6 @@ namespace CalamityMod.Particles { Texture2D joke = ModContent.Request("CalamityMod/Particles/MammothParticle").Value; scaleMult = (MathHelper.Lerp(tex.Size().X / joke.Size().X, tex.Size().Y / joke.Size().Y, 0.5f)); - Main.NewText(scaleMult); tex = joke; UseAltVisual = true; } diff --git a/Particles/GlowTriangle.png b/Particles/GlowTriangle.png new file mode 100644 index 0000000000..cdc9e2e98e Binary files /dev/null and b/Particles/GlowTriangle.png differ diff --git a/Particles/ShineExplosion1.png b/Particles/ShineExplosion1.png new file mode 100644 index 0000000000..0c288e7f05 Binary files /dev/null and b/Particles/ShineExplosion1.png differ diff --git a/Particles/ShineExplosion2.png b/Particles/ShineExplosion2.png new file mode 100644 index 0000000000..44fb3e36a6 Binary files /dev/null and b/Particles/ShineExplosion2.png differ diff --git a/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs b/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs index 73c7b4c53b..a47ffe9a87 100644 --- a/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs +++ b/Projectiles/BaseProjectiles/BaseCustomMeleeSwingProjectile.cs @@ -12,6 +12,7 @@ using Terraria.GameContent.Prefixes; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; +using Terraria.Audio; namespace CalamityMod.Projectiles.BaseProjectiles { @@ -159,6 +160,10 @@ namespace CalamityMod.Projectiles.BaseProjectiles /// Defaults to 0.5f ///
public virtual float RotateInStartup { get; set; } = 0.5f; + /// + /// What sound to use when the sword begins the actual swing (after startup frames) + /// + public virtual SoundStyle? UseSound {get; set;} = null; #endregion @@ -301,8 +306,15 @@ namespace CalamityMod.Projectiles.BaseProjectiles player.direction = -1; Projectile.spriteDirection = -1 * (int)player.gravDir; } + if (AlternateSwings && player.GetModPlayer().swingNum % 2 == 0) + { + Projectile.spriteDirection *= -1; + } swingTime = Main.player[Projectile.owner].HeldItem.useTime; Spawn(source); + StartupTime *= Projectile.MaxUpdates; + CooldownTime *= Projectile.MaxUpdates; + swingTime *= Projectile.MaxUpdates; if (useMeleeSpeed) { var speed = Main.player[Projectile.owner].GetAttackSpeed(); @@ -339,7 +351,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles { var player = Main.player[Projectile.owner]; var modplayer = player.GetModPlayer(); - float adust = MathHelper.ToRadians(45 + 180); + float adust = MathHelper.ToRadians(225); if (timer < StartupTime || timer > StartupTime + swingTime) { angle = Vector2.Lerp(angle, (player.Center - Main.MouseWorld).SafeNormalize(Vector2.One), RotateInStartup); @@ -369,16 +381,22 @@ namespace CalamityMod.Projectiles.BaseProjectiles oldProjectilePos.RemoveAt(0); } } - var angle2 = (AlternateSwings && (modplayer.swingNum % 2 == 1 ? false : true) ? SwingFunction() : -SwingFunction()); + if (inSwing && swingTimer == 1 && UseSound != null) + { + SoundEngine.PlaySound((SoundStyle)UseSound,player.Center); + } + var angle2 = (AlternateSwings && (modplayer.swingNum % 2 == 1 ? false : true) ? SwingFunction() : SwingFunction()); Projectile.Center = armCenter - (angle * OffsetDistance * (1 + (Projectile.scale - 1) * 0.75f)).RotatedBy(Projectile.spriteDirection * angle2); Projectile.rotation = angle.RotatedBy(Projectile.spriteDirection * angle2).ToRotation() + adust; AdditionalAI(); - player.itemTime = ExistsTime + 1 - timer; + player.itemTime = ExistsTime + 2 - timer; + player.itemAnimation = ExistsTime + 2 - timer; if (timer > ExistsTime) { - Projectile.Kill(); player.itemTime = 0; + player.itemAnimation = 0; + Projectile.Kill(); } timer++; if (timer >= StartupTime && timer < StartupTime + swingTime) @@ -427,7 +445,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["fireColor"].SetValue(trailColors[2].ToVector3()); - GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue((AlternateSwings && modplayer.swingNum % 2 == 1) ^ Projectile.spriteDirection == -1 ? false : true); + GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue(Projectile.spriteDirection == -1 ? false : true); GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply(); var positionsToUse = Projectile.oldPos.Take((int)MathHelper.Min(trailLength,swingTimer)).ToArray(); @@ -485,7 +503,7 @@ namespace CalamityMod.Projectiles.BaseProjectiles return; } amount += 1; - if (timer % (swingTime / amount) == 0 && timer > 0 && timer < swingTime - swingTime / amount / 2) + if (swingTimer % (swingTime / amount) == 0 && swingTimer > 0 && swingTimer < swingTime - swingTime / amount / 2) { Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, (Projectile.rotation + negate * MathHelper.ToRadians(45 - negate * 90)).ToRotationVector2() * velocity, type, (int)(Projectile.damage * damagemod), Projectile.knockBack, Projectile.owner, ai0); } diff --git a/Projectiles/Boss/CrimulanSpike.cs b/Projectiles/Boss/CrimulanSpike.cs index 17e7b62fd7..233db11b4a 100644 --- a/Projectiles/Boss/CrimulanSpike.cs +++ b/Projectiles/Boss/CrimulanSpike.cs @@ -52,9 +52,11 @@ namespace CalamityMod.Projectiles.Boss { Color dustColor = Color.Crimson; dustColor.A = 150; - int redSpiky = Dust.NewDust(Projectile.position - Projectile.velocity * 3f, Projectile.width, Projectile.height, DustID.SparksMech, 0f, 0f, 50, dustColor, 1.2f); + int redSpiky = Dust.NewDust(Projectile.position - Projectile.velocity * 3f, Projectile.width, Projectile.height, DustID.TintableDust); Main.dust[redSpiky].velocity *= 0.3f; Main.dust[redSpiky].velocity += Projectile.velocity * 0.3f; + Main.dust[redSpiky].color = dustColor; + Main.dust[redSpiky].scale = 1.4f; Main.dust[redSpiky].noGravity = true; } } @@ -72,9 +74,6 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { Texture2D texture = Projectile.ai[2] > 0f ? ModContent.Request("CalamityMod/Projectiles/Boss/CrimulanSpike" + ((int)Projectile.ai[2] + 1)).Value : TextureAssets.Projectile[Projectile.type].Value; - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1, texture); return false; } diff --git a/Projectiles/Boss/QueenBeenade.cs b/Projectiles/Boss/QueenBeenade.cs index 904fc5a5eb..4a2ff25994 100644 --- a/Projectiles/Boss/QueenBeenade.cs +++ b/Projectiles/Boss/QueenBeenade.cs @@ -10,8 +10,11 @@ namespace CalamityMod.Projectiles.Boss public class QueenBeenade : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; + public override string Texture => $"Terraria/Images/Projectile_{ProjectileID.Beenade}"; + private const int TimeLeft = 180; + public override void SetDefaults() { Projectile.Calamity().DealsDefenseDamage = true; @@ -19,7 +22,7 @@ namespace CalamityMod.Projectiles.Boss Projectile.height = 22; Projectile.hostile = true; Projectile.penetrate = -1; - Projectile.timeLeft = 180; + Projectile.timeLeft = TimeLeft; } public override void AI() @@ -47,7 +50,8 @@ namespace CalamityMod.Projectiles.Boss Projectile.velocity.Y = 16f; } - public override bool? CanDamage() => Projectile.timeLeft <= 0; + // Using 1 just in case + public override bool? CanDamage() => Projectile.timeLeft <= 1; public override bool OnTileCollide(Vector2 oldVelocity) { @@ -60,6 +64,25 @@ namespace CalamityMod.Projectiles.Boss return false; } + public override Color? GetAlpha(Color lightColor) + { + int timer = TimeLeft - Projectile.timeLeft; + float startWarningColorGateValue = 60f; + float timeToReachFullIntensity = 120f; + float timeToReachExplosion = startWarningColorGateValue + timeToReachFullIntensity; + Color initialColor = lightColor; + Color finalColor = Color.Lerp(new Color(125, 0, 0), Color.Red, (float)Math.Abs(Math.Sin((timer - startWarningColorGateValue) * (MathHelper.Pi / 45f)))); + finalColor.A = (byte)(255 - Projectile.alpha); + if (timer > startWarningColorGateValue) + { + float colorTransitionRatio = (timer - startWarningColorGateValue) / timeToReachFullIntensity; + Color explodeColor = Color.Lerp(initialColor, finalColor, colorTransitionRatio); + return explodeColor; + } + else + return initialColor; + } + public override void OnKill(int timeLeft) { int newSize = 40; diff --git a/Projectiles/Boss/QueenBeenadeBee.cs b/Projectiles/Boss/QueenBeenadeBee.cs index b4eb7d0644..489609310c 100644 --- a/Projectiles/Boss/QueenBeenadeBee.cs +++ b/Projectiles/Boss/QueenBeenadeBee.cs @@ -34,12 +34,12 @@ namespace CalamityMod.Projectiles.Boss { // Animation Projectile.frameCounter++; - if (Projectile.frameCounter > 4) + if (Projectile.frameCounter >= 3) { Projectile.frame++; Projectile.frameCounter = 0; } - if (Projectile.frame > 4) + if (Projectile.frame >= 3) Projectile.frame = 0; // Direction and rotation @@ -60,6 +60,8 @@ namespace CalamityMod.Projectiles.Boss { Projectile.ai[0] = 1f; + Projectile.tileCollide = true; + if (Projectile.velocity.Length() < Projectile.ai[2]) Projectile.velocity *= 1.05f; diff --git a/Projectiles/Boss/UnstableCrimulanGlob.cs b/Projectiles/Boss/UnstableCrimulanGlob.cs index 5c2a01564d..71ac79c0a2 100644 --- a/Projectiles/Boss/UnstableCrimulanGlob.cs +++ b/Projectiles/Boss/UnstableCrimulanGlob.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Projectiles.Boss public class UnstableCrimulanGlob : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; + public override void SetDefaults() { Projectile.Calamity().DealsDefenseDamage = true; @@ -28,6 +29,9 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.1f) * Projectile.Opacity; + Lighting.AddLight(Projectile.Center, light.X, light.Y, light.Z); + // Fly up and then fall down if (Projectile.ai[0] == 1f) { @@ -59,7 +63,7 @@ namespace CalamityMod.Projectiles.Boss { Color dustColor = Color.Crimson; dustColor.A = 150; - int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, Projectile.alpha, dustColor); + int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, 0, dustColor); Main.dust[dust].noGravity = true; } @@ -80,9 +84,6 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } diff --git a/Projectiles/Boss/UnstableEbonianGlob.cs b/Projectiles/Boss/UnstableEbonianGlob.cs index 2860149285..89b77b7a77 100644 --- a/Projectiles/Boss/UnstableEbonianGlob.cs +++ b/Projectiles/Boss/UnstableEbonianGlob.cs @@ -29,6 +29,9 @@ namespace CalamityMod.Projectiles.Boss public override void AI() { + Vector3 light = new Vector3(0.5f, 0.1f, 0.5f) * Projectile.Opacity; + Lighting.AddLight(Projectile.Center, light.X, light.Y, light.Z); + if (Projectile.velocity.Length() < 12f && (Main.expertMode || BossRushEvent.BossRushActive || Projectile.ai[0] == 1f)) { float velocityMult = BossRushEvent.BossRushActive ? 1.025f : CalamityWorld.death ? 1.015f : CalamityWorld.revenge ? 1.0125f : Main.expertMode ? 1.01f : 1.005f; @@ -46,7 +49,7 @@ namespace CalamityMod.Projectiles.Boss { Color dustColor = Color.Lavender; dustColor.A = 150; - int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, Projectile.alpha, dustColor); + int dust = Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.TintableDust, 0f, 0f, 0, dustColor); Main.dust[dust].noGravity = true; } @@ -67,9 +70,6 @@ namespace CalamityMod.Projectiles.Boss public override bool PreDraw(ref Color lightColor) { - lightColor.R = (byte)(255 * Projectile.Opacity); - lightColor.G = (byte)(255 * Projectile.Opacity); - lightColor.B = (byte)(255 * Projectile.Opacity); CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index c30a517758..a26faea61e 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -219,6 +219,14 @@ namespace CalamityMod.Projectiles /// A temporary flat amount subtracted from the projectile's damage when hitting the player. Resets to 0 if drops to 0. public int flatDR = 0; + /// Timer for how long a projectile's damage is reduced by the value in . + public int multiplicativeDRTimer = 0; + /// A temporary multiplicative amount of damage reduction when hitting the player. Resets to 0 if drops to 0. + public float multiplicativeDR = 0; + + /// If true, this projectile is a hook which has spawned a flower on it from Bloom Stone. Used to prevent spawning multiple flowers. + public bool hookCanSpawnFlower = false; + /// If true, allows hostile projectiles to deal defense damage to the player. Used mostly for hard-hitting bosses. public bool DealsDefenseDamage = false; @@ -2089,9 +2097,9 @@ namespace CalamityMod.Projectiles float dustVelocityMultiplier = 0.75f; int numDust = 5; int numDust2 = 5; - int fadeInTime = 10; - int fadeOutGateValue = masterMode ? 80 : death ? 50 : 25; - float killGateValue = masterMode ? 90f : death ? 60f : 35f; + int fadeInTime = 50; + int fadeOutGateValue = masterMode ? 120 : death ? 90 : 65; + float killGateValue = masterMode ? 130f : death ? 100f : 75f; int maxFrames = 5; bool fadeIn = projectile.ai[0] < (float)fadeInTime; @@ -2124,7 +2132,7 @@ namespace CalamityMod.Projectiles if (fadeIn) { - projectile.Opacity += 0.1f; + projectile.Opacity += 0.02f; if (projectile.Opacity > 1f) projectile.Opacity = 1f; @@ -4006,11 +4014,28 @@ namespace CalamityMod.Projectiles if (flatDRTimer <= 0) flatDR = 0; } + if (projectile.FinalExtraUpdate() && multiplicativeDRTimer > 0) + { + multiplicativeDRTimer--; + if (multiplicativeDRTimer <= 0) + multiplicativeDR = 0; + } if (projectile.FinalExtraUpdate() && TransformerTimer > 0) { TransformerTimer--; } + // Spawn Bloom Stone flower on landed hooks + // Should only spawn if: Projectile is a hook, hook is grappled to a tile, the player is wearing Bloom Stone, no flower has been spawned from this hook, no pollen exists + if (projectile.aiStyle == ProjAIStyleID.Hook && projectile.ai[0] == 2f && + Main.player[projectile.owner].Calamity().bloomStone && !hookCanSpawnFlower && + !CalamityUtils.AnyOwnedProjectiles(ProjectileType(), projectile.owner)) + { + hookCanSpawnFlower = true; + if (Main.myPlayer == projectile.owner) + Projectile.NewProjectile(projectile.GetSource_FromThis(), projectile.Center, Vector2.Zero, ProjectileType(), 0, 0f, projectile.owner, projectile.whoAmI); + } + // CIT 29JUN2024: Moved from PreAI to PostAI so that it is called every update instead of every frame. // This makes the distance traveled increment more accurately for projectiles with extra updates, as previously projectiles with extra updates // would add the distance traveled for the whole frame on the first update, making the distance checking much choppier. @@ -4093,16 +4118,38 @@ namespace CalamityMod.Projectiles #endregion #region Grappling Hooks + public override void UseGrapple(Player player, ref int type) + { + if (player.Calamity().bloomStoneHookVisuals) + { + // Insert vine effect when spawning a hook + } + } public override void GrapplePullSpeed(Projectile projectile, Player player, ref float speed) { + float mult = 1f; if (player.Calamity().reaverSpeed) - speed *= 1.1f; - } + mult += 0.5f; + if (player.Calamity().bloomStone) + mult += 0.5f; + speed *= mult; + // Visual flowers while being pulled + if (player.Calamity().bloomStoneHookVisuals && player.miscCounter % 5 == 0 && player.velocity.Length() > 2f) + { + Vector2 spawnPos = player.Center + Main.rand.NextVector2Circular(20f, 20f); + CustomSprite flowey = new(spawnPos, Vector2.Zero, 12, "CalamityMod/Projectiles/Magic/GleamingBolt", 0.425f, Color.White * 0.75f, 0f, false); + GeneralParticleHandler.SpawnParticle(flowey); + } + } public override void GrappleRetreatSpeed(Projectile projectile, Player player, ref float speed) { + float mult = 1f; if (player.Calamity().reaverSpeed) - speed *= 1.1f; + mult += 0.5f; + if (player.Calamity().bloomStone) + mult += 0.5f; + speed *= mult; } #endregion @@ -4227,6 +4274,7 @@ namespace CalamityMod.Projectiles public override void ModifyHitPlayer(Projectile projectile, Player target, ref Player.HurtModifiers modifiers) { modifiers.FinalDamage.Flat -= flatDR; + modifiers.FinalDamage *= 1f - multiplicativeDR; } #endregion @@ -4263,7 +4311,7 @@ namespace CalamityMod.Projectiles // If this projectile does not use static iframes, or is not registered to share them, then do nothing. if (!projectile.usesIDStaticNPCImmunity || !SharedStaticIFrames.Includes(projectile.type)) return; - + // Get the set of shared static iframe projectile types. // If it's empty, then do nothing. IList sharedWithProjectiles = SharedStaticIFrames.GetSharedStaticIFrames(projectile.type); @@ -4291,8 +4339,8 @@ namespace CalamityMod.Projectiles case ProjectileID.DeerclopsIceSpike: if (CalamityWorld.revenge || BossRushEvent.BossRushActive) { - float fadeInTime = 10f; - float fadeOutGateValue = masterMode ? 80f : death ? 50f : 25f; + float fadeInTime = 50f; + float fadeOutGateValue = masterMode ? 120f : death ? 90f : 65f; return (projectile.ai[0] >= fadeInTime && projectile.ai[0] < fadeOutGateValue); } break; @@ -4375,7 +4423,8 @@ namespace CalamityMod.Projectiles float homingTime = ((Main.masterMode || BossRushEvent.BossRushActive) ? 120f : CalamityWorld.death ? 105f : 90f); if (projectile.ai[0] == -3f) homingTime += 60f; - return projectile.ai[1] >= homingTime ? new Color(184, 140, 255, projectile.alpha) : lightColor; + + return projectile.ai[1] >= homingTime ? new Color(184, 140, 255, projectile.alpha) : new Color(255, 255, 255, (int)Utils.WrappedLerp(0f, 255f, (float)(projectile.timeLeft % 40) / 40f)); } if (projectile.type == ProjectileID.BloodNautilusShot) @@ -4473,9 +4522,9 @@ namespace CalamityMod.Projectiles Vector2 origin12 = new Vector2(16f, value26.Height / 2); Color alpha5 = projectile.GetAlpha(lightColor); Vector2 vector39 = new Vector2(projectile.scale); - float fadeOutGateValue = masterMode ? 80f : death ? 50f : 25f; - float killGateValue = masterMode ? 90f : death ? 60f : 35f; - float lerpValue5 = Utils.GetLerpValue(killGateValue, killGateValue - 10f, projectile.ai[0], clamped: true); + float fadeOutGateValue = masterMode ? 120f : death ? 90f : 65f; + float killGateValue = masterMode ? 130f : death ? 100f : 75f; + float lerpValue5 = Utils.GetLerpValue(killGateValue, killGateValue - 50f, projectile.ai[0], clamped: true); vector39.Y *= lerpValue5; Vector4 vector40 = lightColor.ToVector4(); Vector4 vector41 = new Color(67, 17, 17).ToVector4(); @@ -4690,8 +4739,8 @@ namespace CalamityMod.Projectiles new Vector2(position.X - Main.screenPosition.X + (float)(projectile.width / 2) - (float)TextureAssets.Projectile[projectile.type].Width() * projectile.scale / 2f + halfSize.X * projectile.scale, position.Y - Main.screenPosition.Y + (float)projectile.height - (float)TextureAssets.Projectile[projectile.type].Height() * projectile.scale / (float)Main.projFrames[projectile.type] + 4f + halfSize.Y * projectile.scale + projectile.gfxOffY), frame, alphaColor, projectile.rotation, halfSize, projectile.scale, spriteEffects, 0f); - } } + } #endregion #region Pre Kill diff --git a/Projectiles/Magic/HolyLaser.cs b/Projectiles/Magic/HolyLaser.cs index bb111a2960..c78db03e4c 100644 --- a/Projectiles/Magic/HolyLaser.cs +++ b/Projectiles/Magic/HolyLaser.cs @@ -47,6 +47,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.friendly = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; + Projectile.DamageType = DamageClass.Magic; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 57feae08c7..b05ce18c1f 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -1,21 +1,35 @@ using System; +using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.Audio; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SHPB : ModProjectile, ILocalizedModType + public class SHPB : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { + public PixelationPrimitiveLayer LayerToRenderTo => PixelationPrimitiveLayer.BeforeProjectiles; + + public ref float ExplodeTimer => ref Projectile.ai[2]; + + public bool CanExplodeFromProximity + { + get => Projectile.ai[1] == 1f; + set => Projectile.ai[1] = value.ToInt(); + } + public new string LocalizationCategory => "Projectiles.Magic"; - public int explosionTimer = 120; public override void SetStaticDefaults() { Main.projFrames[Type] = 4; + ProjectileID.Sets.TrailCacheLength[Type] = 12; + ProjectileID.Sets.TrailingMode[Type] = 2; } public override void SetDefaults() @@ -23,8 +37,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 24; Projectile.height = 24; Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.scale = 0.4f; + Projectile.alpha = 0; + Projectile.scale = 0f; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Magic; } @@ -92,7 +106,6 @@ namespace CalamityMod.Projectiles.Magic float lights = (float)Main.rand.Next(90, 111) * 0.01f; lights *= Main.essScale; Lighting.AddLight(Projectile.Center, 1f * lights, 0.2f * lights, 0.75f * lights); - Projectile.alpha -= 2; // Animation Projectile.frameCounter++; @@ -104,23 +117,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.frame = 0; } - // Size pulsing - bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; - - if (Projectile.localAI[0] == 0f) - { - Projectile.scale += 0.05f; - if (Projectile.scale > 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) - Projectile.localAI[0] = 1f; - } - else - { - Projectile.scale -= 0.05f; - if (Projectile.scale < 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) - Projectile.localAI[0] = 0f; - } - Projectile.ExpandHitboxBy((int)(24 * Projectile.scale)); - // Sight has weak homing if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Sight) { @@ -147,8 +143,8 @@ namespace CalamityMod.Projectiles.Magic else if (GetSoulEffects((int)Projectile.ai[0]) != SoulType.Flight) // Always slow down if not Flight Projectile.velocity *= 0.9875f; + // As soon as a plasma orb is in range of an enemy, it will explode in 1 second. float explodeRange = 250f; - bool canExplode = false; foreach (NPC n in Main.ActiveNPCs) { if (n.CanBeChasedBy(Projectile, false) && Collision.CanHit(Projectile.Center, 1, 1, n.Center, 1, 1)) @@ -159,15 +155,99 @@ namespace CalamityMod.Projectiles.Magic if (npcDist < explodeRange) { explodeRange = npcDist; - canExplode = true; + CanExplodeFromProximity = true; } } } - if (canExplode) + + if (CanExplodeFromProximity) { - explosionTimer--; - if (explosionTimer <= 0) + ExplodeTimer++; + if (ExplodeTimer >= 60f) Projectile.Kill(); + + // Quickly scale down before exploding. + bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; + float minScale = 0.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + float maxScale = 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + Projectile.scale = MathHelper.Clamp(Projectile.scale - 0.075f, minScale, maxScale); + } + else + { + // Size control. + // Scale up to the minimum scale at the start. + if (Projectile.timeLeft >= 285) + { + bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; + float minScale = 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + Projectile.scale += 0.125f; + if (Projectile.scale > minScale) + Projectile.scale = minScale; + } + // Pulse occasionally afterwards. + else if (Projectile.timeLeft <= 285 && Projectile.timeLeft >= 45) + { + bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; + float minScale = 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + float maxScale = 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f); + + Projectile.localAI[0]++; + Projectile.scale = MathHelper.Lerp(minScale, maxScale, CalamityUtils.SineBumpEasing(Projectile.localAI[0] / 75f, 1)); + } + // Scale down once the projectile is about to die. + else + { + // Save the last scale value of the projectile so that we can seamlessly shrink the projectile. + if (Projectile.localAI[1] == 0f) + Projectile.localAI[1] = Projectile.scale; + + Projectile.scale = Utils.Remap(Projectile.timeLeft, 45, 0, Projectile.localAI[1], 0.35f, true); + } + } + + Projectile.ExpandHitboxBy((int)(24 * Projectile.scale)); + Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; + + // Miscellaneous visual additions. + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + if (Main.rand.NextBool(3) && deathInterpolant <= 0f) + { + for (int i = 0; i < 4; i++) + { + Vector2 dustSpawnPosition = Projectile.Center + Main.rand.NextVector2Circular(Projectile.width * 0.75f, Projectile.height * 0.75f); + Vector2 dustVelocity = Projectile.velocity * -1.2f; + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y); + dust.scale = Main.rand.NextFloat(0.8f, 1.2f); + dust.noGravity = true; + dust.noLight = false; + dust.color = FindColorForSoul((int)Projectile.ai[0]); + dust.velocity *= 0.9f; + } + } + + // Start emitting particles on death. + if (deathInterpolant > 0f) + { + float speedMultiplier = MathHelper.Lerp(1f, 3f, deathInterpolant); + float scaleMultiplier = MathHelper.Lerp(1f, 1.65f, deathInterpolant); + for (int i = 0; i < 3; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 2.5f * speedMultiplier; + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y); + dust.scale = Main.rand.NextFloat(1.4f, 1.8f) * scaleMultiplier; + dust.color = FindColorForSoul((int)Projectile.ai[0]); + dust.noGravity = true; + dust.noLight = false; + } + + Vector2 plasmaVelocity = Main.rand.NextVector2Circular(1f, 1f) * 1.35f * speedMultiplier; + Color plasmaColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, deathInterpolant); + + float plasmaScale = Main.rand.NextFloat(0.2f, 0.4f) * scaleMultiplier; + int plasmaLifetime = Main.rand.Next(30, 45); + + SquishyLightParticle plasma = new(Projectile.Center, plasmaVelocity, plasmaScale, plasmaColor, plasmaLifetime); + GeneralParticleHandler.SpawnParticle(plasma); } } @@ -220,16 +300,88 @@ namespace CalamityMod.Projectiles.Magic Main.projectile[p].timeLeft *= 3; } } - } - public override Color? GetAlpha(Color lightColor) => FindColorForSoul((int)Projectile.ai[0]); + // Explosion visuals. + for (int i = 0; i < 25; i++) + { + Vector2 plasmaVelocity = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(6f, 11f); + Color plasmaColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, Main.rand.NextFloat()); + + float plasmaScale = Main.rand.NextFloat(0.8f, 1.4f); + int plasmaLifetime = Main.rand.Next(30, 45); + + SquishyLightParticle plasma = new(Projectile.Center, plasmaVelocity, plasmaScale, plasmaColor, plasmaLifetime); + GeneralParticleHandler.SpawnParticle(plasma); + } + + for (int i = 0; i < 15; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(1.8f, 2.4f); + Color dustColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, Main.rand.NextFloat()); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + } public override bool PreDraw(ref Color lightColor) { - Texture2D tex = ModContent.Request(Texture).Value; - Rectangle frame = tex.Frame(1, Main.projFrames[Type], 0, Projectile.frame); - Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None); + Texture2D mainTexture = ModContent.Request(Texture).Value; + Texture2D bloomCircleTexture = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + Rectangle frame = mainTexture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + + // Start to shake before exploding. + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + float shakeStrength = MathHelper.Lerp(0f, 6f, deathInterpolant); + Vector2 drawPosition = Projectile.Center + Main.rand.NextVector2Circular(shakeStrength, shakeStrength) - Main.screenPosition; + + // Turn the entire projectile white while exploding. + Color drawColor = Color.Lerp(FindColorForSoul((int)Projectile.ai[0]), Color.White, deathInterpolant); + Color bloomColor = Color.Lerp(drawColor, Color.White, 0.25f); + + Main.spriteBatch.SetBlendState(BlendState.Additive); + + Main.EntitySpriteDraw(bloomCircleTexture, drawPosition, null, Projectile.GetAlpha(bloomColor) * 0.85f, Projectile.rotation, bloomCircleTexture.Size() / 2f, Projectile.scale * 0.65f, SpriteEffects.None); + Main.EntitySpriteDraw(mainTexture, drawPosition, frame, Projectile.GetAlpha(drawColor), Projectile.rotation, frame.Size() / 2f, Projectile.scale, SpriteEffects.None); + Main.EntitySpriteDraw(mainTexture, drawPosition, frame, Projectile.GetAlpha(Color.White), Projectile.rotation, frame.Size() / 2f, Projectile.scale * 0.8f, SpriteEffects.None); + + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); return false; } + + public float PlasmaBallWidthFunction(float completion) + { + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + + float width; + float maxBodyWidth = Projectile.scale * 58f; + float curveRatio = 0.15f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + return width * MathHelper.Lerp(1f, 0f, deathInterpolant); + } + + public Color PlasmaBallColorFunction(float completion) + { + Color bodyColor = Color.Lerp(Color.Transparent, FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0f, 0.35f, completion)); + Color endColor = Color.Lerp(bodyColor, FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0.35f, 1f, completion)); + + // Change to white when the ball is about to explode. + float deathInterpolant = ExplodeTimer > 0 ? Utils.GetLerpValue(0, 50, ExplodeTimer, true) : Utils.GetLerpValue(60, 10, Projectile.timeLeft, true); + return Color.Lerp(endColor, Color.White, deathInterpolant); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch) + { + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(PlasmaBallWidthFunction, PlasmaBallColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + } } } diff --git a/Projectiles/Magic/SHPL.cs b/Projectiles/Magic/SHPL.cs index 374445d84b..c667a63398 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -1,28 +1,84 @@ -using CalamityMod.Particles; +using System; +using System.Linq; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SHPL : ModProjectile, ILocalizedModType + public class SHPL : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { public new string LocalizationCategory => "Projectiles.Magic"; - public override string Texture => "CalamityMod/Projectiles/LaserProj"; + + public bool ShouldStopAndDie + { + get => Projectile.ai[1] == 1f; + set => Projectile.ai[1] = value.ToInt(); + } + + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public PixelationPrimitiveLayer LayerToRenderTo => PixelationPrimitiveLayer.BeforeProjectiles; + + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; + } public override void SetDefaults() { Projectile.width = 5; Projectile.height = 5; - Projectile.scale = 2.5f; + Projectile.scale = 1.85f; Projectile.friendly = true; Projectile.extraUpdates = 3; Projectile.timeLeft = 600; + Projectile.penetrate = -1; Projectile.DamageType = DamageClass.Magic; } + public override bool? CanDamage() => !ShouldStopAndDie; + public override void AI() { + // 12MAY2025: fryzahh: + // This is made so that when hitting targets or tiles, the oldPos array can properly update so the laser appears to + // naturally dissipate entirely before despawning. Of course, it's also coded so that the laser stops dealing damage + // entirely once this is done to avoid hitting targets multiple times, so functionally the projectile remains the same + // and this change should have little to no effect on gameplay. If it does, ping me about it. + if (ShouldStopAndDie) + { + Projectile.velocity *= 0f; + if (Projectile.oldPos.Last() == Projectile.position) + { + Projectile.scale -= 0.15f; + if (Projectile.scale <= 0f) + { + Projectile.Kill(); + return; + } + } + + // Spawn a bunch of dusts at the dissipation point. + for (int i = 0; i < 2; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(1.8f, 2.4f); + Color dustColor = Color.Lerp(SHPB.FindColorForSoul((int)Projectile.ai[0]), Color.White, Main.rand.NextFloat()); + + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, dustColor, dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + } + + Projectile.rotation += MathHelper.TwoPi / 60f; Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 0.5f, 0.2f, 0.5f); float timerIncr = 3f; Projectile.localAI[0] += timerIncr; @@ -30,14 +86,65 @@ namespace CalamityMod.Projectiles.Magic Projectile.localAI[0] = 100f; } - public override Color? GetAlpha(Color lightColor) => SHPB.FindColorForSoul((int)Projectile.ai[0]); + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => ShouldStopAndDie = true; - public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); + public override bool OnTileCollide(Vector2 oldVelocity) + { + ShouldStopAndDie = true; + return false; + } public override void OnKill(int timeLeft) { AltLineParticle line = new(Projectile.Center, -Projectile.velocity.RotatedByRandom(MathHelper.Pi / 6f), false, 20, 1f, SHPB.FindColorForSoul((int)Projectile.ai[0])); GeneralParticleHandler.SpawnParticle(line); } + + public override bool PreDraw(ref Color lightColor) => false; + + public override void PostDraw(Color lightColor) + { + if (!ShouldStopAndDie) + return; + + // Draw a star over the collision point while dissipting. + Texture2D starTexture = ModContent.Request("CalamityMod/Particles/FullStar").Value; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + + Main.spriteBatch.SetBlendState(BlendState.Additive); + Main.EntitySpriteDraw(starTexture, drawPosition, null, Color.White, Projectile.rotation, starTexture.Size() * 0.5f, Projectile.scale, 0); + Main.spriteBatch.SetBlendState(BlendState.AlphaBlend); + } + + public float LaserWidthFunction(float completion) + { + float maxBodyWidth = Projectile.scale * Projectile.width; + float scaleInterpolant = Utils.GetLerpValue(0.05f, 0.2f, completion, true) * Utils.GetLerpValue(0.95f, 0.8f, completion, true); + return maxBodyWidth * scaleInterpolant * Projectile.scale; + } + + public float LaserCoreEnergyFunction(float completion) + { + float maxBodyWidth = (Projectile.scale * Projectile.width) * 0.25f; + float scaleInterpolant = Utils.GetLerpValue(0.05f, 0.2f, completion, true) * Utils.GetLerpValue(0.95f, 0.8f, completion, true); + return maxBodyWidth * scaleInterpolant * Projectile.scale; + } + + public Color LaserColorFunction(float completion) + { + Color startColor = Color.Lerp(Color.White, SHPB.FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0f, 0.125f, completion, true)); + Color bodyColor = Color.Lerp(startColor, SHPB.FindColorForSoul((int)Projectile.ai[0]), Utils.GetLerpValue(0.125f, 1f, completion, true)); + return Color.Lerp(startColor, bodyColor, completion); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch) + { + // Render the main trail for the body for the laser. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(LaserWidthFunction, LaserColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + + // Render a smaller, pure white trail in the same position to represent condensed energy in the core of the laser. + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(LaserCoreEnergyFunction, (_) => Color.White, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + } } } diff --git a/Projectiles/Magic/SHPS.cs b/Projectiles/Magic/SHPS.cs index c9214e062b..9ce66fce0c 100644 --- a/Projectiles/Magic/SHPS.cs +++ b/Projectiles/Magic/SHPS.cs @@ -1,18 +1,31 @@ -using CalamityMod.Particles; +using System; +using System.Linq; +using CalamityMod.DataStructures; +using CalamityMod.Graphics.Primitives; +using CalamityMod.Particles; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { - public class SHPS : ModProjectile, ILocalizedModType + public class SHPS : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public ref float Timer => ref Projectile.ai[1]; - public ref float Pickup => ref Projectile.ai[2]; // 0 if attacking soul, 1 if pickup soul + + // Whether or not this soul can be collected by the SHPC or not. + public bool IsAPickupSoul + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value.ToInt(); + } + private float AIState = 0f; // 0 = Idle, 1 = Homing to enemy, 2 = Getting sucked to player private const float HomingRange = 560f; @@ -20,10 +33,16 @@ namespace CalamityMod.Projectiles.Magic private Projectile ToSuckTowards; public float RandomAnglingStrength = 0f; - public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; + public override void SetStaticDefaults() + { + ProjectileID.Sets.CultistIsResistantTo[Type] = true; + ProjectileID.Sets.TrailCacheLength[Type] = 14; + ProjectileID.Sets.TrailingMode[Type] = 2; + } + public override void SetDefaults() { - Projectile.width = Projectile.height = 10; + Projectile.width = Projectile.height = 24; Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.tileCollide = false; @@ -32,7 +51,7 @@ namespace CalamityMod.Projectiles.Magic } // Can only deal damage after it starts homing - public override bool? CanDamage() => Timer >= 25f && Pickup == 0f ? null : false; + public override bool? CanDamage() => Timer >= 25f && !IsAPickupSoul; public override void AI() { @@ -41,7 +60,7 @@ namespace CalamityMod.Projectiles.Magic // Determine behavior if (Timer >= 25) // Always remains idle for a short delay { - if (Pickup == 0f) // Only run homing code if not a pickup + if (!IsAPickupSoul) // Only run homing code if not a pickup { float npcDistCheck = HomingRange; int index = -1; @@ -95,16 +114,21 @@ namespace CalamityMod.Projectiles.Magic if (Timer % 30 == 1f) RandomAnglingStrength = Main.rand.NextFloat(-0.16f, 0.16f); Projectile.velocity = Projectile.velocity.RotatedBy(RandomAnglingStrength); - if (Projectile.velocity.Length() > 2.75f && Pickup == 1f) + if (Projectile.velocity.Length() > 2.75f && IsAPickupSoul) Projectile.velocity *= 0.96f; break; + case 1f: Projectile.extraUpdates = 1; float speed = Projectile.velocity.Length(); Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Target.Center).ToRotation(), 0.15f).ToRotationVector2() * speed; break; + case 2f: - Projectile.velocity = (Projectile.velocity + Utils.DirectionTo(Projectile.Center, ToSuckTowards.ModProjectile().TipPosition + Main.player[Projectile.owner].velocity) * 20f) / 2f; + // Attempt to smoothly fly towards SHPC's barrel. + Vector2 idealVelocity = Projectile.SafeDirectionTo(ToSuckTowards.ModProjectile().TipPosition + Main.player[Projectile.owner].velocity) * 30f; + Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.1f); + if (Vector2.Distance(Projectile.Center, ToSuckTowards.ModProjectile().TipPosition) < 70f) { ToSuckTowards.ModProjectile().SoulColors.Add(Projectile.ai[0]); @@ -113,14 +137,113 @@ namespace CalamityMod.Projectiles.Magic break; } - // Appearance - if (Timer % 1 == 0f) + if (Main.rand.NextBool(12)) { - SquareParticle trail = new(Projectile.Center, Vector2.Zero, false, 20, 3f, SHPB.FindColorForSoul((int)Projectile.ai[0]), Pickup == 1f ? MathHelper.PiOver4 : 0f); - GeneralParticleHandler.SpawnParticle(trail); + for (int i = 0; i < 2; i++) + { + Vector2 dustSpawnPosition = Projectile.Center + Main.rand.NextVector2Circular(6f, 6f); + Vector2 dustVelocity = Projectile.velocity * -1.2f; + float dustScale = Main.rand.NextFloat(0.6f, 0.8f); + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, SHPB.FindColorForSoul((int)Projectile.ai[0]), dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } } - SquareParticle mainSpot = new(Projectile.Center, Vector2.Zero, false, 2, 1.4f, Color.White, Pickup == 1f ? MathHelper.PiOver4 : 0f); - GeneralParticleHandler.SpawnParticle(mainSpot); + + // Pickup souls give off separate particles to differentiate them from Attack souls. + if (Main.rand.NextBool(6) && IsAPickupSoul) + { + for (int i = 0; i < 3; i++) + { + Vector2 smokeVelocity = Main.rand.NextVector2Circular(1f, 1f) * 0.65f; + int smokeLifetime = Main.rand.Next(30, 45); + float smokeScale = Main.rand.NextFloat(0.15f, 0.3f); + float smokeOpacity = Main.rand.NextFloat(0.75f, 0.9f); + + HeavySmokeParticle ghastlySmoke = new(Projectile.Center, smokeVelocity, SHPB.FindColorForSoul((int)Projectile.ai[0]), smokeLifetime, smokeScale, smokeOpacity, 0.02f, true); + GeneralParticleHandler.SpawnParticle(ghastlySmoke); + } + } + } + + public override void OnKill(int timeLeft) + { + // Spawn a bunch of dust along the length of the trail a soul is killed. + BezierCurve curve = new(Projectile.oldPos); + for (int i = 0; i < 35; i++) + { + Vector2 dustSpawnPosition = curve.Evaluate(Main.rand.NextFloat()); + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 3f; + float dustScale = Main.rand.NextFloat(1.2f, 1.8f); + Dust dust = Dust.NewDustDirect(dustSpawnPosition, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, SHPB.FindColorForSoul((int)Projectile.ai[0]), dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + + // Spawn a burst of dust at the center. + for (int i = 0; i < 12; i++) + { + Vector2 dustVelocity = Main.rand.NextVector2Circular(1f, 1f) * 6f; + float dustScale = Main.rand.NextFloat(1.8f, 2.4f); + Dust dust = Dust.NewDustDirect(Projectile.Center, 1, 1, DustID.TintableDustLighted, dustVelocity.X, dustVelocity.Y, 0, SHPB.FindColorForSoul((int)Projectile.ai[0]), dustScale); + dust.noGravity = true; + dust.noLight = false; + dust.noLightEmittence = false; + } + } + + public override bool PreDraw(ref Color lightColor) => false; + + public float SoulWidthFunction(float completion) + { + float width; + float maxBodyWidth = Projectile.scale * 24f; + float curveRatio = 0.15f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width; + } + + public Color SoulColorFunction(float completion) + { + Color tipColor = Color.Lerp(SHPB.FindColorForSoul((int)Projectile.ai[0]), Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(SHPB.FindColorForSoul((int)Projectile.ai[0]), tipColor, completion); + } + + public float SoulCoreWidthFunction(float completion) + { + float width; + float maxBodyWidth = Projectile.scale * 14f; + float curveRatio = 0.15f; + + if (completion < curveRatio) + width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + return width; + } + + public Color SoulCoreColorFunction(float completion) + { + Color tipColor = Color.Lerp(Color.White, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(Color.White, tipColor, completion); + } + + public void RenderPixelatedPrimitives(SpriteBatch spriteBatch) + { + // Render the main trail for the body for the soul. + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak")); + PrimitiveRenderer.RenderTrail(Projectile.oldPos, new(SoulWidthFunction, SoulColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), Projectile.oldPos.Length * 2); + + // Render a smaller, pure white trail in the same position to represent the glowing white core of the soul. + Vector2[] soulCoreLength = Projectile.oldPos.Take(8).ToArray(); + GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + PrimitiveRenderer.RenderTrail(soulCoreLength, new(SoulCoreWidthFunction, SoulCoreColorFunction, (_) => Projectile.Size * 0.5f, true, true, GameShaders.Misc["CalamityMod:ImpFlameTrail"]), soulCoreLength.Length * 2); } } } diff --git a/Projectiles/Magic/SHPV.cs b/Projectiles/Magic/SHPV.cs index b2048e337c..bb9a52caa4 100644 --- a/Projectiles/Magic/SHPV.cs +++ b/Projectiles/Magic/SHPV.cs @@ -191,7 +191,7 @@ namespace CalamityMod.Projectiles.Magic // Draw souls around the gun as a sort of indicator of how many you have sucked in if (SoulColors.Count > 0) { - Texture2D sq = SoulSquare.Value; + Texture2D orbitingSoulTexture = SoulSquare.Value; for (int i = 0; i < SoulColors.Count; i++) { int soulsInRing = SoulColors.Count > MaxSoulsRing ? (SoulColors.Count - i > SoulColors.Count % MaxSoulsRing ? MaxSoulsRing : SoulColors.Count % MaxSoulsRing) : SoulColors.Count; @@ -203,7 +203,10 @@ namespace CalamityMod.Projectiles.Magic // Makes the souls disappear when they go "behind" the gun bool shouldDraw = posOffset.RotatedBy(-rotation).X <= 2.7f; if (shouldDraw) - Main.EntitySpriteDraw(sq, soulPosition + posOffset - Main.screenPosition, null, SHPB.FindColorForSoul((int)SoulColors[i]), 0f, sq.Size() / 2f, 1f, SpriteEffects.None); + { + Main.EntitySpriteDraw(orbitingSoulTexture, soulPosition + posOffset - Main.screenPosition, null, SHPB.FindColorForSoul((int)SoulColors[i]), 0f, orbitingSoulTexture.Size() * 0.5f, 1f, SpriteEffects.None); + Main.EntitySpriteDraw(orbitingSoulTexture, soulPosition + posOffset - Main.screenPosition, null, Color.White, 0f, orbitingSoulTexture.Size() * 0.5f, 0.5f, SpriteEffects.None); + } } } return false; diff --git a/Projectiles/Magic/ShiftingSandsProj.cs b/Projectiles/Magic/ShiftingSandsProj.cs index f231dfd265..60f9c2608a 100644 --- a/Projectiles/Magic/ShiftingSandsProj.cs +++ b/Projectiles/Magic/ShiftingSandsProj.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; + Projectile.tileCollide = false; } public override void AI() @@ -92,6 +93,7 @@ namespace CalamityMod.Projectiles.Magic } else if (Projectile.ai[0] <= 0f) { + Projectile.Calamity().conditionalHomingRange = 750f; Projectile.netUpdate = true; float speed = 12f; Vector2 projCenter = Projectile.Center; @@ -103,7 +105,7 @@ namespace CalamityMod.Projectiles.Magic } Vector2 mouseVec = new Vector2(mouseDistX, mouseDistY); float mouseDist = mouseVec.Length(); - if (mouseDist == 0f || Projectile.ai[0] < 0f) + if (mouseDist <= 2f || Projectile.ai[0] < 0f) { projCenter = player.Center; mouseVec = Projectile.Center - projCenter; diff --git a/Projectiles/Magic/WaterLeechProj.cs b/Projectiles/Magic/WaterLeechProj.cs index 277a9241a8..ec63dd9a4e 100644 --- a/Projectiles/Magic/WaterLeechProj.cs +++ b/Projectiles/Magic/WaterLeechProj.cs @@ -27,8 +27,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.penetrate = -1; Projectile.timeLeft = 540; Projectile.DamageType = DamageClass.Magic; - Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; } public override void AI() diff --git a/Projectiles/Melee/Cyclone.cs b/Projectiles/Melee/Cyclone.cs index 449613f3d8..41d56171c8 100644 --- a/Projectiles/Melee/Cyclone.cs +++ b/Projectiles/Melee/Cyclone.cs @@ -11,7 +11,8 @@ namespace CalamityMod.Projectiles.Melee public class Cyclone : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; - public int dustvortex = 0; + public int dustVortex = 0; + public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Type] = 6; @@ -36,33 +37,31 @@ namespace CalamityMod.Projectiles.Melee public override void AI() { - Projectile.ai[0]++; - Projectile.ai[1]++; - - //Code so it doesnt collide on tiles instantly - if (Projectile.ai[0] >= 12) - Projectile.tileCollide = true; + // Only begin colliding with tiles when the projectile is not inside tiles + CalamityUtils.PreventTileCollisionUntilHitboxIsOutsideOfTiles(Projectile); Projectile.rotation += 2.5f; + Projectile.alpha -= 5; + Projectile.ai[1] += 1f; if (Projectile.alpha < 50) { Projectile.alpha = 50; - if (Projectile.ai[1] >= 15) + if (Projectile.ai[1] >= 15f) { - for (int i = 1; i <= 6; i++) { - Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(dustvortex)); + Vector2 dustspeed = new Vector2(3f, 3f).RotatedBy(MathHelper.ToRadians(dustVortex)); int d = Dust.NewDust(Projectile.Center, Projectile.width / 2, Projectile.height / 2, 31, dustspeed.X, dustspeed.Y, 200, new Color(232, 251, 250, 200), 1.3f); Main.dust[d].noGravity = true; Main.dust[d].velocity = dustspeed; - dustvortex += 60; + dustVortex += 60; } - dustvortex -= 355; - Projectile.ai[1] = 0; + dustVortex -= 355; + Projectile.ai[1] = 0f; } } + float num472 = Projectile.Center.X; float num473 = Projectile.Center.Y; float num474 = 600f; @@ -77,30 +76,20 @@ namespace CalamityMod.Projectiles.Melee if (num478 < num474) { if (npc.position.X < num472) - { npc.velocity.X += 0.05f; - } else - { npc.velocity.X -= 0.05f; - } + if (npc.position.Y < num473) - { npc.velocity.Y += 0.05f; - } else - { npc.velocity.Y -= 0.05f; - } } } } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(204, 255, 255, Projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(204, 255, 255, Projectile.alpha); public override bool PreDraw(ref Color lightColor) { diff --git a/Projectiles/Melee/LaceratorSaw.png b/Projectiles/Melee/LaceratorSaw.png new file mode 100644 index 0000000000..4963c7e8f2 Binary files /dev/null and b/Projectiles/Melee/LaceratorSaw.png differ diff --git a/Projectiles/Melee/MirrorBladeProjectile.cs b/Projectiles/Melee/MirrorBladeProjectile.cs new file mode 100644 index 0000000000..12ceed3044 --- /dev/null +++ b/Projectiles/Melee/MirrorBladeProjectile.cs @@ -0,0 +1,108 @@ +using Terraria.ModLoader; +using CalamityMod.Projectiles.BaseProjectiles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using CalamityMod.Items.Weapons.Melee; +using Terraria.DataStructures; +using System; +using System.Collections.Generic; +using Terraria.Audio; + +namespace CalamityMod.Projectiles.Melee +{ + + public class MirrorBladeProjectile : BaseSwordHoldoutProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Melee"; + public override int swingWidth => 200; + public override Item BaseItem => ModContent.GetModItem(ModContent.ItemType()).Item; + public override int AfterImageLength => 10; + public override int OffsetDistance => 80; + public override bool drawSwordTrail => false; + public override Color[] trailColors => new Color[] { Color.Red, Color.MediumPurple, Color.Purple }; public override int StartupTime { get; set; } + public override int CooldownTime { get; set; } + public override bool AlternateSwings => true; + + public override bool useMeleeSpeed => true; + + public override int swingTime { get; set; } = 8; + + public override SoundStyle? UseSound => SoundID.Item1 with {Volume = 0.7f}; + + public List reflectedProjectiles = new List() { }; + + public override void Defaults() + { + Projectile.extraUpdates = 3; + } + + public override void Spawn(IEntitySource source) + { + var player = Main.player[Projectile.owner]; + var modplayer = player.GetModPlayer(); + StartupTime = 15; + CooldownTime = 15; + swingTime -= StartupTime + CooldownTime; + modplayer.swingNum = (modplayer.swingNum + 1) % 2; + Projectile.timeLeft = 600; + + } + + public override void AdditionalAI() + { + if (inStartup) + { + Projectile.scale = baseScale * MathHelper.Lerp(0.75f, 1f, StartupCompletion); + } + else if (inCooldown) + { + Projectile.Opacity = 1; + Projectile.scale = baseScale * MathHelper.Lerp(1, 0.75f, CooldownCompletion); + } + else + { + Projectile.Opacity = 1; + } + if (!inStartup && !inCooldown) + foreach (var proj in Main.ActiveProjectiles) + { + if (proj.Hitbox.Intersects(Projectile.Hitbox) && proj.hostile && !reflectedProjectiles.Contains(proj.whoAmI)) + { + reflectedProjectiles.Add(proj.whoAmI); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), proj.Center, proj.velocity * -1, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact,Projectile.Center); + } + } + + Lighting.AddLight(Main.player[Projectile.owner].Center, 0.96f, 0.91f, 1f); + } + + public override float SwingFunction() + { + if (inStartup) + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * 0.7f, -swingWidth * 0.4f, 1 - MathF.Pow(StartupCompletion, 0.5f))); + if (inCooldown) + return MathHelper.ToRadians(MathHelper.SmoothStep(swingWidth * 0.5f, (360 - swingWidth * 0.4f), MathF.Pow(CooldownCompletion, 0.5f))); + return MathHelper.ToRadians(MathHelper.SmoothStep(-swingWidth * .5f, (swingWidth * 0.5f), SwingCompletion)); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + for (var i = 0; i < 2; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), target.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.5f), Projectile.knockBack, Projectile.owner); + SoundEngine.PlaySound(SoundID.DD2_WitherBeastCrystalImpact,Projectile.Center); + } + public override float trailOffset => 28; + public override float trailWidth(float completion) + { + return 60; + } + public override int trailLength => 40; + public override bool PreDraw(ref Color lightColor) + { + lightColor = Color.White; + return base.PreDraw(ref lightColor); + } + } +} \ No newline at end of file diff --git a/Projectiles/Melee/MirrorBladeProjectile.png b/Projectiles/Melee/MirrorBladeProjectile.png new file mode 100644 index 0000000000..56f94280f2 Binary files /dev/null and b/Projectiles/Melee/MirrorBladeProjectile.png differ diff --git a/Projectiles/Melee/MirrorBlast.cs b/Projectiles/Melee/MirrorBlast.cs index bcf7c10932..469d7af4ff 100644 --- a/Projectiles/Melee/MirrorBlast.cs +++ b/Projectiles/Melee/MirrorBlast.cs @@ -3,61 +3,196 @@ using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.IO; namespace CalamityMod.Projectiles.Melee { public class MirrorBlast : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; + public bool isShard = true; + + public int shardShield = 0; + + public bool isShield => shardShield > 0; + + private bool hasSpawned = false; + + public int shardNum = -1; + + private Player player => Main.player[Projectile.owner]; public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Type] = 10; - ProjectileID.Sets.TrailingMode[Type] = 1; + Main.projFrames[Type] = 3; } public override void SetDefaults() { - Projectile.width = 12; - Projectile.height = 12; + Projectile.width = 16; + Projectile.height = 16; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.DamageType = DamageClass.Melee; Projectile.penetrate = 1; - Projectile.timeLeft = 300; + Projectile.timeLeft = 1800; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; } + public override void SendExtraAI(BinaryWriter writer) + { + writer.Write(isShard); + writer.Write(hasSpawned); + writer.Write(shardNum); + writer.Write(shardShield); + } + + public override void ReceiveExtraAI(BinaryReader reader) + { + isShard = reader.ReadBoolean(); + hasSpawned = reader.ReadBoolean(); + shardNum = reader.Read(); + shardShield = reader.Read(); + } + public override bool? CanDamage() + { + return !isShard; + } + + public override bool? CanHitNPC(NPC target) + { + if (target.Calamity().DR > 0.9f) { + return false; + } + return base.CanHitNPC(target); + } public override void AI() { - int playerOwner = (int)Player.FindClosest(Projectile.Center, 1, 1); - Projectile.ai[1] += 1f; - if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f) + if (!hasSpawned) { - float scaleFactor = Projectile.velocity.Length(); - Vector2 projDirection = Main.player[playerOwner].Center - Projectile.Center; - projDirection.Normalize(); - projDirection *= scaleFactor; - Projectile.velocity = (Projectile.velocity * 24f + projDirection) / 25f; - Projectile.velocity.Normalize(); - Projectile.velocity *= scaleFactor; + shardNum = player.ownedProjectileCounts[Projectile.type]; + hasSpawned = true; + shardNum = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == Projectile.owner) + { + (proj.ModProjectile as MirrorBlast).shardNum++; + } + } + } + if (isShield) + { + if (shardNum > 10 || Projectile.timeLeft < 2) + { + shardShield = 0; + isShard = false; + Projectile.timeLeft = 1200; + Projectile.velocity = Projectile.DirectionTo(player.Center) * -20f; + return; + } + List positions = new List() //Hardcoded positions for the mirror shield shards so we can make it look nice + { + new(0,75), + new(10,65), + new(-10,65), + new(20,75), + new(-20,75), + new(30,65), + new(-30,65), + new(14,55), + new(-14,55), + new(0,45) + }; + Projectile.velocity = Vector2.Zero; + Projectile.Center = Vector2.Lerp(Projectile.Center, + player.Center + player.DirectionTo(player.Calamity().mouseWorld) + .RotatedBy(MathHelper.ToRadians(positions[shardNum - 1].X)) + * positions[shardNum - 1].Y, + 0.5f); + Projectile.rotation = Projectile.DirectionTo(player.Center).ToRotation() + MathHelper.PiOver2; + shardShield--; + } + else if (isShard) + { + Projectile.velocity = Vector2.Zero; + var shardCount = 0; + foreach (var proj in Main.projectile) + { + if (proj.active && proj.type == ModContent.ProjectileType() && proj.owner == Projectile.owner && (proj.ModProjectile as MirrorBlast).isShard) + { + shardCount++; + } + } + Projectile.Center = Vector2.Lerp(Projectile.Center, player.Center + new Vector2(0, MathHelper.Lerp(-90, -110, MathF.Sin(player.miscCounter / 300f * MathHelper.TwoPi + MathHelper.Pi * (shardNum % 2)))).RotatedBy(MathHelper.ToRadians(player.miscCounter / 300f * 360f + 360f / shardCount * shardNum)), 0.15f); + Projectile.rotation = Projectile.DirectionTo(player.Center).ToRotation() + MathHelper.PiOver2; + if (shardNum > 10 || Projectile.timeLeft < 2) + { + isShard = false; + Projectile.timeLeft = 1200; + Projectile.velocity = Projectile.DirectionTo(player.Center) * -20f; + } + } + else + { + float homingStrength = 0.025f; // Adjust this value for stronger or weaker homing + NPC target = FindClosestNPC(3200f); + if (target != null) + { + Vector2 direction = target.Center - Projectile.Center; + direction.Normalize(); + direction *= 40f; // Adjust speed as needed + Projectile.velocity = Vector2.Lerp(Projectile.velocity, direction, homingStrength); + } + Projectile.rotation = Projectile.velocity.ToRotation(); } - if (Projectile.velocity.Length() < 18f) + Lighting.AddLight(Projectile.Center, 0.96f*0.33f, 0.91f*0.33f, 0.33f); + if (Projectile.FinalExtraUpdate()) + Projectile.frameCounter++; + if (Projectile.frameCounter > 8) { - Projectile.velocity *= 1.02f; + Projectile.frame++; + Projectile.frameCounter = 0; } - - Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; - - Lighting.AddLight(Projectile.Center, 0f, 0.35f, 0.35f); + if (Projectile.frame >= 3) + Projectile.frame = 0; } public override bool PreDraw(ref Color lightColor) { - if (Projectile.timeLeft > 295) - return false; - - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 2); + Texture2D BlastTex = ModContent.Request("CalamityMod/Projectiles/Melee/MirrorBlast").Value; + Texture2D ShardTex = ModContent.Request("CalamityMod/Projectiles/Melee/MirrorShard").Value; + Point BlastTextureDim = new Point(60, 26); + Point ShardTextureDim = new Point(32, 14); + Texture2D UsedTex = isShard ? ShardTex : BlastTex; + Point UsedTextureDim = isShard ? ShardTextureDim : BlastTextureDim; + Vector2 origin = isShard ? ShardTextureDim.ToVector2() / 2f : BlastTextureDim.ToVector2() / 2f + new Vector2(14, 0); + Main.spriteBatch.Draw(UsedTex, Projectile.Center - Main.screenPosition, new Rectangle(0, UsedTextureDim.Y * Projectile.frame, UsedTextureDim.X, UsedTextureDim.Y), Color.White, Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0f); return false; } + + private NPC FindClosestNPC(float maxRange) + { + NPC closestNPC = null; + float closestDistance = maxRange; + + foreach (NPC npc in Main.npc) + { + if (npc.CanBeChasedBy(this) && !npc.friendly) + { + float distance = Vector2.Distance(Projectile.Center, npc.Center); + if (distance < closestDistance) + { + closestDistance = distance; + closestNPC = npc; + } + } + } + + return closestNPC; + } } } diff --git a/Projectiles/Melee/MirrorBlast.png b/Projectiles/Melee/MirrorBlast.png index ae7a902f9a..07a4720957 100644 Binary files a/Projectiles/Melee/MirrorBlast.png and b/Projectiles/Melee/MirrorBlast.png differ diff --git a/Projectiles/Melee/MirrorShard.png b/Projectiles/Melee/MirrorShard.png new file mode 100644 index 0000000000..926658fff7 Binary files /dev/null and b/Projectiles/Melee/MirrorShard.png differ diff --git a/Projectiles/Melee/SeekingScorcherProj.cs b/Projectiles/Melee/SeekingScorcherProj.cs index 3ade299e4f..8b7f83e462 100644 --- a/Projectiles/Melee/SeekingScorcherProj.cs +++ b/Projectiles/Melee/SeekingScorcherProj.cs @@ -230,6 +230,13 @@ namespace CalamityMod.Projectiles.Melee } } } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (Projectile.numHits > 0) + Projectile.damage = (int)(Projectile.damage * 0.8f); + if (Projectile.damage < 1) + Projectile.damage = 1; + } public override void OnKill(int timeLeft) { diff --git a/Projectiles/Melee/ViolenceThrownProjectile.cs b/Projectiles/Melee/ViolenceThrownProjectile.cs index 0bd714b8fa..db26da3a46 100644 --- a/Projectiles/Melee/ViolenceThrownProjectile.cs +++ b/Projectiles/Melee/ViolenceThrownProjectile.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Graphics.Primitives; using CalamityMod.Items.Weapons.Melee; using CalamityMod.NPCs; @@ -11,23 +12,266 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using CalamityMod; +using CalamityMod.NPCs.ExoMechs.Ares; +using CalamityMod.Projectiles.Melee; +using ReLogic.Content; +using System.Linq; +using Terraria.DataStructures; namespace CalamityMod.Projectiles.Melee { [PierceResistException] public class ViolenceThrownProjectile : ModProjectile { + private int hitstop = 0; public override LocalizedText DisplayName => CalamityUtils.GetItemName(); internal Player Owner => Main.player[Projectile.owner]; internal ref float Time => ref Projectile.ai[0]; public override string Texture => "CalamityMod/Items/Weapons/Melee/Violence"; - public override void SetStaticDefaults() + + public bool isJavelin { - ProjectileID.Sets.TrailingMode[Type] = 2; - ProjectileID.Sets.TrailCacheLength[Type] = 36; + get + { + if (Projectile.ai[2] == 0) + return true; + else + return false; + } } + public override void SetStaticDefaults() + { + ProjectileID.Sets.TrailingMode[Projectile.type] = 2; + ProjectileID.Sets.TrailCacheLength[Projectile.type] = 60; + } + + private Vector2 NormalVelocity = Vector2.Zero; + private NPC target; + private Vector2 targetoffset = Vector2.Zero; + private int[] offsetadjust = new int[] + { + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + ModContent.NPCType(), + }; + + public override void OnSpawn(IEntitySource source) + { + if (isJavelin) + JavelinSetDefaults(); + else + YoyoSetDefaults(); + } + + //These methods adjusts to which AI type is in use + #region Variable Methods + public override void SetDefaults() + { + Projectile.timeLeft = 60; + //The rest of this runs in OnSpawn instead due to variable AI stuff + } + public override void AI() + { + if (isJavelin) + JavelinAI(); + else + YoyoAI(); + } + + public override bool PreDraw(ref Color lightColor) + { + if (isJavelin && Projectile.timeLeft > 2) + return JavelinPreDraw(ref lightColor); + else + return YoyoPreDraw(ref lightColor); + } + + public override void ModifyDamageHitbox(ref Rectangle hitbox) + { + if (isJavelin) + JavelinModifyDamageHitbox(ref hitbox); + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + if (isJavelin) + JavelinOnHitNPC(target, hit, damageDone); + else + YoyoOnHitNPC(target, hit, damageDone); + } + #endregion + + //Methods for controlling the Javelin throw + #region Javelin Methods + public void JavelinAI() + { + + var player = Main.player[Projectile.owner]; + float adust = MathHelper.ToRadians(45 + 180); + if (hitstop > 0) + { + hitstop--; + Projectile.timeLeft++; + Projectile.velocity = NormalVelocity * 0.01f + (offsetadjust.Contains(target.type) ? target.position - targetoffset : Vector2.Zero); + targetoffset = target.position; + + Vector2 impactPoint = Vector2.Lerp(Projectile.Center, target.Center, 0.5f);//Projectile.Center + new Vector2(0,-100).RotatedBy(Projectile.rotation + MathHelper.Pi/4f); + Vector2 bloodSpawnPosition = impactPoint + Main.rand.NextVector2Circular(target.width, target.height) * 0.04f; + Vector2 splatterDirection = Projectile.velocity.SafeNormalize(Vector2.Zero) * -1; + + // Emit blood if the target is organic. + if (target.Organic()) + { + if (Projectile.FinalExtraUpdate()) + SoundEngine.PlaySound(SoundID.NPCHit18 with { Volume = 0.2f }, Projectile.Center); + for (int i = 0; i < 1; i++) + { + int bloodLifetime = Main.rand.Next(22, 36); + float bloodScale = Main.rand.NextFloat(0.6f, 0.8f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat()); + bloodColor = Color.Lerp(bloodColor, new Color(51, 22, 94), Main.rand.NextFloat(0.65f)); + + if (Main.rand.NextBool(20)) + bloodScale *= 2f; + + Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.81f) * Main.rand.NextFloat(11f, 23f); + bloodVelocity.Y -= 12f; + BloodParticle blood = new BloodParticle(bloodSpawnPosition, bloodVelocity, bloodLifetime, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + for (int i = 0; i < 1; i++) + { + float bloodScale = Main.rand.NextFloat(0.2f, 0.33f); + Color bloodColor = Color.Lerp(Color.Red, Color.DarkRed, Main.rand.NextFloat(0.5f, 1f)); + Vector2 bloodVelocity = splatterDirection.RotatedByRandom(0.9f) * Main.rand.NextFloat(9f, 14.5f); + BloodParticle2 blood = new BloodParticle2(bloodSpawnPosition, bloodVelocity, 20, bloodScale, bloodColor); + GeneralParticleHandler.SpawnParticle(blood); + } + } + + // Emit sparks if the target is not organic. + else + { + + if (Projectile.FinalExtraUpdate()) + { + for (int i = 0; i < 2; i++) + { + int sparkLifetime = Main.rand.Next(22, 36); + float sparkScale = Main.rand.NextFloat(0.8f, 1f) + 1 * 0.85f; + Color sparkColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.7f)); + sparkColor = Color.Lerp(sparkColor, Color.Orange, Main.rand.NextFloat()); + + if (Main.rand.NextBool(10)) + sparkScale *= 2f; + + Vector2 sparkVelocity = splatterDirection.RotatedByRandom(0.6f) * Main.rand.NextFloat(12f, 25f); + sparkVelocity.Y -= 6f; + SparkParticle spark = new SparkParticle(impactPoint, sparkVelocity, true, sparkLifetime, sparkScale, sparkColor); + GeneralParticleHandler.SpawnParticle(spark); + } + SoundEngine.PlaySound(SoundID.NPCHit18 with { Volume = 0.2f }, Projectile.Center); + } + } + + + } + else + { + Projectile.velocity = NormalVelocity; + } + if (Projectile.timeLeft == 1) + { + Projectile.timeLeft++; + + ReturnToOwner(); + Projectile.rotation += 0.45f; + Projectile.extraUpdates = 3; + Projectile.damage = 0; + Time = 60; + } + Lighting.AddLight(Projectile.Center + (Projectile.rotation - MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.45f, Color.Red.ToVector3() * 0.4f); + } + public bool JavelinPreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + + // Not cloning the points causes the below operations to be applied to the original oldPos value by reference + // and thus causes it to be consistently added over and over, which is not intended behavior. + Vector2[] drawPoints = (Vector2[])Projectile.oldPos.Clone(); + Vector2 aimAheadDirection = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + PrimitiveRenderer.RenderTrail(Projectile.oldPos.Take(60).ToArray(), new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), 25); + return true; + } + public void JavelinSetDefaults() + { + Projectile.timeLeft = 60; + Projectile.width = Projectile.height = 142; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.localNPCHitCooldown = -1; + Projectile.usesLocalNPCImmunity = true; + Projectile.extraUpdates = 4; + Projectile.aiStyle = -2; + Projectile.DamageType = DamageClass.Melee; + Projectile.tileCollide = false; + Projectile.Center = Main.player[Projectile.owner].Center; + NormalVelocity = Projectile.velocity; + Projectile.rotation = Projectile.velocity.ToRotation() + MathF.PI / 4; + } + public void JavelinModifyDamageHitbox(ref Rectangle hitbox) + { + var center = hitbox.Center.ToVector2(); + hitbox.Height = (int)(45 * Projectile.scale); + hitbox.Width = (int)(45 * Projectile.scale); + hitbox.Location = (center + NormalVelocity.SafeNormalize(Vector2.Zero) * 70 - new Vector2(hitbox.Width / 2, hitbox.Height / 2)).ToPoint(); + + } + public void JavelinOnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + var player = Main.player[Projectile.owner]; + this.target = target; + targetoffset = target.position; + float x = Utils.GetLerpValue(1000f, 6000f, damageDone, true); + int x1 = (int)(20 * (x) * (Projectile.extraUpdates + 1)); + if (damageDone > 5) + { + hitstop = x1; + Projectile.damage = (int)(Projectile.damage * 0.9f); + } + target.AddBuff(ModContent.BuffType(), 240); + + + if (Main.netMode != NetmodeID.Server) + { + // Play a splatter and impact sound. + SoundEngine.PlaySound(SoundID.DD2_CrystalCartImpact, Projectile.Center); + + float damageInterpolant = Utils.GetLerpValue(950f, 2000f, hit.Damage, true); + float impactAngularVelocity = MathHelper.Lerp(0.08f, 0.2f, damageInterpolant); + float impactParticleScale = MathHelper.Lerp(0.6f, 1f, damageInterpolant); + impactAngularVelocity *= Main.rand.NextBool().ToDirectionInt() * Main.rand.NextFloat(0.75f, 1.25f); + + Color impactColor = Color.Lerp(Color.Silver, Color.Gold, Main.rand.NextFloat(0.5f)); + Vector2 impactPoint = Vector2.Lerp(Projectile.Center, target.Center, 0.65f); + + + // And create an impact point particle. + ImpactParticle impactParticle = new ImpactParticle(impactPoint, impactAngularVelocity, 20, impactParticleScale, impactColor); + GeneralParticleHandler.SpawnParticle(impactParticle); + } + + } + #endregion + + //These methods are the original Violence "Yoyo" functionality + #region Yoyo Methods + public void YoyoSetDefaults() { Projectile.width = Projectile.height = 142; Projectile.aiStyle = -1; @@ -42,7 +286,7 @@ namespace CalamityMod.Projectiles.Melee Projectile.tileCollide = false; } - public override void AI() + public void YoyoAI() { // Fade in. Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Time, true); @@ -55,7 +299,6 @@ namespace CalamityMod.Projectiles.Melee else { ReturnToOwner(); - float idealAngle = Projectile.AngleTo(Owner.Center) - MathHelper.PiOver4; Projectile.rotation = Projectile.rotation.AngleLerp(idealAngle, 0.1f); Projectile.rotation = Projectile.rotation.AngleTowards(idealAngle, 0.25f); @@ -103,7 +346,7 @@ namespace CalamityMod.Projectiles.Melee Owner.itemAnimation = 2; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + public void YoyoOnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (!Main.dedServ) { @@ -174,6 +417,44 @@ namespace CalamityMod.Projectiles.Melee GeneralParticleHandler.SpawnParticle(impactParticle); } } + public bool YoyoPreDraw(ref Color lightColor) + { + GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); + + Texture2D spearProjectile = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + + // Not cloning the points causes the below operations to be applied to the original oldPos value by reference + // and thus causes it to be consistently added over and over, which is not intended behavior. + Vector2[] drawPoints = (Vector2[])Projectile.oldPos.Clone(); + Vector2 aimAheadDirection = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); + + if (Owner.channel || isJavelin) + { + drawPoints[0] += aimAheadDirection * -12f; + drawPoints[1] = drawPoints[0] - (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * Vector2.Distance(drawPoints[0], drawPoints[1]); + } + for (int i = 0; i < drawPoints.Length; i++) + drawPoints[i] -= (Projectile.oldRot[i] + MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.5f; + + int numPointsRendered = (int)Math.Min(24, Time); + PrimitiveRenderer.RenderTrail(drawPoints.Take((int)Math.Min(Time, 36)).ToArray(), new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), 24); + + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + for (int i = 0; i < 6; i++) + { + float rotation = Projectile.oldRot[i] - MathHelper.PiOver2; + if (Owner.channel) + rotation += 0.2f; + + Color afterimageColor = Color.Lerp(lightColor, Color.Transparent, 1f - (float)Math.Pow(Utils.GetLerpValue(0, 6, i), 1.4D)) * Projectile.Opacity; + Main.EntitySpriteDraw(spearProjectile, drawPosition, null, afterimageColor, rotation, spearProjectile.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); + } + + return false; + } + #endregion + + #region Shared Methods internal float PrimitiveWidthFunction(float completionRatio) { @@ -196,46 +477,6 @@ namespace CalamityMod.Projectiles.Melee return Color.Lerp(frontFade, backFade, (float)Math.Pow(completionRatio, 1.2D)) * (float)Math.Pow(1f - completionRatio, 1.1D) * Projectile.Opacity; } - - public override bool PreDraw(ref Color lightColor) - { - GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/FabstaffStreak")); - - Texture2D spearProjectile = Terraria.GameContent.TextureAssets.Projectile[Type].Value; - - // Not cloning the points causes the below operations to be applied to the original oldPos value by reference - // and thus causes it to be consistently added over and over, which is not intended behavior. - Vector2[] drawPoints = (Vector2[])Projectile.oldPos.Clone(); - Vector2 aimAheadDirection = (Projectile.rotation - MathHelper.PiOver2).ToRotationVector2(); - - if (Owner.channel) - { - drawPoints[0] += aimAheadDirection * -12f; - drawPoints[1] = drawPoints[0] - (Projectile.rotation + MathHelper.PiOver4).ToRotationVector2() * Vector2.Distance(drawPoints[0], drawPoints[1]); - } - for (int i = 0; i < drawPoints.Length; i++) - drawPoints[i] -= (Projectile.oldRot[i] + MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.5f; - - if (Time > Projectile.oldPos.Length) - { - // Violence trakcs 36 positions in oldPos. - // Provide all 36 points for smoothing, but only render 24. - int numPointsRendered = 24; - PrimitiveRenderer.RenderTrail(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"], smoothen: true), numPointsRendered); - } - - Vector2 drawPosition = Projectile.Center - Main.screenPosition; - for (int i = 0; i < 6; i++) - { - float rotation = Projectile.oldRot[i] - MathHelper.PiOver2; - if (Owner.channel) - rotation += 0.2f; - - Color afterimageColor = Color.Lerp(lightColor, Color.Transparent, 1f - (float)Math.Pow(Utils.GetLerpValue(0, 6, i), 1.4D)) * Projectile.Opacity; - Main.EntitySpriteDraw(spearProjectile, drawPosition, null, afterimageColor, rotation, spearProjectile.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0); - } - - return false; - } + #endregion } } diff --git a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs index 43b61fd17b..067878f5a1 100644 --- a/Projectiles/Melee/Yoyos/LaceratorYoyo.cs +++ b/Projectiles/Melee/Yoyos/LaceratorYoyo.cs @@ -1,10 +1,15 @@ -using CalamityMod.Buffs.DamageOverTime; +using System; +using System.Linq; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Items.Weapons.Melee; +using CalamityMod.Projectiles.Healing; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; +using CalamityMod.Particles; namespace CalamityMod.Projectiles.Melee.Yoyos { @@ -13,6 +18,20 @@ namespace CalamityMod.Projectiles.Melee.Yoyos public override LocalizedText DisplayName => CalamityUtils.GetItemName(); public const int MaxUpdates = 3; + private static int CircleRes = 60; + private static int VertRes = 4; + private static int SpikeCount = 8; + + private float circleProgress = 0; + private float verticalProgress = 1; + private bool goingUp = false; + public float chargeProgress = 0; + + private bool sawHit = false; + private bool spawnedBlood = false; + + private int sawDir = 0; + public override void SetStaticDefaults() { ProjectileID.Sets.YoyosLifeTimeMultiplier[Type] = -1f; @@ -33,29 +52,93 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Projectile.MaxUpdates = MaxUpdates; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 6 * MaxUpdates; + } public override void AI() { + if (sawDir == 0) + sawDir = Projectile.velocity.X < 0 ? -1 : 1; + if (chargeProgress > 1) + chargeProgress = 1; + if (chargeProgress > 0) + { + if (Main.player[Projectile.owner].miscCounter % 5 == 0 && Projectile.FinalExtraUpdate() && chargeProgress > 0.05f) + { + spawnedBlood = false; + Projectile.position = Projectile.Center; + Projectile.width = 196; + Projectile.height = 196; + Projectile.Center = Projectile.position; + Projectile.originalDamage = Projectile.damage; + Projectile.damage = (int)(Projectile.damage * MathHelper.Lerp(0, 1f, chargeProgress)); + sawHit = true; + Projectile.usesIDStaticNPCImmunity = true; + Projectile.aiStyle = -1; + Projectile.Damage(); + Projectile.aiStyle = ProjAIStyleID.Yoyo; + Projectile.usesIDStaticNPCImmunity = false; + sawHit = false; + Projectile.damage = Projectile.originalDamage; + Projectile.position = Projectile.Center; + Projectile.width = 16; + Projectile.height = 16; + Projectile.Center = Projectile.position; + + } + if (chargeProgress > 0.05f) + { + float particleSize = 0.9f + 0.15f * (float)Math.Cos(Main.GlobalTimeWrappedHourly % 60f * MathHelper.TwoPi); + particleSize *= 0.5f; + var particlePos = Projectile.Center + new Vector2(0, 84).RotatedByRandom(MathHelper.TwoPi); + var particleVel = particlePos.DirectionTo(Projectile.Center).RotatedBy(-sawDir * MathHelper.PiOver2 * 0.9f).RotatedByRandom(0.1f) * Main.rand.NextFloat(15f, 25f); + Particle blood = new CustomSpark(particlePos, particleVel, "CalamityMod/Particles/PearlParticleGlow", false, (int)MathHelper.Lerp(7, 17, chargeProgress), particleSize, Color.DarkRed, new Vector2(0.5f, 1), false, false, 0, false, false, 0f); + GeneralParticleHandler.SpawnParticle(blood); + } + chargeProgress -= 0.003f / Projectile.extraUpdates; + if (chargeProgress < 0) + chargeProgress = 0; + } + if ((Projectile.position - Main.player[Projectile.owner].position).Length() > 3200f) //200 blocks Projectile.Kill(); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - target.AddBuff(ModContent.BuffType(), 180); - - if (Main.player[Projectile.owner].moonLeech) + if (sawHit) + { + target.AddBuff(ModContent.BuffType(), 60); + Vector2 bloodpos = Projectile.Center + Projectile.DirectionTo(target.Center) * 84; + if (!spawnedBlood && Main.rand.NextBool() && chargeProgress > 0.2f && target.Hitbox.Contains(bloodpos.ToPoint())) + { + Projectile.NewProjectile(Projectile.GetSource_OnHit(target), bloodpos, Projectile.DirectionTo(target.Center).RotatedBy(sawDir * MathHelper.PiOver2 * 0.9f).RotatedByRandom(0.1f) * Main.rand.NextFloat(3f, 5f), ModContent.ProjectileType(), 1, 0f, Projectile.owner); + spawnedBlood = true; + } return; - - Player player = Main.player[Projectile.owner]; - player.lifeRegenTime += 2; + } + var baseYoyo = Main.projectile.First(x => x.active && x.type == ModContent.ProjectileType() && x.owner == Projectile.owner); + baseYoyo.ModProjectile().chargeProgress += (Main.player[Projectile.owner].yoyoGlove ? 0.05f : 0.1f); + target.AddBuff(ModContent.BuffType(), 180); } public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 180); public override bool PreDraw(ref Color lightColor) { + if (chargeProgress > 0) + { + var owner = Main.player[Projectile.owner]; + Texture2D texture = ModContent.Request("CalamityMod/Projectiles/Melee/LaceratorSaw").Value; + Texture2D WindTexture = ModContent.Request("CalamityMod/Projectiles/Melee/BlazingPhantomBlade").Value; + float rot = MathHelper.TwoPi * 30 * sawDir * (owner.miscCounter / 300f); + var color = new Color(200, 200, 200); + var frame = WindTexture.Frame(1, 4, 0, 0); + Main.EntitySpriteDraw(WindTexture, Projectile.Center - Main.screenPosition + rot.ToRotationVector2() * 30, frame, color * MathF.Pow(chargeProgress, 0.5f) * 0.33f, rot - 0.2f * sawDir, new Vector2(frame.Width, frame.Height) * 0.5f, 1, sawDir == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None, 0); + Main.EntitySpriteDraw(WindTexture, Projectile.Center - Main.screenPosition + (rot + MathHelper.Pi).ToRotationVector2() * 30, frame, color * MathF.Pow(chargeProgress, 0.5f) * 0.33f, (rot + MathHelper.Pi) - 0.2f * sawDir, new Vector2(frame.Width, frame.Height) * 0.5f, 1, sawDir == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None, 0); + color = new Color(255, 10, 10); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, color * MathF.Pow(chargeProgress, 0.5f) * 1f, rot, texture.Size() * 0.5f, 1, sawDir == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally, 0); + } CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Type], lightColor, 1); return false; } diff --git a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs index 0f165f509e..83942f5fa5 100644 --- a/Projectiles/Melee/Yoyos/QuagmireYoyo.cs +++ b/Projectiles/Melee/Yoyos/QuagmireYoyo.cs @@ -45,6 +45,7 @@ namespace CalamityMod.Projectiles.Melee.Yoyos Projectile spore = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Projectile.velocity * Main.rand.NextFloat(0.15f, 0.35f) + Vector2.UnitX.RotatedByRandom(MathHelper.Pi), ProjectileID.SporeGas + Main.rand.Next(3), (int)(Projectile.damage * 0.5), Projectile.knockBack, Projectile.owner); spore.DamageType = DamageClass.MeleeNoSpeed; spore.usesLocalNPCImmunity = true; + spore.usesIDStaticNPCImmunity = false; spore.localNPCHitCooldown = 30; } } diff --git a/Projectiles/Ranged/BouncingShotgunPellet.cs b/Projectiles/Ranged/BouncingShotgunPellet.cs index eb59268856..926212c0fa 100644 --- a/Projectiles/Ranged/BouncingShotgunPellet.cs +++ b/Projectiles/Ranged/BouncingShotgunPellet.cs @@ -9,7 +9,7 @@ namespace CalamityMod.Projectiles.Ranged { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/Ranged/RealmRavagerBullet"; - private int bounce = 2; + private int bounce = 3; public override void SetDefaults() { Projectile.width = 4; @@ -29,14 +29,42 @@ namespace CalamityMod.Projectiles.Ranged bounce--; if (bounce <= 0) Projectile.Kill(); - else + + Player owner = Main.player[Projectile.owner]; + + if (bounce == 1) + { + float npcDistCheck = 640f; // 40 tiles + int index = -1; + foreach (NPC n in Main.ActiveNPCs) + { + if (!n.CanBeChasedBy(Projectile)) + continue; + + float currentNPCDist = Vector2.Distance(n.Center, owner.ClampedMouseWorld()); + if (currentNPCDist < npcDistCheck) + { + npcDistCheck = currentNPCDist; + index = n.whoAmI; + } + } + // If the index is not default, smart bounce in the direction of that enemy. + if (index != -1) + { + Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTargetMaxUpdates(Projectile.Center, Main.npc[index], owner.ActiveItem().shootSpeed, 3); + } + return false; + } + else // Otherwise, use standard bouncing behavior. { if (Projectile.velocity.X != oldVelocity.X) + { Projectile.velocity.X = -oldVelocity.X; + } if (Projectile.velocity.Y != oldVelocity.Y) + { Projectile.velocity.Y = -oldVelocity.Y; - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - Projectile.damage /= 2; + } } return false; } diff --git a/Projectiles/Ranged/FlashRoundProj.cs b/Projectiles/Ranged/FlashRoundProj.cs index 1ba053ff56..097af310b5 100644 --- a/Projectiles/Ranged/FlashRoundProj.cs +++ b/Projectiles/Ranged/FlashRoundProj.cs @@ -109,12 +109,11 @@ namespace CalamityMod.Projectiles.Ranged dust.scale = Main.rand.NextFloat(0.75f, 1.1f); dust.noGravity = true; } - //SoundEngine.PlaySound(SoundID.Shatter with { Volume = 0.4f, Pitch = 0.1f + 0.1f * bounces }, Projectile.Center); SoundEngine.PlaySound(SoundID.Item50 with { Volume = 0.3f, Pitch = -0.2f + 0.4f * bounces, MaxInstances = 15 }, Projectile.Center); } for (int i = 0; i < 2; i++) { - Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f * (i), 0.45f * (i), 9, true); + Particle blastRing = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomCircle", Vector2.One, Main.rand.NextFloat(-10, 10), 0.2f * (i), 0.45f * (i), 9, true, makeLight: 0); GeneralParticleHandler.SpawnParticle(blastRing); } float rot = Main.rand.NextFloat(-5, 5); @@ -126,6 +125,7 @@ namespace CalamityMod.Projectiles.Ranged dust.fadeIn = 1.5f; dust.noGravity = true; dust.color = Color.White; + dust.noLightEmittence = true; } // Doesn't actually do damage, just an aoe for confustion infliction and knockback Projectile flash = Projectile.NewProjectileDirect(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), 5, 0f, Projectile.owner); @@ -166,6 +166,11 @@ namespace CalamityMod.Projectiles.Ranged bounces--; return false; } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + float damageMult = (Projectile.numHits == 0 ? 1 : 0.3f); + modifiers.SourceDamage *= damageMult; + } public override void OnKill(int timeLeft) { } diff --git a/Projectiles/Ranged/SmallCoral.cs b/Projectiles/Ranged/SmallCoral.cs deleted file mode 100644 index 40f6c0292c..0000000000 --- a/Projectiles/Ranged/SmallCoral.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.Audio; -using Terraria.ID; -using Terraria.ModLoader; -namespace CalamityMod.Projectiles.Ranged -{ - public class SmallCoral : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Ranged"; - public override void SetDefaults() - { - Projectile.width = 16; - Projectile.height = 22; - Projectile.friendly = true; - Projectile.DamageType = DamageClass.Ranged; - Projectile.penetrate = 1; - Projectile.aiStyle = ProjAIStyleID.Arrow; - Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; - } - - public override void AI() - { - Projectile.velocity.X *= 0.9995f; - Projectile.velocity.Y = Projectile.velocity.Y + 0.01f; - Projectile.rotation = Projectile.velocity.ToRotation(); - if (Projectile.direction == -1) - Projectile.rotation += MathHelper.Pi; - } - - public override void OnKill(int timeLeft) - { - SoundEngine.PlaySound(SoundID.Item10, Projectile.Center); - Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); - Projectile.width = 16; - Projectile.height = 16; - Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); - Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); - for (int i = 0; i < 5; i++) - { - int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.SnowBlock, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1f); - Main.dust[dust].noGravity = true; - Main.dust[dust].velocity *= 2f; - } - } - } -} diff --git a/Projectiles/Ranged/SmallCoral.png b/Projectiles/Ranged/SmallCoral.png deleted file mode 100644 index 10aba07451..0000000000 Binary files a/Projectiles/Ranged/SmallCoral.png and /dev/null differ diff --git a/Projectiles/Ranged/SporeBomb.cs b/Projectiles/Ranged/SporeBomb.cs index 8dce1067ed..c1b5d6dde9 100644 --- a/Projectiles/Ranged/SporeBomb.cs +++ b/Projectiles/Ranged/SporeBomb.cs @@ -90,6 +90,7 @@ namespace CalamityMod.Projectiles.Ranged { Main.projectile[proj].DamageType = DamageClass.Ranged; Main.projectile[proj].usesLocalNPCImmunity = true; + Main.projectile[proj].usesIDStaticNPCImmunity = false; Main.projectile[proj].localNPCHitCooldown = 30; } } diff --git a/Projectiles/Rogue/SandDollarFrag.cs b/Projectiles/Rogue/SandDollarFrag.cs new file mode 100644 index 0000000000..7d0df79ccf --- /dev/null +++ b/Projectiles/Rogue/SandDollarFrag.cs @@ -0,0 +1,46 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +namespace CalamityMod.Projectiles.Rogue +{ + public class SandDollarFrag : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; // Gets overridden in PreDraw anyways + public override void SetDefaults() + { + Projectile.width = 16; + Projectile.height = 22; + Projectile.friendly = true; + Projectile.DamageType = RogueDamageClass.Instance; + } + + public override void AI() + { + Projectile.velocity.Y += 0.11f; + if (Projectile.velocity.Y > 16f) + Projectile.velocity.Y = 16f; + Projectile.rotation += Projectile.velocity.X * 0.025f; + } + + public override void OnKill(int timeLeft) + { + for (int i = 0; i < 5; i++) + { + int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Sand, Projectile.oldVelocity.X / 4, Projectile.oldVelocity.Y / 4, 0, new Color(234, 183, 100), 1f); + Main.dust[dust].noGravity = true; + Main.dust[dust].velocity *= 2f; + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = ModContent.Request("CalamityMod/Projectiles/Rogue/SandDollarFrag" + Projectile.ai[0].ToString()).Value; + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, tex.Size() / 2f, 1f, SpriteEffects.None); + return false; + } + } +} diff --git a/Projectiles/Rogue/SandDollarFrag1.png b/Projectiles/Rogue/SandDollarFrag1.png new file mode 100644 index 0000000000..caffaafff7 Binary files /dev/null and b/Projectiles/Rogue/SandDollarFrag1.png differ diff --git a/Projectiles/Rogue/SandDollarFrag2.png b/Projectiles/Rogue/SandDollarFrag2.png new file mode 100644 index 0000000000..1e318bc1f0 Binary files /dev/null and b/Projectiles/Rogue/SandDollarFrag2.png differ diff --git a/Projectiles/Rogue/SandDollarFrag3.png b/Projectiles/Rogue/SandDollarFrag3.png new file mode 100644 index 0000000000..33c162ee37 Binary files /dev/null and b/Projectiles/Rogue/SandDollarFrag3.png differ diff --git a/Projectiles/Rogue/SandDollarProj.cs b/Projectiles/Rogue/SandDollarProj.cs index 85e86a89df..0b370a56a6 100644 --- a/Projectiles/Rogue/SandDollarProj.cs +++ b/Projectiles/Rogue/SandDollarProj.cs @@ -1,4 +1,9 @@ -using Microsoft.Xna.Framework; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue @@ -8,31 +13,98 @@ namespace CalamityMod.Projectiles.Rogue public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/SandDollar"; + public ref float Timer => ref Projectile.ai[0]; + public ref float BounceCheck => ref Projectile.ai[1]; + private const int Pierce = 2; public override void SetDefaults() { Projectile.width = 30; Projectile.height = 28; Projectile.DamageType = RogueDamageClass.Instance; Projectile.friendly = true; - Projectile.penetrate = -1; - Projectile.aiStyle = ProjAIStyleID.Boomerang; - Projectile.timeLeft = 300; - AIType = ProjectileID.Bananarang; + Projectile.penetrate = Pierce; + Projectile.timeLeft = 600; Projectile.usesIDStaticNPCImmunity = true; - Projectile.idStaticNPCHitCooldown = 10; + Projectile.idStaticNPCHitCooldown = 25; } + public override void AI() + { + Timer++; + Projectile.rotation += BounceCheck > 0f ? 0.35f : 0.2f; + // Bouncing resets the timer for use in fading in its glow + if (Timer >= 30f || BounceCheck > 0f) + { + if (BounceCheck > 0f && Projectile.Calamity().stealthStrike) + Projectile.velocity *= 0.975f; + else + { + Projectile.velocity.X *= BounceCheck > 0f ? 0.985f : 0.998f; + Projectile.velocity.Y += 0.0375f; + } + } + if (Projectile.velocity.Y > 8f) + Projectile.velocity.Y = 8f; + + // Random dust after bouncing + if (BounceCheck > 0f || Projectile.Calamity().stealthStrike) + { + Vector2 dustPos = Projectile.Center + Main.rand.NextVector2CircularEdge(20f, 15f); + Vector2 dustVel = Utils.DirectionTo(Projectile.Center, dustPos).RotatedBy(MathHelper.PiOver2) * 2f; + Dust dust = Dust.NewDustPerfect(dustPos, DustID.Sand, dustVel, Scale: 0.75f); + dust.noGravity = true; + } + } + public override bool? CanDamage() => BounceCheck > 0f && Projectile.Calamity().stealthStrike ? false : null; + public override bool OnTileCollide(Vector2 oldVelocity) { - Projectile.ai[0] += 0.1f; - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; - } - if (Projectile.velocity.Y != oldVelocity.Y) + // Should only bounce if it hasn't bounced before, hasn't pierced an enemy, and is hitting a floor (moving downwards) + if (BounceCheck == 0f && (Projectile.penetrate == Pierce || Projectile.Calamity().stealthStrike) && Projectile.velocity.Y != oldVelocity.Y && oldVelocity.Y > 0f) { + BounceCheck = 1f; + Timer = 0f; + Projectile.penetrate = 1; Projectile.velocity.Y = -oldVelocity.Y; + if (Projectile.velocity.Y < -4f) + Projectile.velocity.Y = -4f; + + // Summon a duststorm on stealth strikes + if (Projectile.Calamity().stealthStrike && Main.myPlayer == Projectile.owner) + { + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage / 4, 1f, Projectile.owner, Projectile.whoAmI); + } + return false; } + return true; + } + + public override void OnKill(int timeLeft) + { + for (int s = 0; s < 8; s++) + { + Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.Sand, Scale: 0.9f); + dust.noGravity = true; + } + + if (BounceCheck > 0f && Main.myPlayer == Projectile.owner) + { + for (int i = 1; i <= 3; i++) + { + Vector2 velocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(3f, 4.5f); + int p = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4f), 0f, Projectile.owner, i); + Main.projectile[p].rotation = Main.rand.NextFloat(MathHelper.TwoPi); + } + } + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = TextureAssets.Projectile[Type].Value; + Vector2 stretch = new Vector2(MathHelper.Lerp(1.2f, 0.8f, (float)Math.Abs(Math.Sin(Projectile.rotation))), MathHelper.Lerp(0.85f, 1.15f, (float)Math.Abs(Math.Sin(Projectile.rotation)))); + Color drawColor = BounceCheck > 0f ? Color.Lerp(lightColor, Color.White, MathHelper.Clamp(Timer / 60f, 0f, 0.5f)) : lightColor; + + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, drawColor, Projectile.rotation, tex.Size() / 2f, stretch, SpriteEffects.None); return false; } } diff --git a/Projectiles/Rogue/SandDollarStealth.cs b/Projectiles/Rogue/SandDollarStealth.cs index 5eed13c7f0..1a7b49c931 100644 --- a/Projectiles/Rogue/SandDollarStealth.cs +++ b/Projectiles/Rogue/SandDollarStealth.cs @@ -1,58 +1,74 @@ -using CalamityMod.Projectiles.Ranged; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class SandDollarStealth : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/SandDollar"; + public override string Texture => "CalamityMod/Projectiles/Typeless/SandCloakVeil"; + private const float Radius = 96f; + private const int StartTime = 180; + private bool shouldDie = false; public override void SetDefaults() { Projectile.width = 30; Projectile.height = 28; Projectile.DamageType = RogueDamageClass.Instance; Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; Projectile.penetrate = -1; - Projectile.aiStyle = ProjAIStyleID.Boomerang; - Projectile.timeLeft = 300; - AIType = ProjectileID.Bananarang; + Projectile.timeLeft = StartTime; + Projectile.Opacity = 0f; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 10; } - public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => OnHitEffects(); - - public override void OnHitPlayer(Player target, Player.HurtInfo info) => OnHitEffects(); - - private void OnHitEffects() + public override void AI() { - int coralAmt = Main.rand.Next(1, 4); - if (Projectile.owner == Main.myPlayer && Projectile.Calamity().stealthStrike) + Projectile disk = Main.projectile[(int)Projectile.ai[0]]; + Projectile.rotation += 0.025f; + + if (disk.active) { - for (int coralCount = 0; coralCount < coralAmt; coralCount++) + if (!shouldDie) { - Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); - int coral = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, velocity, ModContent.ProjectileType(), Projectile.damage / 3, 0f, Projectile.owner); - if (coral.WithinBounds(Main.maxProjectiles)) - Main.projectile[coral].DamageType = RogueDamageClass.Instance; + Projectile.Center = disk.Center + disk.velocity; + Projectile.timeLeft = 20; } - } - } - public override bool OnTileCollide(Vector2 oldVelocity) - { - Projectile.ai[0] += 0.1f; - if (Projectile.velocity.X != oldVelocity.X) - { - Projectile.velocity.X = -oldVelocity.X; } - if (Projectile.velocity.Y != oldVelocity.Y) + else + shouldDie = true; + + if (Projectile.timeLeft >= 20) + Projectile.Opacity += 0.05f; + else + Projectile.Opacity -= 0.05f; + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) => modifiers.HitDirectionOverride = (target.Center.X > Projectile.Center.X).ToDirectionInt(); + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Radius, targetHitbox); + + public override bool PreDraw(ref Color lightColor) + { + Texture2D tex = TextureAssets.Projectile[Type].Value; + float scaleStep = 0.05f; + Color drawCol = Projectile.GetAlpha(Color.Lerp(lightColor, Color.White, 0.5f)); + float drawTransparency = 0.2f; + + if (Projectile.timeLeft > StartTime - 20) + drawTransparency *= Utils.GetLerpValue(StartTime - 20, StartTime, Projectile.timeLeft, true); + else if (Projectile.timeLeft < 20) + drawTransparency *= Utils.GetLerpValue(0, 20, Projectile.timeLeft, true); + + for (int i = 0; i < 20; i++) { - Projectile.velocity.Y = -oldVelocity.Y; + float rotation = (Projectile.rotation + scaleStep * i) * (i % 2 == 0).ToDirectionInt(); + Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, drawCol * drawTransparency, rotation, tex.Size() / 2f, (Radius * 0.0044f) - (i * scaleStep), SpriteEffects.None); } return false; } diff --git a/Projectiles/Typeless/BabyCannonballProjectile.cs b/Projectiles/Typeless/BabyCannonballProjectile.cs index 15f00571b0..2dcca5f59d 100644 --- a/Projectiles/Typeless/BabyCannonballProjectile.cs +++ b/Projectiles/Typeless/BabyCannonballProjectile.cs @@ -31,7 +31,7 @@ namespace CalamityMod.Projectiles.Ranged Projectile.tileCollide = false; Projectile.alpha = 255; Projectile.MaxUpdates = 3; - Projectile.timeLeft = 600; + Projectile.timeLeft = 150 * Projectile.MaxUpdates;; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 11; } diff --git a/Projectiles/Typeless/BatholithBangleProjectile.cs b/Projectiles/Typeless/BatholithBangleProjectile.cs new file mode 100644 index 0000000000..8cb026e4c2 --- /dev/null +++ b/Projectiles/Typeless/BatholithBangleProjectile.cs @@ -0,0 +1,203 @@ +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Accessories; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class BatholithBangleProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public int damageTime = 120; + public int Soundtime1 = 84; + public int Soundtime2 = 90; + public int Soundtime3 = 96; + public int Soundtime4 = 107; + public SlotId SoundSlot; + public Color clr1 = new Color(59, 28, 136); // Light Granite + public Color clr2 = new Color(16, 14, 36); // Dark Granite + public Color clr3 = new Color(23, 186, 218); // Granite energy + public int spinDir = 1; + public bool invalidTarget => (Projectile.ai[0] < 0f || Projectile.ai[0] > 199f || !Main.npc[(int)Projectile.ai[0]].active || Main.npc[(int)Projectile.ai[0]].life <= 0); + public Player Owner => Main.player[Projectile.owner]; + public bool visual => Owner.Calamity().batholithBangleVisual; + public override void SetDefaults() + { + Projectile.width = 120; + Projectile.height = 120; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = damageTime + 2; + Projectile.ArmorPenetration = 35; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.scale = 0.8f; + } + public override void AI() + { + if (time == 0 && visual) + { + spinDir = Main.rand.NextBool() ? 1 : -1; + SoundStyle sound = new("CalamityMod/Sounds/Item/BatholithBangleSound"); + SoundSlot = SoundEngine.PlaySound(sound with { Volume = 1f, MaxInstances = -1 }, Projectile.Center); + } + if (!invalidTarget) + Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; + else if (time < Soundtime2) + { + NPC target = Projectile.Center.ClosestNPCAt(400, true, true); + Projectile.ai[0] = (target == null ? -1 : target.whoAmI); + } + + if (time > Soundtime1) + { + Projectile.rotation += 0.23f * spinDir * (float)Math.Pow(Utils.GetLerpValue(damageTime, Soundtime2, time, true), 1); + } + + float stabLerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime4, damageTime, time, true), 8); + Vector2 triPlace = (Vector2.UnitY * (230 - 150 * stabLerp)) * Projectile.scale; + if (time == Soundtime2) + MakePusle(Projectile.Center + triPlace.RotatedBy(Projectile.rotation)); + if (time == Soundtime3) + MakePusle(Projectile.Center + triPlace.RotatedBy(Projectile.rotation + MathHelper.TwoPi / 3)); + if (time == Soundtime4) + MakePusle(Projectile.Center + triPlace.RotatedBy(Projectile.rotation - MathHelper.TwoPi / 3)); + if (time == damageTime) + { + float visMult = (visual ? 1 : 0.6f); + if (visual) + { + Owner.Calamity().GeneralScreenShakePower = 5f; + + Particle spark = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 12, 1.35f, clr3, Projectile.scale * new Vector2(2.5f, 1.3f), true, true, shrinkSpeed: 1.25f, extraRotation: MathHelper.PiOver2); + GeneralParticleHandler.SpawnParticle(spark); + Particle spark2 = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 10, 1.05f, clr3, Projectile.scale * new Vector2(2f, 1.3f), true, true, shrinkSpeed: 0.7f); + GeneralParticleHandler.SpawnParticle(spark2); + + Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, clr1, "CalamityMod/Particles/BloomRing", Projectile.scale * new Vector2(0.6f, 1.4f), 0, 0.3f, 1.35f, 15); + GeneralParticleHandler.SpawnParticle(pulse); + Particle pulse2 = new CustomPulse(Projectile.Center, Vector2.Zero, clr1, "CalamityMod/Particles/BloomRing", Projectile.scale * new Vector2(1.3f, 0.7f), 0, 0.25f, 1f, 15); + GeneralParticleHandler.SpawnParticle(pulse2); + + } + + for (int i = 0; i < 12; i++) + { + Vector2 vel = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5, 10); + Particle granite = new CustomSpark(Projectile.Center, vel, "CalamityMod/Particles/GlowTriangle", true, Main.rand.Next(30, 55 + 1), Projectile.scale * Main.rand.NextFloat(0.12f, 0.18f), (Main.rand.NextBool() ? clr1 : clr3) * visMult, Vector2.One, true, false, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.5f, 0.5f)); + GeneralParticleHandler.SpawnParticle(granite); + } + } + + if (SoundEngine.TryGetActiveSound(SoundSlot, out var Sound) && Sound.IsPlaying) + Sound.Position = Projectile.Center; + time++; + } + public void MakePusle(Vector2 position) + { + if (!visual) + return; + for (int i = 0; i < 8; i++) + { + Vector2 outerVel = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(1, 5); + Particle marble = new CustomSpark(position + outerVel * 5, outerVel, "CalamityMod/Particles/BloomCircle", false, Main.rand.Next(18, 25 + 1), Projectile.scale * Main.rand.NextFloat(0.3f, 0.4f), Main.rand.NextBool() ? clr1 : clr3, Vector2.One, true, true, extraRotation: Main.rand.NextFloat(-4, 4), spin: Main.rand.NextFloat(-0.3f, 0.3f), glowOpacity: 0.8f); + GeneralParticleHandler.SpawnParticle(marble); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + float critDamage = Math.Min(Owner.GetTotalCritChance(AverageDamageClass.Instance) * 0.01f, 1f); + modifiers.SourceDamage *= 1 + critDamage; + + Vector2 launchVel = Utils.DirectionTo(Owner.Center, target.Center) - Vector2.UnitY; + float launchPower = 9; + target.MoveNPC(launchVel, launchPower, true); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + bool hasCD = Owner.Calamity().cooldowns.TryGetValue(GenericBandCooldown.ID, out CooldownInstance bandCD); + + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Owner.Calamity().generalBandCooldown > BatholithBangle.cooldown / 2) + { + Owner.Calamity().generalBandCooldown -= BatholithBangle.cooldown / 2; + if (hasCD) + bandCD.timeLeft -= BatholithBangle.cooldown / 2; + } + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f, targetHitbox); + public override bool? CanDamage() + { + if (time >= damageTime && Projectile.numHits <= 0) + return null; + else + return false; + } + public override bool? CanHitNPC(NPC target) + { + if ((invalidTarget || Projectile.ai[0] == target.whoAmI) && Projectile.numHits <= 0) + return null; + return false; + } + public override bool PreDraw(ref Color lightColor) + { + if (!visual) + return false; + Asset tri = ModContent.Request("CalamityMod/Particles/GlowTriangle"); + Asset shine = ModContent.Request("CalamityMod/Particles/BloomCircle"); + + float stabLerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime4, damageTime, time, true), 8); + Vector2 triPlace = Vector2.UnitY * (230 - 150 * stabLerp) * Projectile.scale; + + for (int i = 0; i < 6; i++) + { + float scale = Projectile.scale * (0.3f - 0.015f * i); + float rotation = Projectile.rotation; + float spawnScaleBonus = 0.3f; + float squashPower = 0.4f; + Color triColor = Color.Lerp(clr1, clr3, i * 0.14f); + if (time >= Soundtime2) + { + float lerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime2 + 13, Soundtime2, time, true), 2); + Main.EntitySpriteDraw(tri.Value, Projectile.Center + triPlace.RotatedBy(rotation) - Main.screenPosition, null, triColor with { A = 0 }, rotation + MathHelper.Pi * lerp, tri.Size() * 0.5f, Projectile.scale * new Vector2(0.05f * i + 1 - squashPower * (1 - lerp), -0.05f * i + 1 + squashPower * (1 - lerp)) * (scale + spawnScaleBonus * lerp), SpriteEffects.None); + } + if (time >= Soundtime3) + { + rotation += MathHelper.TwoPi / 3; + float lerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime3 + 13, Soundtime3, time, true), 2); + Main.EntitySpriteDraw(tri.Value, Projectile.Center + triPlace.RotatedBy(rotation) - Main.screenPosition, null, triColor with { A = 0 }, rotation + MathHelper.Pi * lerp, tri.Size() * 0.5f, Projectile.scale * new Vector2(0.05f * i + 1 - squashPower * (1 - lerp), -0.05f * i + 1 + squashPower * (1 - lerp)) * (scale + spawnScaleBonus * lerp), SpriteEffects.None); + } + if (time >= Soundtime4) + { + rotation += MathHelper.TwoPi / 3; + float lerp = (float)Math.Pow(Utils.GetLerpValue(Soundtime4 + 13, Soundtime4, time, true), 2); + Main.EntitySpriteDraw(tri.Value, Projectile.Center + triPlace.RotatedBy(rotation) - Main.screenPosition, null, triColor with { A = 0 }, rotation + MathHelper.Pi * lerp, tri.Size() * 0.5f, Projectile.scale * new Vector2(0.05f * i + 1 - squashPower * (1 - lerp), -0.05f * i + 1 + squashPower * (1 - lerp)) * (scale + spawnScaleBonus * lerp), SpriteEffects.None); + } + + } + for (int i = 0; i < 4; i++) + { + float shineLerp = (float)Math.Pow(Utils.GetLerpValue(0, Soundtime4, time, true), 3); + Color clrLerp = Color.Lerp(clr1, clr3, i * 0.3f); + Color shineColor = Color.Lerp(clrLerp, Color.White, i * 0.2f) * shineLerp; + float shineScale = Projectile.scale * 0.4f + 0.3f * shineLerp; + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, shineColor with { A = 0 }, MathHelper.PiOver2, shine.Size() * 0.5f, new Vector2(0.5f - i * 0.15f, 1 + i * 0.2f) * (1 - i * 0.2f) * shineScale, SpriteEffects.None); + Main.EntitySpriteDraw(shine.Value, Projectile.Center - Main.screenPosition, null, shineColor with { A = 0 }, 0, shine.Size() * 0.5f, new Vector2(0.5f - i * 0.15f, 1 + i * 0.2f) * (1 - i * 0.1f) * shineScale, SpriteEffects.None); + } + return false; + } + } +} diff --git a/Projectiles/Typeless/BlackGlassBandProjectile.cs b/Projectiles/Typeless/BlackGlassBandProjectile.cs index 77b1d0e8db..b48eb8ccb2 100644 --- a/Projectiles/Typeless/BlackGlassBandProjectile.cs +++ b/Projectiles/Typeless/BlackGlassBandProjectile.cs @@ -1,7 +1,7 @@ -using CalamityMod.Items.Accessories; -using CalamityMod.Items.Weapons.Ranged; +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Accessories; using CalamityMod.Particles; -using CalamityMod.Tiles.Ores; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; @@ -13,6 +13,8 @@ namespace CalamityMod.Projectiles.Typeless { public new string LocalizationCategory => "Projectiles.Typeless"; public int time = 0; + public Player Owner => Main.player[Projectile.owner]; + public bool visual => Owner.Calamity().bGlassBandVisual; public override void SetDefaults() { Projectile.width = 2; @@ -30,27 +32,29 @@ namespace CalamityMod.Projectiles.Typeless { if (time == 0) { - SoundStyle sound = AuricOre.MineSound; - SoundEngine.PlaySound(sound with { Volume = 0.9f, Pitch = Main.rand.NextFloat(0.15f, 0.25f), MaxInstances = -1 }, Projectile.Center); - SoundStyle sound2 = NullificationPistol.HitSound; - SoundEngine.PlaySound(sound2 with { Volume = 0.6f, Pitch = Main.rand.NextFloat(0.3f, 0.45f), MaxInstances = -1 }, Projectile.Center); + float visMult = (visual ? 1 : 0.3f); + SoundStyle sound = new("CalamityMod/Sounds/Item/BlackGlassBandSound"); + if (visual) + { + SoundEngine.PlaySound(sound with { Volume = 1f, MaxInstances = -1 }, Projectile.Center); + float randRot = Main.rand.NextFloat(0, MathHelper.Pi); + for (int i = -1; i <= 1; i += 2) + { + Vector2 position = Projectile.Center + (Vector2.UnitX * 20 * i).RotatedBy(randRot); + Particle spark = new CustomSpark(position, Vector2.UnitY.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); + GeneralParticleHandler.SpawnParticle(spark); + } + for (int i = -1; i <= 1; i += 2) + { + Vector2 position = Projectile.Center + (Vector2.UnitY * 20 * i).RotatedBy(randRot); + Particle spark = new CustomSpark(position, Vector2.UnitX.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); + GeneralParticleHandler.SpawnParticle(spark); + } + } for (int i = 0; i < 18; i++) { - Particle spark = new CustomSpark(Projectile.Center, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f), "CalamityMod/Particles/GlowOrbParticle", true, 35, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.NextBool() ? Color.DarkSlateBlue : Color.MediumPurple, new Vector2(0.8f, 1.2f), false); - GeneralParticleHandler.SpawnParticle(spark); - } - float randRot = Main.rand.NextFloat(0, MathHelper.Pi); - for (int i = -1; i <= 1; i += 2) - { - Vector2 position = Projectile.Center + (Vector2.UnitX * 20 * i).RotatedBy(randRot); - Particle spark = new CustomSpark(position, Vector2.UnitY.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); - GeneralParticleHandler.SpawnParticle(spark); - } - for (int i = -1; i <= 1; i += 2) - { - Vector2 position = Projectile.Center + (Vector2.UnitY * 20 * i).RotatedBy(randRot); - Particle spark = new CustomSpark(position, Vector2.UnitX.RotatedBy(randRot) * 0.001f, "CalamityMod/Particles/GlowSpark", false, 15, 0.03f, Color.DarkSlateBlue, new Vector2(7f, 0.2f), true, shrinkSpeed: 0.55f); + Particle spark = new CustomSpark(Projectile.Center, new Vector2(9, 9).RotatedByRandom(100) * Main.rand.NextFloat(0.3f, 1f), "CalamityMod/Particles/GlowOrbParticle", true, 35, Main.rand.NextFloat(0.6f, 0.8f), (Main.rand.NextBool() ? Color.DarkSlateBlue : Color.MediumPurple) * visMult, new Vector2(0.8f, 1.2f), false); GeneralParticleHandler.SpawnParticle(spark); } } @@ -59,12 +63,23 @@ namespace CalamityMod.Projectiles.Typeless public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { modifiers.SetCrit(); + float critDamage = Math.Min(Owner.GetTotalCritChance(AverageDamageClass.Instance) * 0.01f, 1f); + modifiers.SourceDamage *= (1 + critDamage); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - Player Owner = Main.player[Projectile.owner]; - if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Owner.Calamity().bGlassbandCooldown > BlackGlassBand.cooldown / 2) - Owner.Calamity().bGlassbandCooldown = BlackGlassBand.cooldown / 2; + bool hasCD = Owner.Calamity().cooldowns.TryGetValue(GenericBandCooldown.ID, out CooldownInstance bandCD); + + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Owner.Calamity().generalBandCooldown > BlackGlassBand.cooldown / 2) + { + Owner.Calamity().generalBandCooldown -= BlackGlassBand.cooldown / 2; + if (hasCD) + bandCD.timeLeft -= BlackGlassBand.cooldown / 2; + } + } + public override bool? CanDamage() + { + return null; } } } diff --git a/Projectiles/Typeless/BloodBomb.cs b/Projectiles/Typeless/BloodBomb.cs index a1b97fc5f4..c0252c1c57 100644 --- a/Projectiles/Typeless/BloodBomb.cs +++ b/Projectiles/Typeless/BloodBomb.cs @@ -17,8 +17,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.height = 20; Projectile.friendly = true; Projectile.penetrate = 1; - Projectile.extraUpdates = 1; - Projectile.timeLeft = 600; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 180 * Projectile.MaxUpdates; } public override void AI() diff --git a/Projectiles/Typeless/BloomStoneFlower.cs b/Projectiles/Typeless/BloomStoneFlower.cs new file mode 100644 index 0000000000..596a08d25f --- /dev/null +++ b/Projectiles/Typeless/BloomStoneFlower.cs @@ -0,0 +1,86 @@ +using CalamityMod.Dusts; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class BloomStoneFlower : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/Magic/BeamingBolt"; + + public ref float HookIndex => ref Projectile.ai[0]; + public ref float FlowerPart => ref Projectile.ai[1]; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 30; + Projectile.scale = 1.2f; + Projectile.friendly = true; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 300; + } + + public override void AI() + { + switch (FlowerPart) + { + case 0: + Projectile hook = Main.projectile[(int)HookIndex]; + if (!(hook.active && hook.aiStyle == ProjAIStyleID.Hook && hook.ai[0] == 2f)) + { + Projectile.Kill(); + return; + } + + Projectile.timeLeft = 5; + if (Vector2.DistanceSquared(Projectile.Center, Main.player[Projectile.owner].Center) < 1024f) + { + SoundEngine.PlaySound(SoundID.Item60, Projectile.Center); + if (Main.myPlayer == Projectile.owner) + { + for (int i = 0; i < 5; i++) + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Main.rand.NextVector2Circular(4f, 4f), Type, 0, 0f, Projectile.owner, 0f, 1f); + } + Projectile.Kill(); + } + break; + case 1: + if (Projectile.width < 90) + Projectile.ExpandHitboxBy(90); + Projectile.velocity *= 0.98f; + + // Visual effect + if (Projectile.timeLeft % 10 == 0) + { + MediumMistParticle pollenCloud = new(Projectile.Center, Main.rand.NextVector2Circular(1f, 1f), Color.Yellow, Color.Gold, 3f, 100f); + GeneralParticleHandler.SpawnParticle(pollenCloud); + } + if (Projectile.timeLeft % 4 == 0) + { + Dust pollenDust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, ModContent.DustType(), newColor: Color.Gold, Scale: 0.6f); + pollenDust.noLightEmittence = true; + pollenDust.noGravity = true; + } + + // Check for buffing + Player owner = Main.player[Projectile.owner]; + foreach (Player p in Main.ActivePlayers) + { + if (!(p == owner || (p.team == owner.team && owner.team != 0))) + continue; + + if (Projectile.Hitbox.Intersects(p.Hitbox)) + p.Calamity().bloomStoneDR = 360; + } + break; + } + } + + public override bool PreDraw(ref Color lightColor) => FlowerPart == 0f; + } +} diff --git a/Projectiles/Typeless/ClaretCannonProj.cs b/Projectiles/Typeless/ClaretCannonProj.cs index 12f7022009..01f9f28319 100644 --- a/Projectiles/Typeless/ClaretCannonProj.cs +++ b/Projectiles/Typeless/ClaretCannonProj.cs @@ -24,9 +24,9 @@ namespace CalamityMod.Projectiles.Typeless Projectile.friendly = true; Projectile.alpha = 0; Projectile.penetrate = 1; - Projectile.timeLeft = 600; Projectile.DamageType = AverageDamageClass.Instance; - Projectile.extraUpdates = 1; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 120 * Projectile.MaxUpdates; Projectile.aiStyle = 0; } @@ -78,4 +78,4 @@ namespace CalamityMod.Projectiles.Typeless GeneralParticleHandler.SpawnParticle(bloodsplosion2); } } -} +} \ No newline at end of file diff --git a/Projectiles/Typeless/DirectStrike.cs b/Projectiles/Typeless/DirectStrike.cs index 7cdb417153..fd9cb07627 100644 --- a/Projectiles/Typeless/DirectStrike.cs +++ b/Projectiles/Typeless/DirectStrike.cs @@ -51,7 +51,7 @@ namespace CalamityMod.Projectiles.Typeless if (projHitbox.Intersects(targetHitbox)) { NPC target = Main.npc[(int)Projectile.ai[0]]; - if (pushVelocity != Vector2.Zero && !invalidTarget && target.CanBeMoved(hasStongDisplacement)) + if (pushVelocity != Vector2.Zero && pushVelocity.X < 255f && !invalidTarget && target.CanBeMoved(hasStongDisplacement)) { target.velocity = (pushVelocity * (target.knockBackResist == 0 ? 0.5f : 1)); } diff --git a/Projectiles/Typeless/GhostlyBolt.cs b/Projectiles/Typeless/GhostlyBolt.cs index ceb42cf336..cddc5fef7a 100644 --- a/Projectiles/Typeless/GhostlyBolt.cs +++ b/Projectiles/Typeless/GhostlyBolt.cs @@ -18,10 +18,8 @@ namespace CalamityMod.Projectiles.Typeless Projectile.friendly = true; Projectile.alpha = 255; Projectile.penetrate = 1; - Projectile.extraUpdates = 1; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 6; - Projectile.timeLeft = 900; + Projectile.MaxUpdates = 2; + Projectile.timeLeft = 180 * Projectile.MaxUpdates; Projectile.ignoreWater = true; Projectile.tileCollide = false; } diff --git a/Projectiles/Typeless/ProtolithBangleProjectile.cs b/Projectiles/Typeless/ProtolithBangleProjectile.cs new file mode 100644 index 0000000000..ca833e6d43 --- /dev/null +++ b/Projectiles/Typeless/ProtolithBangleProjectile.cs @@ -0,0 +1,138 @@ +using System; +using CalamityMod.Cooldowns; +using CalamityMod.Items.Accessories; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using ReLogic.Utilities; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class ProtolithBangleProjectile : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public int time = 0; + public int damageTime = 24; + public int Soundtime1 = 2; + public int Soundtime2 = 8; + public int Soundtime3 = 15; + public int explosionSize = 230; + public SlotId SoundSlot; + public Player Owner => Main.player[Projectile.owner]; + public bool visual => Owner.Calamity().protolithBangleVisual; + public override void SetDefaults() + { + Projectile.width = explosionSize; + Projectile.height = explosionSize; + Projectile.friendly = true; + Projectile.penetrate = -1; + Projectile.extraUpdates = 0; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.alpha = 255; + Projectile.timeLeft = damageTime + 20; + Projectile.ArmorPenetration = 25; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = -1; + Projectile.scale = 0.8f; + } + public override void AI() + { + if (!(Projectile.ai[0] < 0f || Projectile.ai[0] > 199f) && time <= damageTime && Main.npc[(int)Projectile.ai[0]].active && Main.npc[(int)Projectile.ai[0]].life > 0) + Projectile.Center = Main.npc[(int)Projectile.ai[0]].Center; + + Vector2 particlePlace = Vector2.UnitY * 40; + if (time == Soundtime1) + { + MakePusle(Projectile.Center + particlePlace); + } + if (time == Soundtime2) + { + MakePusle(Projectile.Center + particlePlace.RotatedBy(MathHelper.TwoPi / 3)); + } + if (time == Soundtime3) + { + MakePusle(Projectile.Center + particlePlace.RotatedBy(-MathHelper.TwoPi / 3)); + } + if (time == damageTime) + { + float visMult = (visual ? 1 : 0.3f); + Projectile.ai[0] = -1; + + if (visual) + { + Particle spark = new CustomSpark(Projectile.Center, Vector2.Zero, "CalamityMod/Particles/BloomCircle", false, 15, 1.2f, Color.Gold, Projectile.scale * new Vector2(1f, 1.3f), true, true, shrinkSpeed: 0.9f); + GeneralParticleHandler.SpawnParticle(spark); + + Particle pulse = new CustomPulse(Projectile.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Projectile.scale * new Vector2(1.4f, 0.6f), 0, 0.3f, 1.35f, 15); + GeneralParticleHandler.SpawnParticle(pulse); + } + + for (int i = 0; i < 28; i++) + { + Particle marble = new CustomSpark(Projectile.Center, (Vector2.One * Main.rand.NextFloat(8, 13)).RotatedByRandom(MathHelper.TwoPi), "CalamityMod/Particles/Square", true, Main.rand.Next(40, 70 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 15, Color.Lerp(Color.White, Color.Khaki, Main.rand.NextFloat()) * visMult, new Vector2(1f, Main.rand.NextFloat(1, 2)), false, false, extraRotation: Main.rand.NextFloat(-4, 4)); + GeneralParticleHandler.SpawnParticle(marble); + } + } + if (time == 0 && visual) + { + SoundStyle sound = new("CalamityMod/Sounds/Item/ProtolithBangleSound"); + SoundSlot = SoundEngine.PlaySound(sound with { Volume = 1f, MaxInstances = -1 }, Projectile.Center); + } + if (SoundEngine.TryGetActiveSound(SoundSlot, out var Sound) && Sound.IsPlaying) + Sound.Position = Projectile.Center; + time++; + } + public void MakePusle(Vector2 position) + { + if (!visual) + return; + + Particle pulse = new CustomPulse(position, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Projectile.scale * Vector2.One, 0, 0.3f, 0.65f, 25); + GeneralParticleHandler.SpawnParticle(pulse); + + for (int i = 0; i < 18; i++) + { + Vector2 outerVel = Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(5, 7); + Particle marble = new CustomSpark(position + outerVel * 5, -outerVel * 0.6f, "CalamityMod/Particles/Square", false, Main.rand.Next(10, 15 + 1), Projectile.scale * Main.rand.NextFloat(0.08f, 0.14f) * 10, Color.Lerp(Color.White, Color.Khaki, Main.rand.NextFloat()), new Vector2(1f, Main.rand.NextFloat(1, 2)), false, false, extraRotation: Main.rand.NextFloat(-4, 4)); + GeneralParticleHandler.SpawnParticle(marble); + } + } + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + modifiers.SetCrit(); + float critDamage = Math.Min(Owner.GetTotalCritChance(AverageDamageClass.Instance) * 0.01f, 1f); + + float minMult = 0.1f; + int hitsToMinMult = 5; + float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); + modifiers.SourceDamage *= damageMult + critDamage; + + Vector2 launchVel = Utils.DirectionTo(Projectile.Center, target.Center) - Vector2.UnitY; + float launchPower = 6; + target.MoveNPC(launchVel, launchPower, true); + } + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + bool hasCD = Owner.Calamity().cooldowns.TryGetValue(GenericBandCooldown.ID, out CooldownInstance bandCD); + + if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Owner.Calamity().generalBandCooldown > ProtolithBangle.cooldown / 2) + { + Owner.Calamity().generalBandCooldown -= ProtolithBangle.cooldown / 2; + if (hasCD) + bandCD.timeLeft -= ProtolithBangle.cooldown / 2; + } + } + public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, Projectile.width * 0.5f * Projectile.scale, targetHitbox); + public override bool? CanDamage() + { + if (time >= damageTime) + return null; + else + return false; + } + } +} diff --git a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs index 831a4ae3f5..a99c92601f 100644 --- a/Projectiles/Typeless/RelicOfDeliveranceSpear.cs +++ b/Projectiles/Typeless/RelicOfDeliveranceSpear.cs @@ -478,7 +478,9 @@ namespace CalamityMod.Projectiles.Typeless public override bool PreDraw(ref Color lightColor) { Vector2 drawPos = Owner.MountedCenter + (drifting ? idealVel : Projectile.velocity).SafeNormalize(Vector2.UnitX) * (55 - 35 * Utils.GetLerpValue(0, 25, driftTimer, true)); - Projectile.DrawProjectileWithBackglow(Color.Goldenrod with { A = 0 }, Color.White, 3f * driftPowerScaling, effects: Math.Sign((drifting ? idealVel.X : Projectile.velocity.X)) == -1 ? Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically : Microsoft.Xna.Framework.Graphics.SpriteEffects.None, xPos: drawPos.X, yPos: drawPos.Y); + Projectile.DrawProjectileWithBackglow(Color.Goldenrod with { A = 0 }, Color.White, 3f * driftPowerScaling, effects: Math.Sign((drifting ? idealVel.X : Projectile.velocity.X)) == -1 ? SpriteEffects.FlipVertically : SpriteEffects.None, xPos: drawPos.X, yPos: drawPos.Y); + //Asset texBase = ModContent.Request(Texture); + //Main.EntitySpriteDraw(texBase.Value, drawPos, null, Color.White, Projectile.rotation, texBase.Size() * 0.5f, Projectile.scale, Math.Sign((drifting ? idealVel.X : Projectile.velocity.X)) == -1 ? Microsoft.Xna.Framework.Graphics.SpriteEffects.FlipVertically : Microsoft.Xna.Framework.Graphics.SpriteEffects.None); Texture2D texture = ModContent.Request("CalamityMod/Particles/BloomRing").Value; Texture2D texture2 = ModContent.Request("CalamityMod/Particles/GlowSpark").Value; diff --git a/Projectiles/Typeless/WulfrumHook.cs b/Projectiles/Typeless/WulfrumHook.cs index 493644d923..448039accf 100644 --- a/Projectiles/Typeless/WulfrumHook.cs +++ b/Projectiles/Typeless/WulfrumHook.cs @@ -16,6 +16,7 @@ namespace CalamityMod.Projectiles.Typeless { public new string LocalizationCategory => "Projectiles.Typeless"; public Player Owner => Main.player[Projectile.owner]; + public int EquippedHook => Owner.miscEquips[4].type; public HookState State { @@ -117,7 +118,7 @@ namespace CalamityMod.Projectiles.Typeless Point tilePos = Projectile.Center.ToTileCoordinates(); Tile tile = Main.tile[tilePos]; - if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo() || Owner.IsBlacklistedForGrappling(tilePos)) + if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo(EquippedHook == ItemID.SquirrelHook) || Owner.IsBlacklistedForGrappling(tilePos)) State = HookState.Retracting; Projectile.velocity = Vector2.Zero; @@ -153,7 +154,7 @@ namespace CalamityMod.Projectiles.Typeless Tile tile = Main.tile[tilePos]; - if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo() || Owner.IsBlacklistedForGrappling(tilePos)) + if (!tile.HasUnactuatedTile || !tile.CanTileBeLatchedOnTo(EquippedHook == ItemID.SquirrelHook) || Owner.IsBlacklistedForGrappling(tilePos)) continue; if (Main.myPlayer != Owner.whoAmI) continue; @@ -178,6 +179,7 @@ namespace CalamityMod.Projectiles.Typeless //Hook onto the tile Projectile.velocity = Vector2.Zero; State = HookState.Grappling; + Projectile.Center = grapplePos + Vector2.One * 8f; //effects WorldGen.KillTile(x, y, fail: true, effectOnly: true); @@ -190,7 +192,8 @@ namespace CalamityMod.Projectiles.Typeless Owner.grapCount++; //Owner.velocity = Vector2.Zero; } - + if (EquippedHook == ItemID.QueenSlimeHook) + Owner.DoQueenSlimeHookTeleport(grapplePos + new Vector2(-(Owner.Center - Projectile.Center).Length() * 0.75f, 0).RotatedBy(Projectile.DirectionTo(Owner.Center).ToRotation())); mp.SwingLength = (Owner.Center - Projectile.Center).Length(); mp.OldPosition = Owner.Center - Owner.velocity; mp.SetSegments(Projectile.Center); @@ -221,7 +224,27 @@ namespace CalamityMod.Projectiles.Typeless public Color PrimColorFunction(float completionRatio) { - return Color.Lerp(Color.DeepSkyBlue, Color.GreenYellow, (float)Math.Pow(completionRatio, 1.5D)); + Color EndColor = Color.GreenYellow; + + switch (EquippedHook) + { + case ItemID.AntiGravityHook: + EndColor = Color.Aquamarine; + break; + case ItemID.QueenSlimeHook: + EndColor = Color.HotPink; + break; + case ItemID.SquirrelHook: + EndColor = Color.DarkOrange; + break; + case ItemID.StaticHook: + EndColor = Color.Silver; + break; + default: + break; + } + + return Color.Lerp(Color.DeepSkyBlue, EndColor, (float)Math.Pow(completionRatio, 1.5D)); } public override bool PreDraw(ref Color lightColor) diff --git a/Schematics/Barbed_Stockade1.csch b/Schematics/Barbed_Stockade1.csch new file mode 100644 index 0000000000..9d07e3aec6 Binary files /dev/null and b/Schematics/Barbed_Stockade1.csch differ diff --git a/Schematics/Barbed_Stockade2.csch b/Schematics/Barbed_Stockade2.csch new file mode 100644 index 0000000000..c21b797d8a Binary files /dev/null and b/Schematics/Barbed_Stockade2.csch differ diff --git a/Schematics/Barbed_Stockade3.csch b/Schematics/Barbed_Stockade3.csch new file mode 100644 index 0000000000..eae4b2cb42 Binary files /dev/null and b/Schematics/Barbed_Stockade3.csch differ diff --git a/Schematics/Barbed_Stockade4.csch b/Schematics/Barbed_Stockade4.csch new file mode 100644 index 0000000000..a49e0c86d5 Binary files /dev/null and b/Schematics/Barbed_Stockade4.csch differ diff --git a/Schematics/Demonic_Dungeon1.csch b/Schematics/Demonic_Dungeon1.csch new file mode 100644 index 0000000000..7b7595096d Binary files /dev/null and b/Schematics/Demonic_Dungeon1.csch differ diff --git a/Schematics/Demonic_Dungeon2.csch b/Schematics/Demonic_Dungeon2.csch new file mode 100644 index 0000000000..c8116e9d3d Binary files /dev/null and b/Schematics/Demonic_Dungeon2.csch differ diff --git a/Schematics/Hellstone_Stronghold1.csch b/Schematics/Hellstone_Stronghold1.csch index e2e70d2218..f7a79c9c73 100644 Binary files a/Schematics/Hellstone_Stronghold1.csch and b/Schematics/Hellstone_Stronghold1.csch differ diff --git a/Schematics/Hellstone_Stronghold2.csch b/Schematics/Hellstone_Stronghold2.csch index ea381f966c..f05f1d9ef6 100644 Binary files a/Schematics/Hellstone_Stronghold2.csch and b/Schematics/Hellstone_Stronghold2.csch differ diff --git a/Schematics/Sanctum_of_Oblivion1.csch b/Schematics/Sanctum_of_Oblivion1.csch index 334947c89a..1746bf4e6b 100644 Binary files a/Schematics/Sanctum_of_Oblivion1.csch and b/Schematics/Sanctum_of_Oblivion1.csch differ diff --git a/Schematics/Sanctum_of_Oblivion2.csch b/Schematics/Sanctum_of_Oblivion2.csch index ec4c5a8a16..924291f7b7 100644 Binary files a/Schematics/Sanctum_of_Oblivion2.csch and b/Schematics/Sanctum_of_Oblivion2.csch differ diff --git a/Schematics/Sanctum_of_Oblivion3.csch b/Schematics/Sanctum_of_Oblivion3.csch index 9f0bc5c955..13e833b9e2 100644 Binary files a/Schematics/Sanctum_of_Oblivion3.csch and b/Schematics/Sanctum_of_Oblivion3.csch differ diff --git a/Schematics/SchematicManager.cs b/Schematics/SchematicManager.cs index d29ce284f8..f6b72244b5 100644 --- a/Schematics/SchematicManager.cs +++ b/Schematics/SchematicManager.cs @@ -55,6 +55,24 @@ namespace CalamityMod.Schematics internal const string HellstoneStrongholdType2Key = "Hellstone Stronghold Type 2 Key"; internal const string HellstoneStrongholdType2Filename = "Schematics/Hellstone_Stronghold2.csch"; + internal const string DemonicDungeonType1Key = "Demonic Dungeon Type 1 Key"; + internal const string DemonicDungeonType1Filename = "Schematics/Demonic_Dungeon1.csch"; + + internal const string DemonicDungeonType2Key = "Demonic Dungeon Type 2 Key"; + internal const string DemonicDungeonType2Filename = "Schematics/Demonic_Dungeon2.csch"; + + internal const string BarbedStockadeType1Key = "Barbed Stockade Type 1 Key"; + internal const string BarbedStockadeType1Filename = "Schematics/Barbed_Stockade1.csch"; + + internal const string BarbedStockadeType2Key = "Barbed Stockade Type 2 Key"; + internal const string BarbedStockadeType2Filename = "Schematics/Barbed_Stockade2.csch"; + + internal const string BarbedStockadeType3Key = "Barbed Stockade Type 3 Key"; + internal const string BarbedStockadeType3Filename = "Schematics/Barbed_Stockade3.csch"; + + internal const string BarbedStockadeType4Key = "Barbed Stockade Type 4 Key"; + internal const string BarbedStockadeType4Filename = "Schematics/Barbed_Stockade4.csch"; + internal const string RustedWorkshopKey = "Rusted Workshop"; internal const string RustedWorkshopFilename = "Schematics/RustedWorkshop.csch"; @@ -163,6 +181,12 @@ namespace CalamityMod.Schematics [SanctumofOblivionType3Key] = CalamitySchematicIO.LoadSchematic(SanctumofOblivionType3Filename), [HellstoneStrongholdType1Key] = CalamitySchematicIO.LoadSchematic(HellstoneStrongholdType1Filename), [HellstoneStrongholdType2Key] = CalamitySchematicIO.LoadSchematic(HellstoneStrongholdType2Filename), + [DemonicDungeonType1Key] = CalamitySchematicIO.LoadSchematic(DemonicDungeonType1Filename), + [DemonicDungeonType2Key] = CalamitySchematicIO.LoadSchematic(DemonicDungeonType2Filename), + [BarbedStockadeType1Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType1Filename), + [BarbedStockadeType2Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType2Filename), + [BarbedStockadeType3Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType3Filename), + [BarbedStockadeType4Key] = CalamitySchematicIO.LoadSchematic(BarbedStockadeType4Filename), // Draedon's Arsenal world gen structures [RustedWorkshopKey] = CalamitySchematicIO.LoadSchematic(RustedWorkshopFilename), diff --git a/Sounds/CommonCalamitySounds.cs b/Sounds/CommonCalamitySounds.cs index e6b01082d3..fd0f455921 100644 --- a/Sounds/CommonCalamitySounds.cs +++ b/Sounds/CommonCalamitySounds.cs @@ -19,7 +19,9 @@ namespace CalamityMod.Sounds public static readonly SoundStyle WyrmScreamSound = new("CalamityMod/Sounds/Custom/WyrmScream"); - public static readonly SoundStyle LightningSound = new("CalamityMod/Sounds/Custom/LightningStrike") { Volume = 1.5f }; //This is just the regular SoundID.Thunder sound, except its only the first variant + public static readonly SoundStyle LightningSound = new("CalamityMod/Sounds/Custom/LightningStrike") { Volume = 1.6f }; //This is just the regular SoundID.Thunder sound, except its only the first variant + + public static readonly SoundStyle LightningTelegraph = new("CalamityMod/Sounds/Custom/LightningTelegraph") { Volume = 0.7f }; //This is just the regular SoundID.Thunder sound, except its only the fifth variant public static readonly SoundStyle LaserCannonSound = new("CalamityMod/Sounds/Item/LaserCannon") { Volume = 0.85f }; diff --git a/Sounds/Custom/LightningTelegraph.ogg b/Sounds/Custom/LightningTelegraph.ogg new file mode 100644 index 0000000000..3a3d95c15f Binary files /dev/null and b/Sounds/Custom/LightningTelegraph.ogg differ diff --git a/Sounds/Item/BatholithBangleSound.ogg b/Sounds/Item/BatholithBangleSound.ogg new file mode 100644 index 0000000000..a9093f226f Binary files /dev/null and b/Sounds/Item/BatholithBangleSound.ogg differ diff --git a/Sounds/Item/BlackGlassBandSound.ogg b/Sounds/Item/BlackGlassBandSound.ogg new file mode 100644 index 0000000000..9f93b8508e Binary files /dev/null and b/Sounds/Item/BlackGlassBandSound.ogg differ diff --git a/Sounds/Item/ProtolithBangleSound.ogg b/Sounds/Item/ProtolithBangleSound.ogg new file mode 100644 index 0000000000..0e6ccdeff7 Binary files /dev/null and b/Sounds/Item/ProtolithBangleSound.ogg differ diff --git a/Systems/Mechanic/DifficultyModeSystem.cs b/Systems/Mechanic/DifficultyModeSystem.cs index afbfc41794..106dd9bdef 100644 --- a/Systems/Mechanic/DifficultyModeSystem.cs +++ b/Systems/Mechanic/DifficultyModeSystem.cs @@ -1,15 +1,18 @@ using System; using System.Collections.Generic; using System.Linq; +using CalamityMod.Buffs.DamageOverTime; using CalamityMod.CalPlayer; using CalamityMod.Events; using CalamityMod.Items.Armor.Demonshade; +using CalamityMod.UI.ModeIndicator; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; using Terraria; using Terraria.Audio; +using Terraria.Graphics; using Terraria.ID; using Terraria.Localization; using Terraria.ModLoader; @@ -40,6 +43,17 @@ namespace CalamityMod.Systems Difficulties = null; } + // Makes the world automatically convert to Death if in Master, or out of Death if in Expert + public override void PostUpdateWorld() + { + if (!Main.expertMode) + ModeIndicatorUI.SwitchToDifficulty(NoDifficulty.Instance); + if (Main.expertMode && !Main.masterMode && GetCurrentDifficulty == DeathDifficulty.Instance) + ModeIndicatorUI.SwitchToDifficulty(RevengeanceDifficulty.Instance); + if (Main.masterMode && GetCurrentDifficulty == RevengeanceDifficulty.Instance) + ModeIndicatorUI.SwitchToDifficulty(DeathDifficulty.Instance); + } + public static DifficultyMode GetCurrentDifficulty { get @@ -182,7 +196,10 @@ namespace CalamityMod.Systems ActivationSound = SoundID.MenuTick with { Volume = 1f }; ChatTextColor = Color.White; + Instance = this; } + + public static NoDifficulty Instance { get; private set; } = null; } public class RevengeanceDifficulty : DifficultyMode @@ -227,7 +244,10 @@ namespace CalamityMod.Systems ActivationSound = SoundID.Item119; ChatTextColor = Color.Crimson; + Instance = this; } + + public static RevengeanceDifficulty Instance { get; private set; } = null; } public class DeathDifficulty : DifficultyMode @@ -264,6 +284,7 @@ namespace CalamityMod.Systems ActivationSound = DemonshadeHelm.ActivationSound; ChatTextColor = Color.MediumOrchid; + Instance = this; } public override int FavoredDifficultyAtTier(int tier) @@ -278,5 +299,6 @@ namespace CalamityMod.Systems return 0; } + public static DeathDifficulty Instance { get; private set; } = null; } } diff --git a/Systems/World/WorldMiscUpdateSystem.cs b/Systems/World/WorldMiscUpdateSystem.cs index 3056ee31a6..411eae4315 100644 --- a/Systems/World/WorldMiscUpdateSystem.cs +++ b/Systems/World/WorldMiscUpdateSystem.cs @@ -68,7 +68,9 @@ namespace CalamityMod.Systems // Handle Acid Rain update logic. if (AcidRainEvent.AcidRainEventIsOngoing) + { AcidRainEvent.Update(); + } else { if (AcidRainEvent.TimeSinceEventStarted != 0) @@ -113,6 +115,9 @@ namespace CalamityMod.Systems CalamityGlobalNPC.AttemptToSpawnLavaNPCs(p); } + // Spawn the Old Man if Skeletron hasn't been defeated and there is no Old Man, it takes too fucking long otherwise. + TrySpawnOldMan(); + // Make the cultist countdown happen much more quickly. if (Main.netMode != NetmodeID.MultiplayerClient) { @@ -567,6 +572,25 @@ namespace CalamityMod.Systems } #endregion + #region Handle Old Man Spawn + public static void TrySpawnOldMan() + { + if (Main.netMode == NetmodeID.MultiplayerClient || NPC.downedBoss3 || Main.dayTime) + return; + + if (NPC.AnyNPCs(NPCID.OldMan)) + return; + + if (NPC.AnyNPCs(NPCID.SkeletronHead)) + return; + + int oldMan = NPC.NewNPC(NPC.GetSource_TownSpawn(), Main.dungeonX * 16 + 8, Main.dungeonY * 16, NPCID.OldMan); + Main.npc[oldMan].homeless = false; + Main.npc[oldMan].homeTileX = Main.dungeonX; + Main.npc[oldMan].homeTileY = Main.dungeonY; + } + #endregion + #region Handle Dungeon Guardian Spawns public static void TrySpawnDungeonGuardian(Player player) { diff --git a/Systems/World/WorldgenManagementSystem.cs b/Systems/World/WorldgenManagementSystem.cs index e357914007..df971eb101 100644 --- a/Systems/World/WorldgenManagementSystem.cs +++ b/Systems/World/WorldgenManagementSystem.cs @@ -44,6 +44,23 @@ namespace CalamityMod.Systems CustomUnderworld.NewUnderworld(); }); + // Better Underworld structures after the world has been smoothed + int UnderworldStructuresIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Smooth World")); + tasks.Insert(UnderworldStructuresIndex + 1, new PassLegacy("Underworld Structures", (progress, config) => + { + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.UnderworldStructures").Value; + CustomUnderworld.NewUnderworldStructures(); + + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.UnderworldPillars").Value; + CustomUnderworld.NewUnderworldPillars(); + + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.UnderworldTreesAndGrass").Value; + CustomUnderworld.AshTreesAndGrass(); + + progress.Message = Language.GetOrRegister("Mods.CalamityMod.UI.UnderworldGeyserTraps").Value; + CustomUnderworld.PlaceGeyserTraps(); + })); + // Evil Floating Island int islandIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Floating Island Houses")); if (islandIndex != -1) @@ -487,6 +504,20 @@ namespace CalamityMod.Systems } } + // Fix vanilla's stupidity with Gold Chests being able to have Meteorite Bars in them near the Underworld + if (isGoldChest) + { + for (int inventoryIndex = 0; inventoryIndex < 40; inventoryIndex++) + { + if (chest.item[inventoryIndex].type == ItemID.MeteoriteBar) + { + int oldStack = chest.item[inventoryIndex].stack; + chest.item[inventoryIndex].SetDefaults(WorldGen.genRand.NextBool() ? ItemID.PlatinumBar : ItemID.GoldBar); + chest.item[inventoryIndex].stack = oldStack; + } + } + } + // Give Dead Man's Chests better loot. if (isDeadManChest) { diff --git a/Tiles/Abyss/AcidWoodTree.cs b/Tiles/Abyss/AcidWoodTree.cs index 59f1194b03..0e790dcafb 100644 --- a/Tiles/Abyss/AcidWoodTree.cs +++ b/Tiles/Abyss/AcidWoodTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Placeables.Abyss; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.AcidRain; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -54,6 +55,15 @@ namespace CalamityMod.Tiles.Abyss // Returning false at the end prevents vanilla behavior as the default is palm tree behavior which can include undesirable stuff like seagulls public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -115,7 +125,7 @@ namespace CalamityMod.Tiles.Abyss if (type != -1) Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/Astral/AstralTree.cs b/Tiles/Astral/AstralTree.cs index 4361cf3493..d7440d736b 100644 --- a/Tiles/Astral/AstralTree.cs +++ b/Tiles/Astral/AstralTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -73,6 +74,15 @@ namespace CalamityMod.Tiles.Astral // Returning false at the end prevents vanilla behavior as the default is forest tree behavior which can include undesirable stuff like squirrels and butterflies public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) { @@ -137,7 +147,7 @@ namespace CalamityMod.Tiles.Astral type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/AstralDesert/AstralPalmTree.cs b/Tiles/AstralDesert/AstralPalmTree.cs index 6c0d7fc4fe..3fb709e4d8 100644 --- a/Tiles/AstralDesert/AstralPalmTree.cs +++ b/Tiles/AstralDesert/AstralPalmTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using ReLogic.Content; @@ -71,6 +72,16 @@ namespace CalamityMod.Tiles.AstralDesert // Returning false at the end prevents vanilla behavior as the default is palm tree behavior which can include undesirable stuff like seagulls public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? (WorldGen.genRand.NextBool() ? ItemID.Coconut : ItemID.Banana) + : (WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType()); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -123,12 +134,12 @@ namespace CalamityMod.Tiles.AstralDesert type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.Next(36) < 5) // Vanilla palm fruit logic goes first + else if (Main.rand.NextBool(12)) // Vanilla palm fruit logic goes first { int fruitType = Main.rand.NextBool() ? ItemID.Coconut : ItemID.Banana; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); } - else if (Main.rand.Next(36) < 5) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/AstralSnow/AstralSnowTree.cs b/Tiles/AstralSnow/AstralSnowTree.cs index aaa2519155..e8becab1b5 100644 --- a/Tiles/AstralSnow/AstralSnowTree.cs +++ b/Tiles/AstralSnow/AstralSnowTree.cs @@ -3,6 +3,7 @@ using CalamityMod.Dusts; using CalamityMod.Gores.Trees; using CalamityMod.Items.Materials; using CalamityMod.Items.Potions.Food; +using CalamityMod.Items.Tools; using CalamityMod.NPCs.Astral; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -74,6 +75,15 @@ namespace CalamityMod.Tiles.AstralSnow // Returning false at the end prevents vanilla behavior as the default is forest tree behavior which can include undesirable stuff like squirrels and butterflies public override bool Shake(int x, int y, ref bool createLeaves) { + // 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ModContent.ItemType() && WorldGen.genRand.NextBool(3)) + { + int treeDropItemType = WorldGen.genRand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); + Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), x * 16, y * 16, 16, 16, treeDropItemType); + } + int randAmt = Main.rand.Next(1, 3); if (Main.getGoodWorld && Main.rand.NextBool(15)) @@ -137,7 +147,7 @@ namespace CalamityMod.Tiles.AstralSnow type = ItemID.FallenStar; Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, type, randAmt); } - else if (Main.rand.NextBool(3)) + else if (Main.rand.NextBool(12)) { int fruitType = Main.rand.NextBool() ? ModContent.ItemType() : ModContent.ItemType(); Item.NewItem(WorldGen.GetItemSource_FromTreeShake(x, y), new Vector2(x, y) * 16, fruitType); diff --git a/Tiles/CalamityGlobalTile.cs b/Tiles/CalamityGlobalTile.cs index 653abbc334..cee684049a 100644 --- a/Tiles/CalamityGlobalTile.cs +++ b/Tiles/CalamityGlobalTile.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using CalamityMod.Enums; using CalamityMod.Items.Accessories.Vanity; +using CalamityMod.Items.Tools; using CalamityMod.Items.VanillaArmorChanges; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Tiles.Abyss; @@ -24,7 +25,6 @@ namespace CalamityMod.Tiles { public class CalamityGlobalTile : GlobalTile { - public static List GrowthTiles = new List() { TileType(), @@ -48,8 +48,10 @@ namespace CalamityMod.Tiles public override void PreShakeTree(int x, int y, TreeTypes treeType) { - // Add an additional 25% chance to drop vanilla fruits - if (WorldGen.genRand.NextBool(4)) + // All trees have a 33% chance to drop extra fruit when using Feller of Evergreens + Vector2 worldPosition = new Vector2(x, y).ToWorldCoordinates(); + Player nearestPlayer = Main.player[Player.FindClosest(worldPosition, 16, 16)]; + if (nearestPlayer.active && nearestPlayer.ActiveItem().type == ItemType() && WorldGen.genRand.NextBool(3)) { int treeDropItemType = 0; switch (treeType) diff --git a/Utilities/DrawingUtils.cs b/Utilities/DrawingUtils.cs index 9ed32533e5..ce5b774884 100644 --- a/Utilities/DrawingUtils.cs +++ b/Utilities/DrawingUtils.cs @@ -41,6 +41,21 @@ namespace CalamityMod new Color(199, 62, 62), }; + /// + /// The transformation matrix used for drawing backgrounds in Vanilla Terraria. Should be used for any custom background drawing or CustomSky + /// drawing, such as independent sky entities or background shader effects. + /// + public static Matrix BackgroundMatrix + { + get + { + Matrix backgroundMatrix = Main.BackgroundViewMatrix.TransformationMatrix; + Vector3 translationDirection = new(1f, Main.BackgroundViewMatrix.Effects.HasFlag(SpriteEffects.FlipVertically) ? -1f : 1f, 1f); + backgroundMatrix.Translation -= Main.BackgroundViewMatrix.ZoomMatrix.Translation * translationDirection; + return backgroundMatrix; + } + } + #region Projectile Afterimages /// /// Draws a projectile as a series of afterimages. The first of these afterimages is centered on the center of the projectile's hitbox.
@@ -412,9 +427,7 @@ namespace CalamityMod { Vector2 origin = new Vector2(glowmaskTexture.Width / 2f, glowmaskTexture.Height / 2f); - Color color = new Color(250, 250, 250, item.alpha); - if (item.type == ModContent.ItemType()) - color = Color.White; + Color color = Color.White; spriteBatch.Draw(glowmaskTexture, item.Center - Main.screenPosition, null, color, rotation, origin, 1f, SpriteEffects.None, 0f); } diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 460f0f32d4..e66a64ece0 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -136,7 +136,7 @@ namespace CalamityMod return ret; } - public static float GetRangedAmmoCostReduction(this Player player) + public static float GetAmmoCostReduction(this Player player) { // Tally up all possible vanilla effects. float vanillaCost = player.ammoBox ? 0.8f : 1f; @@ -148,7 +148,7 @@ namespace CalamityMod vanillaCost *= 0.75f; // Account for Calamity effects. - return vanillaCost * player.Calamity().rangedAmmoCost; + return vanillaCost * player.Calamity().ammoCost; } public static float GetStandingStealthRegen(this Player player) diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index 5827bfbbff..e8b9ab486f 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -38,6 +38,20 @@ namespace CalamityMod return false; } + public static bool AnyOwnedProjectiles(int projectileID, int ownerID) + { + // Efficiently loop through all projectiles, using a specially designed continue continue that attempts to minimize the amount of OR + // checks per iteration. + foreach (Projectile p in Main.ActiveProjectiles) + { + if (p.type != projectileID || p.owner != ownerID) + continue; + + return true; + } + + return false; + } public static int CountProjectiles(int projectileID) => Main.projectile.Count(proj => proj.type == projectileID && proj.active); public static int CountOwnedProjectiles(int projectileID, int ownerID) => Main.projectile.Count(proj => proj.active && proj.type == projectileID && proj.owner == ownerID); @@ -107,6 +121,50 @@ namespace CalamityMod public static void ExpandHitboxBy(this Projectile projectile, Vector2 newSize) => projectile.ExpandHitboxBy((int)newSize.X, (int)newSize.Y); public static void ExpandHitboxBy(this Projectile projectile, float expandRatio) => projectile.ExpandHitboxBy((int)(projectile.width * expandRatio), (int)(projectile.height * expandRatio)); + /// + /// Prevents a projectile from colliding with tiles until it's no longer inside tiles.
+ /// Useful for large projectiles that would otherwise collide with tiles instantly after spawning.
+ /// Make sure to set Projectile.tileCollide = false; in the projectile's SetDefaults before calling this function in the projectile's AI. + ///
+ public static void PreventTileCollisionUntilHitboxIsOutsideOfTiles(Projectile projectile) + { + if (!projectile.tileCollide) + { + bool canCollide = true; + Vector2 tilePosition; + Point tilePositionPoint; + Tile tileSafely; + float increment = 16f; + float offset = increment * 2f; + float startIndexX = projectile.position.X - increment; + float endIndexX = startIndexX + offset + projectile.width; + float startIndexY = projectile.position.Y - increment; + float endIndexY = projectile.position.Y + offset + projectile.height; + for (float i = startIndexX; i < endIndexX; i += increment) + { + if (!canCollide) + break; + + for (float j = startIndexY; j < endIndexY; j += increment) + { + tilePosition.X = i; + tilePosition.Y = j; + tilePositionPoint = tilePosition.ToTileCoordinates(); + tileSafely = Framing.GetTileSafely(tilePositionPoint); + bool isInSolidTile = tileSafely.HasUnactuatedTile && Main.tileSolid[tileSafely.TileType] && !Main.tileSolidTop[tileSafely.TileType] && !TileID.Sets.Platforms[tileSafely.TileType]; + if (isInSolidTile) + { + canCollide = false; + break; + } + } + } + + if (canCollide) + projectile.tileCollide = true; + } + } + public static void HomeInOnNPC(Projectile projectile, bool ignoreTiles, float distanceRequired, float homingVelocity, float inertia) { if (!projectile.friendly) @@ -649,7 +707,8 @@ namespace CalamityMod Color backAfterimageColor = backglowColor * projectile.Opacity; SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; + if (projectile.spriteDirection == -1 && effects == SpriteEffects.None) spriteEffects = SpriteEffects.FlipHorizontally; + else spriteEffects = effects; for (int i = 0; i < 10; i++) { @@ -692,9 +751,10 @@ namespace CalamityMod Vector2 origin = frame.Value.Size() * 0.5f; SpriteEffects spriteEffects = SpriteEffects.None; - if (projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; + if (projectile.spriteDirection == -1 && effects == SpriteEffects.None) spriteEffects = SpriteEffects.FlipHorizontally; + else spriteEffects = effects; - projectile.DrawBackglow(backglowColor, backglowArea, texture, frame); + projectile.DrawBackglow(backglowColor, backglowArea, texture, frame, spriteEffects, xPos, yPos); Main.spriteBatch.Draw(texture, drawPosition, frame, projectile.GetAlpha(lightColor), projectile.rotation, origin, projectile.scale, spriteEffects, 0f); } diff --git a/Walls/VoidstoneWall.cs b/Walls/VoidstoneWall.cs index a239873c54..3553030f40 100644 --- a/Walls/VoidstoneWall.cs +++ b/Walls/VoidstoneWall.cs @@ -46,8 +46,7 @@ namespace CalamityMod.Walls int yPos = tile.WallFrameY; Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); - Color drawcolor; - drawcolor = WorldGen.paintColor(tile.WallColor); + Color drawcolor = WorldGen.paintColor(tile.WallColor); drawcolor.A = 255; Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); @@ -67,12 +66,9 @@ namespace CalamityMod.Walls brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - drawcolor *= brightness; - Color glowColor = drawcolor * 0.4f; - if (lightColor.R > glowColor.R) glowColor.R = lightColor.R; - if (lightColor.G > glowColor.G) glowColor.G = lightColor.G; - if (lightColor.B > glowColor.B) glowColor.B = lightColor.B; + brightness = MathHelper.Clamp(brightness, 0f, 1f); + Color glowColor = drawcolor *= brightness; if (glowColor.R <= 0 && glowColor.G <= 0 && glowColor.B <= 0) return; diff --git a/Walls/VoidstoneWallUnsafe _Glowmask.png b/Walls/VoidstoneWallUnsafe _Glowmask.png deleted file mode 100644 index a3f5c24d2b..0000000000 Binary files a/Walls/VoidstoneWallUnsafe _Glowmask.png and /dev/null differ diff --git a/Walls/VoidstoneWallUnsafe.cs b/Walls/VoidstoneWallUnsafe.cs index 6469477f7c..2f8aa9fc12 100644 --- a/Walls/VoidstoneWallUnsafe.cs +++ b/Walls/VoidstoneWallUnsafe.cs @@ -55,8 +55,7 @@ namespace CalamityMod.Walls int yPos = tile.WallFrameY; Rectangle frame = new Rectangle(xPos, yPos, xLength, 32); - Color drawcolor; - drawcolor = WorldGen.paintColor(tile.WallColor); + Color drawcolor = WorldGen.paintColor(tile.WallColor); drawcolor.A = 255; Vector2 zero = new Vector2(Main.offScreenRange, Main.offScreenRange); @@ -76,12 +75,9 @@ namespace CalamityMod.Walls brightness *= (float)MathF.Sin(j / 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(i * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); brightness *= (float)MathF.Sin(j * 18f + declareThisHereToPreventRunningTheSameCalculationMultipleTimes); - drawcolor *= brightness; - Color glowColor = drawcolor * 0.4f; - if (lightColor.R > glowColor.R) glowColor.R = lightColor.R; - if (lightColor.G > glowColor.G) glowColor.G = lightColor.G; - if (lightColor.B > glowColor.B) glowColor.B = lightColor.B; + brightness = MathHelper.Clamp(brightness, 0f, 1f); + Color glowColor = drawcolor *= brightness; if (glowColor.R <= 0 && glowColor.G <= 0 && glowColor.B <= 0) return; @@ -90,7 +86,7 @@ namespace CalamityMod.Walls // But maybe we could squeeze bit more by removing the loop for (int k = 0; k < 3; k++) { - Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * 0.2f * k; + Vector2 offset = new Vector2(Main.rand.NextFloat(-1f, 1f), Main.rand.NextFloat(-1f, 1f)) * (0.2f * k); spriteBatch.Draw(GlowMask.Texture, pos + offset + new Vector2(-8 + xOff, -8), frame, glowColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); } } diff --git a/World/CustomUnderworld.cs b/World/CustomUnderworld.cs index 5d55ebe7af..23df6a3460 100644 --- a/World/CustomUnderworld.cs +++ b/World/CustomUnderworld.cs @@ -14,6 +14,13 @@ namespace CalamityMod.World { public class CustomUnderworld { + // Ash island variables + private const double AshIslandGenStart = 0.36; + private const double AshIslandGenStart_Remix = 0.38; + private const double AshIslandGenEnd = 0.64; + private const double AshIslandGenEnd_Remix = 0.62; + private const int AshIslandDepthMaxAboveTheUnderworldFloor = 135; + private const int AshIslandHeightMaxAboveTheUnderworldFloor = 160; private const int MaxIslands = 8; private const int SmallWorldIslands = 4; private const int MediumWorldIslands = 6; @@ -21,6 +28,11 @@ namespace CalamityMod.World private const int SmallWorldOuterIslands = 1; private const int MediumAndLargeWorldOuterIslands = 2; + // Pillar variables + private const int MaxPillarHeight = 68; + private const int RandomizedPillarSectionHeight = 4; + private const int MaxPillarDepthAboveTheUnderworldFloor = 40; + public static void NewUnderworld() { // Generate lower Underworld ash @@ -160,14 +172,14 @@ namespace CalamityMod.World // Remix world stuff, the Ash islands in the middle // Start generating islands at this point - int ashIslandX = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? 0.38 : 0.36)); + int ashIslandX = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenStart_Remix : AshIslandGenStart)); // Stop generating islands at this point - int ashIslandX2 = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? 0.62 : 0.64)); + int ashIslandX2 = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenEnd_Remix : AshIslandGenEnd)); // Ash island gen limits - int ashIslandDepthLimit = Main.maxTilesY - 135; - int ashIslandHeightLimit = Main.maxTilesY - 160; + int ashIslandDepthLimit = Main.maxTilesY - AshIslandDepthMaxAboveTheUnderworldFloor; + int ashIslandHeightLimit = Main.maxTilesY - AshIslandHeightMaxAboveTheUnderworldFloor; // Multiple islands in non-remix if (!WorldGen.remixWorldGen) @@ -275,46 +287,57 @@ namespace CalamityMod.World { // More randomized terrain depending on island type // Lower islands have smoother terrain - switch (chosenIslandSize) + // Islands on the edges have smoother terrain + if (isTallerIsland) { - default: - case 0: - case 1: - if (WorldGen.genRand.NextBool(4)) - ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); - else if (WorldGen.genRand.NextBool(8)) - ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); - break; + if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(8)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + } + else + { + switch (chosenIslandSize) + { + default: + case 0: + case 1: + if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(8)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + break; - case 2: - case 3: - if (WorldGen.genRand.NextBool(3)) - ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); - else if (WorldGen.genRand.NextBool(6)) - ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); - else if (WorldGen.genRand.NextBool(9)) - ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); - break; + case 2: + case 3: + if (WorldGen.genRand.NextBool(3)) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(6)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + else if (WorldGen.genRand.NextBool(9)) + ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); + break; - case 4: - case 5: - if (WorldGen.genRand.NextBool()) - ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); - else if (WorldGen.genRand.NextBool(4)) - ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); - else if (WorldGen.genRand.NextBool(6)) - ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); - break; + case 4: + case 5: + if (WorldGen.genRand.NextBool()) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + else if (WorldGen.genRand.NextBool(6)) + ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); + break; - case 6: - case 7: - if (WorldGen.genRand.NextBool()) - ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); - else if (WorldGen.genRand.NextBool(3)) - ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); - else if (WorldGen.genRand.NextBool(4)) - ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); - break; + case 6: + case 7: + if (WorldGen.genRand.NextBool()) + ashIslandGenLimiter += WorldGen.genRand.Next(-1, 2); + else if (WorldGen.genRand.NextBool(3)) + ashIslandGenLimiter += WorldGen.genRand.Next(-2, 3); + else if (WorldGen.genRand.NextBool(4)) + ashIslandGenLimiter += WorldGen.genRand.Next(-3, 4); + break; + } } } @@ -408,11 +431,11 @@ namespace CalamityMod.World } // Generate a line of background walls from the approximate underworld lava line and down - int maxWallHeight = 68; - int randomizedWallSectionsHeight = 4; + int maxWallHeight = MaxPillarHeight; + int randomizedWallSectionsHeight = RandomizedPillarSectionHeight; int maxWallTypes = 4; int newWallTypeStart = maxWallHeight / maxWallTypes; - int maxWallDepth = Main.maxTilesY - 40; + int maxWallDepth = Main.maxTilesY - MaxPillarDepthAboveTheUnderworldFloor; int smoulderingStoneWallStartDepth = maxWallDepth - maxWallHeight; int cinderWallStartDepth = smoulderingStoneWallStartDepth + newWallTypeStart; int emberWallStartDepth = cinderWallStartDepth + newWallTypeStart; @@ -625,18 +648,638 @@ namespace CalamityMod.World } } - // Obsidian and hellstone towers and schematics... + // Obsidian and hellstone towers... AddHellHouses(); + } - // Place ash trees - for (int x = ashIslandX; x < ashIslandX2 + 15; x++) + public static void NewUnderworldStructures() + { + if (!WorldGen.remixWorldGen) { - for (int y = Main.maxTilesY - 200; y < ashIslandDepthLimit + 30; y++) + // Generate some structures on the ash islands + int ashIslandX = (int)((double)Main.maxTilesX * AshIslandGenStart); + int ashIslandX2 = (int)((double)Main.maxTilesX * AshIslandGenEnd); + bool cragsLocationIsLeft = GenVars.dungeonLocation < Main.maxTilesX / 2; + int ashIslandDepthLimit = Main.maxTilesY - AshIslandDepthMaxAboveTheUnderworldFloor; + int ashIslandHeightLimit = Main.maxTilesY - AshIslandHeightMaxAboveTheUnderworldFloor; + + // Keep track of world size to adjust house distances + float houseDistanceMult = Main.maxTilesX / 4200f; + + // Large = 8, Medium = 6, Small = 4 + int numIslands = (int)(Main.maxTilesX / 4200f * 4f); + + // Small and medium worlds get less structures + bool smallWorld = numIslands == SmallWorldIslands; + bool mediumWorld = numIslands == MediumWorldIslands; + bool largeWorld = numIslands == LargeWorldIslands; + + // Total extra distance between islands for lava lakes + int totalExtraDistanceBetweenAshIslands = (int)((double)Main.maxTilesX * 0.04); + + // Extra distance per island + // The right side looks better with half of this adjustment subtracted + int divisor = cragsLocationIsLeft ? 2 : 4; + int extraDistanceBetweenAshIslands_PerIslandSide = totalExtraDistanceBetweenAshIslands / numIslands / divisor; + + // Calculate distance between islands + int sideAdjustmentMultiplier = cragsLocationIsLeft ? 1 : -1; + int distanceBetweenStructures = (ashIslandX2 - ashIslandX) / numIslands; + int firstIslandWidth = distanceBetweenStructures + (extraDistanceBetweenAshIslands_PerIslandSide * sideAdjustmentMultiplier); + int firstStructureDistanceFromIslandEdge = firstIslandWidth / 2; + int distanceBetweenStructures_AfterFirstIsland = distanceBetweenStructures; + + // Pick an atrium type + // Small worlds get a random single atrium + // Medium and large worlds get a guaranteed shadow chest atrium and another random non-shadow chest atrium + string atriumMapKey; + int atriumType = smallWorld ? WorldGen.genRand.Next(3) : WorldGen.genRand.Next(2); + int numAtriums = smallWorld ? 1 : 2; + if (!smallWorld) { - if (Main.tile[x, y].TileType == TileID.AshGrass && Main.tile[x, y].HasTile && !Main.tile[x, y - 1].HasTile && WorldGen.genRand.NextBool(3)) - WorldGen.TryGrowingTreeByType(TileID.TreeAsh, x, y); + switch (atriumType) + { + default: + case 0: + atriumMapKey = BrimstoneAtriumType1Key; + break; + + case 1: + atriumMapKey = BrimstoneAtriumType3Key; + break; + } + } + else + { + switch (atriumType) + { + default: + case 0: + atriumMapKey = BrimstoneAtriumType1Key; + break; + + case 1: + atriumMapKey = BrimstoneAtriumType2Key; + break; + + case 2: + atriumMapKey = BrimstoneAtriumType3Key; + break; + } + } + var atriumSchematic = TileMaps[atriumMapKey]; + + // Pick stockade types + List stockades = new List(); + int numStockades = largeWorld ? 2 : 1; + int stockadeTypes = 4; + do + { + // Chose a random stockade to add to the list + int chosenStockade = WorldGen.genRand.Next(stockadeTypes); + + // Don't choose the same stockade twice + bool alreadyContainsThisStockadeType = stockades.Contains(chosenStockade); + + if (!alreadyContainsThisStockadeType) + stockades.Add(chosenStockade); + } + while (stockades.Count < numStockades); + + string[] stockadesToGenerate = new string[numStockades]; + for (int stockadeIndex = 0; stockadeIndex < numStockades; stockadeIndex++) + { + switch (stockades[stockadeIndex]) + { + default: + case 0: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType1Key; + break; + + case 1: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType2Key; + break; + + case 2: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType3Key; + break; + + case 3: + stockadesToGenerate[stockadeIndex] = BarbedStockadeType4Key; + break; + } + } + + // Offsets for structures + int atriumOffsetY = 8; + + int cacheOffsetY = 45; + + int sanctumOffsetY = 65; + + int strongholdOffsetX = cragsLocationIsLeft ? 40 : 20; + int strongholdOffsetY = 3; + int secondStrongholdOffsetY = 5; + + int dungeonOffsetX = cragsLocationIsLeft ? 30 : 50; + int dungeonOffsetY = 4; + + int stockadeOffsetX = largeWorld ? strongholdOffsetX : 0; + int secondStockadeOffsetX = dungeonOffsetX; + int stockadeOffsetY = stockadesToGenerate[0] == BarbedStockadeType4Key ? -7 : 8; + + // Place structures + if (cragsLocationIsLeft) + { + // + // Place atriums + // + // Atrium location is on the crags side + int atriumGenX = ashIslandX + firstStructureDistanceFromIslandEdge; + int atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + Point atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + SchematicAnchor anchorType = SchematicAnchor.Center; + bool place = true; + if (!smallWorld) + { + PlaceSchematic(BrimstoneAtriumType2Key, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + // Protect the structure + Rectangle atriumProtectionArea = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea, 10); + + // Move index further along to keep structures spread apart + atriumGenX += distanceBetweenStructures_AfterFirstIsland; + + // Reset the Y index + atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + // Placement point for the second atrium + atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + } + + if (atriumMapKey == BrimstoneAtriumType2Key) + PlaceSchematic(atriumMapKey, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + else + PlaceSchematic>(atriumMapKey, atriumPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle atriumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea2, 10); + + // + // Place sanctums, strongholds, dungeons, and stockades + // + // All of these structures are on the demonic side + int sanctumGenX = ashIslandX2 - firstStructureDistanceFromIslandEdge; + int sanctumGenY = ashIslandDepthLimit + sanctumOffsetY; + + int strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + int dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + int stockadeGenX = sanctumGenX - (smallWorld ? distanceBetweenStructures_AfterFirstIsland : distanceBetweenStructures_AfterFirstIsland * 2); + int stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX + stockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + Point sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + Point strongholdPlacementPoint = new Point(sanctumGenX + strongholdOffsetX, strongholdGenY + strongholdOffsetY); + Point dungeonPlacementPoint = new Point(sanctumGenX - dungeonOffsetX, dungeonGenY + dungeonOffsetY); + Point stockadePlacementPoint = new Point(stockadeGenX + stockadeOffsetX, stockadeGenY + stockadeOffsetY); + if (largeWorld) + { + PlaceSchematic>(stockadesToGenerate[0], stockadePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle stockadeProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[stockadesToGenerate[0]], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea, 10); + + // Reset the Y index for stockades + stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX - secondStockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + // Placement point for the second stockade + int secondStockadeOffsetY = stockadesToGenerate[1] == BarbedStockadeType4Key ? -7 : 8; + stockadePlacementPoint = new Point(stockadeGenX - secondStockadeOffsetX, stockadeGenY + secondStockadeOffsetY); + } + if (!smallWorld) + { + PlaceSchematic>(SanctumofOblivionType1Key, sanctumPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle sanctumProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[SanctumofOblivionType1Key], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea, 10); + + PlaceSchematic(HellstoneStrongholdType1Key, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + // Protect the structure + Rectangle strongholdProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[HellstoneStrongholdType1Key], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea, 10); + + PlaceSchematic>(DemonicDungeonType1Key, dungeonPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle dungeonProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[DemonicDungeonType1Key], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea, 10); + + // Move index further along to keep structures spread apart + sanctumGenX -= distanceBetweenStructures_AfterFirstIsland; + + // Reset the Y index for strongholds + strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + // Placement point for the second stronghold + strongholdPlacementPoint = new Point(sanctumGenX + strongholdOffsetX, strongholdGenY + secondStrongholdOffsetY); + + // Reset the Y index for dungeons + dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + // Placement point for the second dungeon + dungeonPlacementPoint = new Point(sanctumGenX - dungeonOffsetX, dungeonGenY + dungeonOffsetY); + + // Placement point for the second sanctum + sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + } + + // Large worlds have two stockades + string secondStockade = largeWorld ? stockadesToGenerate[1] : stockadesToGenerate[0]; + PlaceSchematic>(secondStockade, stockadePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle stockadeProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStockade], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea2, 10); + + // Small worlds only have one sanctum + string secondSanctum = smallWorld ? SanctumofOblivionType1Key : (WorldGen.genRand.NextBool() ? SanctumofOblivionType2Key : SanctumofOblivionType3Key); + PlaceSchematic>(secondSanctum, sanctumPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle sanctumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondSanctum], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea2, 10); + + // Small worlds only have one stronghold + string secondStronghold = smallWorld ? HellstoneStrongholdType1Key : HellstoneStrongholdType2Key; + PlaceSchematic(secondStronghold, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + // Protect the structure + Rectangle strongholdProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStronghold], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea2, 10); + + // Small worlds only have one dungeon + string secondDungeon = smallWorld ? DemonicDungeonType1Key : DemonicDungeonType2Key; + PlaceSchematic>(secondDungeon, dungeonPlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle dungeonProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondDungeon], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea2, 10); + } + else + { + int atriumGenX = ashIslandX2 - firstStructureDistanceFromIslandEdge; + int atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + Point atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + SchematicAnchor anchorType = SchematicAnchor.Center; + bool place = true; + if (!smallWorld) + { + PlaceSchematic(BrimstoneAtriumType2Key, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + Rectangle atriumProtectionArea = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea, 10); + + atriumGenX -= distanceBetweenStructures_AfterFirstIsland; + + atriumGenY = ashIslandHeightLimit; + while (!Main.tile[atriumGenX, atriumGenY].HasTile) + atriumGenY++; + + atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffsetY); + } + + if (atriumMapKey == BrimstoneAtriumType2Key) + PlaceSchematic(atriumMapKey, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + else + PlaceSchematic>(atriumMapKey, atriumPlacementPoint, anchorType, ref place); + + Rectangle atriumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(atriumProtectionArea2, 10); + + int sanctumGenX = ashIslandX + firstStructureDistanceFromIslandEdge; + int sanctumGenY = ashIslandDepthLimit + sanctumOffsetY; + + int strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + int dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + int stockadeGenX = sanctumGenX + (smallWorld ? distanceBetweenStructures_AfterFirstIsland : distanceBetweenStructures_AfterFirstIsland * 2); + int stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX - stockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + Point sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + Point strongholdPlacementPoint = new Point(sanctumGenX - strongholdOffsetX, strongholdGenY + strongholdOffsetY); + Point dungeonPlacementPoint = new Point(sanctumGenX + dungeonOffsetX, dungeonGenY + dungeonOffsetY); + Point stockadePlacementPoint = new Point(stockadeGenX - stockadeOffsetX, stockadeGenY + stockadeOffsetY); + if (largeWorld) + { + PlaceSchematic>(stockadesToGenerate[0], stockadePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle stockadeProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[stockadesToGenerate[0]], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea, 10); + + // Reset the Y index for stockades + stockadeGenY = ashIslandHeightLimit; + while (!Main.tile[stockadeGenX + secondStockadeOffsetX, stockadeGenY].HasTile) + stockadeGenY++; + + // Placement point for the second stockade + int secondStockadeOffsetY = stockadesToGenerate[1] == BarbedStockadeType4Key ? -7 : 8; + stockadePlacementPoint = new Point(stockadeGenX + secondStockadeOffsetX, stockadeGenY + secondStockadeOffsetY); + } + if (!smallWorld) + { + PlaceSchematic>(SanctumofOblivionType1Key, sanctumPlacementPoint, anchorType, ref place); + + Rectangle sanctumProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[SanctumofOblivionType1Key], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea, 10); + + PlaceSchematic(HellstoneStrongholdType1Key, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + Rectangle strongholdProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[HellstoneStrongholdType1Key], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea, 10); + + PlaceSchematic>(DemonicDungeonType1Key, dungeonPlacementPoint, anchorType, ref place); + + Rectangle dungeonProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[DemonicDungeonType1Key], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea, 10); + + sanctumGenX += distanceBetweenStructures_AfterFirstIsland; + + strongholdGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX - strongholdOffsetX, strongholdGenY].HasTile) + strongholdGenY++; + + strongholdPlacementPoint = new Point(sanctumGenX - strongholdOffsetX, strongholdGenY + secondStrongholdOffsetY); + + dungeonGenY = ashIslandHeightLimit; + while (!Main.tile[sanctumGenX + dungeonOffsetX, dungeonGenY].HasTile) + dungeonGenY++; + + dungeonPlacementPoint = new Point(sanctumGenX + dungeonOffsetX, dungeonGenY + dungeonOffsetY); + + sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); + } + + string secondStockade = largeWorld ? stockadesToGenerate[1] : stockadesToGenerate[0]; + PlaceSchematic>(secondStockade, stockadePlacementPoint, anchorType, ref place); + + Rectangle stockadeProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStockade], stockadePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(stockadeProtectionArea2, 10); + + string secondSanctum = smallWorld ? SanctumofOblivionType1Key : (WorldGen.genRand.NextBool() ? SanctumofOblivionType2Key : SanctumofOblivionType3Key); + PlaceSchematic>(secondSanctum, sanctumPlacementPoint, anchorType, ref place); + + Rectangle sanctumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondSanctum], sanctumPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(sanctumProtectionArea2, 10); + + string secondStronghold = smallWorld ? HellstoneStrongholdType1Key : HellstoneStrongholdType2Key; + PlaceSchematic(secondStronghold, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); + + Rectangle strongholdProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStronghold], strongholdPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(strongholdProtectionArea2, 10); + + string secondDungeon = smallWorld ? DemonicDungeonType1Key : DemonicDungeonType2Key; + PlaceSchematic>(secondDungeon, dungeonPlacementPoint, anchorType, ref place); + + Rectangle dungeonProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondDungeon], dungeonPlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(dungeonProtectionArea2, 10); + } + + // Pick cache types + List caches = new List(); + int numCaches = largeWorld ? 8 : 4; // THIS NUMBER MUST BE EVEN!!! + int cacheTypes = 6; + int totalCachePositions = numCaches / 2; + do + { + // Chose a random cache to add to the list + int chosenCache = WorldGen.genRand.Next(cacheTypes); + + // Don't choose the same cache twice + bool alreadyContainsThisCacheType = caches.Contains(chosenCache); + + // Avoid an infinite loop by picking a random duplicate cache if the max is reached + bool pickRandomDuplicateCache = caches.Count >= cacheTypes; + if (pickRandomDuplicateCache) + pickRandomDuplicateCache = caches[caches.Count - totalCachePositions] != chosenCache; + + if (!alreadyContainsThisCacheType || pickRandomDuplicateCache) + caches.Add(chosenCache); + } + while (caches.Count < numCaches); + + // Chose random caches to not place + // 1 is not placed in a small/medium world + // 3 are not placed in a large world + List cachesToNotPlace = new List(); + int numCachesToNotPlace = largeWorld ? 3 : 1; + do + { + // Chose a random cache to add to the list + int chosenCache = WorldGen.genRand.Next(numCaches); + + // Don't choose the same cache twice + bool alreadyContainsThisCacheType = cachesToNotPlace.Contains(chosenCache); + if (!alreadyContainsThisCacheType) + cachesToNotPlace.Add(chosenCache); + } + while (cachesToNotPlace.Count < numCachesToNotPlace); + + // + // Place caches + // + int cacheGenX = ashIslandX + firstStructureDistanceFromIslandEdge + (distanceBetweenStructures_AfterFirstIsland * numAtriums); + int cacheGenY = ashIslandDepthLimit + cacheOffsetY; + int randomAdjustmentX = 0; + int randomAdjustmentY = 0; + int minRandomX = -30; + int maxRandomX = -20; + int minRandomY = 15; + int maxRandomY = 20; + for (int cacheIndex = 0; cacheIndex < totalCachePositions; cacheIndex++) + { + randomAdjustmentX += WorldGen.genRand.Next(minRandomX, maxRandomX + 1); + randomAdjustmentX = (int)MathHelper.Clamp(randomAdjustmentX, minRandomX, maxRandomX); + randomAdjustmentY += WorldGen.genRand.Next(minRandomY, maxRandomY + 1); + randomAdjustmentY = (int)MathHelper.Clamp(randomAdjustmentY, minRandomY, maxRandomY); + + string cacheMapKey; + switch (caches[cacheIndex]) + { + default: + case 0: + cacheMapKey = BonescrapperCacheType1Key; + break; + + case 1: + cacheMapKey = BonescrapperCacheType2Key; + break; + + case 2: + cacheMapKey = BonescrapperCacheType3Key; + break; + + case 3: + cacheMapKey = BonescrapperCacheType4Key; + break; + + case 4: + cacheMapKey = BonescrapperCacheType5Key; + break; + + case 5: + cacheMapKey = BonescrapperCacheType6Key; + break; + } + + Point cachePlacementPoint = new Point(cacheGenX + randomAdjustmentX, cacheGenY + randomAdjustmentY); + SchematicAnchor anchorType = SchematicAnchor.Center; + bool place = true; + + bool canPlaceEvenCache = true; + switch (cacheIndex) + { + default: + case 0: + canPlaceEvenCache = !cachesToNotPlace.Contains(0); + break; + + case 1: + canPlaceEvenCache = !cachesToNotPlace.Contains(2); + break; + + case 2: + canPlaceEvenCache = !cachesToNotPlace.Contains(4); + break; + + case 3: + canPlaceEvenCache = !cachesToNotPlace.Contains(6); + break; + } + + // Cache types 2, 3, and 6 have chests + if (canPlaceEvenCache) + { + if (cacheMapKey == BonescrapperCacheType2Key || cacheMapKey == BonescrapperCacheType3Key || cacheMapKey == BonescrapperCacheType6Key) + PlaceSchematic(cacheMapKey, cachePlacementPoint, anchorType, ref place, new Action(FillCacheChests)); + else + PlaceSchematic>(cacheMapKey, cachePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle cacheProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[cacheMapKey], cachePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(cacheProtectionArea, 5); + } + + string secondCacheMapKey; + switch (caches[cacheIndex + totalCachePositions]) + { + default: + case 0: + secondCacheMapKey = BonescrapperCacheType1Key; + break; + + case 1: + secondCacheMapKey = BonescrapperCacheType2Key; + break; + + case 2: + secondCacheMapKey = BonescrapperCacheType3Key; + break; + + case 3: + secondCacheMapKey = BonescrapperCacheType4Key; + break; + + case 4: + secondCacheMapKey = BonescrapperCacheType5Key; + break; + + case 5: + secondCacheMapKey = BonescrapperCacheType6Key; + break; + } + + bool canPlaceOddCache = true; + switch (cacheIndex) + { + default: + case 0: + canPlaceOddCache = !cachesToNotPlace.Contains(1); + break; + + case 1: + canPlaceOddCache = !cachesToNotPlace.Contains(3); + break; + + case 2: + canPlaceOddCache = !cachesToNotPlace.Contains(5); + break; + + case 3: + canPlaceOddCache = !cachesToNotPlace.Contains(7); + break; + } + + // Place second cache to the right of the first + if (canPlaceOddCache) + { + Point secondCachePlacementPoint = cachePlacementPoint + new Point(WorldGen.genRand.Next(60, 76), 0); + if (secondCacheMapKey == BonescrapperCacheType2Key || secondCacheMapKey == BonescrapperCacheType3Key || secondCacheMapKey == BonescrapperCacheType6Key) + PlaceSchematic(secondCacheMapKey, secondCachePlacementPoint, anchorType, ref place, new Action(FillCacheChests)); + else + PlaceSchematic>(secondCacheMapKey, secondCachePlacementPoint, anchorType, ref place); + + // Protect the structure + Rectangle cacheProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondCacheMapKey], secondCachePlacementPoint, anchorType); + CalamityUtils.AddProtectedStructure(cacheProtectionArea2, 5); + } + + // Reset positions and move cache placement along the X axis + cacheGenX = ashIslandX + firstStructureDistanceFromIslandEdge + (distanceBetweenStructures_AfterFirstIsland * (numAtriums + cacheIndex + 1)); + cacheGenY = ashIslandDepthLimit + cacheOffsetY; } } + } + + public static void NewUnderworldPillars() + { + int maxWallHeight = MaxPillarHeight; + int randomizedWallSectionsHeight = RandomizedPillarSectionHeight; + int maxWallDepth = Main.maxTilesY - MaxPillarDepthAboveTheUnderworldFloor; + int smoulderingStoneWallStartDepth = maxWallDepth - maxWallHeight; // Generate after houses to avoid complications // Place pillars of walls to show that the roof of the underworld is being held up @@ -813,6 +1456,28 @@ namespace CalamityMod.World } } } + } + + public static void AshTreesAndGrass() + { + // Start generating islands at this point + int ashIslandX = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenStart_Remix : AshIslandGenStart)); + + // Stop generating islands at this point + int ashIslandX2 = (int)((double)Main.maxTilesX * (WorldGen.remixWorldGen ? AshIslandGenEnd_Remix : AshIslandGenEnd)); + + // Ash island gen limits + int ashIslandDepthLimit = Main.maxTilesY - AshIslandDepthMaxAboveTheUnderworldFloor; + + // Place ash trees + for (int x = ashIslandX; x < ashIslandX2 + 15; x++) + { + for (int y = Main.maxTilesY - 200; y < ashIslandDepthLimit + 30; y++) + { + if (Main.tile[x, y].TileType == TileID.AshGrass && Main.tile[x, y].HasTile && !Main.tile[x, y - 1].HasTile && WorldGen.genRand.NextBool(3)) + WorldGen.TryGrowingTreeByType(TileID.TreeAsh, x, y); + } + } // Drunk world ash grass and trees if (WorldGen.drunkWorldGen) @@ -839,10 +1504,25 @@ namespace CalamityMod.World } } } + } + public static void PlaceGeyserTraps() + { // Place Geyser Traps on ash islands + // These are only generated in the no-man's land central islands if (!WorldGen.remixWorldGen) { + // Large = 8, Medium = 6, Small = 4 + // No-man's land islands: Large = 4, Medium = 2, Small = 2 + int numIslands = (int)(Main.maxTilesX / 4200f * 4f); + bool mediumWorld = numIslands == MediumWorldIslands; + + // Start generating traps at this point + int ashIslandX = (int)((double)Main.maxTilesX * (mediumWorld ? 0.453 : 0.43)); + + // Stop generating traps at this point + int ashIslandX2 = (int)((double)Main.maxTilesX * (mediumWorld ? 0.546 : 0.57)); + // Small = 12.6 Medium = 19.2 Large = 25.2 double trapFrequency = (double)Main.maxTilesX * 0.003; if (WorldGen.noTrapsWorldGen) @@ -859,7 +1539,7 @@ namespace CalamityMod.World for (int trapIndex2 = 0; trapIndex2 < maxTrapPlacementAttempts; trapIndex2++) { int trapPlacementX = WorldGen.genRand.Next(ashIslandX, ashIslandX2); - int trapPlacementY = WorldGen.genRand.Next(Main.maxTilesY - 160, Main.maxTilesY - 100); + int trapPlacementY = WorldGen.genRand.Next(Main.maxTilesY - AshIslandHeightMaxAboveTheUnderworldFloor, Main.maxTilesY - 100); if (GeyserTraps(trapPlacementX, trapPlacementY)) break; @@ -967,399 +1647,6 @@ namespace CalamityMod.World } } - if (!WorldGen.remixWorldGen) - { - // Generate some structures on the ash islands - int ashIslandX = (int)((double)Main.maxTilesX * 0.36); - int ashIslandX2 = (int)((double)Main.maxTilesX * 0.64); - bool cragsLocationIsLeft = GenVars.dungeonLocation < Main.maxTilesX / 2; - int ashIslandDepthLimit = Main.maxTilesY - 135; - int ashIslandHeightLimit = Main.maxTilesY - 160; - - // Keep track of world size to adjust house distances - float houseDistanceMult = Main.maxTilesX / 4200f; - - // Large = 8, Medium = 6, Small = 4 - int numIslands = (int)(Main.maxTilesX / 4200f * 4f); - - // Small and medium worlds get less structures - bool smallWorld = numIslands == SmallWorldIslands; - bool mediumWorld = numIslands == MediumWorldIslands; - bool largeWorld = numIslands == LargeWorldIslands; - - // Total extra distance between islands for lava lakes - int totalExtraDistanceBetweenAshIslands = (int)((double)Main.maxTilesX * 0.04); - - // Extra distance per island - // The right side looks better with half of this adjustment subtracted - int divisor = cragsLocationIsLeft ? 2 : 4; - int extraDistanceBetweenAshIslands_PerIslandSide = totalExtraDistanceBetweenAshIslands / numIslands / divisor; - - // Calculate distance between islands - int sideAdjustmentMultiplier = cragsLocationIsLeft ? 1 : -1; - int distanceBetweenStructures = (ashIslandX2 - ashIslandX) / numIslands; - int firstIslandWidth = distanceBetweenStructures + (extraDistanceBetweenAshIslands_PerIslandSide * sideAdjustmentMultiplier); - int firstStructureDistanceFromIslandEdge = firstIslandWidth / 2; - int distanceBetweenStructures_AfterFirstIsland = distanceBetweenStructures; - - // Pick an atrium type - // Small worlds get a random single atrium - // Medium and large worlds get a guaranteed shadow chest atrium and another random non-shadow chest atrium - string atriumMapKey; - int atriumType = smallWorld ? WorldGen.genRand.Next(3) : WorldGen.genRand.Next(2); - int numAtriums = smallWorld ? 1 : 2; - if (!smallWorld) - { - switch (atriumType) - { - default: - case 0: - atriumMapKey = BrimstoneAtriumType1Key; - break; - - case 1: - atriumMapKey = BrimstoneAtriumType3Key; - break; - } - } - else - { - switch (atriumType) - { - default: - case 0: - atriumMapKey = BrimstoneAtriumType1Key; - break; - - case 1: - atriumMapKey = BrimstoneAtriumType2Key; - break; - - case 2: - atriumMapKey = BrimstoneAtriumType3Key; - break; - } - } - var atriumSchematic = TileMaps[atriumMapKey]; - - // Offsets for structures - int atriumOffset = 9; - int cacheOffset = 45; - int sanctumOffset = 65; - int strongholdOffset = 5; - - // Place schematics - if (cragsLocationIsLeft) - { - // - // Place atriums - // - // Atrium location is on the crags side - // Atrium is placed in the center of an island due to its immense size - int atriumGenX = ashIslandX + firstStructureDistanceFromIslandEdge; - int atriumGenY = ashIslandHeightLimit; - while (!Main.tile[atriumGenX, atriumGenY].HasTile) - atriumGenY++; - - Point atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffset); - SchematicAnchor anchorType = SchematicAnchor.Center; - bool place = true; - if (!smallWorld) - { - PlaceSchematic(BrimstoneAtriumType2Key, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - - // Protect the structure - Rectangle atriumProtectionArea = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(atriumProtectionArea, 10); - - // Move index further along to keep structures spread apart - atriumGenX += distanceBetweenStructures_AfterFirstIsland; - - // Reset the Y index - atriumGenY = ashIslandHeightLimit; - while (!Main.tile[atriumGenX, atriumGenY].HasTile) - atriumGenY++; - - // Placement point for the second atrium - atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffset); - } - - if (atriumMapKey == BrimstoneAtriumType2Key) - PlaceSchematic(atriumMapKey, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - else - PlaceSchematic>(atriumMapKey, atriumPlacementPoint, anchorType, ref place); - - // Protect the structure - Rectangle atriumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(atriumProtectionArea2, 10); - - // - // Place sanctums and strongholds - // - // Sanctums 1 and 2 are the large ones - int sanctumGenX = ashIslandX2 - firstStructureDistanceFromIslandEdge; - int sanctumGenY = ashIslandDepthLimit + sanctumOffset; - - int strongholdGenY = ashIslandHeightLimit; - while (!Main.tile[sanctumGenX, strongholdGenY].HasTile) - strongholdGenY++; - - Point sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); - Point strongholdPlacementPoint = new Point(sanctumGenX, strongholdGenY + strongholdOffset); - if (!smallWorld) - { - PlaceSchematic>(SanctumofOblivionType1Key, sanctumPlacementPoint, anchorType, ref place); - - // Protect the structure - Rectangle sanctumProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[SanctumofOblivionType1Key], sanctumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(sanctumProtectionArea, 10); - - PlaceSchematic(HellstoneStrongholdType1Key, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - - // Protect the structure - Rectangle strongholdProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[HellstoneStrongholdType1Key], strongholdPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(strongholdProtectionArea, 10); - - // Move index further along to keep structures spread apart - sanctumGenX -= distanceBetweenStructures_AfterFirstIsland; - - // Reset the Y index for strongholds - strongholdGenY = ashIslandHeightLimit; - while (!Main.tile[sanctumGenX, strongholdGenY].HasTile) - strongholdGenY++; - - // Placement point for the second stronghold - strongholdPlacementPoint = new Point(sanctumGenX, strongholdGenY + strongholdOffset); - - // Placement point for the second sanctum - sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); - } - - // Small worlds only have one sanctum - string secondSanctum = smallWorld ? SanctumofOblivionType1Key : (WorldGen.genRand.NextBool() ? SanctumofOblivionType2Key : SanctumofOblivionType3Key); - PlaceSchematic>(secondSanctum, sanctumPlacementPoint, anchorType, ref place); - - // Protect the structure - Rectangle sanctumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondSanctum], sanctumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(sanctumProtectionArea2, 10); - - // Small worlds only have one stronghold - string secondStronghold = smallWorld ? HellstoneStrongholdType1Key : HellstoneStrongholdType2Key; - PlaceSchematic(secondStronghold, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - - // Protect the structure - Rectangle strongholdProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStronghold], strongholdPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(strongholdProtectionArea2, 10); - } - else - { - int atriumGenX = ashIslandX2 - firstStructureDistanceFromIslandEdge; - int atriumGenY = ashIslandHeightLimit; - while (!Main.tile[atriumGenX, atriumGenY].HasTile) - atriumGenY++; - - Point atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffset); - SchematicAnchor anchorType = SchematicAnchor.Center; - bool place = true; - if (!smallWorld) - { - PlaceSchematic(BrimstoneAtriumType2Key, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - - Rectangle atriumProtectionArea = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(atriumProtectionArea, 10); - - atriumGenX -= distanceBetweenStructures_AfterFirstIsland; - - atriumGenY = ashIslandHeightLimit; - while (!Main.tile[atriumGenX, atriumGenY].HasTile) - atriumGenY++; - - atriumPlacementPoint = new Point(atriumGenX, atriumGenY + atriumOffset); - } - - if (atriumMapKey == BrimstoneAtriumType2Key) - PlaceSchematic(atriumMapKey, atriumPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - else - PlaceSchematic>(atriumMapKey, atriumPlacementPoint, anchorType, ref place); - - Rectangle atriumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(atriumSchematic, atriumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(atriumProtectionArea2, 10); - - int sanctumGenX = ashIslandX + firstStructureDistanceFromIslandEdge; - int sanctumGenY = ashIslandDepthLimit + sanctumOffset; - - int strongholdGenY = ashIslandHeightLimit; - while (!Main.tile[sanctumGenX, strongholdGenY].HasTile) - strongholdGenY++; - - Point sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); - Point strongholdPlacementPoint = new Point(sanctumGenX, strongholdGenY + strongholdOffset); - if (!smallWorld) - { - PlaceSchematic>(SanctumofOblivionType1Key, sanctumPlacementPoint, anchorType, ref place); - - Rectangle sanctumProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[SanctumofOblivionType1Key], sanctumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(sanctumProtectionArea, 10); - - PlaceSchematic(HellstoneStrongholdType1Key, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - - Rectangle strongholdProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[HellstoneStrongholdType1Key], strongholdPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(strongholdProtectionArea, 10); - - sanctumGenX += distanceBetweenStructures_AfterFirstIsland; - - strongholdGenY = ashIslandHeightLimit; - while (!Main.tile[sanctumGenX, strongholdGenY].HasTile) - strongholdGenY++; - - strongholdPlacementPoint = new Point(sanctumGenX, strongholdGenY + strongholdOffset); - - sanctumPlacementPoint = new Point(sanctumGenX, sanctumGenY); - } - - string secondSanctum = smallWorld ? SanctumofOblivionType1Key : (WorldGen.genRand.NextBool() ? SanctumofOblivionType2Key : SanctumofOblivionType3Key); - PlaceSchematic>(secondSanctum, sanctumPlacementPoint, anchorType, ref place); - - Rectangle sanctumProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondSanctum], sanctumPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(sanctumProtectionArea2, 10); - - string secondStronghold = smallWorld ? HellstoneStrongholdType1Key : HellstoneStrongholdType2Key; - PlaceSchematic(secondStronghold, strongholdPlacementPoint, anchorType, ref place, new Action(FillAtriumChests)); - - Rectangle strongholdProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondStronghold], strongholdPlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(strongholdProtectionArea2, 10); - } - - // Pick cache types - List caches = new List(); - int numCaches = largeWorld ? 8 : 4; // THIS NUMBER MUST BE EVEN!!! - int cacheTypes = 6; - int totalCachePositions = numCaches / 2; - do - { - // Chose a random cache to add to the list - int chosenCache = WorldGen.genRand.Next(cacheTypes); - - // Don't choose the same cache twice - bool alreadyContainsThisCacheType = caches.Contains(chosenCache); - - // Avoid an infinite loop by picking a random duplicate cache if the max is reached - bool pickRandomDuplicateCache = caches.Count >= cacheTypes; - if (pickRandomDuplicateCache) - pickRandomDuplicateCache = caches[caches.Count - totalCachePositions] != chosenCache; - - if (!alreadyContainsThisCacheType || pickRandomDuplicateCache) - caches.Add(chosenCache); - } - while (caches.Count < numCaches); - - // - // Place caches - // - int cacheGenX = ashIslandX + firstStructureDistanceFromIslandEdge + (distanceBetweenStructures_AfterFirstIsland * numAtriums); - int cacheGenY = ashIslandDepthLimit + cacheOffset; - int randomAdjustmentX = 0; - int randomAdjustmentY = 0; - int minRandomX = -30; - int maxRandomX = -20; - int minRandomY = 0; - int maxRandomY = 10; - for (int cacheIndex = 0; cacheIndex < totalCachePositions; cacheIndex++) - { - randomAdjustmentX += WorldGen.genRand.Next(minRandomX, maxRandomX + 1); - randomAdjustmentX = (int)MathHelper.Clamp(randomAdjustmentX, minRandomX, maxRandomX); - randomAdjustmentY += WorldGen.genRand.Next(minRandomY, maxRandomY + 1); - randomAdjustmentY = (int)MathHelper.Clamp(randomAdjustmentY, minRandomY, maxRandomY); - - string cacheMapKey; - switch (caches[cacheIndex]) - { - default: - case 0: - cacheMapKey = BonescrapperCacheType1Key; - break; - - case 1: - cacheMapKey = BonescrapperCacheType2Key; - break; - - case 2: - cacheMapKey = BonescrapperCacheType3Key; - break; - - case 3: - cacheMapKey = BonescrapperCacheType4Key; - break; - - case 4: - cacheMapKey = BonescrapperCacheType5Key; - break; - - case 5: - cacheMapKey = BonescrapperCacheType6Key; - break; - } - - Point cachePlacementPoint = new Point(cacheGenX + randomAdjustmentX, cacheGenY + randomAdjustmentY); - SchematicAnchor anchorType = SchematicAnchor.Center; - bool place = true; - - // Cache types 2, 3, and 6 have chests - if (cacheMapKey == BonescrapperCacheType2Key || cacheMapKey == BonescrapperCacheType3Key || cacheMapKey == BonescrapperCacheType6Key) - PlaceSchematic(cacheMapKey, cachePlacementPoint, anchorType, ref place, new Action(FillCacheChests)); - else - PlaceSchematic>(cacheMapKey, cachePlacementPoint, anchorType, ref place); - - // Protect the structure - Rectangle cacheProtectionArea = CalamityUtils.GetSchematicProtectionArea(TileMaps[cacheMapKey], cachePlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(cacheProtectionArea, 5); - - string secondCacheMapKey; - switch (caches[cacheIndex + totalCachePositions]) - { - default: - case 0: - secondCacheMapKey = BonescrapperCacheType1Key; - break; - - case 1: - secondCacheMapKey = BonescrapperCacheType2Key; - break; - - case 2: - secondCacheMapKey = BonescrapperCacheType3Key; - break; - - case 3: - secondCacheMapKey = BonescrapperCacheType4Key; - break; - - case 4: - secondCacheMapKey = BonescrapperCacheType5Key; - break; - - case 5: - secondCacheMapKey = BonescrapperCacheType6Key; - break; - } - - // Place second cache to the right of the first - Point secondCachePlacementPoint = cachePlacementPoint + new Point(WorldGen.genRand.Next(60, 76), 0); - if (secondCacheMapKey == BonescrapperCacheType2Key || secondCacheMapKey == BonescrapperCacheType3Key || secondCacheMapKey == BonescrapperCacheType6Key) - PlaceSchematic(secondCacheMapKey, secondCachePlacementPoint, anchorType, ref place, new Action(FillCacheChests)); - else - PlaceSchematic>(secondCacheMapKey, secondCachePlacementPoint, anchorType, ref place); - - // Protect the structure - Rectangle cacheProtectionArea2 = CalamityUtils.GetSchematicProtectionArea(TileMaps[secondCacheMapKey], secondCachePlacementPoint, anchorType); - CalamityUtils.AddProtectedStructure(cacheProtectionArea2, 5); - - // Reset positions and move cache placement along the X axis - cacheGenX = ashIslandX + firstStructureDistanceFromIslandEdge + (distanceBetweenStructures_AfterFirstIsland * (numAtriums + cacheIndex + 1)); - cacheGenY = ashIslandDepthLimit + cacheOffset; - } - } - // Placing torches in towers float torchAmountMult = Main.maxTilesX / 4200f; for (int torchIndex = 0; (float)torchIndex < 200f * torchAmountMult; torchIndex++) diff --git a/icon.png b/icon.png index bcc6cce92b..80069a3be1 100644 Binary files a/icon.png and b/icon.png differ diff --git a/icon_workshop.png b/icon_workshop.png index df0f63ecf2..1edebb0978 100644 Binary files a/icon_workshop.png and b/icon_workshop.png differ