ID:143124
 
Code:
proc
BDrop()
var/stepped = 0
while(src)
if(src.y<=33)
del src
else
if(src.x>=34)
if(src.x<=44)
var/r = rand(1,3)
if(r==1)
step(src,SOUTHEAST)
if(r==2)
step(src,SOUTHWEST)
if(r==3)
step(src,SOUTH)
else
var/r = rand(1,2)
if(r==1)
step(src,SOUTHWEST)
if(r==2)
step(src,SOUTH)
stepped = 1
if(!stepped)
if(src.x<=44)
if(src.x>=34)
var/r = rand(1,3)
if(r==1)
step(src,SOUTHEAST)
if(r==2)
step(src,SOUTHWEST)
if(r==3)
step(src,SOUTH)
else
var/r = rand(1,2)
if(r==1)
step(src,SOUTHEAST)
if(r==2)
step(src,SOUTH)

sleep(5)
stepped = 0


Problem description:

This is a simple proc called when an object (a banana) is created. It is meant to fall from a height, swaying slightly (and randomly) as it goes down until it gets to y = 33 where it is deleted.

It works fine, but it looks UGLY! How can I neaten this up a bit? The "if" statements are to keep it between x = 34 and x = 44

~Ease~

obj/banana
var/minx = 34
var/maxx = 44
proc
BDrop()
while(y > 33)
var/d = pick(SOUTHEAST, SOUTH, SOUTHWEST)
if(x >= maxx)
d &= ~EAST //remove the EAST component
else if(x <= minx)
d &= ~WEST //remove the WEST component
step(src,d)

del(src)
In response to Garthor (#1)
Thanks Garthor, you're a legend.

~Ease~