ID:145111
 
Code:Attacking System
mob
verb
Attack(mob/M as mob in oview(1))
var/damage = rand(1,15)
usr << "You attacked [M] for [damage] HP!"
if(src.client)
src << "[M] attacked you for [damage] HP!"
M.hp -= damage
usr.deathcheck(M)
if(src.client)
M.exp+=rand(50,300)
M.Levelup()
else
return ..()
proc
deathcheck(mob/M as mob)
if(M.hp <= 0)
if(M.client)
M.loc = locate(1,1,1)
M.hp = M.maxhp
M << "[src] killed you!"
else
M.hp = 100
usr << "You killed [M]!"
M.loc = locate(rand(1,world.maxx),rand(1,world.maxy),rand(1,world.maxz))
proc
attackplayer()
for(var/mob/M in oview(1))
if(get_step_away(src,M,1))
if(M.client)
continue
else
src.Attack(M)
else
return ..()
spawn(20) attackplayer()
move()
for(var/mob/M in oview())
if(get_step_away(src,M,3))
if(!M.client)
continue
else
walk_to(src,M,1,2)
else
continue
Levelup()
if(src.exp >= src.maxexp)
src.lvl++
src.exp = 0
src.maxexp*=2
src<<"You gained a level!"
src.Statup()
Statup()
src.maxhp+=20
src.hp=src.maxhp
src.strexp+=rand(50,300)
src.defexp+=rand(50,300)
src<<"Your stats increase!"
if(strexp == src.strmaxexp)
Strup()
if(defexp == src.defmaxexp)
Defup()
Strup()
if(src.strexp >= src.strmaxexp)
src.str++
src.strexp = 0
src.strmaxexp*=2
src.str += 1
src << "You gained a Strength Level!"
Defup()
if(src.defexp >= src.defmaxexp)
src.def++
src.defexp = 0
src.defmaxexp*=2
src.def += 1
src << "You gained a Defence Level!"
New()
attackplayer()
move()


Problem description:For some reason whenever I get in and start to attack a monster it says i got the same amt of hp taken away as the monster did.. i get no errors when i compile.. I do not know the problem I have been trying to figure it out.. But I don't know.

Thanks

ShimmyShine


No usr..

            usr << "[M] attacked you for [damage] HP!"
if(src.client)
src << "You attacked [M] for [damage] HP!"


Change that usr to M
In response to A.T.H.K
I changed that and it didn't fix my main problem..

My problem which I think i stated might be wrong though is that When ever I get close to one it auto attacks it and it autoattacks me.. what i want is it to atuo me but not me atuo attack it also it tells me I attack myself twice whenver it attacks..
In response to ShimmyShine
Attack(mob/M as mob in oview())


Thats your problem try
Attack(mob/M)
In response to A.T.H.K
Well I did that and instead of me attacking it and it attacking me at same time.. it does it twice at a time.. lol
In response to ShimmyShine
If you made the code you can fix the misstake its not even hard a battle system like this is one of the easist things to code.
In response to A.T.H.K
I know.. But I have been trying to fix it and i can't find the error.. I don't know exactly what the problem is.
In response to ShimmyShine
            usr << "[M] attacked you for [damage] HP!"
if(src.client)
src << "You attacked [M] for [damage] HP!"


You're telling <code>usr</code> (= the attacker) that he attacked <code>M</code>. Yet, then you're checking if the <code>usr (src=usr in mob/verb)</code> has a client, then telling the <code>usr</code> he attacked <code>M</code> AGAIN. You were just a bit fuzzy when you wrote this. ;)
In response to Mysame
Yah it was 4 in the morning when I wrote that, So what do I do make it what your example looks like? (I am too new to be able to even fix my stuff..... sadly..)