spawning monsters and loot.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

spawning monsters and loot.

Post by KnotuAgain »

I cloned a monster. I cloned a coffin. When the champions destory the coffin my cloned skeleton is spawned. So far so good. Next I want to have a list of possible loot, and to have one item to spawn onDie of the monster. That don't work. I have tried having the spawn loot in the cloned monster .lua file (did not work), I tried a call to a script_entity (still did not work). Also tried hudPrint() command to try to trouble shoot. I get a " '}' expected (to close '}' at line 5) near onDie. " error.
cloneObject {
name="my_skeleton_warrior",
baseObject="skeleton_warrior",
OnDie=function(self)
-- skeletonDead.getSkeletonLoot(self.level, self.x, self.y)
skeletonLoot={
"torch",
"dm_bone_arm",
"dagger",
"tar_bead",
"tattered_cloak",
"dm_waterskin_full",
"peasant_cap",
"sack",
"dm_weapon_club",
"shuriken"
}
spawn(skeletonLoot[math.random(1, #skeletonLoot)], level,x,y,0)

end
}

Thanks inadvance for any help.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: spawning monsters and loot.

Post by Isaac »

I don't know if it's a typo in your post, but your onDie hook has a capital O. That would break it.

Also: the level variables in your spawn function, should probably be self.level, self.x, self.y, self.facing.
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

Re: spawning monsters and loot.

Post by KnotuAgain »

I did not notice the capital "O" on the "OnDie". Thanks for pointing that out. Once I fixed that, the code actually got me to that area. After that it was easy to see the self.level etc was needed. Some times you stare at something and you see what you "meant" to type that you don't see what you really typed. Thanks for your help, it is working now.
Post Reply