The Arma II warfare mission – setting starting money and supplies.

Back at it again last night, though I didn’t accomplish much. I did figure out two things though.

Starting Equipment.

When testing I noticed that the UH-1Y that I had placed in the mission editor respawned automatically without me having to buy it. While this is handy, it may be a bit too easy and unbalanced. I may decide to use the MH-6 ported from Arma instead.

Starting Money and Resources.

These are used by the commander to build factories and defenses. I found out how to modify both thanks to KrilionGD‘s post on the official forums. This is the way it works as I understand it.

In the init field of the Warfare Module is a bit of code that calls InitMission.sqf to initialize the warfare mission. This is not where you set your variables, as they will be over rode by the Warfare Module. You can however call a custom config script from InitMission.sqf.  For example, in the InitMission.sqf I added this line:

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

This tells the module to call Init_Common.sqf, where I will be setting the variables for the mission.

I opened up Init_Common.sqf and started to add my custom values.

eastPlayerStartingFunds = 5000;
westPlayerStartingFunds = 5000;
ResistancePlayerStartingFunds = 2000;

Now for each player and AI I have to set their starting funds equal to the above variables. I took a look at the warfare2.pbo and BIS uses a loop to accomplish this.

//Change default starting funds for players and AIs.
 for [{_count = 0},{_count < 32},{_count = _count + 1}] do
 //Player starting funds.
 Call Compile Format["EastPlayer%1Funds = eastPlayerStartingFunds",_count + 1];
 Call Compile Format["WestPlayer%1Funds = westPlayerStartingFunds",_count + 1];
 Call Compile Format["ResistancePlayer%1Funds = resistancePlayerStartingFunds",_count + 1];

 //AI starting funds.
 Call Compile Format["EastAI%1Funds = eastPlayerStartingFunds",_count + 1];
 Call Compile Format["WestAI%1Funds = westPlayerStartingFunds",_count + 1];
 Call Compile Format["ResistanceAI%1Funds = resistancePlayerStartingFunds",_count + 1];

Ok, so its a bit confusing but I think I can break it down. The for .. do script executes all the code between the braces. ie.  { and }; for each value of _count. In this case _count starts at 0 and goes up by one till it gets to 32, then the loop stops.

More info on for do from the biki.

So for each value of _count that big block of code gets executed. Each line works the same and is made up of the commands: Call Compile and Format.

Format is used to build a string which is then run by the Call Compile commands. For example the first time through the loop _counter = 0. Format takes that variable and substitutes it into the string “EastPlayer%1Funds = eastPlayerStartingFunds” where the %1 is. So the first time through the resulting string would be EastPlayer0Funds = eastPlayerStartingFunds.  This then gets run by the Call Compile command, in this example assigning the starting funds to the first east player.

More info on Call Compile from the biki.

More info on Format from the biki.

The next chunk of code I added to Init_Common.sqf was to set the starting Commander funds and supplies.

EastAICommanderFunds = 5000;
 WestAICommanderFunds = 5000;
 ResistanceAICommanderFunds = 5000;
 EastCommanderFunds = 5000;
 WestCommanderFunds = 5000;
 ResistanceCommanderFunds = 5000;
 EastSupplies = 1000;
 WestSupplies = 1000;
 ResistanceSupplies = 1000;


I saved the mission, fired it up and it worked. I had resources to build, but I had $0 to buy units and weapons. More research required.
Re-built the mission and fixed my mistake (typo!). Download the sample mission and give it a try.