1. Stuck or having problems creating your mod?

WIP Beta released Suspect Pursuits Scenario Pack V1.1.1

Escape police vehicles in different locations

  1. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    Darthbob555 submitted a new resource:

    Suspect Pursuits - Escape police vehicles in different locations

    Read more about this resource...
     
  2. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    Following some noticeable issues, I have decided that removing the trees from the scenarios is the best option. Please let me know if this is a problem - I have already seen big FPS increases and much better AI chases so far. Update coming shortly (under review). Thank you :)
     
  3. MattKowalski

    MattKowalski
    Expand Collapse

    Joined:
    Aug 23, 2013
    Messages:
    73
    Thanks for making these, it's a good start and I know the AI isn't fully developed yet.
    "Run to the hills" works 90% of the time, and if you wait for the AI in the first half it actually is pretty fun towards the end, because it can keep up much better in the uphill section.
    "Hard target" doesn't really work, the ETK moves, but just points toward you, regardless of what's in front of it. Which made it unexpectedly scary a couple of times, when I thought the AI was stuck and instead it just popped out from the bushes right in front of me at full speed :-D Otherwise it sadly does not make for long chases.
    "Blacklisted" is simply broken for me. Neither AI cars move at all. Tried to clear the cache, reinstalled and restarted. Nothing :-(

    Still, I'm happy you made these scenarios, they can only get better!
     
  4. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    Quick update - hit a snag with deleting the trees. I believe that the only resolution is to upload a deforested version of the tracks and then have the scenarios take place at those maps and not the default one. The update has, unfortunately, been pushed back. Not sure how long but I just wanted to let you know why it is taking a long time.
    Thank you for your patience :)
     
  5. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    Have you tried using Lua to delete the forest object on scenario start?
     
  6. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    I have not, I am not very experienced with Lua though know a little bit. I have hit a new snag now so I would be interested to how Lua could help. I would be grateful for any information on how to do such a thing.
     
    #6 Darthbob555, Jun 15, 2016
    Last edited: Jun 15, 2016
  7. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    Lua has the TorqueScript.eval function that allows you to run TorqueScript code. If you run something like:
    Code:
    if forest exists
        delete forest
    on scenario start, that should solve your problem. I'm not sure how experienced you are with Lua and TorqueScript, so I'm not sure how much information you need. Feel free to ask if you need more info, though.
     
  8. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    I'm not very acquainted with Lua at all really. I have had a look at your jungle rock island flooding scenario for some guidance but am confused as to where "Ocean" comes from. Can you literally just write "theForest.delete"?

    So far I have this:

    local function onRaceStart()
    TorqueScript.eval([[
    theForest.delete()
    ]])
    end

    I have had a quite read about the TorqueScript.eval function but that just confused me more. I know I haven't added in a check for the forest yet but the code didn't yield any results in the scenario so I left that out.
    Thanks for the help ;)
     
    #8 Darthbob555, Jun 16, 2016
    Last edited: Jun 16, 2016
  9. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    You're sooo close: TS requires its statements to be terminated with a semicolon.
     
  10. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    OK, so I did that and added the semicolon after the delete function but now I have a new problem - I don't think that the game is realising that the scenario has a lua file. I put it into the scenarios folder where the JSON file is but no luck. Do I need to call it from within the .JSON file?
     
  11. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    First: the Lua is automatically loaded as long as it has the same name as the .json, so for blacklisted, it needs to be called "blacklisted.lua". You can also reference Lua scripts directly, by placing them in "mod.zip/lua/scenario", and adding an "extensions" array property to the .json file. Note that if no extension is specified, the game automatically loads the "race" extension, and as you (probably) still need this, your json should now contain something like:
    Code:
    "extensions": [ "race", "forest_deletion" ]
    Second: simply declaring the "onRaceStart" function is not enough: your Lua file needs to return an object that contains it. This object is then loaded in by the game, and the functions on it are registered to be called when needed. So your Lua needs to look something like this:
    Code:
    -- This is the object (module) we will return
    local M = {}
    
    -- What we call the function here doesn't matter
    local function deleteForest()
        TorqueScript.eval("theForest.delete();")
    end
    
    -- Add it to the module, with the correct name
    M.onRaceStart = deleteForest
    
    -- Return the module
    return M
    How you build this object precisely doesn't matter, all that matters is that the correct object is returned. This script would do the exact same thing:
    Code:
    return { onRaceStart = function() TorqueScript.eval("theForest.delete();") end }
    Third: "onRaceStart" is called when the race starts: i.e., after the countdown. You probably want the forest to be deleted as soon as possible, so you probably want to hook into "onClientStartMission", which is called directly after the level finishes loading.
     
  12. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283

    Thank you so much for the information! However, I am still having a few issues. I have changed the code layout and called the function from different sections in the code but no luck.

    Here is the final version of the code that I have ended up with:

    Code:
    local M = {}
    
    local function onClientStartMission ()
        deleteForest();
    end
    
    local function deleteForest()
        TorqueScript.eval("theForest.delete();")
    end
    
    M.onRaceStart = deleteForest
    
    return M
     
  13. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    First: Lua is an interpreted language: it reads the file from top to bottom and executes it while it does so. When it gets to the deleteForest(); line, it hasn't read the the deleteForest function yet, so it will give an error. Declare any functions and variables before using them.

    Second: The name on the returned object is what makes the function "get called". You're still assigning your function to M.onRaceStart, so it will still get called on race start.
     
  14. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    Thank you SO much :). It works! :)

    One thing I have noted is that sometime the car crashes into an invisible wall, presumably a tree. I have done "theForest.hdden = "1"; but it doesn't seem to work.
     
    #14 Darthbob555, Jun 17, 2016
    Last edited: Jun 17, 2016
  15. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    Setting "hidden" to true ("1") simply makes the object invisible. That's why you're calling "delete": that actually removes the object and gets rid of collision too. If you're still running into invisible objects, then either A) the forest isn't getting deleted correctly or B) there's an actual, non-forest, invisible object there. It'd help if you could determine what you're running into (using the editor, or just remembering the location and then checking with the forest enabled).
     
  16. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283

    I have gone into the editor where the car is hitting an object however the editor cannot find any object there. I can confirm that the places in which the car hits is where a tree would normally be.

    Edit:
    I've had more of a poke around. I tried moving theTerrain and it worked. However, the game does not realised it has been moved so only visually shows this. The car then falls through the terrain (as it appears) and acts as though it is on the original terrain location. Should I be calling it on another trigger? I have had it in some game programming that maybe the changes are only being sent to the client (all the visuals and graphics) but on the server side, the location of the terrain has not changed as the changes are not called on the server side. Not sure how BeamNG does their rendering/graphics so I don't know whether this is relevant.

    Second Edit:

    I think I have found the culprit! It MUST be only running on the client side as the function is called by onClientStartMission. This would cause the client to see the trees gone but the server to still think they are there. Again, this might not apply but it seems like a likely culprit to me.
     
    #16 Darthbob555, Jun 17, 2016
    Last edited: Jun 17, 2016
  17. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    I've further look at this issue for some time but cannot find a solution. I have tried calling it on different functions at different times but it does not want to work. Moving the terrain would also work so that the trees are under the terrain and therefore not a problem but it does not want to recognized that it has been moved by the server. Is there another event/function I can call the removal of the forest on?
     
  18. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    It's just a matter of the game not automatically reloading the collision data when the forest is removed, call be:reloadStaticCollision() (in Lua) after deleting the forest to ensure it does get reloaded (thanks to @LuisAntonRebollo for the function).
     
  19. Darthbob555

    Darthbob555
    Expand Collapse

    Joined:
    Feb 14, 2016
    Messages:
    283
    Thank you for the reply. I have called the command using: be:reloadStaticCollision();
    That did not work so I tried just: reloadStaticCollision();
    Am I calling the command incorrectly or is it not working at all?

    The whole code:

    Code:
    local M = {}
    
    local function deleteForest()
        TorqueScript.eval([[
                theForest.delete();
                be:reloadStaticCollision();
            ]])
    end
    
    local function onClientStartMission ()
        deleteForest();
    end
    
    
    M.onClientStartMission = deleteForest
    
    return M
     
  20. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    605
    So:
    Code:
    local function deleteForest()
        TorqueScript.eval([[
            theForest.delete();
        ]])
        be:reloadStaticCollision();
    end
     
  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