Skip to content

Commit

Permalink
Fixed Volcano sword having broken collision checks (#198).
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirsario committed Oct 20, 2023
1 parent 3bc8452 commit 028be9f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Common/Melee/ItemMeleeAttackAiming.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using Microsoft.Xna.Framework;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
Expand Down Expand Up @@ -34,6 +36,13 @@ public float AttackAngle {
}
}

public override void Load()
{
//On_Player.GetPointOnSwungItemPath += GetPointOnSwungItemPathDetour;

IL_Player.ProcessHitAgainstNPC += ProcessHitAgainstNPCInjection;
}

public override void UseAnimation(Item item, Player player)
{
AttackDirection = player.LookDirection();
Expand Down Expand Up @@ -173,4 +182,32 @@ public static Rectangle GetMeleeHitbox(Player player, Item item)

return itemRectangle;
}

/*
private static void GetPointOnSwungItemPathDetour(On_Player.orig_GetPointOnSwungItemPath orig, Player player, float spriteWidth, float spriteHeight, float normalizedPointOnPath, float itemScale, out Vector2 location, out Vector2 outwardDirection)
{
orig(player, spriteWidth, spriteHeight, normalizedPointOnPath, itemScale, out location, out outwardDirection);
if (DebugSystem.EnableDebugRendering) {
DebugSystem.DrawCircle(location, 8f, Color.Turquoise, width: 3);
DebugSystem.DrawLine(location, location + outwardDirection * 32f, Color.MediumTurquoise, width: 3);
}
}
*/

private static void ProcessHitAgainstNPCInjection(ILContext context)
{
var il = new ILCursor(context);

// Skip a weird FieryGreatsword/Volcano block that culls collision for whatever reason.
il.GotoNext(
MoveType.After,
i => i.MatchLdarg(1),
i => i.MatchLdfld(typeof(Item), nameof(Item.type)),
i => i.MatchLdcI4(ItemID.FieryGreatsword)
);

il.Emit(OpCodes.Pop);
il.Emit(OpCodes.Ldc_I4, int.MinValue);
}
}

0 comments on commit 028be9f

Please sign in to comment.