Multiple Mods Maps

Adding support to a map for multiple mods is fairly easy to do. It requires the use of variables and conditional statements. Variables must be declaired before they can be used with the 'Var' keyword and they must be named with a preceding 'v_'. Assigning the mod name to the variable is done like this:

Var v_modname
game.customGameName -> v_modname

This variable is used to selectively run code, depending on the mod, like so:

if v_modname == BF1942

... code to run for vanilla Battlefield ...

elseIf v_modname == XPack1

... code to run for Road to Rome ...

elseIf v_modname == XPack2

... code to run for Secret Weapons ...


... more mods...

endIf

A map loads in 3 stages. On the first pass, this file is run from the maps root folder:

<map root>/Menu/Init.con

This file sets up the loader screen and the menu icon. It also sets this attribute:

game.setMapId <Map Id>

Most mods set the map id to the mod name. Eve of Destruction uses a different map id, "EOD", than the mods name, "EoD", case does matter. So the setup for this file will look like:

... all the breifings ...

rem *** set map id
if v_modname == EoD
game.setMapId = EOD
else
game.setMapId = v_modname
endIf

rem *** set load screen and menu icon
if v_modname == BF1942

game.setLoadPicture ../../bf1942/levels/<map name>/menu/<load screen>
game.setServerInfoIcon ../../bf1942/levels/<map name>/menu/<menu icon>

elseIf v_modname == XPack1

game.setLoadPicture ../../bf1942/levels/<map name>/menu/<load screen>
game.setServerInfoIcon ../../bf1942/levels/<map name>/menu/<menu icon>
...

endIf

You don't really need to set the load screen and icon for each mod, but it does look nicer. The working directory, where the game looks for the load screen and server icon, is:

Menu/Texture

The long path above gets you to the maps Menu folder where you can include any custom load screens and icons.

The next file that is executed is the Init.con in the maps root folder. It defines the soldier type and classes. The same method we used above is used to set the soldiers up correctly for each mod we want to support:

... init code if v_modname == BF1942

game.setTeamSkin 1 JapaneseSoldier
game.setKit 1 0 Jap_Scout
game.setKit 1 1 Jap_Assault
game.setKit 1 2 Jap_AT
game.setKit 1 3 Jap_Medic
game.setKit 1 4 Jap_Engineer

game.setTeamSkin 2 USSoldier
game.setKit 2 0 USMarine_Scout
game.setKit 2 1 UsMarine_Assault
game.setKit 2 2 UsMarine_AT
game.setKit 2 3 USMarine_Medic
game.setKit 2 4 USMarine_Engineer

elseIf v_modname == XPack2

game.setTeamSkin 1 GermanEliteSoldier
game.setKit 1 0 GermanElite_Scout
game.setKit 1 1 GermanElite_Assault
game.setKit 1 2 GermanElite_AT
game.setKit 1 3 GermanElite_Medic
game.setKit 1 4 GermanElite_Engineer

game.setTeamSkin 2 BritishCommandoSoldier
game.setKit 2 0 Commando_Scout
game.setKit 2 1 Commando_Assault
game.setKit 2 2 Commando_AT
game.setKit 2 3 Commando_Medic
game.setKit 2 4 Commando_Engineer

... other mods

endIf

... the rest of the init code

Every mod has a choice of soldiers. Feel free to add the ones you want.

The next step is the most work, since we need to do this for every game type the map supports. Each game type has it's own folder for the scripts that set up the soldier and object spawns. For the most part, we are only concerned with:

ObjectSpawnTemplates.con

Fine tuning some mods might require modifying some of the others, but this is the file that needs the most attention. First we create a variable for every object that is spawned by the spawners, then we assing the object template we want to use for each mod to the vaiable, like so:

Var v_modname

rem ** declare the variables
Var v_apc1
Var v_apc2
Var v_arty1
Var v_arty2
Var v_ltank1
Var v_ltank2
... more variables

rem *** assign object templates to the vars
rem *** notice they can be left blank
game.customGameName -> v_modname
if v_modname == BF1942

v_apc1 = ho-ha
v_apc2 = m3a1
v_arty1 =
v_arty2 =
v_ltank1 = chi-ha
v_ltank2 = sherman
... more templates

elseIf v_modname == XPack2

v_apc1 = FlakPanzer
v_apc2 = LVT4
v_arty1 =
v_arty2 =
v_ltank1 = SturmTiger
v_ltank2 = Sherman_T34
... more templates

elseIf v_modname == DesertCombat

v_apc1 = shilka
v_apc2 = m163
v_arty1 = m-1974
v_arty2 = m-109
v_ltank1 = bmp2
v_ltank2 = m2a3
... more templates

... more mods

endIf

rem *** create the object spawners
ObjectTemplate.create ObjectSpawner APCSpawner
ObjectTemplate.setObjectTemplate 1 v_apc1
ObjectTemplate.setObjectTemplate 2 v_apc2
ObjectTemplate.MinSpawnDelay 30
ObjectTemplate.MaxSpawnDelay 90
ObjectTemplate.SpawnDelayAtStart 0
ObjectTemplate.TimeToLive 120
ObjectTemplate.Distance 120
ObjectTemplate.DamageWhenLost 10
ObjectTemplate.maxNrOfObjectSpawned 1
ObjectTemplate.teamOnVehicle 0

ObjectTemplate.create ObjectSpawner ArtySpawner
ObjectTemplate.setObjectTemplate 1 v_apc1
ObjectTemplate.setObjectTemplate 2 v_apc2
ObjectTemplate.MinSpawnDelay 30
ObjectTemplate.MaxSpawnDelay 90
ObjectTemplate.SpawnDelayAtStart 0
ObjectTemplate.TimeToLive 120
ObjectTemplate.Distance 120
ObjectTemplate.DamageWhenLost 10
ObjectTemplate.maxNrOfObjectSpawned 1
ObjectTemplate.teamOnVehicle 0

ObjectTemplate.create ObjectSpawner LightTankSpawner
ObjectTemplate.setObjectTemplate 1 v_ltank1
ObjectTemplate.setObjectTemplate 2 v_ltank2
ObjectTemplate.MinSpawnDelay 30
ObjectTemplate.MaxSpawnDelay 90
ObjectTemplate.SpawnDelayAtStart 0
ObjectTemplate.TimeToLive 120
ObjectTemplate.Distance 200
ObjectTemplate.DamageWhenLost 10
ObjectTemplate.maxNrOfObjectSpawned 1
ObjectTemplate.teamOnVehicle 0

... more object spawners

Now you can repack the map and it now support all the mods you've included in the code.