Page 2 of 3

Re: Invisible door model

Posted: Mon Jan 21, 2013 7:16 pm
by Ancylus
djoldgames wrote:I have small tweak-tip for you about invisible door model.
Thanks! I haven't done any actual modeling, and wasn't able to figure out much from the toolkit at a quick glance. Much better to be rid of the mesh since it's not needed.

Re: AI Framework

Posted: Fri Jan 24, 2014 2:52 pm
by Eightball
Has anyone tried to code door opening skills into monster AI? Surely there must be a command already in Grimrock since Goromorg can open doors, but I haven't seen anything like that on the forums yet. Some undead monsters or other monsters with hands or smarts should be able to open them, but I'm too new to this to know if it's worth the effort. So far I've just used the illusion of door-opening with scripted events.

Re: AI Framework

Posted: Fri Jan 24, 2014 4:12 pm
by Komag
You could have invisible pressure plates that check monster facing, but that's still just a hack

Re: AI Framework

Posted: Tue Jan 28, 2014 9:57 am
by Eightball
Hmm, I'm going to try that hack. Sounded simple enough. I'm going to use a code line this for each door on the level (it's a small level). How would that line look? I don't see anyone trying a monster-face check anywhere on the forums.
I tried to guess and used the line:

Code: Select all

function openSezMe1()
	if monster.id:facing = 3 then
	temple_door_metal_3:open()
	end
end
but of course I get an error (which I don't understand) asking for a "function argument" in the first line of the if statement "near =".

Re: AI Framework

Posted: Tue Jan 28, 2014 10:51 am
by alois
Eightball wrote:Hmm, I'm going to try that hack. Sounded simple enough. I'm going to use a code line this for each door on the level (it's a small level). How would that line look? I don't see anyone trying a monster-face check anywhere on the forums.
I tried to guess and used the line:

Code: Select all

function openSezMe1()
	if monster.id:facing = 3 then
	temple_door_metal_3:open()
	end
end
but of course I get an error (which I don't understand) asking for a "function argument" in the first line of the if statement "near =".
The correct syntax is "if monster.id:facing == 3" (with the double '='), or otherwise lua thinks you are assigning the value 3 to something! :)

alois :)

Re: AI Framework

Posted: Tue Jan 28, 2014 11:17 am
by Eightball
Thanks again! I've been wondering what the difference was between = and ==.
What is ~=? Would that be "is not equal to"?

I tried the script with the double = but it still says it expects "function arguments" near the "==".

Re: AI Framework

Posted: Tue Jan 28, 2014 12:32 pm
by alois
Eightball wrote:Thanks again! I've been wondering what the difference was between = and ==.
What is ~=? Would that be "is not equal to"?

I tried the script with the double = but it still says it expects "function arguments" near the "==".
Ah, sorry: once you have a monster, monster.id gives its id, monster.facing gives the direction it is facing and so on... so the line should be "if (monster.facing == 3) then ..."

Note that - however - 'monster' seems undefined in your script: maybe the function is "openSezMe1(monster)"?

alois :)

Re: AI Framework

Posted: Tue Jan 28, 2014 2:50 pm
by Eightball
Oh I see. I was hoping that any monster stepping on a hidden pressure plate with the proper facing would open the door. But I guess I may have to assign a script to each monster in the vicinity. I may want to rethink this. Is there a way for the pressure plate activation to check the id of the monster activating it? Then I could just keep it general so that any monster's id could be taken. Maybe this is just beyond me at this point.

Re: AI Framework

Posted: Tue Jan 28, 2014 3:30 pm
by alois
Eightball wrote:Oh I see. I was hoping that any monster stepping on a hidden pressure plate with the proper facing would open the door. But I guess I may have to assign a script to each monster in the vicinity. I may want to rethink this. Is there a way for the pressure plate activation to check the id of the monster activating it? Then I could just keep it general so that any monster's id could be taken. Maybe this is just beyond me at this point.
I'd say: you put a hidden pressure plate only activated by monsters; then, as the plate activates, you trigger a script which checks for entities at the location of the plate; then, if the class of one of the entities is 'Monster', you check its facing:

Code: Select all

function steppedOn(self)
   local facing = tonumber(string.sub(self.id,string.len(self.id))) -- replace with 0,1,2,3 if 'single shot'
   for ent in entitiesAt(self.level,self.x,self.y) do -- "self" refers to the triggerer of the script; i.e., the pressure plate
      if (ent.class == "Monster") then
         if (ent.facing == facing) then
            door_whatever:open()
         end
      end
end
This should do the trick; note the line "local facing = tonumber(string.sub(self.id,string.len(self.id)))"; if you give an id to the pressure plate as follows: hidden_pressure_plate_xxx_y, where xxx is the number you find in the 'id' field in the editor when you create the plate (i.e.: you do not have to change it), and "_y" is either "_0", "_1", "_2", "_3", the function takes the 'facing' you want the monster to have from the plate which is calling the function; hence you can use this function for more than one plate...

alois :)

Re: AI Framework

Posted: Tue Jan 28, 2014 5:30 pm
by chaoscommencer
It might even be preferable to use the above script without checking the monster's facing (remember that the script to open the door is only triggered when the monster steps onto the plate, and not when it turns to face in the right direction after having already walked onto the plate, which it likely won't do unless it can see your party on the other side of the door). Since the monster might not be facing the door when it steps onto the plate (perhaps because of the direction it had been following to chase your party or because it can't see your party on the other side) the door would not open for it. Alois' script above is pretty nice though and might help for controlled situations; in other cases you will likely need to modify it by removing the facing check condition (which would be realistic for automated doors anyways, even if not for monsters opening doors). Just some thoughts to consider...