From e71d36a7b62cbd18cae42f2e36ad808b153e2ea2 Mon Sep 17 00:00:00 2001 From: Mr-Memes Date: Tue, 3 Sep 2024 14:24:10 +0200 Subject: [PATCH] DSO rework. --- CalPlayer/CalamityPlayer.cs | 8 +- CalPlayer/CalamityPlayerMiscEffects.cs | 15 ++-- Items/Accessories/DaawnlightSpiritOrigin.cs | 81 +++++++++++++------- NPCs/CalamityGlobalNPC.cs | 19 +++-- Projectiles/CalamityGlobalProjectile.cs | 13 +++- Projectiles/Typeless/SpiritOriginBullseye.cs | 14 +++- 6 files changed, 98 insertions(+), 52 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 959d9a369c..57772eda68 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -245,7 +245,6 @@ namespace CalamityMod.CalPlayer public int giantShellPostHit = 0; public int tortShellPostHit = 0; public int spiritOriginBullseyeShootCountdown = 0; - public int spiritOriginConvertedCrit = 0; public int RustyMedallionCooldown = 0; public int MiniSwamerCooldown = 0; public float SulphWaterPoisoningLevel; @@ -255,6 +254,7 @@ namespace CalamityMod.CalPlayer public bool ragePulse = false; public int ragePulseVisualTimer = 0; public int ragePulseTimer = 0; + public int SpiritOrginCritChanceIncrease = 0; private const int DashDisableCooldown = 12; @@ -1904,9 +1904,11 @@ namespace CalamityMod.CalPlayer lumenousAmulet = false; oceanCrest = false; aquaticEmblem = false; + if (!spiritOrigin) + SpiritOrginCritChanceIncrease = 0; spiritOrigin = false; spiritOriginVanity = false; - spiritOriginConvertedCrit = 0; + astralStarRain = false; @@ -2396,7 +2398,7 @@ namespace CalamityMod.CalPlayer RustyMedallionCooldown = 0; SulphWaterPoisoningLevel = 0f; holyInfernoFadeIntensity = 0f; - spiritOriginConvertedCrit = 0; + SpiritOrginCritChanceIncrease = 0; rage = 0f; adrenaline = 0f; raiderCritLifespan = 0f; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index b17575ad8e..834a86acde 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -74,6 +74,7 @@ using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; +using static CalamityMod.Items.Accessories.DaawnlightSpiritOrigin; namespace CalamityMod.CalPlayer { @@ -187,14 +188,14 @@ namespace CalamityMod.CalPlayer } } - // After everything else, if Daawnlight Spirit Origin is equipped, set ranged crit to the base 4%. - // Store all the crit so it can be used in damage calculations. - if (spiritOrigin) + + int critChanceDecreaseRate = (int)Utils.Remap(SpiritOrginCritChanceIncrease, 0, ExtraCritHardCap, MinimumLossRate, MaximumLossRate); + int perFrameCritChanceDecrease = SpiritOrginCritChanceIncrease <= ExtraCritHardCap ? MinCritLossPerFrame : + (int)Utils.Remap(SpiritOrginCritChanceIncrease, ExtraCritHardCap, ExtraCritHardCap + CritHardCapScalingInterval, MinCritLossPerFrame, CritLossPerFrameIncreasePerInterval, clamped: false); + if (SpiritOrginCritChanceIncrease > 0 && Player.miscCounter % critChanceDecreaseRate == 0) { - // player.rangedCrit already contains the crit stat of the held item, no need to grab it separately. - // Don't store the base 4% because you're not removing it. - spiritOriginConvertedCrit = (int)(Player.GetTotalCritChance() - 4); - Player.GetCritChance() = -spiritOriginConvertedCrit; + SpiritOrginCritChanceIncrease -= perFrameCritChanceDecrease; + Main.NewText(SpiritOrginCritChanceIncrease, Color.Lerp(Color.Green, Color.Red, Utils.GetLerpValue(0, ExtraCritHardCap, SpiritOrginCritChanceIncrease, true)) * 5f); } if (Player.ActiveItem().type != ModContent.ItemType()) diff --git a/Items/Accessories/DaawnlightSpiritOrigin.cs b/Items/Accessories/DaawnlightSpiritOrigin.cs index c2fe0da51a..dc86ca69a7 100644 --- a/Items/Accessories/DaawnlightSpiritOrigin.cs +++ b/Items/Accessories/DaawnlightSpiritOrigin.cs @@ -1,5 +1,4 @@ using CalamityMod.Buffs.Pets; -using CalamityMod.CalPlayer; using CalamityMod.Items.Materials; using Microsoft.Xna.Framework; using Terraria; @@ -18,16 +17,58 @@ namespace CalamityMod.Items.Accessories // "Despite the seemingly insane numbers here, I think this item might actually be underpowered" // hindsight: the item was not underpowered. Ozzatron 05NOV2021 - // - // Regular crits are intentionally weak, especially because they rarely happen (your crit chance gets murdered). - // Bullseyes should be doing all the work. - private const float OriginBullseyeCritRatio = 3.5f; // Bullseye crits deal x3.5 damage instead of x2. - private const float ForcedCritBullseyeCritRatio = 2.4f; // If your projectile is forced to crit, you get less of a reward. + // Memes 03SEP2024: Old comments kept for record. - private const float StoredCritConversionRatio = 0.01f; // Add +1% more damage to crits for every 1% critical chance the player would have had. - private const float MinUseTimeForSlowBonus = 11f; - private const float MaxSlowBonusUseTime = 72f; - private const float MaxSlowWeaponBonus = 0.33f; // Up to +33% more damage to crits for slower weapons. + #region Balancing Variables + + /// + /// The bullseye's total lifespan while it is not hit. + /// + public const int BullseyeIdleLifetime = 600; + + /// + /// The bullseye's lifespan when hit. + /// + public const int BullseyeHitLifetime = 90; + + /// + /// The minimum amount of critcal strike chance lost per decrease. + /// + public const int MinCritLossPerFrame = 1; + + /// + /// The minimum rate at which the extra critcal strike chance decreases.
+ /// This means that it'll decrease every X frames.
+ ///
+ /// When there's no critical strike chance, this will be the loss rate,
+ /// and it'll linearly scale to . + ///
+ public const int MinimumLossRate = 4; + + /// + /// The maximum rate at which the extra critcal strike chance decreases.
+ /// This means that it'll decrease every X frames.
+ ///
+ /// When the extra critical strike chance reaches ,
+ /// this value will be the loss rate. + ///
+ public const int MaximumLossRate = 1; + + /// + /// The amount of extra critcal strike chance at which the hard scaling starts applying. + /// + public const int ExtraCritHardCap = 75; + + /// + /// When the extra critical strike chance is past ,
+ /// every more, it'll start decreasing by more. + ///
+ public const int CritHardCapScalingInterval = 25; + + /// + /// The amount of extra critical strike chance lost every past . + /// + public const int CritLossPerFrameIncreasePerInterval = 4; // These were very carefully calculated, please don't change them. internal const float RegularEnemyBullseyeRadius = 8f; @@ -36,25 +77,7 @@ namespace CalamityMod.Items.Accessories // Special search radius for coin ricoshots that only applies to DSO targets. public static readonly float RicoshotSearchDistance = 2800f; - internal static float GetDamageMultiplier(Player p, CalamityPlayer mp, bool hitBullseye, bool wasForcedCrit) - { - float baseCritMult = 2f; // In vanilla Terraria, crits do +100% damage. - - // If a bullseye was struck, replace a "regular crit" with a "bullseye crit". - if (hitBullseye) - { - // Bullseye crits are weaker if the projectile was already a forced crit. - // This is currently implemented for ULTRAKILL-style ricoshots and for Heavenly Gale's lightning. - baseCritMult = wasForcedCrit ? ForcedCritBullseyeCritRatio : OriginBullseyeCritRatio; - } - - // Factor in the critical strike chance the player isn't getting to use. - float convertedCritBonus = StoredCritConversionRatio * mp.spiritOriginConvertedCrit; - - float useTimeInterpolant = Utils.GetLerpValue(MinUseTimeForSlowBonus, MaxSlowBonusUseTime, p.ActiveItem().useTime, true); - float slowWeaponBonus = MathHelper.Lerp(0f, MaxSlowWeaponBonus, useTimeInterpolant); - return baseCritMult * (1f + convertedCritBonus + slowWeaponBonus); - } + #endregion public override void SetDefaults() { diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 7374f5c849..3909bda845 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -6118,7 +6118,6 @@ namespace CalamityMod.NPCs // Don't allow large hitbox projectiles or explosions to "snipe" enemies. // Hitbox criteria were changed to allow long one dimensional projectiles so that Condemnation would work. - bool hitBullseye = false; bool acceptableVelocity = projectile.velocity != Vector2.Zero; bool acceptableHitbox = (projectile.width <= 36) || (projectile.height <= 36); if (bullseye != null && acceptableVelocity && acceptableHitbox) @@ -6149,19 +6148,19 @@ namespace CalamityMod.NPCs bool willStrikeBullseye = dotCenter > dotOne && dotCenter > dotTwo; // If a bullseye is triggered, set it as hit. - if (willStrikeBullseye && bullseye.ai[1] == 0f) + if (willStrikeBullseye) { - modifiers.SetCrit(); - hitBullseye = true; - bullseye.ai[1] = 1f; // Make the bullseye disappear immediately. + Main.player[projectile.owner].Calamity().SpiritOrginCritChanceIncrease += Main.player[projectile.owner].ActiveItem().useTime; + + if (bullseye.ai[2] == 0f) + { + bullseye.timeLeft = DaawnlightSpiritOrigin.BullseyeHitLifetime; + bullseye.ai[2] = 1f; + } + bullseye.netUpdate = true; } } - - // The bonus provided by Daawnlight Spirit Origin can be computed as a complete replacement to regular crits. - // As such, it is subtracted by the base critical strike damage boost of 200% - float bonus = DaawnlightSpiritOrigin.GetDamageMultiplier(player, modPlayer, hitBullseye, cgp.forcedCrit) - 2f; - modifiers.CritDamage += bonus; } if (!projectile.npcProj && !projectile.trap) diff --git a/Projectiles/CalamityGlobalProjectile.cs b/Projectiles/CalamityGlobalProjectile.cs index d2d63771fe..1a6ec63b35 100644 --- a/Projectiles/CalamityGlobalProjectile.cs +++ b/Projectiles/CalamityGlobalProjectile.cs @@ -16,6 +16,7 @@ using CalamityMod.NPCs.Cryogen; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.Particles; +using CalamityMod.Projectiles.BaseProjectiles; using CalamityMod.Projectiles.Boss; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Ranged; @@ -187,15 +188,23 @@ namespace CalamityMod.Projectiles public override void OnSpawn(Projectile projectile, IEntitySource source) { + // TODO -- it would be nice to move frame one hacks here, but this runs in the middle of NewProjectile + // which is way too early, the projectile's own initialization isn't even done yet + CreatedByPlayerDash = source is ProjectileSource_PlayerDashHit; IEntitySource sourceItem = source as EntitySource_ItemUse_WithAmmo; if (sourceItem != null) extorterBoost = true; - // TODO -- it would be nice to move frame one hacks here, but this runs in the middle of NewProjectile - // which is way too early, the projectile's own initialization isn't even done yet + // Whenever the player has Daawnlight Spirit Origin, any ranged projectile will have the capacity to infintely supercrit. + if (Main.player[projectile.owner].Calamity().spiritOrigin && projectile.CountsAsClass()) + { + projectile.CritChance += Main.player[projectile.owner].Calamity().SpiritOrginCritChanceIncrease; + projectile.Calamity().supercritHits = -1; + } } + #endregion On Spawn #region Set Defaults diff --git a/Projectiles/Typeless/SpiritOriginBullseye.cs b/Projectiles/Typeless/SpiritOriginBullseye.cs index 6239f1dfcf..9250b46ee3 100644 --- a/Projectiles/Typeless/SpiritOriginBullseye.cs +++ b/Projectiles/Typeless/SpiritOriginBullseye.cs @@ -10,15 +10,27 @@ namespace CalamityMod.Projectiles.Typeless public class SpiritOriginBullseye : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Typeless"; + public Player Owner => Main.player[Projectile.owner]; + public NPC Target => Main.npc[(int)Projectile.ai[0]]; + public bool FadingOut { get => Projectile.ai[1] == 1f; set => Projectile.ai[1] = value.ToInt(); } + + public bool HasBeenHit + { + get => Projectile.ai[2] == 1f; + set => Projectile.ai[2] = value.ToInt(); + } + public Vector2 BullseyeOffsetFromCenter; + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void SetDefaults() { Projectile.width = Projectile.height = (int)(2 * DaawnlightSpiritOrigin.RegularEnemyBullseyeRadius); @@ -27,7 +39,7 @@ namespace CalamityMod.Projectiles.Typeless Projectile.hostile = false; Projectile.ignoreWater = true; Projectile.tileCollide = false; - Projectile.timeLeft = 300; + Projectile.timeLeft = DaawnlightSpiritOrigin.BullseyeIdleLifetime; Projectile.Opacity = 0f; Projectile.penetrate = -1; }