Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with grunt maze pathfinding?
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#1
Help with grunt maze pathfinding?

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?
(This post was last modified: 06-16-2013, 02:55 AM by zergling50.)
04-06-2013, 09:08 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Help with grunt maze pathfinding?

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.

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 04-07-2013, 06:43 AM by PutraenusAlivius.)
04-07-2013, 06:42 AM
Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#3
RE: Help with grunt maze pathfinding?

(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?
04-07-2013, 08:39 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#4
RE: Help with grunt maze pathfinding?

(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.

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-08-2013, 02:05 AM
Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#5
RE: Help with grunt maze pathfinding?

(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.
04-11-2013, 12:04 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Help with grunt maze pathfinding?

(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

Discord: Romulator#0001
[Image: 3f6f01a904.png]
04-11-2013, 07:39 AM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#7
RE: Help with grunt maze pathfinding?

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

In Ruins [WIP]
04-11-2013, 07:55 AM
Find
zergling50 Offline
Member

Posts: 74
Threads: 9
Joined: Jul 2012
Reputation: 1
#8
RE: Help with grunt maze pathfinding?

(04-11-2013, 07:55 AM)NaxEla Wrote: By the way, this is where JustAnotherPlayer got the script from: http://wiki.frictionalgames.com/hpl2/tut...rpathnodes
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.
06-11-2013, 08:25 PM
Find
GrAVit Offline
Senior Member

Posts: 580
Threads: 15
Joined: Oct 2011
Reputation: 22
#9
RE: Help with grunt maze pathfinding?

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.

(This post was last modified: 06-12-2013, 08:02 AM by GrAVit.)
06-12-2013, 07:59 AM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#10
RE: Help with grunt maze pathfinding?

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.

06-12-2013, 12:41 PM
Find




Users browsing this thread: 2 Guest(s)