From 9b9a5de2b60594722127f13bcaa2390dac2449cd Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sun, 15 Sep 2024 20:42:58 -0400 Subject: [PATCH 01/15] Start of SHPC work --- Items/CalamityGlobalItem.cs | 8 + Items/Weapons/Magic/SHPC.cs | 185 +++++++++++++++--- ...Mods.CalamityMod.Items.Weapons.Magic.hjson | 6 +- Projectiles/Magic/SHPB.cs | 45 ++--- Projectiles/Magic/SHPExplosion.cs | 63 ++---- Projectiles/Magic/SHPL.cs | 41 +--- 6 files changed, 216 insertions(+), 132 deletions(-) diff --git a/Items/CalamityGlobalItem.cs b/Items/CalamityGlobalItem.cs index 34a8e4f2a8..ace330bbe6 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; diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 2101b2da51..17f6402591 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -1,35 +1,44 @@ -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 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 = 50; + public int storedSoulpower = 0; + public int recoilProgress = 0; + + 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 = 36; Item.DamageType = DamageClass.Magic; Item.mana = 20; - Item.useAnimation = Item.useTime = 7; + Item.useAnimation = Item.useTime = 60; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; Item.knockBack = 3.25f; - Item.UseSound = SoundID.Item92; + Item.UseSound = FireSound; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); Item.shootSpeed = 20f; @@ -42,17 +51,59 @@ namespace CalamityMod.Items.Weapons.Magic public override bool AltFunctionUse(Player player) => true; + public override void OnCreated(ItemCreationContext context) + { + if (context is RecipeItemCreationContext) + storedSoulpower = ShotsPerSoul; + } + + public int FindSoulForAmmo(Player player) + { + if (player.HasItem(ItemID.SoulofLight)) + return ItemID.SoulofLight; + if (player.HasItem(ItemID.SoulofNight)) + return ItemID.SoulofNight; + if (player.HasItem(ItemID.SoulofFlight)) + return ItemID.SoulofFlight; + if (player.HasItem(ItemID.SoulofFright)) + return ItemID.SoulofFright; + if (player.HasItem(ItemID.SoulofSight)) + return ItemID.SoulofSight; + if (player.HasItem(ItemID.SoulofMight)) + return ItemID.SoulofMight; + return -1; + } + public override bool CanUseItem(Player player) { if (player.altFunctionUse == 2) - { Item.UseSound = CommonCalamitySounds.LaserCannonSound; - } else + Item.UseSound = FireSound; + + return storedSoulpower > 0 || FindSoulForAmmo(player) != -1; + } + + public override bool? UseItem(Player player) + { + if (player.altFunctionUse != 2) + storedSoulpower--; + + if (storedSoulpower <= 0) { - Item.UseSound = SoundID.Item92; + bool ammoConsumed = false; + + if (FindSoulForAmmo(player) != -1) + { + player.ConsumeItem(FindSoulForAmmo(player)); + ammoConsumed = true; + } + + if (ammoConsumed) + storedSoulpower = ShotsPerSoul; } - return base.CanUseItem(player); + + return base.UseItem(player); } public override void ModifyManaCost(Player player, ref float reduce, ref float mult) @@ -64,35 +115,84 @@ 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++) + for (int shootAmt = 0; shootAmt < 2; shootAmt++) { - 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(), damage, knockback * 0.5f, player.whoAmI); } 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); 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.RoyalBlue; + Color colorFG = Color.Lerp(Color.DarkGray, Main.DiscoColor, 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 Recoil Stuff + public override void ModifyWeaponDamage(Player player, ref StatModifier damage) { // scaling legendary!!!! @@ -124,8 +224,43 @@ 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 + 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; + } + return clone; + } + + public override void SaveData(TagCompound tag) + { + tag["ammoStored"] = storedSoulpower; + } + + public override void LoadData(TagCompound tag) + { + storedSoulpower = tag.GetInt("ammoStored"); + } + + public override void NetSend(BinaryWriter writer) + { + writer.Write(storedSoulpower); + } + + public override void NetReceive(BinaryReader reader) + { + storedSoulpower = reader.ReadInt32(); + } + #endregion Saving Ammo Amount } } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 993614cc79..1b20e87cd1 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -778,8 +778,10 @@ 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 + Press Right Click to fire energy beams ''' TooltipGFB: It scales again :) } diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index edbdac9ab9..84b0b7bd9a 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -23,49 +23,45 @@ 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; } 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 if (Projectile.localAI[0] == 0f) { Projectile.scale += 0.05f; - if ((double)Projectile.scale > 1.2) - { + if (Projectile.scale > 1.9f) Projectile.localAI[0] = 1f; - } } else { Projectile.scale -= 0.05f; - if ((double)Projectile.scale < 0.8) - { + if (Projectile.scale < 1.5f) Projectile.localAI[0] = 0f; - } } + Projectile.velocity.X *= 0.985f; Projectile.velocity.Y *= 0.985f; - float projX = Projectile.Center.X; - float projY = Projectile.Center.Y; float explodeRange = 250f; bool canExplode = false; foreach (NPC n in Main.ActiveNPCs) @@ -92,26 +88,25 @@ namespace CalamityMod.Projectiles.Magic } } - public override Color? GetAlpha(Color lightColor) - { - return new Color(255, Main.DiscoG, 155, Projectile.alpha); - } + public override Color? GetAlpha(Color lightColor) => new Color(255, Main.DiscoG, 155, Projectile.alpha); public override bool PreDraw(ref Color lightColor) { - 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); + 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; } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item105, Projectile.Center); + if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3.5f) + Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3.5f; + 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, 0f, 0f); } } } diff --git a/Projectiles/Magic/SHPExplosion.cs b/Projectiles/Magic/SHPExplosion.cs index 10f9bacce6..dcc6b0392b 100644 --- a/Projectiles/Magic/SHPExplosion.cs +++ b/Projectiles/Magic/SHPExplosion.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; @@ -18,62 +19,28 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.timeLeft = 60; + Projectile.timeLeft = 20; 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) + + if (Projectile.ai[0] == 0f) { - projTimer -= (Projectile.ai[0] - 180f) / 2f; - } - if (projTimer <= 0f) - { - 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++; + Color particleColor = new(255, Main.DiscoG, 155); + CustomPulse inner = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomCircle", Vector2.One, 0f, 0.4f, 1.5f, 20); + CustomPulse outer = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0.4f, 2.5f, 20); + CustomPulse explode = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.026f, 0.26f, 20); + + GeneralParticleHandler.SpawnParticle(inner); + GeneralParticleHandler.SpawnParticle(outer); + GeneralParticleHandler.SpawnParticle(explode); + Projectile.ai[0] = 1f; } } } diff --git a/Projectiles/Magic/SHPL.cs b/Projectiles/Magic/SHPL.cs index 38f612c3a0..a2d0a99da7 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { @@ -13,8 +14,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,33 +21,11 @@ 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); @@ -63,12 +40,12 @@ namespace CalamityMod.Projectiles.Magic int dustType = Utils.SelectRandom(Main.rand, new int[] { 246, - 73, - 187 + DustID.PinkFairy, + DustID.Flare_Blue }); - 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; + Dust idx = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity / 2f, dustType, Vector2.Zero, 100, default, 2.1f); + idx.velocity *= 2f; + idx.noGravity = true; } } } From 7814684e75ea4c35e850f8bcc3d9a50c95f2722f Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Sun, 15 Sep 2024 23:25:18 -0400 Subject: [PATCH 02/15] More changes: * Color of orbs, explosions, and beams now changes based on soul type loaded * Soul type used for ammo is now the first in the inventory instead of being in a hierarchy * TODO for tomorrow: Extra effects based on soul type --- Items/Weapons/Magic/SHPC.cs | 131 ++++++++++++++---- ...Mods.CalamityMod.Items.Weapons.Magic.hjson | 2 +- Projectiles/Magic/SHPB.cs | 31 ++++- Projectiles/Magic/SHPB.png | Bin 1770 -> 1619 bytes Projectiles/Magic/SHPExplosion.cs | 6 +- Projectiles/Magic/SHPL.cs | 2 +- 6 files changed, 140 insertions(+), 32 deletions(-) diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 17f6402591..98e94b4ae2 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -23,6 +23,7 @@ namespace CalamityMod.Items.Weapons.Magic public const int ShotsPerSoul = 50; public int storedSoulpower = 0; + public int storedSoulType = ItemID.SoulofLight; // Determines bar color and soul effects for projectile public int recoilProgress = 0; public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; @@ -47,6 +48,94 @@ 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 Weapon-Specific Functions + public override Vector2? HoldoutOffset() => new Vector2(-35, -10); public override bool AltFunctionUse(Player player) => true; @@ -57,45 +146,37 @@ namespace CalamityMod.Items.Weapons.Magic storedSoulpower = ShotsPerSoul; } - public int FindSoulForAmmo(Player player) - { - if (player.HasItem(ItemID.SoulofLight)) - return ItemID.SoulofLight; - if (player.HasItem(ItemID.SoulofNight)) - return ItemID.SoulofNight; - if (player.HasItem(ItemID.SoulofFlight)) - return ItemID.SoulofFlight; - if (player.HasItem(ItemID.SoulofFright)) - return ItemID.SoulofFright; - if (player.HasItem(ItemID.SoulofSight)) - return ItemID.SoulofSight; - if (player.HasItem(ItemID.SoulofMight)) - return ItemID.SoulofMight; - return -1; - } - public override bool CanUseItem(Player player) { if (player.altFunctionUse == 2) + { + Item.useTime = 3; + Item.useAnimation = 3 * storedSoulpower; Item.UseSound = CommonCalamitySounds.LaserCannonSound; + } else + { + Item.useTime = Item.useAnimation = 60; Item.UseSound = FireSound; + } - return storedSoulpower > 0 || FindSoulForAmmo(player) != -1; + return storedSoulpower > 0 || (FindSoulForAmmo(player) != -1 && player.altFunctionUse != 2); } public override bool? UseItem(Player player) { - if (player.altFunctionUse != 2) + if (storedSoulpower > 0) storedSoulpower--; - if (storedSoulpower <= 0) + if (storedSoulpower <= 0 && player.altFunctionUse != 2) { bool ammoConsumed = false; if (FindSoulForAmmo(player) != -1) { - player.ConsumeItem(FindSoulForAmmo(player)); + int soulType = FindSoulForAmmo(player); + player.ConsumeItem(soulType); + storedSoulType = soulType; ammoConsumed = true; } @@ -127,13 +208,13 @@ namespace CalamityMod.Items.Weapons.Magic for (int shootAmt = 0; shootAmt < 2; shootAmt++) { 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(), damage, knockback * 0.5f, player.whoAmI); + Projectile.NewProjectile(source, position + new Vector2(0, -10) + velocity * 2.6f, Speed, ModContent.ProjectileType(), (int)(damage * 0.33f), knockback * 0.5f, player.whoAmI, TransferColorToProj()); } return false; } else { - Projectile.NewProjectile(source, position + new Vector2(0, -10) + velocity * 3f, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI); + Projectile.NewProjectile(source, position + new Vector2(0, -10) + velocity * 3f, velocity, ModContent.ProjectileType(), damage, knockback, player.whoAmI, TransferColorToProj()); return false; } } @@ -146,8 +227,8 @@ namespace CalamityMod.Items.Weapons.Magic 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.RoyalBlue; - Color colorFG = Color.Lerp(Color.DarkGray, Main.DiscoColor, storedSoulpower / (float)ShotsPerSoul); + 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); diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 1b20e87cd1..983574783d 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -781,7 +781,7 @@ SHPC: { 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 - Press Right Click to fire energy beams + Press Right Click to discharge all soulpower in the weapon as weak energy beams ''' TooltipGFB: It scales again :) } diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 84b0b7bd9a..56843872b5 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -28,6 +28,33 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; } + public static Color FindColorForSoul(int projai) + { + Color returnColor = new(0, 0, 0); + switch (projai) + { + case 0: + returnColor = new(240, 29, 196); + break; + case 1: + returnColor = new(123, 29, 220); + break; + case 2: + returnColor = new(106, 240, 250); + break; + case 3: + returnColor = new(4, 51, 222); + break; + case 4: + returnColor = new(79, 255, 124); + break; + case 5: + returnColor = new(255, 128, 20); + break; + } + return returnColor; + } + public override void AI() { // Light and fade in @@ -88,7 +115,7 @@ namespace CalamityMod.Projectiles.Magic } } - public override Color? GetAlpha(Color lightColor) => new Color(255, Main.DiscoG, 155, Projectile.alpha); + public override Color? GetAlpha(Color lightColor) => FindColorForSoul((int)Projectile.ai[0]); public override bool PreDraw(ref Color lightColor) { @@ -106,7 +133,7 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.owner == Main.myPlayer) { - Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 1.5f), 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); } } } diff --git a/Projectiles/Magic/SHPB.png b/Projectiles/Magic/SHPB.png index e0b4f68f5405104c766e15355d0bca919769ae85..35c0478ad846853f949afeaa01344fb0db74e57f 100644 GIT binary patch delta 1603 zcmV-J2E6&|4bu#eBYyw^b5ch_0Itp)=>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi z!vFvd!vV){sAK>D1?WjcK~#8N?VU|8ElU)J-8(`^BnUGM#Xv-i@E`nC{{bTrF)+rA zAdwKv?(Mboo3uB3sjBYU$39i-Njhuq!EtmwR(-6h-TR-Z%zs>8U;o#>9Ld(!R`&l> z__vLJJ=t0ZCLSIh^u5K(%8JI^X50wFMlLTeH8MLpI~sGFaUvLeFE1Lw{r!FW>N{4>#P(jr7>T|S>EF@E|HQ(=f`49s->J{Sc?M<&(>NE0N z$c(_66?Cc3h>WxtZGVHOrzgEE>N9eBda73l88^CP2fvqb#2QP6P>hk}ksXX{uEpz< z*g9A}Ib!wW(sJF_lUcG{((>Kb=l4KNbZzj@OQrlA0e^bU4pM8x^%(&nGehfIYy!9u z3(gr}8Gi}^10Xghn0k$X)ZAhE=7NPAVPeOd)bSw}H)3J+YK$8($ZiC1ug2su0g5r= zOd4a$5yr|H@3n}r8wrgoxyBPW!Za;DG6xzX8hP%Od(Ks#5v#=kDw4cL53NsfnW@JJ zOrXUrxHg>1P&4HlVH5N7^BS!^670ZoU5h~u<$tO$f_jbMj0pDgE-o%Kg1x=H_SF~G zDWP2ZBA`AaS65dWv9k*kYykA#xq=xt!dOPY%*>2NHp1sja1JGON{EdBm}!h?Yz&S3 zo$ED{YJy2M!{>mDHxhj#spqGL5_>)j)MG^EM%F&yBvHPR(D|rwb98j1S1k49$ZwJQ z7k^QV5p!hc3L#fRuoBEY*WyntRCf~FGy*I$mJu*?J(Bv#9ybDD2C$*NYj#lG>^Eox zgv@}UbuGqMh#_Ll#DW&LXbfodDoTh{Ggix^#VtZ6fExiJGh8ubVp}|f8v$&DiS2cU z;zk&lVa9C&6l273oS*64qcr2j$X?1?FMlw(d%1eY5tzVE7K61l!&SrFGlBYyunC-m z063$9Iux+>R;=|4&z57&)MJEA;9M3efj9|)Gb+c&#~SEZb^RxK*S~8AU zW62PTG2(NrNy9V(a+~4x$n*2FMy|T}dc-2u2!I)e*X)~{n;KD}w2U++G&W}3$Tw2W z0IqHE(>M8ZjW82?at;(@Wb8L0Eq~no`$uI`YQ=Jip{}LA6-v($D@V}V0PAccf36X^ zlKKRHP@fUNW*Cgb*e|gN?Lo$x0QDLHFvEoAM4&M`^53VL0L2(_9Oq|x_ga8^FCIVo z_Cl%nI1(D+F~{mVQm5i`t=N^K^-W1I_LL3R5h*=|I>?IQGz7hPn31bZX` zS0qy@KSyG7gDv21-+Gb&cC1cLPBdbc?0bkUy>EnbLQKHMPlzeG4i69Y0;xI1xRDT& z3v%)Kt#RQ-Lhwnsahq`?A%FN35T6>#jT;Gp@nYO2fE$syQFngCvsnv_FEZD{d`sY; zmr5~42G4%6HeXy^)R_8AN9!3vv9n&_IU*+H!t)g6{1wh%#ULhPpXd}r`8m?$hUQ3< zEBYQeV%4ic)sR?Ha|4ub1i(zFMvK!vf7%47#|VHK3pR%FBvhFMZakzV>8^jmGRD20 zg&S$fX2gQ$Y!-b@05_5f%vkg_0g5r=Ocqm9{{xN}U=CDs->3ip002ovPDHLkV1nb4 B@)iI9 delta 1755 zcmV<11|<2@4C)P#BYy_5NklPm3Hy7{=dK`?N&#pt2xwFCiB}AtWpa8R2Uy|9g1H zcV9DKoLHG`6nSZ?1JCz<=zYDRPl#xtU@B#@QDpSh=+sVJHZ&z9&5luqws+bm^y2%Y z&M6y3g3E|jJNYUh_iymRraA1%f4`Wr6R1o!ia39DXj$0Wo|y-4@e7aok2|}!)%$vL z<74yS{DEvv5xc=pHO z+ulE9e)oIxVB==g`AkJ}MIPAN%5X^SK9#e!8cBh*7T4>uBh%udh2P~XE?fB9_JfVu z119R}1%E3eM;8St^00r%f-8sd$nIbL%6N}QMk)caQDpVT?2L^>dPeUHR0K>N*AhzD z6RnCUq>B9ls{k08(JEIFkSsqESQa#@A`;*BCbWI^Ch>(3 zE#H%pjUts*W3ng{B!5}U4i8C(dnN}d`(B-KNF>=P;{Cr= zuQ+(j*;f$5b1uk!ZixSf3Vf=1EG6YsLGuJe5(eyzpyDYV0=@mol1D&YnQc zv$sh;9!cdI4J8{z(t8@^7fh@K$VQP$r83O;zLw%m@tt8NbuE`otrb2Vad}h341Y5g z897YssLMtX@4lAmgkWqQUPe8X{7UK>(aKRoDq($DnB#|?5XfiD?|f=BMNJBd7zWI}Lhl(=3-haky6d7GcTuNyEt=nS1TNl}<6)8p&%dmrE#hZ3U_#nr{n8Kh{2PL;G63WTQyB*_=Fk!BE61F=Hjf z*uLJ;6N~2GvWPMJ!5d~?-+9ljE$qC*!<3^)sJBs@b)249CLiXORKzAvqifDAaD9V2wQF~ctLTB&?*(j214mt~bS+4ruk%O%3kAxDN zCy&k3OR`aDD^%2WcB=~MO5e?}m!LB1H)q$fg z&5jYG&Qt?Jm5^(|S;Qhm2Ui?EFo|QvfpQe_#jbXttfe5aYq}9f7$d!p`71JZ-H}@# z4bLQCGgd$GI*42B3OcGeL?VjuYe^+8`Z?&J6qG|QvHG=`$@*F-3x8N2ajF%?Kvl%W zV$D#4_sWzbsfxIO3+OU$YZ>umGDXl{?9;SLfT{>uV6@0+p}$cJQvF&?bQyu) z3cXl+rF}mid6xpHirD)Q*;8`x%=oV^J@Q+wHg-iyNdb!3%+p@`b?M$ge2U#Yv19P! z=Z)8A1>}exB7BYJXjD6X+J3%dB|!d)0I7_I&3|Ca_x8rlh~`T 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); From 06fb87360f586a286898d4337fd73039a7ef3fe1 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Mon, 16 Sep 2024 13:11:39 -0400 Subject: [PATCH 03/15] Little soul guys :D Also made SquareParticle ACTUALLY A SQUARE --- Items/Weapons/Magic/SHPC.cs | 10 +- .../Mods.CalamityMod.Projectiles.Magic.hjson | 1 + Particles/SquareParticle.cs | 3 +- Projectiles/Magic/SHPB.cs | 9 +- Projectiles/Magic/SHPS.cs | 92 +++++++++++++++++++ 5 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 Projectiles/Magic/SHPS.cs diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 98e94b4ae2..3121a9b39c 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -152,7 +152,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.useTime = 3; Item.useAnimation = 3 * storedSoulpower; - Item.UseSound = CommonCalamitySounds.LaserCannonSound; + Item.UseSound = null; } else { @@ -205,11 +205,9 @@ namespace CalamityMod.Items.Weapons.Magic { if (player.altFunctionUse == 2) { - for (int shootAmt = 0; shootAmt < 2; shootAmt++) - { - 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.33f), knockback * 0.5f, player.whoAmI, TransferColorToProj()); - } + SoundEngine.PlaySound(CommonCalamitySounds.ELRFireSound, player.Center); + 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 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/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 56843872b5..735491f06a 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -28,6 +28,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.DamageType = DamageClass.Magic; } + // This is reused for all SHPC projectiles public static Color FindColorForSoul(int projai) { Color returnColor = new(0, 0, 0); @@ -109,9 +110,7 @@ namespace CalamityMod.Projectiles.Magic { explosionTimer--; if (explosionTimer <= 0) - { Projectile.Kill(); - } } } @@ -134,6 +133,12 @@ namespace CalamityMod.Projectiles.Magic if (Projectile.owner == Main.myPlayer) { 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)); + } } } } diff --git a/Projectiles/Magic/SHPS.cs b/Projectiles/Magic/SHPS.cs new file mode 100644 index 0000000000..2a6711719e --- /dev/null +++ b/Projectiles/Magic/SHPS.cs @@ -0,0 +1,92 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Terraria; +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 SetDefaults() + { + Projectile.width = Projectile.height = 10; + Projectile.friendly = true; + Projectile.DamageType = DamageClass.Magic; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.timeLeft = 180; + } + + public override bool? CanDamage() => Timer >= 30f; + + 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 < 30) // Don't try to home for the first half second + 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); + } + } +} From 2e860414a20c0d56e33f3531bf2655804a0474a2 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Mon, 16 Sep 2024 22:18:09 -0400 Subject: [PATCH 04/15] SHPC SHPC SHPC SHPC * Decreased ammo per soul from 50 to 40 * Now saves your soul type in the item * Different souls used now produce different effects: ** Light makes larger explosions ** Night makes explosions last longer ** Flight restores flight time on direct hits ** Might launches enemies ** Sight has homing ** Fright deals extra flat damage * Small balancing changes --- CalPlayer/CalamityPlayer.cs | 2 + CalPlayer/CalamityPlayerMiscEffects.cs | 2 + Items/CalamityGlobalItem.cs | 3 +- Items/Weapons/Magic/SHPC.cs | 22 ++- ...Mods.CalamityMod.Items.Weapons.Magic.hjson | 1 + Projectiles/Magic/SHPB.cs | 144 ++++++++++++++---- Projectiles/Magic/SHPExplosion.cs | 54 ++++++- Projectiles/Magic/SHPL.cs | 18 +-- Projectiles/Magic/SHPS.cs | 7 +- Utilities/NPCUtils.cs | 2 +- 10 files changed, 200 insertions(+), 55 deletions(-) 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 ace330bbe6..e2b70c8f8f 100644 --- a/Items/CalamityGlobalItem.cs +++ b/Items/CalamityGlobalItem.cs @@ -512,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 3121a9b39c..ce9fc3983f 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -21,24 +21,31 @@ namespace CalamityMod.Items.Weapons.Magic public new string LocalizationCategory => "Items.Weapons.Magic"; public static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/AnomalysNanogunMPFBShot"); - public const int ShotsPerSoul = 50; + 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 = 30; // The amount of flight time restored on direct hits with Flight bombs, in frames + public const float MightKnockbackStrength = 8.5f; // The value to multiply the unit vector by when applying velocity to enemies launched by Might bombs + public const float SightHomingRange = 320f; // Range of homing for Sight bombs, in pixels + public const int FrightFlatDamage = 16; + public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; public override void SetDefaults() { Item.width = 124; Item.height = 52; - Item.damage = 36; + Item.damage = 77; Item.DamageType = DamageClass.Magic; Item.mana = 20; Item.useAnimation = Item.useTime = 60; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; - Item.knockBack = 3.25f; + Item.knockBack = 3f; Item.UseSound = FireSound; Item.autoReuse = true; Item.shoot = ModContent.ProjectileType(); @@ -207,7 +214,7 @@ namespace CalamityMod.Items.Weapons.Magic { SoundEngine.PlaySound(CommonCalamitySounds.ELRFireSound, player.Center); 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()); + Projectile.NewProjectile(source, position + new Vector2(0, -10) + velocity * 2.6f, Speed, ModContent.ProjectileType(), (int)(damage * 0.175f), knockback * 0.5f, player.whoAmI, TransferColorToProj()); return false; } else @@ -310,13 +317,14 @@ namespace CalamityMod.Items.Weapons.Magic Register(); } - #region Saving Ammo Amount + #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; } @@ -324,21 +332,25 @@ namespace CalamityMod.Items.Weapons.Magic 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 Saving Ammo Amount } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 983574783d..7d91cdfb2b 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -781,6 +781,7 @@ SHPC: { 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 ''' TooltipGFB: It scales again :) diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 735491f06a..39cc30b040 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; @@ -29,33 +30,62 @@ namespace CalamityMod.Projectiles.Magic } // This is reused for all SHPC projectiles - public static Color FindColorForSoul(int projai) + #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) { - Color returnColor = new(0, 0, 0); switch (projai) { case 0: - returnColor = new(240, 29, 196); - break; + return SoulType.Light; case 1: - returnColor = new(123, 29, 220); - break; + return SoulType.Night; case 2: - returnColor = new(106, 240, 250); - break; + return SoulType.Flight; case 3: - returnColor = new(4, 51, 222); - break; + return SoulType.Might; case 4: - returnColor = new(79, 255, 124); - break; + return SoulType.Sight; case 5: - returnColor = new(255, 128, 20); - break; + return SoulType.Fright; + + default: + return SoulType.Light; } - return returnColor; } + 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 @@ -75,21 +105,50 @@ namespace CalamityMod.Projectiles.Magic } // 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) + if (Projectile.scale > 1.9f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) Projectile.localAI[0] = 1f; } else { Projectile.scale -= 0.05f; - if (Projectile.scale < 1.5f) + if (Projectile.scale < 1.5f * (lightSoul ? SHPC.LightExplosionSizeMult : 1f)) Projectile.localAI[0] = 0f; } - Projectile.velocity.X *= 0.985f; - Projectile.velocity.Y *= 0.985f; + // 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 // Always slow down if not Sight + Projectile.velocity *= 0.9875f; + float explodeRange = 250f; bool canExplode = false; foreach (NPC n in Main.ActiveNPCs) @@ -114,21 +173,40 @@ namespace CalamityMod.Projectiles.Magic } } - public override Color? GetAlpha(Color lightColor) => FindColorForSoul((int)Projectile.ai[0]); - - public override bool PreDraw(ref Color lightColor) + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { - 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; + 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; + target.velocity = launchVel; + } + } + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + // 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); - if (Main.LocalPlayer.Calamity().GeneralScreenShakePower < 3.5f) - Main.LocalPlayer.Calamity().GeneralScreenShakePower = 3.5f; + 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) { @@ -141,5 +219,15 @@ namespace CalamityMod.Projectiles.Magic } } } + + 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/SHPExplosion.cs b/Projectiles/Magic/SHPExplosion.cs index a729bfe52d..2a96e4c68c 100644 --- a/Projectiles/Magic/SHPExplosion.cs +++ b/Projectiles/Magic/SHPExplosion.cs @@ -1,4 +1,5 @@ using System; +using CalamityMod.Items.Weapons.Magic; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; @@ -9,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() { @@ -19,7 +22,7 @@ namespace CalamityMod.Projectiles.Magic Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; - Projectile.timeLeft = 20; + Projectile.timeLeft = Lifetime; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = -1; } @@ -29,19 +32,62 @@ namespace CalamityMod.Projectiles.Magic float lights = Main.rand.NextFloat(0.9f, 1.1f); lights *= Main.essScale; Lighting.AddLight(Projectile.Center, 5f * lights, 1f * lights, 4f * lights); + 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) { Color particleColor = SHPB.FindColorForSoul((int)Projectile.ai[0]); - CustomPulse inner = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomCircle", Vector2.One, 0f, 0.4f, 1.5f, 20); - CustomPulse outer = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0.4f, 2.5f, 20); - CustomPulse explode = new(Projectile.Center, Vector2.Zero, particleColor, "CalamityMod/Particles/PlasmaExplosion", Vector2.One, Main.rand.NextFloat(MathHelper.TwoPi), 0.026f, 0.26f, 20); + // 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; } + + 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)) + { + Player owner = Main.player[Projectile.owner]; + Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength; + 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 c4d5dcd17f..fcc39b155d 100644 --- a/Projectiles/Magic/SHPL.cs +++ b/Projectiles/Magic/SHPL.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; @@ -34,19 +35,8 @@ namespace CalamityMod.Projectiles.Magic 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, - DustID.PinkFairy, - DustID.Flare_Blue - }); - Dust idx = Dust.NewDustPerfect(Projectile.Center - Projectile.velocity / 2f, dustType, Vector2.Zero, 100, default, 2.1f); - idx.velocity *= 2f; - 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 index 2a6711719e..13fbc454d3 100644 --- a/Projectiles/Magic/SHPS.cs +++ b/Projectiles/Magic/SHPS.cs @@ -1,6 +1,7 @@ using CalamityMod.Particles; using Microsoft.Xna.Framework; using Terraria; +using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic @@ -17,6 +18,7 @@ namespace CalamityMod.Projectiles.Magic 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; @@ -27,7 +29,8 @@ namespace CalamityMod.Projectiles.Magic Projectile.timeLeft = 180; } - public override bool? CanDamage() => Timer >= 30f; + // Can only deal damage after it starts homing + public override bool? CanDamage() => Timer >= 25f; public override void AI() { @@ -38,7 +41,7 @@ namespace CalamityMod.Projectiles.Magic RandomAnglingStrength = Main.rand.NextFloat(-0.16f, 0.16f); // Determine behavior - if (Timer < 30) // Don't try to home for the first half second + if (Timer < 25) // Don't try to home at the start State = 0f; else { 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; } From f82921a9f885709fbc95a9bc23adde6566ff4751 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Tue, 17 Sep 2024 01:58:29 -0400 Subject: [PATCH 05/15] Added flavor tooltip --- Items/Weapons/Magic/SHPC.cs | 2 +- .../en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index ce9fc3983f..5bacc1a3ae 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -16,7 +16,7 @@ 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 static readonly SoundStyle FireSound = new("CalamityMod/Sounds/Item/AnomalysNanogunMPFBShot"); diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index 7d91cdfb2b..b664936bd1 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -784,6 +784,13 @@ SHPC: { 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:'Despite the failure of the Soul Mechs project, I did not give up on souls as a form of fueling weapons.] + [c/1FFBFF:The Soul-Howling Powered Cannon was created so they could be used without the Soul affecting the behavior of the product, eliminating the flaw in my previous project.] + [c/1FFBFF:Without volunteers, however, the ammunition was too scarce for it to be reliable. I soon gave up on the project.] + [c/1FFBFF:Now you wield it, alongside its rare fuel. It is a defective product, but perhaps I overlooked potential in it. I would be willing to observe its performance.'] + ''' TooltipGFB: It scales again :) } From 45326775962e9e6530bc30826a57f0ebb738e9ea Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Tue, 17 Sep 2024 20:50:36 -0400 Subject: [PATCH 06/15] 1 - Added revised flavor tooltip 2 - Flight now make the orbs no longer decelerate, but decreased its flight time boost --- Items/Weapons/Magic/SHPC.cs | 4 ++-- .../en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson | 8 ++++---- Projectiles/Magic/SHPB.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 5bacc1a3ae..807ded9a30 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -28,9 +28,9 @@ namespace CalamityMod.Items.Weapons.Magic public const float LightExplosionSizeMult = 1.5f; public const float NightExplosionTimeMult = 2.5f; - public const int FlightDirectHitFlightBoost = 30; // The amount of flight time restored on direct hits with Flight bombs, in frames + public const int FlightDirectHitFlightBoost = 25; // The amount of flight time restored on direct hits with Flight bombs, in frames public const float MightKnockbackStrength = 8.5f; // The value to multiply the unit vector by when applying velocity to enemies launched by Might bombs - public const float SightHomingRange = 320f; // Range of homing for Sight bombs, in pixels + public const float SightHomingRange = 288f; // Range of homing for Sight bombs, in pixels public const int FrightFlatDamage = 16; public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson index b664936bd1..4140009843 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Magic.hjson @@ -786,10 +786,10 @@ SHPC: { ''' LegendaryText: ''' - [c/1FFBFF:'Despite the failure of the Soul Mechs project, I did not give up on souls as a form of fueling weapons.] - [c/1FFBFF:The Soul-Howling Powered Cannon was created so they could be used without the Soul affecting the behavior of the product, eliminating the flaw in my previous project.] - [c/1FFBFF:Without volunteers, however, the ammunition was too scarce for it to be reliable. I soon gave up on the project.] - [c/1FFBFF:Now you wield it, alongside its rare fuel. It is a defective product, but perhaps I overlooked potential in it. I would be willing to observe its performance.'] + [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/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index 39cc30b040..f9c3f8bdc2 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -146,7 +146,7 @@ namespace CalamityMod.Projectiles.Magic else // Slow down over time if not homing Projectile.velocity *= 0.9875f; } - else // Always slow down if not Sight + else if (!(GetSoulEffects((int)Projectile.ai[0]) == SoulType.Flight))// Always slow down if not Flight Projectile.velocity *= 0.9875f; float explodeRange = 250f; From 211260ffbb06918781aa224de1371df4b521deaa Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Thu, 19 Sep 2024 00:27:45 -0400 Subject: [PATCH 07/15] Balance work --- Items/Weapons/Magic/SHPC.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 807ded9a30..0efb121748 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -29,9 +29,9 @@ namespace CalamityMod.Items.Weapons.Magic 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 = 8.5f; // The value to multiply the unit vector by when applying velocity to enemies launched by Might bombs + public const float MightKnockbackStrength = 9f; // 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 = 16; + public const int FrightFlatDamage = 20; public override void SetStaticDefaults() => ItemID.Sets.ItemsThatAllowRepeatedRightClick[Item.type] = true; @@ -39,9 +39,9 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 124; Item.height = 52; - Item.damage = 77; + Item.damage = 93; Item.DamageType = DamageClass.Magic; - Item.mana = 20; + Item.mana = 15; Item.useAnimation = Item.useTime = 60; Item.useStyle = ItemUseStyleID.Shoot; Item.noMelee = true; @@ -141,7 +141,7 @@ namespace CalamityMod.Items.Weapons.Magic } return projai; } - #endregion Weapon-Specific Functions + #endregion public override Vector2? HoldoutOffset() => new Vector2(-35, -10); @@ -213,8 +213,11 @@ namespace CalamityMod.Items.Weapons.Magic if (player.altFunctionUse == 2) { SoundEngine.PlaySound(CommonCalamitySounds.ELRFireSound, player.Center); - 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.175f), knockback * 0.5f, player.whoAmI, TransferColorToProj()); + if (storedSoulpower % 2 == 0) + { + 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 @@ -277,7 +280,7 @@ namespace CalamityMod.Items.Weapons.Magic player.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, rotation); } - #endregion Recoil Stuff + #endregion public override void ModifyWeaponDamage(Player player, ref StatModifier damage) { @@ -352,6 +355,6 @@ namespace CalamityMod.Items.Weapons.Magic storedSoulpower = reader.ReadInt32(); storedSoulType = reader.ReadInt32(); } - #endregion Saving Ammo Amount + #endregion } } From 237b67634850b68066de918b4f3fd504a99c29b0 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Thu, 19 Sep 2024 11:05:32 -0400 Subject: [PATCH 08/15] Might knockback now gives some extra vertical velocity, so that it can actually launch stuff on the same level as the player --- Items/Weapons/Magic/SHPC.cs | 4 ++-- Projectiles/Magic/SHPB.cs | 2 +- Projectiles/Magic/SHPExplosion.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Items/Weapons/Magic/SHPC.cs b/Items/Weapons/Magic/SHPC.cs index 0efb121748..05cc5a813e 100644 --- a/Items/Weapons/Magic/SHPC.cs +++ b/Items/Weapons/Magic/SHPC.cs @@ -29,7 +29,7 @@ namespace CalamityMod.Items.Weapons.Magic 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 = 9f; // The value to multiply the unit vector by when applying velocity to enemies launched by Might bombs + 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; @@ -39,7 +39,7 @@ namespace CalamityMod.Items.Weapons.Magic { Item.width = 124; Item.height = 52; - Item.damage = 93; + Item.damage = 94; Item.DamageType = DamageClass.Magic; Item.mana = 15; Item.useAnimation = Item.useTime = 60; diff --git a/Projectiles/Magic/SHPB.cs b/Projectiles/Magic/SHPB.cs index f9c3f8bdc2..6760d73471 100644 --- a/Projectiles/Magic/SHPB.cs +++ b/Projectiles/Magic/SHPB.cs @@ -189,7 +189,7 @@ namespace CalamityMod.Projectiles.Magic // 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; + Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength - new Vector2(0, 3); target.velocity = launchVel; } } diff --git a/Projectiles/Magic/SHPExplosion.cs b/Projectiles/Magic/SHPExplosion.cs index 2a96e4c68c..497771e89b 100644 --- a/Projectiles/Magic/SHPExplosion.cs +++ b/Projectiles/Magic/SHPExplosion.cs @@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Magic if (SHPB.GetSoulEffects((int)Projectile.ai[0]) == SHPB.SoulType.Might && target.CanBeMoved(false)) { Player owner = Main.player[Projectile.owner]; - Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength; + Vector2 launchVel = (owner.Calamity().mouseWorld - owner.Center).SafeNormalize(Vector2.UnitY) * SHPC.MightKnockbackStrength - new Vector2(0, 3); target.velocity = launchVel; } } From 3dc542847ed4cea248c95800b252d0f258a6141f Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Thu, 19 Sep 2024 19:30:11 -0500 Subject: [PATCH 09/15] Slime God Core aggro scale. --- NPCs/SlimeGod/SlimeGodCore.cs | 88 +++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 29 deletions(-) diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 9bc6bf6fd2..6ea090ff09 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -220,6 +220,22 @@ 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 + 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 < 3) + aggressionLevel = 3; + else if (splitPaladinCount < 4) + aggressionLevel = 2; + } + // Enrage based on large slimes bool purpleSlimeAlive = false; bool redSlimeAlive = false; @@ -502,11 +518,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; + divisor -= (aggressionLevel - 1) * 20f; if (phase2) - divisor /= 2; + divisor *= 0.5f; if (calamityGlobalNPC.newAI[2] % divisor == 0f) { @@ -515,7 +532,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 +540,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,6 +557,7 @@ namespace CalamityMod.NPCs.SlimeGod buffedSlime = 0; float flySpeed = death ? 15f : revenge ? 13.5f : expertMode ? 12f : 9f; + flySpeed += aggressionLevel; if (phase2) flySpeed *= 1.25f; if (bossRush) @@ -548,46 +566,58 @@ namespace CalamityMod.NPCs.SlimeGod flySpeed *= 1.25f; Vector2 flyDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - Vector2 flyDestination = GetFlyDestination(player); + Vector2 flyDestination = GetFlyDestination(player, aggressionLevel == 3); 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; } - public Vector2 GetFlyDestination(Player target) + public Vector2 GetFlyDestination(Player target, bool targetPlayer) { // Find all large slimes in the world. // If multiple slimes are present, and they are all relatively close together, try to stay in their general area. @@ -617,7 +647,7 @@ namespace CalamityMod.NPCs.SlimeGod } // If no slimes were found, don't bother doing any more calculations. Just use the player's center. - if (largeSlimes.Count <= 0) + if (largeSlimes.Count <= 0 || targetPlayer) return target.Center; // Find the closest slime. From 6c45fd11891f818955315ea010f0c1ec8ad91aa7 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Thu, 19 Sep 2024 19:43:56 -0500 Subject: [PATCH 10/15] Aggression level 4 --- NPCs/SlimeGod/SlimeGodCore.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 6ea090ff09..166171421c 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -225,12 +225,15 @@ namespace CalamityMod.NPCs.SlimeGod // 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 < 3) + if (splitPaladinCount < 2) + aggressionLevel = 4; + else if (splitPaladinCount < 3) aggressionLevel = 3; else if (splitPaladinCount < 4) aggressionLevel = 2; @@ -434,7 +437,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; @@ -520,9 +523,9 @@ namespace CalamityMod.NPCs.SlimeGod if (expertMode && aggressionLevel >= 1) { - float divisor = bossRush ? 90f : death ? 180f : revenge ? 240f : 300f; - divisor -= (aggressionLevel - 1) * 20f; - if (phase2) + 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) @@ -558,12 +561,14 @@ namespace CalamityMod.NPCs.SlimeGod 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, aggressionLevel == 3); From cae76e6d3f726cecfa0776ea0d05f9000f67ca73 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <142704082+CongratsIsTrash@users.noreply.github.com> Date: Thu, 19 Sep 2024 22:22:24 -0400 Subject: [PATCH 11/15] Removed Destroyer's resist to SHPC --- Balancing/BalancingChangesManager.cs | 3 --- 1 file changed, 3 deletions(-) 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 From bb0bdec6cf71e877acd20fd8435beb6b310dd8a3 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Thu, 19 Sep 2024 22:17:35 -0500 Subject: [PATCH 12/15] Fixed a Slime God Core issue. --- NPCs/SlimeGod/SlimeGodCore.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 166171421c..44a4b7a25f 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -571,7 +571,7 @@ namespace CalamityMod.NPCs.SlimeGod flySpeed *= 1.3f; Vector2 flyDirection = new Vector2(NPC.Center.X + (NPC.direction * 20), NPC.Center.Y + 6f); - Vector2 flyDestination = GetFlyDestination(player, aggressionLevel == 3); + Vector2 flyDestination = aggressionLevel >= 3 ? player.Center : GetFlyDestination(player); Vector2 idealVelocity = (flyDestination - flyDirection).SafeNormalize(Vector2.UnitY) * flySpeed; float distanceFromFlyDestination = NPC.Distance(flyDestination); @@ -622,7 +622,7 @@ namespace CalamityMod.NPCs.SlimeGod NPC.rotation = NPC.velocity.X * 0.05f; } - public Vector2 GetFlyDestination(Player target, bool targetPlayer) + public Vector2 GetFlyDestination(Player target) { // Find all large slimes in the world. // If multiple slimes are present, and they are all relatively close together, try to stay in their general area. @@ -652,7 +652,7 @@ namespace CalamityMod.NPCs.SlimeGod } // If no slimes were found, don't bother doing any more calculations. Just use the player's center. - if (largeSlimes.Count <= 0 || targetPlayer) + if (largeSlimes.Count <= 0) return target.Center; // Find the closest slime. From a6756b460360d354258326a2b28c31504a78f935 Mon Sep 17 00:00:00 2001 From: Flowaria Date: Fri, 20 Sep 2024 12:34:35 +0900 Subject: [PATCH 13/15] Fixed Raven Minion Idle Animation Issue --- .../VanillaProjectileOverrides/RavenMinionAI.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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; } } From 975a255e634b03186c0e6cc61bacf4896c863ff7 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Fri, 20 Sep 2024 01:10:11 -0500 Subject: [PATCH 14/15] Hopefully fixes the Slime God Core transparency issue if it begins despawning right after the Paladin it was inhabiting is killed. --- NPCs/SlimeGod/SlimeGodCore.cs | 46 +++-------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/NPCs/SlimeGod/SlimeGodCore.cs b/NPCs/SlimeGod/SlimeGodCore.cs index 44a4b7a25f..423ba2c852 100644 --- a/NPCs/SlimeGod/SlimeGodCore.cs +++ b/NPCs/SlimeGod/SlimeGodCore.cs @@ -240,46 +240,8 @@ namespace CalamityMod.NPCs.SlimeGod } // 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; @@ -700,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; @@ -763,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); From 40515ad75be275644fdc9ee1f5d3e359235206c7 Mon Sep 17 00:00:00 2001 From: CongratsIsTrash <1q2w3e4dasd@gmail.com> Date: Fri, 20 Sep 2024 10:31:22 -0400 Subject: [PATCH 15/15] Removed Sandslasher --- Items/Weapons/Rogue/Sandslasher.cs | 56 -------------- Items/Weapons/Rogue/Sandslasher.png | Bin 1026 -> 0 bytes ...Mods.CalamityMod.Items.Weapons.Rogue.hjson | 10 --- .../Mods.CalamityMod.Projectiles.Rogue.hjson | 1 - Projectiles/Rogue/DuststormCloud.cs | 8 +- Projectiles/Rogue/SandslasherProj.cs | 73 ------------------ 6 files changed, 1 insertion(+), 147 deletions(-) delete mode 100644 Items/Weapons/Rogue/Sandslasher.cs delete mode 100644 Items/Weapons/Rogue/Sandslasher.png delete mode 100644 Projectiles/Rogue/SandslasherProj.cs 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 bee752768046d6d4cf128efcbc38cd89640519ad..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1026 zcmV+d1pWJoP)Yiu_}X2(Z-fca;S0hn3b z0YG<`A-X5s1Vob?%*_CB?&@^_4rcaw0QsrfiqBE~1Odz2I=4Lc0LCUNlS_Zo13>Od zF94a%tALQ4bm7e3*0}%S|Csw`0Z6sBc>p*1Zvim*^hw1Bj0Hg;^tx|P|LjBfh6RV5 zbZq}80DS#r$~rHv6xo4S#x}hcb3I8H0ELOH575}&VFKv5S?7|B4?*eFSBC*OclEjt zklbqCxN&y^fZ4l606yB*2!vkQmwjCE51Mu+to72yyJ-M&S9+Hv86Sdf+)8E*Ij^O~ zIzKa13>KJ!OHQ^Ybq?PKU?5m0qEbmzP&DyMug8a=B$AoU1po$Kne(!}{WXTzol$$8 z>$Q^RpXe}gkeB1Z`dI+34cxTmE5{Q%8&s}zZBYamuI#0<(La*k0kCk?e&_nWYXJ0T zhk!6=yYW+*M%7XChbG5YJwdPM^Dh8cv#{txbY_sEZ0-JE-&^C2-6lRJpZo^E+`S>| zx-ysK#?wTD=Rq6@9?cvApg8CIP+r$bF3E;nI{_Hma0Gz=`t12T4qUXxvSrztc9o|#3{TgcXAldg@3;86E5>xOl|n!wpSdKoB*0&ma{XFmnPXreDx z^#oU|_vmch286xFnB9CWRWGv9JEM6s|KcTU-jc0N2e#(q=KS`(K$z2A!eJba3qk!5 zIZ0JUJ{ap5zB$3sUgvtL$p1KENT!0iQ1{XNs7w|gf|4p*)n_89ide^dP~E8BbIHk8 zCASXrr>B9i%Nxwu^QHI@Tuk-o&l2-B*mt3~X-)!n)G!kJSVHls>-P?W<2- z)CKLyq*~hmDEvEVk#u_xw+a$DRm|>=guc*h@Wl>h_5qNes "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; - } - } -}