From 7edee161b447934345cd2bf2270533ddfe6711fd Mon Sep 17 00:00:00 2001 From: sunny-raindrops Date: Fri, 3 Apr 2026 20:18:45 -0700 Subject: [PATCH] Spam Throw --- Items/Weapons/Rogue/ElephantGun.cs | 57 ++++++++ Items/Weapons/Rogue/ElephantGun.png | Bin 0 -> 450 bytes ...Mods.CalamityMod.Items.Weapons.Rogue.hjson | 10 ++ .../Mods.CalamityMod.Projectiles.Rogue.hjson | 1 + Projectiles/Rogue/ElephantGunThrown.cs | 132 ++++++++++++++++++ 5 files changed, 200 insertions(+) create mode 100644 Items/Weapons/Rogue/ElephantGun.cs create mode 100644 Items/Weapons/Rogue/ElephantGun.png create mode 100644 Projectiles/Rogue/ElephantGunThrown.cs diff --git a/Items/Weapons/Rogue/ElephantGun.cs b/Items/Weapons/Rogue/ElephantGun.cs new file mode 100644 index 0000000000..db85db640b --- /dev/null +++ b/Items/Weapons/Rogue/ElephantGun.cs @@ -0,0 +1,57 @@ +using CalamityMod.Projectiles.Rogue; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Rogue +{ + public class ElephantGun : RogueWeapon + { + public override void SetDefaults() + { + Item.width = 46; + Item.height = 58; + Item.damage = 84; + Item.noMelee = true; + Item.noUseGraphic = true; + Item.useAnimation = Item.useTime = 46; + Item.useStyle = ItemUseStyleID.Swing; + Item.knockBack = 1f; + Item.UseSound = SoundID.Item1; + Item.autoReuse = true; + Item.maxStack = 1; + Item.value = CalamityGlobalItem.RarityLightRedBuyPrice; + Item.rare = ItemRarityID.LightRed; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 3f; + 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 p = Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 1f); + if (p.WithinBounds(Main.maxProjectiles)) + Main.projectile[p].Calamity().stealthStrike = true; + return false; + } + return true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(). + AddIngredient(ItemID.DarkShard). + AddIngredient(ItemID.LightShard). + AddIngredient(ItemID.SoulofLight, 7). + AddIngredient(ItemID.SoulofNight, 7). + AddTile(TileID.Anvils). + Register(); + } + } +} diff --git a/Items/Weapons/Rogue/ElephantGun.png b/Items/Weapons/Rogue/ElephantGun.png new file mode 100644 index 0000000000000000000000000000000000000000..e5b2a6232352eefcb10b42091ff5371eafe12324 GIT binary patch literal 450 zcmV;z0X_bSP)8X1oUy0=d5}r1o zwNbJpWB}QC@(zIC1)b0zd)P0wu4Hr%PTR(m@YY)%ZmF4u82crncBZJjBx_uMg?q zp9N&3g_W^1$Y^U{?|%6Ok6v{8fJYyK&V!UM`(F))dgJhb0x^=PpATK}sT*E1n!(ii zX|&=~H>_q*5dZbmkU@HgpB5PvWVj0qr6 sqJC@7-Sh=Yyqf?mqZv%ynwzzM1$+Q>JZv0h&Hw-a07*qoM6N<$f?qYxYybcN literal 0 HcmV?d00001 diff --git a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson index 79545b4952..92be6318f7 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Weapons.Rogue.hjson @@ -364,6 +364,16 @@ EclipsesFall: { ''' } +ElephantGun: { + DisplayName: Elephant Killer + Tooltip: + ''' + [c/1FFBFF:'My own personal weapon, used to stamp out elephant uprisings.] + [c/1FFBFF:Their souls are forever trapped within this weapon, ready to once again enact revenge.] + [c/1FFBFF:I have backed up the schematics in the event of the original's destruction.'] + ''' +} + EnchantedAxe: { DisplayName: Enchanted Axe Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson index ac3e08848f..6879a97556 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Rogue.hjson @@ -333,3 +333,4 @@ WrathwingFireball.DisplayName: Wrathwing Fireball WrathwingSpear.DisplayName: Wrathwing WulfrumKnifeProj.DisplayName: Wulfrum Knife NanoblackLightspeedCarveSlashVisual.DisplayName: Nanoblack Light-speed Carve Visuals +ElephantGunThrown.DisplayName: Elephant Gun Thrown diff --git a/Projectiles/Rogue/ElephantGunThrown.cs b/Projectiles/Rogue/ElephantGunThrown.cs new file mode 100644 index 0000000000..e977612794 --- /dev/null +++ b/Projectiles/Rogue/ElephantGunThrown.cs @@ -0,0 +1,132 @@ +using System; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.ID; +using Terraria.ModLoader; +using static CalamityMod.CalamityUtils; + +namespace CalamityMod.Projectiles.Rogue +{ + public class ElephantGunThrown : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Rogue"; + public override string Texture => "CalamityMod/Items/Weapons/Rogue/ElephantGun"; + + public static int ChargeupTime = 10; + public static int Lifetime = 500; + public float OverallProgress => 1 - Projectile.timeLeft / (float)Lifetime; + public float ThrowProgress => 1 - Projectile.timeLeft / (float)(Lifetime); + public float ChargeProgress => 1 - (Projectile.timeLeft - Lifetime) / (float)(ChargeupTime); + + public Player Owner => Main.player[Projectile.owner]; + public ref float Returning => ref Projectile.ai[0]; + + public override void SetDefaults() + { + Projectile.width = 46; + Projectile.height = 46; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.penetrate = -1; + Projectile.timeLeft = Lifetime + ChargeupTime; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 10; + Projectile.DamageType = RogueDamageClass.Instance; + } + + public override bool ShouldUpdatePosition() + { + return ChargeProgress >= 1; + } + + public override bool? CanDamage() + { + //We don't want the anticipation to deal damage. + if (ChargeProgress < 1) + return false; + + if (Returning == 1f) + return false; + + return base.CanDamage(); + } + + //Swing animation keys + public CurveSegment pullback = new CurveSegment(EasingType.PolyOut, 0f, 0f, MathHelper.PiOver4 * -1.2f, 2); + public CurveSegment throwout = new CurveSegment(EasingType.PolyOut, 0.7f, MathHelper.PiOver4 * -1.2f, MathHelper.PiOver4 * 1.2f + MathHelper.PiOver2, 3); + internal float ArmAnticipationMovement() => PiecewiseAnimation(ChargeProgress, new CurveSegment[] { pullback, throwout }); + + public override void AI() + { + //Anticipation animation. Make the player look like theyre holding the boomerang + if (ChargeProgress < 1) + { + float armRotation = ArmAnticipationMovement() * Owner.direction; + + Owner.heldProj = Projectile.whoAmI; + + Projectile.Center = Owner.MountedCenter + Vector2.UnitY.RotatedBy(armRotation * Owner.gravDir) * -40f * Owner.gravDir; + Projectile.rotation = (-MathHelper.PiOver2 + armRotation) * Owner.gravDir; + + Owner.SetCompositeArmFront(true, Player.CompositeArmStretchAmount.Full, MathHelper.Pi + armRotation); + + Projectile.tileCollide = false; + return; + } + + Projectile.rotation += 0.4f * Projectile.direction; + + //Play the throw sound when the throw ACTUALLY BEGINS. + //Additionally, make the projectile collide and set its speed and velocity + if (Projectile.timeLeft == Lifetime) + { + SoundEngine.PlaySound(SoundID.DD2_GoblinBomberThrow, Projectile.Center); + Projectile.Center = Owner.MountedCenter + Projectile.velocity * 12f; + Projectile.velocity = Projectile.velocity.SafeNormalize(Vector2.Zero) * 17.5f; + } + + //Boomerang spinny sounds + if (Projectile.soundDelay <= 0) + { + SoundEngine.PlaySound(SoundID.Item7, Projectile.Center); + Projectile.soundDelay = 8; + } + + if (Projectile.velocity.Length() < 2f) + { + Returning = 1f; + Projectile.numHits = 0; + } + + if (Returning == 0f && Projectile.velocity.Length() > 2f && Projectile.timeLeft < (455 + ChargeupTime)) + { + Projectile.velocity *= 0.88f; + } + + if (Returning == 1f && Projectile.velocity.Length() < 20f) + { + Projectile.velocity *= 1.1f; + } + + if (Returning == 1f) + { + //Aim back at the player + Projectile.velocity = Projectile.velocity.Length() * (Owner.MountedCenter - Projectile.Center).SafeNormalize(Vector2.One); + + if ((Projectile.Center - Owner.MountedCenter).Length() < 24f) + { + Projectile.Kill(); + } + } + + } + + public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) + { + Projectile.velocity *= 0.3f; + Returning = 1f; + } + } +}