WB Scenario and Custom Game
WB Scenario and Custom Game
WB Scenario and Custom Game
Version: 1.0 Status: Draft Date: 14 July 2011 Author: William Howard CopyRight 2011 - All Rights Reserved
Contents
Introduction ............................................................................................................................................ 5 Assumptions........................................................................................................................................ 5 Compatibility ....................................................................................................................................... 5 Creating a World Builder Scenario Map ................................................................................................. 6 Create a Map....................................................................................................................................... 6 Start World Builder ............................................................................................................................. 6 Add Civilizations .................................................................................................................................. 7 Set Starting Techs and Policies ........................................................................................................... 9 Add City States .................................................................................................................................. 10 Place Civilization Starting Cities ........................................................................................................ 10 Place Civilization Starting Units......................................................................................................... 12 Add Palaces to Capital Cities ............................................................................................................. 14 Place City States ................................................................................................................................ 15 Set Scenario Properties ..................................................................................................................... 16 Save World Builder Scenario Map .................................................................................................... 16 Playing a World Builder Scenario Map.................................................................................................. 16 Start Civilization ................................................................................................................................ 16 Navigate to Advanced Setup Menu .................................................................................................. 17 Select the WB Scenario Map ............................................................................................................. 18 Select the Civilization to Play ............................................................................................................ 19 Start the Scenario.............................................................................................................................. 20 Play the Scenario............................................................................................................................... 20 Changing a WB Scenario Map into a WB Scenario Mod ....................................................................... 21 Create a New Mod ............................................................................................................................ 21 Add the WB Scenario Map ................................................................................................................ 22 Set the Mod Properties ..................................................................................................................... 24 Delete the Saved WB Scenario Map ................................................................................................. 25 Build the WB Scenario Mod .............................................................................................................. 25 Playing a World Builder Scenario Mod ................................................................................................. 26 Start Civilization ................................................................................................................................ 26 Navigate to Mods Menu ................................................................................................................... 26 Enable the WB Scenario Mod ........................................................................................................... 27 Select the WB Scenario Map ............................................................................................................. 27 CopyRight 2011 - All Rights Reserved
Start the Scenario.............................................................................................................................. 29 Uploading a World Builder Scenario Mod ............................................................................................ 30 Upload with ModBuddy .................................................................................................................... 30 Components of a Custom Game ........................................................................................................... 30 Custom Game Menu ......................................................................................................................... 31 Custom Game Menu Entry................................................................................................................ 31 Configuration Screen ........................................................................................................................ 32 Victory Progress Panel ...................................................................................................................... 32 Changing a WB Scenario Mod into a WB Custom Game ...................................................................... 33 Download, Install and Enable the Traders Scenario ...................................................................... 33 Confirm Operation of the Traders Scenario .................................................................................. 33 Open WB Scenario Mod .................................................................................................................... 36 Import Files from Traders Scenario .................................................................................................. 37 Set VFS Imports ................................................................................................................................. 39 Add Required Properties................................................................................................................... 39 Set Required Option.......................................................................................................................... 40 Add Required Actions ....................................................................................................................... 40 Add Required Content ...................................................................................................................... 40 Edit Scenario Text ............................................................................................................................. 41 Edit Scenario Parameters .................................................................................................................. 41 Edit Scenario Background Graphic .................................................................................................... 43 Edit Scenario Initialisation................................................................................................................. 43 Edit Scenario Victory Progress .......................................................................................................... 44 Files Not To Edit ................................................................................................................................ 45 Build & Test WB Custom Game Mod ................................................................................................ 45 Playing a WB Custom Game .................................................................................................................. 47 Start Civilization ................................................................................................................................ 47 Enable the WB Custom Game Mod .................................................................................................. 47 Select the Custom Game................................................................................................................... 48 Start the Custom Game..................................................................................................................... 50 Check the Victory Progress Display ................................................................................................... 50 Extending the Game Difficulty Selection ........................................................................................... 51 Start ModBuddy ................................................................................................................................ 51 Add Difficulty Options ....................................................................................................................... 51 CopyRight 2011 - All Rights Reserved
View Changes .................................................................................................................................... 51 Extending the Game Adding a Map Script ......................................................................................... 52 Start ModBuddy ................................................................................................................................ 52 Add a Map Script............................................................................................................................... 52 Add Additional Scenario Parameters ................................................................................................ 53 Add Additional Scenario Initialisation ............................................................................................... 53 Add Initial Civilization Technologies ................................................................................................. 53 View Changes .................................................................................................................................... 54 Extending the Game AI Only Civilizations .......................................................................................... 55 Start ModBuddy ................................................................................................................................ 55 Define the Playable Civilization(s)..................................................................................................... 56 Define the AI Civilization(s) ............................................................................................................... 56 View Changes .................................................................................................................................... 56 Conclusion ............................................................................................................................................. 57
Introduction
The goal of this tutorial is to enable you to be able to create Custom Games from World Builder maps and/or map scripts such that they can be played from the Custom Game menu. The tutorial starts by showing you how to create (and play) a World Builder Map Scenario, with simple to follow, step-by-step instructions. The tutorial then proceeds to show you how to convert the scenario into a mod, such that it can be shared with other players by means of the ModHub. Instructions on how to play the scenario as a mod are also given. The tutorial then shows you how to convert the scenario mod into a custom game mod (using prebuilt components) and instructions on how to start the custom game are also given. Finally, the tutorial shows you how to use the pre-built components to enable and/or disable key features of configuring a custom game civilization, map and difficulty selection. By the end of the tutorial you will have a fully working, configurable, custom game based on both a World Builder created map and a standard map script.
Assumptions
This tutorial assumes that you: Understand the basics of XML, SQL and Lua Know how to download, install and enable a mod from the in-game ModHub Have the Civilization V SDK installed Know how to use ModBuddy to create and deploy a simple mod Have the debug logs enabled, know where they are and know how to look for errors in them (specifically database.log, lua.log and xml.log) Know how to use LiveTuner (FireTuner) to test and debug a mod Know how to use World Builder to create a map Know how to upload a mod to the ModHub (Optional) Know how to create .dds format images
Compatibility
This tutorial was written with Civilization V 1.0.1.332 and also tested with 1.0.1.348
Page 5
Create a Map
The first step is to create the map. This can either be done by saving a map from the main Civilization game or by creating one in World Builder - either by running one of the standard scripts or by hand-crafting all the land-masses and adding features and resources. The map should be created at standard size (80x52) and feature lots of islands.
From the Description tab, change the map name to Island Raiders (Civ5Map)
Page 6
Add Civilizations
We now need to add some civilizations to select from to play as. Open the Scenario Editor from the Scenario Editor tab.
Page 7
Add three Players English, Ottoman and Songhai by clicking the + button on the Players tab and then using the Civilization drop-down to select the required civilizations.
Page 8
To jump-start the game we are also going to give each player one starting Policy, a different one for each player. Select the first player and click the Edit Policies button at the bottom centre of the scenario editor dialog. Assign this player the Tradition policy, then close the pop-up window.
Give the second player the Liberty policy and the third the Honor policy. Page 9
Page 10
Click the Cities tab in the Map Editor Tools panel, ensure Create is selected and that Player 1 is showing in the drop-down menu, then click the tile on the map where the capital is to be placed.
On a different island, locate another starting coastal plot, change the drop-down to Player 2 and click on the tile
Page 11
Finally locate the third starting coastal plot on another island, change the drop-down to Player 3 and click on the tile
Page 12
Change the top drop-down to Trireme and click on a coastal tile next to the capital to place a starting ship.
Place a warrior and trireme for each of the other two players
Page 13
Close the pop-up window and repeat for the other two capital cities.
Page 14
Locate a starting position on the map and click the tile to place the city state. Repeat for all twelve city states, aiming for coastal locations well distributed across the map and available land-masses.
Page 15
Start Civilization
Start Civilization and select Mods from the Main Menu
Page 16
Page 17
Ignore all other items and click the Back button (do NOT click the Start Game button!)
Page 18
Page 19
Page 20
Enter the name of the mod in this case IslandRaidersScenario and click the OK button.
Page 21
Complete the required General Information and click the Finish button.
Page 22
Select Add and then New Folder. Give the new folder a name of MAPS (it will be a lot easier to follow the tutorial if you keep this in all capitals)
Right click on the MAPS folder, select Add and then Existing Item Using the file browser dialog that opens, navigate into your \My Documents\My Games\Sid Meier's Civilization 5\Maps subdirectory and select the IslandRaiders.Civ5Map file and click the Add button. Now click on the IslandRaiders.Civ5Map file in the Solution Explorer window, and down at the bottom change the Import into VFS drop-down to True
Page 23
Scroll to the bottom and uncheck the Affects Saved Games option. Click on the Content tab (bottom of the left-hand tabs). Create a new row with a Type of Map, a Name of Island Raiders, a description of Island Raiders Scenario and a FileName of MAPS/IslandRaiders.Civ5Map. Important! 1. Both Type and FileName are case sensitive so Map not map or MAP and MAPS/IslandRaiders.Civ5Map not maps/islandraiders.civ5map etc. 2. The type of the slash in the file name is critical so MAPS/IslandRaiders.Civ5Map not MAPS\IslandRaiders.Civ5Map
Page 24
If we dont delete the map file from here, Civilization will detect it both from the enabled mod and from this location so there will be two entries on our map selection list (which will be confusing).
Page 25
Start Civilization
Start Civilization and select Mods from the Main Menu
Page 26
Page 27
From the Map Type drop-down menu select the Island Raiders entry Note 1: If you have an Island Raiders (Civ5Map) entry, you need to delete the map from your Maps sub-directory (see above). Note 2: If you have no Island Raiders entry you either forgot to set VFS to true, or have made a mistake with the capitalisation of the file name and/or used the wrong slash in the path Ignore all other items and click the Back button (do NOT click the Start Game button!)
Page 28
Finally play your scenario. You will need to "know" what the premise and victory conditions are.
Page 29
Page 30
It turns out that the code that displays this option detects if a mod adds an item for the second component of a custom game (see the following screen grab) and automatically enables/disables this option. So we dont need to do anything to make this work, provided our mod adds a valid entry for the next screen.
This is actually quite simple to achieve, it just requires the correct entries in the .modinfo file (added via ModBuddy of course), but there are a few pitfalls to avoid and some corresponding tricks to use. CopyRight 2011 - All Rights Reserved Page 31
Configuration Screen
The third component of a custom game is a bespoke configuration screen
The definition of the layout of this dialog (an XML file) and the code that drives it is non-trivial.
The definition of the layout of this dialog (an XML file) follows a standard template and is quite simple. The complexity of code (an Lua file) that drives it is determined by the victory conditions of the scenario. CopyRight 2011 - All Rights Reserved Page 32
Page 33
Select the Coastal Traders item (note how the description of the scenario along with the background image - changes in the right hand frame) and then click Load Mod
Select a leader, map type and difficulty and then click Start Game
Page 34
The game will start and display a victory progress banner. The number of luxuries acquired will be zero and the number required will depend on your chosen difficulty (Chieftain requires nine, while Deity requires all fifteen)
Found your capital (if playing on a random map), build a Worker, pick the tech that will be needed to develop your nearest luxury (Calendar in this case). Explore a bit. When the tech is researched and the worker built, get the worker to improve the luxury tile. When the improvement is built (a plantation in this case) confirm that the victory banner updates.
Page 35
We could play the game to its conclusion, but thats sufficient to show that the vanilla game is working! We now want to modify our Island Raiders scenario mod to include the custom game components.
As we no longer want the World Builder map to be playable from the Advanced Setup menu, change the VFS Import for the Islandraiders.Civ5Map file to false
Page 36
Add an LUA folder to the IslandRaidersScenario project and import the three files ScenarioUtilities.lua, ScenarioInitialisation.lua and ScenarioParameters.lua (the Add Existing Item file selection dialog supports multiple select, so these can all be selected and added at the same time)
Page 37
Add an SQL folder to the IslandRaidersScenario project and import the ScenarioText.sql file
Add a UI folder to the project and import the four files ScenarioLoadScreen.lua, ScenarioLoadScreen.xml, ScenarioVictoryProgress.lua and ScenarioVictoryProgress.xml
Finally add an XML folder to the project and import the ScenarioParameters.xml and ScenarioText.xml files
Page 38
Page 39
Important Note: The Name and Description fields for the Custom entry must be TXT_KEY_SCENARIO_TITLE and TXT_KEY_SCENARIO_DESC respectively. Why the TXT_KEY_ entries? The Name field of the Custom entry is prefixed by Custom_Background_ and used as the tag name to locate the background image. XML tags may only contain a limited sub-set of characters and excludes most of the punctuation and also space. This means a Name of Williams Island Raiders Scenario is not valid. However, by using a TXT_KEY_ value for the name, we can conform to the requirements of XML while being able to use any characters in the displayed name as the TXT_KEY_ entry is automatically translated via the game database. Note: If you dont want the victory progress banner, simply omit the InGameUIAddin entry for it. CopyRight 2011 - All Rights Reserved Page 40
Delete the Row entry with tag TXT_KEY_SCENARIO_VICTORY_PROGRESS as it is not needed by the Island Raiders custom game. Save the changes and close the file.
Copy the ModId and paste it into the ScenarioParameters.lua file Page 41
The next four entries relate to the maps used in the scenario, but only the first is relevant for a World Builder Civ5Map file. Change the ScenarioFixedMap entry to refer to the IslandRaiders.Civ5Map file and comment out (by prefixing the lines with --) the next three entries (we will need these again later in the tutorial). As usual, case and the type of slashes is very important.
The next block of lines refer to the civilizations we either defined in our World Builder Scenario Map or wish to play on a random map. As we defined three civilizations when we created the World Builder Scenario Map (all those pages ago), we need to delete the last entry and change the others to reflect our chosen civilizations. (The correct values to use in this table can be found in the CIV5Civilizations.xml core game file.)
If you wish, specify a default civilisation to play, otherwise leave the ScenarioDefaultCivilization set to nil to pick a random civilization to start with (this can be changed by the player from the Custom Game setup screen). The next block of lines refer to the difficulties the player can choose from. To illustrate the autoadaptive dialog we are going to comment these out for the time being and force the difficulty to be King. We will later return and add these back in to see the effect of them on the Custom Game dialog. So, for the moment, comment these lines out.
Page 42
The next block of lines refers to the possible victory types. As our scenario will be turn limited, we could just ignore these, but by picking appropriate ones here the AI stands a better chance of playing to win! For our scenario, we only need domination, so set that to true and all the others to false.
The next line relates to the game speed, pick an appropriate one. For the Island Raiders scenario either GAMESPEED_QUICK or GAMESPEED_STANDARD is suitable. The last line relates to the number of turns the scenario will run for. If there is no turn limit, leave this at zero, but for our Island Raiders scenario we need to change this to 200. (This should be the same as that set in the World Builder Scenario Dialog.)
Locate the InitPlayer(pPlayer) function and delete the block of four lines in the middle (well keep the allocation of 50 gold to each player)
Page 44
GUIDs and MD5s have been replaced by as they will differ, as have non-critical text strings. Some standard tags have been removed from the listing for brevity. Pay particular attention to case of filenames and use of the correct slash types, also the import attributes in the File tags and the values in the Actions and EntryPoints sections. CopyRight 2011 - All Rights Reserved Page 46
Start Civilization
Start Civilization and select Mods from the Main Menu
Page 47
Note: If you can still see the Set Up Game option, you forget to check the Hide Setup Game option on the Mod Info tab in ModBuddy. Select the Island Raiders custom game, note how the scenario premise and victory conditions are displayed. Click the Load Mod button.
If you have two identical entries in the custom game list, you forgot to disable the Traders scenario. (The duplication is intentional, and serves as a warning that there are two conflicting mods enabled.) CopyRight 2011 - All Rights Reserved Page 48
Page 49
Page 50
Start ModBuddy
Start ModBuddy, open the Island Raiders Scenario project and open the ScenarioParameters.lua file (in the LUA folder)
Because the code that displays the custom game configuration screen is auto-adaptive thats all we need to do! Save the changes, close the file and rebuild the mod.
View Changes
Start Civilisation, navigate to the Mods menu and re-enable the IslandRaidersScenario mod. (This is necessary as the rebuild process changes the date-time stamp on the .modinfo file and Civilization therefore detects that the mod has changed and automatically disables the mod.) Select Custom Game and the Island Raiders scenario and check that the scenario setup screen now contains a difficulty selection menu and that King is the default selection.
Page 51
Start ModBuddy
Start ModBuddy and open the Island Raiders Scenario project
Page 52
On the Actions tab, add an entry to execute this file during mod activation.
Our World Builder scenario also granted an initial policy, but we wont replicate that for the script based scenario as it requires non-trivial Lua code to implement. Save the changes and rebuild the mod.
View Changes
Start Civilisation, navigate to the Mods menu and re-enable the IslandRaidersScenario mod. (This is necessary as the rebuild process changes the date-time stamp on the .modinfo file and Civilization therefore detects that the mod has changed and automatically disables the mod.) Select Custom Game and the Island Raiders scenario and check that the scenario setup screen now contains a map selection menu.
Page 54
Start the game with the random map and check that the Trireme unit is placed and that you start with Pottery and Sailing.
Start ModBuddy
Start ModBuddy, open the Island Raiders Scenario project and open the ScenarioParameters.lua file
Page 55
Because the code that displays the custom game configuration screen is auto-adaptive thats all we need to do! Save the changes and close the file.
View Changes
Start Civilisation, navigate to the Mods menu and re-enable the IslandRaidersScenario mod. Select Custom Game and the Island Raiders scenario and check that the scenario setup screen now defaults to England as the playable civilisation and that clicking on the civilization does not open the selection menu.
Page 56
Using LiveTuner, reveal the full map and check that the other Civilizations have been placed.
Conclusion
The Custom Game configuration screen is fully programmable so there are an infinite number of possibilities for custom game mods to take advantage of. However, defining the dialog layout in XML and coding the responses to button clicks and menu selections in Lua is non-trivial, so may be beyond the skill set of most modders who would like to convert their World Builder based scenarios into custom games. Hopefully the TradersScenario sample mod and this Tutorial will enable more modders to take advantage of the custom game screens.
Page 57