Skip to content

Campaign Support

Robosturm edited this page Jun 11, 2019 · 6 revisions

Note this page is under developement and represents the current state it's not finished and isn't released before Beta 4!!!

Note during the next map selection of a campaign no dialogs are possible. Please create your dialogs during a map is played. See Game Scripts

Creating a Campaign

  • Create a javascript file inside the maps-folder
  • Rename the file after finishing or now to a cmp-file. The file ending .cmp is required for the game to detect the file as campaign script.
  • add the following lines of code to the script
  • as usual for function callbacks take a look at the resources/scripts/general/BaseCampaign.js file
var Constructor = function()
{
};
Constructor.prototype = BASECAMPAIGN;
var campaignScript = new Constructor();
  • For the basic campaign info you can add the following lines of code to the constructor function
this.getDescription = function()
{
    return qsTr("This is a test campaign");
};
this.getAuthor = function()
{
    return "Robosturm";
};
this.getCampaignName = function()
{
    return qsTr("Test");
};
  • During playing a game you want to make a set of maps aviable to play for the player. The following callback should return the current maps you want to make playable.
this.getCurrentCampaignMaps = function(campaign)
{
    // return a string list of current selectable maps
    // the first item is the folder the rest are the map-files in the folder
    return ["maps/", "test.map", "test1.map"];
};

This would make the files test.map and test1.map in the folder maps selectable. You should create some variables to keep track of the current campaign state to allow you to return the current playable maps. See Script Variables

  • After a player has selected a map you may want to allow him to select a set of co's for certain players. Note that the CO's for the AI are always fixed and not changeable by the player. The getSelectableCOs allows you to make certain co's playable the campaign variable is the current campaign-object. The map is the current selected map, while player is the index of the current player starting at 0 for player 1 and coIndex is either 0 for CO 1 and 1 for CO 2. Depending on this information you can return a set of co's from which the player can choose one.
this.getSelectableCOs = function(campaign, map, player, coIndex)
{
    return ["CO_ANDY", "CO_MAX", "CO_SAMI"];
};
Clone this wiki locally