Skip to content

Commit

Permalink
Fix remote nail swings causing recoil
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Jul 30, 2024
1 parent d1f4441 commit 04217f6
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions HKMP/Game/Client/GamePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,33 +458,51 @@ private void CallMethodProperOnDoMethodCall(
On.HutongGames.PlayMaker.Actions.CallMethodProper.orig_DoMethodCall orig,
HutongGames.PlayMaker.Actions.CallMethodProper self
) {
// If the FSM and game object do not match the Crystal Shot, we execute the original method and return
if (!self.Fsm.Name.Equals("FSM") || !self.Fsm.GameObject.name.Contains("Crystal Shot")) {
// If the 'behaviour' and 'methodName' strings do not match, we execute the original method and return
if (self.behaviour.Value != "HeroController" ||
self.methodName.Value != "RecoilLeft" &&
self.methodName.Value != "RecoilRight" &&
self.methodName.Value != "RecoilDown" &&
self.methodName.Value != "Bounce"
) {
orig(self);
return;
}

// Find the damager game object from the FSM variables, if it, its parent, or their parent is null, we
// execute the original method and return, because we know that it was not a remote player's nail slash
var damager = self.Fsm.Variables.GetFsmGameObject("Damager").Value;
if (damager == null) {
// If the state does not match, we return as well
if (!self.State.Name.StartsWith("No Box ") && !self.State.Name.StartsWith("Blocked ")) {
orig(self);
return;
}

var parent = damager.transform.parent;
if (parent == null) {
Transform attacks;

// Find either the 'Damager' or the 'Collider' game object from the FSM variables, and check up the hierarchy.
// If it matches the local player's object, then we know it was the local player's slash and not a remote
// player's slash
var damager = self.Fsm.Variables.FindFsmGameObject("Damager");
var collider = self.Fsm.Variables.FindFsmGameObject("Collider");
if (damager != null && damager.Value != null) {
attacks = damager.Value.transform.parent;
} else if (collider != null && collider.Value != null && collider.Value.transform.parent != null) {
attacks = collider.Value.transform.parent.parent;
} else {
orig(self);
return;
}

parent = parent.parent;
if (parent == null) {
if (attacks == null) {
orig(self);
return;
}

if (parent.name.Equals("Knight")) {
var knight = attacks.parent;
if (knight == null) {
orig(self);
return;
}

if (knight.name.Equals("Knight")) {
orig(self);
}
}
Expand Down

0 comments on commit 04217f6

Please sign in to comment.