fixed up shield slam IL edits
This commit is contained in:
1 parent
6473f649bb
commit
4852f84e75
2 files changed
+28
-28
No files matched your search
@@ -35,7 +35,8 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.Main.UpdateTime += PermitNighttimeTownNPCSpawning;
|
||||
On.Terraria.Main.UpdateTime_SpawnTownNPCs += AlterTownNPCSpawnRate;
|
||||
IL.Terraria.Player.Hurt += RemoveRNGFromBlackBelt;
|
||||
IL.Terraria.Player.DashMovement += FixVanillaShieldSlams;
|
||||
IL.Terraria.Player.DashMovement += BuffSolarFlareShieldSlam;
|
||||
IL.Terraria.Player.GiveImmuneTimeForCollisionAttack += MakeShieldSlamIFramesConsistent;
|
||||
IL.Terraria.Player.Update_NPCCollision += NerfShieldOfCthulhuBonkSafety;
|
||||
On.Terraria.WorldGen.OpenDoor += OpenDoor_LabDoorOverride;
|
||||
On.Terraria.WorldGen.CloseDoor += CloseDoor_LabDoorOverride;
|
||||
@@ -119,7 +120,7 @@ namespace CalamityMod.ILEditing
|
||||
IL.Terraria.Main.UpdateTime -= PermitNighttimeTownNPCSpawning;
|
||||
On.Terraria.Main.UpdateTime_SpawnTownNPCs -= AlterTownNPCSpawnRate;
|
||||
IL.Terraria.Player.Hurt -= RemoveRNGFromBlackBelt;
|
||||
IL.Terraria.Player.DashMovement -= FixVanillaShieldSlams;
|
||||
IL.Terraria.Player.DashMovement -= BuffSolarFlareShieldSlam;
|
||||
IL.Terraria.Player.Update_NPCCollision -= NerfShieldOfCthulhuBonkSafety;
|
||||
On.Terraria.WorldGen.OpenDoor -= OpenDoor_LabDoorOverride;
|
||||
On.Terraria.WorldGen.CloseDoor -= CloseDoor_LabDoorOverride;
|
||||
|
||||
@@ -140,26 +140,31 @@ namespace CalamityMod.ILEditing
|
||||
}
|
||||
#endregion Removal of Black Belt Dodge RNG
|
||||
|
||||
#region Vanilla Dash Shield Improvements
|
||||
private static void FixVanillaShieldSlams(ILContext il)
|
||||
#region Vanilla Dash / Shield Slam Improvements
|
||||
private static void MakeShieldSlamIFramesConsistent(ILContext il)
|
||||
{
|
||||
// Remove Shield of Cthulhu setting your iframes to an exact number and instead run Calamity's utility to safely provide iframes.
|
||||
var cursor = new ILCursor(il);
|
||||
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStfld<Player>("immuneNoBlink")))
|
||||
|
||||
// Find the direct assignment of the player's iframes.
|
||||
if (!cursor.TryGotoNext(MoveType.AfterLabel, i => i.MatchStfld<Player>("immuneTime")))
|
||||
{
|
||||
LogFailure("Vanilla Shield Slam Fix", "Could not locate Shield of Cthulhu immunity blinking set.");
|
||||
LogFailure("Shield Slam Consistent Immunity Frames", "Could not locate the assignment of the player's immune time.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy the entire operation which sets your iframes to exactly 4:
|
||||
// ldarg.0 (load "this", aka the Player)
|
||||
// ldc.i4.4 (load 4)
|
||||
// stfld int32 Terraria.Player::immuneTime
|
||||
cursor.RemoveRange(3);
|
||||
// Delete this instruction. The stack still contains the amount of iframes to give.
|
||||
cursor.Remove();
|
||||
|
||||
// Load the player itself onto the stack so that it becomes an argument for the following delegate.
|
||||
// Load the player itself onto the stack so that it becomes the second argument for the following delegate.
|
||||
cursor.Emit(OpCodes.Ldarg_0);
|
||||
cursor.EmitDelegate<Action<Player>>((Player p) => p.GiveIFrames(CalamityPlayer.ShieldOfCthulhuIFrames, false));
|
||||
|
||||
// Emit a delegate which calls the Calamity utility to consistently provide iframes.
|
||||
cursor.EmitDelegate<Action<int, Player>>((frames, p) => CalamityUtils.GiveIFrames(p, frames, false));
|
||||
}
|
||||
|
||||
private static void BuffSolarFlareShieldSlam(ILContext il)
|
||||
{
|
||||
var cursor = new ILCursor(il);
|
||||
|
||||
// Move onto the next dash (Solar Flare set bonus) by looking for the base damage of the direct contact strike.
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcR4(150f)))
|
||||
@@ -178,27 +183,21 @@ namespace CalamityMod.ILEditing
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace vanilla's flat 150 damage (doesn't even scale with melee stats!) with Calamity's calculation.
|
||||
// Replace vanilla's flat 150 damage (doesn't even scale with melee stats!) with the already-calculated base damage, then cast it to int.
|
||||
cursor.Remove();
|
||||
cursor.Emit(OpCodes.Ldloc, 12);
|
||||
cursor.Emit(OpCodes.Ldloc, 13);
|
||||
cursor.Emit(OpCodes.Conv_I4);
|
||||
|
||||
// Move to the immunity frame setting code for the Solar Flare set bonus.
|
||||
if (!cursor.TryGotoNext(MoveType.After, i => i.MatchStfld<Player>("immuneNoBlink")))
|
||||
// Move to the immunity frame setting code for the Solar Flare set bonus. Find the constant 4 given as iframes.
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchLdcI4(4)))
|
||||
{
|
||||
LogFailure("Vanilla Shield Slam Fix", "Could not locate Solar Flare Armor shield slam base damage.");
|
||||
LogFailure("Vanilla Shield Slam Fix", "Could not locate Solar Flare shield slam iframes.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy the entire operation which sets your iframes to exactly 4:
|
||||
// ldarg.0 (load "this", aka the Player)
|
||||
// ldc.i4.4 (load 4)
|
||||
// stfld int32 Terraria.Player::immuneTime
|
||||
cursor.RemoveRange(3);
|
||||
|
||||
// Load the player itself onto the stack so that it becomes an argument for the following delegate.
|
||||
cursor.Emit(OpCodes.Ldarg_0);
|
||||
cursor.EmitDelegate<Action<Player>>((Player p) => p.GiveIFrames(CalamityPlayer.SolarFlareIFrames, false));
|
||||
// Replace it with Calamity's number of iframes.
|
||||
cursor.Remove();
|
||||
cursor.Emit(OpCodes.Ldc_I4, CalamityPlayer.SolarFlareIFrames);
|
||||
}
|
||||
|
||||
private static void NerfShieldOfCthulhuBonkSafety(ILContext il)
|
||||
|
||||
Reference in new issue
Block a user