how to "action" when monster dies.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
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 »

I tried cloning a snail into a "sick_snail", and I added the line

Code: Select all

onDie = diecounter:decrement()
but that doesn't work, so I tried:

Code: Select all

onDie = function()
    diecounter:decrement
    print("you got 'em")
end
but that doesn't work either. both ways give an error and won't load the dungeon
Finished Dungeons - complete mods to play
User avatar
Shloogorgh
Posts: 45
Joined: Sat Sep 22, 2012 12:24 am

Re: how to "action" when monster dies.

Post by Shloogorgh »

I would try putting diecounter:decrement in a script entity within the game and change the onDie function to reference that so you can load and debug it:

Code: Select all

onDie = function()
    return sicksnail.diecounter()
    print("you got 'em")
end
then in game a script entity called sicksnail:

Code: Select all

function diecounter()
      diecounter:decrement
end
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: how to "action" when monster dies.

Post by SpacialKatana »

Komag wrote:I tried cloning a snail into a "sick_snail", and I added the line

Code: Select all

onDie = diecounter:decrement()
but that doesn't work, so I tried:

Code: Select all

onDie = function()
    diecounter:decrement
    print("you got 'em")
end
but that doesn't work either. both ways give an error and won't load the dungeon
Had a similar problem a while back, a script with a counter:decrement() command in would not for love or money decrement the counter. Perhaps the problem is related, and the decrement() command is broken for scripts(ie only works from connecters) ???
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: how to "action" when monster dies.

Post by Blichew »

Komag wrote:I tried cloning a snail into a "sick_snail", and I added the line

Code: Select all

onDie = diecounter:decrement()
but that doesn't work, so I tried:

Code: Select all

onDie = function()
    diecounter:decrement
    print("you got 'em")
end
but that doesn't work either. both ways give an error and won't load the dungeon
my guess would be your onDie = function() line instead of onDie = function(monster)
according to reference: onDie: a hook which is called when the monster dies. The function gets one parameter, the monster itself. If the function returns false, the monster is resurrected to life.

so, while overriding a hook you have to remember to use exact number of parameters (according to asset reference).

I hope this will work for you :)
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 »

hmm, I tried some of that but it didn't work (got crashes of different types, now I can't quite remember exactly what I did or what crashes, should have keep better track!)

But I ended up with it working now. Part of the problem I had was that I have a counter named "diecounter" and that script was also named "diecounter", and it didn't like that, something about calling a global script name or something when I tried to decrement the counter. So I renamed the script, both in the cloneObject and in the script in the editor.

Here is my monsters.lua clone:

Code: Select all

cloneObject{
	model = "mod_assets/models/monsters/snail_ben.fbx",
	name = "sick_snail",
	baseObject = "snail",
	health = 2,
	sight = 1,
	attackPower = 1,
	onDie = function(monster)
		return sickscript.snaildie()
	end
}
and here is my script (named "sickscript") in the editor:

Code: Select all

function snaildie()
	diecounter:decrement()
	print("you got 'em")
end
I still don't understand how parameters work or quite how the monsters.lua affects this sicksnail script, but it works just how I want now - the counter decrements and in turn triggers the actions I want to happen when the snail dies.
Finished Dungeons - complete mods to play
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 »

small note, if I press K to kill the monster, the "you got 'em" prints to the console, but the counter doesn't get decremented. But if I actually attack and kill the snail, the "you got 'em works AND the counter decrements. Why on earth would the print work but not the decrement when pressing K?
Finished Dungeons - complete mods to play
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 »

Probably something related to how you don't get exp when you use k to kill
"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!
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: how to "action" when monster dies.

Post by SpacialKatana »

Hmmm.....that could've been my problem before Komag, I was fast killing bosses to check stuff and using the 'k' method. Now, if I'd actually killed them properly maybe my counter would've worked via the decrement command in the script they fired from the death hook. Sheesh and I did a workaround for it....
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 »

so really this is a bug, or maybe a feature request, but K to kill needs to act like real kills, so we don't always have to fully battle tough monsters we place just to test things fully
Finished Dungeons - complete mods to play
SpacialKatana
Posts: 163
Joined: Fri Sep 14, 2012 6:20 pm

Re: how to "action" when monster dies.

Post by SpacialKatana »

Not so much a bug...but an oversight I suppose :roll:
Post Reply