WIP Beta released Part Randomizer...?

Discussion in 'Content Creation' started by umustbeloggedintododat, Apr 4, 2021.

  1. angelo234

    angelo234
    Expand Collapse
    Junior Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    429
    Yeah I've also made it so it changes parts for "all slots" rather than based on the current config's slots, because it was causing me trouble for a few vehicles. I'm also thinking of changing the "tuning"/JBeam variables for a future update and also colors would be cool too.
    --- Post updated ---
    And it looks like the mod didn't get approved yet so most likely tomorrow it will come out.
     
    • Like Like x 1
  2. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    6,833
    Finally had the time to check the update. Amazing results, works way better than old one! Here's what I got:
    • Moonhawk with twincharged Vivace engine and bus transmission and sound, powered by E85 fuel hauling a 2 ton trailer, it's ultra slow due to giant turbo lag (15hp until 2000RPM and then suddenly 500hp lol)
      sdaasdasd.png
    • Military D-Series that is normally super slow but becomes super fast with nitrous
      sdasdasd.png
    • Mattress transport Diesel Maluch
      dwdwda.png
    • Twincharged SBR4 with flail
      asdasdasddww.png
    • Weirdest Pigeon ever
      sdasddwwd.png
    • Crawler of death that drives WAY better than you might expect
      wdwd.png
    • Zombie apocalypse taxi turbo lag Bluebuck
      asdasdassa.png
    • 2000hp derby Grand Marshal that does AWD burnouts on idle lol
      sdwww.png
    • Wendover that looks like a legit config I would make for one of my mods
      wdwdassd.png
    • T-Series designed by TastiCola inc. to destroy Bepis trucks
      rgdfass.png
    • Mad Max cola delivery Barstow
      frrs.png
    • Race Miramar with 600hp twincharged Bolide engine swap
      dsasddw.png
    • And basically a combination of the above, race 200BX with caravan full of rocks, roof bars stuff, wheelie bar, twincharged 300hp Maluch engine swap, T-Series transmission, police light bar, turbo lag, and burnouts that explode the tires lmao
      sdadw.png
    So basically, working great! Would be cool if it could pick the same final drive for front and rear diff somehow, and if it randomized the colors and variables too, but still it doesn't need this to be one of the best mods ever!
     
    • Like Like x 4
  3. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    6,833
    Would it be possible to add a button to scramble visuals only and not touch anything in the engine, transmission, differentials, etc.? For when you want to have a crazy looking car that is actually fast, or you want to scramble your default but not make it slower, or if you want to race some AI that have the same specs as you but look different.
     
  4. angelo234

    angelo234
    Expand Collapse
    Junior Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    429
    I could try to add an option to only randomize non-drivetrain parts (including removing parts) + only randomize drivetrain parts for the next update.
     
    • Like Like x 1
  5. _N_S_

    _N_S_
    Expand Collapse

    Joined:
    Oct 28, 2017
    Messages:
    46
    I found an error in the code.

    Code:
    ...
    local rand_num = v.min + (v.max - v.min) * math.random()
    rand_num = math.floor(rand_num / v.step) * v.step;
    val_only_vars[k] = rand_num
    ...
    
    If the variable in tuning is from 0 to 1 with a step of 1, then with this code 1 will never fall out.
    Since when rounding to the bottom, even the number 0.999999 will become 0
    To fix this, you can do this:

    Code:
    local multiplier = 10 ^ (#((tostring(v.step)):gsub("(%p)", "")) - 1)
    local rand_num = math.random(v.min * multiplier, v.max * multiplier) / multiplier
    rand_num = math.abs(math.ceil(rand_num / v.step - 0.5) * v.step)
    val_only_vars[k] = rand_num
    
    Well, or just replace
    Code:
    rand_num = math.floor(rand_num / v.step) * v.step;
    on
    Code:
    rand_num = math.abs(math.ceil(rand_num / v.step - 0.5) * v.step)
     
    • Like Like x 2
  6. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    6,833
    Sometimes the mod makes a coreSlot empty when scrambling a body, this shouldn't happen. You should add a check for it. Also, make it not change the frame, because that is buggy and half of the time throws errors on body on frame vehicles like D-Series, and also the Barstow which has a subframe that has the engine. The frame changing also means that on the D-Series and Hopper the suspension is changed when it selects the crawler frames, so it changes the wheels and diffs. You should make it also unable to remove the chassis on vehicles like the Bolide. And also add radiator support to the powertrain parts list because it removes it half of the time and you have no radiator then.
    But aside from these issues this is the best update, racing randomised AI is so fun now!
     
    • Like Like x 1
  7. angelo234

    angelo234
    Expand Collapse
    Junior Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    429
    Thanks for the code suggestion and I'll use your 2nd solution.

    I'll have to look into figuring out what slots are core slots since I only made it not remove the body slot because I knew removing that slot would break many vehicles. And the rest sounds mostly doable and thanks for testing the mod out since I spend so much time just debugging my own code that I just get lazy to perform a bunch of test cases :)
     
  8. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    6,833
    Now most bugs are fixed but 2 still exist: It almost always removes radiator support when scrambling body parts, and with body on frame vehicles and the Bolide it can sometimes remove the body (doesn't happen on unibody cars).
    Also, exhaust should count as powertrain part since it can make a big difference in power in low powered cars like the Pigeon
     
    #128 Agent_Y, Nov 22, 2021
    Last edited: Nov 22, 2021
  9. angelo234

    angelo234
    Expand Collapse
    Junior Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    429
    Hmm that's strange that it can modify the radiator support slot since I put the radiator/radiator support as part of the drivetrain list so it shouldn't be swapping it. But yeah I did notice it can remove the body off those body on frame vehicles but I didn't know if people wanted it like that or not so I just left it like that, but I can make it not remove it. And I also added the exhaust to powertrain list but sounds like its not working :(
     
  10. Agent_Y

    Agent_Y
    Expand Collapse

    Joined:
    Jul 10, 2020
    Messages:
    6,833
    If the code searches by the internal part names, then you should write "radsupport" for radiator, and also add different types of exhaust parts like "header", "stack", "manifold", "pipe", "turbo", "muffler", etc. Search through vanilla vehicles to see what they are called in each one.
    Also on some cars transmission is called "transaxle" or "gearbox" so add these too
     
  11. _N_S_

    _N_S_
    Expand Collapse

    Joined:
    Oct 28, 2017
    Messages:
    46
    I found error
    upload_2021-12-10_20-22-19.png

    If there are no variables in the vehicle, an error appears in the console.

    To fix this, you can use
    Code:
    if vars then else return end
    before
    Code:
    for k, v in pairs(vars) do
    ...
    end
     
    • Like Like x 2
  12. angelo234

    angelo234
    Expand Collapse
    Junior Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    429
    Thank you and will fix it for next update.
     
  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