Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add map_id condition for EoC #72661

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions doc/EFFECT_ON_CONDITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,37 @@ Check the north terrain or furniture has `TRANSPARENT` flag.
},
```

### `map_terrain_id`, `map_furniture_id`
- type: string or [variable object](##variable-object)
- return true if the terrain or furniture has specific id
- `loc` will specify location of terrain or furniture (**mandatory**)

#### Valid talkers:

No talker is needed.

#### Examples
Runs a query, allowing you to pick specific tile around. When picked, stores coordinates of this tile in `check_terrain` variable, and then check is it a `t_grass`. If yes, `effect` is run, otherwise `false_effect` is run
```json
{
"type": "effect_on_condition",
"id": "EOC_TEST_QUERY",
"condition": {
"and": [
{
"u_query_tile": "line_of_sight",
"target_var": { "context_val": "check_terrain" },
"message": "Check what terrain it is",
"range": 10
},
{ "map_terrain_id": "t_grass", "loc": { "context_val": "check_terrain" } }
]
},
"effect": [ { "u_message": "it is a grass" } ],
"false_effect": [ { "u_message": "it is NOT a grass" } ]
}
```

### `map_in_city`
- type: location string or [variable object](##variable-object)
- return true if the location is in a city
Expand Down
22 changes: 22 additions & 0 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,26 @@
};
}

conditional_t::func f_map_ter_furn_id( const JsonObject &jo, std::string_view member )
{
str_or_var furn_type = get_str_or_var( jo.get_member( member ), member, true );
var_info loc_var = read_var_info( jo.get_object( "loc" ) );
bool terrain = true;
if( member == "map_terrain_id" ) {
terrain = true;
} else if( member == "map_furniture_id" ) {
terrain = false;
}
return [terrain, furn_type, loc_var]( dialogue const & d ) {
tripoint loc = get_map().getlocal( get_tripoint_from_var( loc_var, d ) );
if( terrain ) {

Check failure on line 1604 in src/condition.cpp

View workflow job for this annotation

GitHub Actions / build (src)

if with identical then and else branches [bugprone-branch-clone,-warnings-as-errors]
GuardianDll marked this conversation as resolved.
Show resolved Hide resolved
return get_map().ter( loc ) == ter_id( furn_type.evaluate( d ) );
} else {
return get_map().ter( loc ) == ter_id( furn_type.evaluate( d ) );
}
};
}

conditional_t::func f_map_in_city( const JsonObject &jo, std::string_view member )
{
str_or_var target = get_str_or_var( jo.get_member( member ), member, true );
Expand Down Expand Up @@ -2400,6 +2420,8 @@
{"is_weather", jarg::member, &conditional_fun::f_is_weather },
{"map_terrain_with_flag", jarg::member, &conditional_fun::f_map_ter_furn_with_flag },
{"map_furniture_with_flag", jarg::member, &conditional_fun::f_map_ter_furn_with_flag },
{"map_terrain_id", jarg::member, &conditional_fun::f_map_ter_furn_id },
{"map_furniture_id", jarg::member, &conditional_fun::f_map_ter_furn_id },
{"map_in_city", jarg::member, &conditional_fun::f_map_in_city },
{"mod_is_loaded", jarg::member, &conditional_fun::f_mod_is_loaded },
{"u_has_faction_trust", jarg::member | jarg::array, &conditional_fun::f_has_faction_trust },
Expand Down
Loading