| Author |
Topic: driving halftracks in mp! |
| aufklarer |
General Member Since: Sep 4, 2005 Posts: 83 Last: Jul 3, 2006 [view latest posts] |
|
|
|
|
|
|
|
| aufklarer |
General Member Since: Sep 4, 2005 Posts: 83 Last: Jul 3, 2006 [view latest posts] |
|
|
|
|
| aufklarer |
General Member Since: Sep 4, 2005 Posts: 83 Last: Jul 3, 2006 [view latest posts] |
|
|
|
|
| Tridon |
General Member Since: Jan 25, 2006 Posts: 232 Last: Nov 28, 2010 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Sunday, Jun. 18, 2006 08:48 pm |
 |
Your mapname.gsc looks fine and this is how I did it with the Opel trucks:
Code: main()
{
level thread trucks();
}
trucks()
{
level.TruckSpeed = 6.5;
opel1 = getent ("opel1","targetname");
temp = getent (opel1.target,"targetname");
opel1.dest = temp.origin;
opel1.start = opel1 .origin;
opel1 hide();
wait 2;
while (1)
{
opel1 thread truck_driveby("opel1_driveby");
wait 30;
}
}
truck_driveby(sound)
{
// If you specified a sound to play then play it
if (isdefined (sound))
self playsound (sound);
wait 15;
self show();
self moveto(self.dest, level.TruckSpeed, 0.1, 0.1);
wait level.TruckSpeed;
self hide();
self.origin = self.start;
}
I named mine trucks.gsc. You can compare the plane.gsc to my .gsc to see what changes I made and substitute yours in. It will only travel in a straight line from a-->b, so make sure your surface is flat. What I noticed though is, even if the model is solid with a collmap, it isn't so once it's a scrpit_model. I could walk right through my truck model, vehicle_opel_blitz_woodland_static, which also has a collmap. I tested it by adding it a misc_model to my map and it was solid, but as a script_model, it's not. |
 |
|
|
| 103kill |
 |
General Member Since: Dec 2, 2004 Posts: 82 Last: Jun 24, 2009 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Monday, Jun. 19, 2006 05:31 am |
 |
I had encountered this problem before back in CoD. What I did was to model the sp version of vehicle nodes with script_models to make a path for the vehicle.
What I did with a halftrack (it worked pretty well) was to make a script_model halftrack and a script_brushmodel out of clip and an origin brush that matched that of the halftrack. I connected the brushmodel to the script_model, then the script_model to the first origin, then each origin to the next.
Here's a picture of the map setup
In the top right (not supposed to be raised, I just moved it up to show the linking - make sure you match up the brushmodel and script_model origins exactly) is the script_brushmodel, its target is the script_model under it, and that targets the script_model "path nodes" along the road, which are pointed to each other in the turns.
Here's the script:
Code: main()
{
level thread vehicles_start();
}
// *********************************************************
// Overall setup for one vehicle:
// 1 script_brushmodel clip connected to
// 1 script_model vehicle, which is connected to
// the first script_origin pathnode, which is
// connected to more of them and so on and so forth...
//
// the script_noteworthys of the script_origins must match
// the targetname of the script_brushmodel, and make sure
// to put the origin brush of your script_brushmodel on the
// origin of the script_model
//
// finally, in order to make turns, each script_origin must
// be angled in the direction of the next one, and the first node
// in the path must be directly in front of the vehicle (no turns yet)
//
// This script is designed for multiple vehicles with
// multiple speeds
// *********************************************************
vehicles_start()
{
halftrack_clip = getent("halftrack", "targetname"); //a brushmodel clip
halftrack_clip thread init(10, 1); // 1st # = speed, 2nd # = turning speed
// use the above 2 lines or the format below as an example for adding more vehicles
//
// [script name for vehicle] = getent([script_brushmodel targtname], "targetname");
// [script name for vehicle] thread init([speed], [turning speed]);
}
init(speed, rotatespeed)
{
drivenodes = getentarray(self.targetname, "script_noteworthy"); // here we are using script_origins just like vehicle nodes
self thread drive(speed, rotatespeed, drivenodes); // remember, self is still the clip here
}
drive(speed, rotatespeed, drivenodes) // drivenodes is the # of nodes or, subsequently, for loops
{
temp = getent(self.target, "targetname"); // the vehicle
vehicle = getent(self.target, "targetname");
for(i=1; i<drivenodes.size; i++)
{
temp2 = getent(temp.target, "targetname"); // the next node in the path
// start move
self moveto(temp2.origin, speed, .2, .2); // the clip
vehicle moveto(temp2.origin, speed, .2, .2); // the vehicle
wait speed; //give the game time to catch up
// end move
// determine if rotating is necessary
if (self.angles != temp2.angles)
{
// start rotate
self rotateto(temp2.angles, rotatespeed, .1, .1);
vehicle rotateto(temp2.angles, rotatespeed, .1, .1);
wait rotatespeed;
// end rotate
}
temp = temp2; //leapfrog the node
}
}
You can call it from mapname.gsc
Hope that helps
Cheers |
 |
|
|
| aufklarer |
General Member Since: Sep 4, 2005 Posts: 83 Last: Jul 3, 2006 [view latest posts] |
|
|
|
|
| aufklarer |
General Member Since: Sep 4, 2005 Posts: 83 Last: Jul 3, 2006 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Monday, Jun. 19, 2006 11:07 am |
 |
here is my halftracks.gsc file, i used tridons file as an example, but when i load my map to see if it works, it crashes...
and for 103kill's method, if i leave the back of the scrip_brushmodel open then players could jump inside from behind, through the doors, this could be a sollution for not having ramps next to the halftrack, not?
main()
{
level thread halftracks();
}
halftracks()
{
level.halftrackSpeed = 6.5;
sdkfz1 = getent ("sdkfz1","targetname");
temp = getent (sdkfz1.target,"targetname");
sdkfz1.dest = temp.origin;
sdkfz1.start = sdkfz1 .origin;
sdkfz1 hide();
wait 2;
while (1)
{
sdkfz1 thread tank_move("tank_01_move");
wait 30;
}
}
tank_move(sound)
{
// If you specified a sound to play then play it
if (isdefined (sound))
self playsound (sound);
wait 15;
self show();
self moveto(self.dest, level.halftrackSpeed, 0.1, 0.1);
wait level.halftrackSpeed;
self hide();
self.origin = self.start;
}
my targetname is "sdkfz1", and the sound i want for it is "tank_01_move" did i do something wrong? |
 |
|
|
| Slipknot14 |
 |
General Member Since: Feb 23, 2005 Posts: 109 Last: Sep 4, 2012 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Monday, Jun. 19, 2006 01:00 pm |
 |
I think I find an easier way to move the vehicles. I can't test it because I'm not at my computer ![[biggrin]](images/BBCode/smilies/biggrin.gif) .
So: Make a simple script_model for vehicle(I don't know the models name but there is some models that's wheels moving, use that!!! I see them on a multi player map) then press N: targetname:movingveh
Then Make the vehicle of metal clip. And right click>script>brushmodel, then press N: targetname:movingvehclip
The map is ready.
Now the script, something like this:
main()
{
level thread movingvehicle();
level thread movingvehicleclip();
}
movingvehicle()
{
vehicle1 = getent ("movingveh ", "targetname”);
while (1)
{
vehicle1 movez[!or something other axis!] (x, x, x, x);
vehicle1 waittill ("movedone”);
wait (4);
vehicle1 movez[!or something other axis!] (y, y, y, y,);
vehicle1 waittill ("movedone”);
//and more, more moving if you need
}
}
movingvehicleclip()
{
vehicle1clip = getent ("movingvehclip ", "targetname”);
while (1)
{
vehicle1clip movez[!or something other axis!] (x, x, x, x);
vehicle1clip waittill ("movedone”);
wait (4);
vehicle1clip movez[!or something other axis!] (y, y, y, y,);
vehicle1clip waittill ("movedone”);
//and more, more moving if you need
}
}
You need to give the same coordinates for the clip. And if you need MG for it you can Make a new thread with the MG's script model.
You can make rotatings and sound effects for this. I think it's work:) |
 |
|
|
| aufklarer |
General Member Since: Sep 4, 2005 Posts: 83 Last: Jul 3, 2006 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Monday, Jun. 19, 2006 07:55 pm |
 |
thanks slipknot, i tried your method, but when i load the map cod2 crashes, am i supposed to enter coordinates where you placed the x x x x and y y y y?
Quote: vehicle1 movez[!or something other axis!] (x, x, x, x);
vehicle1 waittill ("movedone”);
wait (4);
vehicle1 movez[!or something other axis!] (y, y, y, y,);
vehicle1 waittill ("movedone”);
//and more, more moving if you need
} }
|
 |
|
|