ID:174304
 
is there a way to make "A" face "B"? or to find out whether or not "A" is facing "B"?

This would come in handy for combat and simulated dialogue.
<code>if (A in get_step(B, B.dir)) A << "[B] is looking at you. Be afraid. Be very, very, afraid."</code>
Xallius wrote:
is there a way to make "A" face "B"? or to find out whether or not "A" is facing "B"?

This would come in handy for combat and simulated dialogue.

To make A face B you would do

A.dir = get_dir(A,B) //Note: the order of A and B is important, if you switch them A will face away from B.

To see is A is facing B.
if(A.dir = get_dir(A,B)) //Note: the order has the same effect as in the first example.
// Do something


[Edit] Whoops I made a mistake on the second example there should be teo equal signs since it's a comparision. It should read:

if(A.dir == get_dir(A,B)) //Note: the order has the same effect as in the first example.
// Do something
In response to Crispy
Thanks!
I'll give it a try!
In response to Xallius
//ok, now it says that it cant read null direction
//here is the coding for the battle system test

mob
proc
attacking(mob/M as mob in oview(1))
var/mob
attacker
defender
attacker = src
defender = M
if(attacker in get_step(defender, defender.dir))
attacker << "attacking!"
In response to Xallius
Well, you're trying to read defender.dir when you get that error. Therefore "defender" must be null. It's being assigned the value of "M", which means that "M" must also be null. "M" is an argument to the attacking() proc. Therefore, you forgot to pass in the argument to the proc. Log-gick! =)
In response to Crispy
//erm.. unfortunately Im not sure how to pass it in the proc
//heres my coding for the verb and proc

mob
verb/attack(mob/M as mob in oview(1))
attacking()
proc/attacking(mob/M)
var/mob
attacker
defender
attacker = src
defender = M
if(attacker in get_step(defender, defender.dir))
attacker << "attacking!"