ID:146200
 
Code:
mob/NPC/proc/Makemove()

mob/NPC/proc/NPCMove(tx,ty,tz)
var/area/temparea/targetlocation = new(locate(tx,ty,tz))
for(var/turf/targetturf in targetlocation)
if(targetturf.density == 1)
src.cantmove = 1
for(var/obj/targetobj in targetlocation)
if(targetobj.density == 1)
src.cantmove = 1
if(src.cantmove == 0)
src.loc = locate(tx, ty, tz)
for(var/area/temparea/wtf in world)
new /area/World(wtf.loc)
src.cantmove = 0

mob
NPC
Friendly_Humans
Male
Walkingaround
Makemove()
var/goingto = pick("North","East","South","West")
switch(goingto)
if("North")
NPCMove(x,y+1,z)
if("East")
NPCMove(x+1,y,z)
if("South")
NPCMove(x,y-1,z)
if("West")
NPCMove(x-1,y,z)


Problem description:

My NPC walks through dense objects and turfs, even though it's coded not to move there if there's a dense object or turf. Why is this??
Question : Why don't you use step instead of x+1,etc?

Remember, return is your friend!
In response to Sniper Joe
Return, my friend? o_O
I've never created a proc with return, EVER.
In response to VDZ
Why...?
In response to Sniper Joe
Because I never bothered to learn how to use it because I never needed it.
If ever a moment comes that I need return, I'll start using it. But until then, beware the evil tx + 1s.
In response to Sniper Joe
Never created a proc with return? return is necessary for stopping things from happening. return is also very nice at stopping bugs in long strands of code if it's doing more than one thing.
In response to VDZ
Still, you didn't answer why you aren't using step.
In response to Justin Knight
But enough about return.
Why is the NPC moving through dense objects and turfs?
In response to VDZ
Becuase you are using X+1, which unlike step, move them no matter what is there.
In response to Sniper Joe
I never knew it existed.
In response to VDZ
I still don't understand why you never learned how to use return, when it's really simple to use and can stop some bugs. That's just me though.
In response to VDZ
V_V..Ok to use it.
step(TARGET,DIR) // Target would be what is stepping, and DIR //can be either NORTH,SOUTH,WEST,EAST,etc :)
In response to Sniper Joe
Yes, I looked it up in the DM help. It works now. Thanks.