Skip to content

Commit

Permalink
Commit for remote
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosvolt committed Jan 18, 2024
1 parent 16229e4 commit b4c8c72
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ballistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ dealt_projectile_attack projectile_attack( const projectile &proj_arg, const tri
map &here = get_map();
double target_size = target_critter != nullptr ?
target_critter->ranged_target_size() :
here.ranged_target_size( target_arg );
here.ranged_target_size( target_arg, range );
projectile_attack_aim aim = projectile_attack_roll( dispersion, range, target_size );

// TODO: move to-hit roll back in here
Expand Down
9 changes: 7 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2018,7 +2018,7 @@ bool map::valid_move( const tripoint &from, const tripoint &to,

// End of move cost

double map::ranged_target_size( const tripoint &p ) const
double map::ranged_target_size( const tripoint &p, double range ) const
{
if( impassable( p ) ) {
return 1.0;
Expand All @@ -2028,7 +2028,12 @@ double map::ranged_target_size( const tripoint &p ) const
return 0.0;
}

// TODO: Handle cases like shrubs, trees, furniture, sandbags...
// Coverage of furniture like sandbags gives X% chance to intercept a shot
// Does not apply if you're adjacent, it's assumed you're firing over it
if( x_in_y( coverage( p ), 100 ) && range > 1 ) {
return 1.0;
}

return 0.1;
}

Expand Down
4 changes: 3 additions & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,10 @@ class map
* Size of map objects at `p` for purposes of ranged combat.
* Size is in percentage of tile: if 1.0, all attacks going through tile
* should hit map objects on it, if 0.0 there is nothing to be hit (air/water).
* Coverage value of furniture adds a percent chance to intercept shots
* unless shooter is adjacent to it.
*/
double ranged_target_size( const tripoint &p ) const;
double ranged_target_size( const tripoint &p, double range ) const;

// Sees:
/**
Expand Down

0 comments on commit b4c8c72

Please sign in to comment.