From b91c8b748640b759e767bdeed543ea17e30ba88f Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+ben-tk@users.noreply.github.com> Date: Fri, 14 Jan 2022 18:41:19 -0500 Subject: [PATCH] Seared Pan rework! --- Items/Weapons/Rogue/SearedPan.cs | 33 ++++-- Projectiles/Rogue/NiceCock.cs | 7 ++ Projectiles/Rogue/SearedPanProjectile.cs | 122 ++++++++++++++--------- 3 files changed, 107 insertions(+), 55 deletions(-) diff --git a/Items/Weapons/Rogue/SearedPan.cs b/Items/Weapons/Rogue/SearedPan.cs index fa5be6dd48..353ebb821c 100644 --- a/Items/Weapons/Rogue/SearedPan.cs +++ b/Items/Weapons/Rogue/SearedPan.cs @@ -10,31 +10,32 @@ namespace CalamityMod.Items.Weapons.Rogue { public class SearedPan : RogueWeapon { - // Attacks must be within 48 frames of each other to count as "consecutive" hits + // Attacks must be within 40 frames of each other to count as "consecutive" hits // This is a little less than double the use time - public static int ConsecutiveHitOpening = 48; + public static int ConsecutiveHitOpening = 40; public override void SetStaticDefaults() { DisplayName.SetDefault("Seared Pan"); Tooltip.SetDefault("dAMaGe iS rAthEr cOnSisTeNT\n" + "Fires a frying pan at high velocity\n" + "Enemy hits summon fireballs that linger around the target\n" + - "Landing three consecutive hits grants full stealth\n" + - "Stealth strikes explode into golden sparks, and after hitting an enemy,\n" + - "they cause all fireballs to aggressively home in on their target"); + "Landing three consecutive hits grants will launch a golden pan\n" + + "Golden pans cause all fireballs to aggressively home in on their target\n" + + "Stealth strikes act similar to golden pans but also explode into golden sparks\n" + + "Stealth strikes also summon additional fireballs on hit"); } public override void SafeSetDefaults() { item.width = 60; item.height = 36; - item.damage = 666; + item.damage = 777; item.Calamity().rogue = true; item.knockBack = 10f; item.noMelee = true; item.noUseGraphic = true; item.useStyle = ItemUseStyleID.SwingThrow; - item.useTime = item.useAnimation = 28; + item.useTime = item.useAnimation = 25; item.reuseDelay = 1; item.UseSound = SoundID.Item1; item.autoReuse = true; @@ -47,11 +48,23 @@ namespace CalamityMod.Items.Weapons.Rogue public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { - int pan = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI); - if (player.Calamity().StealthStrikeAvailable() && pan.WithinBounds(Main.maxProjectiles)) + float mode = 1f; + if (player.Calamity().searedPanCounter >= 3) + { + player.Calamity().searedPanCounter = 0; + mode = 2f; + } + if (player.Calamity().StealthStrikeAvailable()) + { + player.Calamity().searedPanCounter = 0; + mode = 3f; + } + int pan = Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, mode); + if (mode > 1f && pan.WithinBounds(Main.maxProjectiles)) { - Main.projectile[pan].Calamity().stealthStrike = true; Main.projectile[pan].extraUpdates++; + if (mode == 3f) + Main.projectile[pan].Calamity().stealthStrike = true; } return false; } diff --git a/Projectiles/Rogue/NiceCock.cs b/Projectiles/Rogue/NiceCock.cs index 529dda0f6c..2f841f3054 100644 --- a/Projectiles/Rogue/NiceCock.cs +++ b/Projectiles/Rogue/NiceCock.cs @@ -11,6 +11,7 @@ namespace CalamityMod.Projectiles.Rogue public class NiceCock : ModProjectile { public bool homing = false; + public int Timer = 0; private bool initialized = false; private Color[] colors = new Color[] { @@ -95,6 +96,12 @@ namespace CalamityMod.Projectiles.Rogue if (Main.npc[index] is null || !Main.npc[index].active || Main.npc[index].life < 0) projectile.Kill(); + // Decrement the timer. This should last a second as stealth strikes will initialize this at 61. + if (Timer > 1) + Timer --; + if (Timer == 1) + homing = true; + NPC target = Main.npc[index]; if (homing) diff --git a/Projectiles/Rogue/SearedPanProjectile.cs b/Projectiles/Rogue/SearedPanProjectile.cs index 3461b4b344..0a5e76f5a2 100644 --- a/Projectiles/Rogue/SearedPanProjectile.cs +++ b/Projectiles/Rogue/SearedPanProjectile.cs @@ -10,6 +10,20 @@ namespace CalamityMod.Projectiles.Rogue { public class SearedPanProjectile : ModProjectile { + internal enum SearedPanTypes + { + VenLocket = 0, + Normal = 1, + Golden = 2, + StealthStrike = 3 + } + + internal SearedPanTypes PanType + { + get => (SearedPanTypes)(int)projectile.ai[0]; + set => projectile.ai[0] = (int)value; + } + public override void SetStaticDefaults() { DisplayName.SetDefault("Pan"); @@ -63,67 +77,51 @@ namespace CalamityMod.Projectiles.Rogue if (!playerCanStealthStrike) return; - // Increment the seared pan counter and refill stealth after three consecutive hits + // Increment the seared pan counter. Pans summoned via the Venerated Locket shouldn't increment the counter. // See CalamityPlayerMiscEffects.cs for code that resets the counter after 40 frames modPlayer.searedPanTimer = 0; - if (!projectile.Calamity().stealthStrike && specialEffects) + if (specialEffects && PanType != SearedPanTypes.VenLocket) modPlayer.searedPanCounter++; - if (modPlayer.searedPanCounter >= 3 && !projectile.Calamity().stealthStrike && specialEffects) - { - modPlayer.searedPanCounter = 0; - modPlayer.rogueStealth = modPlayer.rogueStealthMax; - } - // Stealth strikes spawn four golden sparks on hit - if (projectile.Calamity().stealthStrike) + // Pans summoned via the Venerated Locket have zero special effects + if (PanType == SearedPanTypes.StealthStrike) { modPlayer.searedPanCounter = 0; + // Stealth strikes spawn four golden sparks on hit for (int t = 0; t < 4; t++) { Vector2 velocity = CalamityUtils.RandomVelocity(100f, 70f, 100f); Projectile.NewProjectile(projectile.Center, velocity, ModContent.ProjectileType(), (int)(projectile.damage * 0.2), 0f, projectile.owner); } Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/SearedPanSmash"), (int)projectile.position.X, (int)projectile.position.Y); - // Stealth strikes also cause any fireballs to home in on their targets + // Stealth strikes also cause any existing fireballs to home in on their targets + FireballStuff(true); + + if (!specialEffects) + return; + // Stealth strikes then summon five fireballs to circle the hit enemy, they will home in on their own after a second. + for (int t = 0; t < 5; t++) + { + int i = Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 0f, projectile.owner, 0f, targetIndex); + Main.projectile[i].ModProjectile().Timer = 61; + } + FireballPositions(targetIndex); + } + else if (PanType == SearedPanTypes.Golden) + { + modPlayer.searedPanCounter = 0; + Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/SearedPanSmash"), (int)projectile.position.X, (int)projectile.position.Y); + // Golden pans simply cause all fireballs to home in on their targets FireballStuff(true); } - else if (targetIndex != -1 && health > 0) + else if (PanType == SearedPanTypes.Normal && targetIndex != -1 && health > 0 && specialEffects) { // Summon three fireballs to circle the hit enemy for (int t = 0; t < 3; t++) { Projectile.NewProjectile(projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(projectile.damage * 0.1), 0f, projectile.owner, 0f, targetIndex); } - int fireballCount = 0; - // Count how many fireballs exist already around the given target - for (int i = 0; i < Main.maxProjectiles; i++) - { - // Keep the loop as short as possible - if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) - continue; - if (Main.projectile[i].modProjectile is NiceCock) - { - if (Main.projectile[i].ModProjectile().homing) - continue; - fireballCount++; - } - } - // Adjust the angle of the existing fireballs around a target - float angleVariance = MathHelper.TwoPi / fireballCount; - float angle = 0f; - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) - continue; - if (Main.projectile[i].modProjectile is NiceCock) - { - if (Main.projectile[i].ModProjectile().homing) - continue; - Main.projectile[i].ai[0] = angle; - Main.projectile[i].netUpdate = true; - angle += angleVariance; - } - } + FireballPositions(targetIndex); } } @@ -149,18 +147,52 @@ namespace CalamityMod.Projectiles.Rogue } } + private void FireballPositions(int targetIndex) + { + int fireballCount = 0; + // Count how many fireballs exist already around the given target + for (int i = 0; i < Main.maxProjectiles; i++) + { + // Keep the loop as short as possible + if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) + continue; + if (Main.projectile[i].modProjectile is NiceCock) + { + if (Main.projectile[i].ModProjectile().homing) + continue; + fireballCount++; + } + } + // Adjust the angle of the existing fireballs around a target + float angleVariance = MathHelper.TwoPi / fireballCount; + float angle = 0f; + for (int i = 0; i < Main.maxProjectiles; i++) + { + if (!Main.projectile[i].active || Main.projectile[i].owner != projectile.owner || !Main.projectile[i].Calamity().rogue || targetIndex != (int)Main.projectile[i].ai[1]) + continue; + if (Main.projectile[i].modProjectile is NiceCock) + { + if (Main.projectile[i].ModProjectile().homing) + continue; + Main.projectile[i].ai[0] = angle; + Main.projectile[i].netUpdate = true; + angle += angleVariance; + } + } + } + public override bool OnTileCollide(Vector2 oldVelocity) { - // Kill all fireballs if you miss a stealth strike - if (projectile.Calamity().stealthStrike) + // Kill all fireballs if you miss a stealth strike or golden pan + if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) FireballStuff(false); return true; } public override Color? GetAlpha(Color lightColor) { - // Stealth strikes are golden colored - if (projectile.Calamity().stealthStrike) + // Stealth strikes and golden pans are golden colored + if (PanType == SearedPanTypes.Golden || PanType == SearedPanTypes.StealthStrike) return new Color(255, 222, 0); return null; }