Scripting Tank (Vehicle) Paths

Post your scripting questions / solutions here

Moderator: Moderators

Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Scripting Tank (Vehicle) Paths

Post by Broadus »

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.
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

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
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

in case you're wondering, waypoints are *NOT* part of a .pth file, because AI soldiers don't need to navigate them, only pathnodes. you won't need to rebuild the .pth file after spawning them.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

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!
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

I remember a total warfare mod that had tanks drive paths and shoot enemy.

Is this MP or SP?
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

This is SP. I don't think that'd be very relevant, though, as I need to spawn waypoints with scripts, because I'm modifying the single player Allied Assault stock maps (which can't be edited properly in Radiant).
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

Well, here's some stuff I just pulled out of the .map of a level with tanks in it.
{
"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 spawn an info_vehiclepoint, give it a targetname and then give it a target so it will target another info_vehiclepoint?
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

same as a pathnode. just change info_pathnode to info_vehiclepoint
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

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.
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

while(1) // put it in a loop so it runs all the time
{
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

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.
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
Where would I put while(1) in that?
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

You wouldn't put while(1) in that you only need to spawn a path once . The part you would put in a loop would be the part that makes the tank use the path .
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

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.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

While(1)
{

$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.
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

that section of code you posted, Broadus, just makes the path for the tank, he wont drive until you spawn it and set him on the driving path with the loop bdb just posted.

also, i suggest changing "1" to "isAlive $tank"
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Post Reply