Decisions and Events


This weekend I started working right away on the first feature of 0.3.4 which is 'Decision Modding'. For those who haven't read anything about it before, decisions are the main mechanism, though not the only one, which drives the behavior of factions and polities. Decisions compel faction leaders to make a choice which, depending on the particular decision, can be anything from making a clan gain influence within their tribe, to splitting from that same tribe to form their own.

For 0.3.4 the plan is to streamline the decision creation process, which involved writing around 500 lines of code per decision, by generalizing the code underlying all decisions and make them fully moddable through the use of JSON files. This will greatly simplify the decision creation process while at the same time allowing modders to add their own custom decisions.

Since most decisions so far are triggered by simulation events, I decided to first add events as a mod file category. As an example, I started by adding a 'clan split' event which is the one that fires the 'clan split' decision. Here's a snippet of the file containing the event:

{
  "events": [
    {
      "id": "clan_split",
      "name": "clan split",
      "target": "faction",
      "assignmentConditions": ["faction_type:clan"],
      "triggerConditions": ["administrative_load:0.5", "[NOT]preference:cohesion,0.7"],
      "timeToTrigger": 91250,
      "timeToTriggerFactors": ["[RANGE:0.2,1][INV]administrative_load:0.5,1", "[RANGE:0.2,1]preference:cohesion,0,0.7"],
      "triggerEffects": ["decision:clan_split,target"]
    }
  ]
}

In 0.3.3, events where exclusively defined as being part of discoveries. With 0.3.4, events will be able to be defined separately of discoveries and be used to trigger discoveries and/or decisions.

Here now is a sample of a still unfinished decision mod entry for 'clan split':

{
  "decisions": [
    {
      "id": "clan_split",
      "name": "clan split",
      "parameters": ["faction"],
      "description": [
        {
          "id": "clan_split_description_intro"
          "text": "Several minor bands within clan <faction.name> have been distancing themselves from the rest of the clan, and now they desire to form their own clan.\n"
        },
        {
          "id": "clan_split_description_can_not_prevent_split_low_authority",
          "text": "Unfortunately, <faction.leader.name> can't do anything about it as <faction.name> has not enough respect for authority",
          "conditions": ["[NOT]faction.preference:authority,0.4"]
        },
        {
          "id": "clan_split_description_can_not_prevent_split_low_cohesion",
          "text": "Unfortunately, <faction.leader.name> can't do anything about it as <faction.name> has not enough cohesion.",
          "conditions": ["faction.preference:authority,0.4", "[NOT]faction.preference:cohesion,0.2"]
        },
        {
          "id": "clan_split_description_can_not_prevent_split_high_administrative_load",
          "text": "Unfortunately, <faction.leader.name> can't do anything about it as <faction.name> as the clan has grown too big.",
          "conditions": ["faction.preference:authority,0.4", "faction.preference:cohesion,0.2", "faction.administrative_load:0.9"]
        },
        {
          "id": "clan_split_description_can_prevent_split"
          "text": "Should the clan leader, <faction.leader.name>, try to reach out to them to keep them from splitting into their own clan?",
          "conditions": ["faction.preference:authority,0.4", "faction.preference:cohesion,0.2", "[NOT]faction.administrative_load:0.9"]
        }
      ],
      "options": [
        {
          "id": "clan_split_option_allow_split",
          "text": "Allow clan to split in two...",
          "conditions": ["faction.preference:authority,0.4", "faction.preference:cohesion,0.2", "[NOT]faction.administrative_load:0.9"],
          "effects": [
          ],
          "weight": 1,
          "weightFactors": ["faction.preference:authority"]
        },
        {
          "id": "clan_split_option_prevent_split",
          "text": "Prevent clan from splitting...",
          "conditions": ["faction.preference:authority,0.4", "faction.preference:cohesion,0.2", "[NOT]faction.administrative_load:0.9"],
          "effects": [
          ],
          "weight": 2,
          "weightFactors": ["faction.preference:cohesion"]
        },
        {
          "id": "clan_split_option_cant_prevent_split",
          "text": "Oh well...",
          "conditions": ["[NOT]faction.preference:authority,0.4 [OR] [NOT]faction.preference:cohesion,0.2 [OR] faction.administrative_load:0.9"],
          "effects": [
          ]
        }
      ]
    }
  ]
}

As you can see, defining a decision will still take quite a bit of work. Though this example in particular is one that has a lot of unnecessary fluff with all the custom description entries which are completely optional.

The model decision is still missing some key components like decision effect definitions, but I hope to at least complete some sample ones over the week. My expectation is that next weekend I'll be able to start coding the event and decision parsing modules. With some luck, I'll be able to have a functional modded decision near the end of January.

Get Worlds - History Simulator

Leave a comment

Log in with itch.io to leave a comment.