mob
battle
verb
Attack()
set hidden=1
if (usr.jack==1)
if (usr.icon_state=="jackleft")
if (usr.attacking==0)
usr.attacking=1
flick("jacklefta",usr)
sleep(attackdelay)
usr.attacking=0
else
..()
ID:266719
Jun 2 2002, 5:33 pm
|
|
This is the code I have for my attacking, What I was wondering was how could I make it after it flicks the jacklefta icon state if it detects someone 1 space to the left of the usr it will attack him but if it doesn't it wont do anything.
|
Well, first we have to remember that BYOND doesn't think in terms of left and right, it uses east and west. Unfortunately for you, I don't think in terms of either. I'm going to take a stab and say that left is west. So, what we want to do is find the turf to the east of us.
var/turf/t = get_step(usr,WEST) Then, we want to see if there's a mob in that square. for (var/mob/m in t) do stuff here break If you want it to keep checking to see if there's more than one mob, you leave out the break. |
In response to Garthor
|
|
That's good, except that it doesn't specifically check a direction.
|
In response to Lesbian Assassin
|
|
I just noticed that after re-reading what he wanted. Oops. Edited my suggestion to provide an alternate for what he wanted (which will work for all directions, I might add).
|
...
...
break