Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 79 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Tutorials

»
CoD4 Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Spawning/Moving vehicles, spawning player inside vehicles and spawning actors!
Versions: You must be logged in to view history.

In this tutorial I will show you in an easy way how to create a singleplayer map containing vehicles.
I will show you how to spawn a vehicle (in this case, a UAZ), how to spawn people that operate the vehicle, how to let it move and how to spawn the player inside the vehicle.

NOTE: In the end of this tutorial you can find my XFIRE/MSN/E-mail if you wan't the sourcefiles of this tutorial.

In this first part of the tutorial I will show you how to spawn a vehicle with people in it and how to move it - later on i'll show you how to put yourself in a vehicle.

Step 1
you wan't you vehicle to ride on) and a skybox.
If you haven't, feel free to use one of my singleplayer testmaps located with the sourcefiles.

Step 2
Spawn a "script_vehicle" by rightclicking in your 2D grid -> Script -> Vehicle

Step 3
Assign this entity a model, in this case we are using the "vehicle_uaz_light".

KEY: Model
VALUE: vehicle_uaz_light






Step 4
Now we are going to lay down a path the vehicle is going to follow, we will use multiple "Node" entity's and in this case also a "Node_Rotate" to turn the vehicle.

Right-click in your 2D grid and go to "Info" -> "Vehicle" -> "Node"

A node will now appear, with the node selected press N to bring up the entity window, then mark the box that says "START_NODE" (this means this node represents the startingpoint ofcourse).
Now close the entity window again by pressing N, move the node in front of the vehicle and deselect it.





Step 5
It's time to create the rest of the path, again go to "Info" -> "Vehicle" -> "Node", once you have created another one copy it and make the path you wan't your vehicle to follow.

NOTE: Make sure these new nodes don't have "START_NODE" cheked in the entity window!



Step 6
We will have to turn the vehicle now using a "node_rotate" - the name says it; it turns the vehicle in a desired direction.
Create a "node_rotate" by rightclicking in your 2D grid -> Info -> Vehicle -> Node_rotate
Place it at the point where it's going to turn the vehicle, other then that don't do anything yet, deselect it by pressing ESC.



Step 7
Now we will finish the path of the vehicle (according to my map) if you wan't your vehicle to drive further or make more turns etc. just create some new nodes and node_rotate's to create your desired path.
If your using my map the final result should look like this:

NOTE: I removed the treemodels and clips to create a better overview for this screenshot.


Step 8
Let's connect all the paths now, first select your vehicle, then select the "node" which we created in the beginning that had
 
"START_NODE" cheked in the entity window.
With those 2 selected, press "W" on your keyboard to connect them, if all turns well an arrow will appear showing you the link between the vehicle and the node.



Now deselect the vehicle and the node by pressing ESC, then select your first node (that you had just connected to the jeep) and then the node right in front of it.

Repeat this process untill all the nodes are connected.





Step 9
Now, select all your nodes (including the node_rotate, don't select the vehicle) and press SHIFT + V
The "Vehicle Window" will now pop-up, in the bottom right corner you will see "Speed" - set the speed to 15 (good for jeeps)
 
and press the "Set speed" button, the window will automaticly close.
Open the "Vehicle Window" again and go to "Set Lookahead" - set this to 1, then click on the "Set Lookahead" button.
 
If you did everything right sofar, a red line will appear (if you have atleast one of the nodes selected).



As you can see the "node_rotate" automaticly made the turn for you.



Step 10
Deselect all the nodes and select your vehicle only, then press "N" to bring up the entity window, now add all these key/values to the vehicle:


This will tell the game if the vehicle is friendly or foe (values are "allies" and "axis")
KEY: script_team
VALUE: allies



Used for linking AI to a vehicle. (values are 0 or higher)
KEY: script_vehicleride
VALUE: 1



This tells the game when the vehicle will start to move (when at "0" - vehicle moves when spawned)
KEY: script_vehiclestartmove
VALUE: 0



Type of vehicle, in this case the jeep belongs to "uaz"
KEY: vehicletype
VALUE: uaz



Full list of Vehicletype's and Modelname's


Code:
Vehicletype vehicle_modelname 80s_wagon1 vehicle_80s_wagon1_brn_destructible 80s_wagon1 vehicle_80s_wagon1_green_destructible 80s_wagon1 vehicle_80s_wagon1_red_destructible 80s_wagon1 vehicle_80s_wagon1_silv_destructible 80s_wagon1 vehicle_80s_wagon1_tan_destructible 80s_wagon1 vehicle_80s_wagon1_yel_destructible apache vehicle_apache apache vehicle_apache_dark blackhawk vehicle_blackhawk blackhawk vehicle_blackhawk_low blackhawk vehicle_blackhawk_low_thermal bm21 vehicle_bm21_mobile_dstry bm21_troops vehicle_bm21_mobile_bed_destructible bm21_troops vehicle_bm21_mobile bm21_troops vehicle_bm21_mobile_bed bm21_troops vehicle_bm21_mobile_cover_no_bench bm21_troops vehicle_bm21_mobile_cover"); bm21_troops vehicle_bm21_cover_destructible bm21_troops vehicle_bm21_bed_under_destructible bm21_troops vehicle_bm21_mobile_bed_destructible bmp vehicle_bmp bmp vehicle_bmp_woodland bmp vehicle_bmp_woodland_jeepride bmp vehicle_bmp_woodland_low bmp vehicle_bmp_desert bmp vehicle_bmp_thermal bmp vehicle_bmp_low bradley vehicle_bradley bus vehicle_bus_destructable cobra vehicle_cobra_helicopter cobra vehicle_cobra_helicopter_fly 80s_hatch1 vehicle_80s_hatch1_brn_destructible 80s_hatch1 vehicle_80s_hatch1_green_destructible 80s_hatch1 vehicle_80s_hatch1_red_destructible 80s_hatch1 vehicle_80s_hatch1_silv_destructible 80s_hatch1 vehicle_80s_hatch1_tan_destructible 80s_hatch1 vehicle_80s_hatch1_yel_destructible 80s_sedan1 vehicle_80s_sedan1_brn_destructible 80s_sedan1 vehicle_80s_sedan1_green_destructible 80s_sedan1 vehicle_80s_sedan1_red_destructible 80s_sedan1 vehicle_80s_sedan1_silv_destructible 80s_sedan1 vehicle_80s_sedan1_tan_destructible 80s_sedan1 vehicle_80s_sedan1_yel_destructible hind vehicle_mi24p_hind_desert hind vehicle_mi24p_hind_woodland hind vehicle_mi24p_hind_woodland_opened_door humvee vehicle_humvee_camo humvee vehicle_humvee_camo_50cal_doors humvee vehicle_humvee_camo_50cal_nodoors humvee automobile luxurysedan vehicle_luxurysedan luxurysedan vehicle_luxurysedan_test luxurysedan vehicle_luxurysedan_viewmodel m1a1 vehicle_m1a1_abrams mi17 vehicle_mi17_woodland mi17 vehicle_mi17_woodland_fly mi17 vehicle_mi17_woodland_fly_cheap mi28 vehicle_mi-28_flying mig29 vehicle_mig29_desert mig29 vehicle_av8b_harrier_jet sa6 vehicle_sa6_no_missiles_desert sa6 vehicle_sa6_no_missiles_woodland seaknight vehicle_ch46e seaknight_airlift vehicle_ch46e_opened_door small_hatchback vehicle_small_hatchback_blue small_hatchback vehicle_small_hatchback_green small_hatchback vehicle_small_hatchback_turq small_hatchback vehicle_small_hatchback_white small_hatchback vehicle_small_hatch_turq_destructible small_hatchback vehicle_small_hatch_green_destructible small_hatchback vehicle_small_hatch_turq_destructible small_hatchback vehicle_small_hatch_white_destructible small_hatchback automobile small_wagon vehicle_small_wagon_white_destructible small_wagon vehicle_small_wagon_blue_destructible small_wagon vehicle_small_wagon_green_destructible small_wagon vehicle_small_wagon_turq_destructible small_wagon vehicle_small_wagon_white small_wagon vehicle_small_wagon_blue small_wagon vehicle_small_wagon_green small_wagon vehicle_small_wagon_turq small_wagon automobile t72 vehicle_t72_tank_low t72 vehicle_t72_tank t72 vehicle_t72_tank_woodland tanker vehicle_tanker_truck_civ truck vehicle_pickup_roobars truck vehicle_pickup_4door truck vehicle_opfor_truck truck vehicle_pickup_technical uaz vehicle_uaz_hardtop_destructible uaz vehicle_uaz_light_destructible uaz vehicle_uaz_open_destructible uaz vehicle_uaz_fabric_destructible uaz vehicle_uaz_fabric uaz vehicle_uaz_hardtop uaz vehicle_uaz_open uaz vehicle_uaz_open_for_ride van vehicle_uaz_van van automobile zpu_antiair vehicle_zpu4 zpu_antiair vehicle_zpu4_low

(Thanks to www.ModsonWiki.com)





Step 11
Ok let's spawn some marines that will drive the car, right-click in your 2D grid and go to "Actor" -> "Ally" -> "Marine" -> "AR" -> "m16 basic"
Copy this actor 2 more times, we now have a total of 3 marines, place them next to the car (or anywhere else) and press "N" (with all 3 marines selected) to bring up the entity window.



In the entity window, chek the box that says "SPAWNER", keep the entity window open as we are going to enter some key/values:


The number corresponds with the vehicles "vehicleride" number.
KEY: script_vehicleride
VALUE: 1




Now deselect all 3 actors, and select one of them, we will make him the driver, give him the following key/value in the entity window:

(0 = driver 1 = cargo/gunner 2 = cargo 3 = cargo etc.)
KEY: script_startingposition
VALUE: 0




Deselect this actor and select anotherone, give him a diffirent number:

KEY: script_startingposition
VALUE: 1




Now deselect that actor and select this lastone, give him a diffirent number:

KEY: script_startingposition
VALUE: 2




If you wan't to give the marines a name use the following key/value (one marine at a time):

KEY: script_friendname
VALUE: Any name you wan't him to have




Step 12
Create a playspawn by rightclicking in your 2D grid then go to "Info" -> "Playerstart"
Make sure the playerspawn ISN'T facing towards the actors (you may not see them or they won't spawn!)





Step 13
Now go to "Textures" -> "Tools" and look for the "Trigger" texture, create a brush around the playerspawn.
With that trigger selected click on your 2D grid and go to "Trigger" -> "Multiple"

As soon as you spawn the player will activate the trigger causing the vehicle and actors to spawn and move.
Again make sure the playerstart isn't able to view the actors or they won't spawn.

If you wan't your vehicle to be spawned on a diffirent time, for let's say when you go into a building you wan't it to spawn somewhere - simply create the same trigger but place it in the doorway of that building.
With that trigger selected, select your vehicle and press SHIFT + V to open the "Vehicle Window" now click on the button that says "Spawn Vehicle" - then open it again and click on "Move Vehicle".



Step 14
That's it for the editor, now it's time to script, create a wordpad (.txt) file and change the name to sp_YOURMAPNAME.gsc - don't worry it's already prepared for you, scripts are all by h0ly:

Tell wordpad to open the file (in this case sp_riding_jeep.gsc) and copy this code into it:


Code:
main() { maps_uaz::main("vehicle_uaz_light"); maps_load::main(); }

The vehicle you use is precached in the .gsc - in this case that is "vehicle_uaz_light", if you used a diffirent model simply change the name.

NOTE: If your model is not part of _uaz.gsc then go back to the list I posted some steps above and look up your Vehicletype, then go to C:\Program Files\Activision\Call of Duty 4 - Modern Warfare\raw\maps and find your vehicle's .gsc

My vehicle is from vehicletype uaz so I used maps\_uaz::main("vehicle_uaz_light");



Step 15
Save your map, save your script (place your script in the \Activision\Call of Duty 4 - Modern Warfare\raw\maps folder)
Open your compiletool, and compile the BSP - make sure you have "Connect Paths" selected in the window.

After compiling the BSP build a fastfile, it asks you if you wan't to create new zonefiles, click yes.
Now click on "Update Zone File" and copy the following lines to the RIGHT side of the screen.


Code:
xmodel,viewmodel_base_viewhands
 
fx,explosions/small_vehicle_explosion
 
xanim,uaz_passenger_idle_drive
 
xanim,uaz_passenger_exit_into_run
 
xanim,uaz_passenger_enter_from_huntedrun
 
xanim,uaz_driver_idle_drive
 
xanim,uaz_driver_exit_into_run
 
xanim,uaz_driver_enter_from_huntedrun
 
xanim,uaz_passenger_exit_into_run_door
 
xanim,uaz_passenger_enter_from_huntedrun_door
 
xanim,uaz_driver_exit_into_run_door
 
xanim,uaz_driver_enter_from_huntedrun_door
 
xanim,uaz_driving_idle_backward
 
xanim,uaz_driving_idle_forward
 
xmodel,vehicle_uaz_light
 
weapon,sp/mp5
 
xmodel,weapon_mp5
 
xmodel.viewmodel_mp5


If you used a diffirent model as a vehicle, simply run the map - you will get an error or your vehicle won't show up, fix this by closing the game again and going to "Update Zone Files" - the missingassets should now show up on the left, copy them to the right and save, then rebuild FastFile again.
Everytime you change something you must rebuild the fastfile, if you changed something in the mapeditor then you must compile the BSP again and then rebuild the fastfile.

Now, Launch the map (with "Developer" and "Cheat enabled") and look at them bastards roll!



NOTE: If you get those weird thingy's on your screen simply type "/cg_Drawgun 0" in the console, it's because there's no reflections yet (this command can only be done with cheats on)

NOTE2: If your vehicle doesn't move or spawn, type "/g_connectpaths 1" in the console and restart the map.


While writing this tutorial I made the map, and it works, so if you have any further problems it's because you did something wrong, which will propably happen with your first time, simply try again - if failure keeps coming back then post a thread on the forums or contact me.
The following steps will show you how to spawn the player itself in the vehicle, if you don't wan't this then simply stop reading.



Step 16 (EXTRA)
Ok so you wan't the player to spawn in the car? Open up the Radiant editor with the map you made during the tutorial.
Now select the trigger, and delete it.



Step 17 (EXTRA)
We will now use a script (already writen for you, by h0ly) to spawn the vehicle/actors, if you wan't you can turn the playerspawn back to normal, it doesn't matter now if it's facing the actors or not.
First, we have to set some new values to the vehicle, select the vehicle and add the following key/value in the entity window:

KEY: targetname
VALUE: unit1 (or any name you prefer, but if you chose a diffirent name don't forget to change it in the script)

Ok deselect your vehicle, and select the first pathnode, the one that has "START_NODE" cheked in the entity window, add the following key/value:

KEY: script_noteworthy
VALUE: startingpath (or any name you prefer, but if you chose a diffirent name don't forget to change it in the script)


Save your map and close the editor, now open up your sp_YOURMAPNAME.gsc and delete everything that's in it, next copy this entire script into it:


Code:
#include common_scripts\utility;
 
#include maps\_utility;
 main()
 
{
 
maps\_uaz::main("vehicle_uaz_light"); // DON'T FORGET TO CHANGE THIS SETTING (EXPLAINED IN STEP 14)
 
maps\_load::main();
 
maps\_vehicle::scripted_spawn(0);
 
//Some usefull playercommands
 
level.player disableweapons(); // Takes away all the players weapons
 
level.player allowcrouch(false); // Player is not allowed to crouch
 
level.player allowprone (false); // Player is not allowed to prone
 
//Carscript
 
level.vehicle = getent("unit1", "targetname"); // I called my vehicle unit1, remember? Fill in the name you chose.
 
path = getvehiclenode ("startingpath", "script_noteworthy"); // Same story, this is the START_NODE I was talking about, I named it startingpath.
 
level.vehicle attachPath(path);
 
level.vehicle startPath();
 
level.seat = spawn("script_model",level.vehicle.origin);
 
level.seat setmodel("tag_origin");
 
level.seat linkto(level.vehicle,"tag_guy3",(0,0,-25),(0,0,15)); // the tag_guy3 is the players startingposition, there's more then one, if you type a wrongone the console will give an error and show you all the available tag_'s  -  the numbers define the Y,X coördinates that the player is placed at in the seat. (explained in step 11)
 
level.player PlayerLinkToDelta( level.seat, "tag_origin", 0,50,50,50,50,0,"false" ); // All those 50's are the angles the player can view, use 360 if you wan't full viewangles.
 
}


NOTE: You can remove the "// blablabla" thingy's, everything with // and text behind it is ignored by the game, it's used to make things easier in a script for humans.



Step 18 (EXTRA)
Ok that's it, compile your BSP, then compile your FastFile (or update Zone Files if needed).
Run the map and you should spawn inside the vehicle.




Enjoy scripting/mapping!

Any problems with the tutorial?
Any problems with your map?

Add me on XFIRE = Jeannotvb or MSN/E-mail: Jeannotvb[at]hotmail[dot]com

NOTE: I'm still a beginner in scripting aswell, don't add me to ask any question about scripting related to something outside this tutorial or basic skills.

I will propably expand this tutorial with things such as headlights on the jeep.



Jeannot

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»