Raised This Month: $32 Target: $400
 8% 

Entity chase player without stuck


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 05-31-2020 , 11:47   Entity chase player without stuck
Reply With Quote #1

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?
__________________
My plugin:

Last edited by Celena Luna; 05-31-2020 at 11:47.
Celena Luna is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 05-31-2020 , 13:44   Re: Entity chase player without stuck
Reply With Quote #2

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.
Attached Files
File Type: sma Get Plugin or Get Source (Robot_Terminator.sma - 93 views - 12.2 KB)
__________________
Retired.
Xalus is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-31-2020 , 20:10   Re: Entity chase player without stuck
Reply With Quote #3

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
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-31-2020 at 21:02.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 05-31-2020 , 20:42   Re: Entity chase player without stuck
Reply With Quote #4

Make touch so zombies can pass through the 'obstacles'.
__________________
DJEarthQuake is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 06-01-2020 , 02:38   Re: Entity chase player without stuck
Reply With Quote #5

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.
__________________
Retired.
Xalus is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-01-2020 , 08:42   Re: Entity chase player without stuck
Reply With Quote #6

Quote:
Originally Posted by Xalus View Post
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 View Post
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 View Post
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 View Post
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.
__________________
My plugin:

Last edited by Celena Luna; 06-01-2020 at 08:44.
Celena Luna is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-02-2020 , 04:21   Re: Entity chase player without stuck
Reply With Quote #7

Yes celena it does consume alot of CPU but just for a while on the start of the map
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-02-2020 , 10:40   Re: Entity chase player without stuck
Reply With Quote #8

The only way I can think of is waypoints.


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!
__________________









Last edited by CrazY.; 06-02-2020 at 10:40.
CrazY. is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 06-04-2020 , 09:49   Re: Entity chase player without stuck
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
Yes celena it does consume alot of CPU but just for a while on the start of the map
Quote:
Originally Posted by CrazY. View Post
The only way I can think of is waypoints.


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
__________________
My plugin:
Celena Luna is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-05-2020 , 02:08   Re: Entity chase player without stuck
Reply With Quote #10

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.
supertrio17 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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