Page 1 of 1

Sleep used in onHitMonster does not work

Posted: Sun Mar 22, 2015 3:07 am
by David Ward
We've got a spell that spawns a short puff of cloud on the tile immediately in front of a player, and we want that cloud to put any monster it hits to sleep on impact. The code we tried using (inserted at the end of the cloud object's TileDamager component) looks like this:

Code: Select all

	onHitMonster:function(self, monster)
		monster:setCondition("sleep",10)
		monster:showDamageText("test")
	end,
If we replace the word "sleep" with "burning", "frozen", "poisoned", or "stunned", it sets the condition correctly, but when we hit a monster with the sleep version, nothing happens. The monster takes the damage from the TileDamager, and the word "test" appears over the monster, but there's no sleeping, and there's no error message indicating why not. Can anybody help?

Re: Sleep used in onHitMonster does not work

Posted: Sun Mar 22, 2015 9:01 am
by minmay
There are two likely causes here:
1. Some monsters are immune to sleep. Make sure you use one that isn't, like a fjeld warg.
2. If a sleeping monster is damaged it wakes up. If the TileDamager damage applies after the onHitMonster hook is called then it will wake the monster up right away and may not even show the "Zzz" text.

Re: Sleep used in onHitMonster does not work

Posted: Sun Mar 22, 2015 12:35 pm
by JohnWordsworth
I suspect it's number 2 like MinMay said - the damage is likely waking up the creature instantly after you put it to sleep.

You might want to try using a delayed call with the smallest possible value to call a method which puts the creature to sleep a fraction of a second later.

Re: Sleep used in onHitMonster does not work

Posted: Mon Mar 23, 2015 7:26 pm
by David Ward
That would make sense....because the other conditions work fine...but they don't have that stipulation of being hit and then waking up. Hmmm logic. Thank you.