ID:1138583
 
Keywords: attack, coding, hit, miss, verb
(See the best response by Dipic.)
Code:
    verb
Attack()
if(src.canattack==3)
return 0
src.canattack += 1
var/g=src.canattack
freeze(7)
flick("Attack[src.canattack]",src)
for(var/mob/character/m in get_step(src, dir))
world << m
var/Damage=max(0,src.Str-m.Def)
flick("Hit",m)
step(m,WEST)
step(m,m.dir)
step(m,WEST)
m.dir=EAST
Bump()
if(src.canattack==3)
m.KnockBack(2)
view(m)<<"[src] hit [m] for [Damage] Damage!"
m.Deathcheck()
spawn(10)
if(src.canattack==g)
src.canattack = 0
return 1


Problem description:
this is my completed attack verb, but for somereason when i test it out, it doesnt hit. or atleast doesnt look to me like its hitting...I added the view(m)<<"[src] hit [m] for [Damage] Damage" to test out if i was actually hitting. but it looks like im not. is this a problem with the coding? or something else like an icon issue?
Best response
Is it outputting each "m" that is in the beginning of your loop to the world? If it's getting that far, the rest of that loop should be fine. Your canattack check at the bottom seems a little odd, but it should work as well.

Everything looks OK, as long as the mob you're trying to hit is indeed a /mob/character. Is there a chance that the mob you're attacking is only a /mob, or some other type of /mob that isn't /mob/character?
all the mobs i created branch off from mob/character so that part is correct, and since all the "m" things involve actually hitting another mob/character which is what i cant seem to do, i have no way of telling if it is correctly outputting it. But the flick,freeze, and spawn parts of attacking do work correctly.
Ah that was the problem! i looked into the mob/character branches i created, and it just happened that the one mob i was attacking did not branch off from it. Thx alot for the help!
Great to hear! Glad I could help.