_______________________________________________________________________ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Adding Vehicles:by Drumstix42 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --- --- --- --- --- --- --- --- - _______________________________________________________________________ This is a simple tutorial that will show the process of adding a vehicle to the game, but not a vehicle it self. This makes it easier so that in future tutorials with vehicles them selves, you can just refer to this one tutorial for each one. STEP #1: ----- -------------- vehicle_???.cs -------------- ----- In your first step for adding a vehicle, you must create it's file which is always in the format of: vehicle underscore(_) VEHICLE'SNameHERE .cs Ex.- vehicle_bomber.cs Your vehicle files all go in your scripts/vehicles folder. STEP #2: ----- -------------- serverVehicleHud.cs -------------- ----- In this step we open up serverVehicleHud.cs to add your vehicle the vehicle hud. You'll only need to add one block of code the the: function VehicleHud::updateHud( %obj, %client, %tag ) As you can see it's pretty much all the same code repeated for each vehicle. So, for adding a new vehicle, you add something like this in the place where you'd like to appear on the hud.(put in on the bottom of the list, it shows on the bottom of the vehicle hud): if ( %station.vehicle[VehicleDatablockNameHere] ) { messageClient( %client, 'SetLineHud', "", %tag, %count, "NameToAppearOnVehicleHudHere", "", VehicleDatablockNameHere, $VehicleMax[VehicleDatablockNameHere] - $VehicleTotalCount[%team, VehicleDatablockNameHere] ); %count++; } STEP #3: ----- -------------- vehicle.cs -------------- ----- There are many different parts that can be added in this file, making it the file that usually gets the most mistakes. Depending on what type of vehicle your adding termines the amount need to add. If you vehicle had no weapons, or anything mounted to it, then you wont too much. If your vehicle has either one of these, you'll need much more. For a vehicle such as the shrike, you'll first need a function to this section: //************************************************************** //* VEHICLE CREATION //************************************************************** In this part there is no scout vehicle since it does not have any weapons function ScoutFlyer::onAdd(%this, %obj) { Parent::onAdd(%this, %obj); %obj.mountImage(ScoutChaingunParam, 0); %obj.mountImage(ScoutChaingunImage, 2); %obj.mountImage(ScoutChaingunPairImage, 3); %obj.nextWeaponFire = 2; %obj.schedule(5500, "playThread", $ActivateThread, "activate"); } This is the example of the shrike in which the code is calling for the shrikes weapons to be mounted when it's added to the game. The next place to add code would be under the: //************************************************************** //* WEAPON MOUNTING ON VEHICLES //************************************************************** Here's the shrike code again(you can also find the ScoutVehicle in this part): function ScoutFlyer::playerMounted(%data, %obj, %player, %node) { // scout flyer == SUV (single-user vehicle) commandToClient(%player.client, 'setHudMode', 'Pilot', "Shrike", %node); $numVWeapons = 1; // update observers who are following this guy... if( %player.client.observeCount > 0 ) resetObserveFollow( %player.client, false ); } This code is tell the game what type of seats are in the vehicle and how many weapons the vehicle has. It also has some code for observers following that player. Next comes: //************************************************************** //* VEHICLE INVENTORY MANAGEMENT //************************************************************** Here we simply put in the vehicle maxes for the game: $VehicleRespawnTime = 15000; $Vehiclemax[ScoutVehicle] = 4; $VehicleMax[AssaultVehicle] = 3; $VehicleMax[MobileBaseVehicle] = 1; $VehicleMax[ScoutFlyer] = 4; $VehicleMax[BomberFlyer] = 2; $VehicleMax[HAPCFlyer] = 2; The last part in this file has to do with this function: function clearVehicleCount(%team) All this function does is clear the vehicles at the end of a mission and make sure there's 0 of each when the mission starts. $VehicleTotalCount[%team, ScoutVehicle] = 0; $VehicleTotalCount[%team, AssaultVehicle] = 0; $VehicleTotalCount[%team, MobileBaseVehicle] = 0; $VehicleTotalCount[%team, ScoutFlyer] = 0; $VehicleTotalCount[%team, BomberFlyer] = 0; $VehicleTotalCount[%team, HAPCFlyer] = 0; STEP #4: ----- -------------- station.cs (scripts folder) -------------- ----- The final step of adding a vehicle takes its part in: function StationVehiclePad::createStationVehicle(%data, %obj) This function used to be called: function StationVehiclePad::onAdd(%data, %obj) Details of its change are within the file if you do a seach on it. The code we are adding is at the very bottom of the file: //Remove unwanted vehicles if(%obj.scoutVehicle !$= "Removed") %sv.vehicle[scoutvehicle] = true; if(%obj.assaultVehicle !$= "Removed") %sv.vehicle[assaultVehicle] = true; if(%obj.mobileBaseVehicle !$= "Removed") %sv.vehicle[mobileBasevehicle] = true; if(%obj.scoutFlyer !$= "Removed") %sv.vehicle[scoutFlyer] = true; if(%obj.bomberFlyer !$= "Removed") %sv.vehicle[bomberFlyer] = true; if(%obj.hapcFlyer !$= "Removed") %sv.vehicle[hapcFlyer] = true; This is also another remove vehicles function that's very important from overloading the game with vehicles. For adding another vehicle here would look something like this: if(%obj.VehicleDatablockHere !$= "Removed") %sv.vehicle[VehicleDatablockHere] = true; STEP #5: ----- -------------- server.cs (scripts folder) -------------- ----- Last thing is to exec it. You will see the other vehicle being execed all together. Just place your exec line under the last vehicle in there. exec("scripts/vehicles/yourVehicle.cs"); And that's about it for adding a vehicle to game besides the vehicle itself! Hope this was easy to follow and a helpful tool to use.