Jump to content

Traffic Editor (tool for making custom traffic)


Wojak

Recommended Posts

Na attempt of creating a traffic resource from scratch – not random, but just something to add some spice to the maps

I think I solved the biggest problem (a relatively cheap way of syncing them undependably of any client), but it needs some tweaks and a user friendly (idiot proof) user interface in map editor

Link to comment

to release it, I need to add the proper editor interface, and maybe some exported functions and events

and of course testing... (currently i tested it with two players online including me)

I can just say that it will not be released in 2011 ;)

Link to comment

i didn't test it, and there's some probability i left in some silly bug, but this could improve the driving alot by emulating float control.

local controls={} 
local realcontrolvalues={} 
local controlframecount={} 
  
function emulateAnalogControl(ped,control,float) 
    if not controls[ped] then controls[ped]={} end 
    if not realcontrolvalues[ped] then realcontrolvalues[ped]={} end 
    if not controlframecount[ped] then controlframecount[ped]={} end 
    realcontrolvalues[ped][control]=getPedControlState(ped,control) and 1 or 0 
    controlframecount[ped][control]=1 
    if float then 
        controls[ped][control]=float 
    else 
        setPedControlState(ped,control,false) 
        controls[ped][control]=nil 
        realcontrolvalues[ped][control]=nil 
        break 
    end 
end 
  
addEventHandler('onClientRender',root,function() 
    for k,ped in pairs(controls) do 
        for n,control in pairs(ped) do 
            local tempavg1=(realcontrolvalues[k][n]*controlframecount[k][n]+1)/(controlframecount[k][n]+1) 
            local tempavg2=(realcontrolvalues[k][n]*controlframecount[k][n])/(controlframecount[k][n]+1) 
            if math.abs(tempavg1-control)abs(tempavg2-control) then 
                setPedControlState(ped,control,true) 
                realcontrolvalues[k][n]=tempavg1 
            else 
                setPedControlState(ped,control,false) 
                realcontrolvalues[k][n]=tempavg2 
            end 
            controlframecount[k][n]=controlframecount[k][n]+1 
        end 
    end 
end) 
  

PS: higher fps=more accuracy

Edited by Guest
Link to comment
i didn't test it, and there's some probability i left in some silly bug, but this could improve the driving alot by emulating float control.

--script--

PS: higher fps=more accuracy

I know it's not a bug, but I don't like the look of a double for loop in onClientRender handler function and the idea of running it on all clients at once...

for me: more operations per second = lower FPS (I think not only for me)

If i find it necessary, i will come up with somthing more efficient (less accurate, but hardly noticeable)

btw, where is the "ped" table?

btw2, thank you all for positive comments :)

Link to comment

ped is a table in main table, which contains all controls that you're going to handle.

if you're using this of accelerate and brake buttons, with 10 peds syncered per player, it'll be 20loops only.

and, as you see you're not forced to call the func for all players, just the syncer.

Link to comment

i'm quite happy with the small vehicles behavior, however the big, heavy ones will need some more attention (they just need to take the curve sooner)

i think i will also test some other vehicle types (boats and trains)

My test server should be open tomorrow at 18:00 Warsaw time (search for "wojak" in the server browser)

Link to comment
  • 2 weeks later...
How is the editing interface? You should make it similar to how rcg has made it, except the waypoints is only shown at the spawn point and when you click on the spawn point it shows all the waypoints connected to it.

I'm considering creating an independent tool for making the paths, I think it will be esier to restrict some element propertys that way, but the maps will be in the standard map editor format though.

Link to comment
  • 2 months later...
It really looks Awesome dude, how is the progress going on this?

not as fast like I would like, but forward

recently I've designed the GUI layout of the interface, and started to script the buttons (i want to sync the GUI in all clients, so it looks like the patch creator may be more complicated than the interpreter part)

Once the patch creator is done, i can get back to the interpreter, and it should be down hill from there

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...