#2992
vanilla
Faction system, which lays the groundwork for more complex monster interaction rules:
- Every monster stores an integer which represents its faction ID.
- Faction ID 0 is used for the player and tame monsters; others are sequentially assigned as needed.
- Other groups of shared faction IDs would be things such as “all gnomes in the mines”, “all dwarves in the mines”, “all orcs in Orcish Town”, etc.
- If a group of monsters spawns, they all share a faction ID.
- There is a data structure which stores a list of two faction IDs and an associated rule (fight, peace, etc)
- Monsters of the same faction don’t attack each other, unless possibly they grudge one another.
- Monsters of different factions interact as normal, unless the data structure specifies that their behavior should be overridden.
- When a monster in a faction is attacked by something it didn’t previously want to attack, the data structure is added to with a (attacker faction, defender faction, “hostile”) piece of data. E.g. if a kobold throws a dart and hits an orc in a group, all the orcs now hate that kobold.
- Possibly, if only some monsters see the act of aggression, they split off into a new faction (which is aggressive, while the old one remains non-aggressive), and the data structure is set so that when any monster in the old faction sees a monster in the new faction, it automatically changes to the new faction.
- Monsters that read cursed genocide or create monster could then have the summoned monsters’ faction be hostile to the summoner, for symmetry with players.