ID:2065216
 
When i use the attack verb infront of nothing it keeps making me attack myself.Like..

Raydar attacks Raydar for 100 damage.
You attack Raydar for 100 damage.

And i end up dying everytime. I problem isn't the attack verb i think.

mob/proc
Damage2(var/mob/M)
var/damage=Str//
M.HP-=damage
src<<"You attack [M] for [damage] damage!"
M<<"[src] attacks you for [damage] damage!"

This is a peice of how Damage is taken and given.
You'd have to show your attack function and how it calls Damage2().
Damage(var/mob/M)
var/damage=Str//
M.HP-=damage
src<<"You attack [M] for [damage] damage!"
M<<"[src] attacks you for [damage] damelage!"
if(M.HP <= 0) M.DeathCheck(src)

Punch()
//set hidden=1
if(usr.Attacking) return
var/mob/M=locate(/mob) in get_step(src,dir)
if(M)
Damage(M)
usr.Attacking=1
spawn(4) if(usr) usr.Attacking=0
flick("attack",usr)
Damage2(var/mob/M)
var/damage=Str//
M.HP-=damage
src<<"You attack [M] for [damage] damage!"
M<<"[src] attacks you for [damage] damage!"
Punch2()
var/mob/M=locate(/mob) in get_step(src,dir)
if(M)
Damage(M)
usr.Attacking=1
spawn(4) if(usr) usr.Attacking=0
flick("attack2",usr)
Thats the code for Damage
In response to DragonRador2
I'd highly recommend placing code into DM Forum-formatted structure using the dm and /dm tags surrounded by <>'s.
Like
<#dm>
Code goes here.
<#/dm>
without the #.

It will look like this:
    Damage(var/mob/M)
var/damage=Str//
M.HP-=damage
src<<"You attack [M] for [damage] damage!"
M<<"[src] attacks you for [damage] damelage!"
if(M.HP <= 0) M.DeathCheck(src)

Punch()
//set hidden=1
if(usr.Attacking) return
var/mob/M=locate(/mob) in get_step(src,dir)
if(M)
Damage(M)
usr.Attacking=1
spawn(4) if(usr) usr.Attacking=0
flick("attack",usr)
Damage2(var/mob/M)
var/damage=Str//
M.HP-=damage
src<<"You attack [M] for [damage] damage!"
M<<"[src] attacks you for [damage] damage!"
Punch2()
var/mob/M=locate(/mob) in get_step(src,dir)
if(M)
Damage(M)
usr.Attacking=1
spawn(4) if(usr) usr.Attacking=0
flick("attack2",usr)


I also recommend not to copypasta code which is clearly visible from your code. There's use of usr and there's use of src, which is conflicting in code-grammar.

Also, you may want to re-think your approach about this all. Damage() and Damage2() should all just be one procedure where you pass a /mob and a value, then return any result indicating the /mob dying and continue from there.
@maximus: HTML entities:

&lt; = <

&gt; = >

&amp; = &

&copy; = ©

Useful for letting people know about how to use HTML tags.
the best way to do it/simplest for beginners.
mob/var
Health = 100
Strength = 10
Defence = 10
attacked = 0

mob
proc
fistAttack(mob/M)
getDamage(damageAmount)
deathCheck()

fistAttack(mob/M)
if(attacked)
return
attacked = 1 ; flick(src,"Attack")
var/damageAmount = round(Strength / M.Defence)
if(M) for(M in get_step(src, dir))
M.getDamage(damageAmount)
sleep(5) ; attacked = 0

getDamage(damageAmount)
if(Health < 0)
return deathCheck()
Health -= damageAmount

deathCheck()
if(Health < 0)
loc = locate(1,1,1)
In response to Hebrons
To be honest, I wouldn't even try to calculate damageAmount until after a target has been found. That's just extra logical power not needed. Also, unless there's a need to check if Health is < 0 elsewhere besides getDamage(), just include it within getDamage(). The only other instance I can think of deathCheck() would be used is debugging/moderation tools.

Also, if(M) for(M in get_step(src, dir)) is a wonky way of getting a possible target within a step from the user.
In response to Ter13
Ter13 wrote:
Useful for letting people know about how to use HTML tags.

Yeah. I knew they existed in theory but the memory of what they were just flew past me.
as i said we are trying to build a foundation of something he can get a jist from.. not entirely throw everything at him.. heres a snippet of one of my actual Combat code's although i improved but here
    punch(var/player/target)//seperate the melee_punch to different section's Cooldown(), Calc_dmg(), Check_Condtion(),
if(client && src) // if the player is client.
if(check_cool_down("attack") || stat["stamina"] < 1|| icon_state == "Panting")//args src.isdead ||frozen || busy ||
return
src.cool_down("attack", 5)
var/attack_state = pick("Left Punch","Right Punch")//, "Left Punch", "Right Kick", "Left Kick")
flick("[attack_state]",src)
attack(target)

kick(var/player/target)
if(client && src)
if(check_cool_down("attack") || stat["stamina"] < 1 || icon_state == "Panting")
return
src.cool_down("attack", 5)
var/attack_state = pick("Left Kick","Right Kick")
flick("[attack_state]",src)
attack(target)

attack(var/player/target, dmg)
src.stat["stamina"] = sub(src.stat["stamina"], 2.5)
if(stat["stamina"] < 0)
regenerate("Stamina", 10)

for(target in obounds(src,dir))if(dir == get_dir(src, target))
if(target.isdead)
return

else if(target.stat["health"] <= 1)
target.death_check() ; rem_target(target)
return
if(prob(target.stat_gain_rate))
gain("Reflex")
//gain("Vitality")
if(prob(stat_gain_rate))
gain("Taijutsu")

src.dir = get_dir(src, target)
set_target(target)

if(prob(crit_hit_percentage))
dmg = round(abs(src.stat["taijutsu"] / target.stat["reflex"])) + src.crit_gain_amount
spawn() target.knock_back(src, 5, dir)
else dmg = round(abs(src.stat["taijutsu"] / target.stat["reflex"]))

target.take_damage(dmg)
x_damage(target, dmg)

client.quake(2, 5, SLP = 0)
target.UpdateHealth()

now what's easier to understand?, exactly. but i understand your argument we dont want to teach him bad habit's that are harder to shake off later.
So i should change my whole attack system and damage system?
somewhat.. just dont get ahead of yourself.. and remove the unnecessary lines.