ID:175531
 
If I have a turf e.g.
turf
Floor
icon = 'Turf.dmi'
icon_state = "Floor"
and a Mob e.g.
mob/npc/A669
icon= 'NPC.dmi'
icon_state="A699"

how can I make the mob, go along the turf without turning around or anything? (e.g. make it follow a set path)
Don't cross-post.
In response to Crispy
Crispy wrote:
Don't cross-post.

Nobody was replying to my other one, so i thought it might be in wrong section, so i put it here hoping for HELP!
In response to Gokuss4neo
No one answered because you didn't give them time. This post started less than an hour after your original. Give people a day or so to read your post before you bump, and never cross post. If a post is in the wrong place, a moderator will move it.

That said, I'll give you a break since you are new. ;)

If you want mobs to run along a certain track, one easy way would be to make the mob turn the direction that the turf faces and take a step.

mob/npc/A669
New() // when the mob is created
..() // do the default New() stuff
spawn() // start a new program thread so New() can finish
while(src) // do this loop as long as the mob exists
sleep(5) // a brief delay
if(isturf(loc)) // if the mob is standing on a turf
// take a step in the direction the turf faces
Step(src,loc.dir)

In response to Shadowdarke
Just to add some information to what Shadowdarke said: Every atom can have a direction. You can for example make water turfs that face east, or south, or north, etc., and automatically "float" things along. To give a direction to your turfs, all you have to do is go into the map editor and create instances with dir=NORTH, dir=WEST, etc., then add those to your map. (Or you could manually edit each turf.) I can't imagine it'd be too fun to set the track up, though, since it'd be impossible to see which way the turf faced.

I'd like to make a suggestion for that that could help you. Make an icon file, track.dmi, in which you have a single icon. The icon should be a "movie" type, with only 1 animation frame, and 4 or 8 directions. Draw an arrow for each direction pointing that way.

Now, add something like this to your code:
// put a // comment in front of this line to remove the arrows
#define SHOW_TRACKS 1

#ifdef SHOW_TRACKS
obj/trackarrow
layer=100
icon='track.dmi'
#endif

turf
#ifdef SHOW_TRACKS
overlays=list(/obj/trackarrow)
#endif
If I remember overlays correctly, they should not only show up in the map editor, but the direction of the icon should match the atom they're attached to. So every turf will now have an arrow on it in your map editor, once you compile. (I'd close the map, compile, then edit the map again.)

Lummox JR
In response to Shadowdarke
mob/npc/A669
New() // when the mob is created
..() // do the default New() stuff
spawn() // start a new program thread so New() can finish
while(src) // do this loop as long as the mob exists
sleep(5) // a brief delay
if(isturf(loc)) // if the mob is standing on a turf
// take a step in the direction the turf faces
Step(src,loc.dir)
it says :Race.dm:23:error:Step:undefined proc
In response to Gokuss4neo
Gokuss4neo wrote:
Step(src,loc.dir)
it says :Race.dm:23:error:Step:undefined proc

This was just a minor mistake on Shadowdarke's part. He meant step(). Usually, built-in global procs are lowercase and datum procs are capitalized.

Lummox JR
In response to Lummox JR
Thank you
In response to Lummox JR
Erm..I just tried to make the map and the Arrow didn't show up.
In response to Gokuss4neo
Gokuss4neo wrote:
Erm..I just tried to make the map and the Arrow didn't show up.

Sorry, the arrow DOES show up while playing, but not in map editor.
In response to Shadowdarke
As a slight change, you might want mobs to walk a patrol over turfs in different directions, like a mob that walks between the 2 X's back and forth...

XOOOOOX

A way to solve that is to simply add a few lines to that:
mob/npc/A669
New() // when the mob is created
..() // do the default New() stuff
spawn() // start a new program thread so New() can finish
while(src) // do this loop as long as the mob exists
sleep(5) // a brief delay
if(isturf(loc)) // if the mob is standing on a turf
if(loc.dir) //If the dir is not 0

// take a step in the direction the turf faces
step(src,loc.dir)
else
// otherwise, step in the current direction
step(src,src.dir)

Then, the turfs can set their dir to 0 in order to allow mobs to just continue walking in their current direction, so the directions of the turfs would be...

4000008
(4 being east, 8 being west, so...)
-----<

Thus allowing the mob to go over the same turf and go different directions.