ID:267190
 
I'm here again with another problem.I've made a new mob called a weakling, whose job is to move west untill he runs into something dense or will fall in a hole.Then he is to turn around and do the same thing to the east.Yet when I tried to put it together I had problems. This is the code for the weakling to move...

mob
proc
BadGuyMove()
var/turf/lefturf = locate(src.x-1, src.y, src.z)
var/turf/righturf = locate(src.x+1, src.y, src.z)
var/turf/brighturf = locate(src.x+1, src.y-1, src.z)
var/turf/blefturf = locate(src.x-1, src.y-1, src.z)
while (src)
sleep(17)
if (lefturf.density==1)
if (righturf.density==1)
return
if (righturf.density==0)
if (brighturf.density==0)
return
if (brighturf.density==1)
step(src, EAST)
return
if (lefturf.density==0)
if (blefturf.density==0)
return
if (blefturf.density==1)
step(src, WEST)
return


and if this helps the code for the weakling

mob/enemys
weakling
icon='Mob.dmi'
icon_state="weakling"
New()
spawn()BadGuyMove()


Thanks if you can figure out the problem.
-Beld
I'm not sure what the point of all that proc is, but heres what I would do. for a new weakling, have it start walking like this

new()
walk(src,,3)

then set up the Bump() proc like this

Bump()
if(src.dir==EAST)
walk(src,WEST,3)
if(src.dir==WEST)
walk(src,WEST,3)
else
walk(src,WEST,3)//If its not facing east or west, then make it walk west, if it hits something the bump will call and it should start walkin east. You could do this either way.
In response to Jotdaniel
Maybe I should have told you this but this is a side scrolling game.The code you gave me doesn't do anything differnt by the way
In response to Emperor Beld
Hmm. Did you try it?
In response to Emperor Beld
Btw....What is the problem you had? You never said. I just showed a simpler way to do what you needed(with changes added so it fits your needs.)
In response to Jotdaniel
The problem was the the person doesn't move
In response to Emperor Beld
Oh. Hmm, it wont move with my version either?
In response to Jotdaniel
Nope
It's 3:16 here so I didn't get much time to look it over, but it looks like you had it so he will move once and not move again. Never put return statemets in a while statement like that. return like that is just used to end the current procedure completely and return to whatever called it, to return null. Just have it so if he sees he can walk that direction, he walks, but don't put any coding in for if he sees that he cannot walk that direction (unless you want him to walk the other, of coarse.) delete all your returns in there and that should do the trick.