AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity chase player without stuck (https://forums.alliedmods.net/showthread.php?t=324905)

Celena Luna 05-31-2020 11:47

Entity chase player without stuck
 
I am writing an Zombie Entity that would chase player when they when close.
But the map have a lot of obstacles that player can abuse and make the Zombie stuck on the other side (like a table or a car) and kill it easily

I was thinking about using A* Pathfinding but it cost a lot of CPU

Another method I was think of is mark player's origin every 10 distance => Make Zombie go to that origin in order

But it make the Zombie look stupid if player just running around a circle and then the Zombie did the same.

Is there other method/way I could use for this problem?

Xalus 05-31-2020 13:44

Re: Entity chase player without stuck
 
1 Attachment(s)
I've try'd to make such Zombie AI in the past,
I'll add the code, see if there is anything usefull in it.

NOTE: Only a few functions work, A* Pathfinding is broken to last time I tested it.
Also code is old, optimizes recommended.

Natsheh 05-31-2020 20:10

Re: Entity chase player without stuck
 
i'd suggest to make a predefined path origins for the map.

as czbots work

You do still need efficient path finder to help you with the obstacle and setting the path origins

DJEarthQuake 05-31-2020 20:42

Re: Entity chase player without stuck
 
Make touch so zombies can pass through the 'obstacles'.

Xalus 06-01-2020 02:38

Re: Entity chase player without stuck
 
Marking the player origin is an option,
if you add a check that bot could skip a few if possible & faster.

That would solve the circle problem.

Celena Luna 06-01-2020 08:42

Re: Entity chase player without stuck
 
Quote:

Originally Posted by Xalus (Post 2703341)
I've try'd to make such Zombie AI in the past,
I'll add the code, see if there is anything usefull in it.

NOTE: Only a few functions work, A* Pathfinding is broken to last time I tested it.
Also code is old, optimizes recommended.

I did something similar but the time to find and update the path was slower than entity's think so it usually move 1-2 second slower than the actual path. Also, it isn't detect as the boss size but player size so it seem broke. (I did saw the video on that plugin)

Quote:

Originally Posted by Natsheh (Post 2703399)
i'd suggest to make a predefined path origins for the map.

as czbots work

You do still need efficient path finder to help you with the obstacle and setting the path origins

is it like setting up origin then make the entity move to the origin in order to get to player? but isn't then every think, it have to loop all the predefined origin to check to see which origin is player close to and cost a lot of CPU?

Quote:

Originally Posted by DJEarthQuake (Post 2703400)
Make touch so zombies can pass through the 'obstacles'.

Oh, I really like a Zombie that can 1-shot walk though wall and slap me.
No, thank you.

Quote:

Originally Posted by Xalus (Post 2703429)
Marking the player origin is an option,
if you add a check that bot could skip a few if possible & faster.

That would solve the circle problem.

That what I planned at first but then how to I store it? if there is another Zombie Entity there, they update overlap each other if I using Array from ArrayCreate(). I need to clear the previous origin when reach so Stack like Array is needed.

Natsheh 06-02-2020 04:21

Re: Entity chase player without stuck
 
Yes celena it does consume alot of CPU but just for a while on the start of the map

CrazY. 06-02-2020 10:40

Re: Entity chase player without stuck
 
The only way I can think of is waypoints.
https://user-images.githubuserconten...54230fbcbb.png

The logic is quite simple, but will take some work.
1. You need to set the waypoints for each map and save the data, similar to map spawns editor.
2. In the zombie "walk function", check if there is any obstacle. If false, keep moving, if true, look for the waypoint closest to the zombie towards of its target and move it towards that point.
3. When there's no more obstacle or case the zombie has already walked to the waypoint, repeat from step 2
4. When the zombie reach its target, attack!

You can try to take a look at the artificial intelligence codes to see how it works like Podbots, HL1 source code or an open source game engine like Godot, and try to implement with amxx.

It's not impossible, it will just take some work. Good luck!

Celena Luna 06-04-2020 09:49

Re: Entity chase player without stuck
 
Quote:

Originally Posted by Natsheh (Post 2703617)
Yes celena it does consume alot of CPU but just for a while on the start of the map

Quote:

Originally Posted by CrazY. (Post 2703668)
The only way I can think of is waypoints.
https://user-images.githubuserconten...54230fbcbb.png

The logic is quite simple, but will take some work.
1. You need to set the waypoints for each map and save the data, similar to map spawns editor.
2. In the zombie "walk function", check if there is any obstacle. If false, keep moving, if true, look for the waypoint closest to the zombie towards of its target and move it towards that point.
3. When there's no more obstacle or case the zombie has already walked to the waypoint, repeat from step 2
4. When the zombie reach its target, attack!

You can try to take a look at the artificial intelligence codes to see how it works like Podbots, HL1 source code or an open source game engine like Godot, and try to implement with amxx.

It's not impossible, it will just take some work. Good luck!

Thank you. I will try and see if it work.
It is gonna be long :crab:

supertrio17 06-05-2020 02:08

Re: Entity chase player without stuck
 
Is there any way to "predict" the players path, or to use player path and randomize it a bit, so it wont look like that.


All times are GMT -4. The time now is 10:56.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.