ID:166390
 
Heylo, I started learning to code not too long ago. But ever since I started I kept on trying to make more and go farther. I have 2 questions, and I would be grateful to anyone who had an answer.

The first question is: How would I get an NPC Mob to move on a certian path I want it to? (Example: I want "Bob" To move down 2 and left 2, but I want him to look like hes walking away) I can get the player to by using "usr.loc" which seems to work pretty well. But I dont know what to use for an npc to move.

My second question is: When I was editing the varible dir (While on the map) I cant get the mob to face left. I can get it to face in all other directions but that one. The icon does have 4 directions. But I don't understand why it wont face left...

I realise these are probably stupid questions, but I worked on icons for a long time, and now I want to learn how to code, even if it is just a little bit. Thanks for taking time to help out.

-Trogdor34
Trogdor34 wrote:
The first question is: How would I get an NPC Mob to move on a certian path I want it to? (Example: I want "Bob" To move down 2 and left 2, but I want him to look like hes walking away) I can get the player to by using "usr.loc" which seems to work pretty well. But I dont know what to use for an npc to move.

By setting a mob's loc, all you're doing is basically warping them to a new location. It's not very efficient to use this for a walking type motion, since a mob could really be warped to an entirely different map with just one call.

For specific movements, you might use the step() proc(press F1 in DM, go to Topic, and search for it). There are others, such as step_towards(), step_away(), etc.(Again, look them up via F1).

Along with those are the get_step_towards(), get_step_away()...(and so on).. procs that can be used to gather information. (F1 to look up, again. ;])

There are also similar walk() procs, which you can also read about via F1. ;)

My second question is: When I was editing the varible dir (While on the map) I cant get the mob to face left. I can get it to face in all other directions but that one. The icon does have 4 directions. But I don't understand why it wont face left...

Directions in DM are represented by integer constants 1-10(excluding 3 and 7, for some reason). These variables also can be represented in your source by things such as NORTH, SOUTH, EAST, WEST, etc. The following code will help you determine the integer representation to each direction, since you need the actual number when editing instances on the map:
mob/verb/Directions()
world << "NORTH: [NORTH]\nNORTHEAST: [NORTHEAST]\nEAST: \
[EAST]\nSOUTHEAST: [SOUTHEAST]\nSOUTH: [SOUTH]\nSOUTHWEST: \
[SOUTHWEST]\nWEST: [WEST]\nNORTHWEST: [NORTHWEST]"


I realise these are probably stupid questions, but I worked on icons for a long time, and now I want to learn how to code, even if it is just a little bit. Thanks for taking time to help out.

Not stupid at all; in fact, I'm glad that you were able to ask in an understandable manner---a big help in answering questions. If you need further help, feel free to ask.

Hiead
In response to Hiead
I just want to say thanks Hiead for helping me out. I didnt know about the help given by F1, so thank you again.

-Trogdor34
In response to Hiead
I understand on how to make the usr move. But I don't understand on how you would get an NPC to move. I tried several ways but I am unable to make the NPC move where and when I want it to. If you could help I would be most grateful.