In this tutorial we will add a german truck,with guys in it ,that moves.
ADDING A GERMAN TRUCK WITH GUYS TO YOUR SINGLE PLAYER MAP
---------------------------------------------------------
Tutorial written by BODGER2
SPECIAL THANKS TO MY BROTHER BDBODGER, WHO FIGURED OUT HOW TO DO THIS.
In this tutorial we will add a german truck,with guys in it ,that moves.
The truck has sound,treads, and will blow up when shot with the panzerfaust.
When the truck reachs the end of it's path the guys will jump out.
So here we go
Step 1:Create a SCRIPT_VEHICLE
------------------------------
Right click in 2d view and select SCRIPT/VEHICLE
Give it these KEYS & VALUES
KEY:classname VALUE:script_vehicle
KEY:model VALUE:xmodel/vehicle_german_truck
KEY:vehicletype VALUE:GermanFordTruck
KEY:script_vehiclegroup VALUE:1
Step 2:Create INFO VEHICLE NODES
--------------------------------
Right click in 2d view and select INFO/VEHICLE_NODE
Check the first "info vehicle node" as the START NODE(KEY:spawnflags VALUE:1)
You can set other KEYS & VALUES for speed and lookahead,speed 10 seems to be a good speed.
Add more "info vehicle node" to create a path,DO NOT check them as start nodes.(2 nodes as min for a path,more is ok)
Use "info vehicle node rotate" nodes to make the truck turn on its path.
(eg> KEY:angle VALUE:0 225 0)
Step 3:Connect the truck to the nodes
-------------------------------------
Select the TRUCK then select the first node,the START NODE,then hit CTRL+K.
This will connect the two enities,and auto generate a targetname for the node.
Now select start node and then select the next node in the path,then hit CTRL+K.
And so on,till you get to the end of the path.
Step 4:Create guys to man the truck
-----------------------------------
Right click in 2d view and select ACTOR/any axis model
Give him these KEYS & VALUES
KEY:script_vehiclegroup VALUE:1
KEY:spawnflags VALUE:3 (do this by checking the checkboxs in the entity window,SPAWNER and FORCESPAWN)
KEY:targetname VALUE:truckguys
You can have UP TO 9 guys in the truck,inclueding the driver.
SO clone the first guy a few more times,they all have the same targetname.
Now make one of the guys the driver,select one of them and change his targetname to driver.
Place them near the truck,you don't connect them to anything the script takes care of that.
-----------------------------------------------------------------------------------------------------------------
!!!IMPORTANT,WHEN USING SPAWNERS THE PLAYER SHOULD NEVER BE ABLE TO SEE THE SPAWN POINT,OR THEY WILL NOT SPAWN!!!
-----------------------------------------------------------------------------------------------------------------
STEP 5:CREATE A TRIGGER (This step is not neccessary,but it is the best way to do things)
Make a brush and give it the trigger texture.
With the brush selected,right click in the 2D view and select TRIGGER/MULTIPLE
Give the trigger this KEY & VALUE
KEY:targetname VALUE:truck_trigger
Step 6:Connect the trigger to the truck
---------------------------------------
Select the trigger then select the truck and hit CTRL+K to connect them.
******************************
THATS IT FOR THE MAPPING PART.
******************************
Now for the SCRIPTING part
Create a .GSC file for your map,name it with the same name as your map.
Place it in the maps folder along with the BSP file.
-------------------
Here is the script:
-------------------
main()
{
maps\_load::main();//loads all global scripts
maps\_truck::main();//this precaches models and loads effects
//GIVE PLAYER WEAPONS
level.player takeallweapons();
level.player giveWeapon("panzerfaust");//so you can shoot the truck
level.player giveWeapon("thompson");
level.player giveWeapon("colt");
level.player giveWeapon("fraggrenade");
level.player switchToWeapon("thompson");
//TRUCK
trucktrig = getent ( "truck_trigger","targetname");//don't need this if you have no trigger
trucktrig waittill ("trigger");//don't need this if you have no trigger
truck = getent ( "truck1","targetname");
path = getVehicleNode (truck.target,"targetname");
truck attachpath(path);
truck maps\_truck::init();
truck maps\_truck::attach_guys();
truck startPath();
truck waittill ("reached_end_node");
truck notify ("unload");
}
//END OF MAIN BODY
--------------------
This is just a simple script,if you are doing other things in your script ,where you place lines can effect things.So if you are getting errors,you probably put a line in the wrong place.This script has been tested and does work.
You can get the goods in the downloads section
here