Skip to content

Commit

Permalink
Ported over jsonify of spider pit from BN (CleverRaven#52184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Night-Pryanik authored Oct 22, 2021
1 parent 7f3c999 commit 8fe4894
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 120 deletions.
86 changes: 86 additions & 0 deletions data/json/mapgen/bugs/spider_pit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"type": "mapgen",
"method": "json",
"om_terrain": [ "spider_pit" ],
"weight": 250,
"object": {
"rows": [
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"............>...........",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................",
"........................"
],
"terrain": { ".": [ [ "t_region_groundcover_forest", 50 ], [ "t_region_shrub", 2 ], "t_region_tree" ], ">": "t_slope_down" },
"traps": { ".": [ [ "tr_null", 20 ], "tr_sinkhole" ] },
"items": { ".": { "item": "forest", "chance": 2 } },
"place_fields": [
{ "field": "fd_web", "x": [ 1, 22 ], "y": [ 1, 22 ], "repeat": 60 },
{ "field": "fd_web", "x": [ 8, 15 ], "y": [ 8, 15 ], "repeat": 60 }
],
"place_monsters": [ { "monster": "GROUP_SPIDER", "x": [ 1, 22 ], "y": [ 1, 22 ], "density": 0.5 } ]
}
},
{
"type": "mapgen",
"method": "json",
"om_terrain": [ "spider_pit_under" ],
"weight": 250,
"object": {
"rows": [
"########################",
"##????????????????????##",
"#??????????????????????#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??.........<........??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??..................??#",
"#??????????????????????#",
"##????????????????????##",
"########################"
],
"terrain": { "#": "t_rock", "?": [ [ "t_rock", 2 ], "t_rock_floor" ], ".": "t_rock_floor", "<": "t_slope_up" },
"furniture": { ".": [ [ "f_null", 20 ], "f_egg_sackws" ] },
"items": { ".": { "item": "spider", "chance": 2 } },
"place_fields": [
{ "field": "fd_web", "x": [ 3, 20 ], "y": [ 3, 20 ], "repeat": 60 },
{ "field": "fd_web", "x": [ 8, 15 ], "y": [ 8, 15 ], "repeat": 60 }
],
"place_monsters": [ { "monster": "GROUP_SPIDER", "x": [ 3, 20 ], "y": [ 3, 20 ], "density": 1 } ]
}
}
]
7 changes: 5 additions & 2 deletions data/json/overmap/overmap_special/specials.json
Original file line number Diff line number Diff line change
Expand Up @@ -1224,10 +1224,13 @@
{
"type": "overmap_special",
"id": "Spider Pit",
"overmaps": [ { "point": [ 0, 0, 0 ], "overmap": "spider_pit" }, { "point": [ 0, 0, -1 ], "overmap": "spider_pit_under" } ],
"overmaps": [
{ "point": [ 0, 0, 0 ], "overmap": "spider_pit_north" },
{ "point": [ 0, 0, -1 ], "overmap": "spider_pit_under_north" }
],
"locations": [ "forest" ],
"city_sizes": [ 0, 12 ],
"occurrences": [ 0, 100 ],
"occurrences": [ 33, 100 ],
"rotate": false,
"flags": [ "WILDERNESS", "UNIQUE" ]
},
Expand Down
18 changes: 18 additions & 0 deletions data/json/overmap/overmap_terrain/overmap_terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -822,5 +822,23 @@
"color": "white",
"flags": [ "NO_ROTATE" ],
"see_cost": 5
},
{
"type": "overmap_terrain",
"id": "spider_pit",
"name": "spider pit",
"sym": "S",
"color": "white",
"see_cost": 3,
"flags": [ "RISK_HIGH" ]
},
{
"type": "overmap_terrain",
"id": "spider_pit_under",
"name": "cavern",
"looks_like": "cave_underground",
"sym": "0",
"color": "light_gray",
"see_cost": 5
}
]
19 changes: 0 additions & 19 deletions data/json/overmap/overmap_terrain/overmap_terrain_hardcoded.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,25 +168,6 @@
"see_cost": 3,
"flags": [ "NO_ROTATE", "RISK_HIGH" ]
},
{
"type": "overmap_terrain",
"id": "spider_pit",
"name": "spider pit",
"sym": "S",
"color": "white",
"see_cost": 3,
"flags": [ "NO_ROTATE", "RISK_HIGH" ]
},
{
"type": "overmap_terrain",
"id": "spider_pit_under",
"name": "cavern",
"looks_like": "cave_underground",
"sym": "0",
"color": "light_gray",
"see_cost": 5,
"flags": [ "NO_ROTATE" ]
},
{
"type": "overmap_terrain",
"id": "slimepit",
Expand Down
1 change: 0 additions & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,6 @@ class map
void draw_mine( mapgendata &dat );
void draw_anthill( const mapgendata &dat );
void draw_slimepit( const mapgendata &dat );
void draw_spider_pit( const mapgendata &dat );
void draw_connections( const mapgendata &dat );

// Builds a transparency cache and returns true if the cache was invalidated.
Expand Down
25 changes: 0 additions & 25 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4034,8 +4034,6 @@ void map::draw_map( mapgendata &dat )
if( is_ot_match( "slimepit", terrain_type, ot_match_type::prefix ) ||
is_ot_match( "slime_pit", terrain_type, ot_match_type::prefix ) ) {
draw_slimepit( dat );
} else if( is_ot_match( "spider", terrain_type, ot_match_type::prefix ) ) {
draw_spider_pit( dat );
} else if( is_ot_match( "temple", terrain_type, ot_match_type::prefix ) ) {
draw_temple( dat );
} else if( is_ot_match( "mine", terrain_type, ot_match_type::prefix ) ) {
Expand Down Expand Up @@ -5567,29 +5565,6 @@ void map::draw_mine( mapgendata &dat )
}
}

void map::draw_spider_pit( const mapgendata &dat )
{
const oter_id &terrain_type = dat.terrain_type();
if( terrain_type == "spider_pit_under" ) {
for( int i = 0; i < SEEX * 2; i++ ) {
for( int j = 0; j < SEEY * 2; j++ ) {
if( ( i >= 3 && i <= SEEX * 2 - 4 && j >= 3 && j <= SEEY * 2 - 4 ) ||
one_in( 4 ) ) {
ter_set( point( i, j ), t_rock_floor );
if( !one_in( 3 ) ) {
add_field( {i, j, abs_sub.z}, fd_web, rng( 1, 3 ) );
}
} else {
ter_set( point( i, j ), t_rock );
}
}
}
ter_set( point( rng( 3, SEEX * 2 - 4 ), rng( 3, SEEY * 2 - 4 ) ), t_slope_up );
place_items( item_group_id( "spider" ), 85, point_zero, point( EAST_EDGE, SOUTH_EDGE ),
false, calendar::start_of_cataclysm );
}
}

void map::draw_slimepit( const mapgendata &dat )
{
const oter_id &terrain_type = dat.terrain_type();
Expand Down
71 changes: 0 additions & 71 deletions src/mapgen_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ building_gen_pointer get_mapgen_cfunction( const std::string &ident )
{ "forest_trail_tee", &mapgen_forest_trail_tee },
{ "forest_trail_four_way", &mapgen_forest_trail_four_way },
{ "hive", &mapgen_hive },
{ "spider_pit", &mapgen_spider_pit },
{ "road_straight", &mapgen_road },
{ "road_curved", &mapgen_road },
{ "road_end", &mapgen_road },
Expand All @@ -111,7 +110,6 @@ building_gen_pointer get_mapgen_cfunction( const std::string &ident )
{ "river_curved_not", &mapgen_river_curved_not },
{ "river_straight", &mapgen_river_straight },
{ "river_curved", &mapgen_river_curved },
{ "spider_pit", mapgen_spider_pit },
{ "cavern", &mapgen_cavern },
{ "open_air", &mapgen_open_air },
{ "rift", &mapgen_rift },
Expand Down Expand Up @@ -411,75 +409,6 @@ void mapgen_hive( mapgendata &dat )
}
}

void mapgen_spider_pit( mapgendata &dat )
{
map *const m = &dat.m;
// First generate a forest
dat.fill( 4 );
for( int i = 0; i < 4; i++ ) {
if( dat.t_nesw[i] == "forest" || dat.t_nesw[i] == "forest_water" ) {
dat.dir( i ) += 14;
} else if( dat.t_nesw[i] == "forest_thick" ) {
dat.dir( i ) += 18;
}
}
for( int i = 0; i < SEEX * 2; i++ ) {
for( int j = 0; j < SEEY * 2; j++ ) {
int forest_chance = 0;
int num = 0;
if( j < dat.n_fac ) {
forest_chance += dat.n_fac - j;
num++;
}
if( SEEX * 2 - 1 - i < dat.e_fac ) {
forest_chance += dat.e_fac - ( SEEX * 2 - 1 - i );
num++;
}
if( SEEY * 2 - 1 - j < dat.s_fac ) {
forest_chance += dat.s_fac - ( SEEX * 2 - 1 - j );
num++;
}
if( i < dat.w_fac ) {
forest_chance += dat.w_fac - i;
num++;
}
if( num > 0 ) {
forest_chance /= num;
}
int rn = rng( 0, forest_chance );
if( ( forest_chance > 0 && rn > 13 ) || one_in( 100 - forest_chance ) ) {
m->ter_set( point( i, j ), t_tree );
} else if( ( forest_chance > 0 && rn > 10 ) || one_in( 100 - forest_chance ) ) {
m->ter_set( point( i, j ), t_tree_young );
} else if( ( forest_chance > 0 && rn > 9 ) || one_in( 100 - forest_chance ) ) {
m->ter_set( point( i, j ), t_underbrush );
} else {
m->ter_set( point( i, j ), dat.groundcover() );
}
}
}
m->place_items( item_group_id( "forest" ), 60, point_zero,
point( SEEX * 2 - 1, SEEY * 2 - 1 ), true, dat.when() );
// Next, place webs and sinkholes
for( int i = 0; i < 4; i++ ) {
point p( rng( 3, SEEX * 2 - 4 ), rng( 3, SEEY * 2 - 4 ) );
if( i == 0 ) {
m->ter_set( p, t_slope_down );
} else {
m->ter_set( p, dat.groundcover() );
mtrap_set( m, p, tr_sinkhole );
}
for( int x1 = p.x - 3; x1 <= p.x + 3; x1++ ) {
for( int y1 = p.y - 3; y1 <= p.y + 3; y1++ ) {
madd_field( m, point( x1, y1 ), fd_web, rng( 2, 3 ) );
if( m->ter( point( x1, y1 ) ) != t_slope_down ) {
m->ter_set( point( x1, y1 ), t_dirt );
}
}
}
}
}

int terrain_type_to_nesw_array( oter_id terrain_type, bool array[4] )
{
// count and mark which directions the road goes
Expand Down
1 change: 0 additions & 1 deletion src/mapgen_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void mapgen_forest_trail_curved( mapgendata &dat );
void mapgen_forest_trail_tee( mapgendata &dat );
void mapgen_forest_trail_four_way( mapgendata &dat );
void mapgen_hive( mapgendata &dat );
void mapgen_spider_pit( mapgendata &dat );
void mapgen_river_center( mapgendata &dat );
void mapgen_road( mapgendata &dat );
//void mapgen_bridge( mapgendata &dat );
Expand Down
1 change: 0 additions & 1 deletion src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ bool oter_t::is_hardcoded() const
"office_tower_b_entrance",
"slimepit",
"slimepit_down",
"spider_pit_under",
"temple",
"temple_finale",
"temple_stairs"
Expand Down

0 comments on commit 8fe4894

Please sign in to comment.