Sleep used in onHitMonster does not work

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
David Ward
Posts: 103
Joined: Wed Jan 07, 2015 11:44 pm
Location: Vancouver, BC, Canada

Sleep used in onHitMonster does not work

Post 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?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Sleep used in onHitMonster does not work

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Sleep used in onHitMonster does not work

Post 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.
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
David Ward
Posts: 103
Joined: Wed Jan 07, 2015 11:44 pm
Location: Vancouver, BC, Canada

Re: Sleep used in onHitMonster does not work

Post 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.
Post Reply