ok well im trying to get a monster to change its looking direction to face the attacker.
so i have a theory to somehow set the M.dir to the opposite of the attackers. so if its West set to East so they will be facing each other. I cant seem to make a formula to get this done other than a bunch of If/then commands.
please help.
ID:272591
Oct 7 2008, 11:12 am
|
|
In response to Jeff8500
|
|
my game only uses North, South, East, West
|
In response to Chase_Hammer
|
|
Then create your own get dir proc. If the absolute value of the X distance is greater than the absolute value of the Y distance, then the direction should be north or south. Then its a matter of checking true/false. In my game, I created my own proc to do this, though I'm not especially proud of it >_>
|
Use a list.
var/list/RevDir = list(2,1,,8,10,9,,4,6,5)
Then set the monster's direction to RevDir[attcker's direction]. If your monster is M and your attacker is A, then you'd use: M.dir = RevDir[A.dir] For just N,S,E and W, use this list instead:
var/list/RevCardDir = list(2,1,,8,,,,4,,)
|
atom/proc/FaceObject(atom/a) |
In response to Xooxer
|
|
List? Why not just use the turn() proc?
|
In response to Popisfizzy
|
|
He already said he only wanted the cardinal directions :P
|
In response to Jeff8500
|
|
Well, in that case:
<dm> |
EDIT: If you were to use a formula, you would need to use bits. I'm pretty sure dir = ~enemy.dir would work for that (wait no, nevermind; that would only partially work by giving you a lump of every dir that they aren't facing! EX: Northeast to southwest, north to east|south|west).