Page 4 of 5

Re: how to "action" when monster dies.

Posted: Tue Oct 09, 2012 11:20 am
by Neikun
spawners have a cooldown box. I believe it's measured in seconds.

Re: how to "action" when monster dies.

Posted: Tue Oct 09, 2012 11:41 am
by Komag
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.

Re: how to "action" when monster dies.

Posted: Tue Oct 09, 2012 12:23 pm
by Kuningas
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:

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
The onDie hook:

Code: Select all

onDie = function(self)
	local s = slimekillcounter
	local sl = givegemscript
	s:increment()
	sl:givegem()
end,
Hm. I just realized I still have the counter there, even though I don't really need it. : /

Re: how to "action" when monster dies.

Posted: Wed Oct 10, 2012 11:10 am
by Tyrion
davehca wrote:I was able to get a monster's death to open a door using the following:

Code: Select all

cloneObject {
	name = "snail2",
	baseObject = "snail",

	onDie = function(self) 
 		dungeon_door_iron_1:open()
	end,
}
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.

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.

Posted: Wed Oct 10, 2012 11:24 am
by Blichew
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.

Re: how to "action" when monster dies.

Posted: Thu Oct 25, 2012 1:02 am
by Ciccipicci
It works perfectly!!! :)

Re: how to "action" when monster dies.

Posted: Thu Nov 08, 2012 12:33 pm
by 8kin
:P yay! works a treet

Code: Select all

cloneObject{
	name = "boss_snail",
	baseObject = "snail",
	moveSound = "snail_walk",
	health = 1,
	onDie = function(self)
		lvl2bossdoor:open()
	end		
}
time to add a bit of poison... hmm try and find some spider script

Re: how to "action" when monster dies.

Posted: Fri Nov 09, 2012 3:40 am
by HaunterV
8kin wrote::P yay! works a treet

Code: Select all

cloneObject{
	name = "boss_snail",
	baseObject = "snail",
	moveSound = "snail_walk",
	health = 1,
	onDie = function(self)
		lvl2bossdoor:open()
	end		
}
time to add a bit of poison... hmm try and find some spider script
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.

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,  
}
counter name is stoneogredeath, initial value set to one.

Re: how to "action" when monster dies.

Posted: Fri Nov 09, 2012 6:53 am
by akroma222
@ 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:
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 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...

Re: how to "action" when monster dies.

Posted: Fri Nov 09, 2012 4:02 pm
by HaunterV
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:
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 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...
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.