Objectives, rules and campaign
Set up a map's players and computer opponents, give them objectives, script the mission without code, build the campaign, and translate the game's words. For mission code, see Missions, dialog and objectives.
Set up players and teams
- Open Map settings (right rail).
- Add or remove players (up to the game's
Rules.maxPlayers, 8 by default, 32 at most). A game with fixed players only lets you set their starts. - Click a player's ⋯ to set who plays them (a person, the computer, nobody), their starting resources, their race, and your game's player fields.
- Name teams in the same panel.
- Drag a player by the grip to another seat: they take their objects along.
In a game with races, a map can fix a player's race or leave it to the lobby, and lists the races it offers. See Races.
Set up a computer opponent
- In Map settings, set a player to the computer and open its ⋯.
- Pick its difficulty and personality, and set its flags.
- Add its build order (drag to reorder) and its waves (units, timing, repeats, when to go).
- Press Test this computer to play the map with the Inspector on that seat (its goals, decisions and timing) and the AI overlay on.
Give players objectives
Your game needs the map objectives pack (mapObjectives() in its packs).
- Open Objectives (right rail).
- Add one and set its Id (with your game's prefix), Words and More about it (words or a message key).
- Tick The mission needs it for required ones; leave it off for optional.
- Set Given: at the start, or by a rule.
- Drag by the grip to reorder. In the quest log shows them as the HUD will.
Rules give one with giveMapObjective(world, id) and complete it with world.objectives.complete(player, id).
Make mission rules without code
Your game needs the mission rules pack (missionRules() in its packs).
- Open Rules (right rail) and add a rule.
- Set When: pick a condition (units in a region, so many units, time, an objective's status, a word told, under attack, resources, a hero, difficulty, chance; or all of, any of, not) and fill in its fields from the map's names.
- Choose Once, or Again every so many seconds while it holds. Set Asked as: whose "mine" and "enemy" the condition means.
- Add Actions in order: give, complete or fail an objective; say a line; play a cinematic; spawn a prefab; tell a computer player (
attack,defend,retreat,hold,pause); set two players' relation; start a timer; win; lose. - Drag rules by the grip to change the order they are checked in.
Conditions are the computer players' language (the table in AI); forms the panel does not lay out are written as JSON.
Build the campaign
- Open Campaign (right rail). Press Make a campaign if the game has none.
- Set its name, id and menu words, and add chapters (a name and a picture each).
- Add missions in play order. For each, set Id, Name, Map, Chapter, Difficulty, its menu words and picture, Briefing, Loading screen and Debrief.
- Press Open its map to edit a mission's map in a tab of its own.
- Save (Ctrl+S): it is written to
campaign.json.
Drop pictures from the Assets panel onto picture fields. What is code (a mission's start, carry, next, the rating) stays in code. See A campaign of missions.
Translate the game's words
- Open Languages (bottom drawer).
- Each row is a key with its source text: your game's messages, the map's objectives and rule lines, the campaign, cinematic lines, unit names and the engine's words. Read every map adds the other maps'.
- Type each language's words in its column.
- Tick Not translated or Stale to find what needs work. A stale field's mark keeps it as is.
- Save (Ctrl+S): each language is
languages/<id>.json.
Export CSV downloads the table for a translator; Import CSV… takes it back, one undo step. Your view must name each file so the game fetches it: he: () => import('./languages/he.json'). See Languages.
In code
editor.objectives.add({ id: 'td.hold', text: 'Hold the gate', required: true })
editor.objectives.move(0, 2)
editor.rules.add()
editor.rules.addAction(0, editor.rules.blank('win'))
editor.campaign.addMission({ id: 'm2', name: 'The siege', map: 'siege' })
editor.campaign.openMap('m2')
editor.languages.set('he', 'td.hold', 'החזיקו את השער')
const csv = editor.languages.exportCsv()
editor.languages.importCsv(csv)
editor.doc.players.setPlayerAi(2, { difficulty: 'hard' })Reference
| Panel | Kept in | Checks | API |
|---|---|---|---|
| Objectives | GameMap.data.objectives | objective-id (none or a duplicate), objective-text (no words) | editor.objectives |
| Rules | GameMap.data.rules | rule-id, rule-when, rule-action, rule-name | editor.rules |
| Campaign | campaign.json (CampaignFile) | A file that does not read is shown at the top | editor.campaign |
| Languages | languages/<id>.json (MessagesFile) | Stale by a hash of the source (sourceHash) | editor.languages |
| Players | MapPlayer, world.map.forces | too-many-players, a race the game has not, other-race | MapEditor.movePlayer(from, to) |
| Computer | MapPlayer.data.ai (MapAi) | MapEditor.setPlayerAi, setPlayerAiPart, movePlayerAi; EditorClient.testComputer(player) |
editor.objectives:list(),add(objective?),set(idOrIndex, change),remove,move(from, to),words(text),questLog(),given().editor.rules:list(),add(rule?),set,remove,move,addAction(idOrIndex, action?),setAction,removeAction,blank(kind),places(),prefabs(),cinematics(),speakers(),run().editor.campaign:load(text?),file(),path(),error(),create(name?),set(change),addMission,setMission,removeMission,moveMission,addChapter,setChapter,removeChapter,putInChapter,maps(),openMap(id).editor.languages:ids(),rows(),word(id, key),set(id, key, words),keep,stale(id),readMaps(),exportCsv(languages?),importCsv(text). Without an editor:gatherWords,wordsCsv,readWordsCsv,writeCsv,readCsv.
A map with more players than the game allows is refused where it meets the game (createWorldFromMap throws); it is never cut.