ID:268125
 
Whenever a monster kills me, it says ' killed you!'. It leaves a blank space, and does not show the monsters name. Heres the code:

    proc/Die_Mob(mob/M as mob)
if(src.health<=0)
if(src.client)
src.loc = locate(1,1,2)
src.health = src.maxhealth
src <<"[M] killed you!"
M <<"You killed [src]!"
else
src<<"You killed [M]!"
M.loc = locate(0,0,0)
del(M)


What's wrong here?

Thanks!

-Kappa the Imp
I'm not that good at this, but I think if you change the 'M' to src it would work. Not to sure though. I'll let you copy and paste what you should try:

proc/Die_Mob(mob/M as mob)
if(src.health<=0)
if(src.client)
src.loc = locate(1,1,2)
src.health = src.maxhealth
src <<"[src] killed you!"
M <<"You killed [src]!"
else
src<<"You killed [M]!"
M.loc = locate(0,0,0)
del(M)
In response to Lord Thantos
Lord Thantos wrote:
I'm not that good at this, but I think if you change the 'M' to src it would work. Not to sure though. I'll let you copy and paste what you should try:

proc/Die_Mob(mob/M as mob)
if(src.health<=0)
if(src.client)
src.loc = locate(1,1,2)
src.health = src.maxhealth
src <<"[src] killed you!"
M <<"You killed [src]!"
else
src<<"You killed [M]!"
M.loc = locate(0,0,0)
del(M)

Then the src would be telling itself that it killed itself.

-Kappa the Imp
Did you pass "M" through to the proc?
//Very lame example of an attack verb...
Attack(mob/M in oview(1))
M.hp -= 20
if(M.hp <= 0)
M.Die_Mob(src)

proc/Die_Mob(mob/killedby)
if(src.client)
src.loc = locate(1,1,2)
src.health = src.maxhealth
src <<"[killedby] killed you!"
M <<"You killed [src]!"
else
src<<"You killed [killedby]!"
src.loc = locate(0,0,0)
del(src)

If I'm not mistaken, src is the one being passed through the proc by default, and any extra mobs need to be passed through as variables like that.
In response to Lord Thantos
Lord Thantos wrote:
I'm not that good at this, but I think if you change the 'M' to src it would work. Not to sure though.

Don't give people advice if you don't know what you're doing. You'll just confuse the issue.

Lummox JR
Kappa the Imp wrote:
Whenever a monster kills me, it says ' killed you!'. It leaves a blank space, and does not show the monsters name.

As Enigmaster correctly diagnosed, you forgot to pass M (the killer) to this proc. But you also made another mistake:
proc/Die_Mob(mob/M as mob)
if(src.health<=0)
if(src.client)
src.loc = locate(1,1,2)
src.health = src.maxhealth
src <<"[M] killed you!"
M <<"You killed [src]!"
else
src<<"You killed [M]!"
M.loc = locate(0,0,0)
del(M)
Actually that's three mistakes, but one is minor.

Look at the output lines that tell the killer they've won. In the non-client case, you've mixed up src and M so that src, the victim, is told it killed M, the killer.

Best is to move the output line from the first case outside the if(src.client) block completely, and remove the line from the second case.
M << "You killed [src]!"     // tell the killer
if(src.client)
...
src << "[M] killed you!" // also tell the victim
else
...
The second mistake, the minor one, is that you're setting M.loc to locate(0,0,0), which is the same as null; just use null. Or better yet, don't use that line at all, since you're just going to delete the monster anyway.

The third mistake is that, again, you've mixed up M and src, and reset M's location (unnecessary) and deleted M, when you should have deleted src instead.

Chances are if this is working, it's because you're calling the proc inconsistently. Make sure it's always called for the victim, passing the killer as an argument. If you do it any other way, it's wrong.

Lummox JR