Jump to content
Official BF Editor Forums

Weapon Coding Tutorial

Recommended Posts

Hello everyone, since I have no computer to work on my mod, i though i'd post a small tutorial concerning some of the basic stuff in the .tweak files of the bf2 guns, this tutorial is meant for people who don't know what a certain code/line means:

Well let's get started:

Name of the gun:

ObjectTemplate.activeSafe GenericFireArm - This line means the name of the gun files, if this name is different than the gun folder, things get messy...

This concers crosshairs and other hitmarkers:

ObjectTemplate.weaponHud.guiIndex - This is the GuiIndex, this is what you see when you fire your gun from the hip, 0 is nothing, no crosshair, no hitmarker, 52 is the default crosshair.

ObjectTemplate.weaponHud.altGuiIndex - This is meant for zooming in, 53 is the default M4 red dot.

Fire Type:

ObjectTemplate.fire.addFireRate - The type of fire, 0 is semi-automatic, 1 is 3-round burst, and 2 is full-auto, 3 is crash!!


ObjectTemplate.zoom.zoomDelay - The time it takes until you can fire after you clicked the zoom button, please note, changing this to like 0.2 doesn't have any effect on the length of the zoom in, that lies in the animationsystem.inc!

ObjectTemplate.zoom.addZoomFactor 0

ObjectTemplate.zoom.addZoomFactor 0.8 - This specifies how much the screen zoomes in, 2nd line should be there, removing this line removes your ability to ADS.


ObjectTemplate.aiTemplate - Specifies which weapon.ai the gun uses.

Gun kit codes:

ObjectTemplate.itemIndex 3 - Specifies where the gun is placed in the kit, default Itemindex for usrif_m4 or rurif_ak47 is 3, uspis_92fs is 2, knife is 1, etc.

ObjectTemplate.delayToUse - Specifies the amount of TIME it takes until you can use the gun after you deployed it.

Projectile codes:

ObjectTemplate.tracerTemplate p_tracer_r - the type of tracer the gun uses.

ObjectTemplate.tracerInterval - If this is set to like 2, the gun fires every 2 shots, and so on.

ObjectTemplate.minDamage - The minimum amount of damage a gun can make

ObjectTemplate.damage - the maximum amount of damage a gun can make

ObjectTemplate.damageMandownSoldiers - Specifies if a dead body can be shot or not, 0 is no, 1 is yes

that's it

Edited by SkullTerror
Link to comment
Share on other sites

Can you add more on projectiles and tracers? Can/how they be changed, where to export/find them...?

How can i code 3D ironsights?

You can't, you need to change the animation and the weapon model. Technically all sights in BF2 are 3D, but the rear part is HUD texture while the front is an enlarged 3D model of the weapon's sight.

Link to comment
Share on other sites

  • 4 weeks later...

Nice, but think you were missing a few useful codes:

ObjectTemplate.fire.batchSize sets the amount of projectiles fired with one shot. Always used in shotguns. Also needs this in the

SoldierDeviationComp: ObjectTemplate.deviation.subProjectileDev so that the projectiles in one batch wouldn't go to the exact same place.

ObjectTemplate.fire.burstSize sets the amount of projectiles fired with one burst.

ObjectTemplate.zoom.mouseSpeedMod 0.8 changes the mouse sensitivity when a weapon is zoomed.

ObjectTemplate.ammo.nrOfMags sets the amount of mags the weapon has.

ObjectTemplate.ammo.magSize sets the amount of shots in one mag.

ObjectTemplate.ammo.reloadTime sets the amount of time the weapon reloads. Doesn't make the animation faster.

ObjectTemplate.heatAddWhenFire sets how fast the weapon gains the heat when it's firing.

ObjectTemplate.coolDownPerSec sets how fast the weapon cools down when it's not firing.

ObjectTemplate.overheatPenalty Sets the amount of time you can't fire a weapon if it has overheated.

ObjectTemplate.distToStartLoseDamage sets the distance after which the projectile starts losing its damage.

ObjectTemplate.distToMinDamage sets the distance the projectile has to travel to reach minimum damage(ObjectTemplate.minDamage).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...