mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
## About The Pull Request Fixes https://github.com/tgstation/tgstation/issues/90641 Fixes https://github.com/tgstation/tgstation/issues/88366 Eliminates worries over virtualspace currency being sent to real accounts. When I was looking into why there were no flags for bitrunning areas. Then I saw this mess: <img width="929" height="889" alt="Code_2we2QjDyFp" src="https://github.com/user-attachments/assets/8a807bfe-b566-4057-a8ea-2b306325687d" /> Not having enough space / being too lazy to refactor this is a silly reason to not include flags for something like these virtual areas where it can be quite helpful. Fortunately I am not too lazy ~~in this moment~~ so here we go: It was fairly logical to move over some of these to a separate flag, which I've called `area_flags_mapping` since they pertain to maploading things and terrain generation mostly. `area_flags` stays reserved for general properties and now has more room than it did before for you people to fill it with. In doing this it's also neatened up the code quit a bit, as UNIQUE_AREA was kind of everywhere and now that it's implied by default less areas need to have it defined (or explicitly un-defined). <details> <summary> Working as intended </summary> <img width="787" height="448" alt="dreamseeker_p0Qts36tG1" src="https://github.com/user-attachments/assets/25056f34-8d43-4be2-a293-e53df7a7d1db" /> <img width="383" height="59" alt="dreamseeker_Ek7TXCcpbA" src="https://github.com/user-attachments/assets/89622974-9467-4cdb-8345-d684f7c9004b" /> </details> ## Why It's Good For The Game Fixes an exploit, improves the area flags situation slightly. ## Changelog 🆑 fix: you can no longer send money from virtualspace to a real account code: adds a flag for virtual areas so they can easily be checked, as well as an easy helper proc, 'is_area_virtual(your_area)' /🆑
232 lines
7.6 KiB
Plaintext
232 lines
7.6 KiB
Plaintext
///This datum handles the transitioning from a turf to a specific biome, and handles spawning decorative structures and mobs.
|
|
/datum/biome
|
|
///Type of turf this biome creates
|
|
var/turf_type
|
|
/// Chance of having a structure from the flora types list spawn
|
|
var/flora_density = 0
|
|
/// Chance of spawning special features, such as geysers.
|
|
var/feature_density = 0
|
|
/// Chance of having a mob from the fauna types list spawn
|
|
var/fauna_density = 0
|
|
/// Weighted list of type paths of flora that can be spawned when the
|
|
/// turf spawns flora.
|
|
var/list/flora_types = list()
|
|
/// Weighted list of extra features that can spawn in the biome, such as
|
|
/// geysers. Gets expanded automatically.
|
|
var/list/feature_types = list()
|
|
/// Weighted list of type paths of fauna that can be spawned when the
|
|
/// turf spawns fauna.
|
|
var/list/fauna_types = list()
|
|
|
|
|
|
/datum/biome/New()
|
|
. = ..()
|
|
if(length(flora_types))
|
|
flora_types = expand_weights(fill_with_ones(flora_types))
|
|
|
|
if(length(fauna_types))
|
|
fauna_types = expand_weights(fill_with_ones(fauna_types))
|
|
|
|
if(length(feature_types))
|
|
feature_types = expand_weights(feature_types)
|
|
|
|
|
|
///This proc handles the creation of a turf of a specific biome type
|
|
/datum/biome/proc/generate_turf(turf/gen_turf)
|
|
gen_turf.ChangeTurf(turf_type, null, CHANGETURF_DEFER_CHANGE)
|
|
if(length(flora_types) && prob(flora_density))
|
|
var/obj/structure/flora = pick(flora_types)
|
|
new flora(gen_turf)
|
|
return
|
|
|
|
if(length(feature_types) && prob(feature_density))
|
|
var/atom/picked_feature = pick(feature_types)
|
|
new picked_feature(gen_turf)
|
|
return
|
|
|
|
if(length(fauna_types) && prob(fauna_density))
|
|
var/mob/fauna = pick(fauna_types)
|
|
new fauna(gen_turf)
|
|
|
|
|
|
/// This proc handles the creation of a turf of a specific biome type, assuming
|
|
/// that the turf has not been initialized yet. Don't call this unless you know
|
|
/// what you're doing.
|
|
/datum/biome/proc/generate_turf_for_terrain(turf/gen_turf)
|
|
var/turf/new_turf = new turf_type(gen_turf)
|
|
return new_turf
|
|
|
|
|
|
/**
|
|
* This proc handles the sequential creation of turfs of a specific biome type
|
|
* in order to optimize the generation for large amount of turfs.
|
|
*
|
|
* Arguments:
|
|
* * gen_turfs - List of turfs to use for turf generation.
|
|
*
|
|
* Returns a new list of turfs that were generated by the biome.
|
|
*/
|
|
/datum/biome/proc/generate_turfs_for_terrain(list/turf/gen_turfs)
|
|
var/list/turf/new_turfs = list()
|
|
|
|
for(var/turf/gen_turf as anything in gen_turfs)
|
|
var/turf/new_turf = new turf_type(gen_turf)
|
|
new_turfs += new_turf
|
|
|
|
if(gen_turf.turf_flags & NO_RUINS)
|
|
new_turf.turf_flags |= NO_RUINS
|
|
|
|
CHECK_TICK
|
|
|
|
return new_turfs
|
|
|
|
|
|
/// This proc handles populating the given turf based on whether flora,
|
|
/// features and fauna are allowed. Does not take megafauna into account.
|
|
/datum/biome/proc/populate_turf(turf/target_turf, flora_allowed, features_allowed, fauna_allowed)
|
|
if(flora_allowed && length(flora_types) && prob(flora_density))
|
|
var/obj/structure/flora = pick(flora_types)
|
|
new flora(target_turf)
|
|
return TRUE
|
|
|
|
if(features_allowed && prob(feature_density))
|
|
var/can_spawn = TRUE
|
|
|
|
var/atom/picked_feature = pick(feature_types)
|
|
|
|
for(var/obj/structure/existing_feature in range(7, target_turf))
|
|
if(istype(existing_feature, picked_feature))
|
|
can_spawn = FALSE
|
|
break
|
|
|
|
if(can_spawn)
|
|
new picked_feature(target_turf)
|
|
return TRUE
|
|
|
|
if(fauna_allowed && length(fauna_types) && prob(fauna_density))
|
|
var/mob/picked_mob = pick(fauna_types)
|
|
|
|
// prevents tendrils spawning in each other's collapse range
|
|
if(ispath(picked_mob, /obj/structure/spawner/lavaland))
|
|
for(var/obj/structure/spawner/lavaland/spawn_blocker in range(2, target_turf))
|
|
return FALSE
|
|
|
|
// if the random is not a tendril (hopefully meaning it is a mob), avoid spawning if there's another one within 12 tiles
|
|
else
|
|
var/list/things_in_range = range(12, target_turf)
|
|
for(var/mob/living/mob_blocker in things_in_range)
|
|
if(ismining(mob_blocker))
|
|
return FALSE
|
|
|
|
new picked_mob(target_turf)
|
|
return TRUE
|
|
|
|
return FALSE
|
|
|
|
|
|
/**
|
|
* This proc handles populating the given turfs based on whether flora, features
|
|
* and fauna are allowed. Does not take megafauna into account.
|
|
*
|
|
* Does nothing if `flora_allowed`, `features_allowed` and `fauna_allowed` are
|
|
* `FALSE`, or if there's no flora, feature or fauna types for the matching
|
|
* allowed type. Aka, we return early if the proc wouldn't do anything anyway.
|
|
*/
|
|
/datum/biome/proc/populate_turfs(list/turf/target_turfs, flora_allowed, features_allowed, fauna_allowed)
|
|
if(!(flora_allowed && length(flora_types)) && !(features_allowed && length(feature_types)) && !(fauna_allowed && length(fauna_types)))
|
|
return
|
|
|
|
for(var/turf/target_turf as anything in target_turfs)
|
|
// We do the CHECK_TICK here because there's a bunch of continue calls
|
|
// in this.
|
|
CHECK_TICK
|
|
|
|
if(flora_allowed && length(flora_types) && prob(flora_density))
|
|
var/obj/structure/flora = pick(flora_types)
|
|
new flora(target_turf)
|
|
continue
|
|
|
|
if(features_allowed && prob(feature_density))
|
|
var/can_spawn = TRUE
|
|
|
|
var/atom/picked_feature = pick(feature_types)
|
|
|
|
for(var/obj/structure/existing_feature in range(7, target_turf))
|
|
if(istype(existing_feature, picked_feature))
|
|
can_spawn = FALSE
|
|
break
|
|
|
|
if(can_spawn)
|
|
new picked_feature(target_turf)
|
|
continue
|
|
|
|
if(fauna_allowed && length(fauna_types) && prob(fauna_density))
|
|
var/mob/picked_mob = pick(fauna_types)
|
|
|
|
// prevents tendrils spawning in each other's collapse range
|
|
if(ispath(picked_mob, /obj/structure/spawner/lavaland))
|
|
for(var/obj/structure/spawner/lavaland/spawn_blocker in range(2, target_turf))
|
|
continue
|
|
|
|
// if the random is not a tendril (hopefully meaning it is a mob), avoid spawning if there's another one within 12 tiles
|
|
else
|
|
var/list/things_in_range = range(12, target_turf)
|
|
for(var/mob/living/mob_blocker in things_in_range)
|
|
if(ismining(mob_blocker))
|
|
continue
|
|
|
|
new picked_mob(target_turf)
|
|
|
|
|
|
/datum/biome/mudlands
|
|
turf_type = /turf/open/misc/dirt/jungle/dark
|
|
flora_types = list(
|
|
/obj/structure/flora/grass/jungle/a/style_random = 1,
|
|
/obj/structure/flora/grass/jungle/b/style_random = 1,
|
|
/obj/structure/flora/rock/pile/jungle/style_random = 1,
|
|
/obj/structure/flora/rock/pile/jungle/large/style_random = 1,
|
|
)
|
|
flora_density = 3
|
|
|
|
/datum/biome/plains
|
|
turf_type = /turf/open/misc/grass/jungle
|
|
flora_types = list(
|
|
/obj/structure/flora/grass/jungle/a/style_random = 1,
|
|
/obj/structure/flora/grass/jungle/b/style_random = 1,
|
|
/obj/structure/flora/tree/jungle/style_random = 1,
|
|
/obj/structure/flora/rock/pile/jungle/style_random = 1,
|
|
/obj/structure/flora/bush/jungle/a/style_random = 1,
|
|
/obj/structure/flora/bush/jungle/b/style_random = 1,
|
|
/obj/structure/flora/bush/jungle/c/style_random = 1,
|
|
/obj/structure/flora/bush/large/style_random = 1,
|
|
/obj/structure/flora/rock/pile/jungle/large/style_random = 1,
|
|
)
|
|
flora_density = 15
|
|
|
|
/datum/biome/jungle
|
|
turf_type = /turf/open/misc/grass/jungle
|
|
flora_types = list(
|
|
/obj/structure/flora/grass/jungle/a/style_random = 1,
|
|
/obj/structure/flora/grass/jungle/b/style_random = 1,
|
|
/obj/structure/flora/tree/jungle/style_random = 1,
|
|
/obj/structure/flora/rock/pile/jungle/style_random = 1,
|
|
/obj/structure/flora/bush/jungle/a/style_random = 1,
|
|
/obj/structure/flora/bush/jungle/b/style_random = 1,
|
|
/obj/structure/flora/bush/jungle/c/style_random = 1,
|
|
/obj/structure/flora/bush/large/style_random = 1,
|
|
/obj/structure/flora/rock/pile/jungle/large/style_random = 1,
|
|
)
|
|
flora_density = 40
|
|
|
|
/datum/biome/jungle/deep
|
|
flora_density = 65
|
|
|
|
/datum/biome/wasteland
|
|
turf_type = /turf/open/misc/dirt/jungle/wasteland
|
|
|
|
/datum/biome/water
|
|
turf_type = /turf/open/water/jungle
|
|
|
|
/datum/biome/mountain
|
|
turf_type = /turf/closed/mineral/random/jungle
|