Merged some IL edits that edit the same method

This commit is contained in:
CongratsIsTrash committed 2024-11-22 20:54:12 -05:00
1 parent 33d4dba315
commit 6bdab6bf5e
4 files changed
+134 -171

No files matched your search

+96 -107
View File
@@ -298,10 +298,26 @@ namespace CalamityMod.ILEditing
#endregion
#region Life Regen Changes
private static void PreventWellFedFromBeingRequiredInExpertModeForFullLifeRegen(ILContext il)
private static void UpdateLifeRegenBalancingChanges(ILContext il)
{
// Prevent the greatly reduced life regen while without the well fed buff in expert mode.
// This IL edit accomplishes two things related to life regen:
// 1. Prevents Nebula armor's Life Boosters from cancelling out negative life regen.
// 2. Prevents the greatly reduced life regen while without a Well Fed buff in Expert Mode.
var cursor = new ILCursor(il);
// First, move to where the game checks if the Life Booster level is greater than 0.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Player>("nebulaLevelLife")))
{
LogFailure("Nebula Armor DoT Ignoring Nerf", "Could not locate the Nebula Armor Life Booster variable.");
return;
}
// Pop this value off the stack and replace it with 0.
// 0 will never be greater than 0, so negative life regen will never be canceled out.
cursor.Emit(OpCodes.Pop);
cursor.Emit(OpCodes.Ldc_I4_0);
// Now move to where the game checks if it is Expert Mode and the player does not have a Well Fed buff.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Player>("wellFed")))
{
LogFailure("Expert Mode Well Fed Reduced Life Regen Prevention", "Could not locate the Well Fed bool.");
@@ -337,11 +353,28 @@ namespace CalamityMod.ILEditing
cursor.Emit(OpCodes.Ldc_R4, 0.2f); // Decrease to 0.2f.
}
private static void ManaRegenAdjustment(ILContext il)
private static void UpdateManaRegenBalancingChanges(ILContext il)
{
// Increase the base mana regen so that mage is less annoying to play without mana regen buffs.
// This IL edit accomplishes two things:
// 1. Nerfs Nebula armor's Mana Boosters.
// 2. Increases the base mana regen so that mage is less annoying to play without mana regen buffs.
var cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.8f))) // The multiplier for the mana regen formula: (float)statMana / (float)statManaMax2 * 0.8f + 0.2f.
// Reduce Nebula armor mana regen.
// See BalancingConstants for a more in-depth explanation as to how the Mana Booster works.
// Just know that we need to raise this value in order to nerf it.
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdcI4(6)))
{
LogFailure("Nebula Armor Mana Regen Nerf", "Could not locate the Nebula Armor mana regeneration frame counter threshold.");
return;
}
// Swap the threshold with Calamity's value.
cursor.Next.Operand = BalancingConstants.NebulaManaRegenFrameCounterThreshold;
// Next, move to the mana regen formula.
// The multiplier for the mana regen formula: (float)statMana / (float)statManaMax2 * 0.8f + 0.2f.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.8f)))
{
LogFailure("Mana Regen Buff", "Could not locate the mana regen multiplier variable.");
return;
@@ -464,13 +497,15 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Reduce Eater of Worlds Grenade Resist
private static void ReduceEoWGrenadeResist(ILContext il)
#region Vanilla Boss Resist Changes
private static void VanillaBossResistChanges(ILContext il)
{
// Reduce Expert+ Eater of Worlds' resist to explosives from 80% to 60%.
// This IL edit accomplishes two things:
// 1. Reduces Expert+ Eater of Worlds' resist to explosives from 80% to 60%.
// 2. Effectively removes Lunatic Cultist's resistance to homing projectiles.
var cursor = new ILCursor(il);
// Of course, this is 800 lines into Projectile.Damage, so we must do funky things.
// First, the EoW grenade resist. Naturally, this is 800 lines into Projectile.Damage, so we must do funky things.
for (int f = 0; f < 2; f++)
{
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(1002)))
@@ -490,6 +525,21 @@ namespace CalamityMod.ILEditing
cursor.EmitPop();
cursor.EmitLdcR4(0.4f);
cursor.EmitMul();
// Now, move to the Cultist resist which is right below it.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdsfld(typeof(ProjectileID.Sets), "CultistIsResistantTo")))
{
LogFailure("Lunatic Cultist Homing Resist Removal", "Could not locate the Cultist resist set.");
return;
}
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.75f))) // The resist ratio.
{
LogFailure("Lunatic Cultist Homing Resist Removal", "Could not locate the resist percentage.");
return;
}
// Replace the value with 1, meaning -0% damage or no resist.
cursor.Next.Operand = 1f;
}
#endregion
@@ -510,11 +560,17 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Sharpening Station Nerf
private static void NerfSharpeningStation(ILContext il)
#region UpdateBuffs Balancing Changes
private static void UpdateBuffsBalancingChanges(ILContext il)
{
// Reduce armor penetration from the Sharpening Station from 12 (it was originally 16!)
// This IL edit accomplishes four things:
// 1. Nerf Sharpening Station's armor penetration boost from 12 to 5.
// 2. Nerf Beetle Scale Mail's set bonus Beetle Might melee speed from 10% per stack to 5%.
// 3. Nerf Nebula armor's Damage and Life Boosters (Mana Boosters are not handled in this method).
// 4. Remove the ability for Feral Bite to randomly inflict debuffs.
var cursor = new ILCursor(il);
// First, find the code which applies Sharpened's armor penetration buff.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(BuffID.Sharpened)))
{
LogFailure("Sharpening Station Nerf", "Could not locate the Sharpened buff ID.");
@@ -529,67 +585,28 @@ namespace CalamityMod.ILEditing
// Replace the value entirely.
cursor.Remove();
cursor.Emit(OpCodes.Ldc_R4, BalancingConstants.SharpeningStationArmorPenetration);
}
#endregion
#region Beetle Scale Mail (DPS chestplate) Nerf
private static void NerfBeetleScaleMail(ILContext il)
{
// Adjust melee damage from the Beetle Might buff.
var cursor = new ILCursor(il);
// Next, move to Beetle Scale Mail's melee speed boost from Beetle Might buff.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(BuffID.BeetleMight1)))
{
LogFailure("Beetle Scale Mail Nerf", "Could not locate the Beetle Might buff ID.");
return;
}
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.1f))) // The amount of melee damage to grant.
for (int i = 0; i < 2; i++)
{
LogFailure("Beetle Scale Mail Nerf", "Could not locate the amount of melee damage granted.");
return;
}
// Replace the value entirely.
cursor.Remove();
cursor.Emit(OpCodes.Ldc_R4, BalancingConstants.BeetleScaleMailMeleeDamagePerBeetle);
cursor.GotoNext();
// Adjust melee speed from the Beetle Might buff.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.1f))) // The amount of melee speed to grant.
{
LogFailure("Beetle Scale Mail Nerf", "Could not locate the amount of melee speed granted.");
return;
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.1f))) // The amount of melee damage to grant.
{
LogFailure("Beetle Scale Mail Nerf", "Could not locate the amount of melee speed granted.");
return;
}
}
// Replace the value entirely.
cursor.Remove();
cursor.Emit(OpCodes.Ldc_R4, BalancingConstants.BeetleScaleMailMeleeSpeedPerBeetle);
}
#endregion
#region Vortex Booster Keeps Vortex Stealth When Dashing
private static void VortexBoosterKeepsVortexStealthWhenDashing(On_Player.orig_DashMovement orig, Player self)
{
// Allows for Vortex Booster to keep Vortex armor's stealth when dashing
bool vortexStealth = self.vortexStealthActive;
orig(self);
if (self.wingsLogic == (int)VanillaWingID.WingsVortex)
{
if (vortexStealth && !self.vortexStealthActive)
self.vortexStealthActive = true;
}
}
#endregion
#region Nebula Armor Nerfs
private static void NerfNebulaArmorBaseLifeRegenAndDamage(ILContext il)
{
// Nebula's buffs are processed in the order Mana, Life, Damage
// The mana buff is merely tracked and updated in this function, so it is not IL edited here.
var cursor = new ILCursor(il);
// Adjust life regen from the Nebula Life Boosters.
// Then, Nebula armor's Life and Damage Boosters.
// First is the Life Boosters.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(BuffID.NebulaUpLife1)))
{
LogFailure("Nebula Armor Nerf", "Could not locate the Nebula Life buff ID.");
@@ -610,7 +627,7 @@ namespace CalamityMod.ILEditing
cursor.Remove();
cursor.Emit(OpCodes.Ldc_I4, BalancingConstants.NebulaLifeRegenPerBooster);
// Adjust damage from Nebula Damage Boosters.
// And then the Damage Boosters.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdcI4(BuffID.NebulaUpDmg1)))
{
LogFailure("Nebula Armor Nerf", "Could not locate the Nebula Damage buff ID.");
@@ -624,40 +641,33 @@ namespace CalamityMod.ILEditing
// There are multiple branches pointing to this instruction, so it cannot be removed. Instead, swap its value directly.
cursor.Next.Operand = BalancingConstants.NebulaDamagePerBooster;
}
private static void RemoveNebulaLifeBoosterDoTImmunity(ILContext il)
{
// Prevent Nebula Life Boosters from canceling out all DoT debuff damage.
var cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchLdfld<Player>("nebulaLevelLife")))
// Finally, removing Feral Bite's debuffs.
// Find the random debuff duration multiplier for the debuffs inflicted by Feral Bite.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.01f))) // The 0.01f random debuff duration multiplier.
{
LogFailure("Nebula Armor DoT Ignoring Nerf", "Could not locate the Nebula Armor Life Booster variable.");
LogFailure("Remove Feral Bite Random Debuffs", "Could not locate the Feral Bite random debuff duration multiplier.");
return;
}
// Pop this value off the stack and replace it with a zero.
// Zero will never be greater than zero, so negative life regen will never be canceled out.
cursor.Emit(OpCodes.Pop);
cursor.Emit(OpCodes.Ldc_I4_0);
// Remove and change to 0f, this makes the random debuffs from Feral Bite have 0 duration.
cursor.Remove();
cursor.Emit(OpCodes.Ldc_R4, 0f);
}
#endregion
private static void NerfNebulaArmorManaRegen(ILContext il)
#region Vortex Booster Keeps Vortex Stealth When Dashing
private static void VortexBoosterKeepsVortexStealthWhenDashing(On_Player.orig_DashMovement orig, Player self)
{
// Reduce Nebula armor mana regen.
// The regen is controlled by a frame counter threshold right at the top of the function, typically 6.
// 1 value is added to the counter for every Mana Booster you have.
// If the value reaches the threshold, you gain 1 mana.
// All that needs to be done is raising the threshold, so it takes more frames to get each point of mana.
var cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchLdcI4(6)))
{
LogFailure("Nebula Armor Mana Regen Nerf", "Could not locate the Nebula Armor mana regeneration frame counter threshold.");
return;
}
// Allows for Vortex Booster to keep Vortex armor's stealth when dashing
bool vortexStealth = self.vortexStealthActive;
orig(self);
// Swap the threshold with Calamity's value.
cursor.Next.Operand = BalancingConstants.NebulaManaRegenFrameCounterThreshold;
if (self.wingsLogic == (int)VanillaWingID.WingsVortex)
{
if (vortexStealth && !self.vortexStealthActive)
self.vortexStealthActive = true;
}
}
#endregion
@@ -737,27 +747,6 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Remove Lunatic Cultist Homing Resist
private static void RemoveLunaticCultistHomingResist(ILContext il)
{
// Change Lunatic Cultist's resist from 25% to 0% (effectively removing it).
var cursor = new ILCursor(il);
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdsfld(typeof(ProjectileID.Sets), "CultistIsResistantTo")))
{
LogFailure("Lunatic Cultist Homing Resist Removal", "Could not locate the Cultist resist set.");
return;
}
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.75f))) // The resist ratio.
{
LogFailure("Lunatic Cultist Homing Resist Removal", "Could not locate the resist percentage.");
return;
}
// Replace the value with 1, meaning -0% damage or no resist.
cursor.Next.Operand = 1f;
}
#endregion
#region Remove Frozen Infliction From Deerclops Ice Spikes
private static void RemoveFrozenInflictionFromDeerclopsIceSpikes(ILContext il)
{
+6 -15
View File
@@ -38,8 +38,7 @@ namespace CalamityMod.ILEditing
exoDoorClosed = ModContent.TileType<ExoDoorClosed>();
// Graphics
IL_Main.DoDraw += AdditiveDrawing;
IL_Main.DoDraw += DrawFloralParadiseFog;
IL_Main.DoDraw += CustomDoDrawChanges;
On_Main.DrawCursor += UseCoolFireCursorEffect;
On_Main.SortDrawCacheWorms += DrawFusableParticles;
On_Main.DrawInfernoRings += DrawForegroundParticles;
@@ -63,7 +62,6 @@ namespace CalamityMod.ILEditing
On_NPC.ShouldEmpressBeEnraged += AllowEmpressToEnrageInBossRush;
On_NPC.DoDeathEvents += PreventVanillaBossDeathsInBossRush;
IL_Player.CollectTaxes += MakeTaxCollectorUseful;
IL_Projectile.Damage += RemoveLunaticCultistHomingResist;
// Mechanics / features
On_NPC.ApplyTileCollision += AllowTriggeredFallthrough;
@@ -143,12 +141,10 @@ namespace CalamityMod.ILEditing
// Damage and health balance
On_Main.DamageVar_float_int_float += AdjustDamageVariance;
IL_NPC.ScaleStats_ApplyExpertTweaks += RemoveExpertHardmodeScaling;
IL_Projectile.Damage += ReduceEoWGrenadeResist;
IL_Projectile.Damage += VanillaBossResistChanges;
IL_Projectile.AI_099_2 += LimitTerrarianProjectiles;
IL_Projectile.AI_120_StardustGuardian += StardustGuardianAttackBuffs;
IL_Player.UpdateBuffs += NerfSharpeningStation;
IL_Player.UpdateBuffs += NerfBeetleScaleMail;
IL_Player.UpdateBuffs += NerfNebulaArmorBaseLifeRegenAndDamage;
IL_Player.UpdateBuffs += UpdateBuffsBalancingChanges;
IL_Player.ApplyVanillaHurtEffectModifiers += RemoveBeetleAndSolarFlareMultiplicativeDR;
// Movement speed balance
@@ -158,14 +154,10 @@ namespace CalamityMod.ILEditing
IL_Player.Update += NerfOverpoweredRunAccelerationSources; // Soaring Insignia, Magiluminescence, and Shadow Armor
IL_Player.WingMovement += RemoveSoaringInsigniaInfiniteWingTime;
// Life regen balance
IL_Player.UpdateLifeRegen += PreventWellFedFromBeingRequiredInExpertModeForFullLifeRegen;
IL_Player.UpdateLifeRegen += RemoveNebulaLifeBoosterDoTImmunity;
// Mana regen balance
// Life regen and mana regen balance
IL_Player.UpdateLifeRegen += UpdateLifeRegenBalancingChanges;
IL_Player.UpdateManaRegen += UpdateManaRegenBalancingChanges;
IL_Player.Update += ManaRegenDelayAdjustment;
IL_Player.UpdateManaRegen += ManaRegenAdjustment;
IL_Player.UpdateManaRegen += NerfNebulaArmorManaRegen;
// Item prefix changes
On_Player.GrantPrefixBenefits += PrefixChanges;
@@ -189,7 +181,6 @@ namespace CalamityMod.ILEditing
Terraria.GameContent.Biomes.On_JunglePass.GenerateFinishingTouches += AddStohne;
// Removal of vanilla stupidity
IL_Player.UpdateBuffs += RemoveFeralBiteRandomDebuffs;
IL_Player.StatusFromNPC += RemoveExpertBrainRandomDebuffs;
IL_Player.ItemCheck_EmitUseVisuals += MakeMagmaStoneFireGauntletDustToggleable;
IL_Projectile.EmitEnchantmentVisualsAt += MakeMagmaStoneFireGauntletProjectileDustToggleable;
+32 -31
View File
@@ -836,46 +836,25 @@ namespace CalamityMod.ILEditing
}
#endregion
#region Fog Effect in Floral Paradise
private static void DrawFloralParadiseFog(ILContext il)
#region Custom DoDraw Changes
private static void CustomDoDrawChanges(ILContext il)
{
// This IL edit accomplishes two things:
// 1. Calls a helper function for drawing the fog in the Floral Paradise.
// 2. Allows for drawing additive blend projectiles using IAdditiveDrawer.
ILCursor cursor = new ILCursor(il);
cursor.GotoNext(MoveType.Before, i => i.MatchCallOrCallvirt<Main>("DrawInfernoRings"));
// First, Floral Paradise fog.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt<Main>("DrawInfernoRings")))
return;
cursor.EmitDelegate<Action>(() =>
{
if (Main.netMode != NetmodeID.Server && BiomeTileCounterSystem.FloralParadiseTiles > 0)
DrawFog(Utils.GetLerpValue(0f, 250f, BiomeTileCounterSystem.FloralParadiseTiles, true));
});
}
private static void DrawFog(float intensity)
{
Main.spriteBatch.EnterShaderRegion();
WaterfallRenderer.DrawWaterfalls();
Texture2D fogTexture = ModContent.Request<Texture2D>("Terraria/Images/Misc/Perlin").Value;
Vector2 scale = new Vector2(Main.screenWidth, Main.screenHeight) / fogTexture.Size();
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
GameShaders.Misc["CalamityMod:Fog"].UseOpacity(intensity * 0.74f);
GameShaders.Misc["CalamityMod:Fog"].UseColor(Color.Lerp(Color.Lime, Color.Black, 0.85f));
GameShaders.Misc["CalamityMod:Fog"].UseSaturation(1.67f);
GameShaders.Misc["CalamityMod:Fog"].Shader.Parameters["fogMovementSpeed"].SetValue(1.75f);
GameShaders.Misc["CalamityMod:Fog"].Apply();
Main.spriteBatch.Draw(fogTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
Main.spriteBatch.End();
Main.spriteBatch.Begin();
}
#endregion Fog Effect in Floral Paradise
#region Custom Draw Layers
private static void AdditiveDrawing(ILContext il)
{
ILCursor cursor = new(il);
// Then, additive drawing.
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchCall<ScreenObstruction>("Draw")))
return;
@@ -900,6 +879,28 @@ namespace CalamityMod.ILEditing
Main.spriteBatch.SetBlendState(BlendState.AlphaBlend);
});
}
private static void DrawFog(float intensity)
{
Main.spriteBatch.EnterShaderRegion();
WaterfallRenderer.DrawWaterfalls();
Texture2D fogTexture = ModContent.Request<Texture2D>("Terraria/Images/Misc/Perlin").Value;
Vector2 scale = new Vector2(Main.screenWidth, Main.screenHeight) / fogTexture.Size();
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
GameShaders.Misc["CalamityMod:Fog"].UseOpacity(intensity * 0.74f);
GameShaders.Misc["CalamityMod:Fog"].UseColor(Color.Lerp(Color.Lime, Color.Black, 0.85f));
GameShaders.Misc["CalamityMod:Fog"].UseSaturation(1.67f);
GameShaders.Misc["CalamityMod:Fog"].Shader.Parameters["fogMovementSpeed"].SetValue(1.75f);
GameShaders.Misc["CalamityMod:Fog"].Apply();
Main.spriteBatch.Draw(fogTexture, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
Main.spriteBatch.End();
Main.spriteBatch.Begin();
}
#endregion
#region General Particle Rendering
@@ -128,24 +128,6 @@ namespace CalamityMod.ILEditing
}
#endregion Prevention of Slime Rain Spawns When Near Bosses
#region Remove Feral Bite Random Debuffs
private static void RemoveFeralBiteRandomDebuffs(ILContext il)
{
var cursor = new ILCursor(il);
// Find the random debuff duration multiplier for the debuffs inflicted by Feral Bite.
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(0.01f))) // The 0.01f random debuff duration multiplier.
{
LogFailure("Remove Feral Bite Random Debuffs", "Could not locate the Feral Bite random debuff duration multiplier.");
return;
}
// Remove and change to 0f, this makes the random debuffs from Feral Bite have 0 duration.
cursor.Remove();
cursor.Emit(OpCodes.Ldc_R4, 0f);
}
#endregion
#region Remove Expert Brain of Cthulhu Random Debuffs
private static void RemoveExpertBrainRandomDebuffs(ILContext il)
{