Random City Ownership In The Arma II Warfare Module.

How To Set City Ownership With Random Start Locations.

Last week I played with setting City ownership in the Warfare module using location game logics synchronized to individual cities. If you are using random start locations static city ownership at the start may not be what you want for your mission. The Warfare module offers a way to set City ownership to the cities closest to your random starting location.

Using Scripts To Set City Ownership

Most Warfare variables and scripts are run at the start of the mission. To overide the Warfare modules default values you will have to build a customInitMissionScript. In the mission editor in the Warfare module’s Initialization field paste the following code:

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

This will tell the module to call "InitMission.sqf". Here in the InitMission is where you call your custom scripts to setup the Warfare module. Note that you can’t set any variables etc. in the InitMission file as they will be overwritten when the module starts.

Setting Warfare Variables: customInitCommonScript

In your InitMission file you will see a line of code that sets the variable┬á "customInitCommonScript". I’ve changed it to "Init_common.sqf".

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

This tells the Warfare module to call my script "Init_common.sqf" to initialize values and scripts common to both the client and server.

Init_common For Common Things

Finnally here in my custom Init_common.sqf I can set my values for City ownership.

BIS_WF_MissionDefaultSide = Civilian;
BIS_WF_Constants SetVariable["EASTSTARTINGTOWNSRATIO",0.2];
BIS_WF_Constants SetVariable["WESTSTARTINGTOWNSRATIO",0.2];

What the code means in my example:

  1. BIS_WF_MissionDefaultSide: City ownership will start out as civilian
  2. “EASTSTARTINGTOWNSRATIO”,0.2: 20% of the available cities will be owned by the east at mission start
  3. “WESTSTARTINGTOWNSRATIO”,0.2: 20% of the available cities will be owned by the west at mission start

Setup this way the Warfare Module will set city ownership to the cities nearest to your starting positions.

Resources:

Sample InitMission