Skip to content

Commit

Permalink
Merge pull request #75836 from RenechCDDA/oter_search_all_types
Browse files Browse the repository at this point in the history
EOC OMT search functions look for matching type
  • Loading branch information
Maleclypse authored Aug 30, 2024
2 parents b38588a + 13df54e commit 1ab5fb4
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 183 deletions.
8 changes: 4 additions & 4 deletions data/json/effects_on_condition/misc_effect_on_condition.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
"id": "ambient_subway",
"recurrence": [ "1 hours", "2 hours" ],
"global": true,
"condition": { "or": [ { "u_at_om_location": "subway_ns" }, { "u_at_om_location": "subway_ew" } ] },
"condition": { "u_at_om_location": "subway" },
"effect": [ { "u_message": "<AMBIENT_SUBWAY>", "snippet": true, "sound": true } ]
},
{
"type": "effect_on_condition",
"id": "ambient_lab_subway",
"recurrence": [ "1 hours", "2 hours" ],
"global": true,
"condition": { "or": [ { "u_at_om_location": "lab_subway_ns" }, { "u_at_om_location": "lab_subway_ew" } ] },
"condition": { "u_at_om_location": "lab_subway" },
"effect": [ { "u_message": "<AMBIENT_LAB_SUBWAY>", "snippet": true, "sound": true } ]
},
{
"type": "effect_on_condition",
"id": "ambient_sewer",
"recurrence": [ "1 hours", "2 hours" ],
"global": true,
"condition": { "or": [ { "u_at_om_location": "sewer_ns" }, { "u_at_om_location": "sewer_ew" } ] },
"condition": { "u_at_om_location": "sewer" },
"effect": [ { "u_message": "<AMBIENT_SEWER>", "snippet": true, "sound": true } ]
},
{
Expand Down Expand Up @@ -133,7 +133,7 @@
"id": "sewer_morale_debuff",
"global": false,
"recurrence": [ "20 minutes", "1 hour" ],
"condition": { "or": [ { "u_at_om_location": "sewer_ns" }, { "u_at_om_location": "sewer_ew" } ] },
"condition": { "u_at_om_location": "sewer" },
"effect": [
{ "u_message": "<SEWER_MORALE_DEBUFF>", "snippet": true },
{
Expand Down
46 changes: 1 addition & 45 deletions data/mods/Magiclysm/Spells/druid.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,6 @@
{ "u_is_on_terrain_with_flag": "YOUNG" }
]
},
{ "not": { "u_near_om_location": "road_curved", "range": 1 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 1 } },
{ "not": { "u_near_om_location": "road_tee", "range": 1 } },
{ "not": { "u_near_om_location": "road_straight", "range": 1 } },
{ "not": { "u_near_om_location": "road_end", "range": 1 } },
{ "not": { "u_near_om_location": "road_sw", "range": 1 } },
{ "not": { "u_near_om_location": "road_ne", "range": 1 } },
{ "not": { "u_near_om_location": "road_ew", "range": 1 } },
{ "not": { "u_near_om_location": "road_ns", "range": 1 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 1 } },
{ "not": { "u_near_om_location": "road", "range": 1 } }
]
},
Expand Down Expand Up @@ -731,16 +721,6 @@
{ "u_is_on_terrain_with_flag": "YOUNG" }
]
},
{ "not": { "u_near_om_location": "road_curved", "range": 1 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 1 } },
{ "not": { "u_near_om_location": "road_tee", "range": 1 } },
{ "not": { "u_near_om_location": "road_straight", "range": 1 } },
{ "not": { "u_near_om_location": "road_end", "range": 1 } },
{ "not": { "u_near_om_location": "road_sw", "range": 1 } },
{ "not": { "u_near_om_location": "road_ne", "range": 1 } },
{ "not": { "u_near_om_location": "road_ew", "range": 1 } },
{ "not": { "u_near_om_location": "road_ns", "range": 1 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 1 } },
{ "not": { "u_near_om_location": "road", "range": 1 } }
]
},
Expand Down Expand Up @@ -1302,16 +1282,6 @@
{ "u_is_on_terrain_with_flag": "YOUNG" }
]
},
{ "not": { "u_near_om_location": "road_curved", "range": 1 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 1 } },
{ "not": { "u_near_om_location": "road_tee", "range": 1 } },
{ "not": { "u_near_om_location": "road_straight", "range": 1 } },
{ "not": { "u_near_om_location": "road_end", "range": 1 } },
{ "not": { "u_near_om_location": "road_sw", "range": 1 } },
{ "not": { "u_near_om_location": "road_ne", "range": 1 } },
{ "not": { "u_near_om_location": "road_ew", "range": 1 } },
{ "not": { "u_near_om_location": "road_ns", "range": 1 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 1 } },
{ "not": { "u_near_om_location": "road", "range": 1 } }
]
},
Expand Down Expand Up @@ -1341,21 +1311,7 @@
{ "not": { "u_is_on_terrain_with_flag": "YOUNG" } }
]
},
{
"or": [
{ "u_near_om_location": "road_curved", "range": 1 },
{ "u_near_om_location": "road_four_way", "range": 1 },
{ "u_near_om_location": "road_tee", "range": 1 },
{ "u_near_om_location": "road_straight", "range": 1 },
{ "u_near_om_location": "road_end", "range": 1 },
{ "u_near_om_location": "road_sw", "range": 1 },
{ "u_near_om_location": "road_ne", "range": 1 },
{ "u_near_om_location": "road_ew", "range": 1 },
{ "u_near_om_location": "road_ns", "range": 1 },
{ "u_near_om_location": "road_nesw", "range": 1 },
{ "u_near_om_location": "road", "range": 1 }
]
}
{ "u_near_om_location": "road", "range": 1 }
]
}
]
Expand Down
26 changes: 1 addition & 25 deletions data/mods/Magiclysm/Spells/mana_upgrades.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,7 @@
{ "u_at_om_location": "river_c_not_ne" },
{ "u_at_om_location": "river_c_not_nw" },
{ "u_at_om_location": "river_c_not_se" },
{ "u_at_om_location": "river_c_not_sw" },
{ "u_at_om_location": "river_ne" },
{ "u_at_om_location": "river_se" },
{ "u_at_om_location": "river_sw" },
{ "u_at_om_location": "river_nw" }
{ "u_at_om_location": "river_c_not_sw" }
]
},
{ "u_is_on_terrain_with_flag": "CURRENT" },
Expand Down Expand Up @@ -306,16 +302,6 @@
{ "not": { "u_at_om_location": "FACTION_CAMP_ANY" } },
{ "not": { "u_near_om_location": "cabin", "range": 4 } },
{ "not": { "u_near_om_location": "magic_cabin", "range": 4 } },
{ "not": { "u_near_om_location": "road_curved", "range": 4 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 4 } },
{ "not": { "u_near_om_location": "road_tee", "range": 4 } },
{ "not": { "u_near_om_location": "road_straight", "range": 4 } },
{ "not": { "u_near_om_location": "road_end", "range": 4 } },
{ "not": { "u_near_om_location": "road_sw", "range": 4 } },
{ "not": { "u_near_om_location": "road_ne", "range": 4 } },
{ "not": { "u_near_om_location": "road_ew", "range": 4 } },
{ "not": { "u_near_om_location": "road_ns", "range": 4 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 4 } },
{ "not": { "u_near_om_location": "road", "range": 4 } },
{ "not": { "u_near_om_location": "dirt_road", "range": 4 } },
{ "not": { "u_near_om_location": "dumpsite", "range": 4 } }
Expand Down Expand Up @@ -384,16 +370,6 @@
{ "not": { "u_at_om_location": "FACTION_CAMP_ANY" } },
{ "not": { "u_near_om_location": "cabin", "range": 15 } },
{ "not": { "u_near_om_location": "magic_cabin", "range": 15 } },
{ "not": { "u_near_om_location": "road_curved", "range": 15 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 15 } },
{ "not": { "u_near_om_location": "road_tee", "range": 15 } },
{ "not": { "u_near_om_location": "road_straight", "range": 15 } },
{ "not": { "u_near_om_location": "road_end", "range": 15 } },
{ "not": { "u_near_om_location": "road_sw", "range": 15 } },
{ "not": { "u_near_om_location": "road_ne", "range": 15 } },
{ "not": { "u_near_om_location": "road_ew", "range": 15 } },
{ "not": { "u_near_om_location": "road_ns", "range": 15 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 15 } },
{ "not": { "u_near_om_location": "road", "range": 15 } },
{ "not": { "u_near_om_location": "dirt_road", "range": 15 } },
{ "not": { "u_near_om_location": "dumpsite", "range": 15 } }
Expand Down
10 changes: 0 additions & 10 deletions data/mods/Magiclysm/items/enchanted_boots.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,6 @@
{ "u_is_on_terrain_with_flag": "YOUNG" }
]
},
{ "not": { "u_near_om_location": "road_curved", "range": 1 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 1 } },
{ "not": { "u_near_om_location": "road_tee", "range": 1 } },
{ "not": { "u_near_om_location": "road_straight", "range": 1 } },
{ "not": { "u_near_om_location": "road_end", "range": 1 } },
{ "not": { "u_near_om_location": "road_sw", "range": 1 } },
{ "not": { "u_near_om_location": "road_ne", "range": 1 } },
{ "not": { "u_near_om_location": "road_ew", "range": 1 } },
{ "not": { "u_near_om_location": "road_ns", "range": 1 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 1 } },
{ "not": { "u_near_om_location": "road", "range": 1 } }
]
},
Expand Down
16 changes: 1 addition & 15 deletions data/mods/Xedra_Evolved/mutations/paraclesians/arvore_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,7 @@
"run_eocs": [
{
"id": "EOC_CONDITION_CHECK_ARVORE_IN_THE_WILD_ON_OMT_ENTER_2",
"condition": {
"and": [
{ "not": { "u_near_om_location": "road_curved", "range": 2 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 2 } },
{ "not": { "u_near_om_location": "road_tee", "range": 2 } },
{ "not": { "u_near_om_location": "road_straight", "range": 2 } },
{ "not": { "u_near_om_location": "road_end", "range": 2 } },
{ "not": { "u_near_om_location": "road_sw", "range": 2 } },
{ "not": { "u_near_om_location": "road_ne", "range": 2 } },
{ "not": { "u_near_om_location": "road_ew", "range": 2 } },
{ "not": { "u_near_om_location": "road_ns", "range": 2 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 2 } },
{ "not": { "u_near_om_location": "road", "range": 2 } }
]
},
"condition": { "not": { "u_near_om_location": "road", "range": 2 } },
"effect": [ { "math": [ "u_arvore_is_in_wilderness", "=", "1" ] } ],
"false_effect": [ { "math": [ "u_arvore_is_in_wilderness", "=", "0" ] } ]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@
{ "u_is_on_terrain_with_flag": "YOUNG" }
]
},
{ "not": { "u_near_om_location": "road_curved", "range": 1 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 1 } },
{ "not": { "u_near_om_location": "road_tee", "range": 1 } },
{ "not": { "u_near_om_location": "road_straight", "range": 1 } },
{ "not": { "u_near_om_location": "road_end", "range": 1 } },
{ "not": { "u_near_om_location": "road_sw", "range": 1 } },
{ "not": { "u_near_om_location": "road_ne", "range": 1 } },
{ "not": { "u_near_om_location": "road_ew", "range": 1 } },
{ "not": { "u_near_om_location": "road_ns", "range": 1 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 1 } },
{ "not": { "u_near_om_location": "road", "range": 1 } }
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,27 +336,7 @@
{
"type": "effect_on_condition",
"id": "EOC_HOMULLUS_ALL_ROADS_TRANSLOCATE_CHECK",
"condition": {
"and": [
"u_is_outside",
{
"or": [
{ "u_at_om_location": "road_curved" },
{ "u_at_om_location": "road_tee" },
{ "u_at_om_location": "road_four_way" },
{ "u_at_om_location": "road_end" },
{ "u_at_om_location": "road_sw" },
{ "u_at_om_location": "road_ne" },
{ "u_at_om_location": "road_ew" },
{ "u_at_om_location": "road_ns" },
{ "u_at_om_location": "road_nesw" },
{ "u_at_om_location": "road" },
{ "u_at_om_location": "road_straight" }
]
},
{ "u_is_on_terrain_with_flag": "ROAD" }
]
},
"condition": { "and": [ "u_is_outside", { "u_at_om_location": "road" }, { "u_is_on_terrain_with_flag": "ROAD" } ] },
"effect": [ { "u_cast_spell": { "id": "paraclesian_translocate" } } ],
"false_effect": [ { "u_message": "You must be standing on a road to cast this spell.", "type": "mixed" } ]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,6 @@
{
"condition": {
"or": [
{ "u_near_om_location": "road_curved", "range": 3 },
{ "u_near_om_location": "road_four_way", "range": 3 },
{ "u_near_om_location": "road_tee", "range": 3 },
{ "u_near_om_location": "road_straight", "range": 3 },
{ "u_near_om_location": "road_end", "range": 3 },
{ "u_near_om_location": "road_sw", "range": 3 },
{ "u_near_om_location": "road_ne", "range": 3 },
{ "u_near_om_location": "road_ew", "range": 3 },
{ "u_near_om_location": "road_ns", "range": 3 },
{ "u_near_om_location": "road_nesw", "range": 3 },
{ "u_near_om_location": "road", "range": 3 },
{ "u_near_om_location": "dirt_road", "range": 3 },
{ "u_near_om_location": "subway", "range": 3 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,7 @@
{ "u_is_on_terrain": "t_dirtfloor_thatchroof" }
]
},
{
"or": [
{ "u_near_om_location": "road_curved", "range": 1 },
{ "u_near_om_location": "road_four_way", "range": 1 },
{ "u_near_om_location": "road_tee", "range": 1 },
{ "u_near_om_location": "road_straight", "range": 1 },
{ "u_near_om_location": "road_end", "range": 1 },
{ "u_near_om_location": "road_sw", "range": 1 },
{ "u_near_om_location": "road_ne", "range": 1 },
{ "u_near_om_location": "road_ew", "range": 1 },
{ "u_near_om_location": "road_ns", "range": 1 },
{ "u_near_om_location": "road_nesw", "range": 1 },
{ "u_near_om_location": "road", "range": 1 }
]
}
{ "u_near_om_location": "road", "range": 1 }
]
}
]
Expand Down Expand Up @@ -161,16 +147,6 @@
{
"and": [
{ "not": { "test_eoc": "EOC_HOMULLUS_IN_CIVILIZATION_CHECKER_CONDITION" } },
{ "not": { "u_near_om_location": "road_curved", "range": 1 } },
{ "not": { "u_near_om_location": "road_four_way", "range": 1 } },
{ "not": { "u_near_om_location": "road_tee", "range": 1 } },
{ "not": { "u_near_om_location": "road_straight", "range": 1 } },
{ "not": { "u_near_om_location": "road_end", "range": 1 } },
{ "not": { "u_near_om_location": "road_sw", "range": 1 } },
{ "not": { "u_near_om_location": "road_ne", "range": 1 } },
{ "not": { "u_near_om_location": "road_ew", "range": 1 } },
{ "not": { "u_near_om_location": "road_ns", "range": 1 } },
{ "not": { "u_near_om_location": "road_nesw", "range": 1 } },
{ "not": { "u_near_om_location": "road", "range": 1 } }
]
},
Expand Down Expand Up @@ -339,10 +315,6 @@
{ "u_near_om_location": "river_c_not_nw", "range": 1 },
{ "u_near_om_location": "river_c_not_se", "range": 1 },
{ "u_near_om_location": "river_c_not_sw", "range": 1 },
{ "u_near_om_location": "river_ne", "range": 1 },
{ "u_near_om_location": "river_se", "range": 1 },
{ "u_near_om_location": "river_sw", "range": 1 },
{ "u_near_om_location": "river_nw", "range": 1 },
{ "u_near_om_location": "lake_shore", "range": 1 },
{ "u_near_om_location": "lake_surface", "range": 1 }
]
Expand Down Expand Up @@ -396,10 +368,6 @@
{ "u_at_om_location": "river_c_not_nw" },
{ "u_at_om_location": "river_c_not_se" },
{ "u_at_om_location": "river_c_not_sw" },
{ "u_at_om_location": "river_ne" },
{ "u_at_om_location": "river_se" },
{ "u_at_om_location": "river_sw" },
{ "u_at_om_location": "river_nw" },
{ "u_at_om_location": "lake_shore" },
{ "u_at_om_location": "lake_surface" }
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
{ "u_near_om_location": "river_c_not_nw", "range": 1 },
{ "u_near_om_location": "river_c_not_se", "range": 1 },
{ "u_near_om_location": "river_c_not_sw", "range": 1 },
{ "u_near_om_location": "river_ne", "range": 1 },
{ "u_near_om_location": "river_se", "range": 1 },
{ "u_near_om_location": "river_sw", "range": 1 },
{ "u_near_om_location": "river_nw", "range": 1 },
{ "u_near_om_location": "lake_shore", "range": 1 },
{ "u_near_om_location": "lake_surface", "range": 1 },
{ "u_near_om_location": "ocean", "range": 1 },
Expand Down Expand Up @@ -214,10 +210,6 @@
{ "u_at_om_location": "river_c_not_nw" },
{ "u_at_om_location": "river_c_not_se" },
{ "u_at_om_location": "river_c_not_sw" },
{ "u_at_om_location": "river_ne" },
{ "u_at_om_location": "river_se" },
{ "u_at_om_location": "river_sw" },
{ "u_at_om_location": "river_nw" },
{ "u_at_om_location": "lake_shore" },
{ "u_at_om_location": "lake_surface" },
{ "u_at_om_location": "ocean" },
Expand Down
4 changes: 2 additions & 2 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ conditional_t::func f_at_om_location( const JsonObject &jo, std::string_view mem
const std::optional<mapgen_arguments> *maybe_args = overmap_buffer.mapgen_args( omt_pos );
return !recipe_group::get_recipes_by_id( "all_faction_base_types", omt_ter, maybe_args ).empty();
} else {
return oter_no_dir( omt_ter ) == location_value;
return oter_no_dir_or_connections( omt_ter ) == location_value;
}
};
}
Expand Down Expand Up @@ -1082,7 +1082,7 @@ conditional_t::func f_near_om_location( const JsonObject &jo, std::string_view m
!recipe_group::get_recipes_by_id( "all_faction_base_types", omt_ter, maybe_args ).empty() ) {
return true;
} else {
if( oter_no_dir( omt_ter ) == location_value ) {
if( oter_no_dir_or_connections( omt_ter ) == location_value ) {
return true;
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7749,6 +7749,22 @@ std::string_view oter_no_dir( const oter_id &oter )
return base_oter_id;
}

std::string_view oter_no_dir_or_connections( const oter_id &oter )
{
std::string_view base_oter_id = oter_no_dir( oter );
for( const std::string &suffix : om_lines::mapgen_suffixes ) {
if( string_ends_with( base_oter_id, suffix ) ) {
base_oter_id = base_oter_id.substr( 0, base_oter_id.size() - suffix.size() );
}
}
for( const auto &connection_type : om_lines::all ) {
if( string_ends_with( base_oter_id, connection_type.suffix ) ) {
base_oter_id = base_oter_id.substr( 0, base_oter_id.size() - connection_type.suffix.size() );
}
}
return base_oter_id;
}

int oter_get_rotation( const oter_id &oter )
{
std::string base_oter_id = oter.id().c_str();
Expand Down
5 changes: 5 additions & 0 deletions src/overmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,11 @@ om_special_sectors get_sectors( int sector_width );
*/
std::string_view oter_no_dir( const oter_id &oter );

/**
* Returns the string of oter without any directional, connection, or line suffix
*/
std::string_view oter_no_dir_or_connections( const oter_id &oter );

/**
* Return 0, 1, 2, 3 respectively if the suffix is _north, _west, _south, _east
* Return 0 if there's no suffix
Expand Down

0 comments on commit 1ab5fb4

Please sign in to comment.