Page 2 of 2

Re: How to let monsters drop things?

Posted: Thu Sep 13, 2012 8:57 pm
by resonansER
Moonsprite wrote:
resonansER wrote:I don't understand HOW connect this script with monster. :( Please, show the sample.
It took me awhile to figure this out as well (I'm new to this scripting stuff too).

The principle behind this is that you are making a new monster that has an attribute that on its death, it will drop a key.

So:

- first I'd suggest you close the editor (I'd guess all assets are loaded when you first start and/or open your project) If the editor is running it won't see the new monster.
- in your 'scripts' folder on your harddisk within your project folder, open the file 'monsters.lua'.
- Add the script mentioned above
- save and exit file.
- start your editor and open your current project (thats where the edited monsters.lua file resides within)
- you should now find you have a new asset (called 'KeySnail' if you named it as the above script).
- now whenever you use this asset/monster, it will drop a key or its death (so only use this monster once, or if you have a hundred locked doors, use this monster another 99 times :D )
I UNDERSTAND!!! THANK YOU SO MUCH! COOL!!! I create first snail who dropped key! THANK YOU!!! :shock: ;) :D :D

And thank you for this, antti!:
antti wrote: I'd slightly tweak the spawning like so:
spawn("iron_key", self.level, self.x, self.y, self.facing)

None of those tweaks might not be absolutely necessary in this case but they will make the script a little more robust and flexible. Using self.level instead of 2 means that the script will work no matter what floor the creature is on. self.facing is just a "nice touch" so that the item is spawned according to the monster's orientation. And finally, I left out the ID, which is an optional parameter. This means that there will be no trouble with clashing IDs if you would want to, for some reason, use multiple snails like these.
Cool!

Re: How to let monsters drop things?

Posted: Fri Sep 14, 2012 6:54 am
by petri
Please note:

The engine can support items carried by individual monsters without needing to clone the base monster type. There's just an oversight that this functionality is not exposed in the scripting interface / inspector. So it's not recommended that you clone the monster type but unfortunately that seems to be the only way with beta-1.2.6. Next update should fix this.

Also check out "lootDrop" property in monster definitions. It's a bit easier to use than onDie.

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 1:52 am
by Grimwold
any help on how to format lootDrop: I cloned a skeleton warrior to change the loot drops and none of them dropped anything.

This is the code I put in monsters.lua

Code: Select all

cloneObject{
        name = "skeleton_warrior",
        baseObject = "skeleton_warrior",
        lootDrop = { 65, “legionary_spear”, 55, “legionary_shield”, 45, "legionary_helmet" }
}
Edit: I've also had the editor completely crash twice now, when attacking a modified skeleton warrior (possibly at the point of death??)

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 1:56 am
by Akatana
65 + 55 + 45 = 165

I think 100% is the highest maybe they don't drop because its over 100% (9000!)

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 2:00 am
by Grimwold
Akatana wrote:65 + 55 + 45 = 165

I think 100% is the highest maybe they don't drop because its over 100% (9000!)
I didn't think it was additive.. how else could skeleton warriors drop both shield and spear every time otherwise?

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 2:04 am
by Billick
I think you need a comma after your lootDrop definition.

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 2:19 am
by Grimwold
after a little experimentation, the following worked to some degree:

Code: Select all

lootDrop = {50, "legionary_spear", 25, "legionary_shield", 25, "legionary_helmet"}
however I hardly ever got a helmet

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 10:09 pm
by SpacialKatana
Okay, the following is crashing my game/editor when I kill the monster, but I don't get why. I have an item called orb_of_power cloned from a golden orb. The monster has 1 health and increment for testing purposes....

cloneObject{
name = "uggardian_orb2",
baseObject = "uggardian",
health = 1,
healthIncrement = 1,
sight = 6,

onDie = function(self)
spawn("orb_of_power", self.level, self.x, self.y, self.facing, "orb2")
uggdoor1:open()
end
}

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 10:11 pm
by Akatana

Code: Select all

cloneObject{
name = "uggardian_orb2",
baseObject = "uggardian",
health = 1,
healthIncrement = 1,
sight = 6,

onDie = function(self)
spawn("orb_of_power", self.level, self.x, self.y, self.facing)
uggdoor1:open()
end
}
try this :)

Re: How to let monsters drop things?

Posted: Sun Sep 16, 2012 10:37 pm
by SpacialKatana
Fixed.

The code was fine, I'd forgotten to delete the object (ID orb2) from another level, the ID clash was crashing the game :)