Home   FORUM Help Login Register  
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
* *

PUKF Info

User Info

Welcome, Guest. Please login or register.
Did you miss your activation email?
September 07, 2010, 02:44:54 PM

Login with username, password and session length

Who's Online

7 Guests, 1 User
da12thMonkey
written by swift88 | 8332 Views | 1 Comments | Rating: (1 rates)

Vehicle configs (Pt 1) - by Swift88

So you want to do a config… But you don't know how to do it? Well all you need is notepad open and a lot of time looking at # {};

I am going to give you an easy 2 part step-by step example of how to easily create a config.cpp (I'll just call it a cpp from now on).

A cpp is just a text document, sometimes it contains complicated scripting, but mainly it just tells OFP how you want your vehicle to behave. It can define anything from the ammunition type, to the colour of the lights which come from the vehicle.

Cpp's may seem hard, but once you understand the format and layout it is really quite easy.

A cpp consists of many sections, here are the main OFP sections which are important to config a vehicle:




CfgPatches - relates to what OFP version is required, what unit names are used in the game, which weapons are used (Which have been stated in CFG weapons - see below) and what add-ons this vehicle relies on to work. This is where we define the name of the PBO that all of our files are inside. IMPORTANT - the classname here has to match our PBO name. We can define as many different types of vehicle, weapons, magazines, etc, as we want in here, but for the purpose of this tutorial we'll just be creating one vehicle.

CfgModels - this is where the vehicle has its class defined - almost everything in OFP is defined using a 'class' - this is because OFP is object oriented - google on this if you're really interested, but basically all it means is that you can 'inherit' from other classes, for example, you can inherit from a standard BIS M1A1 tank and call it anything you want. Some limited settings are inherited from the base classes which are things like Helicopter, Car, and Tank amongst others. This section also lists any sections the vehicle has, this is useful if they are going to be hidden in game, and for somet other things. IMPORTANT - The classname of each vehicle we define in this section must match its p3d (model) name.

CfgAmmo - this is where the vehicles ammunition and magazines are configured.

CfgWeapons - this is similar to CFG ammo, however defines the weapon being used.

CfgSounds - If you want to add a custom sound, like say for instance the egine for the warrior or the landrover, this is where to define it.

CfgVehicles (in part2) - basically this is where the whole vehicle is defined. This states what Directory the p3d (the model for the vehicle) is in, and nearly every other setting defining how the vehicle interacts with the OFP environment, speed, acceleration, armour, number of magazine, number of crew, cargo (passengers) etc etc.

CfgNonAiVehicles (in part 2) - where animations for the crew and cargo are defined.

CfgTextureToMaterial (in part2) - say you want a metal texture to look like its metal ingame. It has numerous Types of materials to choose from, but I am not too familiar to it so im not going to go any further on this one.




Cpps always have the same amount of { as they do } (these are called curly braces and the number of left hand ones is always equal to the number of right hand ones), and nearly every line has ; when the line is over, unless its the start line of a class! (These are called semi colons)

heres an example of { } using the CfgPatches section:

class CfgPatches
{

class UKF_Sankeys

{
units[] = {UKF_Sankey};
weapons[] = {};
requiredVersion = 1.91;
};
};


From this I can see that it's the CFG Patches section (with a { to open the class), which states the pbo we're defining has a class name of UKF_Sankeys IMPORTANT - This has to match the pbo name of the vehicle. UKF_Sankeys has one unit called ukf_sankey (it has to be the same as the cfg vehicles class name defined for this vehicle). It has no weapons and requires version 1.91 of OFP. You can see that we 'closed' each of curly braces with }; the first one closed our custom class UKF_Sankeys, the second one closes the CfgPatches section.Note how each time a curly brace has been opened we've indented by 2 spaces, and each time one is close we remove an indent - this can help keep track of whether enough braces are used in complicated configs.

Next is Cfgmodels, where things like hidden selections are defined, and what base class the vehicle uses (ie. Tank boat etc):

class CfgModels
{
class default {};
class Vehicle: default {};
class Car: Vehicle
{
sectionsInherit="Vehicle";
sections[]={"hitch"};
};
class UKF_Sankey: Car {};
};


This shows the vehicle inherits from the base class car (which in turn inherits from Vehicle, and in turn default), and that there is a section called Hitch (which maybe a hidden selection later using a setobjecttexture option). Here we define our class of UKF_Sankey which inherits from car. IMPORTANT - The classname defined here must match the P3d name of the model.

Next we have CfgAmmo and CfgWeapons which ill try and breeze past. Although ammo and weapons are configured below these are just for example purposes

class CfgAmmo
{
class default {};
class BulletSingle: Default {};
class Bullet7_6: BulletSingle {};
class Bullet12_7: Bullet7_6 {};

class ukf_mcar_dummymilan: Bullet12_7
{
airLock=1;
hit=1500;
indirectHit=100;
indirectHitRange=.5;
minRange=100;
minRangeProbab=.9;
midRange=1500;
midRangeProbab=0.9;
maxRange=3500;
maxRangeProbab=0.8;
soundHit[]={"",0,1};
soundHitMan[]={"",0,1};
soundHitArmor[]={"",0,1};
soundHitBuilding[]={"",0,1};
soundFly[]={"",0.010000,2};
soundEngine[]={"",0.001000,1};
explosive=0;
initTime=-1.000000;
cost=1000;
tracerColor[]={0,0,0,0.001};
};
};


I'm not going to explain the ammunition CFG properties, but as you can see it is rather easy to see how it works however the sound properties normally have a sound file in the "" (quotes) areas, this is where you would put a patch to your custom sounds. To use the default sounds inherited from Bullet12_7 delete these lines - only things which we define in our class will overide the settings from the class we inherit from.

If you look at the Top you see

class default {};

class BulletSingle: Default {};

This is defining what base class the ammo is using. By inheriting from similar base classes you can save a lot of time doing pages of configing and tests! Which to be honest would be rather boring!

class CfgWeapons
{
class Default {};
class UKF_155mmHEMag: Default
{
ammo="UKF_155mmHE";
scopeWeapon=0;
scopeMagazine=2;
displayName="155mm HE";
shortNameMagazine="155mm HE";
displayNameMagazine="155mm HE";
opticsZoomMin=0.040000;
opticsZoomMax=0.120000;
distanceZoomMin=4000;
distanceZoomMax=110;
canlock=1;
recoil="Naval";
count=15;
initSpeed=850;
thrustTime=0;
reloadTime=8;
magazineReloadTime=2;
sound[]={"Weaponsgun120",10.000000,1};
reloadSound[]={"Weaponsmissload",0.000316,1};
flash="gunfire";
flashSize=10.00000;
};
};


Here, as above, I thought id just show you an example of the CFG.

Next is Cfgsounds.

class CfgSounds
{
class connect
{
sound[]={"ukf_sankeyconx",6,1};
name = "connect";
titles[] = {};
};
};


As you can see its basically the sound with the filename and sound volume of how far you can hear it, and the name of it just in case you need to add it to a init and don't want to define it all over again.

Now, go away look at a few Configs and see if this helped at all... if you didnt understand this, then dont continue as this is easy in comparison to CFG vehicles, which we'll tackle in part 2.

Comments: (1 Comments , 0 are new)

Recent Threads

TinyPortal v1.0 beta 4 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Army Green Theme By Wdm2005 © 2008
Valid XHTML 1.0! Valid CSS!