spawning a monster onDie

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: spawning a monster onDie

Post by Isaac »

bongobeat wrote:Hello,

can a monster be spawned after the death of another monster, and a the same place of the dying monster?
Yes.

Code: Select all

--script name: hook_script
spawn('zarchton', 1, 15,15,0,0).monster:addConnector("onDie", "hook_script", "deathSpawn")

function deathSpawn(monster)
	local c = spawn( "zarchton_ambush", monster.go.level,
				monster.go.x, monster.go.y,
				monster.go.facing, monster.go.elevation).monster
				c:setLevel(2)
				c:setMaxHealth(228)
				c:addConnector("onDie", "hook_script", "deathSpawn")
end
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: spawning a monster onDie

Post by Eleven Warrior »

Hi Issac thxs for this code man :) Just wondering why you added the line: c:addConnector("onDie", "hook_script", "deathSpawn") to the second monster? Wont it just keep respawing a new monster each time it dies or did I miss something thxs :)
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: spawning a monster onDie

Post by Isaac »

Eleven Warrior wrote:Hi Issac thxs for this code man :) Just wondering why you added the line: c:addConnector("onDie", "hook_script", "deathSpawn") to the second monster? Wont it just keep respawing a new monster each time it dies or did I miss something thxs :)
It is an infinite demo... To demonstrate; but the second hook can be removed or commented out.

*But it's neat to kill off the zarchtons in the editor with 'K', and they just keep crawling out of the pond (or floor).
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: spawning a monster onDie

Post by Eleven Warrior »

Isaac wrote:
Eleven Warrior wrote:Hi Issac thxs for this code man :) Just wondering why you added the line: c:addConnector("onDie", "hook_script", "deathSpawn") to the second monster? Wont it just keep respawing a new monster each time it dies or did I miss something thxs :)
It is an infinite demo... To demonstrate; but the second hook can be removed or commented out.

*But it's neat to kill off the zarchtons in the editor with 'K', and they just keep crawling out of the pond (or floor).


Sound cool and funny at the same time. I tried it and man what a laugh, also gave me some awesome new ideas when my Brain went to sleep lol :)
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: spawning a monster onDie

Post by bongobeat »

Azel wrote:Oh yeah, the Teleporter wouldn't be able to do it in the exact location where the original monster died; unless you added Script. The smaller script minmay gave is definitely better for a straight 1-to-1 scenario: monster dies, monster spawns. Sorry if I confused you, I tend to like to make things a bit more adventurous, so to speak. Cheers!
no problem, thanks for the help :)

Isaac wrote:
bongobeat wrote:Hello,

can a monster be spawned after the death of another monster, and a the same place of the dying monster?
Yes.

Code: Select all

--script name: hook_script
spawn('zarchton', 1, 15,15,0,0).monster:addConnector("onDie", "hook_script", "deathSpawn")

function deathSpawn(monster)
	local c = spawn( "zarchton_ambush", monster.go.level,
				monster.go.x, monster.go.y,
				monster.go.facing, monster.go.elevation).monster
				c:setLevel(2)
				c:setMaxHealth(228)
				c:addConnector("onDie", "hook_script", "deathSpawn")
end
oh my! funny things, thanks for that! ;)
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply