From 9625eeffca835c1ed21f80627230d4bc27bdc8e0 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Sat, 18 Jan 2020 22:40:29 +0300 Subject: [PATCH] Use percent chance in ammo effects aoe instead of one_in chance --- data/json/ammo_effects.json | 4 ++-- src/ammo_effect.cpp | 4 ++-- src/ammo_effect.h | 2 +- src/projectile.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/json/ammo_effects.json b/data/json/ammo_effects.json index 6bc29a7ee0b92..d9e9017f9d062 100644 --- a/data/json/ammo_effects.json +++ b/data/json/ammo_effects.json @@ -8,7 +8,7 @@ "intensity_max": 0, "radius": 0, "radius_z": 0, - "chance": 1, + "chance": 100, "size": 0, "check_passable": false, "check_sees": false, @@ -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 } }, { "id": "EXPLOSIVE_HUGE", diff --git a/src/ammo_effect.cpp b/src/ammo_effect.cpp index edc8a5a74d244..38142e95fcf50 100644 --- a/src/ammo_effect.cpp +++ b/src/ammo_effect.cpp @@ -100,8 +100,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" ); diff --git a/src/ammo_effect.h b/src/ammo_effect.h index 50b13d53a096a..e13cb6fe0f6fd 100644 --- a/src/ammo_effect.h +++ b/src/ammo_effect.h @@ -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; diff --git a/src/projectile.cpp b/src/projectile.cpp index ba229a8862206..8bcbdb09532ce 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -95,7 +95,7 @@ void apply_ammo_effects( const tripoint &p, const std::set &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 ) {