Skip to content

Commit c90c11c

Browse files
committed
Pre-burnt generator
1 parent f99581d commit c90c11c

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

data/json/furniture_and_terrain/terrain-floors-indoor.json

+22
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,28 @@
16291629
"items": [ { "item": "clay_lump", "count": [ 6, 12 ] } ]
16301630
}
16311631
},
1632+
{
1633+
"type": "terrain",
1634+
"id": "t_floor_burnt",
1635+
"name": "burnt floor",
1636+
"description": "Whatever this floor used to be made of, it's little more than charred remains now.",
1637+
"symbol": ".",
1638+
"looks_like": "t_dirtfloor",
1639+
"color": "black",
1640+
"move_cost": 2,
1641+
"connect_groups": "INDOORFLOOR",
1642+
"flags": [ "TRANSPARENT", "COLLAPSES", "INDOORS" ],
1643+
"bash": {
1644+
"str_min": 1,
1645+
"str_max": 6,
1646+
"//COMMENT": "I don't know, charcoal breaking sounds? Onomatopoeia is outside my skillset!",
1647+
"sound": "crunch!",
1648+
"sound_fail": "twang!",
1649+
"sound_vol": 8,
1650+
"sound_fail_vol": 4,
1651+
"ter_set": "t_null"
1652+
}
1653+
},
16321654
{
16331655
"type": "terrain",
16341656
"id": "t_floor_paper",

data/json/furniture_and_terrain/terrain-walls.json

+23
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,29 @@
11731173
},
11741174
"shoot": { "chance_to_hit": 25, "reduce_damage": [ 20, 40 ], "reduce_damage_laser": [ 10, 30 ], "destroy_damage": [ 30, 100 ] }
11751175
},
1176+
{
1177+
"type": "terrain",
1178+
"id": "t_wall_burnt",
1179+
"name": "burnt wall",
1180+
"looks_like": "t_wall_wood_broken",
1181+
"description": "Whatever this wall used to be made of, it's little more than charred remains now.",
1182+
"symbol": "#",
1183+
"color": "black",
1184+
"move_cost": 0,
1185+
"coverage": 35,
1186+
"connect_groups": "WALL",
1187+
"connects_to": "WALL",
1188+
"flags": [ "TRANSPARENT", "NOITEM", "SUPPORTS_ROOF", "REDUCE_SCENT", "PERMEABLE" ],
1189+
"bash": {
1190+
"str_min": 4,
1191+
"str_max": 20,
1192+
"sound": "crash!",
1193+
"sound_fail": "whump!",
1194+
"ter_set": "t_null",
1195+
"items": [ { "item": "ash", "count": [ 200, 500 ] }, { "item": "scrap", "count": [ 2, 5 ] } ]
1196+
},
1197+
"shoot": { "chance_to_hit": 25, "reduce_damage": [ 5, 10 ], "reduce_damage_laser": [ 10, 30 ], "destroy_damage": [ 5, 20 ] }
1198+
},
11761199
{
11771200
"type": "terrain",
11781201
"id": "t_wall_log_half",

src/mapgen.cpp

+63
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ static const ter_str_id ter_t_door_glass_frosted_c( "t_door_glass_frosted_c" );
210210
static const ter_str_id ter_t_door_metal_c( "t_door_metal_c" );
211211
static const ter_str_id ter_t_door_metal_locked( "t_door_metal_locked" );
212212
static const ter_str_id ter_t_floor( "t_floor" );
213+
static const ter_str_id ter_t_floor_burnt( "t_floor_burnt" );
213214
static const ter_str_id ter_t_fungus_floor_in( "t_fungus_floor_in" );
214215
static const ter_str_id ter_t_fungus_wall( "t_fungus_wall" );
215216
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" );
225226
static const ter_str_id ter_t_thconc_floor( "t_thconc_floor" );
226227
static const ter_str_id ter_t_thconc_floor_olight( "t_thconc_floor_olight" );
227228
static const ter_str_id ter_t_vat( "t_vat" );
229+
static const ter_str_id ter_t_wall_burnt( "t_wall_burnt" );
228230
static const ter_str_id ter_t_water_sh( "t_water_sh" );
229231

230232
static const trait_id trait_NPC_STATIC_NPC( "NPC_STATIC_NPC" );
@@ -564,6 +566,66 @@ static void GENERATOR_add_fire( map &md,
564566

565567
}
566568

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+
567629
static void GENERATOR_riot_damage( map &md, const tripoint_abs_omt &p )
568630
{
569631
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 )
584646
GENERATOR_bash_damage( md, all_points_in_map, days_since_cataclysm );
585647
GENERATOR_move_items( md, all_points_in_map, days_since_cataclysm );
586648
GENERATOR_add_fire( md, all_points_in_map, days_since_cataclysm );
649+
GENERATOR_pre_burn( md, all_points_in_map, days_since_cataclysm );
587650

588651
// NOTE: Below currently only runs for bloodstains.
589652
for( size_t i = 0; i < all_points_in_map.size(); i++ ) {

0 commit comments

Comments
 (0)