@@ -210,6 +210,7 @@ static const ter_str_id ter_t_door_glass_frosted_c( "t_door_glass_frosted_c" );
210
210
static const ter_str_id ter_t_door_metal_c ( " t_door_metal_c" );
211
211
static const ter_str_id ter_t_door_metal_locked ( " t_door_metal_locked" );
212
212
static const ter_str_id ter_t_floor ( " t_floor" );
213
+ static const ter_str_id ter_t_floor_burnt ( " t_floor_burnt" );
213
214
static const ter_str_id ter_t_fungus_floor_in ( " t_fungus_floor_in" );
214
215
static const ter_str_id ter_t_fungus_wall ( " t_fungus_wall" );
215
216
static const ter_str_id ter_t_grass ( " t_grass" );
@@ -225,6 +226,7 @@ static const ter_str_id ter_t_strconc_floor( "t_strconc_floor" );
225
226
static const ter_str_id ter_t_thconc_floor ( " t_thconc_floor" );
226
227
static const ter_str_id ter_t_thconc_floor_olight ( " t_thconc_floor_olight" );
227
228
static const ter_str_id ter_t_vat ( " t_vat" );
229
+ static const ter_str_id ter_t_wall_burnt ( " t_wall_burnt" );
228
230
static const ter_str_id ter_t_water_sh ( " t_water_sh" );
229
231
230
232
static const trait_id trait_NPC_STATIC_NPC ( " NPC_STATIC_NPC" );
@@ -564,6 +566,66 @@ static void GENERATOR_add_fire( map &md,
564
566
565
567
}
566
568
569
+ static void GENERATOR_pre_burn ( map &md,
570
+ std::list<tripoint_bub_ms> &all_points_in_map,
571
+ int days_since_cataclysm )
572
+ {
573
+ // Later, this will be loaded from json.
574
+ generator_vars burnt_vars{};
575
+ // Fires are still raging around this time, but some start appearing
576
+ // Never appears before this date
577
+ burnt_vars.scaling_days_start = 3 ;
578
+
579
+ burnt_vars.scaling_days_end = 14 ; // Continues appearing at maximum appearance rate after this day
580
+ burnt_vars.num_attempts = 1 ; // Currently only applied to the whole map, so one pass.
581
+
582
+ burnt_vars.min_intensity = 6 ; // For this generator: % chance at start day
583
+ burnt_vars.max_intensity = 28 ; // For this generator: % chance at end day
584
+
585
+ // between start and end day we linearly interpolate.
586
+ double lerp_scalar = static_cast <double >( ( days_since_cataclysm - burnt_vars.scaling_days_start ) /
587
+ ( burnt_vars.scaling_days_end - burnt_vars.scaling_days_start ) );
588
+ burnt_vars.percent_chance = lerp ( burnt_vars.min_intensity , burnt_vars.max_intensity , lerp_scalar );
589
+ // static values outside that range. Note we do not use std::clamp because the chance is *0* until the start day is reached
590
+ if ( days_since_cataclysm < burnt_vars.scaling_days_start ) {
591
+ burnt_vars.percent_chance = 0 ;
592
+ } else if ( days_since_cataclysm >= burnt_vars.scaling_days_end ) {
593
+ burnt_vars.percent_chance = burnt_vars.max_intensity ;
594
+ }
595
+
596
+ for ( int i = 0 ; i < burnt_vars.num_attempts ; i++ ) {
597
+ if ( !x_in_y ( burnt_vars.percent_chance , 100 ) ) {
598
+ continue ; // failed roll
599
+ }
600
+ for ( tripoint_bub_ms current_tile : all_points_in_map ) {
601
+ if ( md.has_flag_ter ( ter_furn_flag::TFLAG_NATURAL_UNDERGROUND, current_tile ) ) {
602
+ continue ;
603
+ }
604
+ if ( md.has_flag_ter ( ter_furn_flag::TFLAG_DOOR, current_tile ) ) {
605
+ // Doorways get burned to smithereens. Put a floor there.
606
+ md.ter_set ( current_tile.xy (), ter_t_floor_burnt );
607
+ } else if ( md.has_flag_ter ( ter_furn_flag::TFLAG_WALL, current_tile ) ) {
608
+ // burnt wall
609
+ md.ter_set ( current_tile.xy (), ter_t_wall_burnt );
610
+ } else if ( md.has_flag_ter ( ter_furn_flag::TFLAG_INDOORS, current_tile ) ) {
611
+ // if we're indoors but we're not a wall, then we must be a floor.
612
+ md.ter_set ( current_tile.xy (), ter_t_floor_burnt );
613
+ } else if ( !md.has_flag_ter ( ter_furn_flag::TFLAG_INDOORS, current_tile ) ) {
614
+ // if we're outside on ground level, burn it to dirt.
615
+ if ( current_tile.z () == 0 ) {
616
+ md.ter_set ( current_tile.xy (), ter_t_dirt );
617
+ }
618
+ }
619
+
620
+ // destroy any furniture that is in the tile. it's been burned, after all.
621
+ md.furn_set ( current_tile.xy (), furn_str_id::NULL_ID () );
622
+
623
+ // destroy all items in the tile.
624
+ md.i_clear ( current_tile.xy () );
625
+ }
626
+ }
627
+ }
628
+
567
629
static void GENERATOR_riot_damage ( map &md, const tripoint_abs_omt &p )
568
630
{
569
631
std::list<tripoint_bub_ms> all_points_in_map;
@@ -584,6 +646,7 @@ static void GENERATOR_riot_damage( map &md, const tripoint_abs_omt &p )
584
646
GENERATOR_bash_damage ( md, all_points_in_map, days_since_cataclysm );
585
647
GENERATOR_move_items ( md, all_points_in_map, days_since_cataclysm );
586
648
GENERATOR_add_fire ( md, all_points_in_map, days_since_cataclysm );
649
+ GENERATOR_pre_burn ( md, all_points_in_map, days_since_cataclysm );
587
650
588
651
// NOTE: Below currently only runs for bloodstains.
589
652
for ( size_t i = 0 ; i < all_points_in_map.size (); i++ ) {
0 commit comments