Skip to content

Commit

Permalink
Merge pull request #4717 from MistakeNot4892/rework/fantasy_submaps
Browse files Browse the repository at this point in the history
Moving Shaded Hills level data and submap logic into fantasy modpack.
  • Loading branch information
out-of-phaze authored Jan 18, 2025
2 parents 8c0219b + d66dbb7 commit df41986
Show file tree
Hide file tree
Showing 39 changed files with 309 additions and 265 deletions.
8 changes: 8 additions & 0 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ var/global/list/areas = list()
area_blurb_category = type
..()

/area/proc/get_additional_fishing_results()
return

/area/Initialize()
var/list/additional_fishing_results = get_additional_fishing_results()
if(LAZYLEN(additional_fishing_results))
LAZYINITLIST(fishing_results)
for(var/fish in additional_fishing_results)
fishing_results[fish] = additional_fishing_results[fish]
. = ..()
global.areas += src
if(!requires_power || !apc)
Expand Down
43 changes: 38 additions & 5 deletions code/modules/multiz/level_data.dm
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@
// Whether or not this level permits things like graffiti and filth to persist across rounds.
var/permit_persistence = FALSE

// Submap loading values, passed back via getters like get_subtemplate_budget().
/// A point budget to spend on subtemplates (see template costs)
var/subtemplate_budget = 0
/// A string identifier for the category of subtemplates to draw from for this level.
var/subtemplate_category = null
/// A specific area to use when determining where to place subtemplates.
var/subtemplate_area = null

/datum/level_data/New(var/_z_level, var/defer_level_setup = FALSE)
. = ..()
level_z = _z_level
Expand Down Expand Up @@ -418,16 +426,22 @@
//
/// Helper proc for subtemplate generation. Returns a point budget to spend on subtemplates.
/datum/level_data/proc/get_subtemplate_budget()
return 0
return subtemplate_budget
/// Helper proc for subtemplate generation. Returns a string identifier for a general category of template.
/datum/level_data/proc/get_subtemplate_category()
return
return subtemplate_category
/// Helper proc for subtemplate generation. Returns a bitflag of template flags that must not be present for a subtemplate to be considered available.
/datum/level_data/proc/get_subtemplate_blacklist()
return
/// Helper proc for subtemplate generation. Returns a bitflag of template flags that must be present for a subtemplate to be considered available.
/datum/level_data/proc/get_subtemplate_whitelist()
return
/// Helper proc for getting areas associated with placable submaps on this level.
/datum/level_data/proc/get_subtemplate_areas(template_category, blacklist, whitelist)
if(subtemplate_area)
return islist(subtemplate_area) ? subtemplate_area : list(subtemplate_area)
if(base_area)
return list(base_area)

///Called when setting up the level. Apply generators and anything that modifies the turfs of the level.
/datum/level_data/proc/generate_level()
Expand Down Expand Up @@ -461,12 +475,34 @@
for(var/gen_type in map_gen)
new gen_type(origx, origy, level_z, endx, endy, FALSE, TRUE, get_base_area_instance())

/// Helper proc for placing mobs on a level after level creation.
/datum/level_data/proc/get_mobs_to_populate_level()
return

///Called during level setup. Run anything that should happen only after the map is fully generated.
/datum/level_data/proc/after_generate_level()

build_border()

if(daycycle_id && daycycle_type)
SSdaycycle.register_level(level_z, daycycle_id, daycycle_type)

var/list/mobs_to_spawn = get_mobs_to_populate_level()
if(length(mobs_to_spawn))
for(var/list/mob_category in mobs_to_spawn)
var/list/mob_types = mob_category[1]
var/mob_turf = mob_category[2]
var/mob_count = mob_category[3]
var/sanity = 1000
while(mob_count && sanity)
sanity--
var/turf/place_mob_at = locate(rand(level_inner_min_x, level_inner_max_x), rand(level_inner_min_y, level_inner_max_y), level_z)
if(istype(place_mob_at, mob_turf) && !(locate(/mob/living) in place_mob_at))
var/mob_type = pickweight(mob_types)
new mob_type(place_mob_at)
mob_count--
CHECK_TICK

///Changes anything named we may need to rename accordingly to the parent location name. For instance, exoplanets levels.
/datum/level_data/proc/adapt_location_name(var/location_name)
SHOULD_CALL_PARENT(TRUE)
Expand Down Expand Up @@ -742,9 +778,6 @@ INITIALIZE_IMMEDIATE(/obj/abstract/level_data_spawner)
/datum/random_map/noise/ore
)

/datum/level_data/proc/get_subtemplate_areas(template_category, blacklist, whitelist)
return list(base_area)

///Try to allocate the given amount of POIs onto our level. Returns the template types that were spawned
/datum/level_data/proc/spawn_subtemplates(budget = 0, template_category, blacklist, whitelist)

Expand Down
7 changes: 0 additions & 7 deletions maps/shaded_hills/areas/_areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
)
sound_env = GENERIC
ambience = list()
var/list/additional_fishing_results

/area/shaded_hills/Initialize()
if(additional_fishing_results)
for(var/fish in additional_fishing_results)
fishing_results[fish] = additional_fishing_results[fish]
. = ..()

/area/shaded_hills/outside
name = "\improper Grasslands"
Expand Down
5 changes: 4 additions & 1 deletion maps/shaded_hills/areas/grassland.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@
color = COLOR_BLUE
description = "The soft susurration of running water mingles with the hum of insects and croak of frogs."
area_blurb_category = /area/shaded_hills/outside/river
additional_fishing_results = list(

/area/shaded_hills/outside/river/get_additional_fishing_results()
var/static/list/additional_fishing_results = list(
/mob/living/simple_animal/aquatic/fish/large = 5,
/mob/living/simple_animal/aquatic/fish/large/salmon = 5,
/mob/living/simple_animal/aquatic/fish/large/trout = 5,
/mob/living/simple_animal/aquatic/fish/large/pike = 3
)
return additional_fishing_results

/area/shaded_hills/caves
name = "\improper Deep Tunnels"
Expand Down
15 changes: 9 additions & 6 deletions maps/shaded_hills/areas/woods.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

/area/shaded_hills/outside/river/lake
name = "Woodland Lake"
additional_fishing_results = list(
/mob/living/simple_animal/aquatic/fish/large/bass = 5,
/mob/living/simple_animal/aquatic/fish/large/trout = 5,
/mob/living/simple_animal/aquatic/fish/large/javelin = 5,
/mob/living/simple_animal/hostile/aquatic/carp = 3,
/mob/living/simple_animal/aquatic/fish/large/koi = 1

/area/shaded_hills/outside/river/lake/get_additional_fishing_results()
var/static/list/additional_fishing_results = list(
/mob/living/simple_animal/aquatic/fish/large/bass = 5,
/mob/living/simple_animal/aquatic/fish/large/trout = 5,
/mob/living/simple_animal/aquatic/fish/large/javelin = 5,
/mob/living/simple_animal/hostile/aquatic/carp = 3,
/mob/living/simple_animal/aquatic/fish/large/koi = 1
)
return additional_fishing_results

/area/shaded_hills/outside/woods
name = "Woodlands"
Expand Down
79 changes: 27 additions & 52 deletions maps/shaded_hills/levels/_levels.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
daycycle_type = /datum/daycycle/shaded_hills
daycycle_id = "daycycle_shaded_hills"
template_edge_padding = 0 // we use a strictly delineated subarea, no need for this guard
var/submap_budget = 0
var/submap_category = null
var/submap_area
var/list/mobs_to_spawn = list()

/datum/daycycle/shaded_hills
cycle_duration = 2 HOURS // 1 hour of daylight, 1 hour of night
Expand All @@ -29,32 +25,6 @@
time_in_cycle = rand(cycle_duration)
..()

/datum/level_data/main_level/shaded_hills/get_subtemplate_areas(template_category, blacklist, whitelist)
return submap_area ? (islist(submap_area) ? submap_area : list(submap_area)) : null

/datum/level_data/main_level/shaded_hills/get_subtemplate_budget()
return submap_budget

/datum/level_data/main_level/shaded_hills/get_subtemplate_category()
return submap_category

/datum/level_data/main_level/shaded_hills/after_generate_level()
. = ..()
if(length(mobs_to_spawn))
for(var/list/mob_category in mobs_to_spawn)
var/list/mob_types = mob_category[1]
var/mob_turf = mob_category[2]
var/mob_count = mob_category[3]
var/sanity = 1000
while(mob_count && sanity)
sanity--
var/turf/place_mob_at = locate(rand(level_inner_min_x, level_inner_max_x), rand(level_inner_min_y, level_inner_max_y), level_z)
if(istype(place_mob_at, mob_turf) && !(locate(/mob/living) in place_mob_at))
var/mob_type = pickweight(mob_types)
new mob_type(place_mob_at)
mob_count--
CHECK_TICK

/datum/level_data/main_level/shaded_hills/grassland
name = "Shaded Hills - Grassland"
level_id = "shaded_hills_grassland"
Expand All @@ -68,11 +38,12 @@
"shaded_hills_swamp" = SOUTH,
"shaded_hills_downlands" = EAST
)
submap_budget = 5
submap_category = MAP_TEMPLATE_CATEGORY_SH_GRASSLAND
submap_area = /area/shaded_hills/outside/poi
subtemplate_budget = 5
subtemplate_category = MAP_TEMPLATE_CATEGORY_FANTASY_GRASSLAND
subtemplate_area = /area/shaded_hills/outside/poi

mobs_to_spawn = list(
/datum/level_data/main_level/shaded_hills/grassland/get_mobs_to_populate_level()
var/static/list/mobs_to_spawn = list(
list(
list(
/mob/living/simple_animal/passive/mouse = 9,
Expand All @@ -85,7 +56,7 @@
10
)
)

return mobs_to_spawn

/datum/level_data/main_level/shaded_hills/swamp
name = "Shaded Hills - Swamp"
Expand All @@ -97,11 +68,12 @@
/datum/random_map/noise/shaded_hills/swamp,
/datum/random_map/noise/forage/shaded_hills/swamp
)
submap_budget = 5
submap_category = MAP_TEMPLATE_CATEGORY_SH_SWAMP
submap_area = /area/shaded_hills/outside/swamp/poi
subtemplate_budget = 5
subtemplate_category = MAP_TEMPLATE_CATEGORY_FANTASY_SWAMP
subtemplate_area = /area/shaded_hills/outside/swamp/poi

mobs_to_spawn = list(
/datum/level_data/main_level/shaded_hills/swamp/get_mobs_to_populate_level()
var/static/list/mobs_to_spawn = list(
list(
list(
/mob/living/simple_animal/passive/mouse = 6,
Expand All @@ -127,6 +99,7 @@
10
)
)
return mobs_to_spawn

/datum/level_data/main_level/shaded_hills/woods
name = "Shaded Hills - Woods"
Expand All @@ -138,11 +111,12 @@
/datum/random_map/noise/shaded_hills/woods,
/datum/random_map/noise/forage/shaded_hills/woods
)
submap_budget = 5
submap_category = MAP_TEMPLATE_CATEGORY_SH_WOODS
submap_area = /area/shaded_hills/outside/woods/poi
subtemplate_budget = 5
subtemplate_category = MAP_TEMPLATE_CATEGORY_FANTASY_WOODS
subtemplate_area = /area/shaded_hills/outside/woods/poi

mobs_to_spawn = list(
/datum/level_data/main_level/shaded_hills/woods/get_mobs_to_populate_level()
var/static/list/mobs_to_spawn = list(
list(
list(
/mob/living/simple_animal/passive/mouse = 6,
Expand All @@ -162,6 +136,7 @@
5
)
)
return mobs_to_spawn

/datum/level_data/main_level/shaded_hills/downlands
name = "Shaded Hills - Downlands"
Expand All @@ -173,19 +148,19 @@
connected_levels = list(
"shaded_hills_grassland" = WEST
)
submap_budget = 5
submap_category = MAP_TEMPLATE_CATEGORY_SH_DOWNLANDS
submap_area = /area/shaded_hills/outside/downlands/poi
subtemplate_budget = 5
subtemplate_category = MAP_TEMPLATE_CATEGORY_FANTASY_DOWNLANDS
subtemplate_area = /area/shaded_hills/outside/downlands/poi

/datum/level_data/main_level/shaded_hills/caverns
name = "Shaded Hills - Caverns"
level_id = "shaded_hills_caverns"
connected_levels = list(
"shaded_hills_dungeon" = EAST
)
submap_budget = 5
submap_category = MAP_TEMPLATE_CATEGORY_SH_CAVERNS
submap_area = /area/shaded_hills/caves/deep/poi
subtemplate_budget = 5
subtemplate_category = MAP_TEMPLATE_CATEGORY_FANTASY_CAVERNS
subtemplate_area = /area/shaded_hills/caves/deep/poi
level_generators = list(
/datum/random_map/automata/cave_system/shaded_hills,
/datum/random_map/noise/ore/rich
Expand All @@ -198,9 +173,9 @@
connected_levels = list(
"shaded_hills_caverns" = WEST
)
submap_budget = 5
submap_category = MAP_TEMPLATE_CATEGORY_SH_DUNGEON
submap_area = /area/shaded_hills/caves/dungeon/poi
subtemplate_budget = 5
subtemplate_category = MAP_TEMPLATE_CATEGORY_FANTASY_DUNGEON
subtemplate_area = /area/shaded_hills/caves/dungeon/poi
base_turf = /turf/floor/rock/basalt

/obj/abstract/level_data_spawner/shaded_hills_grassland
Expand Down
12 changes: 0 additions & 12 deletions maps/shaded_hills/shaded_hills.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@
#include "jobs/visitors.dm"
#include "jobs/wilderness.dm"

#include "submaps/_submaps.dm"
#include "submaps/downlands/_downlands.dm"
#include "submaps/grassland/_grassland.dm"
#include "submaps/swamp/_swamp.dm"
#include "submaps/woods/_woods.dm"
#include "submaps/woods/bear_den/bear_den.dm"
#include "submaps/woods/chemistry_shack/chemistry_shack.dm"
#include "submaps/woods/fairy_rings/fairy_rings.dm"
#include "submaps/woods/fox_den/fox_den.dm"
#include "submaps/woods/hunter_camp/hunter_camp.dm"
#include "submaps/woods/old_cabin/old_cabin.dm"

#include "levels/_levels.dm"
#include "levels/random_map.dm"
#include "levels/strata.dm"
Expand Down
23 changes: 0 additions & 23 deletions maps/shaded_hills/submaps/_submaps.dm

This file was deleted.

9 changes: 0 additions & 9 deletions maps/shaded_hills/submaps/downlands/_downlands.dm

This file was deleted.

9 changes: 0 additions & 9 deletions maps/shaded_hills/submaps/grassland/_grassland.dm

This file was deleted.

4 changes: 0 additions & 4 deletions maps/shaded_hills/submaps/swamp/_swamp.dm

This file was deleted.

4 changes: 0 additions & 4 deletions maps/shaded_hills/submaps/woods/_woods.dm

This file was deleted.

6 changes: 0 additions & 6 deletions maps/shaded_hills/submaps/woods/bear_den/bear_den.dm

This file was deleted.

Loading

0 comments on commit df41986

Please sign in to comment.