Oddly-shaped rover drive

This commit is contained in:
IbanPlay authored and Cameron Ewell committed 2022-07-11 19:05:37 -04:00
1 parent 7fdc3cbb0d
commit b2973aa53a
8 files changed
+202 -7

No files matched your search

+7 -1
View File
@@ -5862,7 +5862,13 @@ namespace CalamityMod.CalPlayer
#region Custom Hurt Sounds
if (hurtSoundTimer == 0)
{
if ((profanedCrystal || profanedCrystalForce) && !profanedCrystalHide)
if (Player.GetModPlayer<RoverDrivePlayer>().ProtectionMatrixDurability > 0)
{
playSound = false;
SoundEngine.PlaySound(RoverDrive.ShieldHurtSound, Player.position);
hurtSoundTimer = 20;
}
else if ((profanedCrystal || profanedCrystalForce) && !profanedCrystalHide)
{
playSound = false;
SoundEngine.PlaySound(Providence.DeathSound, Player.position);
+1
View File
@@ -25,6 +25,7 @@ namespace CalamityMod.Cooldowns
public override Color CooldownStartColor => PowerActive ? Color.Lerp(new Color(112, 244, 244), new Color(54, 177, 221), DurabilityPercent) : new Color(92, 187, 99);
public override Color CooldownEndColor => PowerActive ? Color.Lerp(new Color(112, 244, 244), new Color(54, 177, 221), DurabilityPercent) : new Color(160, 232, 77);
public override SoundStyle? EndSound => new("CalamityMod/Sounds/Custom/AbilitySounds/WulfrumBastionRecharge");
//public override bool SavedWithPlayer => false;
public override void OnCompleted()
{
+82
View File
@@ -0,0 +1,82 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.GameContent;
using static CalamityMod.CalamityUtils;
using static Terraria.ModLoader.ModContent;
using CalamityMod.Items.Accessories;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using System;
namespace CalamityMod.Cooldowns
{
public class WulfrumRoverDriveDurability : CooldownHandler
{
private static Color ringColorLerpStart = new Color(49, 220, 221);
private static Color ringColorLerpEnd = new Color(99, 226, 142);
private float AdjustedCompletion => (instance.timeLeft) / (float)RoverDrive.ProtectionMatrixDurabilityMax;
public static new string ID => "WulfrumRoverDriveDurability";
public override bool CanTickDown => !instance.player.GetModPlayer<RoverDrivePlayer>().RoverDriveOn || instance.timeLeft <= 0;
public override bool ShouldDisplay => instance.player.GetModPlayer<RoverDrivePlayer>().RoverDriveOn;
public override string DisplayName => "Protective Matrix Durability";
public override string Texture => "CalamityMod/Cooldowns/WulfrumRoverDriveActive";
public override string OutlineTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOutline";
public override string OverlayTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOverlay";
public override Color OutlineColor => new Color(112, 244, 244);
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 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);
}
}
public class WulfrumRoverDriveRecharge : CooldownHandler
{
private static Color ringColorLerpStart = new Color(194, 255, 57);
private static Color ringColorLerpEnd = new Color(92, 187, 99);
public static new string ID => "WulfrumRoverDriveRecharge";
public override bool ShouldDisplay => true;
public override string DisplayName => "Protective Matrix Recharge";
public override string Texture => "CalamityMod/Cooldowns/WulfrumRoverDrive";
public override bool SavedWithPlayer => false;
public override bool PersistsThroughDeath => false;
public override Color OutlineColor => new Color(194, 255, 67);
public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
public override void OnCompleted() => instance.player.GetModPlayer<RoverDrivePlayer>().ProtectionMatrixDurability = RoverDrive.ProtectionMatrixDurabilityMax;
public override SoundStyle? EndSound => null;
}
}
+106
View File
@@ -2,12 +2,21 @@
using Terraria;
using Terraria.ModLoader;
using Terraria.ID;
using CalamityMod.Cooldowns;
using CalamityMod.Items.Materials;
using Terraria.Audio;
namespace CalamityMod.Items.Accessories
{
public class RoverDrive : ModItem
{
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 int ProtectionMatrixDurabilityMax = 50;
public static int ProtectionMatrixRechargeTime = 60 * 10;
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
@@ -39,6 +48,8 @@ namespace CalamityMod.Items.Accessories
{
CalamityPlayer modPlayer = player.Calamity();
modPlayer.roverDrive = true;
player.GetModPlayer<RoverDrivePlayer>().RoverDriveOn = true;
}
//Scrappable for 3-6 wulfrum scrap or a 20% chance to get an energy core
@@ -54,4 +65,99 @@ namespace CalamityMod.Items.Accessories
}
}
}
public class RoverDrivePlayer : ModPlayer
{
public bool RoverDriveOn;
public int ProtectionMatrixDurability = 0;
public int ProtectionMatrixCharge = 0;
public override void ResetEffects()
{
//Turn this into armor health when we can
if (RoverDriveOn)
Player.statLifeMax2 += ProtectionMatrixDurability;
else
ProtectionMatrixDurability = 0;
RoverDriveOn = false;
}
public override void PostHurt(bool pvp, bool quiet, double damage, int hitDirection, bool crit)
{
if (RoverDriveOn)
{
if (ProtectionMatrixDurability > 0)
{
ProtectionMatrixDurability -= (int)damage;
if (ProtectionMatrixDurability <= 0)
{
ProtectionMatrixDurability = 0;
//Switch CD
//Sound effect of engine shutting down
}
}
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out var cdDurability))
{
cdDurability.timeLeft = ProtectionMatrixDurability;
}
//Reset recharge time.
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var cd))
{
cd.timeLeft = RoverDrive.ProtectionMatrixRechargeTime;
}
}
}
public override void UpdateDead()
{
ProtectionMatrixDurability = 0;
}
public override void PostUpdateMiscEffects()
{
if (!RoverDriveOn)
{
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out var cdDurability) && !RoverDriveOn)
cdDurability.timeLeft = 0;
if (Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var cdRecharge) && !RoverDriveOn)
cdRecharge.timeLeft = 0;
}
else
{
if (ProtectionMatrixDurability == 0 && !Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var cd))
{
Player.AddCooldown(WulfrumRoverDriveRecharge.ID, RoverDrive.ProtectionMatrixRechargeTime);
}
if (ProtectionMatrixDurability > 0 && !Player.Calamity().cooldowns.TryGetValue(WulfrumRoverDriveDurability.ID, out cd))
{
CooldownInstance durabilityCooldown = Player.AddCooldown(WulfrumRoverDriveDurability.ID, RoverDrive.ProtectionMatrixDurabilityMax);
durabilityCooldown.timeLeft = ProtectionMatrixDurability;
SoundEngine.PlaySound(RoverDrive.ActivationSound, Player.Center);
}
if (ProtectionMatrixDurability > 0)
{
Player.Calamity().roverDrive = true;
Player.Calamity().roverDriveTimer = 2;
}
else
{
Player.Calamity().roverDriveTimer = 618;
Player.Calamity().roverDrive = false;
}
}
}
}
}
+6 -5
View File
@@ -48,6 +48,8 @@ namespace CalamityMod.Items.Armor.Wulfrum
Item.useAnimation = 10;
Item.useTime = 4;
Item.reuseDelay = 17;
Item.noUseGraphic = false;
}
public override void ModifyTooltips(List<TooltipLine> tooltips)
@@ -73,9 +75,8 @@ namespace CalamityMod.Items.Armor.Wulfrum
}
Item.noUseGraphic = false;
if (!player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out var cd) || cd.timeLeft > WulfrumHat.BastionCooldown + WulfrumHat.BastionTime - WulfrumHat.BastionBuildTime)
Item.noUseGraphic = true;
Item.noUseGraphic = true;
}
@@ -105,15 +106,15 @@ namespace CalamityMod.Items.Armor.Wulfrum
if (!player.Calamity().cooldowns.TryGetValue(WulfrumBastion.ID, out var cd) || cd.timeLeft > WulfrumHat.BastionCooldown + WulfrumHat.BastionTime - WulfrumHat.BastionBuildTime)
return;
if (player.ItemTimeIsZero)
noAnimation = false;
if (player.itemAnimation > Item.useAnimation)
noAnimation = true;
float animProgress = 1 - player.itemAnimation / (float)player.itemAnimationMax;
if (noAnimation)
//It beecomes nan if the player loads into a world with the set bonus already active / without shooting any weapons before using it.
//this is because itemAnimationMax isnt set before the item gets used once.
if (noAnimation || animProgress is float.NaN)
animProgress = 1;
//Default
-1
View File
@@ -455,7 +455,6 @@ namespace CalamityMod.Items.Armor.Wulfrum
Main.mouseItem.TurnToAir();
}
//This shouldn't ever be possible since the power mode prevents you from using or moving items around
if (!wulfrumSet && WulfrumHat.PowerModeEngaged(Player, out var cd))
{
Binary file not shown.
Binary file not shown.