Skip to content

Commit

Permalink
Merge pull request #77428 from RenechCDDA/faction_limited_area_claim
Browse files Browse the repository at this point in the history
Some factions claim only one OMT
  • Loading branch information
Maleclypse authored Nov 2, 2024
2 parents afebbc5 + 2247b5e commit abd7e37
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions data/json/npcs/factions.json
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@
"likes_u": 30,
"respects_u": 20,
"known_by_u": false,
"limited_area_claim": true,
"size": 1,
"power": 1,
"currency": "fur",
Expand Down
1 change: 1 addition & 0 deletions data/mods/DinoMod/NPC/NC_BO_BARONYX.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
"likes_u": 30,
"respects_u": 20,
"known_by_u": false,
"limited_area_claim": true,
"size": 25,
"power": 20,
"currency": "icon",
Expand Down
2 changes: 2 additions & 0 deletions data/mods/Magiclysm/npc/factions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"likes_u": 0,
"respects_u": 0,
"known_by_u": false,
"limited_area_claim": true,
"size": 5,
"power": 100,
"//": "90 days worth of food for 1 person, at 3000kcal/day and full RDA of iron/calcium/vitC",
Expand Down Expand Up @@ -68,6 +69,7 @@
"likes_u": 10,
"respects_u": 10,
"known_by_u": false,
"limited_area_claim": true,
"size": 50,
"power": 50,
"//": "90 days worth of food for 1 person, at 3000kcal/day and full RDA of iron/calcium/vitC",
Expand Down
2 changes: 2 additions & 0 deletions doc/FACTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ An NPC faction looks like this:
"fac_food_supply": { "calories": 115200, "vitamins": { "iron": 800, "calcium": 800, "vitC": 600 } },
"consumes_food": true,
"lone_wolf_faction": true,
"limited_area_claim": false,
"wealth": 75000000,
"currency": "FMCNote",
"price_rules": [
Expand Down Expand Up @@ -77,6 +78,7 @@ Field | Meaning
`"relations"` | dictionary, a description of how the faction sees other factions. See below
`"mon_faction"` | string, optional. The monster faction `"name"` of the monster faction that this faction counts as. Defaults to "human" if unspecified.
`"lone_wolf_faction"` | bool, optional. This is a proto/micro faction template that is used to generate 1-person factions for dynamically spawned NPCs, defaults to "false" if unspecified.
`"limited_area_claim"`| bool, optional. Default false. Whether or not camps owned by this faction 'claim' the entire reality bubble and will be angered by hostile player actions in that area. If true, they only claim the specific OMT the camp is located on.
`"description"` | string, optional. The player's description of this faction as seen in the faction menu.
`"epilogues"` | array of objects, optional. Requires these objects: `power_min` - minimal faction power for epilogue to appear, `power_max` - maximum faction power for epilogue to appear, `id` - id of text snippet containing text of epilogue.

Expand Down
3 changes: 3 additions & 0 deletions src/faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ faction_template::faction_template()
size = 0;
power = 0;
lone_wolf_faction = false;
limited_area_claim = false;
currency = itype_id::NULL_ID();
}

Expand Down Expand Up @@ -143,6 +144,7 @@ faction_template::faction_template( const JsonObject &jsobj )
currency = itype_id::NULL_ID();
}
lone_wolf_faction = jsobj.get_bool( "lone_wolf_faction", false );
limited_area_claim = jsobj.get_bool( "limited_area_claim", false );
load_relations( jsobj );
mon_faction = mfaction_str_id( jsobj.get_string( "mon_faction", "human" ) );
optional( jsobj, false, "epilogues", epilogue_data );
Expand Down Expand Up @@ -559,6 +561,7 @@ faction *faction_manager::get( const faction_id &id, const bool complain )
elem.second.currency = fac_temp.currency;
elem.second.price_rules = fac_temp.price_rules;
elem.second.lone_wolf_faction = fac_temp.lone_wolf_faction;
elem.second.limited_area_claim = fac_temp.limited_area_claim;
elem.second.name = fac_temp.name;
elem.second.desc = fac_temp.desc;
elem.second.mon_faction = fac_temp.mon_faction;
Expand Down
1 change: 1 addition & 0 deletions src/faction.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class faction_template
bool consumes_food; //Whether this faction actually draws down the food_supply when eating from it
int wealth; //Total trade currency
bool lone_wolf_faction; // is this a faction for just one person?
bool limited_area_claim;
itype_id currency; // id of the faction currency
std::vector<faction_price_rule> price_rules; // additional pricing rules
std::map<std::string, std::bitset<static_cast<size_t>( npc_factions::relationship::rel_types )>>
Expand Down
4 changes: 4 additions & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6111,6 +6111,10 @@ bool game::warn_player_maybe_anger_local_faction( bool really_bad_offense,
return true; // Nobody to piss off
}
basecamp *actual_camp = *bcp;
if( actual_camp->get_owner()->limited_area_claim &&
player_character.global_omt_location() != actual_camp->camp_omt_pos() ) {
return true; // outside of claimed area
}
if( actual_camp->allowed_access_by( player_character, asking_for_public_goods ) ) {
return true; // You're allowed to do this anyway
}
Expand Down

0 comments on commit abd7e37

Please sign in to comment.