ID:263015
 
You see, this works fine most of the time. The problem is what happens when the attacked mob moves away (or dies) in the 4/5ths of a second between adding and removing the animation. This is the add/remove animation code:
atom/proc
addOverlay(icon_file, state)
var/image/A = image(icon_file, icon_state=state)
A.layer = MOB_LAYER + 55
src.overlays += A
removeOverlay(icon_file, state)
var/image/A = image(icon_file, icon_state=state)
A.layer = MOB_LAYER + 55
src.overlays -= A

... and this is the implementation of those procs - in an attack proc.
// This is part of a larger proc
M.loc.addOverlay('Attacks.dmi', "DA")
spawn(8)
M.loc.removeOverlay('Attacks.dmi', "DA")

I tried using a /turf/var to store M.loc and using that, but it had the same effect.

When this happens and the attacker is me, I get a runtime error. Otherwise, I don't. The error is a Cannot find null.loc-flavor error.

What could I do to fix this?



--Vito
I know you said you tried it, but maybe you mistyped something:
// This is part of a larger proc
var/turf/T = M.loc
T.addOverlay('Attacks.dmi', "DA")
spawn(8)
T.removeOverlay('Attacks.dmi', "DA")

In response to DarkCampainger
No, the ".loc." is there on purpose. It's there so the animation will linger a half-second or so when you kill something - ortherwise, you could never see it when you can 1-hit monsters.


--Vito
In response to Vito Stolidus
Maybe just try putting a little bit of a sleep into your death check code, to wait for the icon overlay to finish what it needs to before deleting the overlay.
In response to Satans Spawn
Seeing as you normally pass the killer as an argument in the DeathCheck() proc, why not try changing it in there?
In response to Satans Spawn
I would recommend moving the mob to 0,0,0 as soon as he dies, then wait about a minute to remove him. This would give plenty of time for all procs to finish thier work on him, and remove him from anyplace the player could still hit him. I ran into simuliar problems back when I was a newbie. Constant runtimes from the mob being deleted in the middle of another proc. I never thought of that solution back then, wish I would have.
In response to DarkCampainger
Try this.
// This is part of a larger proc
M.addOverlay('Attacks.dmi', "DA")
spawn(8)
if(M)//This will make sure the mob still exists
M.removeOverlay('Attacks.dmi', "DA")

You may need, if you havent already, anoter removeOverlay() in the death check.

(Supaz)
In response to Mysame
There are many different attacks possible, but that might work - for half the problem. When you hold down the arrow key (bump to attack-style combat) you rush past when the enemy dies - and the attack overlay on you remains forever. That's over half of the problem.

--Vito
In response to Vito Stolidus
Did you move the mob off the map and put in a wait time? Chances are, this would fix your problem.
In response to Scoobert
I fixed it with a variant of Mysame's idea:

mob/Dcheck(mob/M)
if(!src) return
if(Mhealth == null) return // if max health is null ignore the death
if(Health <= 0) // if health is less than 1
M.removeOverlay('Attacks.dmi', "DA")
src.removeOverlay('Attacks.dmi', "DA")


I had a brainstorm and added that src.removeOverlay to Mysame's idea - and the problem dissapeared where it occurred before. Thanks guys.


--Vito