From afff48782c5411c330d1ce5b43060821896104d8 Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Wed, 5 Jun 2024 21:39:50 -0500 Subject: [PATCH 1/3] feat(balance): increase variety of potential damage states for spawned vehicles --- src/vehicle.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b5c52d6f5a91..13fbda6176b0 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -620,11 +620,15 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) } for( const vpart_reference &vp : get_parts_including_carried( "FRIDGE" ) ) { - vp.part().enabled = true; + if( one_in( 2 ) ) { + vp.part().enabled = true; + } } for( const vpart_reference &vp : get_parts_including_carried( "FREEZER" ) ) { - vp.part().enabled = true; + if( one_in( 2 ) ) { + vp.part().enabled = true; + } } for( const vpart_reference &vp : get_parts_including_carried( "WATER_PURIFIER" ) ) { @@ -637,8 +641,8 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) const size_t p = vp.part_index(); vehicle_part &pt = vp.part(); - if( vp.has_feature( VPFLAG_REACTOR ) ) { - // De-hardcoded reactors. Should always start active + if( vp.has_feature( VPFLAG_REACTOR ) && one_in( 4 ) ) { + // De-hardcoded reactors, may or may not start active pt.enabled = true; } @@ -733,6 +737,11 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) set_hp( pt, 0 ); } + // An added 5% chance to bust each windshield + if( vp.has_feature( "WINDSHIELD" ) && one_in( 20 ) ) { + set_hp( pt, 0 ); + } + /* Bloodsplatter the front-end parts. Assume anything with x > 0 is * the "front" of the vehicle (since the driver's seat is at (0, 0). * We'll be generous with the blood, since some may disappear before @@ -761,6 +770,11 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) blood_inside_pos.emplace( vp.mount() ); } } + + // Potentially bust a single tire if not already wrecking them + if( !destroyTires && !wheelcache.empty() && one_in( 20 ) ) { + set_hp( parts[random_entry( wheelcache )], 0 ); + } } //sets the vehicle to locked, if there is no key and an alarm part exists if( vp.has_feature( "SECURITY" ) && has_no_key && pt.is_available() ) { @@ -772,11 +786,11 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) } } } - // destroy tires until the vehicle is not drivable + // destroy a random number of tires, vehicles with more wheels are more likely to survive if( destroyTires && !wheelcache.empty() ) { int tries = 0; - while( valid_wheel_config() && tries < 100 ) { - // wheel config is still valid, destroy the tire. + while( valid_wheel_config() && tries < wheelcache.size() ) { + // keep going until either we've ruined all wheels or made one attempt for every wheel set_hp( parts[random_entry( wheelcache )], 0 ); tries++; } From 968b4bb7a71749c91eee09e47bd3fd78ecba43ce Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Wed, 5 Jun 2024 21:56:45 -0500 Subject: [PATCH 2/3] Update vehicle.cpp --- src/vehicle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 13fbda6176b0..6d33aad563a5 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -789,7 +789,8 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status ) // destroy a random number of tires, vehicles with more wheels are more likely to survive if( destroyTires && !wheelcache.empty() ) { int tries = 0; - while( valid_wheel_config() && tries < wheelcache.size() ) { + int maxtries = wheelcache.size(); + while( valid_wheel_config() && tries < maxtries ) { // keep going until either we've ruined all wheels or made one attempt for every wheel set_hp( parts[random_entry( wheelcache )], 0 ); tries++; From 5420273ab0c1e402b9aa6c995bea71f25cbe0033 Mon Sep 17 00:00:00 2001 From: Chaosvolt Date: Wed, 5 Jun 2024 22:16:35 -0500 Subject: [PATCH 3/3] Update vehicle_power_test.cpp --- tests/vehicle_power_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/vehicle_power_test.cpp b/tests/vehicle_power_test.cpp index dab7fdd026f4..4a2918d8c231 100644 --- a/tests/vehicle_power_test.cpp +++ b/tests/vehicle_power_test.cpp @@ -37,6 +37,7 @@ TEST_CASE( "vehicle power with reactor and solar panels", "[vehicle][power]" ) REQUIRE( !veh_ptr->reactors.empty() ); vehicle_part &reactor = veh_ptr->part( veh_ptr->reactors.front() ); + reactor.enabled = true; GIVEN( "the reactor is empty" ) { reactor.ammo_unset();