Prerequisites:
- Pack File Manager (I use 4.1.2 for Attila)
- Make a backup of: ETW/data/main.pack, ETW/data/patch_en.pack and ETW/data/campaigns/main/scripting.lua
Step 1: Create unique mission key
All missions need their own unique key, therefore it is important to create one for each mission.
1. Open with PFM: main.pack -> db -> mission_tables
2. Go to options in top left corner -> click "CA Are Read Only" to toggle edit mode
3. Select number 1 in the top-left corner (the first row), right-click and choose: "Insert Row"
4. In the first column that appears empty add: "test_mission" as key and copy paste the rest from the row below which is from key "ep1_build_farm"
5. Save file
Step 2: Add mission description text
1. Open with PFM: patch_en.pack -> text -> localisation.loc
2. Scroll to the bottom and select, click "Add New Row" and simply add tag: "mission_test_text", and some description, e.g: "This is a text description in the purpose of a tutorial."
3. Select "Save As" to overwrite existing file
Step 3: Add mission to campaign
1. Open main/scripting.lua (preferably with a code editor like VS Code or Atom)
2. Paste following code under function OnFactionTurnStart() on line 9
Code:
elseif conditions.FactionName("sweden", context) and conditions.FactionIsHuman("sweden", context) then
scripting.game_interface:trigger_custom_mission("test_mission", "sweden", "build_building", 3, "corn_peasant_farms", "", "mission_test_text", "", 500, "", context)
end
3. Save file
Results:
Conclusion:
We just created a build mission for Sweden which happens on the first turn, has three turns as time limit and a reward of 500 coins. All these parameters can easily be changed in the code pasted above. There are many different types of missions to trigger and you can find complete list inside: main.pack -> db -> mission_activities_tables. Some examples are: blockade_port, capture_city, make_alliance, recruit, research, etc.
Happy modding!