Frictional Games Forum (read-only)
Help with grunt maze pathfinding? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Help with grunt maze pathfinding? (/thread-21075.html)

Pages: 1 2


Help with grunt maze pathfinding? - zergling50 - 04-06-2013

I have a situation where you are in a maze like area and you have to run and try to find something while under the pressure of the monster chasing you (there are no dead ends only loop backs). The problem is of course that the grunt gets stuck and tries walking through the walls when I use ShowEnemyPlayerPosition instead of chasing down the player. Since I know actually coding some sort of improved pathfinding for the grunt is probably out of the question (too big of a task) I was wondering if there were any tips or tricks you guys had for accomplishing this? One idea I had was to set script areas randomly throughout the maze with a deactivated grunt near them and whenever the player walks over one it disables all the other grunts and activates that one, but I realized this would only work the first time and if the player ran back to that area and stepped on it the grunt would be somewhere else. I tried seeing if there was a method that let you move a grunt instantly somewhere else but I couldn't find anything. Any suggestions?


RE: Help with grunt maze pathfinding? - PutraenusAlivius - 04-07-2013

Here. This was a script made by Kyle S.
void OnStart()
{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("servant_grunt_1", "PNScriptArea", "MonsterFunction2", false, 1);
}
void MonsterFunction2()
{
for (int i = 1; i <6; i++)
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, 0, "");
}
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1",true);
for (int i = 1; i <11; i++)
{
int x;
switch( i )
{
case 0:
x = 2;
break;
case 10:
x = 4;
break;
default
x = 0;
}
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, x, "");
}
}

Please note that the monster will NOT stop unless you deactivate it.


RE: Help with grunt maze pathfinding? - zergling50 - 04-07-2013

(04-07-2013, 06:42 AM)JustAnotherPlayer Wrote: Here. This was a script made by Kyle S.
void OnStart()
{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("servant_grunt_1", "PNScriptArea", "MonsterFunction2", false, 1);
}
void MonsterFunction2()
{
for (int i = 1; i <6; i++)
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, 0, "");
}
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1",true);
for (int i = 1; i <11; i++)
{
int x;
switch( i )
{
case 0:
x = 2;
break;
case 10:
x = 4;
break;
default
x = 0;
}
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, x, "");
}
}

Please note that the monster will NOT stop unless you deactivate it.

This seems really cool, is there anything I need to set up for it to work or just add it to my code and run it?


RE: Help with grunt maze pathfinding? - PutraenusAlivius - 04-08-2013

(04-07-2013, 08:39 PM)zergling50 Wrote:
(04-07-2013, 06:42 AM)JustAnotherPlayer Wrote: Here. This was a script made by Kyle S.
void OnStart()
{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("servant_grunt_1", "PNScriptArea", "MonsterFunction2", false, 1);
}
void MonsterFunction2()
{
for (int i = 1; i <6; i++)
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, 0, "");
}
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1",true);
for (int i = 1; i <11; i++)
{
int x;
switch( i )
{
case 0:
x = 2;
break;
case 10:
x = 4;
break;
default
x = 0;
}
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, x, "");
}
}

Please note that the monster will NOT stop unless you deactivate it.

This seems really cool, is there anything I need to set up for it to work or just add it to my code and run it?
Just try to add it to your code and run it.


RE: Help with grunt maze pathfinding? - zergling50 - 04-11-2013

(04-08-2013, 02:05 AM)JustAnotherPlayer Wrote:
(04-07-2013, 08:39 PM)zergling50 Wrote:
(04-07-2013, 06:42 AM)JustAnotherPlayer Wrote: Here. This was a script made by Kyle S.
void OnStart()
{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("servant_grunt_1", "PNScriptArea", "MonsterFunction2", false, 1);
}
void MonsterFunction2()
{
for (int i = 1; i <6; i++)
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, 0, "");
}
}
void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1",true);
for (int i = 1; i <11; i++)
{
int x;
switch( i )
{
case 0:
x = 2;
break;
case 10:
x = 4;
break;
default
x = 0;
}
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, x, "");
}
}

Please note that the monster will NOT stop unless you deactivate it.

This seems really cool, is there anything I need to set up for it to work or just add it to my code and run it?
Just try to add it to your code and run it.

When I try running the game it says ERR : Expected ':'
and seems to be pointing around this area in the code

break;
default
x = 0;

also one concern i have is the code references a "PNScriptArea" in one of the addentitycollidecallback's and I have not made any area called this. Do I have to, and what is it's intended purpose so I know where to place it.


RE: Help with grunt maze pathfinding? - Romulator - 04-11-2013

(04-11-2013, 12:04 AM)zergling50 Wrote:
(04-08-2013, 02:05 AM)JustAnotherPlayer Wrote:
(04-07-2013, 08:39 PM)zergling50 Wrote: When I try running the game it says ERR : Expected ':'

and seems to be pointing around this area in the code



break;

default

x = 0;

also one concern i have is the code references a "PNScriptArea" in one of the addentitycollidecallback's and I have not made any area called this. Do I have to, and what is it's intended purpose so I know where to place it.
Put a : after default, and if that doesn't work, I am unsure.
The AddEntityCollideCallback up the top suggests that it is a script where the Monster collides with in order to carry out something, but because that actual script is not mentioned in any of the above posts, it may or may not be relevant to your dilemma. The PNScriptArea itself is the name of the script if it existed Smile


RE: Help with grunt maze pathfinding? - NaxEla - 04-11-2013

By the way, this is where JustAnotherPlayer got the script from: http://wiki.frictionalgames.com/hpl2/tutorials/script/monsterpathnodes
Reading that page might help you with this situation.


RE: Help with grunt maze pathfinding? - zergling50 - 06-11-2013

(04-11-2013, 07:55 AM)NaxEla Wrote: By the way, this is where JustAnotherPlayer got the script from: http://wiki.frictionalgames.com/hpl2/tutorials/script/monsterpathnodes
Reading that page might help you with this situation.

thanks I'll take a look and see.
I've had to put this project on the backburner for a bit but im back into it now so sorry for the long delay.


RE: Help with grunt maze pathfinding? - GrAVit - 06-12-2013

That script which was suggested has to do with monster patrolling.

If you want the grunt to effectively chase you down in a maze, this script really does nothing about it.

The way to stop the grunt from getting stuck in walls is to add pathnodes, you can add them using the area tool and selecting pathnodes from the dropdown menu.



Pathnodes help the grunt navigate the maze. They don't have to be scripted to work. Place them approximately the same distance away from each other. Also, they don't have to be too close to each other, but stairs should have a pathnode on every step of the stairs. If you want an idea of how to place them even better, check out one of the original Amnesia maps.


RE: Help with grunt maze pathfinding? - Daemian - 06-12-2013

Your first solution may work using the ResetProp function on the grunts.
I'm not sure if this works for enemies. Give a try.

But i wouldn't use ShowEnemyPlayerPosition on a maze.
I think it's better to just put a slow walking grunt and give him a set of pathnodes to follow.
Then, after a while, you repeat this with a timer.