diff --git a/CalPlayer/DrawLayers/SpringStoolBottom.png b/CalPlayer/DrawLayers/SpringStoolBottom.png new file mode 100644 index 0000000000..9c11a5cf0d Binary files /dev/null and b/CalPlayer/DrawLayers/SpringStoolBottom.png differ diff --git a/CalPlayer/DrawLayers/SpringStoolLayer.cs b/CalPlayer/DrawLayers/SpringStoolLayer.cs new file mode 100644 index 0000000000..5343d50ce5 --- /dev/null +++ b/CalPlayer/DrawLayers/SpringStoolLayer.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.ExtraJumps; +using CalamityMod.Items.Accessories; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; +using static Terraria.ModLoader.PlayerDrawLayer; + +namespace CalamityMod.CalPlayer.DrawLayers +{ + public class SpringStoolLayer : PlayerDrawLayer + { + private Asset stoolTexture; + private Asset springTexture; + private Asset topTexture; + + public override Position GetDefaultPosition() => new BeforeParent(PlayerDrawLayers.Leggings); + + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) + { + // Only draw if the player is holding Up and still + return drawInfo.drawPlayer.GetModPlayer().springStool && + drawInfo.drawPlayer.portableStoolInfo.IsInUse; + } + + protected override void Draw(ref PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + + // Load textures if null + stoolTexture ??= ModContent.Request("CalamityMod/CalPlayer/DrawLayers/SpringStoolBottom"); + springTexture ??= ModContent.Request("CalamityMod/CalPlayer/DrawLayers/SpringStoolSpring"); + topTexture ??= ModContent.Request("CalamityMod/CalPlayer/DrawLayers/SpringStoolTop"); + + Texture2D stoolTex = stoolTexture.Value; + Texture2D springTex = springTexture.Value; + Texture2D topTex = topTexture.Value; + + // Bottom Position + Vector2 bottomPosition = new Vector2( + (int)(drawInfo.Position.X - Main.screenPosition.X + drawPlayer.width / 2f), + (int)(drawInfo.Position.Y - Main.screenPosition.Y + drawPlayer.height + drawPlayer.portableStoolInfo.HeightBoost) + ); + Rectangle bottomSource = stoolTex.Frame(); + Vector2 bottomOrigin = new Vector2(bottomSource.Width / 2f, bottomSource.Height - 2); + + // Spring + Vector2 springPosition = bottomPosition - new Vector2(0, bottomSource.Height); + Rectangle springSource = springTex.Frame(); + Vector2 springOrigin = new Vector2(springSource.Width / 2f, springSource.Height - 2); + + // Top + Vector2 topPosition = springPosition - new Vector2(0, springSource.Height - 5); + Rectangle topSource = topTex.Frame(); + Vector2 topOrigin = new Vector2(topSource.Width / 2f, topSource.Height); + + // Add all to cache + DrawPart(ref drawInfo, stoolTex, bottomPosition, bottomSource, bottomOrigin); + DrawPart(ref drawInfo, springTex, springPosition, springSource, springOrigin); + DrawPart(ref drawInfo, topTex, topPosition, topSource, topOrigin); + } + + private void DrawPart(ref PlayerDrawSet drawInfo, Texture2D tex, Vector2 pos, Rectangle src, Vector2 origin) + { + drawInfo.DrawDataCache.Add(new DrawData(tex, pos, src, drawInfo.colorArmorLegs, drawInfo.drawPlayer.bodyRotation, origin, 1f, drawInfo.playerEffect, 0) + { shader = drawInfo.cPortableStool }); + } + } +} diff --git a/CalPlayer/DrawLayers/SpringStoolSpring.png b/CalPlayer/DrawLayers/SpringStoolSpring.png new file mode 100644 index 0000000000..82271ba49b Binary files /dev/null and b/CalPlayer/DrawLayers/SpringStoolSpring.png differ diff --git a/CalPlayer/DrawLayers/SpringStoolTop.png b/CalPlayer/DrawLayers/SpringStoolTop.png new file mode 100644 index 0000000000..0cdc45e3ef Binary files /dev/null and b/CalPlayer/DrawLayers/SpringStoolTop.png differ diff --git a/CalamityKeybinds.cs b/CalamityKeybinds.cs index 235da907f4..62b5f44039 100644 --- a/CalamityKeybinds.cs +++ b/CalamityKeybinds.cs @@ -18,6 +18,7 @@ namespace CalamityMod public static ModKeybind NormalityRelocatorHotKey { get; private set; } public static ModKeybind RageHotKey { get; private set; } public static ModKeybind SpectralVeilHotKey { get; private set; } + public static ModKeybind SpringStoolJumpHotKey { get; private set; } public static ModKeybind TransformerHotKey { get; private set; } public static ModKeybind SwitchGravityHotkey {get; private set;} public static ModKeybind ExpandDebuffInfo { get; private set; } @@ -40,6 +41,7 @@ namespace CalamityMod NormalityRelocatorHotKey = KeybindLoader.RegisterKeybind(Mod, "NormalityRelocator", "Z"); RageHotKey = KeybindLoader.RegisterKeybind(Mod, "RageMode", "V"); SpectralVeilHotKey = KeybindLoader.RegisterKeybind(Mod, "SpectralVeilTeleport", "Z"); + SpringStoolJumpHotKey = KeybindLoader.RegisterKeybind(Mod, "SpringStoolJumpHotKey", "U"); TransformerHotKey = KeybindLoader.RegisterKeybind(Mod, "TransformerHotKey", "K"); SwitchGravityHotkey = KeybindLoader.RegisterKeybind(Mod, "GravitySwapOverride", "T"); ExpandDebuffInfo = KeybindLoader.RegisterKeybind(Mod, "ExpandDebuffInfo", "LeftControl"); @@ -62,6 +64,7 @@ namespace CalamityMod NormalityRelocatorHotKey = null; RageHotKey = null; SpectralVeilHotKey = null; + SpringStoolJumpHotKey = null; TransformerHotKey = null; ExpandDebuffInfo = null; } diff --git a/Cooldowns/Stooldown.cs b/Cooldowns/Stooldown.cs new file mode 100644 index 0000000000..888044482c --- /dev/null +++ b/Cooldowns/Stooldown.cs @@ -0,0 +1,30 @@ +using System; +using CalamityMod.Items.Accessories; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Cooldowns +{ + public class Stooldown : CooldownHandler + { + public static new string ID => "Stooldown"; + public override bool ShouldDisplay => true; + public override bool CanTickDown => true; + public override void Tick() + { + base.Tick(); + } + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/Stooldown"; + public override Color OutlineColor => Color.SandyBrown; + public override Color CooldownStartColor => Color.Brown; + public override Color CooldownEndColor => Color.Khaki; + + public override SoundStyle? EndSound => new("CalamityMod/Sounds/Item/AscendantOff"); + } +} diff --git a/Cooldowns/Stooldown.png b/Cooldowns/Stooldown.png new file mode 100644 index 0000000000..60913ece69 Binary files /dev/null and b/Cooldowns/Stooldown.png differ diff --git a/Cooldowns/StooldownOutline.png b/Cooldowns/StooldownOutline.png new file mode 100644 index 0000000000..93ce7852e0 Binary files /dev/null and b/Cooldowns/StooldownOutline.png differ diff --git a/Cooldowns/StooldownOverlay.png b/Cooldowns/StooldownOverlay.png new file mode 100644 index 0000000000..e9226d6904 Binary files /dev/null and b/Cooldowns/StooldownOverlay.png differ diff --git a/Items/Accessories/SpringStool.cs b/Items/Accessories/SpringStool.cs new file mode 100644 index 0000000000..e68a6b1687 --- /dev/null +++ b/Items/Accessories/SpringStool.cs @@ -0,0 +1,226 @@ +using System; +using System.Collections.Generic; +using CalamityMod.Cooldowns; +using CalamityMod.Projectiles.Typeless; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.Audio; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.Localization; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class SpringStool : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + public override void ModifyTooltips(List list) => list.IntegrateHotkey(CalamityKeybinds.SpringStoolJumpHotKey); + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((JumpCooldown).FramesToSeconds(), (CritRateBoostAboveTargets)); + + public static int JumpCooldown = CalamityUtils.SecondsToFrames(20); + public static int CritRateBoostAboveTargets = 5; + + public override void SetDefaults() + { + Item.width = 30; + Item.height = 46; + Item.value = CalamityGlobalItem.RarityGreenBuyPrice; + Item.rare = ItemRarityID.Green; + Item.accessory = true; + } + + public override void UpdateAccessory(Player player, bool hideVisual) + { + player.GetModPlayer().springStool = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.PortableStool). + AddRecipeGroup("AnyCopperBar", 3). + AddTile(TileID.Anvils). + Register(); + } + } + + + public class SpringStoolPlayer : ModPlayer + { + public bool springStool = false; + public int springStoolTimer = 0; + public bool hasGroundedSinceJump = true; + + public override void Load() + { + // Hook directly into vanilla's stool drawing + On_PlayerDrawLayers.DrawPlayer_03_PortableStool += HandleStoolStacking; + + // Used to apply the conditional crit chance boost + // Projectiles uses standard tML hooks + On_Player.ProcessHitAgainstNPC += HandleExtraMeleeHitboxCrit; + } + + public override void PostUpdate() + { + bool theCollisionCheck = Collision.TileCollision(Player.position + Vector2.UnitY, Vector2.Zero, Player.width, Player.height, fallThrough: false, fall2: false).Y == 0f; + + if ((Player.velocity.Y == 0 && theCollisionCheck) || Player.grappling[0] >= 0) + hasGroundedSinceJump = true; + } + + public override void PostUpdateEquips() + { + if (CalamityKeybinds.SpringStoolJumpHotKey.JustPressed && springStool && Main.myPlayer == Player.whoAmI && !Player.HasCooldown(Stooldown.ID) && !Player.mount.Active && hasGroundedSinceJump) + { + springStoolTimer = 12; + + Player.AddCooldown(Stooldown.ID, (int)SpringStool.JumpCooldown, true); + hasGroundedSinceJump = false; + + Vector2 spawnPos = Player.Bottom + new Vector2(0f, -60f); + + // Spawn stool with downward and randomly angled force + Projectile.NewProjectile(Player.GetSource_FromThis(), spawnPos, new Vector2(Main.rand.NextFloat(-1f, 1f), 1.2f), ModContent.ProjectileType(), 0, 0f, Player.whoAmI); + SoundEngine.PlaySound(SoundID.Item61 with { Pitch = 0.3f, Volume = 0.7f }, Player.Center); + + if (IsVanillaStoolEquipped(Player)) + { + // Spawn a step stool copy with a random velocity. Only works if step stool is equipped as well as spring stool. + Projectile.NewProjectile(Player.GetSource_FromThis(), spawnPos + new Vector2(0f, -4f), new Vector2(Main.rand.NextBool() ? Main.rand.NextFloat(6f, 7f) : Main.rand.NextFloat(-6f, -7f), Main.rand.NextFloat(-8f, -10f)), ModContent.ProjectileType(), 0, 0f, Player.whoAmI); + } + } + + if (springStool) + { + bool holdingUp = Player.controlUp; + bool standingStill = Player.velocity.Y == 0 && Math.Abs(Player.velocity.X) < 0.1f; + + if (holdingUp && standingStill && !Player.mount.Active) + { + int boost = 61; + if (IsVanillaStoolEquipped(Player)) + boost += 24; + + Player.portableStoolInfo.HasAStool = true; + Player.portableStoolInfo.IsInUse = true; + Player.portableStoolInfo.HeightBoost = boost; + Player.portableStoolInfo.VisualYOffset = boost; + Player.portableStoolInfo.MapYOffset = boost; + + // Forces the player into the stool-standing frame + Player.UpdatePortableStoolUsage(); + } + + else + { + // Ensures the player can use the stool if they stop moving/hold up + Player.portableStoolInfo.HasAStool = true; + } + } + } + + private void HandleStoolStacking(On_PlayerDrawLayers.orig_DrawPlayer_03_PortableStool orig, ref PlayerDrawSet drawInfo) + { + bool isUsingStool = drawInfo.drawPlayer.portableStoolInfo.IsInUse; + var modPlayer = drawInfo.drawPlayer.GetModPlayer(); + bool hasSpring = modPlayer.springStool; + + if (!isUsingStool) + { + orig(ref drawInfo); + return; + } + + if (!hasSpring) + { + orig(ref drawInfo); + return; + } + + if (IsVanillaStoolEquipped(drawInfo.drawPlayer)) + { + orig(ref drawInfo); + return; + } + + return; + } + + private bool IsVanillaStoolEquipped(Player player) + { + for (int k = 3; k <= 12; k++) + { + if (player.armor[k].type == ItemID.PortableStool) + + return true; + } + return false; + } + + public override void PreUpdateMovement() + { + if (springStoolTimer > 0) + { + springStoolTimer--; + + if (Player.whoAmI == Main.myPlayer) + { + float launchPower = 20f * Utils.GetLerpValue(0, 10, springStoolTimer, true); + Player.velocity.Y = -launchPower * Player.gravDir; + + // Prevent vanilla jump logic from interfering + Player.jump = 0; + Player.fallStart = (int)(Player.position.Y / 16f); + } + } + } + + // Adds crit to melee hitboxes + private static void HandleExtraMeleeHitboxCrit(On_Player.orig_ProcessHitAgainstNPC orig, Player self, Item sItem, Rectangle itemRectangle, int originalDamage, float knockback, int npcIndex) + { + bool getBoost = self.GetModPlayer().springStool && self.Top.Y < Main.npc[npcIndex].Top.Y; + if (getBoost) + sItem.crit += SpringStool.CritRateBoostAboveTargets; + + orig(self, sItem, itemRectangle, originalDamage, knockback, npcIndex); + + if (getBoost) + sItem.crit -= SpringStool.CritRateBoostAboveTargets; + } + // Scuffed implementation to add crit to projectiles, using one hook to add it and then a later hook to remove it + // There are two return statements in between these hooks that I would normally be nervous of, however neither actually affect this at all: + // * The first is Electrosphere Launcher's rockets dying on hit, which kills the projectile anyways and can just have a manual check against + // * The second is Abigail's Flower hit cooldown logic, which does nothing since it's a minion that doesn't crit + public override void ModifyHitNPCWithProj(Projectile proj, NPC target, ref NPC.HitModifiers modifiers) + { + if (springStool && proj.type != ProjectileID.ElectrosphereMissile) + { + if (Player.Top.Y < target.Top.Y) + proj.CritChance += SpringStool.CritRateBoostAboveTargets; + } + } + public override void OnHitNPCWithProj(Projectile proj, NPC target, NPC.HitInfo hit, int damageDone) + { + if (springStool && proj.type != ProjectileID.ElectrosphereMissile) + { + if (Player.Top.Y < target.Top.Y) + proj.CritChance -= SpringStool.CritRateBoostAboveTargets; + } + } + + public override void ResetEffects() + { + springStool = false; + springStoolTimer = 0; + } + + public override void UpdateDead() + { + springStool = false; + springStoolTimer = 0; + hasGroundedSinceJump = true; + } + } +} diff --git a/Items/Accessories/SpringStool.png b/Items/Accessories/SpringStool.png new file mode 100644 index 0000000000..1b7c3fd918 Binary files /dev/null and b/Items/Accessories/SpringStool.png differ diff --git a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson index 6aa3b7186e..52d2f71605 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Accessories.hjson @@ -1682,6 +1682,17 @@ SpiritGlyph: { ''' } +SpringStool: { + DisplayName: Spring Stool + Tooltip: + ''' + Hold Up to reach higher + Press [KEY] to jump super high + Super jumps can only be performed once every {0} seconds and after landing + +{1}% critical strike chance when striking enemies below you + ''' +} + StarbusterCore: { DisplayName: Starbuster Core Tooltip: diff --git a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson index 8c950f3fd4..b139893fdb 100644 --- a/Localization/en-US/Mods.CalamityMod.Keybinds.hjson +++ b/Localization/en-US/Mods.CalamityMod.Keybinds.hjson @@ -16,3 +16,4 @@ TransformerHotKey.DisplayName: Transformer Hot Key GravitySwapOverride.DisplayName: Gravity Swap Override ExpandDebuffInfo.DisplayName: See Debuff Information ThePointerLock.DisplayName: The Pointer Lock On +SpringStoolJumpHotKey.DisplayName: Spring Stool Jump Hotkey diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index 77d8aa7a5e..3c03ba6f79 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -135,8 +135,10 @@ SkyFlareFriendly.DisplayName: Flare SlimeStream.DisplayName: Slime Stream SlurperBobber.DisplayName: Slurper Bobber SpiritOriginBullseye.DisplayName: Spirit Origin Bullseye +SpringStoolFX.DisplayName: Spring Stool StandingFire.DisplayName: Flame StarStruckWaterBottle.DisplayName: Bottle +StepStoolBonusFX.DisplayName: Step Stool Bonus StickyFeatherAero.DisplayName: Feather StomperSlam.DisplayName: Stomper Slam SuicideBomberDemon.DisplayName: Demon diff --git a/Localization/en-US/Mods.CalamityMod.UI.hjson b/Localization/en-US/Mods.CalamityMod.UI.hjson index dd4585b266..92531f5615 100644 --- a/Localization/en-US/Mods.CalamityMod.UI.hjson +++ b/Localization/en-US/Mods.CalamityMod.UI.hjson @@ -151,6 +151,7 @@ Cooldowns: { SpongeDurability: Sponge Barrier Durability SpongeRecharge: Sponge Barrier Recharge Starburst: Stratus Starbursts + Stooldown: Stooldown SuperradiantSawBoost: Superradiant Saw Boost TarragonCloak: Tarragon Cloak Cooldown TarragonImmunity: Tarragon Immunity Cooldown diff --git a/Projectiles/Typeless/SpringStoolFX.cs b/Projectiles/Typeless/SpringStoolFX.cs new file mode 100644 index 0000000000..43b814b8a1 --- /dev/null +++ b/Projectiles/Typeless/SpringStoolFX.cs @@ -0,0 +1,140 @@ +using System; +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using rail; +using Terraria; +using Terraria.Audio; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class SpringStoolFX : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + + float rotationFactor = 0.015f; + public static float EaseOutElastic(float x, float amplitude = 1f, float period = 0.3f) + { + if (x == 0f) return 0f; + if (x == 1f) return 1f; + + amplitude = Math.Max(1f, amplitude); + + float s = (float)(period / (2 * Math.PI) * Math.Asin(1f / amplitude)); + + return (float)( + amplitude * + Math.Pow(2, -10f * x) * + Math.Sin((x - s) * (2 * Math.PI) / period) + + 1f + ); + } + + public override void SetStaticDefaults() + { + Main.projFrames[Type] = 5; + } + + public override void SetDefaults() + { + Projectile.width = 78; + Projectile.height = 142; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.friendly = false; + Projectile.penetrate = -1; + Projectile.alpha = 0; + Projectile.timeLeft = 120; + } + + public override void AI() + { + Player player = Main.player[Projectile.owner]; + + if (Projectile.frame < 4) + { + Projectile.frameCounter++; + + if (Projectile.frameCounter >= 4) + { + Projectile.frameCounter = 0; + Projectile.frame++; + + if (Projectile.frame > 4) + { + { + Projectile.frame = 4; // clamp to last frame + } + } + } + } + + float progress = MathHelper.Clamp(Projectile.ai[0] / 70f, 0f, 1f); + + Projectile.ai[1] = EaseOutElastic(progress); + + + Projectile.ai[0]++; + + if (Projectile.ai[0] < 3f) // Stick to bottom of player initially + { + Projectile.Center = player.Bottom + new Vector2(0f, -25f); + } + + else + { + // Begin rotating after initial launch at an increasingly fast rate + rotationFactor *= 1.033f; + Projectile.rotation -= rotationFactor; + } + + if (Projectile.ai[0] == 4f) + { + { + SoundStyle boing = new("CalamityMod/Sounds/Item/Springy"); + SoundEngine.PlaySound(boing with { Volume = 1f, PitchVariance = 0.1f }); + } + } + + if (Projectile.ai[0] == 16) // About when the spring retracts into itself, spawn dusts and sparks + { + for (int k = 0; k < 6; k++) + { + Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool(3) ? 7 : 8); + dust.scale = Main.rand.NextFloat(0.8f, 1.3f); + dust.velocity = new Vector2(8, 2).RotatedByRandom(100) * Main.rand.NextFloat(0.25f, 1.2f); + dust.noGravity = false; + Particle spark = new AltLineParticle(Projectile.Center, new Vector2(8, 8).RotatedByRandom(100) * Main.rand.NextFloat(0.4f, 0.9f), true, 15, 0.8f, Color.Lerp(Color.LightGray, Color.Brown, Main.rand.NextFloat(0.3f, 0.7f)) * 0.75f); + GeneralParticleHandler.SpawnParticle(spark); + } + } + + if (Projectile.ai[0] >= 28f) // Begin fading + { + Projectile.alpha += 10; + Projectile.scale *= 0.98f; + + } + + if (Projectile.alpha >= 255 || !player.active || player.dead) + Projectile.Kill(); + } + + public override bool? CanDamage() => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Type].Value; + int frameHeight = texture.Height / Main.projFrames[Type]; + Rectangle sourceRect = new Rectangle(0, frameHeight * Projectile.frame, texture.Width, frameHeight); + Vector2 drawOrigin = new Vector2(texture.Width * 0.5f, frameHeight * 0.5f); + Vector2 drawPos = Projectile.Center - Main.screenPosition; + + Vector2 scale = new Vector2(Projectile.scale, Projectile.scale * Projectile.ai[1]); + + Main.EntitySpriteDraw(texture, drawPos, sourceRect, Projectile.GetAlpha(lightColor), Projectile.rotation + (Main.player[Projectile.owner].gravDir == -1 ? MathHelper.Pi : 0), drawOrigin, scale, SpriteEffects.None, 0); + return false; + } + } +} diff --git a/Projectiles/Typeless/SpringStoolFX.png b/Projectiles/Typeless/SpringStoolFX.png new file mode 100644 index 0000000000..4d21337bde Binary files /dev/null and b/Projectiles/Typeless/SpringStoolFX.png differ diff --git a/Projectiles/Typeless/StepStoolBonusFX.cs b/Projectiles/Typeless/StepStoolBonusFX.cs new file mode 100644 index 0000000000..6cd1a56d57 --- /dev/null +++ b/Projectiles/Typeless/StepStoolBonusFX.cs @@ -0,0 +1,56 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Typeless +{ + public class StepStoolBonusFX : ModProjectile, ILocalizedModType + { + public new string LocalizationCategory => "Projectiles.Typeless"; + public override string Texture => "Calamitymod/Projectiles/InvisibleProj"; + public float OpacityMultiplier = 1f; + public override void SetDefaults() + { + Projectile.width = 28; + Projectile.height = 28; + + Projectile.tileCollide = true; + Projectile.ignoreWater = true; + Projectile.friendly = false; + Projectile.penetrate = -1; + + Projectile.timeLeft = 100; + Projectile.alpha = 0; + } + + public override void AI() + { + // Gravity! + Projectile.velocity.Y += 0.15f; + + Projectile.rotation += 0.12f; + Projectile.scale -= 0.0125f; + OpacityMultiplier -= 0.025f; + + if (Projectile.timeLeft > 99) + Projectile.alpha = 255; + else + Projectile.alpha = 0; + } + + public override bool? CanDamage() => false; + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = TextureAssets.Extra[102].Value; + Vector2 origin = texture.Size() / 2f; + + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.White * ((1f - (Projectile.alpha / 255f)) * OpacityMultiplier), Projectile.rotation + (Main.player[Projectile.owner].gravDir == -1 ? MathHelper.Pi : 0), origin, Projectile.scale * 1.25f, SpriteEffects.None); + + return false; + } + } +} diff --git a/Sounds/Item/Springy.ogg b/Sounds/Item/Springy.ogg new file mode 100644 index 0000000000..09fa4c4f8d Binary files /dev/null and b/Sounds/Item/Springy.ogg differ