Skip to content

Commit

Permalink
Merge pull request #50853 from jbytheway/more_mapgen_values
Browse files Browse the repository at this point in the history
Parametric mapgen part 4: Support mapgen parameters in for most mapgen ids
  • Loading branch information
kevingranade authored Aug 18, 2021
2 parents 9900449 + c3a1e6f commit 13146bd
Show file tree
Hide file tree
Showing 11 changed files with 478 additions and 177 deletions.
30 changes: 30 additions & 0 deletions data/json/loot_zones.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,35 @@
"type": "LOOT_ZONE",
"name": "Loot: Ignore Favorites",
"description": "Favorite items inside of this zone are ignored by \"sort out loot\" zone-action."
},
{
"id": "NO_AUTO_PICKUP",
"type": "LOOT_ZONE",
"name": "No Auto Pickup",
"description": "You won't auto-pickup items inside the zone."
},
{
"id": "NO_NPC_PICKUP",
"type": "LOOT_ZONE",
"name": "No NPC Pickup",
"description": "Friendly NPCs don't pickup items inside the zone."
},
{
"id": "NPC_RETREAT",
"type": "LOOT_ZONE",
"name": "NPC Retreat",
"description": "When fleeing, friendly NPCs will attempt to retreat toward this zone if it is within 60 tiles."
},
{
"id": "NPC_NO_INVESTIGATE",
"type": "LOOT_ZONE",
"name": "NPC Ignore Sounds",
"description": "Friendly NPCs won't investigate unseen sounds coming from this zone."
},
{
"id": "NPC_INVESTIGATE_ONLY",
"type": "LOOT_ZONE",
"name": "NPC Investigation Area",
"description": "Friendly NPCs will investigate unseen sounds only if they come from inside this area."
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@
"|JJJXs^|",
"||||||||"
],
"palettes": [ "lab_common_palette", "lab_mutagen_palette" ],
"palettes": [ "lab_common_palette", "lab_mutagen_palette", "lab_vent_palette" ],
"terrain": { "|": "t_wall_metal" },
"furniture": { "^": "f_vent_cold_air2_blast", "%": "f_standing_tank" },
"furniture": { "%": "f_standing_tank" },
"liquids": { "%": { "liquid": "purifier", "amount": [ 2, 20 ] } },
"place_loot": [
{ "group": "tools_mutation", "x": [ 1, 3 ], "y": 1, "chance": 70 },
Expand Down Expand Up @@ -258,15 +258,9 @@
"|JJJXs^|",
"||||||||"
],
"palettes": [ "lab_common_palette", "lab_mutagen_palette" ],
"palettes": [ "lab_common_palette", "lab_mutagen_palette", "lab_vent_palette" ],
"terrain": { "|": "t_wall_metal" },
"furniture": {
"^": "f_vent_cold_air2_blast",
"%": "f_standing_tank",
"!": "f_standing_tank",
"ō": "f_standing_tank",
"ŏ": "f_standing_tank"
},
"furniture": { "%": "f_standing_tank", "!": "f_standing_tank", "ō": "f_standing_tank", "ŏ": "f_standing_tank" },
"liquids": {
"%": { "liquid": "purifier", "amount": [ 2, 20 ] },
"!": { "liquid": "mutagen_bird", "amount": [ 2, 20 ] },
Expand Down Expand Up @@ -308,15 +302,9 @@
"|JJJXs^|",
"||||||||"
],
"palettes": [ "lab_common_palette", "lab_mutagen_palette" ],
"palettes": [ "lab_common_palette", "lab_mutagen_palette", "lab_vent_palette" ],
"terrain": { "|": "t_wall_metal" },
"furniture": {
"^": "f_vent_cold_air2_blast",
"%": "f_standing_tank",
"!": "f_standing_tank",
"ō": "f_standing_tank",
"ŏ": "f_standing_tank"
},
"furniture": { "%": "f_standing_tank", "!": "f_standing_tank", "ō": "f_standing_tank", "ŏ": "f_standing_tank" },
"liquids": {
"%": { "liquid": "mutagen_cattle", "amount": [ 2, 20 ] },
"!": { "liquid": "mutagen_bird", "amount": [ 2, 20 ] },
Expand Down Expand Up @@ -358,9 +346,9 @@
"|JJJXs^|",
"||||||||"
],
"palettes": [ "lab_common_palette", "lab_mutagen_palette" ],
"palettes": [ "lab_common_palette", "lab_mutagen_palette", "lab_vent_palette" ],
"terrain": { "|": "t_wall_metal" },
"furniture": { "^": "f_vent_cold_air2_blast", "%": "f_standing_tank", "!": "f_standing_tank", "ō": "f_standing_tank" },
"furniture": { "%": "f_standing_tank", "!": "f_standing_tank", "ō": "f_standing_tank" },
"liquids": {
"%": { "liquid": "purifier", "amount": [ 2, 20 ] },
"!": { "liquid": "mutagen_bird", "amount": [ 2, 20 ] },
Expand Down Expand Up @@ -1030,8 +1018,7 @@
" ^ ",
"mmm"
],
"palettes": [ "lab_common_palette" ],
"furniture": { "^": "f_vent_cold_air2_blast" },
"palettes": [ "lab_common_palette", "lab_vent_palette" ],
"place_loot": [
{ "item": "meat", "x": [ 0, 2 ], "y": 0, "chance": 70, "repeat": [ 1, 3 ] },
{ "item": "tallow", "x": [ 0, 2 ], "y": 0, "chance": 70, "repeat": [ 1, 3 ] },
Expand Down Expand Up @@ -1073,8 +1060,7 @@
" ^ ",
"mmm"
],
"palettes": [ "lab_common_palette" ],
"furniture": { "^": "f_vent_cold_air2_blast" },
"palettes": [ "lab_common_palette", "lab_vent_palette" ],
"place_loot": [
{ "item": "meat", "x": [ 0, 2 ], "y": 0, "chance": 70, "repeat": [ 1, 3 ] },
{ "item": "meat_tainted", "x": [ 0, 2 ], "y": 2, "chance": 70, "repeat": [ 1, 3 ] }
Expand Down
12 changes: 12 additions & 0 deletions data/json/mapgen_palettes/lab/lab_modular_palette.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,5 +569,17 @@
{ "item": "snacks", "chance": 30 }
]
}
},
{
"type": "palette",
"id": "lab_vent_palette",
"//": "Adds a vent to the grate from the common palette. Vent will be either cold or hot, but the same for the entire lab",
"parameters": {
"lab_vent_type": {
"type": "furn_str_id",
"default": { "distribution": [ [ "f_vent_cold_air2_blast", 2 ], [ "f_vent_hot_air2_blast", 1 ] ] }
}
},
"furniture": { "^": { "param": "lab_vent_type", "fallback": "f_vent_cold_air2_blast" } }
}
]
10 changes: 10 additions & 0 deletions src/cata_variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,22 @@ std::string enum_to_string<cata_variant_type>( cata_variant_type type )
case cata_variant_type::chrono_seconds: return "chrono_seconds";
case cata_variant_type::debug_menu_index: return "debug_menu_index";
case cata_variant_type::efftype_id: return "efftype_id";
case cata_variant_type::faction_id: return "faction_id";
case cata_variant_type::field_type_id: return "field_type_id";
case cata_variant_type::field_type_str_id: return "field_type_str_id";
case cata_variant_type::furn_id: return "furn_id";
case cata_variant_type::furn_str_id: return "furn_str_id";
case cata_variant_type::flag_id: return "flag_id";
case cata_variant_type::int_: return "int";
case cata_variant_type::item_group_id: return "item_group_id";
case cata_variant_type::itype_id: return "itype_id";
case cata_variant_type::matype_id: return "matype_id";
case cata_variant_type::mongroup_id: return "mongroup_id";
case cata_variant_type::mtype_id: return "mtype_id";
case cata_variant_type::move_mode_id: return "character_movemode";
case cata_variant_type::mutagen_technique: return "mutagen_technique";
case cata_variant_type::mutation_category_id: return "mutation_category_id";
case cata_variant_type::npc_template_id: return "npc_template_id";
case cata_variant_type::oter_id: return "oter_id";
case cata_variant_type::oter_type_str_id: return "oter_type_str_id";
case cata_variant_type::point: return "point";
Expand All @@ -64,11 +70,15 @@ std::string enum_to_string<cata_variant_type>( cata_variant_type type )
case cata_variant_type::spell_id: return "spell_id";
case cata_variant_type::string: return "string";
case cata_variant_type::ter_id: return "ter_id";
case cata_variant_type::ter_furn_transform_id: return "ter_furn_transform_id";
case cata_variant_type::ter_str_id: return "ter_str_id";
case cata_variant_type::trait_id: return "trait_id";
case cata_variant_type::trap_id: return "trap_id";
case cata_variant_type::trap_str_id: return "trap_str_id";
case cata_variant_type::tripoint: return "tripoint";
case cata_variant_type::vgroup_id: return "vgroup_id";
case cata_variant_type::widget_id: return "widget_id";
case cata_variant_type::zone_type_id: return "zone_type_id";
// *INDENT-ON*
case cata_variant_type::num_types:
break;
Expand Down
42 changes: 41 additions & 1 deletion src/cata_variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,22 @@ enum class cata_variant_type : int {
chrono_seconds,
debug_menu_index,
efftype_id,
faction_id,
field_type_id,
field_type_str_id,
furn_id,
furn_str_id,
flag_id,
int_,
item_group_id,
itype_id,
matype_id,
mtype_id,
mongroup_id,
move_mode_id,
mutagen_technique,
mutation_category_id,
npc_template_id,
oter_id,
oter_type_str_id,
point,
Expand All @@ -64,11 +70,15 @@ enum class cata_variant_type : int {
spell_id,
string,
ter_id,
ter_furn_transform_id,
ter_str_id,
trait_id,
trap_id,
trap_str_id,
tripoint,
vgroup_id,
widget_id,
zone_type_id,
num_types, // last
};

Expand Down Expand Up @@ -175,7 +185,7 @@ struct convert_enum {
};

// These are the specializations of convert for each value type.
static_assert( static_cast<int>( cata_variant_type::num_types ) == 34,
static_assert( static_cast<int>( cata_variant_type::num_types ) == 44,
"This assert is a reminder to add conversion support for any new types to the "
"below specializations" );

Expand Down Expand Up @@ -254,6 +264,15 @@ struct convert<cata_variant_type::move_mode_id> : convert_string_id<move_mode_id
template<>
struct convert<cata_variant_type::efftype_id> : convert_string_id<efftype_id> {};

template<>
struct convert<cata_variant_type::faction_id> : convert_string_id<faction_id> {};

template<>
struct convert<cata_variant_type::field_type_id> : convert_int_id<field_type_id> {};

template<>
struct convert<cata_variant_type::field_type_str_id> : convert_string_id<field_type_str_id> {};

template<>
struct convert<cata_variant_type::furn_id> : convert_int_id<furn_id> {};

Expand All @@ -278,6 +297,9 @@ struct convert<cata_variant_type::int_> {
}
};

template<>
struct convert<cata_variant_type::item_group_id> : convert_string_id<item_group_id> {};

template<>
struct convert<cata_variant_type::itype_id> : convert_string_id<itype_id> {};

Expand All @@ -287,13 +309,19 @@ struct convert<cata_variant_type::matype_id> : convert_string_id<matype_id> {};
template<>
struct convert<cata_variant_type::mtype_id> : convert_string_id<mtype_id> {};

template<>
struct convert<cata_variant_type::mongroup_id> : convert_string_id<mongroup_id> {};

template<>
struct convert<cata_variant_type::mutagen_technique> : convert_enum<mutagen_technique> {};

template<>
struct convert<cata_variant_type::mutation_category_id> :
convert_string_id<mutation_category_id> {};

template<>
struct convert<cata_variant_type::npc_template_id> : convert_string_id<npc_template_id> {};

template<>
struct convert<cata_variant_type::oter_id> : convert_int_id<oter_id> {};

Expand Down Expand Up @@ -333,12 +361,19 @@ struct convert<cata_variant_type::string> : convert_string<std::string> {};
template<>
struct convert<cata_variant_type::ter_id> : convert_int_id<ter_id> {};

template<>
struct convert<cata_variant_type::ter_furn_transform_id> :
convert_string_id<ter_furn_transform_id> {};

template<>
struct convert<cata_variant_type::ter_str_id> : convert_string_id<ter_str_id> {};

template<>
struct convert<cata_variant_type::trait_id> : convert_string_id<trait_id> {};

template<>
struct convert<cata_variant_type::trap_id> : convert_int_id<trap_id> {};

template<>
struct convert<cata_variant_type::trap_str_id> : convert_string_id<trap_str_id> {};

Expand All @@ -357,9 +392,14 @@ struct convert<cata_variant_type::tripoint> {
}
};

template<>
struct convert<cata_variant_type::vgroup_id> : convert_string_id<vgroup_id> {};

template<>
struct convert<cata_variant_type::widget_id> : convert_string_id<widget_id> {};

template<>
struct convert<cata_variant_type::zone_type_id> : convert_string_id<zone_type_id> {};

} // namespace cata_variant_detail

Expand Down
16 changes: 0 additions & 16 deletions src/clzones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,6 @@ static const item_category_id item_category_food( "food" );

zone_manager::zone_manager()
{
types.emplace( zone_type_id( "NO_AUTO_PICKUP" ),
zone_type( to_translation( "No Auto Pickup" ),
to_translation( "You won't auto-pickup items inside the zone." ) ) );
types.emplace( zone_type_id( "NO_NPC_PICKUP" ),
zone_type( to_translation( "No NPC Pickup" ),
to_translation( "Friendly NPCs don't pickup items inside the zone." ) ) );
types.emplace( zone_type_id( "NPC_RETREAT" ),
zone_type( to_translation( "NPC Retreat" ),
to_translation( "When fleeing, friendly NPCs will attempt to retreat toward this zone if it is within 60 tiles." ) ) );
types.emplace( zone_type_id( "NPC_NO_INVESTIGATE" ),
zone_type( to_translation( "NPC Ignore Sounds" ),
to_translation( "Friendly NPCs won't investigate unseen sounds coming from this zone." ) ) );
types.emplace( zone_type_id( "NPC_INVESTIGATE_ONLY" ),
zone_type( to_translation( "NPC Investigation Area" ),
to_translation( "Friendly NPCs will investigate unseen sounds only if they come from inside this area." ) ) );

for( const zone_type &zone : zone_type::get_all() ) {
types.emplace( zone.id, zone );
}
Expand Down
6 changes: 6 additions & 0 deletions src/faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@ faction *faction_manager::get( const faction_id &id, const bool complain )
return nullptr;
}

template<>
bool string_id<faction>::is_valid() const
{
return g->faction_manager_ptr->get( *this, false ) != nullptr;
}

void basecamp::faction_display( const catacurses::window &fac_w, const int width ) const
{
int y = 2;
Expand Down
Loading

0 comments on commit 13146bd

Please sign in to comment.