ID:142523
 
Code:
    verb
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
if (HP <= 0)
usr << "[src] has died at your hands!"
del(src)
else
usr << "You attack [M]!" //send this message to the usr
oview() << "[usr] attacks [M]!" //send this message to everybody else
var/damage = rand(10,20) //assign a random # to a new variable between 1-10
world << "[damage] damage!" //tell the damage to the world
M.HP -= damage //take away the damage from M
M.DeathCheck()


Problem description:
Well, this is what I have now, and I just started to learn coding again. But when I attack an enemy, he doesnt die, it says he does, but he doesnt die, like, get deleted...
does ur DeathCheck() delete it?
In response to Reno Kujika
no... it doesnt get deleted at all...
Your going to need to post your deathcheck() proc, aside from that code being seemingly retarded, I see no major problems.
In response to Giantpanda
-_- just took a look, theres nothing in my deathcheck... lol. So I put it in, like Zilal's guide tells me too...

                M.DeathCheck()
if (HP <= 0)
world << "[src] dies!"
del(src)


but now I get the error code:
loading Testworld.dme
Testworld.dm:31:error: proc definition not allowed inside another proc

Testworld.dmb - 1 error, 0 warnings (double-click on an error to jump to it)
Well, your "if" check is checking against the attacker's HP, not the target's HP. I don't think that's what you intended.

The whole if block seems unnecessary. Your deathcheck should delete the mob if appropriate.
In response to Nathaneil
Check your indentation levels. You probably are trying to define DeathCheck() under a verb/proc/etc.
In response to Jmurph
your right about the IF thing, before it kept killing me instead of the enemy... lol

heres the code, I dont see anything wrong with the indentation:
    verb
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
usr << "You attack [M]!" //send this message to the usr
oview() << "[usr] attacks [M]!" //send this message to everybody else
var/damage = rand(10,20) //assign a random # to a new variable between 10-20
world << "[damage] damage!" //tell the damage to the world
M.HP -= damage //take away the damage from M
M.DeathCheck()
if (HP <= 0)
world << "[src] dies!"
del(src)


wait, do you mean the 'if' after the deathcheck?
In response to Nathaneil
Nathaneil wrote:
your right about the IF thing, before it kept killing me instead of the enemy... lol

heres the code, I dont see anything wrong with the indentation:
    verb
> attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
> usr << "You attack [M]!" //send this message to the usr
> oview() << "[usr] attacks [M]!" //send this message to everybody else
> var/damage = rand(10,20) //assign a random # to a new variable between 10-20
> world << "[damage] damage!" //tell the damage to the world
> M.HP -= damage //take away the damage from M
> M.Deathcheck()
> proc
> DeathCheck()
> if (HP <= 0)
> world << "[src] dies!"
> del(src)

You CAN'T define procs inside a verb.
In response to Nathaneil
uh...
btw, indention is WAY off probably, but eh
mob/proc
deathcheck() //rename to whatever the frick ya want.
if(HP<=0)
if(client) //or src.client. forgot, anyway, if your a PLAYER...
world<<"[usr] has died."
src.Move(locate(/turf/turfnamehere)) //it's recommended that turf doesnt have an icon state. place it anywhere on the map. some people teleport back to the start, for example.
else //your NOT a client, then.
world<<"[src] has been killed by [usr]" //eh, kinda nice to see once in a while.
del(src)
In response to Eternal Desire
Ack!! Im getting soooo confused -_- it would be easier if it was 1 on 1, like no delay in helping, so do you (or anyone) think you can help via AIM? (if so, just add me and IM me)

AIM: ShawksHockey34

Thanks peoples
why it is not working as do you want?:

delete
if (HP <= 0)
as we arent trying to check if the src is HP is 0 or less also the attacker is getting deleted by this line
 del(src)<dm>

so try this:

<dm>
verb
attack(mob/M in oview(1))
var/damage = rand(10,20)
src << "You attack [M]!"
view(src) << "[src] attacks [M] for [damage] damage!"
M.HP -= damage
M.DeathCheck(src)
proc
DeathCheck(mob/M)
if(src.HP <= 0)
world<<"[M] has been killed by [src]!"
else
return


Well, I am not sure about if you will like the death proc as it just tells to everyone that the attacker killed the 'M', so the rest of the deah proc is up for you

verb
attack(mob/M as mob in oview(1)) //attack a mob within 1 tile of you
var/damage = rand(10,20) //assign a random # to a new variable between 10-20
usr << "You attack [M]! [damage] damage!" //send this message to the usr
oview() << "[usr] attacks [M]! [damage] damage!" //send this message to everybody else
M.HP -= damage //take away the damage from M
if (HP <= 0) // This is the death check so you don't need a seperate function.
usr << "[M] has died at your hands!" // Tell yourself that you killed the punk.
oview() << "[M] has died at [usr]'s hands!" // Let everybody else know it too.
del(src)
In response to Hork
Thanks for trying, but that didn't work either, sadly... :(
Eh, I guess I can just play games while I figure it out...