AI Framework

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Ancylus
Posts: 50
Joined: Thu Oct 11, 2012 5:54 pm

Re: Invisible door model

Post 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.
User avatar
Eightball
Posts: 48
Joined: Thu Jan 09, 2014 8:21 am

Re: AI Framework

Post 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.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: AI Framework

Post by Komag »

You could have invisible pressure plates that check monster facing, but that's still just a hack
Finished Dungeons - complete mods to play
User avatar
Eightball
Posts: 48
Joined: Thu Jan 09, 2014 8:21 am

Re: AI Framework

Post 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 =".
alois
Posts: 112
Joined: Mon Feb 18, 2013 7:29 am

Re: AI Framework

Post 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 :)
User avatar
Eightball
Posts: 48
Joined: Thu Jan 09, 2014 8:21 am

Re: AI Framework

Post 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 "==".
alois
Posts: 112
Joined: Mon Feb 18, 2013 7:29 am

Re: AI Framework

Post 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 :)
User avatar
Eightball
Posts: 48
Joined: Thu Jan 09, 2014 8:21 am

Re: AI Framework

Post 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.
alois
Posts: 112
Joined: Mon Feb 18, 2013 7:29 am

Re: AI Framework

Post 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 :)
chaoscommencer
Posts: 119
Joined: Sun Jan 05, 2014 7:48 pm

Re: AI Framework

Post 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...
Working on a dungeon that displays a massive collection of assets while sorting them into convenient reusable plugin format (concept from some of leki's mods). Will contribute some of my own models as well eventually and follow that with custom dungeon.
Post Reply