diff --git a/Balancing/BalancingChangesManager.cs b/Balancing/BalancingChangesManager.cs index e357f081a4..3e10e83716 100644 --- a/Balancing/BalancingChangesManager.cs +++ b/Balancing/BalancingChangesManager.cs @@ -183,9 +183,6 @@ namespace CalamityMod.Balancing // 25% resist to Avalanche's Ice Bombs and shards. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); - // 25% resist to SHPC. - NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType())))); - // 25% resist to Snowstorm Staff. NPCSpecificBalancingChanges.AddRange(Bundle(CalamityLists.DestroyerIDs, Do(new ProjectileResistBalancingRule(0.75f, ProjectileType(), ProjectileType())))); #endregion diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 08fbe74c5f..ff3a3e3c14 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -622,6 +622,7 @@ namespace CalamityMod.CalPlayer public bool harpyRing = false; public bool angelTreads = false; public bool harpyWingBoost = false; //harpy wings + harpy ring + public int harpyWingFeatherCooldown = 0; public bool fleshKnuckles = false; public bool ironBoots = false; public bool depthCharm = false; @@ -2752,6 +2753,7 @@ namespace CalamityMod.CalPlayer persecutedEnchantSummonTimer = 0; momentumCapacitorTime = 0; momentumCapacitorBoost = 0f; + harpyWingFeatherCooldown = 0; LungingDown = false; chaliceBleedoutBuffer = 0D; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index c473ec355b..858759d482 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -1543,6 +1543,8 @@ namespace CalamityMod.CalPlayer hideOfDeusTimer--; if (murasamaHitCooldown > 0) murasamaHitCooldown--; + if (harpyWingFeatherCooldown > 0) + harpyWingFeatherCooldown--; if (burningSeaBurnOut > 0) { burningSeaBurnOut--; diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 34a8e4f2a8..e2b70c8f8f 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -8,6 +8,7 @@ using CalamityMod.Enums; using CalamityMod.Events; using CalamityMod.Items.Accessories; using CalamityMod.Items.VanillaArmorChanges; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Items.Weapons.Melee; using CalamityMod.Items.Weapons.Summon; using CalamityMod.NPCs.Other; @@ -205,6 +206,13 @@ namespace CalamityMod.Items break; } + // Allow Souls to be used as ammo for SHPC. + if (item.type == ItemID.SoulofLight || item.type == ItemID.SoulofNight || item.type == ItemID.SoulofFlight || item.type == ItemID.SoulofMight || item.type == ItemID.SoulofSight || item.type == ItemID.SoulofFright) + { + item.ammo = ItemID.SoulofLight; + item.notAmmo = true; // Prevents them from showing an "Ammo" tooltip or going to ammo slots. + } + // Increase how much health Mushrooms heal. if (item.type == ItemID.Mushroom && item.healLife == 15) item.healLife = 25; @@ -504,8 +512,9 @@ namespace CalamityMod.Items } if (modPlayer.harpyWingBoost && (modPlayer.harpyRing || modPlayer.angelTreads)) { - if (Main.rand.NextBool(5) && !item.channel) + if (Main.rand.NextBool(5) && modPlayer.harpyWingFeatherCooldown == 0 && !item.channel) { + modPlayer.harpyWingFeatherCooldown = 20; if (player.whoAmI == Main.myPlayer) { float spreadX = velocity.X + Main.rand.NextFloat(-0.75f, 0.75f); diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 2101b2da51..05cc5a813e 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -1,35 +1,52 @@ -using System.Collections.Generic; -using CalamityMod.Items.Materials; +using CalamityMod.Items.Materials; using CalamityMod.Projectiles.Magic; using CalamityMod.Sounds; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; using Terraria; +using Terraria.Audio; using Terraria.DataStructures; +using Terraria.GameContent; using Terraria.ID; using Terraria.ModLoader; +using Terraria.ModLoader.IO; namespace CalamityMod.Items.Weapons.Magic { - public class SHPC : ModItem, ILocalizedModType + public class SHPC : LegendaryItem, ILocalizedModType { public new string LocalizationCategory => "Items.Weapons.Magic"; - public override void SetStaticDefaults() - { - ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; - } + public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/AnomalysNanogunMPFBShot"); + + public const int ShotsPerSoul = 40; + public int storedSoulpower = 0; + public int storedSoulType = ItemID.SoulofLight; // Determines bar color and soul effects for projectile + public int recoilProgress = 0; + + public const float LightExplosionSizeMult = 1.5f; + public const float NightExplosionTimeMult = 2.5f; + public const int FlightDirectHitFlightBoost = 25; // The amount of flight time restored on direct hits with Flight bombs, in frames + public const float MightKnockbackStrength = 8f; // The value to multiply the unit vector by when applying velocity to enemies launched by Might bombs + public const float SightHomingRange = 288f; // Range of homing for Sight bombs, in pixels + public const int FrightFlatDamage = 20; + + public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; public override void SetDefaults() { Item.width = 124; Item.height = 52; - Item.damage = 16; + Item.damage = 94; Item.DamageType = DamageClass.Magic; - Item.mana = 20; - Item.useAnimation = Item.useTime = 7; + Item.mana = 15; + Item.useAnimation = Item.useTime = 60; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 3.25f; - Item.UseSound = SoundID.Item92; + Item.knockBack = 3f; + Item.UseSound = FireSound; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; @@ -38,21 +55,143 @@ namespace CalamityMod.Items.Weapons.Magic Item.rare = ItemRarityID.Pink; } + #region Weapon-Specific Functions + public int FindSoulForAmmo(Player player) + { + int soul = -1; + bool foundItem = false; + + // First check ammo slots + for (int s = 54; s < 58; s++) + { + if (player.inventory[s].stack > 0 && player.inventory[s].ammo == ItemID.SoulofLight) + { + soul = player.inventory[s].type; + foundItem = true; + break; + } + } + + // If you didn't find anything in ammo slots, check normal inventory + if (!foundItem) + { + for (int i = 0; i < 54; i++) + { + if (player.inventory[i].stack > 0 && player.inventory[i].ammo == ItemID.SoulofLight) + { + soul = player.inventory[i].type; + break; + } + } + } + + return soul; + } + + public Color FindColorForSoul() + { + Color returnColor = new(0, 0, 0); + switch (storedSoulType) + { + case ItemID.SoulofLight: + returnColor = new(240, 29, 196); + break; + case ItemID.SoulofNight: + returnColor = new(123, 29, 220); + break; + case ItemID.SoulofFlight: + returnColor = new(106, 240, 250); + break; + case ItemID.SoulofMight: + returnColor = new(4, 51, 222); + break; + case ItemID.SoulofSight: + returnColor = new(79, 255, 124); + break; + case ItemID.SoulofFright: + returnColor = new(255, 128, 20); + break; + } + return returnColor; + } + + public int TransferColorToProj() + { + int projai = 0; + switch (storedSoulType) + { + case ItemID.SoulofLight: + projai = 0; + break; + case ItemID.SoulofNight: + projai = 1; + break; + case ItemID.SoulofFlight: + projai = 2; + break; + case ItemID.SoulofMight: + projai = 3; + break; + case ItemID.SoulofSight: + projai = 4; + break; + case ItemID.SoulofFright: + projai = 5; + break; + } + return projai; + } + #endregion + public override Vector2? HoldoutOffset() => new Vector2(-35, -10); public override bool AltFunctionUse(Player player) => true; + public override void OnCreated(ItemCreationContext context) + { + if (context is RecipeItemCreationContext) + storedSoulpower = ShotsPerSoul; + } + public override bool CanUseItem(Player player) { if (player.altFunctionUse == 2) { - Item.UseSound = CommonCalamitySounds.LaserCannonSound; + Item.useTime = 3; + Item.useAnimation = 3 * storedSoulpower; + Item.UseSound = null; } else { - Item.UseSound = SoundID.Item92; + Item.useTime = Item.useAnimation = 60; + Item.UseSound = FireSound; } - return base.CanUseItem(player); + + return storedSoulpower > 0 || (FindSoulForAmmo(player) != -1 && player.altFunctionUse != 2); + } + + public override bool? UseItem(Player player) + { + if (storedSoulpower > 0) + storedSoulpower--; + + if (storedSoulpower <= 0 && player.altFunctionUse != 2) + { + bool ammoConsumed = false; + + if (FindSoulForAmmo(player) != -1) + { + int soulType = FindSoulForAmmo(player); + player.ConsumeItem(soulType); + storedSoulType = soulType; + ammoConsumed = true; + } + + if (ammoConsumed) + storedSoulpower = ShotsPerSoul; + } + + return base.UseItem(player); } public override void ModifyManaCost(Player player, ref float reduce, ref float mult) @@ -64,35 +203,85 @@ namespace CalamityMod.Items.Weapons.Magic public override float UseSpeedMultiplier(Player player) { if (player.altFunctionUse == 2) - return 1f; + return 6f; - return 1 / 7.14f; + return 1f; } public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (player.altFunctionUse == 2) { - for (int shootAmt = 0; shootAmt < 3; shootAmt++) + SoundEngine.PlaySound(CommonCalamitySounds.ELRFireSound, player.Center); + if (storedSoulpower % 2 == 0) { - float SpeedX = velocity.X + (float)Main.rand.Next(-20, 21) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-20, 21) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), damage, knockback * 0.5f, player.whoAmI); + Vector2 Speed = new Vector2(velocity.X + Main.rand.NextFloat(-1f, 1f), velocity.Y + Main.rand.NextFloat(-1f, 1f)); + Projectile.NewProjectile(source, position + new Vector2(0, -10) + velocity * 2.6f, Speed, ModContent.ProjectileType(), (int)(damage * 0.25f), knockback * 0.5f, player.whoAmI, TransferColorToProj()); } return false; } else { - for (int shootAmt = 0; shootAmt < 3; shootAmt++) - { - float SpeedX = velocity.X + (float)Main.rand.Next(-40, 41) * 0.05f; - float SpeedY = velocity.Y + (float)Main.rand.Next(-40, 41) * 0.05f; - Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, ModContent.ProjectileType(), (int)(damage * 1.1), knockback, player.whoAmI); - } + Projectile.NewProjectile(source, position + new Vector2(0, -10) + velocity * 3f, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, TransferColorToProj()); return false; } } + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + float barScale = 2.5f; + var barBG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; + var barFG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; + + Vector2 drawPos = position + new Vector2((frame.Width - barBG.Width * 0.5f) * scale, (frame.Height + 45f) * scale); + Rectangle frameCrop = new Rectangle(0, 0, (int)(storedSoulpower / (float)ShotsPerSoul * barFG.Width), barFG.Height); + Color colorBG = Color.Black; + Color colorFG = Color.Lerp(Color.DarkGray, FindColorForSoul(), storedSoulpower / (float)ShotsPerSoul); + + spriteBatch.Draw(barBG, drawPos, null, colorBG, 0f, origin, scale * barScale, 0f, 0f); + spriteBatch.Draw(barFG, drawPos, frameCrop, colorFG * 0.8f, 0f, origin, scale * barScale, 0f, 0f); + + CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, storedSoulpower.ToString(), drawPos + new Vector2(-200, -60) * scale, Color.GreenYellow, Color.Black, scale * 2.5f); + } + + #region Recoil Stuff + public override void HoldItem(Player player) => player.Calamity().mouseWorldListener = true; + public override void UseStyle(Player player, Rectangle heldItemFrame) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float itemRotation = player.compositeFrontArm.rotation + MathHelper.PiOver2 * player.gravDir; + + Vector2 itemPosition = player.MountedCenter + itemRotation.ToRotationVector2() * 35f; + Vector2 itemSize = new Vector2(Item.width, Item.height); + Vector2 itemOrigin = new Vector2(-35, 0); + + if (player.altFunctionUse != 2) + { + recoilProgress++; + if (recoilProgress < Item.useAnimation / 3) + { + itemPosition -= (player.Calamity().mouseWorld - player.Center).SafeNormalize(Vector2.UnitX) * (Item.useAnimation / 3 - recoilProgress) * 0.75f; + } + else + { + if (recoilProgress >= Item.useAnimation - 1) + recoilProgress = 0; + } + } + + CalamityUtils.CleanHoldStyle(player, itemRotation, itemPosition, itemSize, itemOrigin); + base.UseStyle(player, heldItemFrame); + } + + public override void UseItemFrame(Player player) + { + player.ChangeDir(Math.Sign((player.Calamity().mouseWorld - player.Center).X)); + float rotation = (player.Center - player.Calamity().mouseWorld).ToRotation() * player.gravDir + MathHelper.PiOver2; + + player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); + } + #endregion + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) { // scaling legendary!!!! @@ -124,8 +313,48 @@ namespace CalamityMod.Items.Weapons.Magic AddIngredient(). AddIngredient(4). AddRecipeGroup("AnyMythrilBar", 10). + AddIngredient(ItemID.SoulofFright, 5). + AddIngredient(ItemID.SoulofMight, 5). + AddIngredient(ItemID.SoulofSight, 5). AddTile(TileID.MythrilAnvil). Register(); } + + #region Saving Ammo Amount and Soul Type + public override ModItem Clone(Item item) + { + ModItem clone = base.Clone(item); + if (clone is SHPC a && item.ModItem is SHPC a2) + { + a.storedSoulpower = a2.storedSoulpower; + a.storedSoulType = a2.storedSoulType; + } + return clone; + } + + public override void SaveData(TagCompound tag) + { + tag["ammoStored"] = storedSoulpower; + tag["soulType"] = storedSoulType; + } + + public override void LoadData(TagCompound tag) + { + storedSoulpower = tag.GetInt("ammoStored"); + storedSoulType = tag.GetInt("soulType"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(storedSoulpower); + writer.Write(storedSoulType); + } + + public override void NetReceive(BinaryReader reader) + { + storedSoulpower = reader.ReadInt32(); + storedSoulType = reader.ReadInt32(); + } + #endregion } } diff --git a/Items/Weapons/Rogue/Sandslasher.cs b/Items/Weapons/Rogue/Sandslasher.cs deleted file mode 100644 index a7ad94ff3b..0000000000 --- a/Items/Weapons/Rogue/Sandslasher.cs +++ /dev/null @@ -1,56 +0,0 @@ -using CalamityMod.Items.Materials; -using CalamityMod.Projectiles.Rogue; -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.DataStructures; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Items.Weapons.Rogue -{ - public class Sandslasher : RogueWeapon - { - public override void SetDefaults() - { - Item.width = 40; - Item.height = 40; - Item.damage = 115; - Item.noMelee = true; - Item.noUseGraphic = true; - Item.useAnimation = 20; - Item.useStyle = ItemUseStyleID.Swing; - Item.useTime = 20; - Item.knockBack = 5f; - Item.UseSound = SoundID.Item1; - Item.autoReuse = true; - Item.value = CalamityGlobalItem.RarityLimeBuyPrice; - Item.rare = ItemRarityID.Lime; - Item.shoot = ModContent.ProjectileType(); - Item.shootSpeed = 8f; - Item.DamageType = RogueDamageClass.Instance; - } - - public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) - { - if (player.Calamity().StealthStrikeAvailable()) - { - int proj = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI); - if (proj.WithinBounds(Main.maxProjectiles)) - Main.projectile[proj].Calamity().stealthStrike = true; - return false; - } - return true; - } - - public override void AddRecipes() - { - CreateRecipe(). - AddIngredient(). - AddIngredient(6). - AddRecipeGroup("AnyGoldBar", 10). - AddIngredient(ItemID.HardenedSand, 25). - AddTile(TileID.MythrilAnvil). - Register(); - } - } -} diff --git a/Items/Weapons/Rogue/Sandslasher.png b/Items/Weapons/Rogue/Sandslasher.png deleted file mode 100644 index bee7527680..0000000000 Binary files a/Items/Weapons/Rogue/Sandslasher.png and /dev/null differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 993614cc79..4140009843 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -778,8 +778,18 @@ SHPC: { Tooltip: "[GFB]" TooltipNormal: ''' - Fires plasma orbs that linger and emit massive explosions - Press to fire powerful energy beams + Consumes Souls as ammo + Fires orbs of unstable, concentrated soulpower that linger after ejection + Orbs create a large explosion and emit seeking souls after collapse + Orbs have varying effects depending on Soul type used + Press Right Click to discharge all soulpower in the weapon as weak energy beams + ''' + LegendaryText: + ''' + [c/1FFBFF:'Though soul-powered machines were a near failure, potential remained in souls as a form of fuel.] + [c/1FFBFF:To avoid my last experiments' main flaw, the Soul-Harnessing Plasma Cannon was designed to expel souls as projectiles before they exert control over the weapon.] + [c/1FFBFF:Each soul type appears to react differently to the base plasma. Yet, lacking volunteers, obtaining potential ammunition is currently too difficult to undergo further testing.] + [c/1FFBFF:A shame, for a weapon that could have practically unlimited ammunition in the battlefield. Perhaps some day, its potential can be truly tested.'] ''' TooltipGFB: It scales again :) } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 70dc83ba46..39b4651db3 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -954,16 +954,6 @@ SandDollar: { ''' } -Sandslasher: { - DisplayName: Sandslasher - Tooltip: - ''' - Throws a huge shuriken made out of fused sand unaffected by gravity which slowly accelerates horizontally - It does more damage depending on how fast it goes horizontally and how long it has been flying for - Stealth strikes periodically release sand clouds - ''' -} - ScarletDevil: { DisplayName: Scarlet Devil Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson index 2e16c9183a..9d9a8fa897 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Magic.hjson @@ -199,6 +199,7 @@ ShiftingSandsProj.DisplayName: Shifting Sands SHPB.DisplayName: SHPB SHPExplosion.DisplayName: SHPB Explosion SHPL.DisplayName: SHPL +SHPS.DisplayName: SHPS SilvaBurst.DisplayName: Silva Burst SlitheringEelProjectile.DisplayName: Slithering Eel SmallSpirit.DisplayName: Small Angry Spirit diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index 82c4f549fb..d31641e95d 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -230,7 +230,6 @@ SamsaraSlicerProjectile.DisplayName: Samsara Slicer SamsaraSlicerSmallDisk.DisplayName: Samsara Slicer SandDollarProj.DisplayName: Sand Dollar SandDollarStealth.DisplayName: Sand Dollar -SandslasherProj.DisplayName: Sandslasher ScarletBlast.DisplayName: Scarlet Blast ScarletDevilBullet.DisplayName: Gungnir Bullet ScarletDevilProjectile.DisplayName: Spear the Gungnir diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 9bc6bf6fd2..423ba2c852 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -220,47 +220,28 @@ namespace CalamityMod.NPCs.SlimeGod } } + // Used to gauge how aggressive the core is, based on Paladins alive + // Stay near the Paladins and do nothing else at level 0 + // Fire projectiles at level 1 + // Charge at level 2 + // Follow the player around instead of the Paladins at level 3 + // Buff a Paladin far sooner, fire more projectiles, and charge faster at level 4 + int aggressionLevel = 0; + if (!NPC.AnyNPCs(ModContent.NPCType()) && !NPC.AnyNPCs(ModContent.NPCType())) + { + aggressionLevel = 1; + int splitPaladinCount = NPC.CountNPCS(ModContent.NPCType()) + NPC.CountNPCS(ModContent.NPCType()); + if (splitPaladinCount < 2) + aggressionLevel = 4; + else if (splitPaladinCount < 3) + aggressionLevel = 3; + else if (splitPaladinCount < 4) + aggressionLevel = 2; + } + // Enrage based on large slimes - bool purpleSlimeAlive = false; - bool redSlimeAlive = false; - - if (CalamityGlobalNPC.slimeGodPurple != -1) - { - if (Main.npc[CalamityGlobalNPC.slimeGodPurple].active) - { - if (buffedSlime == 1) - Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 1f; - else - Main.npc[CalamityGlobalNPC.slimeGodPurple].localAI[1] = 0f; - - calamityGlobalNPC.newAI[0] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.X; - calamityGlobalNPC.newAI[1] = Main.npc[CalamityGlobalNPC.slimeGodPurple].Center.Y; - - // Despawn check - calamityGlobalNPC.newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodPurple].ai[0] == 4f ? 1f : 0f; - - purpleSlimeAlive = true; - } - } - - if (CalamityGlobalNPC.slimeGodRed != -1) - { - if (Main.npc[CalamityGlobalNPC.slimeGodRed].active) - { - if (buffedSlime == 2) - Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 1f; - else - Main.npc[CalamityGlobalNPC.slimeGodRed].localAI[1] = 0f; - - NPC.ai[1] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.X; - NPC.ai[2] = Main.npc[CalamityGlobalNPC.slimeGodRed].Center.Y; - - // Despawn check - calamityGlobalNPC.newAI[3] = Main.npc[CalamityGlobalNPC.slimeGodRed].ai[0] == 3f ? 1f : 0f; - - redSlimeAlive = true; - } - } + bool purpleSlimeAlive = EbonianPaladinAlive(NPC); + bool redSlimeAlive = CrimulanPaladinAlive(NPC); // Start shooting blobs more often, move faster and buff large slimes more often if one type of large slime is dead bool phase2 = !purpleSlimeAlive || !redSlimeAlive; @@ -418,7 +399,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.timeLeft = 1800; // Hide inside large slime - float hideInsideLargeSlimePhaseGateValue = phase2 ? 300f : 900f; + float hideInsideLargeSlimePhaseGateValue = aggressionLevel == 4 ? 120f : phase2 ? 300f : 900f; float hideInsideLargeSlimePhaseDuration = 600f; float exitLargeSlimeGateValue = hideInsideLargeSlimePhaseGateValue + hideInsideLargeSlimePhaseDuration; calamityGlobalNPC.newAI[2] += 1f; @@ -502,11 +483,12 @@ namespace CalamityMod.NPCs.SlimeGod // Avoid cheap bullshit NPC.damage = 0; - if (expertMode) + if (expertMode && aggressionLevel >= 1) { - float divisor = bossRush ? 90f : death ? 180f : revenge ? 240f : 300f; - if (phase2) - divisor /= 2; + float divisor = bossRush ? 50f : death ? 90f : revenge ? 120f : 150f; + divisor -= (aggressionLevel - 1) * 10f; + if (aggressionLevel == 4) + divisor *= 0.5f; if (calamityGlobalNPC.newAI[2] % divisor == 0f) { @@ -515,7 +497,7 @@ namespace CalamityMod.NPCs.SlimeGod { if (Main.rand.NextBool()) { - float projectileVelocity = 4f; + float projectileVelocity = 4f + (aggressionLevel - 1) * 2f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); Vector2 velocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; @@ -523,7 +505,7 @@ namespace CalamityMod.NPCs.SlimeGod } else { - float projectileVelocity = 8f; + float projectileVelocity = 8f + (aggressionLevel - 1) * 2f; int type = ModContent.ProjectileType(); int damage = NPC.GetProjectileDamage(type); Vector2 velocity = Vector2.Normalize(player.Center - NPC.Center) * projectileVelocity; @@ -540,49 +522,64 @@ namespace CalamityMod.NPCs.SlimeGod buffedSlime = 0; float flySpeed = death ? 15f : revenge ? 13.5f : expertMode ? 12f : 9f; + flySpeed += aggressionLevel; + if (aggressionLevel == 4) + flySpeed += 3f; if (phase2) - flySpeed *= 1.25f; + flySpeed *= 1.1f; if (bossRush) - flySpeed *= 1.25f; + flySpeed *= 1.2f; if (Main.getGoodWorld) - flySpeed *= 1.25f; + flySpeed *= 1.3f; Vector2 flyDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - Vector2 flyDestination = GetFlyDestination(player); + Vector2 flyDestination = aggressionLevel >= 3 ? player.Center : GetFlyDestination(player); Vector2 idealVelocity = (flyDestination - flyDirection).SafeNormalize(Vector2.UnitY) * flySpeed; float distanceFromFlyDestination = NPC.Distance(flyDestination); - NPC.ai[0] -= 1f; - if (distanceFromFlyDestination < 200f || NPC.ai[0] > 0f) + if (aggressionLevel >= 2) { - // Set damage - NPC.damage = NPC.defDamage; + NPC.ai[0] -= 1f; + if (distanceFromFlyDestination < 200f || NPC.ai[0] > 0f) + { + // Set damage + NPC.damage = NPC.defDamage; - if (distanceFromFlyDestination < 200f) - NPC.ai[0] = 20f; + if (distanceFromFlyDestination < 200f) + NPC.ai[0] = 20f; - if (NPC.velocity.X < 0f) - NPC.direction = -1; - else - NPC.direction = 1; + if (NPC.velocity.X < 0f) + NPC.direction = -1; + else + NPC.direction = 1; - NPC.rotation += NPC.direction * 0.3f; + NPC.rotation += NPC.direction * 0.3f; - return; + return; + } } - float inertia = 50f; - if (Main.getGoodWorld) - inertia *= 0.8f; - if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) - inertia -= Main.rand.Next(31); + if (distanceFromFlyDestination < 150f && aggressionLevel < 2) + { + if (NPC.velocity.Length() > flySpeed * 0.2f) + NPC.velocity *= 0.9f; + } + else + { + float inertia = 50f; + inertia -= aggressionLevel * 3f; + if (Main.getGoodWorld) + inertia *= 0.8f; + if (CalamityWorld.LegendaryMode && CalamityWorld.revenge) + inertia *= Main.rand.NextFloat(0.2f, 1f); - NPC.velocity = (NPC.velocity * inertia + idealVelocity) / (inertia + 1f); - if (distanceFromFlyDestination < 350f) - NPC.velocity = (NPC.velocity * 10f + idealVelocity) / 11f; - if (distanceFromFlyDestination < 300f) - NPC.velocity = (NPC.velocity * 7f + idealVelocity) / 8f; + NPC.velocity = (NPC.velocity * inertia + idealVelocity) / (inertia + 1f); + if (distanceFromFlyDestination < 350f) + NPC.velocity = (NPC.velocity * 10f + idealVelocity) / 11f; + if (distanceFromFlyDestination < 300f) + NPC.velocity = (NPC.velocity * 7f + idealVelocity) / 8f; + } NPC.rotation = NPC.velocity.X * 0.05f; } @@ -665,7 +662,7 @@ namespace CalamityMod.NPCs.SlimeGod } SpriteEffects spriteEffects = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; - Color drawColorAlpha = buffedSlime != 0f ? new Color(200, 150, Main.DiscoB, NPC.alpha) * NPC.Opacity : NPC.GetAlpha(drawColor); + Color drawColorAlpha = (buffedSlime != 0f && !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; @@ -728,7 +725,7 @@ namespace CalamityMod.NPCs.SlimeGod } // Reset the color - drawColorAlpha = NPC.GetAlpha(drawColor); + drawColorAlpha = (buffedSlime != 0f && !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/Particles/SquareParticle.cs b/Particles/SquareParticle.cs index 811230e9fb..b3fe433662 100644 --- a/Particles/SquareParticle.cs +++ b/Particles/SquareParticle.cs @@ -42,10 +42,9 @@ namespace CalamityMod.Particles public override void CustomDraw(SpriteBatch spriteBatch) { - Vector2 scale = new Vector2(0.8f, 1.2f) * Scale; Texture2D texture = ModContent.Request(Texture).Value; - spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f); + spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, Scale, 0, 0f); } } } diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index edbdac9ab9..6760d73471 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Items.Weapons.Magic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -23,49 +24,131 @@ namespace CalamityMod.Projectiles.Magic Projectile.height = 24; Projectile.friendly = true; Projectile.alpha = 255; - Projectile.penetrate = 1; + Projectile.scale = 0.4f; Projectile.timeLeft = 300; Projectile.DamageType = DamageClass.Magic; } + // This is reused for all SHPC projectiles + #region General SHPC Projectile Functions + public enum SoulType + { + Light, // Larger explosion + Night, // Explosion lasts longer + Flight, // Restores flight time on direct hits + Might, // Launches enemies + Sight, // Weakly homes + Fright // Deals extra flat damage + } + + public static SoulType GetSoulEffects(int projai) + { + switch (projai) + { + case 0: + return SoulType.Light; + case 1: + return SoulType.Night; + case 2: + return SoulType.Flight; + case 3: + return SoulType.Might; + case 4: + return SoulType.Sight; + case 5: + return SoulType.Fright; + + default: + return SoulType.Light; + } + } + + public static Color FindColorForSoul(int projai) + { + switch (projai) + { + case 0: + return new(240, 29, 196); + case 1: + return new(123, 29, 220); + case 2: + return new(106, 240, 250); + case 3: + return new(4, 51, 222); + case 4: + return new(79, 255, 124); + case 5: + return new(255, 128, 20); + + default: + return new(0, 0, 0); + } + } + #endregion General SHPC Projectile Functions + public override void AI() { + // Light and fade in 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++; if (Projectile.frameCounter > 4) { - Projectile.frame++; Projectile.frameCounter = 0; + Projectile.frame++; + if (Projectile.frame > 3) + Projectile.frame = 0; } - if (Projectile.frame > 3) - { - Projectile.frame = 0; - } - Projectile.ai[0] = (float)Main.rand.Next(-100, 101) * 0.0025f; - Projectile.ai[1] = (float)Main.rand.Next(-100, 101) * 0.0025f; + + // Size pulsing + bool lightSoul = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light; + if (Projectile.localAI[0] == 0f) { Projectile.scale += 0.05f; - if ((double)Projectile.scale > 1.2) - { + if (Projectile.scale > 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) Projectile.localAI[0] = 1f; - } } else { Projectile.scale -= 0.05f; - if ((double)Projectile.scale < 0.8) - { + if (Projectile.scale < 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) Projectile.localAI[0] = 0f; - } } - Projectile.velocity.X *= 0.985f; - Projectile.velocity.Y *= 0.985f; - float projX = Projectile.Center.X; - float projY = Projectile.Center.Y; + + // Sight has weak homing + if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Sight) + { + float npcDistCheck = SHPC.SightHomingRange; + int index = -1; + foreach (NPC n in Main.ActiveNPCs) + { + if (!n.CanBeChasedBy(Projectile)) + continue; + + float currentNPCDist = Vector2.Distance(n.Center, Projectile.Center); + if (currentNPCDist < npcDistCheck) + { + npcDistCheck = currentNPCDist; + index = n.whoAmI; + } + } + + if (index != -1) + { + float speed = Projectile.velocity.Length(); + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Main.npc[index].Center).ToRotation(), 0.1f).ToRotationVector2() * speed; + } + else // Slow down over time if not homing + Projectile.velocity *= 0.9875f; + } + else if (!(GetSoulEffects((int)Projectile.ai[0]) == SoulType.Flight))// Always slow down if not Flight + Projectile.velocity *= 0.9875f; + float explodeRange = 250f; bool canExplode = false; foreach (NPC n in Main.ActiveNPCs) @@ -86,33 +169,65 @@ namespace CalamityMod.Projectiles.Magic { explosionTimer--; if (explosionTimer <= 0) - { Projectile.Kill(); - } } } - public override Color? GetAlpha(Color lightColor) + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - return new Color(255, Main.DiscoG, 155, Projectile.alpha); + Player owner = Main.player[Projectile.owner]; + // Flight restores flight time on direct hit + if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Flight) + { + if (owner.wingTime < owner.wingTimeMax) + owner.wingTime += SHPC.FlightDirectHitFlightBoost; + + if (owner.wingTime > owner.wingTimeMax) + owner.wingTime = owner.wingTimeMax; + } + + // Might launches enemies + if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Might && target.CanBeMoved(false)) + { + Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength - new Vector2(0, 3); + target.velocity = launchVel; + } } - public override bool PreDraw(ref Color lightColor) + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { - Texture2D texture2D13 = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - int framing = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value.Height / Main.projFrames[Projectile.type]; - int y6 = framing * Projectile.frame; - Main.spriteBatch.Draw(texture2D13, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, y6, texture2D13.Width, framing)), Projectile.GetAlpha(lightColor), Projectile.rotation, new Vector2((float)texture2D13.Width / 2f, (float)framing / 2f), Projectile.scale, SpriteEffects.None, 0); - return false; + // Fright deals extra flat damage + if (GetSoulEffects((int)Projectile.ai[0]) == SoulType.Fright) + modifiers.SourceDamage.Flat += SHPC.FrightFlatDamage; } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item105, Projectile.Center); + float screenshake = GetSoulEffects((int)Projectile.ai[0]) == SoulType.Light ? 5f : 3.5f; + if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < screenshake) + Main.LocalPlayer.Calamity().GeneralScreenShakePower = screenshake; + if (Projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center.X, Projectile.Center.Y, 0f, 0f, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), Projectile.knockBack, Projectile.owner, Projectile.ai[0], 0f); + + for (int i = 0; i < 5; i++) + { + Vector2 soulVelocity = -Vector2.UnitY.RotatedByRandom(MathHelper.Pi) * Main.rand.NextFloat(6f, 9f); + Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, soulVelocity, ModContent.ProjectileType(), (int)(Projectile.damage * 0.33f), 0f, Projectile.owner, Main.rand.Next(6)); + } } } + + public override Color? GetAlpha(Color lightColor) => FindColorForSoul((int)Projectile.ai[0]); + + 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); + return false; + } } } diff --git a/Projectiles/Magic/SHPB.png b/Projectiles/Magic/SHPB.png index e0b4f68f54..35c0478ad8 100644 Binary files a/Projectiles/Magic/SHPB.png and b/Projectiles/Magic/SHPB.png differ diff --git a/Projectiles/Magic/SHPExplosion.cs b/Projectiles/Magic/SHPExplosion.cs index 10f9bacce6..497771e89b 100644 --- a/Projectiles/Magic/SHPExplosion.cs +++ b/Projectiles/Magic/SHPExplosion.cs @@ -1,4 +1,6 @@ using System; +using CalamityMod.Items.Weapons.Magic; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -8,6 +10,8 @@ namespace CalamityMod.Projectiles.Magic { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public const int Lifetime = 20; + public ref float Timer => ref Projectile.ai[2]; public override void SetDefaults() { @@ -18,63 +22,72 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.timeLeft = 60; + Projectile.timeLeft = Lifetime; Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 15; + Projectile.localNPCHitCooldown = -1; } public override void AI() { - float lights = (float)Main.rand.Next(90, 111) * 0.01f; + float lights = Main.rand.NextFloat(0.9f, 1.1f); lights *= Main.essScale; Lighting.AddLight(Projectile.Center, 5f * lights, 1f * lights, 4f * lights); - float projTimer = 25f; - if (Projectile.ai[0] > 180f) + bool lightSoul = SHPB.GetSoulEffects((int)Projectile.ai[0]) == SHPB.SoulType.Light; + bool nightSoul = SHPB.GetSoulEffects((int)Projectile.ai[0]) == SHPB.SoulType.Night; + + // Increase explosion size with time + int explosionSize = 200 + (int)MathHelper.Clamp(Timer, 0, Lifetime) * (int)Math.Ceiling(15 * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)); + Projectile.ExpandHitboxBy(explosionSize); + + if (Projectile.ai[1] == 0f) { - projTimer -= (Projectile.ai[0] - 180f) / 2f; + Color particleColor = SHPB.FindColorForSoul((int)Projectile.ai[0]); + // Light makes the explosion larger + float sizeScalar = lightSoul ? SHPC.LightExplosionSizeMult : 1f; + + CustomPulse inner = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomCircle", Vector2.One, 0f, 0.4f, 1.5f * sizeScalar, Lifetime); + CustomPulse outer = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0.4f, 2.5f * sizeScalar, Lifetime); + CustomPulse explode = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.026f, 0.26f * sizeScalar, Lifetime); + + GeneralParticleHandler.SpawnParticle(inner); + GeneralParticleHandler.SpawnParticle(outer); + GeneralParticleHandler.SpawnParticle(explode); + + // Night makes the explosion last longer + if (nightSoul) + { + Projectile.timeLeft = (int)(Lifetime * SHPC.NightExplosionTimeMult); + + CustomPulse nightInner = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomCircle", Vector2.One, 0f, 0.4f, 1.5f, (int)(Lifetime * SHPC.NightExplosionTimeMult)); + CustomPulse nightOuter = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0.4f, 2.5f, (int)(Lifetime * SHPC.NightExplosionTimeMult)); + CustomPulse nightExplode = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.026f, 0.26f, (int)(Lifetime * SHPC.NightExplosionTimeMult)); + + GeneralParticleHandler.SpawnParticle(nightInner); + GeneralParticleHandler.SpawnParticle(nightOuter); + GeneralParticleHandler.SpawnParticle(nightExplode); + } + Projectile.ai[1] = 1f; } - if (projTimer <= 0f) + + Timer++; + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + // Might launches enemies + if (SHPB.GetSoulEffects((int)Projectile.ai[0]) == SHPB.SoulType.Might && target.CanBeMoved(false)) { - projTimer = 0f; - Projectile.Kill(); - } - projTimer *= 0.7f; - Projectile.ai[0] += 4f; - int timerCounter = 0; - while ((float)timerCounter < projTimer) - { - float rando1 = (float)Main.rand.Next(-40, 41); - float rando2 = (float)Main.rand.Next(-40, 41); - float rando3 = (float)Main.rand.Next(12, 36); - float randoAdjust = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); - randoAdjust = rando3 / randoAdjust; - rando1 *= randoAdjust; - rando2 *= randoAdjust; - int randomDust = Main.rand.Next(3); - if (randomDust == 0) - { - randomDust = 246; - } - else if (randomDust == 1) - { - randomDust = 73; - } - else - { - randomDust = 187; - } - int EXPLODE = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, randomDust, 0f, 0f, 100, default, 2f); - Main.dust[EXPLODE].noGravity = true; - Main.dust[EXPLODE].position.X = Projectile.Center.X; - Main.dust[EXPLODE].position.Y = Projectile.Center.Y; - Dust expr_149DF_cp_0 = Main.dust[EXPLODE]; - expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); - Dust expr_14A09_cp_0 = Main.dust[EXPLODE]; - expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); - Main.dust[EXPLODE].velocity.X = rando1; - Main.dust[EXPLODE].velocity.Y = rando2; - timerCounter++; + Player owner = Main.player[Projectile.owner]; + Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength - new Vector2(0, 3); + target.velocity = launchVel; } } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // Fright deals extra flat damage + if (SHPB.GetSoulEffects((int)Projectile.ai[0]) == SHPB.SoulType.Fright) + modifiers.SourceDamage.Flat += SHPC.FrightFlatDamage; + } } } diff --git a/Projectiles/Magic/SHPL.cs b/Projectiles/Magic/SHPL.cs index 38f612c3a0..fcc39b155d 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -13,8 +15,6 @@ namespace CalamityMod.Projectiles.Magic Projectile.width = 5; Projectile.height = 5; Projectile.friendly = true; - Projectile.alpha = 255; - Projectile.penetrate = 1; Projectile.extraUpdates = 3; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Magic; @@ -22,54 +22,21 @@ namespace CalamityMod.Projectiles.Magic public override void AI() { - if (Projectile.alpha > 0) - { - Projectile.alpha -= 25; - } - if (Projectile.alpha < 0) - { - Projectile.alpha = 0; - } Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 0.5f, 0.2f, 0.5f); float timerIncr = 3f; - if (Projectile.ai[1] == 0f) - { - Projectile.localAI[0] += timerIncr; - if (Projectile.localAI[0] > 100f) - { - Projectile.localAI[0] = 100f; - } - } - else - { - Projectile.localAI[0] -= timerIncr; - if (Projectile.localAI[0] <= 0f) - { - Projectile.Kill(); - return; - } - } + Projectile.localAI[0] += timerIncr; + if (Projectile.localAI[0] > 100f) + Projectile.localAI[0] = 100f; } - public override Color? GetAlpha(Color lightColor) => new Color(255, Main.DiscoG, 155, Projectile.alpha); + public override Color? GetAlpha(Color lightColor) => SHPB.FindColorForSoul((int)Projectile.ai[0]); public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); public override void OnKill(int timeLeft) { - int dustAmt = Main.rand.Next(3, 7); - for (int d = 0; d < dustAmt; d++) - { - int dustType = Utils.SelectRandom(Main.rand, new int[] - { - 246, - 73, - 187 - }); - int idx = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, dustType, 0f, 0f, 100, default, 2.1f); - Main.dust[idx].velocity *= 2f; - Main.dust[idx].noGravity = true; - } + AltLineParticle line = new(Projectile.Center, -Projectile.velocity.RotatedByRandom(MathHelper.Pi / 6f), false, 20, 1f, SHPB.FindColorForSoul((int)Projectile.ai[0])); + GeneralParticleHandler.SpawnParticle(line); } } } diff --git a/Projectiles/Magic/SHPS.cs b/Projectiles/Magic/SHPS.cs new file mode 100644 index 0000000000..13fbc454d3 --- /dev/null +++ b/Projectiles/Magic/SHPS.cs @@ -0,0 +1,95 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Magic +{ + public class SHPS : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Magic"; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public ref float Timer => ref Projectile.ai[1]; + public ref float State => ref Projectile.ai[2]; // 0 = Idle; 1 = Homing to enemy + public const float HomingRange = 560f; + + public NPC Target; + public float RandomAnglingStrength = 0f; + + public override void SetStaticDefaults() => ProjectileID.Sets.CultistIsResistantTo[Type] = true; + public override void SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 180; + } + + // Can only deal damage after it starts homing + public override bool? CanDamage() => Timer >= 25f; + + public override void AI() + { + Timer++; + + // Randomly changes the strength of idle turning + if (Timer % 30 == 1f) + RandomAnglingStrength = Main.rand.NextFloat(-0.16f, 0.16f); + + // Determine behavior + if (Timer < 25) // Don't try to home at the start + State = 0f; + else + { + float npcDistCheck = HomingRange; + int index = -1; + foreach (NPC n in Main.ActiveNPCs) + { + if (!n.CanBeChasedBy(Projectile)) + continue; + + float currentNPCDist = Vector2.Distance(n.Center, Projectile.Center); + if (currentNPCDist < npcDistCheck) + { + npcDistCheck = currentNPCDist; + index = n.whoAmI; + } + } + + if (index == -1) + State = 0f; + else + { + Target = Main.npc[index]; + State = 1f; + } + } + + // Actual behavior + if (State == 0f) + { + Projectile.extraUpdates = 0; + Projectile.velocity = Projectile.velocity.RotatedBy(RandomAnglingStrength); + } + else if (State == 1f) + { + Projectile.extraUpdates = 1; + float speed = Projectile.velocity.Length(); + Projectile.velocity = Projectile.velocity.ToRotation().AngleTowards(Projectile.SafeDirectionTo(Target.Center).ToRotation(), 0.15f).ToRotationVector2() * speed; + } + + // Appearance + if (Timer % 1 == 0f) + { + SquareParticle trail = new(Projectile.Center, Vector2.Zero, false, 25, 3f, SHPB.FindColorForSoul((int)Projectile.ai[0])); + GeneralParticleHandler.SpawnParticle(trail); + } + SquareParticle mainSpot = new(Projectile.Center, Vector2.Zero, false, 2, 1.4f, Color.White); + GeneralParticleHandler.SpawnParticle(mainSpot); + } + } +} diff --git a/Projectiles/Rogue/DuststormCloud.cs b/Projectiles/Rogue/DuststormCloud.cs index 39820711d9..394602c8c5 100644 --- a/Projectiles/Rogue/DuststormCloud.cs +++ b/Projectiles/Rogue/DuststormCloud.cs @@ -5,10 +5,7 @@ namespace CalamityMod.Projectiles.Rogue public class DuststormCloud : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; - public override void SetStaticDefaults() - { - Main.projFrames[Projectile.type] = 4; - } + public override void SetStaticDefaults() => Main.projFrames[Projectile.type] = 4; public override void SetDefaults() { @@ -16,13 +13,10 @@ namespace CalamityMod.Projectiles.Rogue Projectile.height = 14; Projectile.friendly = true; Projectile.alpha = 255; - Projectile.penetrate = -1; //Would only be used by Sandslasher stealth Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.timeLeft = 600; Projectile.DamageType = DamageClass.Generic; - Projectile.usesIDStaticNPCImmunity = true; //Would only be used by Sandslasher stealth - Projectile.idStaticNPCHitCooldown = 6; //Also only used by Sandslasher stealth } public override void AI() diff --git a/Projectiles/Rogue/SandslasherProj.cs b/Projectiles/Rogue/SandslasherProj.cs deleted file mode 100644 index 804f778f39..0000000000 --- a/Projectiles/Rogue/SandslasherProj.cs +++ /dev/null @@ -1,73 +0,0 @@ -using Microsoft.Xna.Framework; -using Terraria; -using Terraria.ID; -using Terraria.ModLoader; - -namespace CalamityMod.Projectiles.Rogue -{ - public class SandslasherProj : ModProjectile, ILocalizedModType - { - public new string LocalizationCategory => "Projectiles.Rogue"; - public override string Texture => "CalamityMod/Items/Weapons/Rogue/Sandslasher"; - - public override void SetStaticDefaults() - { - ProjectileID.Sets.TrailCacheLength[Projectile.type] = 6; - ProjectileID.Sets.TrailingMode[Projectile.type] = 0; - } - - public override void SetDefaults() - { - Projectile.width = 40; - Projectile.height = 40; - Projectile.friendly = true; - Projectile.ignoreWater = true; - Projectile.penetrate = 3; - Projectile.usesLocalNPCImmunity = true; - Projectile.localNPCHitCooldown = 16; - Projectile.DamageType = RogueDamageClass.Instance; - Projectile.timeLeft = 600; - } - - public override void AI() - { - Projectile.ai[0] += 1f; - Projectile.ai[1] += 1f; - if (Projectile.ai[0] == 3f) - Projectile.tileCollide = true; - if (Projectile.velocity.X < 0f) - { - Projectile.velocity.X -= 0.07f; - if ((Projectile.ai[0] %= 30f) == 0f) - Projectile.damage -= (int)(Projectile.velocity.X * 2f); - } - else if (Projectile.velocity.X > 0f) - { - Projectile.velocity.X += 0.07f; - if ((Projectile.ai[0] %= 30f) == 0f) - Projectile.damage += (int)(Projectile.velocity.X * 2f); - } - Projectile.rotation += 0.1f * Projectile.direction + (Projectile.velocity.X / 85); - if (Projectile.Calamity().stealthStrike && Projectile.ai[1] >= 5f) - { - Vector2 speed = new Vector2(Main.rand.NextFloat(-2f, 2f), Main.rand.NextFloat(-2f, 2f)); - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.position, speed, ModContent.ProjectileType(), (int)(Projectile.damage * 0.4), 0f, Projectile.owner); - Projectile.ai[1] = 0; - } - } - - public override void OnKill(int timeLeft) - { - for (int i = 0; i < 15; i++) - { - Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.UnusedBrown, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, 0, default, 1f); - } - } - - public override bool PreDraw(ref Color lightColor) - { - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); - return false; - } - } -} diff --git a/Projectiles/VanillaProjectileOverrides/RavenMinionAI.cs b/Projectiles/VanillaProjectileOverrides/RavenMinionAI.cs index 8aa29d19d9..61408ff159 100644 --- a/Projectiles/VanillaProjectileOverrides/RavenMinionAI.cs +++ b/Projectiles/VanillaProjectileOverrides/RavenMinionAI.cs @@ -31,8 +31,10 @@ namespace CalamityMod.Projectiles.VanillaProjectileOverrides Player owner = Main.player[proj.owner]; Target = owner.Center.MinionHoming(EnemyDistanceDetection, owner); + var hasTarget = Target is not null; + CheckMinionExistence(proj, owner); - DoAnimation(proj); + DoAnimation(proj, charging: hasTarget); proj.localNPCHitCooldown = 10; proj.friendly = true; @@ -43,7 +45,7 @@ namespace CalamityMod.Projectiles.VanillaProjectileOverrides proj.rotation = MathHelper.ToRadians(proj.velocity.X); proj.MinionAntiClump(0.5f); - if (Target is not null) + if (hasTarget) { Vector2 dashDirection = proj.SafeDirectionTo(Target.Center); @@ -129,12 +131,16 @@ namespace CalamityMod.Projectiles.VanillaProjectileOverrides proj.timeLeft = 2; } - private static void DoAnimation(Projectile proj) + private static void DoAnimation(Projectile proj, bool charging) { proj.frameCounter++; if (proj.frameCounter >= 5) { - proj.frame = (proj.frame + 1) % Main.projFrames[proj.type]; + var maxFrames = Main.projFrames[proj.type] / 2; + proj.frame = (proj.frame + 1) % maxFrames; + + if (charging) proj.frame += maxFrames; + proj.frameCounter = 0; } } diff --git a/Utilities/NPCUtils.cs b/Utilities/NPCUtils.cs index 5fa4f373d1..a5ec20c2dd 100644 --- a/Utilities/NPCUtils.cs +++ b/Utilities/NPCUtils.cs @@ -736,7 +736,7 @@ namespace CalamityMod if (CalamityPlayer.areThereAnyDamnBosses) ignoreKBImmune = false; bool isAPillar = target.type == NPCID.LunarTowerSolar || target.type == NPCID.LunarTowerVortex || target.type == NPCID.LunarTowerNebula || target.type == NPCID.LunarTowerStardust; - if (!isAPillar && !target.boss && target.IsAnEnemy(true, true, false) && (ignoreKBImmune ? true : target.knockBackResist > 0)) + if (!isAPillar && !target.boss && target.IsAnEnemy(true, true, false) && (ignoreKBImmune || target.knockBackResist > 0)) return true; return false; }