Darkest Hour - Dev Diary #13 - Modding with Darkest Hour Part 3
Today we're going to talk about the improvements we made to the existing event system.
First all, you'll be happy to know that now events can have an unlimited number of action, we are no more bounded by a maximum of 4 choices. You can create an event with as many action as you want, you're only bundled by the size of your screen.
But this is just the beginning. Perhaps the greatest improvement we made to the event system is the introduction of triggers in action and commands. This means that a trigger can be associated to an action and that action will be displayed and selectable only if its trigger is satisfied. The same happens for commands: a single command can have a trigger and that command will be executed only if its trigger is satisfied. This change opens a whole new dimension for event writing because with only event you'll able to attain results that previously required many different events (or where altogether not reachable!). Let us give you a few simple examples of this feature.
Example 1 - you can have different actions based on the government:
trigger = { government = democracy }
command = { ... }
}
action = {
trigger = { government = communist }
command = { ... }
}
action = {
trigger = { government = nazi }
command = { ... }
}
xample 2 – a command can be executed only if the trigger is satisfied (surrender of France):
command = { type = secedearea which = GER value = "Bourgogne_Champagne" }
command = { type = secedearea which = GER value = "Lorraine_Alsace" }
command = { type = secedearea which = GER value = "Pas de Calais" }
command = { type = secedearea which = GER value = "Paris" }
command = { type = secedearea which = GER value = "Normandy" }
command = { type = secedearea which = GER value = "Loire" }
command = { type = secedearea which = GER value = "Brittany" }
command = { trigger = { control = { province = 87 data = ITA } } type = secedeprovince which = ITA value = 87 } # Nice
command = { trigger = { control = { province = 86 data = ITA } } type = secedeprovince which = ITA value = 86 } # Toulon
command = { trigger = { control = { province = 90 data = ITA } } type = secedeprovince which = ITA value = 90 } # Grenoble
command = { trigger = { control = { province = 91 data = ITA } } type = secedeprovince which = ITA value = 91 } # Chambery
command = { trigger = { control = { province = 94 data = ITA } } type = secedeprovince which = ITA value = 94 } # Corsica
}
As you can see, now you don't have to write action_a, action_b, action_c and action_d anymore, but a simple action is enough. Obviously the old syntax is still valid, as we always said we want to keep compatibility with HOI2 Armageddon mods.
This change also required a new system to calculate the ai_chance. We therefore created this new set of rules:
- sum of AI chances of all valid actions could be any positive number (removed fixed sum = 100 prerequisite);
- invalid actions are skipped in AI chances calculations;
- actions without specified AI chances are ignored by the AI if there is at least one valid action with AI chance set;
- if no AI chance is set for valid action, random action is chosen from all valid actions (removed increased chance to pick 1st action);
Another feature we introduced are the so called one-action events. This means that when this option is selected (by writing one_action = yes), even if an event has more than one action, only one of the possible actions will be displayed to the player (who therefore will be forced to accept it).The choice of the action is based on the defined AI chance for each action. In this way the player cannot choose the action and is forced to accept whatever happens to him.
An example is perhaps worth more than many words: the effects of the attack on Pearl Harbour can be written as a one_action event, so that neither the Japan nor USA can choose the amount of losses inflicted on the American fleet.
id = 1122334455
random = no
country = USA
one_action = yes
name = "Attack on Pearl Harbour!"
desc = "4062desc"
action = {
ai_chance = 10
name = "We suffered very heavy losses"
...
}
action = {
ai_chance = 50
name = "We suffered heavy losses"
...
}
action = {
ai_chance = 15
name = "We suffered light losses"
...
}
action = {
ai_chance = 5
name = "We suffered very light losses"
...
}
}
When this event is triggered, only one action is displayed to the player and the probability of a single action is based on the ai_chance. The same rules explained above apply here, so it is not necessary to have the sum of ai_chance equal to 100. So the second action ("We suffered heavy losses") has a probability of being chosen equal to 50/(10 +50 +15 + 5) = 62.5 %.
Fianlly, the last feature we're going to talk about today is the events with saved date. It is possible to save the date in which an event fired and then use it as a trigger in another event, for example to make an event fire at least 100 days after another event fired.
Example: the first event will have save_date = yes:
id = 1234567890
random = no
save_date = yes
country = GER
...
}
The second event will have:
event = { id = 1234567890 days = 100 }
}
Darkest Hour Complete will make full use of these new features, but some of the mods currently being ported to DH will use them too! Wait&See! ;-)
Here are a couple of screenshots from our Development Team: