diff --git a/baystation12.dme b/baystation12.dme
index bdbb2ffbcb1..6f0e4a2308b 100644
--- a/baystation12.dme
+++ b/baystation12.dme
@@ -7,229 +7,11 @@
// BEGIN_FILE_DIR
#define FILE_DIR .
#define FILE_DIR "code"
-#define FILE_DIR "code/ATMOSPHERICS"
-#define FILE_DIR "code/ATMOSPHERICS/components"
-#define FILE_DIR "code/ATMOSPHERICS/components/binary_devices"
-#define FILE_DIR "code/ATMOSPHERICS/components/trinary_devices"
-#define FILE_DIR "code/ATMOSPHERICS/components/unary"
-#define FILE_DIR "code/controllers"
-#define FILE_DIR "code/datums"
-#define FILE_DIR "code/datums/diseases"
-#define FILE_DIR "code/datums/helper_datums"
-#define FILE_DIR "code/datums/organs"
-#define FILE_DIR "code/datums/spells"
-#define FILE_DIR "code/defines"
-#define FILE_DIR "code/defines/obj"
-#define FILE_DIR "code/defines/obj/clothing"
-#define FILE_DIR "code/defines/procs"
-#define FILE_DIR "code/defines/sd_procs"
-#define FILE_DIR "code/FEA"
-#define FILE_DIR "code/game"
-#define FILE_DIR "code/game/area"
-#define FILE_DIR "code/game/events"
-#define FILE_DIR "code/game/events/EventProcs"
-#define FILE_DIR "code/game/events/Events"
-#define FILE_DIR "code/game/gamemodes"
-#define FILE_DIR "code/game/gamemodes/autotraitor"
-#define FILE_DIR "code/game/gamemodes/blob"
-#define FILE_DIR "code/game/gamemodes/blob/blobs"
-#define FILE_DIR "code/game/gamemodes/changeling"
-#define FILE_DIR "code/game/gamemodes/cult"
-#define FILE_DIR "code/game/gamemodes/epidemic"
-#define FILE_DIR "code/game/gamemodes/events"
-#define FILE_DIR "code/game/gamemodes/events/holidays"
-#define FILE_DIR "code/game/gamemodes/extended"
-#define FILE_DIR "code/game/gamemodes/malfunction"
-#define FILE_DIR "code/game/gamemodes/meme"
-#define FILE_DIR "code/game/gamemodes/meteor"
-#define FILE_DIR "code/game/gamemodes/nuclear"
-#define FILE_DIR "code/game/gamemodes/revolution"
-#define FILE_DIR "code/game/gamemodes/sandbox"
-#define FILE_DIR "code/game/gamemodes/traitor"
-#define FILE_DIR "code/game/gamemodes/wizard"
-#define FILE_DIR "code/game/jobs"
-#define FILE_DIR "code/game/jobs/job"
-#define FILE_DIR "code/game/machinery"
-#define FILE_DIR "code/game/machinery/atmoalter"
-#define FILE_DIR "code/game/machinery/bots"
-#define FILE_DIR "code/game/machinery/camera"
-#define FILE_DIR "code/game/machinery/computer"
-#define FILE_DIR "code/game/machinery/doors"
-#define FILE_DIR "code/game/machinery/embedded_controller"
-#define FILE_DIR "code/game/machinery/kitchen"
-#define FILE_DIR "code/game/machinery/pipe"
-#define FILE_DIR "code/game/machinery/telecomms"
-#define FILE_DIR "code/game/magic"
-#define FILE_DIR "code/game/mecha"
-#define FILE_DIR "code/game/mecha/combat"
-#define FILE_DIR "code/game/mecha/equipment"
-#define FILE_DIR "code/game/mecha/equipment/tools"
-#define FILE_DIR "code/game/mecha/equipment/weapons"
-#define FILE_DIR "code/game/mecha/medical"
-#define FILE_DIR "code/game/mecha/working"
-#define FILE_DIR "code/game/objects"
-#define FILE_DIR "code/game/objects/closets"
-#define FILE_DIR "code/game/objects/closets/secure"
-#define FILE_DIR "code/game/objects/effects"
-#define FILE_DIR "code/game/objects/effects/decals"
-#define FILE_DIR "code/game/objects/effects/decals/Cleanable"
-#define FILE_DIR "code/game/objects/effects/spawners"
-#define FILE_DIR "code/game/objects/items"
-#define FILE_DIR "code/game/objects/items/devices"
-#define FILE_DIR "code/game/objects/items/devices/PDA"
-#define FILE_DIR "code/game/objects/items/devices/radio"
-#define FILE_DIR "code/game/objects/items/robot"
-#define FILE_DIR "code/game/objects/items/stacks"
-#define FILE_DIR "code/game/objects/items/stacks/sheets"
-#define FILE_DIR "code/game/objects/items/stacks/tiles"
-#define FILE_DIR "code/game/objects/items/weapons"
-#define FILE_DIR "code/game/objects/items/weapons/grenades"
-#define FILE_DIR "code/game/objects/items/weapons/implants"
-#define FILE_DIR "code/game/objects/items/weapons/secstorage"
-#define FILE_DIR "code/game/objects/items/weapons/storage"
-#define FILE_DIR "code/game/objects/items/weapons/tanks"
-#define FILE_DIR "code/game/objects/storage"
-#define FILE_DIR "code/game/objects/structures"
-#define FILE_DIR "code/game/objects/structures/crates_lockers"
-#define FILE_DIR "code/game/objects/structures/crates_lockers/closets"
-#define FILE_DIR "code/game/objects/structures/crates_lockers/closets/secure"
-#define FILE_DIR "code/game/objects/structures/stool_bed_chair_nest"
-#define FILE_DIR "code/game/player"
-#define FILE_DIR "code/game/structure"
-#define FILE_DIR "code/game/turfs"
-#define FILE_DIR "code/game/turfs/simulated"
-#define FILE_DIR "code/game/turfs/space"
-#define FILE_DIR "code/game/turfs/unsimulated"
-#define FILE_DIR "code/game/vehicles"
-#define FILE_DIR "code/game/vehicles/airtight"
-#define FILE_DIR "code/game/verbs"
-#define FILE_DIR "code/js"
-#define FILE_DIR "code/modules"
-#define FILE_DIR "code/modules/admin"
-#define FILE_DIR "code/modules/admin/DB ban"
-#define FILE_DIR "code/modules/admin/permissionverbs"
-#define FILE_DIR "code/modules/admin/verbs"
-#define FILE_DIR "code/modules/assembly"
-#define FILE_DIR "code/modules/awaymissions"
-#define FILE_DIR "code/modules/awaymissions/maploader"
-#define FILE_DIR "code/modules/chemical"
-#define FILE_DIR "code/modules/client"
-#define FILE_DIR "code/modules/clothing"
-#define FILE_DIR "code/modules/clothing/glasses"
-#define FILE_DIR "code/modules/clothing/gloves"
-#define FILE_DIR "code/modules/clothing/head"
-#define FILE_DIR "code/modules/clothing/masks"
-#define FILE_DIR "code/modules/clothing/shoes"
-#define FILE_DIR "code/modules/clothing/spacesuits"
-#define FILE_DIR "code/modules/clothing/suits"
-#define FILE_DIR "code/modules/clothing/under"
-#define FILE_DIR "code/modules/clothing/under/jobs"
-#define FILE_DIR "code/modules/clothing/uniforms"
-#define FILE_DIR "code/modules/critters"
-#define FILE_DIR "code/modules/critters/hivebots"
-#define FILE_DIR "code/modules/customitems"
-#define FILE_DIR "code/modules/DetectiveWork"
-#define FILE_DIR "code/modules/flufftext"
-#define FILE_DIR "code/modules/food"
-#define FILE_DIR "code/modules/genetics"
-#define FILE_DIR "code/modules/icon generation"
-#define FILE_DIR "code/modules/library"
-#define FILE_DIR "code/modules/liquid"
-#define FILE_DIR "code/modules/maps"
-#define FILE_DIR "code/modules/mining"
-#define FILE_DIR "code/modules/mob"
-#define FILE_DIR "code/modules/mob/dead"
-#define FILE_DIR "code/modules/mob/dead/observer"
-#define FILE_DIR "code/modules/mob/living"
-#define FILE_DIR "code/modules/mob/living/blob"
-#define FILE_DIR "code/modules/mob/living/carbon"
-#define FILE_DIR "code/modules/mob/living/carbon/alien"
-#define FILE_DIR "code/modules/mob/living/carbon/alien/humanoid"
-#define FILE_DIR "code/modules/mob/living/carbon/alien/humanoid/caste"
-#define FILE_DIR "code/modules/mob/living/carbon/alien/larva"
-#define FILE_DIR "code/modules/mob/living/carbon/alien/special"
-#define FILE_DIR "code/modules/mob/living/carbon/amorph"
-#define FILE_DIR "code/modules/mob/living/carbon/brain"
-#define FILE_DIR "code/modules/mob/living/carbon/human"
-#define FILE_DIR "code/modules/mob/living/carbon/metroid"
-#define FILE_DIR "code/modules/mob/living/carbon/monkey"
-#define FILE_DIR "code/modules/mob/living/parasite"
-#define FILE_DIR "code/modules/mob/living/silicon"
-#define FILE_DIR "code/modules/mob/living/silicon/ai"
-#define FILE_DIR "code/modules/mob/living/silicon/ai/freelook"
-#define FILE_DIR "code/modules/mob/living/silicon/decoy"
-#define FILE_DIR "code/modules/mob/living/silicon/pai"
-#define FILE_DIR "code/modules/mob/living/silicon/robot"
-#define FILE_DIR "code/modules/mob/living/simple_animal"
-#define FILE_DIR "code/modules/mob/living/simple_animal/friendly"
-#define FILE_DIR "code/modules/mob/living/simple_animal/hostile"
-#define FILE_DIR "code/modules/mob/new_player"
-#define FILE_DIR "code/modules/mob/simple_animal"
-#define FILE_DIR "code/modules/paperwork"
-#define FILE_DIR "code/modules/power"
-#define FILE_DIR "code/modules/power/antimatter"
-#define FILE_DIR "code/modules/power/singularity"
-#define FILE_DIR "code/modules/power/singularity/particle_accelerator"
-#define FILE_DIR "code/modules/projectiles"
-#define FILE_DIR "code/modules/projectiles/ammunition"
-#define FILE_DIR "code/modules/projectiles/guns"
-#define FILE_DIR "code/modules/projectiles/guns/energy"
-#define FILE_DIR "code/modules/projectiles/guns/projectile"
-#define FILE_DIR "code/modules/projectiles/projectile"
-#define FILE_DIR "code/modules/reagents"
-#define FILE_DIR "code/modules/reagents/reagent_containers"
-#define FILE_DIR "code/modules/reagents/reagent_containers/food"
-#define FILE_DIR "code/modules/reagents/reagent_containers/food/drinks"
-#define FILE_DIR "code/modules/reagents/reagent_containers/food/drinks/bottle"
-#define FILE_DIR "code/modules/reagents/reagent_containers/food/snacks"
-#define FILE_DIR "code/modules/reagents/reagent_containers/glass"
-#define FILE_DIR "code/modules/reagents/reagent_containers/glass/bottle"
-#define FILE_DIR "code/modules/recycling"
-#define FILE_DIR "code/modules/research"
-#define FILE_DIR "code/modules/research/xenoarchaeology"
-#define FILE_DIR "code/modules/scripting"
-#define FILE_DIR "code/modules/scripting/AST"
-#define FILE_DIR "code/modules/scripting/AST/Operators"
-#define FILE_DIR "code/modules/scripting/Implementations"
-#define FILE_DIR "code/modules/scripting/Interpreter"
-#define FILE_DIR "code/modules/scripting/Parser"
-#define FILE_DIR "code/modules/scripting/Scanner"
-#define FILE_DIR "code/modules/security levels"
#define FILE_DIR "code/TriDimension"
-#define FILE_DIR "code/unused"
-#define FILE_DIR "code/unused/beast"
-#define FILE_DIR "code/unused/computer2"
-#define FILE_DIR "code/unused/disease2"
-#define FILE_DIR "code/unused/gamemodes"
-#define FILE_DIR "code/unused/hivebot"
-#define FILE_DIR "code/unused/mining"
-#define FILE_DIR "code/unused/optics"
-#define FILE_DIR "code/unused/pda2"
-#define FILE_DIR "code/unused/powerarmor"
-#define FILE_DIR "code/unused/spacecraft"
#define FILE_DIR "code/WorkInProgress"
-#define FILE_DIR "code/WorkInProgress/AI_Visibility"
-#define FILE_DIR "code/WorkInProgress/animusstation"
-#define FILE_DIR "code/WorkInProgress/Apples"
#define FILE_DIR "code/WorkInProgress/Cael_Aislinn"
#define FILE_DIR "code/WorkInProgress/Cael_Aislinn/Rust"
#define FILE_DIR "code/WorkInProgress/Cael_Aislinn/Supermatter"
-#define FILE_DIR "code/WorkInProgress/carn"
-#define FILE_DIR "code/WorkInProgress/Chinsky"
-#define FILE_DIR "code/WorkInProgress/mapload"
-#define FILE_DIR "code/WorkInProgress/Mini"
-#define FILE_DIR "code/WorkInProgress/Mloc"
-#define FILE_DIR "code/WorkInProgress/organs"
-#define FILE_DIR "code/WorkInProgress/Ported"
-#define FILE_DIR "code/WorkInProgress/Ported/Abi79"
-#define FILE_DIR "code/WorkInProgress/Ported/Bureaucracy"
-#define FILE_DIR "code/WorkInProgress/Ported/Spawners"
-#define FILE_DIR "code/WorkInProgress/SkyMarshal"
-#define FILE_DIR "code/WorkInProgress/Tastyfish"
-#define FILE_DIR "code/WorkInProgress/virus2"
-#define FILE_DIR "code/WorkInProgress/virus2/Disease2"
-#define FILE_DIR "code/WorkInProgress/Wrongnumber"
-#define FILE_DIR "code/ZAS"
#define FILE_DIR "html"
#define FILE_DIR "icons"
#define FILE_DIR "icons/48x48"
@@ -251,9 +33,7 @@
#define FILE_DIR "icons/turf"
#define FILE_DIR "icons/vehicles"
#define FILE_DIR "icons/vending_icons"
-#define FILE_DIR "interface"
#define FILE_DIR "maps"
-#define FILE_DIR "maps/RandomZLevels"
#define FILE_DIR "sound"
#define FILE_DIR "sound/AI"
#define FILE_DIR "sound/ambience"
@@ -268,8 +48,6 @@
#define FILE_DIR "sound/violin"
#define FILE_DIR "sound/voice"
#define FILE_DIR "sound/weapons"
-#define FILE_DIR "tools"
-#define FILE_DIR "tools/Redirector"
// END_FILE_DIR
// BEGIN_PREFERENCES
@@ -282,6 +60,17 @@
#include "code\setup.dm"
#include "code\stylesheet.dm"
#include "code\world.dm"
+#include "code\__HELPERS\files.dm"
+#include "code\__HELPERS\game.dm"
+#include "code\__HELPERS\global_lists.dm"
+#include "code\__HELPERS\icons.dm"
+#include "code\__HELPERS\lists.dm"
+#include "code\__HELPERS\logging.dm"
+#include "code\__HELPERS\names.dm"
+#include "code\__HELPERS\text.dm"
+#include "code\__HELPERS\time.dm"
+#include "code\__HELPERS\type2type.dm"
+#include "code\__HELPERS\unsorted.dm"
#include "code\ATMOSPHERICS\atmospherics.dm"
#include "code\ATMOSPHERICS\datum_pipe_network.dm"
#include "code\ATMOSPHERICS\datum_pipeline.dm"
@@ -382,25 +171,10 @@
#include "code\defines\obj\weapon.dm"
#include "code\defines\procs\AStar.dm"
#include "code\defines\procs\captain_announce.dm"
-#include "code\defines\procs\church_name.dm"
#include "code\defines\procs\command_alert.dm"
-#include "code\defines\procs\command_name.dm"
#include "code\defines\procs\dbcore.dm"
#include "code\defines\procs\forum_activation.dm"
-#include "code\defines\procs\gamehelpers.dm"
-#include "code\defines\procs\global_lists.dm"
-#include "code\defines\procs\helper_list.dm"
-#include "code\defines\procs\helper_text.dm"
-#include "code\defines\procs\helper_type2type.dm"
-#include "code\defines\procs\helpers.dm"
-#include "code\defines\procs\icon_procs.dm"
-#include "code\defines\procs\icon_procs_readme.dm"
-#include "code\defines\procs\logging.dm"
-#include "code\defines\procs\religion_name.dm"
-#include "code\defines\procs\station_name.dm"
#include "code\defines\procs\statistics.dm"
-#include "code\defines\procs\syndicate_name.dm"
-#include "code\defines\procs\time_stamp.dm"
#include "code\game\asteroid.dm"
#include "code\game\atoms.dm"
#include "code\game\atoms_movable.dm"
diff --git a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
index 1f3aae999d4..feea5bff52c 100644
--- a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
@@ -138,7 +138,7 @@ obj/machinery/atmospherics/binary/passive_gate
if(!src.allowed(user))
user << "\red Access denied."
return
- usr.machine = src
+ usr.set_machine(src)
interact(user)
return
@@ -149,7 +149,7 @@ obj/machinery/atmospherics/binary/passive_gate
if(href_list["set_press"])
var/new_pressure = input(usr,"Enter new output pressure (0-4500kPa)","Pressure control",src.target_pressure) as num
src.target_pressure = max(0, min(4500, new_pressure))
- usr.machine = src
+ usr.set_machine(src)
src.update_icon()
src.updateUsrDialog()
return
diff --git a/code/ATMOSPHERICS/components/binary_devices/pump.dm b/code/ATMOSPHERICS/components/binary_devices/pump.dm
index 7746d238d22..cca6acaf199 100644
--- a/code/ATMOSPHERICS/components/binary_devices/pump.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/pump.dm
@@ -156,7 +156,7 @@ obj/machinery/atmospherics/binary/pump
if(!src.allowed(user))
user << "\red Access denied."
return
- usr.machine = src
+ usr.set_machine(src)
interact(user)
return
@@ -167,7 +167,7 @@ obj/machinery/atmospherics/binary/pump
if(href_list["set_press"])
var/new_pressure = input(usr,"Enter new output pressure (0-4500kPa)","Pressure control",src.target_pressure) as num
src.target_pressure = max(0, min(4500, new_pressure))
- usr.machine = src
+ usr.set_machine(src)
src.update_icon()
src.updateUsrDialog()
return
diff --git a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
index c04a927fc48..e52f89e218f 100644
--- a/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
@@ -147,7 +147,7 @@ obj/machinery/atmospherics/binary/volume_pump
if(!src.allowed(user))
user << "\red Access denied."
return
- usr.machine = src
+ usr.set_machine(src)
interact(user)
return
@@ -158,7 +158,7 @@ obj/machinery/atmospherics/binary/volume_pump
if(href_list["set_transfer_rate"])
var/new_transfer_rate = input(usr,"Enter new output volume (0-200l/s)","Flow control",src.transfer_rate) as num
src.transfer_rate = max(0, min(200, new_transfer_rate))
- usr.machine = src
+ usr.set_machine(src)
src.update_icon()
src.updateUsrDialog()
return
diff --git a/code/ATMOSPHERICS/components/trinary_devices/filter.dm b/code/ATMOSPHERICS/components/trinary_devices/filter.dm
index 55b0a195164..a2d72ca523b 100755
--- a/code/ATMOSPHERICS/components/trinary_devices/filter.dm
+++ b/code/ATMOSPHERICS/components/trinary_devices/filter.dm
@@ -211,7 +211,7 @@ obj/machinery/atmospherics/trinary/filter/attack_hand(user as mob) // -- TLE
obj/machinery/atmospherics/trinary/filter/Topic(href, href_list) // -- TLE
if(..())
return
- usr.machine = src
+ usr.set_machine(src)
src.add_fingerprint(usr)
if(href_list["filterset"])
src.filter_type = text2num(href_list["filterset"])
diff --git a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm
index 026c3531fdf..69307784a94 100644
--- a/code/ATMOSPHERICS/components/trinary_devices/mixer.dm
+++ b/code/ATMOSPHERICS/components/trinary_devices/mixer.dm
@@ -112,7 +112,7 @@ obj/machinery/atmospherics/trinary/mixer
if(!src.allowed(user))
user << "\red Access denied."
return
- usr.machine = src
+ usr.set_machine(src)
var/dat = {"Power: [on?"On":"Off"]
Desirable output pressure:
[target_pressure]kPa | Change
diff --git a/code/FEA/FEA_airgroup.dm b/code/FEA/FEA_airgroup.dm
index 00a6afc3949..67b5c757565 100644
--- a/code/FEA/FEA_airgroup.dm
+++ b/code/FEA/FEA_airgroup.dm
@@ -90,7 +90,8 @@ datum/air_group
if (next_check > 0)
next_check--
return 1
- next_check += check_delay + rand(max(check_delay, 1)/2,check_delay)
+ var/player_count = max(player_list.len, 3) / 3
+ next_check += check_delay + rand(player_count, player_count * 1.5)
check_delay++
var/turf/simulated/list/border_individual = list()
diff --git a/code/FEA/FEA_turf_tile.dm b/code/FEA/FEA_turf_tile.dm
index d043e348245..1fd6aaf7152 100644
--- a/code/FEA/FEA_turf_tile.dm
+++ b/code/FEA/FEA_turf_tile.dm
@@ -304,7 +304,8 @@ turf
if (next_check > 0)
next_check--
return 1
- next_check += check_delay + rand(max(check_delay, 1)/2,check_delay)
+ var/player_count = max(player_list.len, 3) / 3
+ next_check += check_delay + rand(player_count, player_count * 1.5)
check_delay++
var/turf/simulated/list/possible_fire_spreads = list()
diff --git a/code/ZAS/Variable Settings.dm b/code/ZAS/Variable Settings.dm
index 9b02ec553e6..4aabbce5262 100644
--- a/code/ZAS/Variable Settings.dm
+++ b/code/ZAS/Variable Settings.dm
@@ -280,7 +280,7 @@ pl_control
else if(istext(vars["[V]_RANDOM"]))
var/txt = vars["[V]_RANDOM"]
if(findtextEx(txt,"PROB"))
- txt = dd_text2list(txt,"/")
+ txt = text2list(txt,"/")
txt[1] = dd_replacetext(txt[1],"PROB","")
var/p = text2num(txt[1])
var/r = txt[2]
@@ -290,7 +290,7 @@ pl_control
newvalue = vars[V]
else if(findtextEx(txt,"PICK"))
txt = dd_replacetext(txt,"PICK","")
- txt = dd_text2list(txt,",")
+ txt = text2list(txt,",")
newvalue = pick(txt)
else
newvalue = roll(txt)
diff --git a/code/__HELPERS/files.dm b/code/__HELPERS/files.dm
new file mode 100644
index 00000000000..955c5ba300a
--- /dev/null
+++ b/code/__HELPERS/files.dm
@@ -0,0 +1,18 @@
+//checks if a file exists and contains text
+//returns text as a string if these conditions are met
+/proc/return_file_text(filename)
+ if(fexists(filename) == 0)
+ error("File not found ([filename])")
+ return
+
+ var/text = file2text(filename)
+ if(!text)
+ error("File empty ([filename])")
+ return
+
+ return text
+
+//Sends resource files to client cache
+/mob/proc/getFiles()
+ for(var/file in args)
+ src << browse_rsc(file)
\ No newline at end of file
diff --git a/code/defines/procs/gamehelpers.dm b/code/__HELPERS/game.dm
similarity index 84%
rename from code/defines/procs/gamehelpers.dm
rename to code/__HELPERS/game.dm
index 864cc3666fe..ab258c8e328 100644
--- a/code/defines/procs/gamehelpers.dm
+++ b/code/__HELPERS/game.dm
@@ -280,7 +280,6 @@ proc/isInSight(var/atom/A, var/atom/B)
if(M.ckey == lowertext(key))
return M
return null
-
proc/check_can_reach(atom/user, atom/target)
if(!in_range(user,target))
return 0
@@ -320,3 +319,33 @@ var/list/DummyCache = list()
D.loc = null
DummyCache.Add(D)
return 1
+
+// Will return a list of active candidates. It increases the buffer 5 times until it finds a candidate which is active within the buffer.
+
+/proc/get_active_candidates(var/buffer = 1)
+
+ var/list/candidates = list() //List of candidate KEYS to assume control of the new larva ~Carn
+ var/i = 0
+ while(candidates.len <= 0 && i < 5)
+ for(var/mob/dead/observer/G in player_list)
+ if(((G.client.inactivity/10)/60) <= buffer + i) // the most active players are more likely to become an alien
+ if(!(G.mind && G.mind.current && G.mind.current.stat != DEAD))
+ candidates += G.key
+ i++
+ return candidates
+
+// Same as above but for alien candidates.
+
+/proc/get_alien_candidates()
+
+ var/list/candidates = list() //List of candidate KEYS to assume control of the new larva ~Carn
+ var/i = 0
+ while(candidates.len <= 0 && i < 5)
+ for(var/mob/dead/observer/G in player_list)
+ if(G.client.be_alien)
+ if(((G.client.inactivity/10)/60) <= ALIEN_SELECT_AFK_BUFFER + i) // the most active players are more likely to become an alien
+ if(!(G.mind && G.mind.current && G.mind.current.stat != DEAD))
+ candidates += G.key
+ i++
+ return candidates
+
diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm
new file mode 100644
index 00000000000..4238c756ac9
--- /dev/null
+++ b/code/__HELPERS/global_lists.dm
@@ -0,0 +1,37 @@
+var/list/clients = list() //list of all clients
+var/list/admins = list() //list of all clients whom are admins
+var/list/directory = list() //list of all ckeys with associated client
+
+//Since it didn't really belong in any other category, I'm putting this here
+//This is for procs to replace all the goddamn 'in world's that are chilling around the code
+
+var/global/list/player_list = list() //List of all mobs **with clients attached**. Excludes /mob/new_player
+var/global/list/mob_list = list() //List of all mobs, including clientless
+var/global/list/living_mob_list = list() //List of all alive mobs, including clientless. Excludes /mob/new_player
+var/global/list/dead_mob_list = list() //List of all dead mobs, including clientless. Excludes /mob/new_player
+
+var/global/list/cable_list = list() //Index for all cables, so that powernets don't have to look through the entire world all the time
+var/global/list/hair_styles_list = list() //stores /datum/sprite_accessory/hair indexed by name
+var/global/list/facial_hair_styles_list = list() //stores /datum/sprite_accessory/facial_hair indexed by name
+var/global/list/chemical_reactions_list //list of all /datum/chemical_reaction datums. Used during chemical reactions
+var/global/list/chemical_reagents_list //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff
+var/global/list/landmarks_list = list() //list of all landmarks created
+
+//////////////////////////
+/////Initial Building/////
+//////////////////////////
+//Realistically, these should never be run, but ideally, they should only be run once at round-start
+
+/proc/make_datum_references_lists()
+ var/list/paths
+ //Hair - Initialise all /datum/sprite_accessory/hair into an list indexed by hair-style name
+ paths = typesof(/datum/sprite_accessory/hair) - /datum/sprite_accessory/hair
+ for(var/path in paths)
+ var/datum/sprite_accessory/hair/H = new path()
+ hair_styles_list[H.name] = H
+ //Facial Hair - Initialise all /datum/sprite_accessory/facial_hair into an list indexed by facialhair-style name
+ paths = typesof(/datum/sprite_accessory/facial_hair) - /datum/sprite_accessory/facial_hair
+ for(var/path in paths)
+ var/datum/sprite_accessory/facial_hair/H = new path()
+ facial_hair_styles_list[H.name] = H
+
diff --git a/code/defines/procs/icon_procs.dm b/code/__HELPERS/icons.dm
similarity index 62%
rename from code/defines/procs/icon_procs.dm
rename to code/__HELPERS/icons.dm
index ce56408ead4..cfca598adbc 100644
--- a/code/defines/procs/icon_procs.dm
+++ b/code/__HELPERS/icons.dm
@@ -1,8 +1,217 @@
/*
- IconProcs
- by Lummox JR
- Check the icon_procs_readme.dm for how they work.
- */
+IconProcs README
+
+A BYOND library for manipulating icons and colors
+
+by Lummox JR
+
+version 1.0
+
+The IconProcs library was made to make a lot of common icon operations much easier. BYOND's icon manipulation
+routines are very capable but some of the advanced capabilities like using alpha transparency can be unintuitive to beginners.
+
+CHANGING ICONS
+
+Several new procs have been added to the /icon datum to simplify working with icons. To use them,
+remember you first need to setup an /icon var like so:
+
+var/icon/my_icon = new('iconfile.dmi')
+
+icon/ChangeOpacity(amount = 1)
+ A very common operation in DM is to try to make an icon more or less transparent. Making an icon more
+ transparent is usually much easier than making it less so, however. This proc basically is a frontend
+ for MapColors() which can change opacity any way you like, in much the same way that SetIntensity()
+ can make an icon lighter or darker. If amount is 0.5, the opacity of the icon will be cut in half.
+ If amount is 2, opacity is doubled and anything more than half-opaque will become fully opaque.
+icon/GrayScale()
+ Converts the icon to grayscale instead of a fully colored icon. Alpha values are left intact.
+icon/ColorTone(tone)
+ Similar to GrayScale(), this proc converts the icon to a range of black -> tone -> white, where tone is an
+ RGB color (its alpha is ignored). This can be used to create a sepia tone or similar effect.
+ See also the global ColorTone() proc.
+icon/MinColors(icon)
+ The icon is blended with a second icon where the minimum of each RGB pixel is the result.
+ Transparency may increase, as if the icons were blended with ICON_ADD. You may supply a color in place of an icon.
+icon/MaxColors(icon)
+ The icon is blended with a second icon where the maximum of each RGB pixel is the result.
+ Opacity may increase, as if the icons were blended with ICON_OR. You may supply a color in place of an icon.
+icon/Opaque(background = "#000000")
+ All alpha values are set to 255 throughout the icon. Transparent pixels become black, or whatever background color you specify.
+icon/BecomeAlphaMask()
+ You can convert a simple grayscale icon into an alpha mask to use with other icons very easily with this proc.
+ The black parts become transparent, the white parts stay white, and anything in between becomes a translucent shade of white.
+icon/AddAlphaMask(mask)
+ The alpha values of the mask icon will be blended with the current icon. Anywhere the mask is opaque,
+ the current icon is untouched. Anywhere the mask is transparent, the current icon becomes transparent.
+ Where the mask is translucent, the current icon becomes more transparent.
+icon/UseAlphaMask(mask, mode)
+ Sometimes you may want to take the alpha values from one icon and use them on a different icon.
+ This proc will do that. Just supply the icon whose alpha mask you want to use, and src will change
+ so it has the same colors as before but uses the mask for opacity.
+
+COLOR MANAGEMENT AND HSV
+
+RGB isn't the only way to represent color. Sometimes it's more useful to work with a model called HSV, which stands for hue, saturation, and value.
+
+ * The hue of a color describes where it is along the color wheel. It goes from red to yellow to green to
+ cyan to blue to magenta and back to red.
+ * The saturation of a color is how much color is in it. A color with low saturation will be more gray,
+ and with no saturation at all it is a shade of gray.
+ * The value of a color determines how bright it is. A high-value color is vivid, moderate value is dark,
+ and no value at all is black.
+
+Just as BYOND uses "#rrggbb" to represent RGB values, a similar format is used for HSV: "#hhhssvv". The hue is three
+hex digits because it ranges from 0 to 0x5FF.
+
+ * 0 to 0xFF - red to yellow
+ * 0x100 to 0x1FF - yellow to green
+ * 0x200 to 0x2FF - green to cyan
+ * 0x300 to 0x3FF - cyan to blue
+ * 0x400 to 0x4FF - blue to magenta
+ * 0x500 to 0x5FF - magenta to red
+
+Knowing this, you can figure out that red is "#000ffff" in HSV format, which is hue 0 (red), saturation 255 (as colorful as possible),
+value 255 (as bright as possible). Green is "#200ffff" and blue is "#400ffff".
+
+More than one HSV color can match the same RGB color.
+
+Here are some procs you can use for color management:
+
+ReadRGB(rgb)
+ Takes an RGB string like "#ffaa55" and converts it to a list such as list(255,170,85). If an RGBA format is used
+ that includes alpha, the list will have a fourth item for the alpha value.
+hsv(hue, sat, val, apha)
+ Counterpart to rgb(), this takes the values you input and converts them to a string in "#hhhssvv" or "#hhhssvvaa"
+ format. Alpha is not included in the result if null.
+ReadHSV(rgb)
+ Takes an HSV string like "#100FF80" and converts it to a list such as list(256,255,128). If an HSVA format is used that
+ includes alpha, the list will have a fourth item for the alpha value.
+RGBtoHSV(rgb)
+ Takes an RGB or RGBA string like "#ffaa55" and converts it into an HSV or HSVA color such as "#080aaff".
+HSVtoRGB(hsv)
+ Takes an HSV or HSVA string like "#080aaff" and converts it into an RGB or RGBA color such as "#ff55aa".
+BlendRGB(rgb1, rgb2, amount)
+ Blends between two RGB or RGBA colors using regular RGB blending. If amount is 0, the first color is the result;
+ if 1, the second color is the result. 0.5 produces an average of the two. Values outside the 0 to 1 range are allowed as well.
+ The returned value is an RGB or RGBA color.
+BlendHSV(hsv1, hsv2, amount)
+ Blends between two HSV or HSVA colors using HSV blending, which tends to produce nicer results than regular RGB
+ blending because the brightness of the color is left intact. If amount is 0, the first color is the result; if 1,
+ the second color is the result. 0.5 produces an average of the two. Values outside the 0 to 1 range are allowed as well.
+ The returned value is an HSV or HSVA color.
+BlendRGBasHSV(rgb1, rgb2, amount)
+ Like BlendHSV(), but the colors used and the return value are RGB or RGBA colors. The blending is done in HSV form.
+HueToAngle(hue)
+ Converts a hue to an angle range of 0 to 360. Angle 0 is red, 120 is green, and 240 is blue.
+AngleToHue(hue)
+ Converts an angle to a hue in the valid range.
+RotateHue(hsv, angle)
+ Takes an HSV or HSVA value and rotates the hue forward through red, green, and blue by an angle from 0 to 360.
+ (Rotating red by 60° produces yellow.) The result is another HSV or HSVA color with the same saturation and value
+ as the original, but a different hue.
+GrayScale(rgb)
+ Takes an RGB or RGBA color and converts it to grayscale. Returns an RGB or RGBA string.
+ColorTone(rgb, tone)
+ Similar to GrayScale(), this proc converts an RGB or RGBA color to a range of black -> tone -> white instead of
+ using strict shades of gray. The tone value is an RGB color; any alpha value is ignored.
+*/
+
+/*
+Get Flat Icon DEMO by DarkCampainger
+
+This is a test for the get flat icon proc, modified approprietly for icons and their states.
+Probably not a good idea to run this unless you want to see how the proc works in detail.
+mob
+ icon = 'old_or_unused.dmi'
+ icon_state = "green"
+
+ Login()
+ // Testing image underlays
+ underlays += image(icon='old_or_unused.dmi',icon_state="red")
+ underlays += image(icon='old_or_unused.dmi',icon_state="red", pixel_x = 32)
+ underlays += image(icon='old_or_unused.dmi',icon_state="red", pixel_x = -32)
+
+ // Testing image overlays
+ overlays += image(icon='old_or_unused.dmi',icon_state="green", pixel_x = 32, pixel_y = -32)
+ overlays += image(icon='old_or_unused.dmi',icon_state="green", pixel_x = 32, pixel_y = 32)
+ overlays += image(icon='old_or_unused.dmi',icon_state="green", pixel_x = -32, pixel_y = -32)
+
+ // Testing icon file overlays (defaults to mob's state)
+ overlays += '_flat_demoIcons2.dmi'
+
+ // Testing icon_state overlays (defaults to mob's icon)
+ overlays += "white"
+
+ // Testing dynamic icon overlays
+ var/icon/I = icon('old_or_unused.dmi', icon_state="aqua")
+ I.Shift(NORTH,16,1)
+ overlays+=I
+
+ // Testing dynamic image overlays
+ I=image(icon=I,pixel_x = -32, pixel_y = 32)
+ overlays+=I
+
+ // Testing object types (and layers)
+ overlays+=/obj/effect/overlayTest
+
+ loc = locate (10,10,1)
+ verb
+ Browse_Icon()
+ set name = "1. Browse Icon"
+ // Give it a name for the cache
+ var/iconName = "[ckey(src.name)]_flattened.dmi"
+ // Send the icon to src's local cache
+ src<