Skip to content

Commit

Permalink
Basic Implementation for vehicle damage world option
Browse files Browse the repository at this point in the history
This adds a new world option to modify vehicle damage. The purpose is to have a global value to alter initial vehicle health.
Vehicles may be more broken with a value > 1 than usual so players may need to scrounge up vehicle parts to get a working one.
In comparison the No Hope mod modifies most mapgen JSON files to create wrecks instead of vehicles.

No Hope does it by setting values for "number" such as [ 3, 4 ] inside vehicle_spawn.json
The problem of this solution is that whenver a new map is created that uses "place_vehicles" it would need to be modified. This is hard to maintain and changes to the maps need to be backported.

The multiplication inside this commit is only a very basic solution that may be changed at will. There were no considerations towards the distribution of non-damaged, damaged and broken components as well as the set_hp values inside the following function
  • Loading branch information
BeatAroundTheBuscher committed May 24, 2024
1 parent ba5ca3b commit e5d05f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2315,6 +2315,11 @@ void options_manager::add_options_world_default()
-1, 18, 6
);

add( "VEHICLE_DAMAGE", world_default, translate_marker( "Vehicle damage modifier" ),
translate_marker( "A scaling factor that determines how damaged vehicles are." ),
0.0, 10.0, 1, 0.1
);

add( "SPAWN_DENSITY", world_default, translate_marker( "Spawn rate scaling factor" ),
translate_marker( "A scaling factor that determines density of monster spawns." ),
0.0, 50.0, 1.0, 0.1
Expand Down
5 changes: 3 additions & 2 deletions src/vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,9 @@ void vehicle::init_state( int init_veh_fuel, int init_veh_status )
} else {
//a bit of initial damage :)
//clamp 4d8 to the range of [8,20]. 8=broken, 20=undamaged.
int broken = 8;
int unhurt = 20;
const float chance = get_option<float>( "VEHICLE_DAMAGE" ) ;
int broken = 8 * chance;
int unhurt = 20 * chance;
int roll = dice( 4, 8 );
if( roll < unhurt ) {
if( roll <= broken ) {
Expand Down

0 comments on commit e5d05f6

Please sign in to comment.