Spawning Monster with Connectors and/or Dropped Items?

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!
Post Reply
Mortis_of_Midian
Posts: 14
Joined: Wed Dec 10, 2014 6:07 pm

Spawning Monster with Connectors and/or Dropped Items?

Post by Mortis_of_Midian »

How do I go about adding connectors (onDie) or Items to a monster spawned from a script?

Example spawn script line

spawn("uggardian", 4, 15, 26, 1, 0)

Is there something I can add to the end of this? Eg: :addItem / addConnector:onDie ?

Sorry if this has been asked before, I've a had a good look around, but I can't find a clear answer.
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Spawning Monster with Connectors and/or Dropped Items?

Post by Isaac »

Code: Select all

spawn("uggardian", 4, 15, 26, 1, 0).monster:addItem(spawn("dagger").item)
Adds a dagger to the spawned Uggardian.
Last edited by Isaac on Mon Jul 18, 2016 6:59 pm, edited 4 times in total.
User avatar
Zo Kath Ra
Posts: 940
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Spawning Monster with Connectors and/or Dropped Items?

Post by Zo Kath Ra »

Spawns the uggardian at the script entity's location and adds a connector for onDie:

Code: Select all

local ugga = spawn("uggardian", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
ugga.monster:addConnector("onDie", self.go.id, "uggaDies")

function uggaDies()
	hudPrint("Dead")
end
Mortis_of_Midian
Posts: 14
Joined: Wed Dec 10, 2014 6:07 pm

Re: Spawning Monster with Connectors and/or Dropped Items?

Post by Mortis_of_Midian »

Thanks again guys - I had a brief chance to try it out this morning, all working perfectly :-)
Post Reply