Page 1 of 1
How to make a monster spawn a poison cloud on death
Posted: Fri Jan 17, 2014 12:25 pm
by LocalFire
I'd like a custom monster to spawn a poison cloud on death, so far I've tried using an onDie hook and it works when I test it with a blockage, but not with the monster itself
heres the code
Code: Select all
onDie = function(object)
ghoulplague.onDeath(object.level, object.x, object.y)
end,
Calling on the script
Code: Select all
function onDeath()
local facing = (party.facing + 2)%4
spawn("poison_cloud", level, x, y, facing)
end
and yes I have checked the spelling on the SE, it works fine if I use it on a set of spider eggs, but not for the monster, What am I doing wrong?
Re: How to make a monster spawn a poison cloud on death
Posted: Fri Jan 17, 2014 4:15 pm
by DesperateGames
The following combination works for me:
Code: Select all
onDie=function(monster)
death_test.spawnCloud(monster)
end
Calling on the script:
Code: Select all
function spawnCloud(monster)
spawn("poison_cloud", monster.level, monster.x, monster.y, monster.facing)
end
Can you check on the parameters for your OnDeath() function? In the script it has no parameters defined, but in the monster definition you are trying to pass object.level etc. to the function, I'm not sure how lua / Grimrock handles this....
Re: How to make a monster spawn a poison cloud on death
Posted: Fri Jan 17, 2014 5:14 pm
by msyblade
It may be that you are calling "object.level, x and y", while you need it to reference "monster.level, x and y". This would also explain why it works on spider eggs.
Re: How to make a monster spawn a poison cloud on death
Posted: Sat Jan 18, 2014 2:23 am
by LocalFire
Well that explains it, I feel kinda dumb for not realizing that, thanks guys
Re: How to make a monster spawn a poison cloud on death
Posted: Sat Jan 18, 2014 5:28 am
by msyblade
Happens to the best of us. sometimes the forest is so big, the trees start to look alike. That's why were here, a fresh set of eyes is just invaluable on projects this size.
Re: How to make a monster spawn a poison cloud on death
Posted: Sat Jan 18, 2014 11:16 am
by Eleven Warrior
cloneObject{
name="Boss",
baseObject = "ogre",
onDie = function(monster)
spawn("poison_cloud", monster.level, monster.x, monster.y, monster.facing)
end
}