I was drawn to write this tutorial by my search for a full emergent general script. I have found bits and pieces, but never a tutorial dedicated solely to emergent generals. This tutorial is based off of my compiled notes on the topic. I would like to thank Gigantus (for his patient advice ) and David93.
The goal of this tutorial is two-fold. Firstly, I would like to give modders a working script that they can copy and paste directly into their work. Secondly, I hope to teach some new modders what all is needed in order to create their own emergent general scripts. So here goes:
Code:
monitor_event PreFactionTurnStart FactionIsLocal
and FactionType england
and I_TurnNumber > 3
and I_NumberOfSettlements england < 5
historic_event a_hero_emerges
spawn_army
faction england
character random_name, named character, age 18, x 111, y 145
traits GoodCommander 1
unit NE Bodyguard exp 2 armour 0 weapon_lvl 0
end
terminate_monitor
end_monitor
This script is set up to be fully functional with kingdoms. Place this script at the bottom of the campaign_script file in the data\world\maps\campaign\imperial_campaign folder, just above the end scripts section. For an experienced scripter, looking for a pre-made script, you can stop reading as the rest of this tutorial will break down each line of the script.
monitor_event PreFactionTurnStart FactionIsLocal: This line has three crucial parts. The monitor tells the engine to check for the following event, while the PreFactionTurnStart instructs it to check before the start of the turn (obviously). FactionIsLocal (faction is human) is the first condition that must be met before this event can trigger in-game. This could also read:
monitor_event PreFactionTurnStart not FactionIsLocal (each condition can be a “not” condition)
Each following condition is scripted on its own line (tabbed one time from the monitor_event line) .
This particular event is set to trigger when a player is England, it is after turn three, and the player has less than 5 regions.
Code:
and FactionType england
and I_TurnNumber > 3
and I_NumberOfSettlements england < 5
historic_event a_hero_emerges
I have added the historic_event a_hero_emerges line to trigger an in-game pop up to let the player know that a faction has had a general emerge. For this to work we have to add a historic event in the historic_events.txt file in the data\text folder
Code:
{A_HERO_EMERGES_BODY}At the time of their greastest need, this man has emerged as a hero for the people.
{A_HERO_EMERGES_TITLE}A Hero Emerges
Add these lines at the bottom of this file.
The following part of the script tells the engine what to do once the conditions are met. In this case we want a general to spawn so we need to use the spawn_army identifier.
Code:
spawn_army
faction england
character random_name, named character, age 18, x 111, y 145
traits GoodCommander 1
unit NE Bodyguard exp 2 armour 0 weapon_lvl 0
end
The next line deals with which faction receives the spawned army, followed by the characters name, age, and location on the map where they will spawn. I have used random_name, but you can use any name as long as they are in the proper places in the data files: descr_names and descr_names_lookup, along with the data/text file: names.
The next line gives the spawned general his traits and can be followed by an ancillary line below. (A list of traits and ancillaries can be found in their proper data files.
This line: “unit NE Bodyguard exp 2 armour 0 weapon_lvl 0 “ is important, as a general must have a bodyguard. If you wish to add additional units to your general’s army, you will need additional unit lines (max 20 total). To find unit names to replace “ NE Bodyguard” look in the export_descr_unit file in the data folder and choose the name on the “type” line.
The next few lines end the script:
End (ends the spawn_army)
terminate_monitor (will not allow the monitor to trigger more than once)
end_monitor (ends the monitor)
Once again this is just a compilation of my notes on this topic and I hope it helps someone learn this skill MUCH faster than I did
This is my first tutorial and any advice on structure or changes would be appriciated.
SoP