Skip to content

Commit

Permalink
Moving mob spawning for levels out of Shaded Hills onto main code.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 10, 2025
1 parent 831143a commit 777cff3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
22 changes: 22 additions & 0 deletions code/modules/multiz/level_data.dm
Original file line number Diff line number Diff line change
Expand Up @@ -475,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
31 changes: 9 additions & 22 deletions maps/shaded_hills/levels/_levels.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +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/list/mobs_to_spawn = list()

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

/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 @@ -60,7 +42,8 @@
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 @@ -73,7 +56,7 @@
10
)
)

return mobs_to_spawn

/datum/level_data/main_level/shaded_hills/swamp
name = "Shaded Hills - Swamp"
Expand All @@ -89,7 +72,8 @@
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 @@ -115,6 +99,7 @@
10
)
)
return mobs_to_spawn

/datum/level_data/main_level/shaded_hills/woods
name = "Shaded Hills - Woods"
Expand All @@ -130,7 +115,8 @@
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 @@ -150,6 +136,7 @@
5
)
)
return mobs_to_spawn

/datum/level_data/main_level/shaded_hills/downlands
name = "Shaded Hills - Downlands"
Expand Down
3 changes: 1 addition & 2 deletions maps/shaded_hills/shaded_hills_testing.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/datum/map/shaded_hills
apc_test_exempt_areas = list(
/area/space = NO_SCRUBBER|NO_VENT|NO_APC,
/area/shaded_hills = NO_SCRUBBER|NO_VENT|NO_APC,
/area/fantasy = NO_SCRUBBER|NO_VENT|NO_APC
/area/shaded_hills = NO_SCRUBBER|NO_VENT|NO_APC
)
4 changes: 4 additions & 0 deletions mods/content/fantasy/submaps/_submaps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
/datum/map_template/fantasy/get_template_cost()
return cost

/datum/map/New()
LAZYSET(apc_test_exempt_areas, /area/fantasy, NO_SCRUBBER|NO_VENT|NO_APC)
..()

/area/fantasy
abstract_type = /area/fantasy
allow_xenoarchaeology_finds = FALSE
Expand Down

0 comments on commit 777cff3

Please sign in to comment.