Creating a Simple Mission

One of the new Arma II features I’ve been interested in are the editor modules. To try them out I’m going to walk through building a simple single player mission. I’m particularly interested in the Dynamic Object and Secondary Operations modules.

If you are following along I’m assuming that you are familiar with the basics of Arma II mission editing: inserting units, saving etc.

Mission Outline

For my simple little mission the player will start from an observation post, patrol through a town, deal with any enemy along the way and return to the observation post.

Dynamic Object module (DynO)

According to the biki the DynO will allow you to build sets of objects from existing templates. Armaholic has a nice set of reference images from the built in library. I’m going to use the template called “guardpost3_us” for my observation post.

First I’ll place a game logic on the map where I would like my observation post created.  To call the DynO I place the following script in the game logic’s Init field.

[getPos this, getdir this, "guardpost3_us"] call (compile (preprocessFileLineNumbers "ca\modules\dyno\data\scripts\objectMapper.sqf"));

The parameters I’m passing to the script, getPos this, getdir this are the position and direction of the game logic, allowing me to tweak the placement of my observation post just by moving or changing the direction of the game logic.

Guard Post 3 US

Base Created by DynO

Now that I have my observation post being created where I want it, it’s time to man it.

BIS has a function just for this, which I’ll examine in my next post.

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.

WarfareExampleResistance.Chernarus

Adventures in editing – The Arma II warfare mission.

My gaming group and I have been playing the Arma II warfare mission, called 05 Superpowers for the last few weeks. We’ve been enjoying the mission, but this week they asked if  we could make a few changes.

  1. helicopters at the start of the mission or sooner helicopter factory creation (hey its a really big map!)
  2. more starting money (default is $0)
  3. aircraft factory at the airfields

So I de-pbo’ed the mission and opened it in the editor. I was expecting game logics all over the place and general nastyness. I was surprised however as the map only showed the initial starting vehicles and playable units, all synced to a single warfare editor module. Nice.

I placed an empty UH-1Y, synced it with the Warfare module and previewed the mission. There it was when I spawned at HQ. Very nice, very easy and one of the requests dealt with.

Thinking then that the majority of the warfare mission was handled by the module, I checked the init.sqf and other files in the mission folder looking for variables I could use to set starting money etc. I found references in the scripts to setting variables in the initialization of the warfare module, not in the scripts as the would be over ridden. So back into the editor and I open the module. Something about custom scripts go here. Not helpful. Currently the biki has no documentation on the warfare module.

Rummaging around I noticed an example warfare mission (doh!) with more scripts, folders etc.  I poked around in here and found references to starting money, but as yet I haven’t had a chance to figure it out yet. Task for Thursday.

Curious as to what the differences in the two missions are I opened the sample mission in the editor. Its the same as the Superpowers mission except they had location game logics synced to the warfare module as well. (screen shots on thursday) I thought maybe I could place an airport location game logic in the editor and sync it with the warfare editor module to satisfy request #3.  No such luck. I’ll have to go back at it tomorrow night and maybe post something at the official forums to see if anyone else has any ideas.