Mummy opens door

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Mummy opens door

Post by Mysterious »

Hi guys need help on this. I am using a mummy to walk towards a door, when mummy gets to the door, the door opens and he walks through the door end. I have tried this and the mummy does walk to the door but does not open the door and the mummy does not walk through the door way.

So I know the mummy can walk to dungeon_door_wooden_1, I need to get him to walk through. I think he may have to go to a new object.

Mummy Object:

Code: Select all

--- Mummy opens door with Lever ---

defineObject{
   name = "mummy_test_1",
   baseObject = "mummy",
   components = {
   {
      class = 'Brain',
      onThink = function(self)
            Monster_To_Room.script.onThink(self)
      end,
   }
}
}
Script in editor:

Code: Select all

function onThink(self)
   --print(state)
   if state == "begin" and self.partyLastSeen ~= 0 then
      if self:goTo("dungeon_door_wooden_1") then
         state = "closed"
      end
   end
   if state == "closed" then
      dungeon_door_wooden_1.door:open() ---Somewhere here I need the mummy to walk through door maybe to new object---
      state = "end"
   end
end
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Mummy opens door

Post by MrChoke »

You should use BrainComponent:here() to tell you if the mummy has made it to the door or not. If the monster is on the same square as the object you specify, it will return true.
Once its true you can tell the door to open.

Regarding having him walk through, if you want to control his movement still you need to tell him to goTo() another object, one in the room behind the door.


UPDATE: Petri just told me that the BrainComponet:seek(number, number) function will make a mob move to the X and Y coordinates you specify. seek takes 2 numbers, not one. So you could give the mummy square coordinates in the room as well.
NOTE: I am not sure seek() is working right... I tested it last night and it didn't seem like it was but maybe I was wrong...
Post Reply