Dedicated Server - Dynamic Race Bot [DRB]

Discussion in 'Automobilista 2 - General Discussion' started by Svenny, Dec 25, 2023.

  1. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    Hi All,
    Over the last couple of weeks I've been playing around with the LUA scripting for the dedicated server.
    Based on some suggestions over in the dedicated server thread regarding dynamic rotations of combos I decided to have a go and make something.
    Dynamic Race BOT or DRB.
    Using the sms_rotate lua scripts as a basis, I've now got a lua addon for the dedicated server that can do the following:
    • Dynamically select vehicles or classes and tracks for the next race weekend bypassing the need to setup multiple rotations.
    • Dynamic rotation selection if you still want finer controls.
    • Random weather slots for P/Q/R sessions.
    • Weather event probability, ie LightRain per total rotations, single rotation or per session.
    • Weather weights (Higher weights = more likely to occur)
    • Weather exclusion - assign zero weight.
    • Random Weather for random slot selection.
      • It will either select a weather event up or down from that slot dynamically to fill surrounding slots.
      • The Session length is also used to control the weather progression if not overridden in the setup/config. Race progression and Weather progression are synced.
    • Option for Race Date to be the current DS system date.
    • Option for session start times to be randomly selected and based on surrounding session times.
    • DRB will also send an ingame chat message to all members when the race has ended with the next race weekend combo.
    • Dynamic Dates for each race weekend. [Released in v0.2]
    • Server Admin commands like skip combo [in lobby], advance session, restart server. [Released in v0.2]
    • Multiclass options and slots [Released for v0.3]

    Future planned additions:
    • Auto add any new tracks and/or vehicles to config lists on startup.
    • Let me know.

    How to install on dedicated server:
    • Download and unzip
    • Copy the ams2_drb into the dedicated server lua folder.
    • Make a backup of your server.cfg. ie server.bak
    • Open up the server.cfg file and ensure enableLuaApi is true and add ams2_drb to the luaApiAddons section.
    Code:
    enableLuaApi : true
    luaAddonRoot: "lua"
    luaConfigRoot: "lua_config"
    luaOutputRoot: "lua_output"
    luaApiAddons : [
        "sms_base",
        //"sms_rotate",
        //"sms_motd",
        //"sms_stats",
        //"ams2_bot",
        "ams2_drb",
    • Further down in the server.cfg, ensure controlGameSetup is true and sessionAttributes between the two { } brackets can be cleared as these attributes get loaded by the default settings. Save when done.
    Code:
    allowEmptyJoin : true
    controlGameSetup : true
    sessionAttributes : {
    // Session Attributes are assigned from DRB and DRB's defaults.
    }
    • Now start the server, leave for a few seconds and shutdown. This will copy over the default DRB config settings [ams2_drb_default_config.json] into the lua_config folder [ams2_drb_config.json] which you can now edit to your liking.
    • There are so many options to play around with but I've left comments in from the sms_rotate base but have also added more to hopefully help self document what each one does.[ More to come]
    • The default should work OOTB and help you get started quickly.
    Any future updates will be posted here and as always your feedback is welcomed.

    Changelog:

    v0.3 ALPHA

    Note: Existing ams2_drb_config.json files in lua_config folder will be backed up and new config copied across as there is a version change

    Minor Bug Fixes:
    • Some code clean-up, fail safes/validation, etc added.
    New Features:
    • Added Multiclass options now. Select upto 10 or set to zero to have DRB randomly select slots between 1-10 for sessions.
    • Added more/missing options and help text to the default setups. Scheduled FCY and Damage Random Failures.


    v0.2 ALPHA
    Note: Existing ams2_drb_config.json files in lua_config folder will be backed up and new config copied across as there is a version change

    Main Bug Fixes:
    • Some code clean-up, fail safes/validation, etc added
    • Setting to random vehicles now works
    • Issue with track grid size persistence instead of resetting to defaults
    • Temporary work around to first random number generated would be the same for first function to call this. Would only notice on consecutive server restarts.
    New Features:
    • Assign server admins via steamid in config to have some additional controls via in game chat for admins.
      • + : when in lobby, admin can skip dynamic combo to generate new combo
      • advance : this will advance session practice > qualify, qualify > race. If advance in race, this restarts race
      • reset : soft restart of server - destroys session.
    • Disabling the dynamic weather system ( "enable_dynamic_weather_system" : false,) will revert back to real-time weather and zero slots
    • Added dynamic race date selector [ "use_dynamic_date" : true,] that randomly selects date between now and default race date on track. This will take precedence over using current date if set to true.
    • Added some additional messages [community and voice chat info] to be displayed to all users when joining or returning to lobby

    v0.1 APLHA
    - Initial Release
     

    Attached Files:

    Last edited: Dec 28, 2024 at 1:16 AM
    • Like Like x 5
    • Winner Winner x 2
  2. Asturbo

    Asturbo Member AMS2 Club Member

    Joined:
    Apr 8, 2017
    Messages:
    44
    Likes Received:
    48
    Amazing
     
    • Like Like x 1
  3. BrunoB

    BrunoB TT mode tifosi BANNED

    Joined:
    Jun 13, 2020
    Messages:
    2,582
    Likes Received:
    651
    Are these not´s intended or are they typos that should have been now´s?
     
    • Funny Funny x 1
  4. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    updated now. A little too much christmas cheer for me, plus it was 1am...
    there will be a few more hidden gems like this no doubt!
     
    Last edited: Dec 26, 2023
    • Like Like x 1
    • Funny Funny x 1
  5. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    So I've just update DRB - Check opening post for more details.

    As my understanding of the possibilities we could have with the lua api and getting way ahead of myself.... I have some potential new ideas/thoughts to either include in this add on (~1000 lines of code so far...) or split into separate lua add on..not sure yet.

    These could be (should this be popular):
    ? Player stats like completed races, total laps, podiums, ranking etc
    ? Track/combo records i.e. fastest lap
    ? Customisable Points/rating system.

    At this point it's only stored on the actual DS in a file, however there might be opportunity to upload such data to a central portal...

    PS: I've updated one of my servers with new DRB, just search for "DRB" in server browser if you want to see it in action.
     
    Last edited: Dec 30, 2023
    • Useful Useful x 1
  6. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    ** UPDATE **

    >>Download<<

    v0.3 ALPHA

    Note: Existing ams2_drb_config.json files in lua_config folder will be backed up and new config copied across as there is a version change

    Minor Bug Fixes:
    • Some code clean-up, fail safes/validation, etc added.
    New Features:
    • Added Multiclass options now. Select upto 10 or set to zero to have DRB randomly select slots between 1-10 for sessions.
    • Added more/missing options and help text to the default setups. Scheduled FCY and Damage Random Failures.
     
  7. Florent.Neron

    Florent.Neron New Member

    Joined:
    Feb 18, 2024
    Messages:
    20
    Likes Received:
    3
    Hi,
    this looks great! Can't wait to try it! Is the project still being followed?
     
  8. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    Thanks and yes it is. Currently one thing I'm working/thinking through on is a better way to manage car/class/track selections as this is very manual at the moment but works. I'll also upload onto github in the next few weeks, just to make managing things a little easier..
     
    • Winner Winner x 1
  9. Diesels

    Diesels New Member

    Joined:
    Friday
    Messages:
    3
    Likes Received:
    0
    How do you enable Multiclass? If i set "enable_dynamic_multi_classes" to true i get the lua error: attempt to call a nil value ('global_number') and nothing works.
     
    Last edited: Dec 27, 2024 at 11:17 PM
  10. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    Hi - In the config file, have you set "enable_dynamic_vehicle_classes" to false? Example below.

    Code:
        "enable_dynamic_combos": true,
        "enable_dynamic_vehicles" : false,
        "enable_dynamic_vehicle_classes" : false,
    
        // Allow Multi class/track day sessions
        "enable_dynamic_multi_classes" : true,
        // Max is 10. Set to zero for DRB to randomly select number of slots
        "enable_dynamic_multi_classes_count" : 10,
    The code should handle this by setting "enable_dynamic_vehicle_classes" to false if multiclass is selected.
    I've been tweaking the main lua file recently and have updated the main download zip which also might fix a few other minor issues. Can you give the latest version a try and see if that resolved your issue?
     
    Last edited: Dec 27, 2024 at 11:52 PM
  11. Diesels

    Diesels New Member

    Joined:
    Friday
    Messages:
    3
    Likes Received:
    0
    Hi
    this update resolved the issue, now multiclass works! But there is a small issue in that the skip function via ingame chat does not work anymore. I had no problems with that before. New config file an steam ID is set.
     
  12. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    Excellent...Oh..I simplified the skip to be a + symbol now.
     
    • Like Like x 1
  13. Marius H

    Marius H Probationary forum-moderator Staff Member AMS2 Club Member

    Joined:
    Mar 24, 2016
    Messages:
    6,076
    Likes Received:
    2,685
    Corrected a typo in the title for you. :cool:
     
    • Like Like x 1
  14. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    Thankyou!
     
    • Like Like x 2
  15. Mikk Schleifer

    Mikk Schleifer Active Member AMS2 Club Member

    Joined:
    Nov 30, 2019
    Messages:
    197
    Likes Received:
    177
    Great job Svenny, keep on going, installed and amazed !!:)
    Is it possible to add the Kick/ban function for ingame chat too ?
    Multiclass doesnt work for me too, setup like you told but always one class
    to select from, strange.
    Do i have to predefine the multiclass slots maybe?
    That would be nice for single classes too, 10 predefined
    classes with suitable track and weather.

    greetings Mikk
     
    Last edited: Dec 28, 2024 at 2:09 PM
  16. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    Thanks!. Yep kicking a player is possible. Is it a high ping kick (lagging/etc) or a simply a driver isn't playing nice?
    PS: I've got a version in the works that also adds some AI Drivers should users want that as well.
     
  17. Mikk Schleifer

    Mikk Schleifer Active Member AMS2 Club Member

    Joined:
    Nov 30, 2019
    Messages:
    197
    Likes Received:
    177
    Nice, kicking for both reasons would be top, AI add on the fly too, i started conversation btw.
     
  18. Diesels

    Diesels New Member

    Joined:
    Friday
    Messages:
    3
    Likes Received:
    0
    So i am testing around with the skip fuction and some weather settings.
    Sometimes when i skip i get this message: "oops...no weather supplied to weather_type_selector for 1 slot for stage Race. using default of MediumCloud."
    And it seems like some weather with high weight does not show up at all.
    My weather section looks like this:

    Code:
    "practice_weather_slots_max" : 3,
    "qualify_weather_slots_max" : 1,
    "race_weather_slots_max" : 4,
    
    "weather_weight" : {
            "Hazy" : 2,
            "Clear" : 15,
            "LightCloud" : 12,
            "MediumCloud" : 10,
            "HeavyCloud" : 9,
            "Overcast" : 10,
            "LightRain" : 0,
            "Rain" : 0,
            "Storm" : 0,
            "ThunderStorm" : 0,
            "Foggy" : 3,
            "FogWithRain" : 0,
            "HeavyFog" : 2,
            "HeavyFogWithRain" : 0,
            "Random" : 0,
    I only ever see, Clear, a lot of light cloud, hazy and foggy. None of the other weather types.
     
  19. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    yes..I'm not sure why this occurs as its not all the time during my use, so it might simply be code/time execution delay. Marked to recheck anyway...

    I'll try your settings and see what's going on and get back to you.

    Thanks for the feedback.
     
  20. Svenny

    Svenny Member

    Joined:
    Jul 25, 2023
    Messages:
    32
    Likes Received:
    29
    As for high ping, I've already created a stand alone lua addon - See this post HighPingKicker
     
    • Like Like x 1

Share This Page