spawner/spawning problem

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

spawner/spawning problem

Post by zeltak »

What I'm trying to do is have a set number of skeleton patrols patrolling an area almost constantly and I figured out I could use Shroom's little script for checking things in an area. I couldn't figure out how to check how many things are in the given area so I thought I would make a 3 new specific monster for the task and check each one of them individually. So I cloned 3 skeleton patrols.
eg.

Code: Select all

cloneObject{
	name = "Patrol_1",
	baseObject = "skeleton_patrol",
	}
and so on.

Then I added connector from a hidden plate to the lua script.

Shroom's script was this:

Code: Select all

    function checkPatrol1()
       if checkForThings("Patrol_1",12,21,1,16) then
          spawn("Patrol_1", party.level, 13, 15, 1)
       end
    end

    function checkForThings(thing,xMin,xMax,yMin,yMax)
       for x = xMin,xMax do
          for y = yMin,yMax do
             for object in entitiesAt(1,x,y) do
                if object.name == thing then
                   return false
                end
             end
          end
       end
       return true
    end
Problem is that it won't spawn any new Patrol_1's after the initially placed Patrol_1 is dead. In this way or tied to a spawner (eg. I replaced the "spawn" -line with spawner_1:activate() -command). Is there something wrong with the "spawn" -line? When replaced with the spawner activation it doesn't allow me to spawn my new creature type or if I try to spawn a new skeleton_patrol with the name "Patrol_1" it doesn't do that either.
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: spawner/spawning problem

Post by Shroom »

Your logic is wrong - you are checking for the existance of something and if it exists, your trying to spawn another with the same name - which wont happen.

add == false after the checkThings() call

ie

Code: Select all

    function checkPatrol1()
       if checkForThings("Patrol_1",12,21,1,16) == false then
          --spawn("Patrol_1", party.level, 13, 15, 1)
          spawner1:activate()
       end
    end
I havent tried this, but i would thing this is a better way of doing it - create the spawner, and activate it if there are no patrols left (you could have multiple - and you could even add in a counter to always have more than x for example)
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: spawner/spawning problem

Post by zeltak »

Thanks for a quick reply, but adding == false didn't fix the problem. Yeah, I gather there are more easy solutions for making this work, but I haven't figured them out yet. I don't have any scripting experience, I just try to figure out things from examples and copying scripts. I should propably sit down and have a patience to read proper Lua -documentations.. :roll:
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: spawner/spawning problem

Post by Shroom »

forgive me - i was talking rubbish - In the example you gave it returns false if it is found, true if it is not.

take out the == false bit - you had that bit right. I will put it in the editor and give you the right code back
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: spawner/spawning problem

Post by Shroom »

Right - my apologies for my earlier lapse - this works. I created a small room 4 wide by 3 high starting at 20,14 and ending 22,17. I put a single crab in it.

Code: Select all

    function checkPatrol1()
       if checkForThings("crab",20,22,14,17) then
          spawn("crab", party.level, 22, 15, 1)
       end
    end

    function checkForThings(thing,xMin,xMax,yMin,yMax)
       for x = xMin,xMax do
          for y = yMin,yMax do
             for object in entitiesAt(1,x,y) do
                if object.name == thing then
                   return false
                end
             end
          end
       end
       return true
    end
I am using the default crab here as you can see. One thing I did notice, depending on when you check, it seems to not see it in the small frame of time it is moving from one square to another as I ended up with 2 crabs after spamming the check :)

Could this be a problem with your monster rather than your lua?
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: spawner/spawning problem

Post by zeltak »

Thank you! Good to know it's not the script then at least. But yes, that was part of the original question, is there something preventing the spawning of custom monsters? When I place the custom monster on the map, it behaves normally as it should. I just can't spawn it. It doesn't even try to give me a choice to choose it in a spawner or spawn it if I try to do it through a script.

edit: Hold on! Even if I try to use it with normal monster it doesn't work for me O.o Now I'm confused..
User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: spawner/spawning problem

Post by zeltak »

Ok, it seems there's something preventing the spawning of skeleton patrol. I tested it with crab and it does work fine, but when I change it to skeleton_patrol it doesn't work anymore..

edit: further testing proves the same thing for skeleton_archer_patrol.
edit2: I tested it without any script in the between, just the pressure plate and spawner. It doesn't spawn patrols of any kind (neither skeleton or beast -kind).
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: spawner/spawning problem

Post by Shroom »

zeltak wrote:Ok, it seems there's something preventing the spawning of skeleton patrol. I tested it with crab and it does work fine, but when I change it to skeleton_patrol it doesn't work anymore..

edit: further testing proves the same thing for skeleton_archer_patrol.
edit2: I tested it without any script in the between, just the pressure plate and spawner. It doesn't spawn patrols of any kind (neither skeleton or beast -kind).
Could that be because thats not a monster - but a number of skeleton_warrior or skeleton_archer? Try searching for that
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: spawner/spawning problem

Post by Shroom »

It works with warrior, but I cant get a patrol to spawn at all - and if I get 2 warriors to spawn in the same place, LoG crashes!
User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: spawner/spawning problem

Post by Shroom »

Shroom wrote:It works with warrior, but I cant get a patrol to spawn at all - and if I get 2 warriors to spawn in the same place, LoG crashes!
ok it crashed once - now it manages to spawn 2 in one place - further spawns give an error on the display - but i still have 2 spawns in 1 place

Edit: Actually looks like i had more than 2, butnot sure how many
Post Reply