Home   Help Search Login Register  

Author Topic: Simulating heavy traffic on a stretch of road...  (Read 559 times)

0 Members and 1 Guest are viewing this topic.

Ade

  • Guest
Simulating heavy traffic on a stretch of road...
« on: 08 Feb 2004, 18:56:13 »
Evening all   ;)

I'm designing a mission which features, for reasons I won't go into here, the player attempting to make his/her escape from a couple of technicals in his/her faithful sidekick's (t)rusty Skoda.  A doMove/getPos loop repeating every few seconds takes care of controlling the technicals.  So far, so good  :)

I was trying to think of ways of adding some constant traffic to the couple of kilometres of road in the mission area to make it more like a proper car chase (although I suspect Bullitt and The French Connection won't have much to worry about).  Putting in some groups of vehicles on cycle waypoints is a bit awkward as you get jams of vehicles all doing terrible three-point turns like some learner drivers' convention.

So my chosen method was to put gamelogics at either end of the road (I called them westGen and northGen).  Then have several groups of civvie cars and trucks going from A to B or B to A.  In the init field of the group leaders I put a call to the following little script (flipping the start and end gamelogics for traffic in the other direction).  Then I gave each group a simple move waypoint beyond the end gamelogic.  tHe script is intended to teleport them back to their start point before they ever get

_lead = _this select 0
_beamMeUp = group _lead
_scotty = units _beamMeUp

#checkpos
if (_lead distance westGen < 50) then {goto "beam"}
~1
goto "checkPos"

#beam

"_x setPos getPos northGen" forEach _scotty

player sideChat "Script executed"
exit

I test-ran the mission and watched amused as a group of cars arrived near westGen and promptly crashed as their drivers were beamed to northGen.  So it sort of works :-\.

Obviously what I would like to know is: can I get car and driver to neatly teleport together or am I barking up completely the wrong tree here ? ???

Sorry for the epic post,

Ade

deaddog

  • Guest
Re:Simulating heavy traffic on a stretch of road...
« Reply #1 on: 08 Feb 2004, 19:12:32 »
As you can see, a group is composed of the humans, not the vehicles.

Try:

"vehicle _x setPos getPos northGen" forEach _scotty

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Simulating heavy traffic on a stretch of road...
« Reply #2 on: 08 Feb 2004, 19:25:11 »
It will take a bit of playing about but I think you should be able to get it to work.   You might have to use seperate commands to beam the vehicles and the drivers seperately:  a moveInDriver command should sort things out if they get separated.

If you have lots of traffic in both directions they will occasionally crash into each other or trees.    Some kind of setDammage 0 line of code might be needed.

I trust the beaming points are unlikely to be spotted by the player ... some extra trees from kegetys editor addon might be helpful.



Plenty of reviewed ArmA missions for you to play

Ade

  • Guest
Cheers deaddog and MacGuba,

I have now got it working ... nearly ...  :D

I used the "vehicle _x..." at the start of the loop, which successfully beamed a group of two cars and drivers to the correct position, but separately.  For some reason, the cars were damaged quite badly (now I know why they could never get McCoy into those transporters) and the drivers leapt out and wandered off to the waypoint.

I'm betting that it's because one car is being dropped on top of the other since with a single car, the script now works without any problems (and is curiously entertaining to watch  ::)).

I'd rather use groups than individual vehcles as it will save me some fat-fingering so if anyone can think of a way of teleporting the cars in a line spaced out by a few metres, I'll be grateful, but the principle works and might be useful for other things.

The script is:

;Script to loop vehicle between two checkpoints in one direction only
;Call the script from the init line of each vehicle
;in this example the start checkpoint is northGen and the end is westGen

_lead = _this select 0
_beamMeUp = group _lead
_scotty = units _beamMeUp

#checkpos
if (_lead distance westGen < 50) then {goto "beam"}
~1
goto "checkPos"

#beam

"vehicle _x setPos getPos northGen" forEach _scotty
"vehicle _x setDamage 0" forEach _scotty

player sideChat "Script executed"

goto "checkPos"

Now all I need to do is choose my checkpoint locations carefully.  While I want to avoid any unwanted crashes between AI vehicles, a few smashes induced by the player weaving to avoid 50 cal rounds should give the right atmosphere.

I'll experiment to find the optimum traffic density.  I have a 1.8 GHz Athlon- based system which gets 3488 on the OFP benchmark, which I guess is a sort of average PC. Does anyone have an estimate of the maximum number of units you can run at a decent speed on different benchmark ratings? I could even write a script to spawn extra vehicles on a fast PC if this would be useful.

Ade  8)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Simulating heavy traffic on a stretch of road...
« Reply #4 on: 08 Feb 2004, 22:59:08 »
I wouldn't even bother trying to do this with groups - I'd go straight to doing it one vehicle at a time.    Quicker in the long run.

There is no simple correlation between number of units and benchmark.    It depends on which island the action is based, the weather (I mean in the game, not outside your window), how close the units are, how many types of vehicle/unit are in your mission, how many triggers there are including where they are and what's in the condition line ..... well you get the picture.   You just have to experiment as you say.   I wouldn't get too carried away on benchmarking in some created vehicles ... apart from anything else you can't test it properly on your machine....
Plenty of reviewed ArmA missions for you to play