ID:223285
 
Keywords: code, help, i, need, please, the, with
mob
var
health = 20

verb
Attack(mob/M as mob in oview(1))
set category = "Commands"
if (usr.dir == NORTH)
if (M.loc = locate(usr.x,usr.y+1,usr.z))
var/damage = rand(1,10)
M.health -= damage
usr << "You hit [M] for [damage] damage!"
M:deathcheck()

proc
deathcheck()
if (src.health <= 0)
world << "[src] has been killed by [usr]!"
src.Move(locate(1,1,1))



above is the code, it has 1 error, it says
attack.dm:9:error: : missing expression,
and i dotn know what is wrong with it, please help.
nevermind, found answer! :)
FYI Next time you should post things within DM tags.
Like so..
mob
var
health = 20

verb
Attack(mob/M as mob in oview(1))
set category = "Commands"
if (usr.dir == NORTH)
if (M.loc = locate(usr.x,usr.y+1,usr.z))
var/damage = rand(1,10)
M.health -= damage
usr << "You hit [M] for [damage] damage!"
M:deathcheck()

proc
deathcheck()
if (src.health <= 0)
world << "[src] has been killed by [usr]!"
src.Move(locate(1,1,1))


Also, please post the solution of what exactly was going wrong, for reference in the future if people search.
In response to Flame Sage
Flame Sage wrote:
Also, please post the solution of what exactly was going wrong, for reference in the future if people search.

if (M.loc = locate(usr.x,usr.y+1,usr.z)) was missing an =
Why are you using the : operator? You're doing the things wrong. Also Flame Sage, you should put the tabs in the example, just saying.

mob
var/health = 20

verb/Attack(mob/M as mob in oview(1))
set category = "Commands"
if(src.dir == NORTH)
if(M.loc == locate(src.x, src.y+1, src.z)) // How Falacy said, you were missing a =.
var/damage = rand(1,10)
M.health -= damage
src << "You hit [M] for [damage] damage!"
M.DeathCheck()

proc/DeathCheck()
if(src.health <= 0)
world << "[src] has been killed by [usr]"
src.Move(locate(1,1,1))


Also you should use src instead of usr, it's the "same" but still.
In response to Ocean King
Ocean King wrote:
you should use src instead of usr

Not in verbs.
Why not? In most of the cases i only use usr in this:

obj/Test
icon = 'Test.dmi';
Click()
usr << "You clicked [src]"


EDIT: I Don't know if this is where i used it as i'm not going to check, lazyness.
In response to Yuuki Kei
Yuuki Kei wrote:
Not in verbs.

You should only use usr in mouse procs (like Click), and verbs that have a src setting (set src in X)
mob
var/health = 20

verb/Attack()
set category = "Commands"
for(var/mob/M in get_step(src, dir))
var/damage = rand(1,10)
M.health -= damage
src << "You hit [M] for [damage] damage!"
M.DeathCheck()
break

proc/DeathCheck()
if(src.health <= 0)
world << "[src] has been killed by [usr]"
src.Move(locate(1,1,1))


Here you go. It's a simple fix to your current code, and also works for all directions. It will also remove the error you'll get with using "oview" in a directional attack verb.

Using oview like that will result in you getting a useless options list if you attack a certain square with more than one target in range.

As such, it's better to ditch it entirely - In favour of a proc that locates the tile directly infront of you, before attacking any mobs in said tile.

~Xerif