diff --git a/HKMP/Fsm/FsmPatcher.cs b/HKMP/Fsm/FsmPatcher.cs index fc6f819b..a74be040 100644 --- a/HKMP/Fsm/FsmPatcher.cs +++ b/HKMP/Fsm/FsmPatcher.cs @@ -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; + }); + } } }