Page 1 of 1

Spider Eggs and cracking them open

Posted: Wed Jan 23, 2013 9:35 pm
by Saurbaum
Hi everyone,

I'm trying to put together a room with a lot of hatch-able spider eggs as a trap. Step one is complete and that's following the steps to make the eggs spawn a spider on hatching. That bit works fine.

What I want to do though is to make pressing a button hatch all the eggs.

I wrote a script to go through the eggs in the room and destroy them using damageTile(). That works but it also almost always kills the freshly spawned spider even though they are spawned onDeath() of the eggs. I think I can see why in terms of game logic update that happens because onDeath() happens spawns the monster then the damageTile() spots another entity in the tile to damage and kills the spider.

I think I can get round it by making a custom spider that's immune to one type of damage and have them spawn out the piosion immune spider and use poison damage to break the eggs. I'd rather not go this way just in case the player has dumped all his magic points into earth magic it'd suck to have it all rendered useless.

So assuming I've not overlooked something obvious can anyone suggest a way to kill the eggs better than damageTile() or a way to prevent the spider death which won't screw over a party's abilities if they have been stacked that way?

Re: Spider Eggs and cracking them open

Posted: Wed Jan 23, 2013 9:41 pm
by Komag
I don't know how your script works to make the spiders from the eggs, but you could stick in a very short timer, like 0.05s, to spawn the spiders after the eggs are killed, that might do it.

Or you could simply destroy() all the eggs and use the script to spawn the spiders directly (perhaps again after a very brief delay)

Re: Spider Eggs and cracking them open

Posted: Wed Jan 23, 2013 9:45 pm
by Saurbaum
My script is the classic example from the Grimrock website. onDeath() of the eggs causes the spawn of a spider in it's space.

I tried doing destroy() on the egg and while it does work (with a minor mod to the script) it removes the eggs so you don't have the broken open model displayed.

Re: Spider Eggs and cracking them open

Posted: Wed Jan 23, 2013 10:55 pm
by Komag
You could spawn those in, maybe have to define a new decoration object with the broken egg model first

Re: Spider Eggs and cracking them open

Posted: Wed Jan 23, 2013 11:10 pm
by Drakkan
just tried this solution and seems its working.
open your object.lua and add this there

defineObject{
name = "spider_eggs_broken",
class = "Decoration",
model = "assets/models/env/spider_eggs_broken.fbx",
brokenModel = "assets/models/env/spider_eggs_broken.fbx",
placement = "floor",
editorIcon = 56,
}

this will allows you to destroy egg and then replace its place with broken object like regular (using spawn command) example:

Code: Select all

function broken()
function destroyandspawn()
egg1:destroy()
spawn("spider_eggs_broken", 2, 16, 5, 3, "broken1")  -- coordinates of the original egg (level, x,y,tile)
end

Re: Spider Eggs and cracking them open

Posted: Wed Jan 23, 2013 11:18 pm
by Saurbaum
While that's possible it's starting to get a little convoluted.

If someone goes round and destroys the eggs in turn to take out the spiders one at a time I don't want to drop them all on the player as a trap if they have been careful and cleared them out first.

So I'll end up with a very complicated script tracking the eggs that haven't been destroyed. When the button is pressed I remove them spawn in replacement cracked open eggs along with their fresh spiders.

Speaking directly to the Devs now should one happen to stumble across this.

Is is possible to add a damage() function to all objects with a health rating? Something a little more targeted than the damageTile() we have now.

Re: Spider Eggs and cracking them open

Posted: Fri Feb 01, 2013 11:55 pm
by Saurbaum
In a moment of inspiration I made my hatchable eggs have a health of 1 which means a damageTile strength 1 will burst them wide open leaving the spider unharmed.

Oddly trying to do damage "physical" fails with an error but "fire" works a treat.

Re: Spider Eggs and cracking them open

Posted: Sat Feb 02, 2013 1:49 am
by Drakkan
Saurbaum wrote:In a moment of inspiration I made my hatchable eggs have a health of 1 which means a damageTile strength 1 will burst them wide open leaving the spider unharmed.

Oddly trying to do damage "physical" fails with an error but "fire" works a treat.
good to know :) btw:When I tried to deal some precise physical dmg with script (like 100 physical dmg) it was instead dealing some random values 0-200. probably depends on evasion of that object...