Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NRE when riposte kills opponents #3615

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/CombatExtended/Harmony/Harmony_Verb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruct

FieldInfo fverbProps = AccessTools.Field(typeof(Verb), nameof(Verb.verbProps));
FieldInfo fticksBetweenBurstShots = AccessTools.Field(typeof(VerbProperties), nameof(VerbProperties.ticksBetweenBurstShots));
FieldInfo fnonInterruptingSelfCast = AccessTools.Field(typeof(VerbProperties), nameof(VerbProperties.nonInterruptingSelfCast));

MethodInfo pnonInterruptingSelfCast = AccessTools.PropertyGetter(typeof(Verb), nameof(Verb.NonInterruptingSelfCast));
MethodInfo pCasterPawn = AccessTools.PropertyGetter(typeof(Verb), nameof(Verb.CasterPawn));
MethodInfo pSpawned = AccessTools.PropertyGetter(typeof(Pawn), nameof(Pawn.Spawned));

Expand All @@ -58,7 +58,7 @@ internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruct
// Check if the caster pawn is spawned before attempting to set them into cooldown stance,
// since the caster may be dead as a result e.g. a successful melee riposte in TryCastShot().
// Vanilla already performs this check if the attack connected, but not when it missed.
if (codes[i].Branches(out Label? blockEndLabel) && codes[i - 1].LoadsField(fnonInterruptingSelfCast))
if (codes[i].Branches(out Label? blockEndLabel) && codes[i - 1].Is(OpCodes.Call, pnonInterruptingSelfCast))
{
yield return codes[i];
yield return new CodeInstruction(OpCodes.Ldarg_0);
Expand Down
Loading