Skip to content

Commit

Permalink
Fix issue with acid hazard deaths
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Dec 18, 2023
1 parent 139d734 commit 6293d9c
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions HKMP/Fsm/FsmPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,50 @@ private void OnFsmEnable(On.PlayMakerFSM.orig_OnEnable orig, PlayMakerFSM self)
triggerAction.collideTag.Value = "Player";
triggerAction.collideTag.UseVariable = false;
}

// Insert an action that specifically re-scales the fireball to be in line with the player's scale
// For some reason players dying in acid might mess up the future scale of fireballs
// This is the case for the "top" and "spiral" objects of the fireball

// TODO: figure out the root cause of the issue that this band-aid solution fixes. It has something to do
// with the HazardDeath animation effect playing that messes up future fireballs in the same scene.
// Although the issue already exists as soon as I try to find the FSM for the acid death object.
// Something with FSM initialization gets messed up at that point, but I'm confused why this doesn't happen
// with spike deaths or anywhere else for that matter.
if ((self.name.Contains("Fireball Top") || self.name.Contains("Fireball2 Top")) && self.Fsm.Name.Equals("Fireball Cast")) {
self.InsertMethod("L or R", 3, () => {
var hero = HeroController.instance.gameObject;
if (hero == null) {
return;
}

var heroScaleX = hero.transform.localScale.x;

var scaleFsmVar = self.Fsm.GetFsmFloat("Hero Scale");
if (scaleFsmVar == null) {
return;
}

scaleFsmVar.Value = heroScaleX;
});
}

if (self.name.Contains("Fireball2 Spiral") && self.Fsm.Name.Equals("Fireball Control")) {
self.InsertMethod("Init", 3, () => {
var hero = HeroController.instance.gameObject;
if (hero == null) {
return;
}

var heroScaleX = hero.transform.localScale.x;

var scaleFsmVar = self.Fsm.GetFsmFloat("X Scale");
if (scaleFsmVar == null) {
return;
}

scaleFsmVar.Value = heroScaleX;
});
}
}
}

0 comments on commit 6293d9c

Please sign in to comment.