1 - Added Sponge shield, mechanically speaking.
2 - Lunic Corps shield behavior tweaked slightly.
This commit is contained in:
1 parent
fb1df16d79
commit
9c65937f8e
9 files changed
+185
-39
No files matched your search
+18
-14
@@ -388,8 +388,10 @@ namespace CalamityMod.CalPlayer
|
||||
#region Energy Shields
|
||||
public bool HasAnyEnergyShield => roverDrive || lunicCorpsSet || sponge;
|
||||
public bool drawnAnyShieldThisFrame = false;
|
||||
|
||||
|
||||
// TODO -- Some way to show the player their total shield points.
|
||||
public int TotalEnergyShielding => RoverDriveShieldDurability + LunicCorpsShieldDurability + SpongeShieldDurability;
|
||||
|
||||
public int RoverDriveShieldDurability = 0;
|
||||
public int LunicCorpsShieldDurability = 0;
|
||||
public int SpongeShieldDurability = 0;
|
||||
@@ -400,9 +402,12 @@ namespace CalamityMod.CalPlayer
|
||||
// Lunic Corps shield is controlled by its armor set bool
|
||||
// Lunic Corps shield comes from an armor set and its visibility is non optional
|
||||
internal float lunicCorpsShieldPartialRechargeProgress = 0f;
|
||||
internal bool playedLunicCorpsShieldSound = false;
|
||||
|
||||
public bool sponge = false;
|
||||
public bool spongeShieldVisible = false;
|
||||
internal float spongeShieldPartialRechargeProgress = 0f;
|
||||
internal bool playedSpongeShieldSound = false;
|
||||
#endregion
|
||||
|
||||
#region Abyss
|
||||
@@ -5769,8 +5774,7 @@ namespace CalamityMod.CalPlayer
|
||||
if (SpongeShieldDurability <= 0)
|
||||
{
|
||||
SpongeShieldDurability = 0;
|
||||
// TODO -- unique sound for The Sponge
|
||||
SoundEngine.PlaySound(LunicCorpsHelmet.ShieldHurtSound, Player.Center);
|
||||
SoundEngine.PlaySound(TheSponge.ShieldHurtSound, Player.Center);
|
||||
Player.Calamity().GeneralScreenShakePower += anyShieldBroke ? 0.5f : 2f;
|
||||
anyShieldBroke = true;
|
||||
}
|
||||
@@ -5821,10 +5825,12 @@ namespace CalamityMod.CalPlayer
|
||||
if (lunicCorpsSet && cooldowns.TryGetValue(Cooldowns.LunicCorpsShieldDurability.ID, out var masterChefDurabilityCD))
|
||||
masterChefDurabilityCD.timeLeft = LunicCorpsShieldDurability;
|
||||
|
||||
// TODO -- Sponge cooldown...
|
||||
// Update Sponge durability on the cooldown rack.
|
||||
if (sponge && cooldowns.TryGetValue(SpongeDurability.ID, out var spongeDurabilityCD))
|
||||
spongeDurabilityCD.timeLeft = SpongeShieldDurability;
|
||||
}
|
||||
|
||||
// Regardless of whether shields took damage, iterate over all shield regen on ANY hit.
|
||||
// Regardless of whether shields took damage, iterate over and stall all shield regen on ANY hit.
|
||||
// This applies even if you are hit while shields are fully down, or if you unequip any of the relevant items.
|
||||
{
|
||||
// Rover Drive does not recharge while partially full, only when broken.
|
||||
@@ -5832,14 +5838,13 @@ namespace CalamityMod.CalPlayer
|
||||
if (cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var roverDriveRechargeCD))
|
||||
roverDriveRechargeCD.timeLeft = RoverDrive.ShieldRechargeTime;
|
||||
|
||||
// If the Lunic Corps Armor is still recharging, reset its recharge delay to full.
|
||||
if (cooldowns.TryGetValue(LunicCorpsShieldRecharge.ID, out var cd))
|
||||
cd.timeLeft = LunicCorpsHelmet.ShieldRechargeDelay;
|
||||
// If the Lunic Corps Armor is not yet recharging, start its recharge timer.
|
||||
else
|
||||
Player.AddCooldown(Cooldowns.LunicCorpsShieldRecharge.ID, LunicCorpsHelmet.ShieldRechargeDelay, true);
|
||||
// Set the Lunic Corps Armor's recharge delay to full. Override any existing cooldown instance.
|
||||
if (lunicCorpsSet)
|
||||
Player.AddCooldown(LunicCorpsShieldRecharge.ID, LunicCorpsHelmet.ShieldRechargeDelay, true);
|
||||
|
||||
// TODO -- Stop Sponge cooldown
|
||||
// Set The Sponge's recharge delay to full. Override any existing cooldown instance.
|
||||
if (sponge)
|
||||
Player.AddCooldown(SpongeRecharge.ID, TheSponge.ShieldRechargeDelay, true);
|
||||
}
|
||||
|
||||
// Use a "Free Dodge" to cancel the hit if the shields completely absorbed the hit.
|
||||
@@ -5936,9 +5941,8 @@ namespace CalamityMod.CalPlayer
|
||||
}
|
||||
else if (sponge && SpongeShieldDurability > 0)
|
||||
{
|
||||
// TODO -- unique sound for The Sponge
|
||||
modifiers.DisableSound();
|
||||
SoundEngine.PlaySound(LunicCorpsHelmet.ShieldHurtSound, Player.Center);
|
||||
SoundEngine.PlaySound(TheSponge.ShieldHurtSound, Player.Center);
|
||||
hurtSoundTimer = 20;
|
||||
}
|
||||
else if ((profanedCrystal || profanedCrystalForce) && !profanedCrystalHide)
|
||||
|
||||
@@ -3497,21 +3497,28 @@ namespace CalamityMod.CalPlayer
|
||||
// Because later tier shields are brighter, shields are handled from highest tier to lowest tier here.
|
||||
bool shieldAddedLight = false;
|
||||
|
||||
// TODO -- Sponge cooldown management
|
||||
// If The Sponge is not equipped, obliterate its durability cooldown.
|
||||
// The recharge cooldown is intentionally left in place to prevent hot swapping to recharge the shield
|
||||
if (!sponge)
|
||||
{
|
||||
// stuff
|
||||
if (cooldowns.TryGetValue(SpongeDurability.ID, out var cdDurability))
|
||||
cdDurability.timeLeft = 0;
|
||||
|
||||
// As The Sponge's shield can be left in a partially recharged state, this is for safety.
|
||||
// If the player does not have the accessory equipped for even one frame, discharge all shields.
|
||||
SpongeShieldDurability = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SpongeShieldDurability == 0 && true)
|
||||
{
|
||||
// stuff
|
||||
}
|
||||
// If The Sponge's shield is discharged and hasn't started its recharge delay, start that.
|
||||
if (SpongeShieldDurability == 0 && !cooldowns.ContainsKey(SpongeRecharge.ID))
|
||||
Player.AddCooldown(SpongeRecharge.ID, TheSponge.ShieldRechargeDelay);
|
||||
|
||||
if (SpongeShieldDurability > 0 && true)
|
||||
// If the shield has greater than zero durability but that durability is not on the cooldown rack, add it to the cooldown rack.
|
||||
if (SpongeShieldDurability > 0 && !cooldowns.ContainsKey(SpongeDurability.ID))
|
||||
{
|
||||
// stuff
|
||||
var durabilityCooldown = Player.AddCooldown(SpongeDurability.ID, TheSponge.ShieldDurabilityMax);
|
||||
durabilityCooldown.timeLeft = SpongeShieldDurability;
|
||||
}
|
||||
|
||||
// Add light if this shield is currently active
|
||||
@@ -3521,6 +3528,25 @@ namespace CalamityMod.CalPlayer
|
||||
Lighting.AddLight(Player.Center, Color.DeepSkyBlue.ToVector3() * 0.75f);
|
||||
shieldAddedLight = true;
|
||||
}
|
||||
|
||||
// If the shield has greater than zero durability and isn't in its recharge delay, actively replenish shield points.
|
||||
// Play a sound on the first frame this occurs.
|
||||
if (SpongeShieldDurability > 0 && !cooldowns.ContainsKey(SpongeRecharge.ID))
|
||||
{
|
||||
if (!playedSpongeShieldSound)
|
||||
SoundEngine.PlaySound(TheSponge.ActivationSound, Player.Center);
|
||||
playedSpongeShieldSound = true;
|
||||
|
||||
// This number is not an integer, and stores exact per-frame recharge progress.
|
||||
spongeShieldPartialRechargeProgress += TheSponge.ShieldDurabilityMax / (float)TheSponge.TotalShieldRechargeTime;
|
||||
|
||||
// Cast to int to get whole number of shield points recharged this frame.
|
||||
int pointsActuallyRecharged = (int)spongeShieldPartialRechargeProgress;
|
||||
|
||||
// Give those points to the real shield durability. Then remove them from recharge progress.
|
||||
SpongeShieldDurability += pointsActuallyRecharged;
|
||||
spongeShieldPartialRechargeProgress -= pointsActuallyRecharged;
|
||||
}
|
||||
}
|
||||
|
||||
// If the Lunic Corps armor is not equipped, obliterate its durability cooldown.
|
||||
@@ -3529,9 +3555,8 @@ namespace CalamityMod.CalPlayer
|
||||
{
|
||||
if (cooldowns.TryGetValue(Cooldowns.LunicCorpsShieldDurability.ID, out var cdDurability))
|
||||
cdDurability.timeLeft = 0;
|
||||
// if (cooldowns.TryGetValue(MasterChefShieldRecharge.ID, out var cdRecharge)) cdRecharge.timeLeft = 0;
|
||||
|
||||
// As Lunic Corps shields can be left in partially recharged states, this is for safety.
|
||||
// As the Lunic Corps armor's shield can be left in a partially recharged state, this is for safety.
|
||||
// If the player does not have the armor equipped for even one frame, discharge all shields.
|
||||
LunicCorpsShieldDurability = 0;
|
||||
}
|
||||
@@ -3543,20 +3568,21 @@ namespace CalamityMod.CalPlayer
|
||||
if (LunicCorpsShieldDurability == 0 && !cooldowns.ContainsKey(LunicCorpsShieldRecharge.ID))
|
||||
Player.AddCooldown(LunicCorpsShieldRecharge.ID, LunicCorpsHelmet.ShieldRechargeDelay);
|
||||
|
||||
// If the shield has greater than zero durability but that durability is not on the cooldown rack,
|
||||
// add it to the cooldown rack and play a sound of the shield turning on.
|
||||
// If the shield has greater than zero durability but that durability is not on the cooldown rack, add it to the cooldown rack.
|
||||
if (LunicCorpsShieldDurability > 0 && !cooldowns.ContainsKey(Cooldowns.LunicCorpsShieldDurability.ID))
|
||||
{
|
||||
var durabilityCooldown = Player.AddCooldown(Cooldowns.LunicCorpsShieldDurability.ID, LunicCorpsHelmet.ShieldDurabilityMax);
|
||||
durabilityCooldown.timeLeft = LunicCorpsShieldDurability;
|
||||
SoundEngine.PlaySound(LunicCorpsHelmet.ActivationSound, Player.Center);
|
||||
}
|
||||
|
||||
// If the shield has greater than zero durability and isn't in its recharge delay, actively replenish shield points.
|
||||
// Play a sound on the first frame this occurs.
|
||||
if (LunicCorpsShieldDurability > 0 && !cooldowns.ContainsKey(LunicCorpsShieldRecharge.ID))
|
||||
{
|
||||
// TODO -- sound should be played when recharging starts. This requires extra state tracking
|
||||
|
||||
if (!playedLunicCorpsShieldSound)
|
||||
SoundEngine.PlaySound(LunicCorpsHelmet.ActivationSound, Player.Center);
|
||||
playedLunicCorpsShieldSound = true;
|
||||
|
||||
// This number is not an integer, and stores exact per-frame recharge progress.
|
||||
lunicCorpsShieldPartialRechargeProgress += LunicCorpsHelmet.ShieldDurabilityMax / (float)LunicCorpsHelmet.TotalShieldRechargeTime;
|
||||
|
||||
|
||||
@@ -88,14 +88,7 @@ namespace CalamityMod.Cooldowns
|
||||
public override Color OutlineColor => new Color(133, 204, 237);
|
||||
public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
|
||||
public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
|
||||
|
||||
// Lunic Corps shields gain their first point of durability when this cooldown completes.
|
||||
public override void OnCompleted()
|
||||
{
|
||||
CalamityPlayer modPlayer = instance.player.Calamity();
|
||||
if (modPlayer.lunicCorpsSet)
|
||||
modPlayer.LunicCorpsShieldDurability = 1;
|
||||
}
|
||||
public override SoundStyle? EndSound => null;
|
||||
public override SoundStyle? EndSound => LunicCorpsHelmet.ActivationSound;
|
||||
public override void Tick() => instance.player.Calamity().playedLunicCorpsShieldSound = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using CalamityMod.CalPlayer;
|
||||
using CalamityMod.Items.Accessories;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.Localization;
|
||||
using static CalamityMod.CalamityUtils;
|
||||
using static Terraria.ModLoader.ModContent;
|
||||
|
||||
namespace CalamityMod.Cooldowns
|
||||
{
|
||||
public class SpongeDurability : CooldownHandler
|
||||
{
|
||||
private static Color ringColorLerpStart = new Color(82, 203, 222);
|
||||
private static Color ringColorLerpEnd = new Color(113, 178, 222);
|
||||
|
||||
private float AdjustedCompletion => instance.timeLeft / (float)TheSponge.ShieldDurabilityMax;
|
||||
|
||||
public static new string ID => "SpongeDurability";
|
||||
public override bool CanTickDown => !instance.player.Calamity().sponge || instance.timeLeft <= 0;
|
||||
public override bool ShouldDisplay => instance.player.Calamity().sponge;
|
||||
public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}");
|
||||
public override string Texture => "CalamityMod/Cooldowns/SpongeDurability";
|
||||
public override string OutlineTexture => "CalamityMod/Cooldowns/SpongeOutline";
|
||||
public override string OverlayTexture => "CalamityMod/Cooldowns/SpongeOverlay";
|
||||
public override Color OutlineColor => new Color(133, 204, 237);
|
||||
public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
|
||||
public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
|
||||
public override bool SavedWithPlayer => false;
|
||||
public override bool PersistsThroughDeath => false;
|
||||
|
||||
public override void ApplyBarShaders(float opacity)
|
||||
{
|
||||
// Use the adjusted completion
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].Apply();
|
||||
}
|
||||
|
||||
public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
|
||||
{
|
||||
base.DrawExpanded(spriteBatch, position, opacity, scale);
|
||||
|
||||
float Xoffset = instance.timeLeft > 9 ? -10f : -5;
|
||||
DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + new Vector2(Xoffset, 4) * scale, Color.Lerp(ringColorLerpStart, Color.OrangeRed, 1 - instance.Completion), Color.Black, scale);
|
||||
}
|
||||
|
||||
public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
|
||||
{
|
||||
Texture2D sprite = Request<Texture2D>(Texture).Value;
|
||||
Texture2D outline = Request<Texture2D>(OutlineTexture).Value;
|
||||
Texture2D overlay = Request<Texture2D>(OverlayTexture).Value;
|
||||
|
||||
// Draw the outline
|
||||
spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f);
|
||||
|
||||
// Draw the icon
|
||||
spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
|
||||
|
||||
// Draw the small overlay
|
||||
int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion);
|
||||
Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight);
|
||||
spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
|
||||
|
||||
float Xoffset = instance.timeLeft > 9 ? -10f : -5;
|
||||
DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + new Vector2(Xoffset, 4) * scale, Color.Lerp(ringColorLerpStart, Color.OrangeRed, 1 - instance.Completion), Color.Black, scale);
|
||||
}
|
||||
}
|
||||
|
||||
public class SpongeRecharge : CooldownHandler
|
||||
{
|
||||
private static Color ringColorLerpStart = new Color(179, 212, 242);
|
||||
private static Color ringColorLerpEnd = new Color(113, 178, 222);
|
||||
|
||||
public static new string ID => "SpongeRecharge";
|
||||
public override bool ShouldDisplay => true;
|
||||
public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}");
|
||||
public override string Texture => "CalamityMod/Cooldowns/SpongeRecharge";
|
||||
public override bool SavedWithPlayer => false;
|
||||
public override bool PersistsThroughDeath => false;
|
||||
public override Color OutlineColor => new Color(133, 204, 237);
|
||||
public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
|
||||
public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
|
||||
public override SoundStyle? EndSound => TheSponge.ActivationSound;
|
||||
public override void Tick() => instance.player.Calamity().playedSpongeShieldSound = false;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 411 B |
Binary file not shown.
|
After Width: | Height: | Size: 212 B |
Binary file not shown.
|
After Width: | Height: | Size: 177 B |
Binary file not shown.
|
After Width: | Height: | Size: 358 B |
@@ -6,6 +6,7 @@ using CalamityMod.Tiles.Furniture.CraftingStations;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent;
|
||||
using Terraria.ID;
|
||||
@@ -17,8 +18,23 @@ namespace CalamityMod.Items.Accessories
|
||||
public class TheSponge : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Accessories";
|
||||
|
||||
public override string Texture => (DateTime.Now.Month == 4 && DateTime.Now.Day == 1) ? "CalamityMod/Items/Accessories/TheSpongeReal" : "CalamityMod/Items/Accessories/TheSponge";
|
||||
|
||||
// TODO -- Unique sounds for The Sponge
|
||||
public static readonly SoundStyle ShieldHurtSound = new("CalamityMod/Sounds/Custom/RoverDriveHit") { PitchVariance = 0.6f, Volume = 0.6f, MaxInstances = 0 };
|
||||
public static readonly SoundStyle ActivationSound = new("CalamityMod/Sounds/Custom/RoverDriveActivate") { Volume = 0.85f };
|
||||
public static readonly SoundStyle BreakSound = new("CalamityMod/Sounds/Custom/RoverDriveBreak") { Volume = 0.75f };
|
||||
|
||||
public static int ShieldDurabilityMax = 180;
|
||||
public static int ShieldRechargeDelay = CalamityUtils.SecondsToFrames(6);
|
||||
public static int TotalShieldRechargeTime = CalamityUtils.SecondsToFrames(6);
|
||||
|
||||
// While active, The Sponge gives 30 defense and 30% DR
|
||||
public static int ShieldActiveDefense = 30;
|
||||
public static float ShieldActiveDamageReduction = 0.3f;
|
||||
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 30));
|
||||
@@ -27,7 +43,6 @@ namespace CalamityMod.Items.Accessories
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.defense = 20;
|
||||
Item.width = 20;
|
||||
Item.height = 20;
|
||||
Item.value = CalamityGlobalItem.Rarity14BuyPrice;
|
||||
@@ -39,10 +54,22 @@ namespace CalamityMod.Items.Accessories
|
||||
{
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
modPlayer.sponge = true;
|
||||
modPlayer.spongeShieldVisible = !hideVisual;
|
||||
|
||||
if (modPlayer.SpongeShieldDurability > 0)
|
||||
{
|
||||
player.statDefense += ShieldActiveDefense;
|
||||
player.endurance += ShieldActiveDamageReduction;
|
||||
}
|
||||
}
|
||||
|
||||
// In vanity, provides a visual shield but no actual functionality
|
||||
public override void UpdateVanity(Player player) => player.Calamity().spongeShieldVisible = true;
|
||||
|
||||
// Renders the bubble shield over the item in the world.
|
||||
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
|
||||
{
|
||||
// Will not render a shield if the April Fool's sprite is active.
|
||||
if (Texture == "CalamityMod/Items/Accessories/TheSponge")
|
||||
{
|
||||
Texture2D tex = ModContent.Request<Texture2D>("CalamityMod/Items/Accessories/TheSpongeShield").Value;
|
||||
@@ -50,13 +77,16 @@ namespace CalamityMod.Items.Accessories
|
||||
}
|
||||
}
|
||||
|
||||
// TODO -- Is this necessary to block the shield in-inventory on April first?
|
||||
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
||||
{
|
||||
return Texture != "CalamityMod/Items/Accessories/TheSponge";
|
||||
}
|
||||
|
||||
// Renders the bubble shield over the item in a player's inventory.
|
||||
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
||||
{
|
||||
// Will not render a shield if the April Fool's sprite is active.
|
||||
if (Texture == "CalamityMod/Items/Accessories/TheSponge")
|
||||
{
|
||||
float wantedScale = 0.85f;
|
||||
|
||||
Reference in new issue
Block a user