Making a monster move on a predefined path?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Ixnatifual

Making a monster move on a predefined path?

Post by Ixnatifual »

Is it possible to make a monster follow a certain path somehow?
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Making a monster move on a predefined path?

Post by petri »

At least in theory you could disallow moving and turning towards tiles that are not on the predefined path using onMove and onTurn hooks. Good luck! :)
Ixnatifual

Re: Making a monster move on a predefined path?

Post by Ixnatifual »

I've used blockers instead. The problem is you're just telling it where it can't go, which means that while it's spotted the player in a different direction, it's not gonna move off on the path anytime soon. Perhaps a feature request could be made to put a "monster target" entity in a level and set a monster to target that entity instead of the party when moving. A lot of interesting monster manipulation could be done this way.
User avatar
ScroLL
Posts: 56
Joined: Tue Sep 18, 2012 12:21 pm
Location: Vermont

Re: Making a monster move on a predefined path?

Post by ScroLL »

Is it possible for us to script our own AI states?
User avatar
Favashi
Posts: 3
Joined: Thu Sep 20, 2012 3:01 pm

Re: Making a monster move on a predefined path?

Post by Favashi »

Hi!!

I was trying to do the same for my dungeon. So far I've managed to do for one monster. I think doing some modification may work for various monsters (perhaps creating an array of ids of monsters with two array mappings).

With this setup I got the monster follow the path marked in green.

Image

First you have to make a clone of the monster in the file "monsters.lua", put in the following code:

Code: Select all

cloneObject{
    name="skeleton_guard",
    baseObject = "skeleton_warrior",
    onMove = function(self, dir)
	   return movScript.chekMovement(dir)
    end,

    onTurn = function(self, dir)
       return movScript.checkTurn(dir)
    end,
}
We then create an instance of the script in the editor (I have followed the example of the spider eggs)

The script code is as follows:

Code: Select all

curr_pos = 1
mov_map  = {1,1,1,1,2,2,2,2,1,1,1,1,0,0,0,0,3,3,3,3}
turn_map  = {0,0,0,0,1,0,0,0,-1,0,0,0,-1,0,0,0,-1,0,0,0,1}

function chekMovement(dir)
	print("MOVE =>",curr_pos)
	if curr_pos >= table.getn(mov_map) then
		curr_pos = 1
	end
	if dir ~= mov_map[curr_pos] then
		return false
	end
	curr_pos = curr_pos + 1
	return true
end

function checkTurn(dir)
    print("TURN =>",curr_pos)
	if dir ~= turn_map[curr_pos] then
		return false
	end
	return true
end
Sorry for my bad English...
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: Making a monster move on a predefined path?

Post by Montis »

What happens when you move behind the monster? I could imagine it just gets stuck since tries to turn to you but can't?
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
User avatar
Favashi
Posts: 3
Joined: Thu Sep 20, 2012 3:01 pm

Re: Making a monster move on a predefined path?

Post by Favashi »

Well, according to the tests I've done, when monsters detects the party group, they try turning in his direction, but as always receive false to turn, they could not. I think the script can be improved a lot. I did it last night something quick.

Maybe there is another way to do it. A hook can be added to the "onDamage" event to cancel this behavior. It would be interesting if there was an event when they detect the party group for cancel this behaviour.
Post Reply