Scripts help

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Scripts help

Post by Drakkan »

xbdj wrote:Got it:

cloneObject{
name = "snail_drop",
baseObject = "snail",
onDie = function(self)
spawn("rock", self.level, self.x, self.y, self.facing)
end,
}


Add this to your monster.lua file (and edit text as necessary ofcourse)
and then simply spawn a "snail_drop" instead of a snail...or whatever monster it is you need to drop it
I tried this:
cloneObject{
name = "skeleton_Iron_Key",
baseObject = "skeleton_patrol",
onDie = function(self)
spawn("iron_key", self.level, self.x, self.y, self.facing)
end,
}

working fine with single monster like skeleton_warrior etc....
not working for skeleton_patrol :/
made some tests and items are not spawning for single group of monsters :/ Any ideas ?
Breath from the unpromising waters.
Eye of the Atlantis
xbdj
Posts: 32
Joined: Sun Dec 30, 2012 7:43 pm

Re: Scripts help

Post by xbdj »

Hmmm...weird...I just tried it and - as you say - it doesnt work with patrols!

Sorry...Im all out of ideas now
Hariolor
Posts: 42
Joined: Sun Apr 15, 2012 5:59 am

Re: Scripts help

Post by Hariolor »

Drakkan wrote:Hello everybody,

2. It is possible to script somehow that object "spawner" (creature) will drop some item after killing ?
EDIT: solved for single monster. However still not working for group of single monsters (like skeleton_patrol)

thats all for now, thanks
see this thread

viewtopic.php?f=14&t=3194&hilit=additem&start=20

patrols are made up of groups of single monsters - AFAIK nobody has yet come up with a method to use an addItem() with a patrol successfully.
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: Scripts help

Post by Diarmuid »

Hi, I managed to do it!

While working on my EXSP framework, I spent two days doing tests to detect monster groups properly. So here's for you a function that returns a table of all individual monsters in a monster group:

Code: Select all

function getMonsterGroup(level, x, y)
	local monstersTable = {}
	for i in entitiesAt(level,x,y) do
		if i.class == "Monster" then
			table.insert(monstersTable, i)
		end	
	end
	return monstersTable
end
So I used this code to add a brass key to the first skeleton in a patrol which was at 1, 6, 4:

Code: Select all

	local monsters = getMonsterGroup(1,6,4)
	monsters[1]:addItem(spawn("brass_key"))
Enjoy! 8-)
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Scripts help

Post by Komag »

you could maybe set up an onDie hook to search and see if they are the last to die, and if so, spawn the key
Finished Dungeons - complete mods to play
Post Reply

Return to “Modding”