Scripting Tank (Vehicle) Paths
Moderator: Moderators
Scripting Tank (Vehicle) Paths
How can I script a path for a tank (where he makes his way from Point A to Point B), and make the tank follow that path?
I plan on putting some cool tank battles in Spearhead! I might try to pull some off in Allied Assault, or at least a tank-escort-type-level, although only German tanks are in Allied Assault, and the Sherman (with animations) can't be converted to AA, though I was easily able to convert it to Spearhead.
I plan on putting some cool tank battles in Spearhead! I might try to pull some off in Allied Assault, or at least a tank-escort-type-level, although only German tanks are in Allied Assault, and the Sherman (with animations) can't be converted to AA, though I was easily able to convert it to Spearhead.

-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
Theres tanks scripts for AA laying around
Spawn the tank as script_model
Spawn waypoints or script origins, And script the tank to go to through them and back again.Heres some links.
/forum/viewtopic.php?t=10308&highlight=tank
Drivable tanks(has bugs)link below
/forum/viewtopic.php?t=9859&highlight=tank
And heres the Tut from main page,Its not a tank, But youll get the idea, Its also for mapping, But itll show you the scripting.
/t.php?id=68
Spawn the tank as script_model
Spawn waypoints or script origins, And script the tank to go to through them and back again.Heres some links.
/forum/viewtopic.php?t=10308&highlight=tank
Drivable tanks(has bugs)link below
/forum/viewtopic.php?t=9859&highlight=tank
And heres the Tut from main page,Its not a tank, But youll get the idea, Its also for mapping, But itll show you the scripting.
/t.php?id=68
Well, I don't need driveable tanks, but... Thanks? I actually have a script for them (I didn't make it, of course), and I've tested them out, but the problem is no stock Allied Assault levels would really work out with a tank, unless I wanted to sacrifice what could have been a good on-foot level. I might make a version of my mod, once I'm done with it, that's all about the player being able to drive tanks everywhere...
Anyway, though the other links look like they'll help me get the tank actually moving on the path, I still need to know how to spawn the path in a script. Once that's all settled, I can probably make the maps tank-battle-ready!
Anyway, though the other links look like they'll help me get the tank actually moving on the path, I still need to know how to spawn the path in a script. Once that's all settled, I can probably make the maps tank-battle-ready!

-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
Well, here's some stuff I just pulled out of the .map of a level with tanks in it.
So, how would I spawn an info_vehiclepoint, give it a targetname and then give it a target so it will target another info_vehiclepoint?{
"classname" "info_vehiclepoint"
"origin" "1498 -713 423"
"_color" "0.501961 0.000000 0.000000"
"angle" "270"
"$targetname" "gerry_tank_2_path"
"target" "t31"
}
// Entity #105
{
"classname" "info_vehiclepoint"
"origin" "1542 -1080 426"
"_color" "0.501961 0.000000 0.000000"
"targetname" "t31"
"angle" "270"
"target" "t35"
}
// Entity #107
{
"classname" "info_vehiclepoint"
"origin" "1589 -1608 416"
"_color" "0.501961 0.000000 0.000000"
"targetname" "t35"
"angle" "270"
"target" "t36"
}

So how would I get the tank to loop on the path, like going in a circle forever?
I just have to mention that I finally was able to script tanks (using scripts from t2l4) so that they would dynamically shoot at more targets than just the player! I also got troopers to shoot at tanks dynamically in a similar fashion. All I have to know is the names of the tanks (so troopers will shoot at them), and the names of the targets for tanks (other tanks, or troopers). That, and I have to have tanks/troopers thread the scripts that make them shoot eachother.
But don't let me distract the topic. Seriously, path-looping.
I just have to mention that I finally was able to script tanks (using scripts from t2l4) so that they would dynamically shoot at more targets than just the player! I also got troopers to shoot at tanks dynamically in a similar fashion. All I have to know is the names of the tanks (so troopers will shoot at them), and the names of the targets for tanks (other tanks, or troopers). That, and I have to have tanks/troopers thread the scripts that make them shoot eachother.
But don't let me distract the topic. Seriously, path-looping.

-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
This is what my tank path script looks like. For some reason. I haven't tested it yet, but I feel like it wouldn't work, loop or no.
Where would I put while(1) in that?fftank1pathmake:
local.coords = "3407.24 2186.46 -167.88"::"4928.78 1759.60 -135.76"::"-2921.52 -2941.21 0.12"::"-3899.13 -4050.83 16.13"::"-4279.17 -3179.59 0.13" // C style arrays don't work in MoHAA
local.lastPath = spawn info_vehiclepoint "origin" local.coords[1] "targetname" "fftank1path"
for(local.i = 2; local.i <= local.coords.length; local.i++)
{
local.newPath = spawn info_vehiclepoint "origin" local.coords[local.i] "targetname" ("fftank1path" + local.i)
local.lastPath.target = local.newPath.targetname
local.lastPath = local.newPath
}
end

So how would I go about doing the loop, then?
Not that it would matter quite yet. I tried the above script I mentioned and said I didn't test. After testing it, I couldn't even get it to work. I might give another crack at it because I think maybe I did something wrong, but I still don't know how to spawn a path for a vehicle, and the above script seems to leave no room for looping opened.
Can't I just spawn each info_vehiclepoint individually and tell them what to target? It seems to me that doing that would be the way to get things to loop, because then I could make the last part of the looping path just target the beginning.
Not that it would matter quite yet. I tried the above script I mentioned and said I didn't test. After testing it, I couldn't even get it to work. I might give another crack at it because I think maybe I did something wrong, but I still don't know how to spawn a path for a vehicle, and the above script seems to leave no room for looping opened.
Can't I just spawn each info_vehiclepoint individually and tell them what to target? It seems to me that doing that would be the way to get things to loop, because then I could make the last part of the looping path just target the beginning.

While(1)
{
$mytank drive local.path local.speed local.accel 200 local.lookahead
$mytank waitTill drive
}
That will just make it drive maybe look at the global/vehicles_thinker.scr I think there maybe a thread you can use like the enemy_tank_think thread.
{
$mytank drive local.path local.speed local.accel 200 local.lookahead
$mytank waitTill drive
}
drive( Vector position, Float speed, Float acceleration, Float reach_distance, Float look_ahead, [ Vector alternate_position ] )
Makes the vehicle drive to position with speed and acceleration until reached_distance close to position
That will just make it drive maybe look at the global/vehicles_thinker.scr I think there maybe a thread you can use like the enemy_tank_think thread.

