hedge-dev / HMMCodes

Hedge Mod Manager community codes repository
15 stars 18 forks source link

[Bug][Sonic Frontiers] Programatically disabling the boost doesn't disable boost motion blur when moving #59

Closed mikeploythai closed 11 months ago

mikeploythai commented 11 months ago

Was playing around with the SET_STATE_FLAG method. I noticed that once IsBoost is set to false, it will disable the boost state, but doesn't disable the motion blur while moving, whether that's on the ground, on a rail, airborne, etc. The only way to disable to filter is to do something that invokes the filter in the first place (ex. doing a spin boost will remove the blur once it's exited)

Context for snippet - Let the player boost for up to 500ms if they're rail grinding

// Disables boost except when the player is airborne or grinding
if (IS_STATE_FLAG(IsGrind) || !Player.Status.IsGrounded())
  Lua.Call("SetPlayerAbilityEnabled", "Boost", true)
else
  Lua.Call("SetPlayerAbilityEnabled", "Boost", false)

// Limits boost time to 0.5s while grinding
if (IS_STATE_FLAG(IsGrind) && IS_STATE_FLAG(IsBoost)) {
  // For debugging; custom method I made in a separate library
  string timerLabel = "GRIND BOOST TIMER";
  var elapsedTime = Counters.GetElapsedTime(timerLabel);

  if (elapsedTime >= 0.5f) {
    SET_STATE_FLAG(IsBoost, false);
    ResetElapsedTime(timerLabel);
  }
}

Janky counter library I made if you want to test the snippet above on your end w/o errors

Library "Counters" by "cali_burrito"
{
  #lib "Time"

  private static float _elapsedTime = 0f;
  private static bool _isTimerReset = true;

  public float GetElapsedTime(string in_timerLabel) {
    _isTimerReset = false;
    _elapsedTime += Time.GetDeltaTime();
    Console.WriteLine($"{in_timerLabel}: {_elapsedTime}s");

    return _elapsedTime;
  }

  public void ResetElapsedTime(string in_timerLabel) {
    if (!_isTimerReset) {
      _elapsedTime = 0;
      Console.WriteLine($"{in_timerLabel}: TIMER RESET");
      _isTimerReset = true;
    }
  }

  public void GetTrackedValue(string in_trackerLabel, float in_value) {
    Console.WriteLine($"{in_trackerLabel}: {in_value}");
  }
}
DeaTh-G commented 11 months ago

SET_STATE_FLAG replicates how the game sets these flags itself, via calling the set function of the csl::ut::Bitset<uint64_t> (BitSet64 in HMMCodes) variable type on app::player::BlackboardStatus with the flag we want to set.

This is to say, that this issue is not really a problem with the HMMCodes BlackboardStatus.hmm library, and thus, its not really a HMMCodes issue.

mikeploythai commented 11 months ago

Thanks for the clarification! If I ever decide to join the HMM server, I'll probably ask about the specific flag for the blur, if it exists. For now, I'll just refactor the solution to increase the boost consumption time while grinding rather than setting the boost flag on and off 👍