//Title: Procedure for generating movement ranges
//Credit to: Jp
//Contributed by: Jp
/*
This snippet takes an atom/movable and a number as an
argument, and returns a list containing every turf the mob
can reach by moving that number of times. It takes density
into account.
WARNING: This snippet relies on Enter() doing what it should
do - that is, returning 1 if some atom/movable can enter
some turf. If you've done something silly with Enter() -
like, for example, changed it so it displays a message when
someone enters something - then it will produce a wide
variety of interesting bugs. That's due to you putting code
in Enter() that should have ended up in Entered()
*/
proc/generateMoveSquares(atom/movable/m,mrange)
var/list/inrange=list(m.loc)
for(var/k=1, k<=mrange, k++)
for(var/turf/t in inrange)
for(var/turf/poss in orange(t,1))
if(poss.Enter(m))
inrange+=poss
inrange-=t
return inrange
/*
Example: Takes every square that you can get to in five
moves, and changes its text for a little while. Best seen in
text mode
*/
mob/verb/movementRange()
for(var/turf/t in generateMoveSquares(src,5))
t.text="#"
spawn(20) t.text=" "
ID:195076
Jan 14 2007, 9:19 pm (Edited on Aug 16 2011, 11:07 pm)
|
|
Aug 16 2011, 2:46 pm
|
|
When you call Enter(), it should be poss.Enter(m). You reversed it.
|
In response to Hypnautilus
|
|
Fixed. Thanks for the catch.
|