Skip to content

Commit

Permalink
Use percent chance in ammo effects aoe instead of one_in chance (#37190)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Granade <[email protected]>
  • Loading branch information
ZhilkinSerg and kevingranade authored Jan 31, 2020
1 parent 5b19149 commit ffc3ce3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions data/json/ammo_effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"intensity_max": 0,
"radius": 0,
"radius_z": 0,
"chance": 1,
"chance": 100,
"size": 0,
"check_passable": false,
"check_sees": false,
Expand Down Expand Up @@ -89,7 +89,7 @@
{
"id": "PLASMA",
"type": "ammo_effect",
"aoe": { "field_type": "fd_plasma", "intensity_min": 2, "intensity_max": 3, "chance": 2 },
"aoe": { "field_type": "fd_plasma", "intensity_min": 2, "intensity_max": 3, "chance": 50 },
"trail": { "field_type": "fd_plasma", "intensity_min": 1, "intensity_max": 2, "chance": 50 }
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/ammo_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ void ammo_effect::check() const
if( aoe_size < 0 ) {
debugmsg( "Value of aoe_size cannot be negative" );
}
if( aoe_chance < 0 ) {
debugmsg( "Field chance divisor cannot be negative" );
if( aoe_chance > 100 || aoe_chance <= 0 ) {
debugmsg( "Field chance of %s out of range (%d of min 1 max 100)", id.c_str(), aoe_chance );
}
if( aoe_radius_z < 0 || aoe_radius < 0 ) {
debugmsg( "Radius values cannot be negative" );
Expand Down
2 changes: 1 addition & 1 deletion src/ammo_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ammo_effect {
int aoe_intensity_max = 0;
int aoe_radius = 1;
int aoe_radius_z = 0;
int aoe_chance = 1;
int aoe_chance = 100;
int aoe_size = 0;
explosion_data aoe_explosion_data;
bool aoe_check_passable = false;
Expand Down
2 changes: 1 addition & 1 deletion src/projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void apply_ammo_effects( const tripoint &p, const std::set<std::string> &effects
for( const ammo_effect &ae : ammo_effects::get_all() ) {
if( effects.count( ae.id.str() ) > 0 ) {
for( auto &pt : g->m.points_in_radius( p, ae.aoe_radius, ae.aoe_radius_z ) ) {
if( one_in( ae.aoe_chance ) ) {
if( x_in_y( ae.aoe_chance, 100 ) ) {
const bool check_sees = !ae.aoe_check_sees || g->m.sees( p, pt, ae.aoe_check_sees_radius );
const bool check_passable = !ae.aoe_check_passable || g->m.passable( pt );
if( check_sees && check_passable ) {
Expand Down

0 comments on commit ffc3ce3

Please sign in to comment.