ID:264904
 
Code:
mob/Monsters
Green_Slime
// Information for that mob is in here then...
proc
Death_Check()
if(Health <= 0)
invisibility = 101
density = 0
spawn(400)
invisibility = 0
density = 1
Health = Max_Health


Problem description:
The density is changed to 0 but the monsters aren't made invisible, however... When I leave the density stuff out they become invisible. I have no idea what's going on. Any ideas?

Thanks.

You know you're using spawn() incorrectly? Look it up. Requires indentation.
In response to Emasym
Emasym wrote:
You know you're using spawn() incorrectly? Look it up. Requires indentation.

The issue is that it doesn't require indentation, and the behavior when you don't use indentation is incredibly arbitrary. However, because it's still technically correct, no errors or warnings are thrown, and so people don't find out about the mistake until things don't behave properly.
In response to Garthor
I've always wondered why it doesn't throw a compile error.

Long story short, though, code won't do what he expects.
In response to Emasym
Wow that was a weird problem. You're absolutely right, just because it doesn't throw an error doesn't mean there wasn't an issue with my indentation and thus I never noticed it.

Here's the solution, very simple.

    proc
Monster_Death_Check()
if(src.Health <= 0)
src.density = 0
src.invisibility = 101
spawn(400)
src.density = 1
src.invisibility = 0
src.Health = Max_Health
In response to Kyle_ZX
Incidentally, instead of a whole lot of mobs running around invis, why not set their loc to 0, then place them back on their initial() loc?
In response to Emasym
You're right that's a way to do it but I don't see how it's more effective. I stop the monsters from moving too so the result is the same.
In response to Kyle_ZX
On second thought, now I notice that I'm using walk_to to make them follow the player which is hard to stop so using your loc method is actually easier and probably a few calculations more efficient.

    proc
Monster_Death_Check()
if(src.Health <= 0)
Alive = 0
loc = 0
spawn(400)
Alive = 1
loc = initial(loc)
src.Health = Max_Health


Alive isn't there now too help my other code, it's there just so I can keep track of how many monsters are dead for later.