This guide will explain how to make custom chapter missions, even for factions that are not normally playable. It assumes a basic knowledge of modding database tables and the startpos. In this example I will be using Massilia's entries as to create an introduction and missions for Liguria (Genua).
*This tutorial assumes you have made the faction playable and that the faction has a Chapter Mission entry in its FACTION ARRAY. If it does not have that, it will not trigger any chapter missions. Factions made playable using the Assembly Kit should have the chapter missions unlocked. In order to insert a Chapter Mission array into an existing startpos, you must first use the esf to xml method to unpack the startpos. You can then manually insert the Chapter mission parameters into the FACTION ARRAY.
Files you will need in your mod pack (Example is for the Grand Campaign):
/campaigns/main_rome/startpos.esf with the new faction set as playable
/campaigns/main_rome/missions.txt
/campaigns/main_rome/scripting.lua
/db/advice_levels_table
/db/advice_threads_table
/db/missions_table
/lua_scripts/export_advice.lua
/text/db/advice_levels.loc
/text/db/mission_text.loc
/text/db/missions.loc
Step One: Create a Custom Introduction for the Faction
- Every faction has a custom introduction that triggers the chapter missions for that faction.
1. Create a custom advice entry for your new introduction. Open /db/advice_levels and find an existing faction intro. They will have a key that looks like "3088_TWRII_Faction_Intro_Massilia_1_Thread". Clone that row.
2. Find the row you just cloned and change the Key and ID number to custom values. For our example we will use "40001_TWRII_Faction_Intro_Liguria_1_Thread" and 40001 as the ID to keep it simple. In the advice_levels.loc file, make new entries for the title and description of your introduction.
3. Create an entry in /db/advice_threads that matches the custom key you made. For our example, "40001_TWRII_Faction_Intro_Liguria_1_Thread". These 2 tables can be made into fragments and simply have these entries only, if you prefer.
4. Open /lua_scripts/export_advice.lua and find an entry for one of the faction introductions. They should look like this:
5. Copy that entry and paste it under the previous entry. Change each instance of the old key to the new one and also change the faction name. For our example it would now look like this:Code:--[[ 3088_TWRII_Faction_Intro_Massilia_1_Trigger ]]-- function impl_3088_TWRII_Faction_Intro_Massilia_1_Trigger (context) return conditions.FactionIsLocal(context) and conditions.FactionName("rom_massilia", context) and conditions.CampaignName("main_rome", context) and conditions.TurnNumber(context) == 1 end events.FactionTurnStart[#events.FactionTurnStart+1] = function (context) if impl_3088_TWRII_Faction_Intro_Massilia_1_Trigger(context) then effect.advance_contextual_advice_thread("3088_TWRII_Faction_Intro_Massilia_1_Thread", 1, context) return true end return false end
6. Open up campaigns/main_rome/scripting.lua. You will find various entries here that trigger the introductions and also the chapter missions. There are 5 parts to each of the faction scripts, you will need to add new entries to all 5.Code:--[[ 40001_TWRII_Faction_Intro_Liguria_1_Trigger ]]-- function impl_40001_TWRII_Faction_Intro_Liguria_1_Trigger (context) return conditions.FactionIsLocal(context) and conditions.FactionName("rom_liguria", context) and conditions.CampaignName("main_rome", context) and conditions.TurnNumber(context) == 1 end events.FactionTurnStart[#events.FactionTurnStart+1] = function (context) if impl_40001_TWRII_Faction_Intro_Liguria_1_Trigger(context) then effect.advance_contextual_advice_thread("40001_TWRII_Faction_Intro_Liguria_1_Thread", 1, context) return true end return false end
7. The first part transitions the advice trigger we just created in the export_advice.lua into the introduction. It looks like this:
Copy that and paste it under the last entry. Change the number 2139663973 to the ID you chose for your custom advice entry above (40001). The coordinates should be coordinates of the starting city of that faction. You can find this in the startpos or by guessingCode:-- MASSILIA elseif conditions.AdviceJustDisplayed("2139663973", context) and not CampaignUI.IsMultiplayer() and intro_advice_shown == false then out.ting("intro advice issued") ActivateCinematicCam(true) intro_advice_shown = true scripting.game_interface:scroll_camera_with_direction(5.5, {150.406403, 306.824707, 1.05, 0}, {150.406403, 306.824707, 0.76, 0}) camera_pan = 380. Set the camera_pan=# to 420 in your entry. This number increases by 10 for each new entry here and the final entry in the vanilla script is 410.
8. The next entry to be copy and pasted looks like this:
Spoiler Alert, click show to read:
9. These are the commands for the camera's movement. The easiest thing to do is simply create an entry that stays at one spot. But, you can choose to make multiple entries for the camera movement. The key is that you need the first and last entry at least and you must change the numbers to the new values. In the previous step we changed the camera_pan value to 420. That was the trigger for the script to begin the camera pan.
10. So, take the new script you copied from above and change the values to start with 420 (instead of 380) and move up to 429. At the very least you need both 420 and 429. The coordinate values are where the camera will travel and how it will orient. Finally, change the last text "rom_intro_mission_massilia" to your own custom entry. Let's use "rom_intro_mission_liguria" for our example.
11. The third part of the script to copy and paste looks like this:
This is simply telling the script that if the camera pan stops before 389, assume it is the 389 value. Copy that and paste it, then change the values to 420 rather than 380 and 429 rather than 389.Code:elseif camera_pan >= 380 and camera_pan <= 389 then camera_pan = 389 OnCameraMoverFinished(context)
12. The fourth part looks like this:
Copy/paste it under the final part and change the faction name to your faction, in our case rom_liguria. The coordinates at the end are the city coordinates.Code:elseif conditions.FactionName("rom_massilia", context) and conditions.FactionIsHuman("rom_massilia", context) and camera_pan==0 then out.ting("local player is Massilia and intro camera pan is not being played") CampaignUI.SetCameraZoom(0.85) CampaignUI.SetCameraHeading(0.0) CampaignUI.SetCameraTargetInstant(150.406403, 306.824707)
13. The final script to add is:
This triggers the Chapter Missions. Change the rom_intro_mission_massilia to the custom entry you created above (rom_intro_mission_liguria in our example). Change the faction name and also change the entry "objective_massilia_1_primary" to a custom entry. We will use "objective_liguria_1_primary."Code:elseif (context.string == "rom_intro_mission_massilia") or ((context.string == "check_intro_runs") and (intro_advice_shown == false) and (player_faction == "rom_massilia")) then scripting.game_interface:trigger_custom_mission("rom_massilia", "objective_massilia_1_primary") out.ting("DEBUG: Intro advice shown:"..tostring(intro_advice_shown))




Reply With Quote





