Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhardcode dead vegetation extras #73022

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/json/itemgroups/trash_and_debris.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
[ "bag_body_bag", 1 ]
]
},
{
"type": "item_group",
"id": "dead_vegetation",
"items": [ { "item": "twig", "prob": 15, "count": [ 5, 20 ] }, [ "withered", 60 ], [ "stick_long", 15 ], [ "stick", 30 ] ]
},
{
"type": "item_group",
"id": "trash",
Expand Down
96 changes: 96 additions & 0 deletions data/json/mapgen/map_extras/dead_vegetation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[
{
"type": "mapgen",
"method": "json",
"update_mapgen_id": "mx_dead_vegetation",
"object": {
"place_nested": [
{ "chunks": [ "15x15_dead_vegetation" ], "x": [ 4, 5 ], "y": [ 4, 5 ] },
{ "chunks": [ "15x15_dead_vegetation" ], "x": [ 0, 4 ], "y": [ 0, 9 ] },
{ "chunks": [ "15x15_dead_vegetation" ], "x": [ 5, 9 ], "y": [ 0, 9 ] },
{ "chunks": [ "15x15_dead_vegetation" ], "x": [ 0, 9 ], "y": [ 0, 4 ] },
{ "chunks": [ "15x15_dead_vegetation" ], "x": [ 0, 9 ], "y": [ 5, 9 ] }
]
}
},
{
"type": "mapgen",
"method": "json",
"update_mapgen_id": "mx_point_dead_vegetation",
"object": { "place_nested": [ { "chunks": [ "15x15_dead_vegetation" ], "x": [ 0, 9 ], "y": [ 0, 9 ] } ] }
},
{
"type": "mapgen",
"method": "json",
"nested_mapgen_id": "15x15_dead_vegetation",
"object": {
"mapgensize": [ 15, 15 ],
"place_nested": [
{ "chunks": [ "7x7_dead_vegetation" ], "x": [ 0, 8 ], "y": [ 0, 8 ] },
{ "chunks": [ "7x7_dead_vegetation" ], "x": [ 0, 8 ], "y": [ 0, 8 ] },
{ "chunks": [ "7x7_dead_vegetation" ], "x": [ 0, 8 ], "y": [ 0, 8 ] }
]
}
},
{
"type": "mapgen",
"method": "json",
"nested_mapgen_id": "7x7_dead_vegetation",
"object": {
"mapgensize": [ 7, 7 ],
"rows": [
" xxx ",
" xXXXx ",
"xXXXXXx",
"xXXXXXx",
"xXXXXXx",
" xXXXx ",
" xxx "
],
"nested": { "X": { "chunks": [ "1x1_dead_vegetation" ] }, "x": { "chunks": [ "1x1_dead_vegetation", "null" ] } }
}
},
{
"type": "mapgen",
"method": "json",
"nested_mapgen_id": "1x1_dead_vegetation",
"object": {
"mapgensize": [ 1, 1 ],
"ter_furn_transforms": { " ": { "transform": "dead_vegetation" } },
"place_items": [ { "item": "dead_vegetation", "x": 0, "y": 0, "chance": 1 } ]
}
},
{
"type": "ter_furn_transform",
"id": "dead_vegetation",
"//": "Ideally place withered plant item somehow",
"furniture": [
{
"result": "f_null",
"valid_flags": [ "PLANT", "FLOWER", "ORGANIC" ],
"//": "Ideally place a withered plant, for now we just place items randomly"
}
],
"terrain": [
{
"result": "t_grass_dead",
"valid_terrain": [ "t_grass", "t_grass_long", "t_grass_tall", "t_grass_golf", "t_grass_white", "t_moss", "t_forestfloor" ]
},
{ "result": "t_tree_deadpine", "valid_terrain": [ "t_tree_pine" ] },
{ "result": "t_tree_birch_harvested", "valid_terrain": [ "t_tree_birch" ] },
{ "result": "t_tree_dead", "valid_terrain": [ "t_tree_willow" ] },
{ "result": "t_tree_hickory_dead", "valid_terrain": [ "t_tree_hickory", "t_tree_hickory_harvested" ] },
{
"result": "t_dirt",
"valid_flags": [ "SHRUB" ],
"//": "Ideally place sticks half the time, for now we just place items randomly"
},
{
"result": "t_dirt",
"valid_flags": [ "YOUNG" ],
"//": "Ideally place a long stick half the time, for now we just place items randomly"
},
{ "result": [ [ "t_tree_dead", 9 ], [ "t_trunk", 4 ], [ "t_stump", 3 ] ], "valid_flags": [ "TREE" ] }
]
}
]
4 changes: 2 additions & 2 deletions data/json/overmap/map_extras.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@
"type": "map_extra",
"name": { "str": "Dead Vegetation" },
"description": "Dead vegetation is here.",
"generator": { "generator_method": "map_extra_function", "generator_id": "mx_dead_vegetation" },
"generator": { "generator_method": "update_mapgen", "generator_id": "mx_dead_vegetation" },
"min_max_zlevel": [ 0, 0 ],
"sym": ".",
"color": "brown",
Expand All @@ -457,7 +457,7 @@
"type": "map_extra",
"name": { "str": "Dead Vegetation (Point)" },
"description": "Dead vegetation is here.",
"generator": { "generator_method": "map_extra_function", "generator_id": "mx_point_dead_vegetation" },
"generator": { "generator_method": "update_mapgen", "generator_id": "mx_point_dead_vegetation" },
"min_max_zlevel": [ 0, 0 ],
"sym": ".",
"color": "brown",
Expand Down
45 changes: 0 additions & 45 deletions src/map_extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ static const map_extra_id map_extra_mx_casings( "mx_casings" );
static const map_extra_id map_extra_mx_city_trap( "mx_city_trap" );
static const map_extra_id map_extra_mx_clay_deposit( "mx_clay_deposit" );
static const map_extra_id map_extra_mx_corpses( "mx_corpses" );
static const map_extra_id map_extra_mx_dead_vegetation( "mx_dead_vegetation" );
static const map_extra_id map_extra_mx_fungal_zone( "mx_fungal_zone" );
static const map_extra_id map_extra_mx_grove( "mx_grove" );
static const map_extra_id map_extra_mx_helicopter( "mx_helicopter" );
Expand All @@ -111,7 +110,6 @@ static const map_extra_id map_extra_mx_looters( "mx_looters" );
static const map_extra_id map_extra_mx_minefield( "mx_minefield" );
static const map_extra_id map_extra_mx_null( "mx_null" );
static const map_extra_id map_extra_mx_point_burned_ground( "mx_point_burned_ground" );
static const map_extra_id map_extra_mx_point_dead_vegetation( "mx_point_dead_vegetation" );
static const map_extra_id map_extra_mx_pond( "mx_pond" );
static const map_extra_id map_extra_mx_portal_in( "mx_portal_in" );
static const map_extra_id map_extra_mx_reed( "mx_reed" );
Expand Down Expand Up @@ -1300,47 +1298,6 @@ static bool mx_clay_deposit( map &m, const tripoint &abs_sub )
return false;
}

static bool mx_dead_vegetation( map &m, const tripoint &abs_sub )
{
// This map extra kills all plant life, creating area of desolation.
// Possible result of acid rain / radiation / etc.,
// but reason is not exposed (no rads, acid pools, etc.)

for( int i = 0; i < SEEX * 2; i++ ) {
for( int j = 0; j < SEEY * 2; j++ ) {
const tripoint loc( i, j, abs_sub.z );

dead_vegetation_parser( m, loc );
}
}

return true;
}

static bool mx_point_dead_vegetation( map &m, const tripoint &abs_sub )
{
// This map extra creates patch of dead vegetation using a simple cellular automaton.
// Lesser version of mx_dead_vegetation

constexpr int width = SEEX * 2;
constexpr int height = SEEY * 2;

// Generate the cells for dead vegetation.
std::vector<std::vector<int>> current = CellularAutomata::generate_cellular_automaton( width,
height, 55, 5, 4, 3 );

for( int i = 0; i < width; i++ ) {
for( int j = 0; j < height; j++ ) {
if( current[i][j] == 1 ) {
const tripoint loc( i, j, abs_sub.z );
dead_vegetation_parser( m, loc );
}
}
}

return true;
}

static void burned_ground_parser( map &m, const tripoint &loc )
{
const furn_t &fid = m.furn( loc ).obj();
Expand Down Expand Up @@ -2206,8 +2163,6 @@ static FunctionMap builtin_functions = {
{ map_extra_mx_shrubbery, mx_shrubbery },
{ map_extra_mx_pond, mx_pond },
{ map_extra_mx_clay_deposit, mx_clay_deposit },
{ map_extra_mx_dead_vegetation, mx_dead_vegetation },
{ map_extra_mx_point_dead_vegetation, mx_point_dead_vegetation },
{ map_extra_mx_burned_ground, mx_burned_ground },
{ map_extra_mx_point_burned_ground, mx_point_burned_ground },
{ map_extra_mx_casings, mx_casings },
Expand Down
Loading