Making a monster move on a predefined path?
-
Ixnatifual
Making a monster move on a predefined path?
Is it possible to make a monster follow a certain path somehow?
Re: Making a monster move on a predefined path?
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?
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.
Re: Making a monster move on a predefined path?
Is it possible for us to script our own AI states?
Re: Making a monster move on a predefined path?
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.

First you have to make a clone of the monster in the file "monsters.lua", put in the following code:
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:
Sorry for my bad English...
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.

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,
}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- 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?
What happens when you move behind the monster? I could imagine it just gets stuck since tries to turn to you but can't?
Re: Making a monster move on a predefined path?
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.
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.