how to spawn a monster only if a certain square is empty?

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

how to spawn a monster only if a certain square is empty?

Post by Komag »

I want to spawn a monster into a "monster closet" but only if there is not already a monster in there and also the party must not be in there (but if there are items in there it's okay.)

I know I can check the contents of a square with a script, but I want items tossed in by the party to not block the spawn, and I'm not quite sure how to set it all up anyway.
Finished Dungeons - complete mods to play
User avatar
Akatana
Posts: 42
Joined: Tue Apr 10, 2012 11:07 pm

Re: how to spawn a monster only if a certain square is empty

Post by Akatana »

Maybe try it with a hidden preasure plate? :)
Aazlan
Posts: 13
Joined: Thu Sep 13, 2012 6:59 pm

Re: how to spawn a monster only if a certain square is empty

Post by Aazlan »

Yep, the hidden pressure plates have check boxes for Triggered by... Party, Items, Monster. Just turn off Items and you should be good to go.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: how to spawn a monster only if a certain square is empty

Post by Komag »

okay, that sounds like the best way to go, works great!

Here is my script

Code: Select all

function monstercloset()
    if closetplate:isUp() == true then
        closetspawn:activate()
    end
end
EDIT - changed True to true
Last edited by Komag on Sat Sep 15, 2012 2:09 pm, edited 1 time in total.
Finished Dungeons - complete mods to play
User avatar
Billick
Posts: 201
Joined: Thu Apr 19, 2012 9:28 pm

Re: how to spawn a monster only if a certain square is empty

Post by Billick »

Komag wrote:okay, that sounds like the best way to go.
Here is my non-working script, how do I fix it?

Code: Select all

function monstercloset()
    if closetplate:isUp() == True then
        closetspawn:activate()
    end
end
booleans have to be all lowercase maybe? Try changing "True" to "true".
Halls of Barrian - current version 1.0.3 - Steam Nexus
Me Grimrock no bozo!
Magus
Posts: 56
Joined: Wed Sep 12, 2012 6:05 pm

Re: how to spawn a monster only if a certain square is empty

Post by Magus »

yeah changing the True to true should work fine.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: how to spawn a monster only if a certain square is empty

Post by Komag »

uh oh, flying monsters don't trigger pressure plates! HELP!
Finished Dungeons - complete mods to play
Magus
Posts: 56
Joined: Wed Sep 12, 2012 6:05 pm

Re: how to spawn a monster only if a certain square is empty

Post by Magus »

entitiesAt(level, x, y) i think this function will help you. Maybe add a timer that runs every 0.25 seconds.

EDIT:
I haven't used enemys yet so I don't know if this works but try somthing like this:

for i in entitiesAt(level, x, y) do
if i.name == "NAME OF THE ENEMY" then
...code...
else
...code...
end
end
Last edited by Magus on Sat Sep 15, 2012 2:17 pm, edited 1 time in total.
Aazlan
Posts: 13
Joined: Thu Sep 13, 2012 6:59 pm

Re: how to spawn a monster only if a certain square is empty

Post by Aazlan »

How big is the closet? Just 1 square? Then you should be able to connect the plate to that lua script entity, and then just use spawn("your_choice_of_Monster", closet level, closet x, closet y, respawn rate) instead of closetspawn:activate()
Aazlan
Posts: 13
Joined: Thu Sep 13, 2012 6:59 pm

Re: how to spawn a monster only if a certain square is empty

Post by Aazlan »

The other option for flying enemies would be to use a blob spawner and a hidden receptor, and have the monster spawn if the blob activates the receptor. Pretty sure monsters block blobs. Otherwise, I'm not sure what you would connect Magus' lua script to exactly, maybe hidden pressure plate and a timer I guess.
Post Reply