Modding/Examples

Intro
Some modding examples, starting easy and getting more complex.

Remember to read Making a Simple Mod before you go any further if you're new to modding.

Changing Vehicle Armor Values
("armor_heavy" turret(600 600 600 300) body(600 300 300 200) body2(600 300 300 200) body3(600 300 300 200)) ("armor_mantlet" t(800)) ("armor_engine" t(100 100 100 100)) ("armor_heavy" turret(350 170 50 40) body(350 150 60 40) body2(350 150 60 40) body3(350 150 60 40)) ("armor_mantlet" t(350)) ("armor_engine" t(100 100 100 100))
 * Armor is represented in each vehicle's 3D model. But it's thickness value is exposed in the data files and is easy to change. (See here for details)
 * As an example, we'll change the M1A2 Abrams to old M1 protection levels.
 * Open \resource\entity\-vehicle\usa\m1a2_abrams\m1a2_abrams.def and scroll down to the armor section which looks like this:
 * The values are for (front side rear top). Most vehicles have multiple "body" pieces that make up their armor, so you'll need to apply the same changes to each one:


 * NOTE: The game engine does not support different armor values vs. HEAT weapons, so Chobham/ERA/etc. have no impact in the game.

Adding Different Speeds to Tank Ammo
The deault weapon file looks like this: {from "pattern gun" ... 	("speed" s(1000)) ("caliber_large") {projectileDamage 1100} ("damage" a(1100) b(900) c(700) d(500) e(300)) {parameters "heat" ("damage_cumulative" a(700)) } 	{parameters "atgm" ("damage_cumulative" a(1000)) {bullet_view "9m119_ammo" {tail "tow_tail" "tail"} } 		("speed2" s(278)) {gravity 0} }       ...  } Add more details to the existing {parameters} and a new {parameters} for the HE round (called "fg" in the data files): {parameters "heat" ("damage_cumulative" a(700)) (speed s(900))      ;<--new line } 	{parameters "atgm" ("damage_cumulative" a(1000)) {bullet_view "9m119_ammo" {tail "tow_tail" "tail"} } 		("speed2" s(278)) {gravity 0} } 	{parameters "fg"            ;<--new entry ("speed2" s(1250)) }
 * Let's start with a very simple mod to enhance game realism slightly. We're going to differentiate the speed settings for different types of tank ammunition. We'll use the T-80BV.
 * There's only one file being edited here: [\gamelogic\set\stuff\gun\12mm_2a46m-1], so that's the only file you'd need in your mod directory in the "resources" sub-folder.

Adding an ATGM to the T-62

 * This is a good example of making a seemingly simple change which requires going through several different related files to accomplish.
 * The goal here is to take a plain old tank and enhance it with a gun-launched ATGM.
 * Comparing files with the ATGM-equipped T-80U, you can discover what needs to be added to the T-62 to give it a similar (made-up) weapon.
 * (The steps below are numbered but the order doesn't matter).

1.Change Vehicle DEF: [entity\-vehicle\grm\t-62\t-62.def] {extender "inventory" {box {item "ammo bullet115 ap" 20} {item "ammo bullet115 fg" 10} {item "ammo bullet115 atgm" 10} ;<--new line {item "ammo 7x54" 2500} {item "ammo 12x108" 1000} {item "grenade decoy" 1} }
 * Changing the entire gun in {Weaponry} to the T-80U's would work, but is too simplistic.
 * Add a new line to the inventory--a new ammo type which doesn't exist yet

2.Change Weapon: [gamelogic\set\stuff\gun\115mm_2a20] {parameters "fg" ("speed2" s(100)) } ;-BELOW IS ADDED- {parameters "atgm" ("damage_cumulative" a(600)) ;<--mm of penetration (any range) {bullet_view "9m119_ammo"   ;<--just copies of T-80U visuals {tail "tow_tail" "tail"} } 	("speed2" s(250)) ;<--flight speed in m/s {gravity 0}      ;<--missiles need 0 gravity as they don't drop }
 * Add ATGM parameters to the gun (made-up numbers, except for gravity).
 * The vehicle & its gun are ready. Now we need to create the ammo.

3.Add Ammo inventory item: [entity\inventory\-ammo\-shell\9m119_ammo\] {game_entity (include "/properties/stuff.ext") {Extension "9m115_ammo.mdl"} {extender "stuff" {item "ammo bullet115 atgm"} ;<--same name as added in step #1 } }
 * Copy this directory and rename it "9m115_ammo".
 * Rename "9m119_ammo.def" to "9m115_ammo.def". Rename "9m119_ammo.mdl" to "9m115_ammo.mdl".
 * Edit 9m115_ammo.def to be this:

4.Add Ammo "Bullet": [gamelogic\set\stuff\shell\bullet125.atgm.ammo] {entity "9m115_ammo"} ;<--same name as folder & file in step #3
 * Copy this file and rename it "bullet115.atgm.ammo", change the {entity} line to:

5.Add Ammo description: [\localization\desc.lng] {"bullet115 atgm" "115mm My Little ATGM"} ;The 1st name is from step #1, the 2nd name can be whatever you want
 * Create a "localization" folder under your mod folder.
 * Copy \localization\desc.lng into it.
 * Add the following line in the {"ammo"} section:
 * This is the name that appears in the HUD when the weapon is selected.

Porting Old MoW Content: Adding a WW2 Tank
In this case we're simply adding the vehicle to the existing USA team. The better way to do this would be to create a new nationality and add it there. TIPS ;-Example is from Assault Squad 2's Pz4g tank MDL file- ;-FROM THIS: {bone revolute "gun_rot" {parameters "ID=gun_rot;"} {limits -8 22} {speed 0.01} {Matrix34 1	0	0 		0	0	1  		0	-1	0  		17.7642	-1.28549	6.06673  	}
 * Copy over vehicle folder \entity\-vehicle\usa\
 * You may need to tweak the MDL file (which contains the model skeleton)--see TIPS below.
 * Copy over its gun file into \gamelogic\set\stuff\gun\
 * Replace, comment out, or also port over the fire & reload sounds to ??? folder
 * Don't forget any coax (or other) mguns too--or comment out them out, they would go in the ?? folder
 * Copy over it's (3) -shell folders into \entity\inventory\-ammo\-shell\
 * Copy over its (3) "bullet..." files into \gamelogic\set\stuff\shell\
 * (for now) duplicate ap.pattern and rename apcr.pattern (or comment out)
 * If there are missing defines (the apcr.pattern here), then they need to be added to the ".presets" file
 * Add line to \gamelogic\set\multiplayer\units\vehicles_usa.set (we’re adding it to the us side in this case)
 * This adds the unit to purchase button list (although there seems to be some other factor that combines to influence it's position on the list other than just position in the file).
 * Add fps control entry to \gamelogic\set\tp_control.set
 * This controls some of the visual settings in FPS mode (but not gunsight bitmap)
 * Add line to localization\desc.lng
 * This is the name of the vehicle that appears to the player in game.
 * Copy over TGA’s to \interface\scene\unit_icon\
 * Add line to \gamelogic\set\registry\unit.reg (copy an existing tank)
 * Add line to \gamelogic\script\multiplayer\bot.data.lua (copy an existing tank)
 * Add entry to \gamelogic\set\interaction_entity\tank.inc (copy existing tank)
 * Controls movement sounds (engine, turret, etc.) and a few other things
 * Test the ported unit by trying to place it in the Editor
 * The Editor will crash and report errors, which are helpful.
 * Trying to place a faulty unit in game will just result in a mysteriously missing unit and you won't know why.
 * Tweaking the MDL file to fix turret rotation
 * Old MoW vehicle (from Assault Squad 2 at least) have a "gun_rot" (gun depression/elevation bone) orientation problem that makes the turret misalign with the gunsight when pointing the gun downward.
 * This is fixed by going into it's {Matrix34} and setting its orientation to match that of CtA "gun_rot" bones:

;-TO THIS: {bone revolute "gun_rot" {parameters "ID=gun_rot;"} {limits -8 22} {speed 0.01} {Matrix34 1	0	0 		0	0	-1   ;<switched sign on the 1 0	1	0   ;<switched sign on the 1 17.7642	-1.28549	6.06673 	}

ISSUES
 * Missing textures
 * You need to rifle through texture folders outside the vehicle folder to find the occasional munition, shared track or camouflage texture.

Adding (or Changing) a Vehicle to a Faction
Any functioning vehicle can be added to a faction very easily: simply modify the faction's "vehicles_XXX.set" file. You can move vehicles between factions just as easily. You can even share vehicles across factions, but there is a caveat there.

The game does not really differentiate between *.set files. You can go into any *.set file and by simply changing the faction--"s(XXX)"--of a vehicle, it will disappear as a purchase option for the old faction and appear in the new faction.

Simple Version
 * 1) Open "\set\multiplayer\units\vehicles_usa.set" & "vehicles_grm.set"
 * 2) Copy-paste the {"technical_lmg"...} line from vehicles_grm to vehicles_usa.
 * 3) *You now have a playable GRM vehicle on the USA team. But the crew will be GRM soldiers. If you want to fix this, read further.
 * 4) You must disable (delete or comment out) the {"technical_lmg"...} from "vehicles_grm" for the correct (US in this case) crew to show up.

Alternate Method (not recommended but it works) Because the game doesn't care which *.set file a unit is defined in, you could also:
 * 1) Open "\set\multiplayer\units\vehicles_grm.set"
 * 2) In the {"technical_lmg"}, change s(grm) to s(usa)
 * The Humvee vehicle is now gone from the GRM faction and will appear in the USA faction purchase buttons (with a US crew).
 * This is a bit confusing, however, since most people wouldn't think to look in the wrong faction for a vehicle entry.

Full Method If you want both factions to have the same vehicle, and for the correct crew to appear, you (probably) need to:
 * 1) Duplicate the vehicle--its \entity\-vehicle\... folder--and give it another name. e.g. "technical_lmg_usa".
 * 2) Add a line for this vehicle copy into the desired faction *.set file. Obviously make sure the s(XXX) line lists the correct faction.

Editing a Ported Vehicle

 * The vehicle must be imported into Blender, and then exported to 3DS Max for editing and export.