Introduction to scenarios creation

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

  1. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    Without your help it would have been impossible to create a two suspects chase scenario. Thanks for your help Gamergull.
    And please play and review my scenario "West Coast Chase Series"
     
  2. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    I've run into a problem that I can't explain.
    I'm on the main menu, and I load my scenario via the main menu. (Bear in mind my scenario takes place on a custom map "Desert_Highway", which is in the repository.)
    The map will load, as will the scenario interface, but my car will not load and nothing else does.


    I'll get a countdown if I agree to start the scenario, but attempts to reload it by pressing "r" do nothing except freeze the timer.
    I open up my level editor, and find my scenario sitting among the other files. The scenario is unloaded.

    Upon manually loading the scenario, I get all my stuff...the car, the checkpoints, the props...even the "MUDK1P" license plate.

    So I'll hit F11 and attempt to play the game, but find that despite the game informing me there are 20 checkpoints, none of them seem to load.
    But in this case, for some reason I hit F11 and spawned in as a tire barrier...

    (Edit: I found out I misplaced a file, and this resulted in me spawning as the first thing listed...in this case, a tire barrier. So that issue has been sorted out, and I'm now spawning as the Covet, but all other issues remain.)
    I've spent several hours trying all sorts of things, including rewriting a good portion of my coding. (Bear in mind that I am an idiot with coding.) I even made sure EVERYTHING had a name.
    Here's an image of said scenario coding; let me know if there's anything amiss with it.

    (BTW, the reason that the checkpoints are counting down is because I messed up when naming everything...)
     
    #222 Dat-Mudkip, Nov 21, 2018
    Last edited: Nov 21, 2018
  3. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    • Informative Informative x 1
  4. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    @Dat-Mudkip You're missing commas at the end of the maxTime and waitTime lines. Although this doesn't usually cause fatal errors, it would be good to correct that.

    Also, try pressing tilde (~) while in gameplay, there might be an error log that can point out the issue.
     
    • Informative Informative x 1
  5. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    If you're talking about the file name, it's "my_first_scenario.prefab".
    Before you ask, it's under Documents>BeamNG.drive>levels>Desert_Highway

    Thanks for pointing out the comma issue. That's been fixed.

    The error log spat this out:


    I'm not an expert, but it looks like it cannot locate the mission file for some reason...
    It's located in Documents>BeamNG.drive>levels>Desert_Highway>scenarios, so I'm not sure what the issue is.
     
  6. arnok19

    arnok19
    Expand Collapse

    Joined:
    Jun 28, 2018
    Messages:
    279
    @Dat-Mudkip try to give the checkpoint names in this order I mean (starting from 1, 2, 3...) or if that doesn't work download a scenario pack and see how others did it. I think this will solve your problem
     
  7. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    Not to come off as rude, but what difference would it make?
    I was thinking about that just a little while ago. I may very well take a look at that.
     
  8. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    I think I know what it is. "my_first_scenario already exists in level", hmm, seems that you saved the map after you finished working on the prefab file. You have to avoid saving and only pack the prefab when you're done. To correct this, try to open the map in Freeroam mode, then edit it, and delete the prefab object from the scene tree. Don't worry, this won't delete your scenario. Hopefully this fixes things.
     
  9. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    It now works! I must've saved it by accident at some point...not sure when or why, but there we go!

    Since I got you on the line, I got two more questions:

    How do I change "skins" on a vehicle? For example, the tire barriers below...I want to change the direction the arrows are going, and I know in game you are given an option to spawn it with different skins. Could you tell me how to do that?



    My second question:
    As much as I like the Covet, there's not way this scenario will function properly with it. I want to use a semi-custom car for this scenario. The vehicle is a Sunburst with a high-performance radiator, slightly increased top speed, about half the fuel load, and it has a recolored paint scheme. Everything comes with the game, so there are no additional mods that need to be brought into question.
    Here's an image of the car:

    Once again, this is one of the default skins that was recolored in-game.
     
  10. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    Alright. So, to change the skin or configuration of vehicles, edit the partConfig line, as shown here:

    partconfig-help.jpg

    You may have to look in the game files (located within the steam/steamapps folder) to find the path of the part config you need. To help you out, here are the ones for "tirewall":
    • vehicles/tirewall/arrows_L.pc
    • vehicles/tirewall/arrows_R.pc
    • vehicles/tirewall/etk.pc
    • vehicles/tirewall/gripall.pc
    • vehicles/tirewall/hirochi.pc
    Same goes for the Sunburst, although the part config file should be found in your documents/BeamNG folder. Don't forget to edit the JBeam line in the editor to "sunburst".
     
  11. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    I keep getting an error message that "partmgmt" is unable to load the file, though it seems to be detecting the existence of said file...


    I did make sure that the custom configuration file is under vehicles/sunburst, and that the name "Modified Rally" is correct...not sure what I'm doing wrong.
    On the bright side, it is loading the bare-boned Sunburst, so at least I'm going the right direction.



    The tire barriers seem to change correctly after I reload the scenario, so why the Sunburst is not able to do the same seems strange.
     
  12. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    Alright, so it turns out I keep seriously underestimateing the amount of information Beam.NG wants before it will be cooperative.
    Bottom line is that I figured it out and fixed the issue, and now the car is showing up fine.
    To anyone reading this who wants to know how I fixed it, you may find this page useful.
     
  13. Grzybaon

    Grzybaon
    Expand Collapse

    Joined:
    Jan 31, 2019
    Messages:
    2
    Can somebody help me?
    Code:
    "speed":
    {
    "minSpeed":18,
    "maxTimeout":2,
    "wayPointNum":[1],
    "msg":"Don't slow down!",
    "purpose":"fail"
    },

    And after slowing down it counts like there is win not fail.
    I don't know what i made wrong.
     
  14. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,681
    Can you post the full .lua?
    (use the CODE tags so it does not loose the formatting please, under the + in the text editor toolbar)

    Also the game logs should say the 'purpose/reason' of wins and fails. What does it say?
     
  15. Grzybaon

    Grzybaon
    Expand Collapse

    Joined:
    Jan 31, 2019
    Messages:
    2
    I fixed problem sorry for wasting your time :)
     
    #235 Grzybaon, Jan 31, 2019
    Last edited: Jan 31, 2019
  16. NGAP NSO Shotgun Chuck

    NGAP NSO Shotgun Chuck
    Expand Collapse

    Joined:
    Mar 6, 2015
    Messages:
    1,407
    Some incredibly stupid questions:

    1. How much of this is relevant to creating pure time attacks rather than scenarios? The wiki guide for that seems to skip much of this but leaves you with no way to actually position the objects you need.

    2. I'm going to revive that old (and never-answered) questions about what you do when the map you're working with doesn't have the object you need - mod maps, custom-made objects, etc.
     
  17. Occam's Razer

    Occam's Razer
    Expand Collapse

    Joined:
    Aug 7, 2013
    Messages:
    1,152
    Quickraces use similar code, but have a different folder structure. Aside from that, it should be possible to copy the relevant files from an official quickrace and plop it into the map of your choosing, then start the quickrace in-game and adjust the prefab in the editor, same as a scenario.*

    It is possible to retrieve objects from other maps to use in quickraces. You'll have to create a folder for the level (which you'll have to do to create a quickrace anyway), then place the relevant folders and files for the object in question. Usually, this'll be the .dae file, the 1-3 texture files, and a materials.cs file pointing to those textures.**

    *not sure if that answers your question. It's pretty late, so my reading comprehension is shot atm.

    **Many materials.cs files identify official textures via absolute paths, ie "levels/utah/art/shapes/texture.dds" instead of just "texture.dds". If your object is one of the former, you won't need to copy the textures at all.
     
    • Informative Informative x 1
  18. NGAP NSO Shotgun Chuck

    NGAP NSO Shotgun Chuck
    Expand Collapse

    Joined:
    Mar 6, 2015
    Messages:
    1,407
    Sounds like it would answer my question, but due to being a complete n00b to anything involving code (and to the fact that it's pretty late here too) I'm not sure what to do with that information this moment. Figure it out some other day I guess.
     
    #238 NGAP NSO Shotgun Chuck, Feb 17, 2019
    Last edited: Feb 17, 2019
  19. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    Oh look, I'm bringing back the dead again.

    I've gotten back to Beam.NG after a long slump, and started doing scenarios again.
    For the record: DesertHighway is a messy map that may look simple, but needs a serious overhaul. Hell, I might do it myself. But that's not the point.

    I'm making a rally race that features the new Italian car.
    Here's the area that the race will finish, which is included in the map.



    I decided to *cough* "borrow" the finish boards that are used in the Utah scenario in which you pilot a rally car.
    So a little bit of poking around, and I found the file, pulled it onto the map, and...



    ..voilĂ ! Easy!
    Now my computer is a pile of junk for Beam.NG...it doesn't exactly have much RAM, so it tends to be a little laggy. While I can often push 40-60 FPS when only one vehicle is out, it can bog down quickly...especially when you consider that DesertHighway is far from optimized. I figured that, if I wanted to improve the frames a bit, I could simply replace some of the props (mostly cones and tire barriers) with some of the mesh barricades also found in the Utah Scenario I mentioned earlier...after all, I don't think it's unreasonable to as efficient as possible.
    So I did the same thing with the barricade as I did with the finish sign. (They're in the same folder, I might add.) And the result...



    ...is less than optimal. Any ideas?
     
  20. Dat-Mudkip

    Dat-Mudkip
    Expand Collapse

    Joined:
    Dec 6, 2015
    Messages:
    25
    Also, the AI for the Pigeons on one of my scenarios have crapped out, and this isn't the first scenario where this has happened. The thing I don't understand is that the scenario was working fine, but I decided to add one more vehicle via cloning it. I ensured it got a new name (and paint color). I'll dump the LUA code below; hopefully someone will tell me what I've messed up.

    (The design is a figure-eight; that's why "ppwp3" is listed twice under "waypoints".)

    Code:
    local M = {}
    
    local helper = require('scenario/scenariohelper')
    local logTag = 'pigeon_panic'
    
    local finalWaypointName = 'ppwp7'
    local playerInstance = 'secretcar0'
    local running = false
    local playerWon = false
    local aiWon = false
    local noOfLaps = 2
    local lapsCompleted = {}
    
    local function reset()
      lapsCompleted['secretcar0'] = 0
      lapsCompleted['secretcar1'] = 0
      lapsCompleted['secretcar2'] = 0
      lapsCompleted['secretcar3'] = 0
      lapsCompleted['secretcar4'] = 0
    
      running = false
      playerWon = false
      aiWon = false
    end
    
    local function fail(reason)
      scenario_scenarios.finish({failed = reason})
      reset()
    end
    
    local function success(reason)
      scenario_scenarios.finish({msg = reason})
      reset()
    end
    
    local function onRaceStart()
    
      scenario_scenarios.trackVehicleMovementAfterDamage(playerInstance, {waitTimerLimit=10})
    
        running = true
    end
    
    local function onCountdownStarted()
      reset()
    
      local arg = {vehicleName = 'secretcar1',
                  waypoints = {'ppwp1', 'ppwp2', 'ppwp3', 'ppwp4', 'ppwp5', 'ppwp6', 'ppwp3', 'ppwp7', 'ppwp1'},
                  lapCount = noOfLaps,
                  aggression = 1.1} -- aggression here acts as a multiplier to the Ai default aggression i.e. 0.7.
    
      helper.setAiPath(arg)
    
      arg.vehicleName = 'secretcar2'
      arg.aggression = 1.4
    
      helper.setAiPath(arg)
    
      arg.vehicleName = 'secretcar3'
      arg.aggression = 1.2
     
      helper.setAiPath(arg)
     
      arg.vehicleName = 'secretcar4'
      arg.aggression = 0.9
    
      helper.setAiPath(arg)
    end
    
    local function onRaceWaypointReached(data)
      --log('I', logTag,'onRaceWaypointReached called ')
      if data.waypointName == finalWaypointName then
        lapsCompleted[data.vehicleName] = lapsCompleted[data.vehicleName] + 1
        if lapsCompleted[data.vehicleName] == noOfLaps then
          if data.vehicleName == playerInstance and not aiWon then
            playerWon = true
          elseif not playerWon then
            aiWon = true
          end
        end
      end
    end
    
    local function onRaceResult()
      if playerWon then
        success('scenarios.utah.chapter_2.chapter_2_6_canyon.pass.msg')
      else
        fail('scenarios.utah.chapter_2.chapter_2_6_canyon.fail.msg')
      end
    end
    
    local function onVehicleStoppedMoving(vehicleID, damaged)
      if running then
        local playerVehicleID = scenetree.findObject(playerInstance):getID()
        if vehicleID == playerVehicleID and damaged and not playerWon then
          fail('scenarios.utah.chapter_2.chapter_2_6_canyon.fail.msg')
        end
      end
    end
    
    M.onRaceStart = onRaceStart
    M.onCountdownStarted = onCountdownStarted
    M.onRaceWaypointReached = onRaceWaypointReached
    M.onRaceResult = onRaceResult
    M.onVehicleStoppedMoving = onVehicleStoppedMoving
    return M
     
  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