Adding Units to Warfare Factories

A while back I did a series of posts explaining how to add custom units to the Warfare modules’ Aircraft factory. see

It was long and involved and while correct, there is an easier way. So if you haven’t read those posts, read this one first and decide which one works for your mission.

The premise for this example is that you want to create a basically stock Warfare mission, but just want to add a CH-47 to the Aircraft Factory.

 

In The Mission Editor

Warfare Module Synced to USMC Rifleman

The first step is to insert a player unit (USMC Rifleman) and the Warfare module into the mission. As usual use F5 to sync the player to the module. Always make sure that the player unit is not grouped to the module. Note that I’m using the USMC Rifleman, as that unit is recognized by the module without any additional work on my part.

In the Warfare module’s initialization field, type the following code:

BIS_WF_Common SetVariable ["customInitMissionScript","InitMission.sqf"];

This will tell the module that I’m going to call a script (InitMission.sqf in this example) that will contain my custom initialization scripts. Save the mission then open up the text editor of your choice.

 

In The Text Editor

First create the file InitMission.sqf that we specified in the editor. This will contain some script telling the warfare module to call my custom init scripts. Cut and paste the following:

BIS_WF_Common SetVariable ["sidePlacement",[true,-1,-1]];
BIS_WF_Common SetVariable ["customInitClientScript",""];

BIS_WF_Common SetVariable ["customInitCommonScript","Init_Common.sqf"];

BIS_WF_Common SetVariable ["customInitServerScript",""];
BIS_WF_Common SetVariable ["customInitBasesScript",""];
BIS_WF_Common SetVariable ["customBaseLayoutsScript",""];
BIS_WF_Common SetVariable ["customTownsScript",""];

Note that the only script we actually want to call is Init_Common.sqf however if we don’t include the other blank script calls, the mission will hang on loading.

Next you will need to create a file called Init_Common.sqf that will add the CH-47 to the Aircraft factory.

 

Custom Init_Common.sqf

Even though we specified in the Warfare Module’s init that we were calling custom scripts, the module still goes through the motions and creates global variables, factions, factory equipment lists etc. exactly as if it were a stock warfare mission. Only once the module is completely initialized does it run our custom scripts, allowing us to overwrite/change the default settings.

One of the things the Warfare Module declares is a function called BIS_WF_AddUnitData, and we are going to use it to add our CH-47 to the equipment list. To do this, add the following code to your Init_Common.sqf

[West,"Aircraft","CH_47F_BAF",140,40,0,3,"","","USMC"] Call BIS_WF_AddUnitData;

Where:

  • West is the side we are going to add units to
  • Aircraft is the factory we are going to add units to
  • CH_47F_BAF is the class name of the unit we are adding
  • 140 is the cost of the unit
  • 40 is the build time in seconds
  • 0 is the points earned towards increasing player rank when killing this unit
  • 3 is the number of crew for the unit
  • the two sets of quotes “” are left blank; the module will use the description and image from the addon’s config
  • USMC is the faction that will be able to buy the unit.

And that is that. If I have made no typo’s I should see the CH-47 in my list of equipment when I run the mission.

Reference

BIS_WF_AddUnitData
See example mission below.