diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 3003008d01..eb2fb927bf 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -8,6 +8,7 @@ using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatBuffs; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.CalPlayer.Dashes; +using CalamityMod.CalPlayer.DrawLayers; using CalamityMod.Cooldowns; using CalamityMod.DataStructures; using CalamityMod.Dusts; @@ -72,6 +73,7 @@ using CalamityMod.Utilities; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -863,6 +865,7 @@ namespace CalamityMod.CalPlayer public bool tesla = false; public bool teslaVisuals = true; public bool cryogenSoul = false; + public bool springStool = false; public bool ascendantInsignia = false; public int ascendantInsigniaBuffTime = 0; public int ascendantInsigniaCooldown = 0; @@ -2411,6 +2414,7 @@ namespace CalamityMod.CalPlayer tesla = false; teslaVisuals = true; cryogenSoul = false; + springStool = false; ascendantInsignia = false; magmaStoneVisuals = true; eGauntlet = false; @@ -4966,6 +4970,37 @@ namespace CalamityMod.CalPlayer Lighting.AddLight(Player.Center, Light * (0.55f + (oceanCrestTimer * 0.0035f))); } + if (springStool) + { + + if (springStool) + { + bool holdingUp = Player.controlUp; + bool standingStill = Player.velocity.Y == 0 && Player.velocity.X == 0; + + if (holdingUp && standingStill && !Player.mount.Active) + { + // Vertical displacement when using Spring Stool + int boost = 61; + + Player.portableStoolInfo.HasAStool = true; + Player.portableStoolInfo.IsInUse = true; + Player.portableStoolInfo.HeightBoost = boost; + Player.portableStoolInfo.VisualYOffset = boost; + Player.portableStoolInfo.MapYOffset = boost; + + Player.UpdatePortableStoolUsage(); + + } + else + { + // Stool still exists even if not being used + Player.portableStoolInfo.HasAStool = true; + } + + } + } + if (rampartOfDeities) { // Ice Barrier buff inherited from Frozen Turtle Shell @@ -5022,6 +5057,8 @@ namespace CalamityMod.CalPlayer public override void PostUpdate() { + Main.NewText(Main.LocalPlayer.Top.Y); + if (ZoneAbyss && Main.netMode != NetmodeID.Server) { //Main aura @@ -6244,6 +6281,20 @@ namespace CalamityMod.CalPlayer GeneralParticleHandler.SpawnParticle(square1); GeneralParticleHandler.SpawnParticle(square2); } + + public override void Load() + { + // Hook into the vanilla stool drawing method to remove it + On_PlayerDrawLayers.DrawPlayer_03_PortableStool += HideStepStool; + } + + private void HideStepStool(On_PlayerDrawLayers.orig_DrawPlayer_03_PortableStool orig, ref PlayerDrawSet drawInfo) + { + if (drawInfo.drawPlayer.GetModPlayer().springStool) + return; + + orig(ref drawInfo); + } #endregion #region Mana Consumption Effects diff --git a/CalPlayer/CalamityPlayerHitHurt.cs b/CalPlayer/CalamityPlayerHitHurt.cs index df6c24e6df..e4b66643bd 100644 --- a/CalPlayer/CalamityPlayerHitHurt.cs +++ b/CalPlayer/CalamityPlayerHitHurt.cs @@ -461,6 +461,25 @@ namespace CalamityMod.CalPlayer #endregion #region Modify Hit NPC + + public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) + { + if (springStool) + { + if (Main.LocalPlayer.Top.Y < target.Top.Y) + { + // Effective +10% crit chance. Increasing crit chance additively through manual rolling is scuffed for crossmod compatability, feel free to improve it if you know a better way + float finalCritChance = Player.GetTotalCritChance(modifiers.DamageType) + 100f; + + if (Main.rand.NextFloat(1f, 101f) <= finalCritChance) + modifiers.SetCrit(); + + else + modifiers.DisableCrit(); + } + } + } + public override void ModifyHitNPCWithItem(Item item, NPC target, ref NPC.HitModifiers modifiers) { modifiers.CritDamage += critDamage; diff --git a/CalPlayer/DrawLayers/SpringStoolLayer.cs b/CalPlayer/DrawLayers/SpringStoolLayer.cs new file mode 100644 index 0000000000..395674947a --- /dev/null +++ b/CalPlayer/DrawLayers/SpringStoolLayer.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.ExtraJumps; +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/ExtraJumps/SpringStoolBottom"); + springTexture ??= ModContent.Request("CalamityMod/ExtraJumps/SpringStoolSpring"); + topTexture ??= ModContent.Request("CalamityMod/ExtraJumps/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/Cooldowns/Stooldown.cs b/Cooldowns/Stooldown.cs new file mode 100644 index 0000000000..3482f788ac --- /dev/null +++ b/Cooldowns/Stooldown.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using Terraria.Audio; +using Terraria.Localization; + +namespace CalamityMod.Cooldowns +{ + public class Stooldown : CooldownHandler + { + public static new string ID => "Stooldown"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/AscendEffect"; + public override Color OutlineColor => new Color(197, 165, 108); + public override Color CooldownStartColor => new Color(144, 84, 29); + 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/ExtraJumps/SpringStoolBottom.png b/ExtraJumps/SpringStoolBottom.png new file mode 100644 index 0000000000..9c11a5cf0d Binary files /dev/null and b/ExtraJumps/SpringStoolBottom.png differ diff --git a/ExtraJumps/SpringStoolJump.cs b/ExtraJumps/SpringStoolJump.cs new file mode 100644 index 0000000000..efdc34dcb9 --- /dev/null +++ b/ExtraJumps/SpringStoolJump.cs @@ -0,0 +1,51 @@ +using CalamityMod.Particles; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using Terraria; +using Terraria.DataStructures; +using Terraria.ModLoader; + +namespace CalamityMod.ExtraJumps +{ + public class SpringStoolJump : ExtraJump + { + public override Position GetDefaultPosition() => BeforeBottleJumps; + public override float GetDurationMultiplier(Player player) => 1f; + public override void UpdateHorizontalSpeeds(Player player) + { + player.runAcceleration *= 2f; + player.maxRunSpeed *= 1.35f; + } + + public override void OnStarted(Player player, ref bool playSound) + { + playSound = true; + if (player.wingsLogic <= 0) + { + player.velocity.Y *= player.slowFall ? 2.0f : 2.75f; + } + else + { + player.velocity.Y *= 1.7f; + } + player.StopExtraJumpInProgress(); + for (int i = 0; i < 3; i++) + { + Vector2 position = player.Center; + Vector2 velocity = (Vector2.UnitY * -(2.5f + 2f * i)) * player.gravDir; + int lifetime = 120; + float scale = MathHelper.Lerp(0.05f, 0.1f, i / 3f); + Color color = new Color(94, 229, 163); + Vector2 stretch = new Vector2(0.5f, 1.5f); + float shrink = -0.3f; + Particle boostRing = new CustomSpark(position, velocity, "CalamityMod/Particles/HighResHollowCircleHardEdgeAlt", false, lifetime, scale, color, stretch, shrinkSpeed: shrink); + GeneralParticleHandler.SpawnParticle(boostRing); + } + } + public override void ShowVisuals(Player player) + { + player.StopExtraJumpInProgress(); + } + } +} diff --git a/ExtraJumps/SpringStoolJump.png b/ExtraJumps/SpringStoolJump.png new file mode 100644 index 0000000000..cbe569b76b Binary files /dev/null and b/ExtraJumps/SpringStoolJump.png differ diff --git a/ExtraJumps/SpringStoolSpring.png b/ExtraJumps/SpringStoolSpring.png new file mode 100644 index 0000000000..ae305c7263 Binary files /dev/null and b/ExtraJumps/SpringStoolSpring.png differ diff --git a/ExtraJumps/SpringStoolTop.png b/ExtraJumps/SpringStoolTop.png new file mode 100644 index 0000000000..0cdc45e3ef Binary files /dev/null and b/ExtraJumps/SpringStoolTop.png differ diff --git a/Items/Accessories/SpringStool.cs b/Items/Accessories/SpringStool.cs new file mode 100644 index 0000000000..d9aad7eaed --- /dev/null +++ b/Items/Accessories/SpringStool.cs @@ -0,0 +1,36 @@ +using CalamityMod.CalPlayer; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Accessories +{ + public class SpringStool : ModItem, ILocalizedModType + { + public new string LocalizationCategory => "Items.Accessories"; + + 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) + { + CalamityPlayer modPlayer = player.Calamity(); + modPlayer.springStool = true; + } + + public override void AddRecipes() + { + CreateRecipe(). + AddIngredient(ItemID.PortableStool). + AddIngredient(ItemID.CopperBar, 3). + AddTile(TileID.Anvils). + Register(); + } + } +} 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