Files
Polaris/code/controllers/subsystems/xenoarch.dm
Neerti fdabe51ee8 Linter Introduction + Cleanup (#8085)
* Adds linter defines to repo.

* Uncomments linter defines already in the code.

* Resolves unreachable code linter errors.

* Nukes decade+ old syndie specops code except for computer since that's mapped in?????

* Resolves procs has no parent linter error.

* Proc signature fixes

* Bad comments

* "In" danger

* Type safety

* Implied nested list abuse

* Top level ..() usage

* Sleepy coder typos

* Invalid kwargs calls

* Pointless returns

* Linter hacks (see full message)

Byond doesn't care and it has no effect but linter doesn't like var/proc
for holding references to procs, despite that it's valid byond code.

Also, the linter seems to have serious issues figuring out relative
proc names. This commit is a sort of take-it-or-leave-it thing. It's not
required, it just cuts down on warnings, but this code is valid DM code.

* WHATEVER THIS IS

* Trick dreamchecker linter into ignoring this file's sins in it's weird use of vars

* Fix list decoration syntax - Its a list, not list of lists

- To declare that a var is a list you can `var/list/blah = list()` syntax or the `var/blah[0]` syntax.  Both do exactly the same thing. But if you do `var/list/blah[0]` that is just like doing `var/list/list/blah = list()`

* Hopefully stops the ai holder subtype folder from going quantum and sometimes changes capitalization over time, and incidentally causing 20+ linter errors.

* Fixes unwrapped negated object in list linter error.

* Resolves colon-like list accessing linter error.

* Turns linter on in linter config.

* Fixes closet indentation properly and cleans up suit storage unit switch.

Co-authored-by: Aronai Sieyes <arokha@arokha.com>
Co-authored-by: Leshana <Leshana@users.noreply.github.com>
2021-05-25 18:17:26 -09:00

120 lines
3.8 KiB
Plaintext

#define XENOARCH_SPAWN_CHANCE 0.5
#define DIGSITESIZE_LOWER 4
#define DIGSITESIZE_UPPER 12
#define ARTIFACTSPAWNNUM_LOWER 6
#define ARTIFACTSPAWNNUM_UPPER 12
//
// Xenoarch subsystem handles initialization of Xenoarcheaology artifacts and digsites.
//
SUBSYSTEM_DEF(xenoarch)
name = "Xenoarch"
init_order = INIT_ORDER_XENOARCH
flags = SS_NO_FIRE
var/list/artifact_spawning_turfs = list()
var/list/digsite_spawning_turfs = list()
/datum/controller/subsystem/xenoarch/Initialize(timeofday)
SetupXenoarch()
..()
/datum/controller/subsystem/xenoarch/Recover()
if (istype(SSxenoarch.artifact_spawning_turfs))
artifact_spawning_turfs = SSxenoarch.artifact_spawning_turfs
if (istype(SSxenoarch.digsite_spawning_turfs))
digsite_spawning_turfs = SSxenoarch.digsite_spawning_turfs
/datum/controller/subsystem/xenoarch/stat_entry(msg)
if (!Debug2)
return // Only show up in stat panel if debugging is enabled.
. = ..()
/datum/controller/subsystem/xenoarch/proc/SetupXenoarch()
for(var/turf/simulated/mineral/M in world)
if(!M.density || (M.z in using_map.xenoarch_exempt_levels))
continue
if(isnull(M.geologic_data))
M.geologic_data = new /datum/geosample(M)
if(!prob(XENOARCH_SPAWN_CHANCE))
continue
var/farEnough = 1
for(var/A in digsite_spawning_turfs)
var/turf/T = A
if(T in range(5, M))
farEnough = 0
break
if(!farEnough)
continue
digsite_spawning_turfs.Add(M)
var/digsite = get_random_digsite_type()
var/target_digsite_size = rand(DIGSITESIZE_LOWER, DIGSITESIZE_UPPER)
var/list/processed_turfs = list()
var/list/turfs_to_process = list(M)
var/list/viable_adjacent_turfs = list()
if(target_digsite_size > 1)
for(var/turf/simulated/mineral/T in orange(2, M))
if(!T.density)
continue
if(T.finds)
continue
if(T in processed_turfs)
continue
viable_adjacent_turfs.Add(T)
target_digsite_size = min(target_digsite_size, viable_adjacent_turfs.len)
for(var/i = 1 to target_digsite_size)
turfs_to_process += pick_n_take(viable_adjacent_turfs)
while(turfs_to_process.len)
var/turf/simulated/mineral/archeo_turf = pop(turfs_to_process)
processed_turfs.Add(archeo_turf)
if(isnull(archeo_turf.finds))
archeo_turf.finds = list()
if(prob(50))
archeo_turf.finds.Add(new /datum/find(digsite, rand(10, 190)))
else if(prob(75))
archeo_turf.finds.Add(new /datum/find(digsite, rand(10, 90)))
archeo_turf.finds.Add(new /datum/find(digsite, rand(110, 190)))
else
archeo_turf.finds.Add(new /datum/find(digsite, rand(10, 50)))
archeo_turf.finds.Add(new /datum/find(digsite, rand(60, 140)))
archeo_turf.finds.Add(new /datum/find(digsite, rand(150, 190)))
//sometimes a find will be close enough to the surface to show
var/datum/find/F = archeo_turf.finds[1]
if(F.excavation_required <= F.view_range)
archeo_turf.archaeo_overlay = "overlay_archaeo[rand(1,3)]"
archeo_turf.update_icon()
//have a chance for an artifact to spawn here, but not in animal or plant digsites
if(isnull(M.artifact_find) && digsite != DIGSITE_GARDEN && digsite != DIGSITE_ANIMAL)
artifact_spawning_turfs.Add(archeo_turf)
//Larger maps will convince byond this is an infinite loop, so let go for a second
CHECK_TICK
//create artifact machinery
var/num_artifacts_spawn = rand(ARTIFACTSPAWNNUM_LOWER, ARTIFACTSPAWNNUM_UPPER)
while(artifact_spawning_turfs.len > num_artifacts_spawn)
pick_n_take(artifact_spawning_turfs)
var/list/artifacts_spawnturf_temp = artifact_spawning_turfs.Copy()
while(artifacts_spawnturf_temp.len > 0)
var/turf/simulated/mineral/artifact_turf = pop(artifacts_spawnturf_temp)
artifact_turf.artifact_find = new()
#undef XENOARCH_SPAWN_CHANCE
#undef DIGSITESIZE_LOWER
#undef DIGSITESIZE_UPPER
#undef ARTIFACTSPAWNNUM_LOWER
#undef ARTIFACTSPAWNNUM_UPPER