Hi guys, let me explain how the roadsystem works.
Fisrt let me point out that this is as a very simple way of getting control over your vehicles, so making sure that units use the road to travel from one point on the map to another. The limitation is that units can only move between pre-defined points on the map, the so called drop zones.
This still could come in handy, especially on lager maps where logistics are part of the game because units move faster on roads and will not run into the enemy, as long as you control the roads on which the units travel of course.
So this is how it works. I drew a schematic representation of a map below.
- On the map you have a number of roads.
- The blue and red squares A to E are the drop points. Lets say that the red drop point are for vehicle leaving, the blue ones for arriving units.
- The numbers 1 to 23 represent ScriptAreas. These would be round and positioned in the middle of the road. In reality more script areas would be needed to make the vehicle follow the road.
To make it possible to travel between all points A,B,C,D and E the script includes a number of arrays. These arays just connect the point along which the vehicle will move.
eg.
Road1 = {1,2,3,4,5,6,7,8,9) --Road going from A to B
Road2 = {1,2,3,4,5,10,11,12,13,14} -- Road going from A to C
Road3 = {9,8,7,6,5,10,23,22,21,19,20} -- Road going from B to D
.... and so on.
Now to go from one drop point to another a loop (while....do) is created. In this loop a QCmd is created for each variable in the array. (so for each ScriptArea in the array)
This looks something like this.
QCmd (0,UnitScriptID, x,y); where x and y are obtained by using the function
x,y = GetScripAreaParams(ScripTArea);
As said this method is basic and I would like to push this idea a bit further.
If you're still interested then take a look at the overview below.
The idea here is that a truck (or other unit) could be called by another unit on the map.
When the truck is "called" it will find the road closest to its position.
Then the truck will move along the road along the blue line (this is the shortest distance via the road between the two units)
The truck will leave the road to get to 'calling unit'
This will be bit more challenging to script and would keep me occupied for a while but I'm convinced it can be done.
The thing is that it would be important for the player to control the roads, but I guess this would add to the realism.
Major Pain. I will study your post and get back to you.