ID:272688
 
Okay, how would I make it so you can only attack the person infront of you're charater that stumped me...
You might find dir, get_dir and oview interesting to read on.
In response to Schnitzelnagler
Well, I got.
Punch(mob/Player/M in oview(1))


I need to know how from an example of how to make it so they only attack what's infront of them.
In response to Gizhy Games
Gizhy Games wrote:
I need to know how from an example of how to make it so they only attack what's infront of them.

Did you read on dir and get_dir as I suggested?

If so, what kind of problem did you face?
Unless you just want to avoid all work and just have others code (parts of) your game.
In response to Schnitzelnagler
I wouldn't ask for help if I knew how to do it, and secondly I wouldn't be making a game if I was lazy......


I need an example of how to use the get_dir and such, to make the mob/Player/ attack what's infront of them.

And thanks for you're help.
In response to Gizhy Games
Such an example should be in the DM Guide, if not the DM Reference. I'll double check to make sure.
In response to Gizhy Games
get_dir(Loc1,Loc2) returns the direction from Loc1 to Loc2.
The dir variable holds an atoms direction.

If you would compare the two, you'd know if "Loc2" was in the direction "Loc1" is facing, just as an non concrete example.
In response to Mizukouken Ketsu
Okay so there isn't an example coding snippet, but they explain it in a way that makes it easy to understand.

Format:
get_dir(Loc1,Loc2)

Returns:
The direction from Loc1 to Loc2. Possible results are NORTH, SOUTH, EAST, WEST, NORTHEAST, NORTHWEST, SOUTHEAST, and SOUTHWEST. An approximation will be made if the true direction is not exactly in line with one of these.

Args:
Loc1: An object on the map.
Loc2: An object on the map.

If the direction is not directly lying along one of the four primary cardinal directions, the result will become the nearest diagonal direction (eg. if Loc2 is mostly north but a little to the east of Loc1, the direction returned will be NORTHEAST).
In response to Mizukouken Ketsu
Please correct me if I'm wrong but is this the proper way to put it.
Kick(mob/Player/M in get_dir(usr.loc,M.loc))

I want them to only hit the person infront of them.
In response to Gizhy Games
If you read the reference, get_dir() returns a direction, not a location or a list, therefore you can't use it with in.
Though, what you really want is this.
In response to Kaioken
Yes, you can use get_dir() with in. I use it all the time when I want an attack verb to only hit the person in front of the usr, and it works 100% the way I intended it.

e.g.
mob/verb
Attack(mob/M in get_step(usr,usr.dir))
var/dmg = usr.str*1.5
M.Health -= dmg
view(M)<<"[M] took [dmg] damage from [usr]!"
M.Death_Check(usr)


:D That simple!
In response to Mizukouken Ketsu
Mizukouken Ketsu wrote:
Yes, you can use get_dir() [...]

You mean get_step(). <,<
In response to Kaioken
Okay I really need to read for all our sakes...
In response to Mizukouken Ketsu
Well thank you, you've fixed my problem.
In response to Kaioken
Kaioken wrote:
If you read the reference, get_dir() returns a direction, not a location or a list, therefore you can't use it with in.
Though, what you really want is this.

That depends on the design of the game.
If your game is using an automatically continued attack (opposed to the click/key spamm) and you want to avoid someone attacking something not in their direction, checking the dir and get_dir might be better.
Though I agree, for a simple click attack, repeat step one kind of game get_step is the solution of choice.