Introduction to scenarios creation

Discussion in 'Content Creation' started by Nadeox1, Jul 14, 2015.

  1. Peepsed

    Peepsed
    Expand Collapse

    Joined:
    Jul 12, 2015
    Messages:
    14
    I've been trying to make a simple drag race scenario but I'm having a hard time. As far as I can tell, there are no "goals" that detect when the AI has passed a waypoint? I just want the scenario to fail the user if the AI car passes a waypoint first.

    And since I'm here, is there anyway to allow the players car to rev beyond about 2500 rpm during the scenario count down?
     
    #201 Peepsed, Sep 13, 2017
    Last edited: Sep 13, 2017
  2. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    I created a race scenario but my AI car won't drive, here is my .prefab and .json file. Much of it is copy pasted from the drag race scenario from jungle rock island, the scenario im creating is in Hirochi Raceway.


    Yellow AI car wont drive
    AICar.png

    .json
    Code:
    [
    {
        "name": "scenarios.jungle_rock_island.drag_race.title",
        "description": "scenarios.jungle_rock_island.drag_race.description",
        "authors": "BeamNG",
        "difficulty": "55",
        "date": 1456401873,
        "levelObjects": {
            "tod" : {
                "time" : 0.85,
                "dayLength" : 120,
                "play" : false,
                },
          
        },
        "blackListActions": ["toggleShifterMode"]
        "lapConfig": ["wp_player_target"],
        "radiusMultiplierAI": 3,
    },
    ]
    .prefab
    Code:
    //--- OBJECT WRITE BEGIN ---
    $ThisPrefab = new SimGroup() {
       canSave = "1";
       canSaveDynamicFields = "1";
          groupPosition = "0.000000 0.000000 0.000000";
    
       new BeamNGWaypoint(wp_target_distance) {
          drawDebug = "0";
          position = "-350.248993 169.878006 24.8045006";
          rotation = "1 0 0 0";
          scale = "1 1 1";
          canSave = "1";
          canSaveDynamicFields = "1";
       };
       new TSStatic() {
          shapeName = "levels/jungle_rock_island/art/shapes/race/race_rally_finish_checkpoint_red.dae";
          playAmbient = "1";
          meshCulling = "0";
          originSort = "0";
          useInstanceRenderData = "0";
          instanceColor = "White";
          collisionType = "Collision Mesh";
          decalType = "Collision Mesh";
          allowPlayerStep = "1";
          prebuildCollisionData = "0";
          renderNormals = "0";
          forceDetail = "-1";
          position = "684.166 -550.067 160.5";
          rotation = "0 0 1 141.857";
          scale = "1 1 1";
          canSave = "1";
          canSaveDynamicFields = "1";
       };
       new TSStatic() {
          shapeName = "levels/jungle_rock_island/art/shapes/race/race_rally_finish_checkpoint_red.dae";
          playAmbient = "1";
          meshCulling = "0";
          originSort = "0";
          useInstanceRenderData = "0";
          instanceColor = "White";
          collisionType = "Collision Mesh";
          decalType = "Collision Mesh";
          allowPlayerStep = "1";
          prebuildCollisionData = "0";
          renderNormals = "0";
          forceDetail = "-1";
          position = "707.797 -530.368 160.193";
          rotation = "0 0 1 139.809";
          scale = "1 1 1";
          canSave = "1";
          canSaveDynamicFields = "1";
       };
       new BeamNGWaypoint(wp_player_target) {
          drawDebug = "0";
          position = "-386.574005 236.376999 24.9909";
          rotation = "1 0 0 0";
          scale = "6 6 6";
          canSave = "1";
          canSaveDynamicFields = "1";
       };
       new BeamNGWaypoint(wp_ai_target) {
          drawDebug = "0";
          position = "-386.574005 236.376999 24.9909";
          rotation = "1 0 0 0";
          scale = "6 6 6";
          canSave = "1";
          canSaveDynamicFields = "1";
       };
       new BeamNGVehicle(aiCar) {
          JBeam = "sbr";
          color = "0.996078 0.960784 0.00392157 1.248";
          colorPalette0 = "White";
          colorPalette1 = "0.5 0.5 0.5 0";
          colorPalette2 = "White";
          colorPalette3 = "White";
          partConfig = "vehicles/sbr/hillclimb.pc";
          renderDistance = "500";
          renderFade = "0.1";
          isAIControlled = "0";
          dataBlock = "default_vehicle";
          position = "-390.542633 251.309128 25.2136135";
          rotation = "0.0859509 0.00601851 -0.996281 40.9113";
          scale = "1 1 1";
          canSave = "1";
          canSaveDynamicFields = "1";
       };
       new BeamNGVehicle(scenario_player0) {
          JBeam = "sbr";
          color = "0.0784314 0.109804 0.568627 1.132";
          colorPalette0 = "White";
          colorPalette1 = "White";
          colorPalette2 = "White";
          colorPalette3 = "White";
          partConfig = "vehicles/sbr/hillclimb.pc";
          renderDistance = "500";
          renderFade = "0.1";
          isAIControlled = "0";
          dataBlock = "default_vehicle";
          position = "-397.632874 253.663025 25.2136135";
          rotation = "0 0 -1 40.5897";
          scale = "1 1 1";
          canSave = "1";
          canSaveDynamicFields = "1";
       };
    };
    //--- OBJECT WRITE END ---
     
    #202 ThreeDTech21, Sep 19, 2017
    Last edited: Sep 19, 2017
  3. Gavril T85

    Gavril T85
    Expand Collapse

    Joined:
    Aug 14, 2017
    Messages:
    635
    (slight bump) Ok, I found out the answer to my other question. But whenever I repack the scenario folder thingy, It doesn't ask me where to save it to. Everything else about it seemed to work, until I reloaded it with all seven of my checkpoints (since it didn't save a .prefab AFIAK, I filled in the waypoints section myself.) None of the checkpoints were there except the first one, but when I went into the level editor, all the yellow sphere checkpoint thingies were where I put them. Here are some pictures to help:
    How I set it up in Notepad++
    Untitled.png

    Showing my Waypoints
    20171030171846_1.jpg
     
  4. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,683
    Some things changed since I wrote this guide.
    The prefab saving should happen correctly in Documents/BeamNG.Drive/levels now.

    As for your problem, please note 'waypoints' vs 'Waypoints'.
    It's case sensitive IIRC.
     
    • Informative Informative x 1
  5. Instant Winrar

    Instant Winrar
    Expand Collapse

    Joined:
    Jun 12, 2015
    Messages:
    697
    Scenarios and Time Trials seem pretty similar in-game, and in the game files. Are there are any major differences between the two that I should know about?
    I can't find a guide or any information at all on the creation of Time Trials, but I don't see them being much different than Scenarios - That's why I'm asking in this thread.

    I have several scenarios I made for personal use that are simply short circuits that I wanted to time myself around, so I feel like turning some into Time Trials as I'd have a leader board of my results.
     
  6. RyvyLo

    RyvyLo
    Expand Collapse

    Joined:
    May 15, 2014
    Messages:
    438
    They are indeed pretty similar, and the creation process is the same. There are some differences though, if i remember correctly the main differences are :
    - The folder they're in
    - In the .prefab, the player position is no longer 'scenario_player0', it's represented by various spawn spheres for each case (normal, rolling start, etc...). The best thing to do is to copy-paste a spawn-sphere from an existing quickrace and change it's name.
    - In the .json the 'vehicle' field is no longer needed, and a bunch of new fields are in place
    - There are brackets on the .json that are here on scenarios and not in quickrace

    Anyway, it's easy to port scenarios to quickraces, the best way to do it is to open official files on one side and your scenario files in the other, then play a game of spot the differences. The name of the fields are pretty clear, so it should be easy to guess what the new functions does.

    EDIT : You could also check my Juggernaut scenarios, they have scenarios and quickraces for the same track, so it will be even faster to spot the differences.

    And while I'm at it, here are some useful things about quickraces :
    - prefab named yourQuickraceName_forward and yourQuickraceName_reverse are only loaded when the quickrace is not in reverse for the 1st one, and in reverse for the second one. Useful for signs for example
    - If you want to have custom lua extensions, the game looks for the .lua file to load in levels\theLevel\theQuickraceName.lua, and not in levels\theLevel\quickrace\theQuickraceName.lua. It doesn't work like the scenarios that looks in levels\theLevel\scenarios\theScenarioName.lua.
     
    #206 RyvyLo, Nov 8, 2017
    Last edited: Nov 8, 2017
  7. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    Thanks Nadeox1 for a wonderful tutorial for how to create a scenario. just one doubt, how can I include my "mod" vehicles in the scenarios. I remember when I went to try for first time it was telling to specify the correct path. Please help....
     
  8. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    Nadeox1 how to enter date after creating your own scenario?? when i tried to enter date normally it didn't accept. is there any special method to enter the creation date?o_O
     
  9. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,683
    Dates are based on unix timestamp.
    Simply go here, and copy/paste the current unix time:
    https://www.unixtimestamp.com/
     
    • Like Like x 1
  10. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    Thanks Nadeox1;). One more doubt I have how to create races with 4 or 5 opponents in scenarios? Do you have any tutorial on this? 'cause half coding is done in Lua and i don't know how to do it??:confused:
     
  11. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    Please help, something gone wrong while making my scenario, the car i want to place is not going smooth...seems like I pressed a wrong key by mistake!! See the video i have uploaded
     

    Attached Files:

  12. RyvyLo

    RyvyLo
    Expand Collapse

    Joined:
    May 15, 2014
    Messages:
    438
    It seems like you enabled grid snapping. Clicking on the icon I circled should fix the problem.
    Capture.png

    About the AI races, yes you will have to do some coding in Lua. I would recommend making a bunch of simpler scenarios (point A to B races) before to familiarize yourself with the scenario creation process.
     
    • Like Like x 1
  13. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    Thanks for your help! RyvyLo.
    about the AI races i'm just skeptical :confused:. i copy and paste the codes from other scenarios but AI is in no mood to race with me
     
  14. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    hey does anybody know the lua programming for a police scenario where we have to chase two suspects. I want to make this scenario...i'm excited but the programming part is making me nervous!!:(:confused:
     
  15. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    I have some code for that. Paste this in a blank lua file: https://pastebin.com/0CUgEfuj

    This code supports 3 evading suspects. I could make this more automatic, but I'm too lazy right now; I put this together really hastily. Make sure you edit the "nonPlayers" line. Don't forget to remove the "goal purpose = win" line in your json file. Also, the lua file has to be named the same as the other scenario files.
     
    • Like Like x 1
  16. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    --- Post updated ---
    so like always im trying to create a race with one opponent same like the scenario "Mountain Race". but problems are not leaving me the AI only goes through 3 checkpoints (ignoring rest of the 16 checkpoints)o_O and retrieves to the starting line again.. i don't know what is the reason behind this??:confused: i copied the same lua code which was for the WCUSA's Mountain Race and made some changes but still it is the same. View the video down:

    ALSO THANKS GAMERGULL FOR THE EVADING SUSPECTS LUA CODE :)
     

    Attached Files:

  17. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    I've always wanted to make my own races, so I'll try to help. I set up a test scenario, copied the code, and modified it to match my object names. It seemed to work fine. Double check your waypoint names, I guess?

    (By the way, I think I found a bug! There's no "aiInstance" variable declaration in the original mountain race code. It won't detect the AI if it wins.)
     
    • Like Like x 1
  18. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    I created a police chase with two opponents successfully; all thanks to you Gamergull for providing the Lua code;). next i want to create a race with 3 opponents..currently working on it
     
  19. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    I have created my scenario "west coast chase series" and posted it under scenarios category..it is displaying some message that your mod is currently awaiting approval......what does that mean??
     
  20. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    Ah, that's normal. One of the staff has to play and approve your mod to make sure that it works for everyone and is of decent or better quality. The staff can be busy, so this takes up to a week. It can be hard to contain your excitement (sure was for me! lol) but eventually, you get a message of approval.

    I like police chases, I'll be sure to check it out.
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice