mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Random mouse placement (#21483)
* Restructured handle_environment() This creates the environment_is_safe() proc for simple_animals * Mice are placed at roundstart randomly Rejoyce as wires are bitten in random locations. * Removes all mice from the maps * Code review * Code review II
This commit is contained in:
40
code/controllers/subsystem/squeak.dm
Normal file
40
code/controllers/subsystem/squeak.dm
Normal file
@@ -0,0 +1,40 @@
|
||||
var/datum/subsystem/squeak/SSsqueak
|
||||
|
||||
// The Squeak
|
||||
// because this is about placement of mice mobs, and nothing to do with
|
||||
// mice - the computer peripheral
|
||||
|
||||
/datum/subsystem/squeak
|
||||
name = "Squeak"
|
||||
priority = 40
|
||||
flags = SS_NO_FIRE
|
||||
|
||||
var/list/exposed_wires = list()
|
||||
|
||||
/datum/subsystem/squeak/New()
|
||||
NEW_SS_GLOBAL(SSsqueak)
|
||||
|
||||
/datum/subsystem/squeak/Initialize(timeofday)
|
||||
find_exposed_wires()
|
||||
var/num_mice = 10
|
||||
|
||||
var/mob/living/simple_animal/mouse/M
|
||||
var/turf/proposed_turf
|
||||
|
||||
while((num_mice > 0) && exposed_wires.len)
|
||||
proposed_turf = pick_n_take(exposed_wires)
|
||||
if(!M)
|
||||
M = new(proposed_turf)
|
||||
else
|
||||
M.forceMove(proposed_turf)
|
||||
if(M.environment_is_safe())
|
||||
num_mice -= 1
|
||||
M = null
|
||||
|
||||
/datum/subsystem/squeak/proc/find_exposed_wires()
|
||||
exposed_wires.Cut()
|
||||
|
||||
var/list/all_turfs = block(locate(1,1,1), locate(world.maxx,world.maxy,1))
|
||||
for(var/turf/open/floor/plating/T in all_turfs)
|
||||
if(locate(/obj/structure/cable) in T)
|
||||
exposed_wires += T
|
||||
Reference in New Issue
Block a user