how to "action" when monster dies.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: how to "action" when monster dies.

Post by Neikun »

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
  • Message me to join in!
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: how to "action" when monster dies.

Post 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.
Finished Dungeons - complete mods to play
User avatar
Kuningas
Posts: 268
Joined: Wed Apr 11, 2012 10:29 pm
Location: Northern Finland

Re: how to "action" when monster dies.

Post 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. : /
BASILEUS
Tyrion
Posts: 5
Joined: Tue Oct 09, 2012 11:27 pm

Re: how to "action" when monster dies.

Post 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?
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: how to "action" when monster dies.

Post 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.
User avatar
Ciccipicci
Posts: 154
Joined: Mon Oct 08, 2012 12:55 am

Re: how to "action" when monster dies.

Post by Ciccipicci »

It works perfectly!!! :)
User avatar
8kin
Posts: 5
Joined: Wed Nov 07, 2012 1:04 pm

Re: how to "action" when monster dies.

Post 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
--
When you're a hammer, everything looks like a nail.
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: how to "action" when monster dies.

Post 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.
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
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: how to "action" when monster dies.

Post 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...
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: how to "action" when monster dies.

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