Attack(mob/M as mob in view(1))
if(M.life >= 1 && usr.delayed == 0 && M.attackable == 1 && usr.canattack == 1)
M.Damage(((usr.strength*0.8)+rand(usr.strength/5,usr.strength/3))/(M.resilience/3))
var/ow = M
ow = M.Damage()
view() << "[usr] hit [M] for [ow] !"
usr.delayed = 1
usr.await = 30 - (usr.speed/4)
sleep(usr.await)
usr.await = 0
usr.delayed = 0
if(M.Damage() >= M.life)
M.KO()
if(usr.delayed == 1||usr.canattack == 0)
M.life += 0
if(M.ko == 1)
view() << "[usr] is about to kill [M]"
switch(alert("Do you want to kill them?",,"Yes","No"))
if("Yes")
if(M.NPC == 1)
view() << "<font color = maroon> [usr] kills [M]!"
del M
if(!NPC)
view() << "<font color = maroon> [usr] kills [M]!"
M.contents = locate(M.loc)
M.loc = locate(/turf/dead)
if("No")
view() << "[usr] gave mercy on [M]."
M.loc=M.loc
//------------------------------//
mob
proc
Damage(D)
life = life - D
KO()
src.ko = 1
canattack = 0
view() << "<font color=yellow>[src] is unable to stand by themselves!"
sleep(120)
view() << "<font color=yellow>[src] wobbled back to their feet!"
src.ko = 0
src.canattack = 1
Problem description:
Hello Forum people. Above is the Attack verb, KO proc and Damage proc. It basically allows the attacking of a mob in view range 1, with a delay to allow manipulation of attack speed. I have several issues. The first issue I have is, how do I make it so that it attacks what is in the direction the usr is faceing, rather than anything in a radius around the usr? Also, when the player "kills" an npc this pops up in Dream Seeker :
runtime error: Cannot read null.loc
proc name: Attack (/mob/verb/Attack)
usr: Jin150 (/mob)
src: Jin150 (/mob)
call stack:
Jin150 (/mob): Attack(null)
runtime error: Cannot read null.ko
proc name: Attack (/mob/verb/Attack)
usr: Jin150 (/mob)
src: Jin150 (/mob)
call stack:
Jin150 (/mob): Attack(null)
However, when a normal player is killed, everything runs as planned (I.E teleporting the player to the specified turf).
My final problem, is the message that displays attack damage looks like this in game: Jin150 hit Jin150 for !
I can't for the life of me, get the Damage() number to show xD.
Well thank you for reading this if you did, and any responses will be greatly appreciated :) (I should probably point out now that I am learning to use DM properlly as I make this game XP )
Try that one
Attack(mob/M in get_step(usr,usr.dir))