ID:156014
 
A friend of mine made this for me about two years ago and recently I've been wondering if it could be... well, improved somehow (efficiency-wise, coding-wise, etc).

mob
effects
verb
Tornado()
set category = "Effects"
if(tornado)
tornado = FALSE
return FALSE
else
var
radius = input("Radius?", "Radius") as null | num
if(radius && radius <= world.view)
tornado = TRUE

while(tornado)
for(var/atom/movable/O in view(radius))
if(O.anchor)
continue
var
_x = O.x - x
_y = O.y - y
_dir = get_dir(loc, O.loc)
switch(_dir)
if(NORTH)
O.x--
if(WEST)
O.y--
if(SOUTH)
O.x++
if(EAST)
O.y++
if(NORTHEAST)
if(_y > _x)
O.x--
if(_x > _y)
O.y++
if(abs(_x) == abs(_y))
O.x--
if(NORTHWEST)
if(abs(_y) > abs(_x))
O.x--
if(abs(_x) > abs(_y))
O.y--
if(abs(_x) == abs(_y))
O.y--
if(SOUTHWEST)
if(abs(_y) > abs(_x))
O.x++
if(abs(_x) > abs(_y))
O.y--
if(abs(_x) == abs(_y))
O.x++
if(SOUTHEAST)
if(abs(_y) > abs(_x))
O.x++
if(abs(_x) > abs(_y))
O.y++
if(abs(_x) == abs(_y))
O.y++
sleep(1)
To be honest, I don't know what this code is supposed to go for other than doing customized movement of some sort. If you explain what it is supposed to do, maybe one of us could help you.
One thing you can definitley do is comebine some of those statements.

Ex.

 if(SOUTHEAST)
if(abs(_y) > abs(_x))
O.x++
if((abs(_x) > abs(_y)) || (abs(_x) == abs(_y)))