Getting EngineBoost and/or assigned key inputs from rF2 engine to plugin

Discussion in 'Plugins' started by cosimo, Aug 5, 2015.

  1. cosimo

    cosimo Registered

    Joined:
    Apr 14, 2013
    Messages:
    823
    Likes Received:
    94
    I'm trying to work on a new plugin and need to know either:
    • when the player presses the assigned key/joy/button to change the engine boost (IncrementBoost, DecrementBoost)
    • which engine boost level is currently used and which range is available for the current mod, f.ex. Current Boost 2 over available values of 1, 2 and 3.

    I poked CheckHWControl() but I don't think that's what I need.

    Any idea?
    Thanks!
     
  2. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    7,354
    Likes Received:
    3,061
    I think CheckHWControl is what you want.

    You can pick up the starting (setup) boost setting from the garage setup file (it gets created in the current player folder, which is also where the CustomPluginOptions.JSON gets created, so if you read its path from InternalsPluginV04::SetEnvironment (EnvironmentInfoV01.mPath[1]) and replace "CustomPluginOptions.JSON" with "tempGarage.svm" you've got the garage setup, which is written every time the player jumps into the car), reading [ENGINE] : EngineBoostSetting (bear in mind it'll be //commented if default, so you might want to manually parse it).

    From there you can use CheckHWControl() to check for IncrementBoost and DecrementBoost being pressed (incoming value will be ~1.0) and keep track of the overall boost setting. I'm pretty sure those inputs won't register if the player tries to change boost but can't (e.g. they press IncrementBoost but they're already on full) but would be worth checking.

    Drawbacks apart from that:
    - Can't tell the overall available range
    - There's the approx. 1 second plugin startup delay, potentially they could change boost before the plugin can see the input... but if they're using the plugin for information that would be a silly thing to do!


    Unfortunately I think that's about your only option, without starting to allow for specific mods or trying to pull out mod files to read the boost parameters for the current car. Depends how critical it is really :) (you could also 'learn' the boost ranges based on the vehicle class, so the player can improve the plugin's accuracy by running through the whole boost range and letting the plugin see it and store the range...)
     
  3. cosimo

    cosimo Registered

    Joined:
    Apr 14, 2013
    Messages:
    823
    Likes Received:
    94
    Thanks Lazza, that's great info.

    Question: I saw that CheckHWControl() fires every so often with "IncrementBoost" and "DecrementBoost" even when I'm not pressing them.
    When you say "incoming value will be ~1.0", does that mean that the float value will be zero if the buttons are not pressed?
    Besides, is the purpose of CheckHWControl() documented anywhere? Interface is confusing because it seems like it would allow the plugin to change values, but then in the comments it says it really doesn't allow that, cause it would be cheating.
     
  4. cosimo

    cosimo Registered

    Joined:
    Apr 14, 2013
    Messages:
    823
    Likes Received:
    94
    Answering to myself here. Yes, it works that way.

    Unfortunately, I also saw that CheckHWControl() fires with a fRetValue=1 even if EngineBoost is already at max setting and you try to increase it.
    It's just a "dumb" event fired, there's no connection to the actual engine boost setting.
    I've scoured the InternalsPlugin source code for something that hinted at EngineBoost, with no success.

    ...
     
  5. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    7,354
    Likes Received:
    3,061
    Jeez, that's a shame. I think I was getting confused with memory peeking in rF1, where certain addresses only change when an actual change occurs rather than for the raw input. That rather puts a dampener on things.

    As far as inputs, you can switch on a lot of the inputs from a plugin but none of the ones that could affect driving.
     

Share This Page