Tag damage isn't flat, unfucked Firecracker

This commit is contained in:
DominicKarma committed 2022-05-18 21:10:11 -05:00
1 parent f03eda020f
commit dfbb5e31dc
3 files changed
+105 -1

No files matched your search

+9
View File
@@ -22,6 +22,15 @@
internal static readonly int DaedalusReflectCooldown = 5400;
internal static readonly int EvolutionReflectCooldown = 7200;
// Internal vanilla item damage variables
internal static readonly float LeatherWhipTagDamageMultiplier = 1.08f;
internal static readonly float SnapthornTagDamageMultiplier = 1.04f;
internal static readonly float SpinalTapTagDamageMultiplier = 1.08f;
internal static readonly float FirecrackerExplosionDamageMultiplier = 2.25f; // Relative to the whip, not the summon.
internal static readonly float DurendalTagDamageMultiplier = 1.09f;
internal static readonly float MorningStarTagDamageMultiplier = 1.11f;
internal static readonly float KaleidoscopeTagDamageMultiplier = 1.12f;
// TODO -- Add all balance related constants here that don't belong in other files.
// These constants were just the ones sitting in CalamityPlayer.
// Review all constants and static readonlys in the entire mod to find things to add.
+2
View File
@@ -102,6 +102,7 @@ namespace CalamityMod.ILEditing
IL.Terraria.Projectile.CanExplodeTile += MakeMeteoriteExplodable;
IL.Terraria.Main.UpdateTime_StartNight += BloodMoonsRequire200MaxLife;
IL.Terraria.WorldGen.AttemptFossilShattering += PreventFossilShattering;
IL.Terraria.Projectile.Damage += MakeTagDamageMultiplicative;
// Fix vanilla bugs exposed by Calamity mechanics
IL.Terraria.NPC.NPCLoot += FixSplittingWormBannerDrops;
@@ -184,6 +185,7 @@ namespace CalamityMod.ILEditing
IL.Terraria.Projectile.CanExplodeTile -= MakeMeteoriteExplodable;
IL.Terraria.Main.UpdateTime_StartNight -= BloodMoonsRequire200MaxLife;
IL.Terraria.WorldGen.AttemptFossilShattering -= PreventFossilShattering;
IL.Terraria.Projectile.Damage -= MakeTagDamageMultiplicative;
// Fix vanilla bugs exposed by Calamity mechanics
// On.Terraria.Main.InitLifeBytes -= BossRushLifeBytes;
+94 -1
View File
@@ -1,8 +1,11 @@
using Mono.Cecil.Cil;
using CalamityMod.Balancing;
using Microsoft.Xna.Framework;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.ILEditing
{
@@ -220,6 +223,96 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Make Tag Damage Multiplicative
private static void MakeTagDamageMultiplicative(ILContext il)
{
var cursor = new ILCursor(il);
int damageLocalIndex = 37;
bool replaceWithMultipler(int flagLocalIndex, float damageFactor, bool usesExtraVariableToStoreDamage = false)
{
// Move after the bool load and branch-if-false instruction.
cursor.Goto(0);
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdloc(flagLocalIndex)))
{
LogFailure("Making Tag Damage Multiplicative", $"Could not locate the flag local index of '{flagLocalIndex}'.");
return false;
}
cursor.Index += 2;
// OPTIONAL case for if an extra variable to store damage is used:
// Load damage to add.
// Store damage to add as a variable.
// Load damage ->
// Load damage addition ->
// Add the two ->
// Store damage.
cursor.RemoveRange(usesExtraVariableToStoreDamage ? 6 : 4);
// Load damage ->
// Cast damage to float ->
// Load the damage factor ->
// Multiply the two ->
// Cast the result to int, removing the fractional part ->
// Store damage.
cursor.Emit(OpCodes.Ldloc, damageLocalIndex);
cursor.Emit(OpCodes.Conv_R4);
cursor.Emit(OpCodes.Ldc_R4, damageFactor);
cursor.Emit(OpCodes.Mul);
cursor.Emit(OpCodes.Conv_I4);
cursor.Emit(OpCodes.Stloc, damageLocalIndex);
return true;
}
// Leather whip.
replaceWithMultipler(50, BalancingConstants.LeatherWhipTagDamageMultiplier);
// Durendal.
replaceWithMultipler(51, BalancingConstants.DurendalTagDamageMultiplier);
// Snapthorn.
replaceWithMultipler(54, BalancingConstants.SnapthornTagDamageMultiplier);
// Spinal Tap.
replaceWithMultipler(55, BalancingConstants.SpinalTapTagDamageMultiplier);
// Morning Star.
replaceWithMultipler(56, BalancingConstants.MorningStarTagDamageMultiplier);
// Kaleidoscope.
replaceWithMultipler(57, BalancingConstants.KaleidoscopeTagDamageMultiplier, true);
// SPECIAL CASE: Firecracker's damage is fucking absurd and everything needs to go.
cursor.Goto(0);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStloc(64)))
{
LogFailure("Making Tag Damage Multiplicative", $"Could not locate the flag local index of 52.");
return;
}
// Change the damage of the explosions.
cursor.Emit(OpCodes.Ldarg_0);
cursor.EmitDelegate<Func<Projectile, int>>(projectile =>
{
int damage = (int)(Main.player[projectile.owner].ActiveItem().damage * BalancingConstants.FirecrackerExplosionDamageMultiplier);
damage = (int)Main.player[projectile.owner].GetDamage(DamageClass.Summon).ApplyTo(damage);
return damage;
});
cursor.Emit(OpCodes.Stloc, 64);
// Change the x in damage += x; to zero.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchAdd()))
{
LogFailure("Making Tag Damage Multiplicative", $"Could not locate the damage additive value.");
return;
}
cursor.Index--;
cursor.Remove();
cursor.Emit(OpCodes.Ldc_I4_0);
}
#endregion Make Tag Damage Multiplicative
#region Fix Chlorophyte Crystal Attacking Where it Shouldn't
#endregion Fix Chlorophyte Crystal Attacking Where it Shouldn't