ID:1582741
 
(See the best response by Ter13.)
So I've started to introduce ShadowDarke's PP library into a project of mine and I was wondering how I would go about making sure that the client faces their target within a certain range.

eg. You enter game, double click another player (target) and once you're within x tiles you face them, like a Mexican stand off kinda thing. Any ideas?
Best response
Move() allows you to override the direction that the movable object will face when attempting to move by specifying Dir.

Given a little bit more work, this system can be expanded to be quite sophisticated.

#define STANDOFF_DIST 5

mob
combatant
var/tmp
mob/combatant/target
proc
Targeted(mob/combatant/c)
//check if the this is a valid target for c
if(c!=src && istype(c,/mob/combatant))
c.Target(src)

Target(mob/combatant/c)
//you can do additional checks here if you need
src.target = c

Move(atom/NewLoc,Dir=0,step_x=0,step_y=0)
if(target && src.target.z==src.z && get_dist(src,target)<=STANDOFF_DIST)
Dir = get_dir(src,target)
return ..(NewLoc,Dir,step_x,step_y)

DblClick()
src.Targeted(usr)
Is there any reason inparticular that you define the distance instead of using a num in the Move proc or is that just something you do? :)
I don't know what your preferences are, so I just want to make it clear that 5 was an arbitrary choice.

I do tend to use preprocessor definitions, rather than embed the behavior directly. It makes the game quite a bit easier to adjust for changes down the road.
Okay, I was wondering if there was some advantage to definitions as opposed to embedding in this situation. Thanks. :)
Would there be a way to make it so that the player would face their target with pixel precision? As in, you face your opponent even at an angle?

Sorry, I've just finished my whole implementation and it's odd to see projectiles firing with such precision when you're aiming only roughly in their direction.

Thanks in advance. :)
Yeah, but it's going to require either a non-projected perspective for your whole game, or generating more than 8 directional states, which can be time-consuming and costly.

Either way, it's not really a question.
Ahhh, okay then. Thanks!