Skip to content

Commit

Permalink
feat: allow treating steel targets as practice targets (#4143)
Browse files Browse the repository at this point in the history
* feat: allow treating steel targets as practice targets

* Update json_flags.md

* style(autofix.ci): automated formatting

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
chaosvolt and autofix-ci[bot] authored Feb 4, 2024
1 parent d3ee92c commit d937e8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion data/json/furniture_and_terrain/furniture-recreation.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"move_cost_mod": 2,
"coverage": 40,
"required_str": 5,
"flags": [ "PLACE_ITEM", "TRANSPARENT" ],
"flags": [ "PLACE_ITEM", "TRANSPARENT", "SHOOT_ME" ],
"bash": {
"str_min": 6,
"str_max": 40,
Expand Down
2 changes: 2 additions & 0 deletions doc/src/content/docs/en/mod/json/reference/json_flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ List of known flags, used in both `terrain.json` and `furniture.json`.
- `SEALED` Can't use <kbd>e</kbd> to retrieve items; must smash them open first.
- `SEEN_FROM_ABOVE` Visible from a higher level (provided the tile above has no floor)
- `SHARP` May do minor damage to players/monsters passing through it.
- `SHOOT_ME` Players can aim at terrain or furniture with this flag like they can with
`tr_practice_target` to train marksmanship.
- `SHORT` Feature too short to collide with vehicle protrusions. (mirrors, blades).
- `SIGN` Show written message on examine.
- `SMALL_PASSAGE` This terrain or furniture is too small for large or huge creatures to pass
Expand Down
6 changes: 5 additions & 1 deletion src/ranged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ static const bionic_id bio_ups( "bio_ups" );
static const trait_id trait_PYROMANIA( "PYROMANIA" );
static const trait_id trait_NORANGEDCRIT( "NO_RANGED_CRIT" );

// not to confuse with item flags (json_flag)
static const std::string flag_SHOOT_ME( "SHOOT_ME" );

// Maximum duration of aim-and-fire loop, in turns
static constexpr int AIF_DURATION_LIMIT = 10;

Expand Down Expand Up @@ -2757,7 +2760,8 @@ tripoint target_ui::choose_initial_target()
const std::vector<tripoint> nearby = closest_points_first( src, range );
const auto target_spot = std::find_if( nearby.begin(), nearby.end(),
[this, &here]( const tripoint & pt ) {
return here.tr_at( pt ).id == tr_practice_target && this->you->sees( pt );
return ( here.has_flag_ter_or_furn( flag_SHOOT_ME, pt ) ||
here.tr_at( pt ).id == tr_practice_target ) && this->you->sees( pt );
} );
if( target_spot != nearby.end() ) {
return *target_spot;
Expand Down

0 comments on commit d937e8f

Please sign in to comment.