ID:141182
 
Code:
DeathCheck(mob/killer)
if (src.HP <= 0)
world << "[src] was killed by [killer]!"
killer.xp += src.mxp
if (src == usr)
src.loc=locate(1,1,1)
src.HP = 15
else
var/X = src.x
var/Y = src.y
var/Z = src.z
src.loc=locate(rand(1,1000), rand(1,1000), 2)
sleep(50)
src.loc=locate(X, Y, Z)

Attacked(mob/atk)
src.DeathCheck(atk)
if (!src)

else
sleep(10)
src.DeathCheck(atk)
if (!src)

else
var/dmg = src.str - atk.def
s_damage(atk, dmg, "blue")
src.HP -= dmg
attack(mob/M as mob in oview(1))
set category = "Skills"
if (M == usr)
src << "You attack [M]!"
M << "[usr] attacks you!"
//var/dmg = 1 //Testing Purposes
var/dmg=src.str-M.def //Reg one
s_damage(M, dmg, "blue")
M.HP -= dmg
M.DeathCheck(usr)
src.LevelCheck()
else
src << "You attack [M]!"
//var/dmg = 1 //Testing Purposes
var/dmg=src.str-M.def //Reg one
s_damage(M, dmg, "blue")
M.HP -= dmg
M.DeathCheck(usr)
src.LevelCheck()
if (!M)
src << ""
else
M.Attacked(usr)


Problem description:

For some odd reason, instead of attacking the moster right infront of me, I attack the monster to the upper right corner. Also, i can sometimes attack things that aren't there, but weren't there.

Thanks in advance.
Neos300 wrote:
>                   var/X = src.x
> var/Y = src.y
> var/Z = src.z
> src.loc=locate(rand(1,1000), rand(1,1000), 2)
> sleep(50)
> src.loc=locate(X, Y, Z)


Looks like you've ignored some useful things said to you in your previous topic. ;) Also, you should use spawn() instead of sleep() in such cases, because the latter causes the entire proc chain to be delayed and have to wait as well, instead of just continue immediately/normally. f.ex. in your code, it doesn't let the attack() verb proceed for 5 seconds. Lastly, I would fork this code over into a different and a new proc, but that's not *necessary*.

Also, no put usr in proc.

For some odd reason, instead of attacking the moster right infront of me, I attack the monster to the upper right corner.

Nothing's odd at all. You've configured the verb to use a selection of mobs in oview(), so that's pretty much how it works. Unless I understand you incorrectly.

Also, i can sometimes attack things that aren't there, but weren't there.

I could guess of course, but anyway, this doesn't really make sense. =P
In response to Kaioken
Thanks.