A problem with Story Now in video games (
introduced here) is to support shifting attitudes of individuals and groups towards the player(s) and each other. One solution would be implementing Factions and Attitudes. Below the LJ-CUT is the result of a few days of tinkering.
What is a Faction?
Conceptually, a Faction is simply an in-game community. A Faction object simply needs to consist of a description.
In the Bloodrange Mountains, there are three Factions.
- Bloodrange Wolfmen
- Moonclaw Wolfmen
- Red River Colonists
What is an Attitude?
An Attitude is a link from one Faction to another, describing how the Faction feels towards this other one. A Faction can link to another Faction once only, though two Fations may (and usually should) link to each other. It should consist of modifiers or indicators of behavior, such as friendship, anger, fear, and respect.
The two wolfmen Factions know of each other, but only the Bloodrange Wolfmen have encountered the colonists. For our example, we have four different modifiers as paired opposites: Friendship/Anger, Fear/Courage.
- Moonclaw Wolfmen -> Bloodrange Wolfmen: Friendship: 50, Fear: 10 (the Moonclaw are friends with the Bloodrange Wolfmen, but recognize the Bloodrange's more savage nature).
- Bloodrange Wolfmen -> Moonclaw Wolfmen: Friendship: 40, Courage: 20 (the Bloodrange are allied with, but have contempt for the Moonclaw)
- Bloodrange Wolfmen -> Red River Colonists: Anger: 100, Courage: 20 (The Bloodrange want the colonists out of their land)
- Red River Colonists -> Bloodrange Wolfmen: Anger: 20, Fear: 25 (The Colonists would rather make peace with the Bloodrange, but cannot due to the Bloodrange's violence).
Faction Interaction
Once you've created your Factions, you use them as a basis for the behavior of your AI. Members of the same Faction should have some sort of default behavior (or perhaps you store behavior modifiers in a Faction that only apply between members). When an AI from one Faction interacts with another, its behavior choices are influenced by its Faction's Attitude.
Nehemiah is a Red River Colonist. Flashing Teeth is a Bloodrange Wolfman. We use the Attitudes to determine their behavior.
- Nehemiah: His Faction's attitude towards the Bloodrange Wolfmen is Anger 20 & Fear 25. Since his Fear outweighs his Anger, he tries to run away.
- Flashing Teeth: Anger 100, Courage 20. He'll not only attack, but he'll not want to run away until absolutely necessary.
If Nehemiah runs away or is killed, the Red River Colonists' Fear increases to 30 and the Bloodrange Wolfmen's Courage increases to 25.
Now, if two Factions interact without having any Attitudes towards each other, you'll want to create new Attitudes. To get even trickier, provide for situations where the Attitudes may or may not be created (if someone kills all members of a Faction in the room, then that Faction won't find out about it).
Nehemiah is out hunting when he spies a band of Moonclaw Wolfmen. For whatever reason, he attacks. Two of the Wolfmen flee (their companions dead), Nehemiah survives and returns to the colony. Two new Attitudes are created:
- Moonclaw Wolfmen -> Red River Colonists: Anger: 10, Fear: 15
- Red River Colonists -> Moonclaw Wolfmen: Anger: 5, Courage: 10
If you want to get even more complicated, you could search along a Faction's Attitudes and connected Factions in order to influence behavior.
Parent Factions
It makes sense that a particular Faction could itself be composed of Factions. In a pair of Attitudes between Factions, you can designate one of those as a parent. This way, children and parents can influence each other's behavior modifiers.
We create two new parent Factions.
- Wolf Tribes: This encompasses all of the Wolfmen, and so is parent to the Bloodrange and Moonclaw Wolfmen.
- Akkadian Empire: Parent to the Red River Colonists.
The Akkadian Empire is unaware of the Wolf Tribes at the beginning of our game so we only create two new Attitudes with arbitrary values.
- Wolf Tribes -> Red River Colonists: Anger 50, Courage: 10.
- Red River Colonists -> Wolf Tribes : Anger: 10, Fear: 10.
Now you can have Attitudes trickle up and down through parent/child relationships.
In our game, we want to apply half of a behavior modifier change to its parent. If Nehemiah is out hunting and spies the Moonclaw (neither Faction has encountered the other yet), we have a basis for his behavior.
- Nehemiah: His Faction has no Attitude towards the Moonclaw, so we check the parents of both. We see that his Faction has an Attitude towards the Wolf Tribes. Since it's not a direct relationship, these modifiers are half as strong. With an Anger 5 and Fear 5, Nehemiah's AI decides to back away quietly.
- Moonclaw Wolfmen: They spy Nehemiah and so we check Faction Attitudes. There is none, but we do find the Wolf Tribe parent's Attitude. Halving this for an Anger 25, Courage 5, the Moonclaw band decides to attack.
After the encounter, as the prior example, Nehemiah survives and two of the Moonclaw band flee. In addition to creating new Attitudes, any Faction's parents' Attiudes are also modified (by half their children's adjustment).
- Moonclaw Wolfmen -> Red River Colonists (new): Anger: 10, Fear: 15
- Red River Colonists -> Moonclaw Wolfmen (new): Anger: 5, Courage: 10
- Wolf Tribes -> Red River Colonists (adjusted by half of its child's adjustment): Anger: 50 + 5 = 55, Courage 10 - 7 = 3.
Additionally, an individual can belong to any Faction you've created, since these parent Factions are still Factions.
A mercenary band from far away arrives. Their Faction is the Akkadian Empire, and so long as they survive their initial encounter with any Wolfmen, the Akkadian Empire will create new Attitudes towards the wolfmen Factions.
Multiple Factions per AI
This part is pretty easy, you just have to consider how to implement how multiple Attitudes will affect an individual's AI. Two things to consider:
- The difference between belonging to a Faction explicitly (the individual belongs to the Faction) and implicitly (the individual's parents' Factions).
- How to handle the cases where an individual belongs to both a Faction and that Faction's parent.
Factions and the Player
The easiest way to handle this would be to create a unique Faction for each player, of which only the player is a member. This prevents any need for special cases concerning the player. If the player joins any Factions, then the player's actions will affect the adjustment and creation of new Attitudes. You should not need to create any Attitudes connecting the player Faction to any other Factions (since the "AI" in this case is the user's commands).
The player (belonging only to the Player faction for now) enters the game and comes across Nehemiah and the Moonclaw Wolfmen fighting. The player decides to aid the Wolfmen, causing Nehemiah to flee. In addition to the Attitudes discussed above, two new Attitudes are created:
- Moonclaw Wolfmen -> Player Faction: Friendly: 10, Fear: 0
- Red River Colonists -> Player Faction: Anger: 10, Fear: 10
If the player comes across any colonists, chances are that they will fight or run, or at least act unfriendly.
As an added bonus, if the player receives enough adolation, or tries to start a guild, political movement, etc. you can simply create a new Faction and with new Attitudes that match the world's Attitudes towards the player Faction.
Important Non-player Characters
Say a non-player individual needs to be more important than just another generic monster or citizen. You can handle this by creating a new Faction, specific to that individual, with the parent as the individual's original Faction. When this individual is dead, simply remove their unique Faction. Or, similar to the player starting a new Faction, allow further members into this new Faction.
Nehemiah kills enough Wolfmen to be lauded as a hero against the savage beasts. The game decides to create a new Faction, Wolfkillers, with the following results:
- Any Attitudes that applied to Nehemiah's original Faction (Red River Colonists) are copied and applied to the Wolfkillers.
- The Red River Colonists become a parent to the Wolfkillers
- Nehemiah's membership is moved from the Red River Colonists to the Wolfkillers. Note that he is still affected by the Red River Colonist's attitudes because it is a parent of his current Faction.
Scalability
Factions are abstract, and can encompass everything from the individual on up. Because of this, you can scale their application up beyond individual behavior. If you create a
4X Game (like Civilization), each civilization could belong to its own Faction. When an alliance is created, you create a new Faction, which then influences the AI members of that alliance. You can treat war, peace treaties and trade agreements similarly.
Incorporating Factions with Story Now
So how to incorporate Factions with Story Now?
- Scripted Events: A scripted event or cutscene can be presented when desired by simply manipulating the Attitudes manually, through a pre-written script. In fact, you could disable the dynamic Attitude shifts and cause all Attitude and Faction changes through scripted events. This would neuter the Faction system, but allow you to create a more traditional gaming experience.
- Scenario Triggers: When certain Attitude modifiers are achieved (or a combination), then allow for a Scenario with condition/events to be triggered. If a pair of Factions are at serious odds, your code can pick from a list of Scenarios to present to the player.
- Spontaneous Story Now: My hope is that random encounters setup between various Factions. By simply tracking shifting Attitudes and applying them to AI decisions you can achieve simple instances of Story Now.
Scripted Events
When the player enters a pre-determined outpost, a cut scene has the wolfmen appear. The cut scene creates a new Attitude from the Wolf Tribe to the Player Faction. The scripting also sets the wolfmen to attempt to kidnap the outpost's children.
Scenario Triggers
When the Bloodrange Wolfmen's Anger reaches 100 and their Courage reaches 50, a Kidnap Children Scenario is unlocked. When the player next enters a colonist outpost, a band of Bloodrange wolfmen appear and attempt to kidnap any children in the outpost.
Spontaneous Story Now
When a pack of wolfmen is randomly spawned near a colonist outpost, the combination of their Faction's Anger and Courage may cause the AI behavior of "kidnap the children."