CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.33k stars 4.14k forks source link

useful faction API #29377

Open mlangsdorf opened 5 years ago

mlangsdorf commented 5 years ago

CDDA needs a more useful faction API. The current API provides a bunch of meaningless junk without providing tools for managing NPC to NPC faction relationships.

Faction ownership and secure areas

Factions are going to own stuff (#27467), including map tiles. Some map tiles are going to be secure tiles, which indicate places that non-faction members are prevented from entering.

Faction Hierarchies

Most factions are going to have an internal hierarchy. This will be represented by a series of factions with differing relationship flags but basically the same name.

Faction Relationship Flags

Factions need to have ways to to indicate their relationships to each other. These flags are not reciprocal, so Faction Alpha might have WATCH_YOUR_BACK for Faction Beta, while Faction Beta does not have WATCH_YOUR_BACK for Faction Alpha.

I am proposing the following faction relationship flags: -- KILL_ON_SIGHT (KOS): Faction Alpha will shoot members of Faction Beta. -- WATCH_YOUR_BACK (WYB): Faction Alpha will attack monsters/NPCs that are attacking members of Faction Beta. -- SHARE_MY_STUFF (SMS): Faction Alpha will let members of Faction Beta use or take items or vehicles belonging to Faction Alpha. -- GUARD_YOUR_STUFF (GYS): Faction Alpha will prevent a character in Faction Delta without a SHARE_MY_STUFF relationship to Faction Beta from taking Faction Beta's items. -- INVITED_GUEST (IG): Faction Beta is allowed inside Faction Alpha's secure areas. -- DEFEND_YOUR_SPACE (DYS): Faction Alpha will prevent a character in Faction Delta without an INVITED_GUEST relationship to Faction Beta from entering Faction Beta's secure areas. -- KNOWS_YOUR_VOICE (KYV): Faction Alpha recognizes the voices of members of Faction Beta and will not move to see the source of normal speech from a member of Faction Beta.

There need to API functions to test, set, and clear these flags.

Example in practice

The Refugee Center has the following factions. -- Free Merchants 0 (FM0) has no members and the Center's lobby is their secure area. It has IG flags for all other factions. -- Free Merchants 1 (FM1) has all the members on the first floor and the rest of the first floor is their secure area. The player can buy a pass to grant them INVITED_GUEST status for their faction (this will be a new dialogue option), and if they do nice things for the Free Merchants, will get WATCH_YOUR_BACK.

Free Merchants 1 Flags KOS WYB SMS GYS IG DYS KYV
Free Merchants 0 Y Y Y Y Y
Free Merchants 2 Y Y Y Y Y Y
Old Guard Y Y Y Y
Lobby Beggars Y Y Y
Your Followers Can be acquired Y Can be bought

-- Free Merchants 2 (FM2) has all the members in the basement and the basement is their secure area. If the player does enough nice things, they will get INVITED_GUEST and WATCH_YOUR_BACK through a quest line that hasn't been written.

Free Merchants 2 Flags KOS WYB SMS GYS IG DYS KYV
Free Merchants 0 Y Y Y Y Y
Free Merchants 1 Y Y Y Y Y
Old Guard Y Y Y
Lobby Beggars Y Y Y
Your Followers Can be acquired Y Can be acquired

-- Old Guard (OG) has the Old Guard Rep and Old Guard doctor as members. They have no secure area in the Evac Center. They have WATCH_YOUR_BACK to all other factions and KNOWS_YOUR_VOICE to all factions but Your Followers.

-- Lobby Beggars (LB) has the beggars in the lobby as members and no secure area. They have no relationship flags except KNOWS_YOUR_VOICE to all factions but Your Followers.

-- Your Followers (YF) has the player and any companion NPCs as members. By default, they have no relationship flags with other factions, but the player can set them in the faction manager.

How this works in practice: The Lobby Beggars are INVITED_GUEST of Free Merchant 0, but not Free Merchant 1, so they can stay in the lobby but the Free Merchant guards will warn them if they try to enter the rest of the building. The Free Merchant Guards will defend the Lobby Beggars against monsters, and stop the player from stealing their stuff, but the Beggars won't care if anyone attacks the Free Merchant Guards or takes their stuff. Everyone knows each other's voices, and guards won't investigate casual conversation.

Initially, the player is in the same boat as the Lobby Beggars, except the Free Merchant guards won't defend her. She can buy a pass (or demonstrate that she has supplies to sell) to the rest of the first level, which makes her INVITED_GUEST to Free Merchant 1. If the player does enough missions for the Center, she gets accepted by the Free Merchants and gets INVITED_GUEST to Free Merchant 2 and access to the basement.

Faction Money and Desires

There needs to be an API function to retrieve any pseudo-currencies that the faction will treat as a medium of exchange, and another API function to retrieve the set of items that they will buy at a premium.

Other API functions

To be determined

Faction Display

The third tab in the faction manager should summarize the known factions and their relationship to the Your Followers faction. Selecting a faction should provide more detail (size, power, wealth, etc) and their relations with other factions.

Your Followers faction

The Your Followers faction needs to be expanded to "Your Follower getID" so that two different characters in the same world have different factions and different followers. Similarly, the friendly flag for monsters should be an int of the player getID they are friendly with.

I'm going to be coding this Real Soon Now.

mlangsdorf commented 5 years ago

Old dead faction code cleaned out in #29374