From say code import, we get to learn one proc.

This commit is contained in:
eswordthecat
2015-04-04 23:16:44 +08:00
parent 666b16b242
commit 39a3bca274
4 changed files with 56 additions and 30 deletions

View File

@@ -130,7 +130,7 @@
//This is the new version of recursive_mob_check, used for say(). //This is the new version of recursive_mob_check, used for say().
//The other proc was left intact because morgue trays use it. //The other proc was left intact because morgue trays use it.
/proc/recursive_hear_check(var/atom/O) /proc/recursive_hear_check(atom/O)
var/list/processing_list = list(O) var/list/processing_list = list(O)
var/list/processed_list = list() var/list/processed_list = list()
var/list/found_atoms = list() var/list/found_atoms = list()
@@ -150,6 +150,26 @@
return found_atoms return found_atoms
/proc/recursive_type_check(atom/O, type = /atom)
var/list/processing_list = list(O)
var/list/processed_list = new/list()
var/list/found_atoms = new/list()
while (processing_list.len)
var/atom/A = processing_list[1]
if (istype(A, type))
found_atoms |= A
for (var/atom/B in A)
if (!processed_list[B])
processing_list |= B
processing_list.Cut(1, 2)
processed_list[A] = A
return found_atoms
//var/debug_mob = 0 //var/debug_mob = 0
// Will recursively loop through an atom's contents and check for mobs, then it will loop through every atom in that atom's contents. // Will recursively loop through an atom's contents and check for mobs, then it will loop through every atom in that atom's contents.

View File

@@ -328,9 +328,16 @@ var/bomb_set
return return
return return
/obj/item/weapon/disk/nuclear/Destroy() /obj/item/weapon/disk/nuclear/Del()
if(blobstart.len > 0) if(blobstart.len > 0)
var/obj/D = new /obj/item/weapon/disk/nuclear(pick(blobstart)) var/picked_location = pick(blobstart)
message_admins("[src] has been destroyed. Spawning [D] at ([D.x], [D.y], [D.z]).")
log_game("[src] has been destroyed. Spawning [D] at ([D.x], [D.y], [D.z]).") var/log_message = "[type] has been destroyed. Creating one at [formatJumpTo(picked_location)]"
message_admins(log_message)
log_game(log_message)
new /obj/item/weapon/disk/nuclear(picked_location)
..() ..()

View File

@@ -310,9 +310,9 @@
return return
else else
var/inside = src.search_contents_for(/atom) var/inside = recursive_type_check(src, /atom/movable) - src
if(is_type_in_list(/obj/item/weapon/disk/nuclear, inside))
usr << "You get the feeling that you shouldn't cremate one of the items in the cremator." if (locate(/obj/item/weapon/disk/nuclear) in inside)
return return
for (var/mob/M in viewers(src)) for (var/mob/M in viewers(src))
@@ -333,7 +333,9 @@
del(M) del(M)
for (var/obj/O in inside) //obj instead of obj/item so that bodybags and ashes get destroyed. We dont want tons and tons of ash piling up for (var/obj/O in inside) //obj instead of obj/item so that bodybags and ashes get destroyed. We dont want tons and tons of ash piling up
del(O) qdel(O)
inside = null
new /obj/effect/decal/cleanable/ash(src) new /obj/effect/decal/cleanable/ash(src)
sleep(30) sleep(30)
@@ -393,12 +395,10 @@
return return
/obj/machinery/crema_switch/attack_hand(mob/user as mob) /obj/machinery/crema_switch/attack_hand(mob/user as mob)
if(src.allowed(usr)) if (allowed(user))
for (var/obj/structure/crematorium/C in world) for (var/obj/structure/crematorium/C in world)
if (C.id == id) if (C.id == id)
if (!C.cremating)
C.cremate(user) C.cremate(user)
else else
usr << "\red Access denied." user << "<SPAN CLASS='alert'>Access denied.</SPAN>"
return return

View File

@@ -52,16 +52,14 @@
qdel(A) qdel(A)
return return
if(istype(A, /obj/item/weapon/disk/nuclear)) // Don't let nuke disks travel Z levels ... And moving this shit down here so it only fires when they're actually trying to change z-level. var/disks_list = recursive_type_check(A, /obj/item/weapon/disk/nuclear)
del(A) //The disk's Destroy() proc ensures a new one is created
return
var/list/disk_search = A.search_contents_for(/obj/item/weapon/disk/nuclear)
if(istype(A, /obj/structure/stool/bed/chair/vehicle)) if(istype(A, /obj/structure/stool/bed/chair/vehicle))
var/obj/structure/stool/bed/chair/vehicle/B = A var/obj/structure/stool/bed/chair/vehicle/B = A
if(B.buckled_mob) if(B.buckled_mob)
disk_search = B.buckled_mob.search_contents_for(/obj/item/weapon/disk/nuclear) disks_list = recursive_type_check(B.buckled_mob, /obj/item/weapon/disk/nuclear)
if(!isemptylist(disk_search))
if (length(disks_list))
if(istype(A, /mob/living)) if(istype(A, /mob/living))
var/mob/living/MM = A var/mob/living/MM = A
if(MM.client && !MM.stat) if(MM.client && !MM.stat)
@@ -75,11 +73,12 @@
else if(MM.y >= world.maxy -TRANSITIONEDGE) else if(MM.y >= world.maxy -TRANSITIONEDGE)
MM.inertia_dir = 2 MM.inertia_dir = 2
else else
for(var/obj/item/weapon/disk/nuclear/N in disk_search) for (var/obj/item/weapon/disk/nuclear/N in disks_list)
del(N)//Make the disk respawn it is on a clientless mob or corpse qdel(N) // make the disk respawn if it is floating on its own.
else else
for(var/obj/item/weapon/disk/nuclear/N in disk_search) for (var/obj/item/weapon/disk/nuclear/N in disks_list)
del(N)//Make the disk respawn if it is floating on its own qdel(N) // make the disk respawn if it is floating on its own.
return return
//Check if it's a mob pulling an object //Check if it's a mob pulling an object