Battlefield Modding

The Official Modding Resource for Battlefield 1942 and the Battlefield Series
It is currently Mon Oct 19, 2009 5:30 pm


Getting Started
Getting Started
Prepping Your Files
  Testing Methods
Auto-Start Map
True Testing Enviroment
General How-To's
Stop Base Camping
Removing Out Of Bounds
Stop Base Camping 2
Disabling Parachutes
Add Repair Points
Add Spawn Points
Paradrops
Main Base Swapping
Modifying the Point System
Conquest Ticket System
Making CTF Versions of Maps
Vehicle How-To's
Replace/Add Vehicles
Lock Vehicles
Partially Disabling Vehicles
Totally Disabling Vehicles
Making a Carbomb
Adding Nitrous
Making Amphibious
Performance Tweaking
Adding Healing Supply
Adding/Changing/Removing Carrier Vehicles
Weapon How-To's
Spawn Weapon Kits
Change the Weapon Kits of Soldiers
Modifying Weapon Attributes
Disabling Weapons
Modifying the Damage System
Disabling Overheating
 
 
 
Fix Wall Hacks
How to Fix Wall/Floor Hacks
Basrah's Edge
Lost Village
Stalingrad
Al Khafji Docks
El Alamein
Other Fixes
Leaning F16 Fix
Glass Humvee
Oil Fields Exploding A-10
Operation Bragg Fixes
 
 
References
Object List
Weapon Kits List
Global Object Spawners
Global Soldier Spawns
Projectile Material Numbers
 

Modifying the Damage System

This tutorial is divided into four sections.

1) The first section shows how to modify the damage of the stinger by changing the material number of the projectile, while at the same time trying to get the reader to understand the damage system in the process.

2) The second section shows how to make the same modification, but by creating a new material number server side only.

3) The third section explains the damage system in more detail and also discusses how to change the damage of a material against a specific topic.

4) The fourth section shows how to change a single weapon's damage against a target (even if other weapons use the same material number).

1) Changing a Projectile's Material Number

I've been reading about the damage system in BF, and thought I'd try screwing around with the stinger. My goal was to make the stinger more powerfull, but do it server side only.

If you look at the objects.rfa file for DC, and look at OBJECTS\handweapons\Stinger\Objects.rfa, you'll see the definition of the stinger. go down till you see the line that says:

ObjectTemplate.projectileTemplate StingerMissile

every hand weapon should have a line like this. it tells you what the projectile is for the weapon. now for the stinger, it's projectile is defined in OBJECTS\handweapons\StingerMissile\Weapons.con. but for most other weapons (like machine guns, etc), you can find their projectile info in OBJECTS\handweapons\common\weapons.con

so looking at OBJECTS\handweapons\StingerMissile\Weapons.con, you'll see the projectile info for StingerMissile. the lines we are concerned about are the ones that say:

ObjectTemplate.material 850
ObjectTemplate.material2 850

these numbers define the material of the projectile. basically, the BF server uses this number to find an entry in the game.rfa (bf1942\game\materialManagerdefine.con), which is the base damage that material causes. if you looked up 850, you'll see the stinger:

rem Stinger Missile
MaterialManager.material 850
MaterialManager.materialAttGroup 850
MaterialManager.materialDefGroup 850
MaterialManager.materialDamage 10

but stop here. we don't care about this for now, We will pick up here in the next section. what we are going to do right now is just flat out change the material of the stinger. i thought the SMAW material would be cool.

If you look up the material for the SMAW, you'll see it is:

ObjectTemplate.material 226
ObjectTemplate.material2 707

by the way, the material2 is used for splash damage, whereas material is just direct damage.

so lets do it! I'll use lost village as an example. open up your ObjectSpawnTemplates.con file, and add these lines at the end of the file:

ObjectTemplate.Active StingerMissile
ObjectTemplate.material 226
ObjectTemplate.material2 707

Now try firing a stinger missile. it still looks like a stinger, acts like a stinger, but now it does nasty splash damage, and can drop a blackhawk in one shot. of course, it'll probly take out a humvee in one shot too.. dunno didn't test it.

2) Creating a new Material Number

Now if you didn't want to change the material # of the stinger, you could have instead just increased the materialDamage of the stinger material. This could either be done in the game.rfa itself, or on a per map basis.

To do it on a per map basis, what we'll do is create a brand new material number, and use the existing stinger attGroup and defGroup, but increase the materialDamage.

First, we need to find a material number that isn't already being used. After doing a search in the game.rfa, i discovered that material number 851 is not being used for anything. Using 851 as our new material number, the following code at the end of your ObjectSpawnTemplates.con file would increase the stinger's materialDamage to 30:

ObjectTemplate.Active StingerMissile
ObjectTemplate.material 851
ObjectTemplate.material2 851

rem New Super Stinger Missile
MaterialManager.material 851
MaterialManager.materialAttGroup 850
MaterialManager.materialDefGroup 850
MaterialManager.materialDamage 30

Notice we ObjectTemplate.Active the StingerMissile Projectile, and change it's material and material2 to our new material number (851). Then we define 851 to be just like 850, except that increase the materialDamage to 30.

3) Modifying the Damage a weapon does to a specific target

OK, we saw how to modify a parameter that affects how overall powerful a weapon is, but what if we want to modify the damage a weapon does to a specific target?

For that, lets look at the damage system a little deeper.

First off, the basic formula for computing damage in the BF engine is:

Hitpoints = MaterialDamage * DamageMod * AngleFalloff * DistanceMod

Lets walk through these:

AngleFalloff
nothing we can do about this one. Basically, if you hit a target dead on (instead of at an angle) you'll do maximum damage. Otherwise, you'll do partial damage (the formula for AngleFalloff is cosine(angle), where an angle of 0 is a straight on hit, which would yield a cosine(0) = 1, and an angle like 89 would be a barely missed graze off the surface, which would yield a cosing(89) = almost 0).

DistanceMod
This is a number between minDamage and 1 which is affected by distance for some weapons. The relavent settings for this can be found in OBJECTS.RFA:objects\handweapons\Common\Weapons.con. An example entry for the shotgun is:

ObjectTemplate.minDamage 0.5
ObjectTemplate.distToStartLoseDamage 40
ObjectTemplate.distToMinDamage 80

What this means is that if your within 40 meters, the DistanceMod will be 1. if you are further than 80 meters, then the DistanceMod will be .5. If you are between 40 to 80 meters, the DistanceMod is determined by this formula:

DistanceMod = minDamage + (1-minDamage) * (distToMinDamage - distance) / (distToMinDamage - distToStartLoseDamage)

You could probably use an ObjectTemplate.Active in your map RFA's to reopen the projectile in question and change these. I havn't tried it so I'll leave it as an excersice to the reader.

MaterialDamage
The first section covered this setting. Every material that exists for a weapon has this setting. It is an overall number that you can tweak if a weapon is generally too powerful, or not powerfull enough.

As an example, we're going to increase the amount of damage the stinger does to infantry.

First, we find the Stinger's projectile template in the objects.rfa:OBJECTS\handweapons\Stinger\Objects.rfa. It is:

ObjectTemplate.projectileTemplate StingerMissile

looking at objects.rfa:OBJECTS\handweapons\StingerMissile\Weapons.con, we get the material of the Stinger:

ObjectTemplate.material 850
ObjectTemplate.material2 850

Remember, material is direct damage, and material2 is for splash damage.

Now open up the game.rfa:bf1942\game\materialManagerdefine.con, and look down till you see the stinger material 850 lines:

rem Stinger Missile
MaterialManager.material 850
MaterialManager.materialAttGroup 850
MaterialManager.materialDefGroup 850
MaterialManager.materialDamage 10

We could increase the materialDamage for the stinger to make it more powerful as described in the previous section, however, this would affect all targets. We only want to increase the damage to infantry. Which is what DamageMod is going to do for us.

DamageMod

Staying in the game.rfa, open up bf1942\Game\damage_system\StingerMissile.con

The first three lines are the damage the stinger does to infantry:

MaterialManager.attGroup 850
MaterialManager.defGroup 40
MaterialManager.damageMod .1
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 850
MaterialManager.defGroup 41
MaterialManager.damageMod .1
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 850
MaterialManager.defGroup 42
MaterialManager.damageMod .1
MaterialManager.setEffectTemplate e_ExplGranade

40 is head, 41 is trunk, 42 is limbs. Notice the damageMod of .1! WTF??? A stinger is a missile, and if it hits you, it's gonna freekin hurt. Lets fix this.

Lets change it to 1 instead of .1. Lets rem out the original lines and add the new code. So now we have:

MaterialManager.attGroup 850
MaterialManager.defGroup 40
rem MaterialManager.damageMod .1
MaterialManager.damageMod 1
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 850
MaterialManager.defGroup 41
rem MaterialManager.damageMod .1
MaterialManager.damageMod 1
MaterialManager.setEffectTemplate e_ExplGranade

MaterialManager.attGroup 850
MaterialManager.defGroup 42
rem MaterialManager.damageMod .1
MaterialManager.damageMod 1
MaterialManager.setEffectTemplate e_ExplGranade

Now that knocks off about a bar and a half. Good enough for me. Tweak it to your liking.

The rest of the file defines the damage done to other materials. Materials for models are defined in 3dmax when the model is made. Check the reference section of this site for a list of materials and where they are used.

4) Changing specific target damamge on a per map basis

Sometimes, more than one weapon uses the same material number. Therefore, adjusting the values in the previous section would affect all projectiles that use that material number.

What if you only wanted to change the damage a certain projectile does against a target, but do not want to affect the damage other projectiles do that might be using that same material number?

Using the method described in Section 2 above, this can be accompished. This can either be done in the game.rfa (which would affect all maps), or on a per map basis.

Lets say we want to adjust the splash damage done by a SMAW or RPG against infantry (we're going to decrease it). Checking the game.rfa, 852 is not being used by any material, so we're going to use that as our new material for SMAW/RPG splash.

We'll put this in our ObjectSpawnTemplates.con of our map rfa (or we can put it in the game.rfa, in bf1942\game\materialManagerdefine.con).

rem Modified SMAW Splash
MaterialManager.material 852
MaterialManager.materialAttGroup 852
MaterialManager.materialDefGroup 852
MaterialManager.materialDamage 10

Now, if you look at the objects.con for the RPG or SMAW, you'll see the material used for splash (material2) is 707. Unfortunately, this is the same material grenades use for splash as well, and we don't want to affect grenades, just SMAWs and RPGs.

We can either change this 707 here to be 852 (which would affect all maps), or we can put the following code at the end of our ObjectSpawnTemplates.con:

ObjectTemplate.Active RPGProjectile
ObjectTemplate.material2 852

ObjectTemplate.Active SMAWProjectile
ObjectTemplate.material2 852 

The only thing left to do now is to define material 852 in its entirety. What we'll do is copy and paste all the settings for material 707, and change all the 707s to be 852s. This can either be done in the game.rfa, at the end of an existing file under damage_system\, or at the end of ObjectSpawnTemplates.con.

The result would look like this (the infantry lines that were changed are in bold):

rem *** modified SMAW splash (material 852) ***
rem * *************************************************
rem *      Infantry target
rem * *************************************************
MaterialManager.attGroup 852
MaterialManager.defGroup 40
MaterialManager.damageMod 3.5

MaterialManager.attGroup 852
MaterialManager.defGroup 41
MaterialManager.damageMod 1.0

MaterialManager.attGroup 852
MaterialManager.defGroup 42
MaterialManager.damageMod .25

rem * *************************************************
rem *      scout cars target
rem * *************************************************

MaterialManager.attGroup 852
MaterialManager.defGroup 43
MaterialManager.damageMod 5

MaterialManager.attGroup 852
MaterialManager.defGroup 44
MaterialManager.damageMod 5


rem * *************************************************
rem *      Light Vehicle target
rem * *************************************************

MaterialManager.attGroup 852
MaterialManager.defGroup 45
MaterialManager.damageMod 7

MaterialManager.attGroup 852
MaterialManager.defGroup 46
MaterialManager.damageMod 7

MaterialManager.attGroup 852
MaterialManager.defGroup 47
MaterialManager.damageMod 5

MaterialManager.attGroup 852
MaterialManager.defGroup 48
MaterialManager.damageMod 5

MaterialManager.attGroup 852
MaterialManager.defGroup 49
MaterialManager.damageMod 5


rem * *************************************************
rem *      Heavy Vehicle target
rem * *************************************************

MaterialManager.attGroup 852
MaterialManager.defGroup 50
MaterialManager.damageMod 1

MaterialManager.attGroup 852
MaterialManager.defGroup 51
MaterialManager.damageMod 0

MaterialManager.attGroup 852
MaterialManager.defGroup 52
MaterialManager.damageMod 0

MaterialManager.attGroup 852
MaterialManager.defGroup 53
MaterialManager.damageMod 0

MaterialManager.attGroup 852
MaterialManager.defGroup 54
MaterialManager.damageMod 0

rem * *************************************************
rem *      Planes target
rem * *************************************************

MaterialManager.attGroup 852
MaterialManager.defGroup 60
MaterialManager.damageMod 5

MaterialManager.attGroup 852
MaterialManager.defGroup 61
MaterialManager.damageMod 5

MaterialManager.attGroup 852
MaterialManager.defGroup 62
MaterialManager.damageMod 4

MaterialManager.attGroup 852
MaterialManager.defGroup 63
MaterialManager.damageMod 4

rem * *************************************************
rem *      Default
rem * *************************************************

MaterialManager.attGroup 852
MaterialManager.defGroup 0
MaterialManager.damageMod 0.0

MaterialManager.attGroup 852
MaterialManager.defGroup 1
MaterialManager.damageMod 0.0
cron

©2009
No materials may be duplicated under any circumstances.