Skip to content

Campaign Support

Robosturm edited this page Jun 13, 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

For Variable Support take a look here

Creating a Campaign

  • create a folder ending with ".camp" for example "tutorial.camp". All maps inside this folder are not shown in the map selection view. So you should but your campaign maps inside the folder. ;)
  • Create a javascript file inside the maps-folder, but not in the campaign-folder you created before
  • Rename the file after finishing or now to a jsm-file. The file ending .jsm 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"];
};
  • Store the campaign progress after a map is finished. A finished map is confirmed by the game by calling the following callback
mapFinished : function(campaign, map, result)
{
    // called when a map has been finished
    // campaign = campaign object
    // map = finished map object
    // result = true -> won, false -> lost
    // it's up to the campaign developer how to handle the map result
},
  • Return true from the following function when the player reached the end of the campaign.
getCampaignFinished : function(campaign)
{
    // should return true when the campaign is at it's end
    return false;
},
Clone this wiki locally