Raised This Month: $12 Target: $400
 3% 

NPC View Distance


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DavidJr
Senior Member
Join Date: Apr 2012
Old 06-12-2016 , 06:27   NPC View Distance
Reply With Quote #1

Hello, I'm working on zombie npc, which I don't really know what this is called. I'll use image illustration.

Black circle: NPC (info_target entity)
Blue circle: Players
Red border: The view distance of the NPC

Question is how to detect players only inside the view distance? My current code just detects the nearby players around the npc. I want to make the NPC chases (I already knew how to make the NPC moves) the player who is in it's view distance.

Thank you before.
__________________
What are you looking for here?

Last edited by DavidJr; 06-12-2016 at 06:28.
DavidJr is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-12-2016 , 06:42   Re: NPC View Distance
Reply With Quote #2

This may help you: https://mxr.alliedmods.net/hlsdk/sou...ombat.cpp#1164
klippy is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 06-12-2016 , 06:47   Re: NPC View Distance
Reply With Quote #3

Quote:
Originally Posted by KliPPy View Post
Thanks, I understand this, probably this is what I'm going to do to check the player is in the viewcone, now problem is how to create the NPC's viewcone?
__________________
What are you looking for here?

Last edited by DavidJr; 06-12-2016 at 06:51.
DavidJr is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-12-2016 , 07:09   Re: NPC View Distance
Reply With Quote #4

I don't know what do you mean by "create the NPC's viewcone", but look at line 1176:
PHP Code:
if ( flDot m_flFieldOfView 
m_flFieldOfView is the viewcone size.

https://mxr.alliedmods.net/hlsdk/source/dlls/util.h#161
Here you can see values that the game uses. Dot product result is always between -1.0 and 1.0. It's all calculated with some simple math.
klippy is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 06-12-2016 , 20:46   Re: NPC View Distance
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
I don't know what do you mean by "create the NPC's viewcone", but look at line 1176:
PHP Code:
if ( flDot m_flFieldOfView 
m_flFieldOfView is the viewcone size.

https://mxr.alliedmods.net/hlsdk/source/dlls/util.h#161
Here you can see values that the game uses. Dot product result is always between -1.0 and 1.0. It's all calculated with some simple math.
Okay thank you
__________________
What are you looking for here?
DavidJr is offline
AGoodGuy
Member
Join Date: Sep 2014
Old 06-14-2016 , 06:14   Re: NPC View Distance
Reply With Quote #6

Did you make a pathfinding yet?
Seem this is hardest work on AI gameplay.
__________________
Without Passion Life Is Nothing

Quote:
“If you can't fly then run, if you can't run then walk, if you can't walk then crawl, but whatever you do, you have to keep moving forward.”― Martin Luther King Jr.
AGoodGuy is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 06-14-2016 , 08:30   Re: NPC View Distance
Reply With Quote #7

Quote:
Originally Posted by AGoodGuy View Post
Did you make a pathfinding yet?
Seem this is hardest work on AI gameplay.
Planning to work on this feature, probably it is hard, but the hardest part is maintaining the CPU usage.
__________________
What are you looking for here?
DavidJr 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 20:07.


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