how to "action" when monster dies.
Re: how to "action" when monster dies.
spawners have a cooldown box. I believe it's measured in seconds.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
- Message me to join in!
Re: how to "action" when monster dies.
if you want to limit the number of snails in the room, one easy way would be to have the room filled with hidden pressure plates which are set to monster only, and then you easily count how many are down at any given moment.
Finished Dungeons - complete mods to play
Re: how to "action" when monster dies.
Ok it works, basically. Thanks for the tip with the spawn command, guys. I feel like I understand coding a little bit more now. : D
There is just a small inconsistency, which doesn't affect the overall funcion of the script. The thing is, when checking for existence with the onDie hook, it seems to still find the dying entity on the very moment it is ceasing existence (and the script is ran), resulting in a negative for this script. So it doesn't add the item to the third one when the second one is killed, but rather, it adds the item just when the third one is killed as well. But it manages to do this so that the item is still dropped by it, so overall, the script works.
I suppose adding a minimal delay could help? Not that it matters in this case, but in some other cases it could cause confusion. (that, or I still get something wrong here)
Here is the working script, if someone wants it:
The lua entity:
The onDie hook:
Hm. I just realized I still have the counter there, even though I don't really need it. : /
There is just a small inconsistency, which doesn't affect the overall funcion of the script. The thing is, when checking for existence with the onDie hook, it seems to still find the dying entity on the very moment it is ceasing existence (and the script is ran), resulting in a negative for this script. So it doesn't add the item to the third one when the second one is killed, but rather, it adds the item just when the third one is killed as well. But it manages to do this so that the item is still dropped by it, so overall, the script works.
I suppose adding a minimal delay could help? Not that it matters in this case, but in some other cases it could cause confusion. (that, or I still get something wrong here)
Here is the working script, if someone wants it:
The lua entity:
Code: Select all
function givegem()
if not findEntity("sewer_slime_1") and not findEntity("sewer_slime_2") then
sewer_slime_3:addItem(spawn("green_gem"))
end
end
Code: Select all
onDie = function(self)
local s = slimekillcounter
local sl = givegemscript
s:increment()
sl:givegem()
end,
BASILEUS
Re: how to "action" when monster dies.
davehca wrote:I was able to get a monster's death to open a door using the following:
If it returns "false" then when the monster "dies" it doesn't really, but the door still opens. What's funny is if I set to toggle() and return false, after the initial "death" the door will toggle with each whack made against the creature.Code: Select all
cloneObject { name = "snail2", baseObject = "snail", onDie = function(self) dungeon_door_iron_1:open() end, }
So how exactly do you get a door to open by killing the snail?
First, it is not possible to draw a connector from the snail to the script.
Also, I get an error message, because cloneObject is not a function.
How exactly do you solve this?
Re: how to "action" when monster dies.
You have to put that code into your monsters.lua file that is located in your C:\Users\{your_user_name}\Documents\Almost Human\Legend of Grimrock\Dungeons\{your_dungeon_name}\mod_assets\scripts\ folder.
What it does it defines a new type of monster called snail2 which is a clone of a normal snail, except the fact that if any instance of snail2 dies it opens dungeon_door_iron_1.
What it does it defines a new type of monster called snail2 which is a clone of a normal snail, except the fact that if any instance of snail2 dies it opens dungeon_door_iron_1.
- Ciccipicci
- Posts: 154
- Joined: Mon Oct 08, 2012 12:55 am
Re: how to "action" when monster dies.
It works perfectly!!!
Re: how to "action" when monster dies.
yay! works a treet
time to add a bit of poison... hmm try and find some spider script
Code: Select all
cloneObject{
name = "boss_snail",
baseObject = "snail",
moveSound = "snail_walk",
health = 1,
onDie = function(self)
lvl2bossdoor:open()
end
}
--
When you're a hammer, everything looks like a nail.
When you're a hammer, everything looks like a nail.
Re: how to "action" when monster dies.
can i get this to activate a pressure plate instead of a door? I have about 200 doors i need to open when my boss monster dies so this one door script doesnt work for me entirely.8kin wrote: yay! works a treet
time to add a bit of poison... hmm try and find some spider scriptCode: Select all
cloneObject{ name = "boss_snail", baseObject = "snail", moveSound = "snail_walk", health = 1, onDie = function(self) lvl2bossdoor:open() end }
i tihnk i need pressure plate because the increment isnt working for me so the counter wont fire the luas attached to it. but if i manually use a pressure plate it works well.
Code: Select all
cloneObject{
name = "stone_ogre_2",
baseObject = "stone_ogre",
health = 1,
onDie = function(self)
local s = stoneogredeath
s:decrement()
end,
}
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
Re: how to "action" when monster dies.
@ 8kin - I used the same script, works well!
@HaunterV - could you possible make the onDie hook for the boss monster activate a script that went along the lines of:
(I have not tested this) but...
I have used a similar script connected to a plate to open all portcullis in order to reset a portcullis puzzle...
@HaunterV - could you possible make the onDie hook for the boss monster activate a script that went along the lines of:
SpoilerShow
Code: Select all
function openAllDoors()
for i in allEntities(party.level) do
if i.id:sub(1,200) == "boss_door_" then
i:open()
end
end
end
I have used a similar script connected to a plate to open all portcullis in order to reset a portcullis puzzle...
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: how to "action" when monster dies.
see i have 5 of those, 1 for each configuration of the room. waht i want is to call a script that fires all of them.akroma222 wrote:@ 8kin - I used the same script, works well!
@HaunterV - could you possible make the onDie hook for the boss monster activate a script that went along the lines of:(I have not tested this) but...SpoilerShowCode: Select all
function openAllDoors() for i in allEntities(party.level) do if i.id:sub(1,200) == "boss_door_" then i:open() end end end
I have used a similar script connected to a plate to open all portcullis in order to reset a portcullis puzzle...
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc