Skip to content

Commit

Permalink
Unhardcode mx_dead_vegetation and mx_point_dead_vegetation
Browse files Browse the repository at this point in the history
  • Loading branch information
Procyonae committed Apr 14, 2024
1 parent e9f4fbd commit d247932
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 45 deletions.
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
43 changes: 0 additions & 43 deletions src/map_extras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,47 +1300,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 +2165,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

0 comments on commit d247932

Please sign in to comment.