Reworked Old Duke's Scales.

This commit is contained in:
Memes authored and Cameron Ewell committed 2023-08-01 20:03:14 -04:00
1 parent 049c9862c7
commit 519bb21655
9 files changed
+181 -36

No files matched your search

-2
View File
@@ -543,7 +543,6 @@ namespace CalamityMod.CalPlayer
public bool voltaicJelly = false;
public bool jellyChargedBattery = false;
public float summonProjCooldown;
public bool oldDukeScales = false;
public bool sandWaifu = false;
public bool sandWaifuVanity = false;
public bool sandBoobWaifu = false;
@@ -1612,7 +1611,6 @@ namespace CalamityMod.CalPlayer
thiefsDime = false;
dynamoStemCells = false;
etherealExtorter = false;
oldDukeScales = false;
blazingCore = false;
voltaicJelly = false;
jellyChargedBattery = false;
-27
View File
@@ -3058,33 +3058,6 @@ namespace CalamityMod.CalPlayer
Player.npcTypeNoAggro[ModContent.NPCType<GammaSlime>()] = true;
}
if (oldDukeScales)
{
Player.buffImmune[ModContent.BuffType<SulphuricPoisoning>()] = true;
Player.buffImmune[BuffID.Poisoned] = true;
Player.buffImmune[BuffID.Venom] = true;
if (Player.statLife <= (int)(Player.statLifeMax2 * 0.75))
{
Player.GetDamage<GenericDamageClass>() += 0.06f;
Player.GetCritChance<GenericDamageClass>() += 3;
}
if (Player.statLife <= (int)(Player.statLifeMax2 * 0.5))
{
Player.GetDamage<GenericDamageClass>() += 0.06f;
Player.GetCritChance<GenericDamageClass>() += 3;
}
if (Player.statLife <= (int)(Player.statLifeMax2 * 0.25))
{
Player.GetDamage<GenericDamageClass>() += 0.06f;
Player.GetCritChance<GenericDamageClass>() += 3;
}
if (Player.lifeRegen < 0)
{
Player.GetDamage<GenericDamageClass>() += 0.1f;
Player.GetCritChance<GenericDamageClass>() += 5;
}
}
if (dArtifact)
Player.GetDamage<GenericDamageClass>() += 0.25f;
+43
View File
@@ -0,0 +1,43 @@
using System;
using CalamityMod.Items.Accessories;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.GameContent;
using Terraria.Localization;
namespace CalamityMod.Cooldowns
{
public class OldDukeScalesFatigue : CooldownHandler
{
public float CompletionPercentage => MathF.Round(100 - instance.Completion * 100);
private bool IsPlayerTired => instance.player.GetModPlayer<OldDukeScalesPlayer>().IsTired;
private float TextXOffset => CompletionPercentage > 99 ? -18 : CompletionPercentage > 9 ? -15 : -12;
private Vector2 TextPosition => new(TextXOffset, 25);
private Color TextColor => IsPlayerTired ? Color.Red : Color.White;
private Color TextBorderColor = Color.Black;
public static new string ID => "OldDukeScalesFatigue";
public override bool CanTickDown => false;
public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}");
public override bool ShouldDisplay => instance.player.GetModPlayer<OldDukeScalesPlayer>().OldDukeScalesOn || IsPlayerTired;
public override string Texture => "CalamityMod/Cooldowns/" + ID;
public override Color CooldownStartColor => IsPlayerTired ? Color.Red : Color.Lerp(Color.Green, Color.Red, instance.Completion);
public override Color CooldownEndColor => IsPlayerTired ? Color.Red : Color.Lerp(Color.Green, Color.Red, instance.Completion);
public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
{
base.DrawExpanded(spriteBatch, position, opacity, scale);
CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, CompletionPercentage.ToString() + "%", position + TextPosition, TextColor, TextBorderColor);
}
public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale)
{
base.DrawCompact(spriteBatch, position, opacity, scale);
CalamityUtils.DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, CompletionPercentage.ToString() + "%", position + TextPosition, TextColor, TextBorderColor);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

+126 -3
View File
@@ -1,6 +1,8 @@
using CalamityMod.CalPlayer;
using CalamityMod.Cooldowns;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Audio;
using Terraria.ModLoader;
namespace CalamityMod.Items.Accessories
@@ -9,6 +11,11 @@ namespace CalamityMod.Items.Accessories
public class OldDukeScales : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Accessories";
public static int RecoverTime = 120;
public static int DashFatigueIncrease = 240;
public static int MaxFatigue = 1200; // This is also the time that it takes the player to recover from the loss of all stamina.
public override void SetDefaults()
{
Item.width = 28;
@@ -20,8 +27,124 @@ namespace CalamityMod.Items.Accessories
public override void UpdateAccessory(Player player, bool hideVisual)
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.oldDukeScales = true;
OldDukeScalesPlayer modPlayer = player.GetModPlayer<OldDukeScalesPlayer>();
modPlayer.OldDukeScalesOn = true;
}
}
public class OldDukeScalesPlayer : ModPlayer
{
public bool OldDukeScalesOn = false;
public bool IsTired = false;
public bool HasBoostedDashFirstFrame = false;
private SoundStyle TiredSound => new SoundStyle("CalamityMod/Sounds/Custom/OldDukeHuff") { PitchVariance = .1f, Volume = .8f };
public int Fatigue = 0;
public int RecoverTimer = 0;
public override void PostUpdateMiscEffects()
{
if (OldDukeScalesOn)
{
// Show the bar if the player doesn't have it.
if (!Player.HasCooldown(OldDukeScalesFatigue.ID))
Player.AddCooldown(OldDukeScalesFatigue.ID, OldDukeScales.MaxFatigue);
if (!IsTired)
{
// +10% DR.
Player.endurance += 0.1f;
// +10% Max Movement Speed.
Player.maxRunSpeed *= 1.1f;
// +10% Max Acceleration.
Player.accRunSpeed *= 1.1f;
// If the player has dashed, increase that dash's velocity,
// the fatigue and sets the time before the fatigue can decrease.
if (Player.dashDelay == -1)
{
if (!HasBoostedDashFirstFrame)
{
RecoverTimer = OldDukeScales.RecoverTime;
Fatigue += OldDukeScales.DashFatigueIncrease;
Player.velocity.X *= 1.25f;
HasBoostedDashFirstFrame = true;
}
}
else
HasBoostedDashFirstFrame = false;
// If the player has reached max fatigue, the player becomes tired.
if (Fatigue >= OldDukeScales.MaxFatigue)
{
SoundEngine.PlaySound(TiredSound, Player.Center);
IsTired = true;
}
}
}
if (IsTired)
{
// -30% Movement Speed.
Player.moveSpeed -= 0.3f;
// If the player dashes, that dash is 50% slower.
if (Player.dashDelay == -1)
{
if (!HasBoostedDashFirstFrame)
{
Player.velocity.X *= 0.5f;
HasBoostedDashFirstFrame = true;
}
}
else
HasBoostedDashFirstFrame = false;
// If the fatigue has worn off, the player is back to normal.
if (Fatigue <= 0)
IsTired = false;
}
//
// This code below the condition for when the accesory is equipped
// is a prevention to not exploit the item and only get the good bonuses.
//
// The cooldown doens't act as a normal cooldown, we use the fatigue as the time left of the cooldown.
if (Player.Calamity().cooldowns.TryGetValue(OldDukeScalesFatigue.ID, out var cooldown))
{
cooldown.timeLeft = Fatigue;
// The cooldown handler doesn't like values higher than 600 frames.
// So we update the duration to a higher value every frame.
cooldown.duration = OldDukeScales.MaxFatigue;
}
// If there's any amount of recovery before decreasing the fatigue, decrease this.
if (RecoverTimer > 0)
RecoverTimer--;
// If the player has recovered, start decreasing the fatigue.
if (Fatigue > 0 && RecoverTimer <= 0)
Fatigue -= Player.StandingStill() ? 2 : 1;
// The fatigue cannot go higher than the max.
if (Fatigue >= OldDukeScales.MaxFatigue)
Fatigue = OldDukeScales.MaxFatigue;
}
public override void ResetEffects()
{
OldDukeScalesOn = false;
}
public override void UpdateDead()
{
Fatigue = 0;
RecoverTimer = 0;
}
}
}
@@ -1170,10 +1170,17 @@ OldDukeScales: {
DisplayName: Old Duke's Scales
Tooltip:
'''
While under the effects of a damaging debuff, you gain 10% increased damage and 5% crit
For every 25% of lost life, you gain 6% increased damage and 3% crit
This will max out at 18% increased damage and 9% crit when under 25% life
Provides immunity to poisoned, venom, and sulphuric poisoning
15% increased damage reduction
10% increased max movement speed and acceleration
25% increased dash velocity and length
Gives you a stamina indicator on the cooldown rack
Using any dash will consume 20% of your stamina
Stamina will gradually recover to 100% after not dashing for 1 second
Stamina recovers faster when you are stationary
If your stamina reaches 0%, you become exhausted
[c/CE0E18:While exhausted, this item's damage reduction and movement bonuses are negated]
[c/CE0E18:Being exhausted reduces movement speed by 30% and dash velocity by 50%]
This debuff lasts until your stamina reaches 100% again
'''
}
@@ -91,6 +91,7 @@ Cooldowns: {
MasterChefShieldDurability: Energy Shield Durability
MasterChefShieldRecharge: Energy Shield Recharge
NebulousCore: Nebulous Core Cooldown
OldDukeScalesFatigue: Stamina
OmegaBlueActive: Abyssal Madness
OmegaBlueCooldown: Abyssal Madness Cooldown
PermafrostConcoction: Permafrost's Concoction Cooldown