AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NPC View Distance (https://forums.alliedmods.net/showthread.php?t=283820)

DavidJr 06-12-2016 06:27

NPC View Distance
 
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.

klippy 06-12-2016 06:42

Re: NPC View Distance
 
This may help you: https://mxr.alliedmods.net/hlsdk/sou...ombat.cpp#1164

DavidJr 06-12-2016 06:47

Re: NPC View Distance
 
Quote:

Originally Posted by KliPPy (Post 2426911)

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?

klippy 06-12-2016 07:09

Re: NPC View Distance
 
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.

DavidJr 06-12-2016 20:46

Re: NPC View Distance
 
Quote:

Originally Posted by KliPPy (Post 2426922)
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 :wink:

AGoodGuy 06-14-2016 06:14

Re: NPC View Distance
 
Did you make a pathfinding yet?
Seem this is hardest work on AI gameplay. :D

DavidJr 06-14-2016 08:30

Re: NPC View Distance
 
Quote:

Originally Posted by AGoodGuy (Post 2427445)
Did you make a pathfinding yet?
Seem this is hardest work on AI gameplay. :D

Planning to work on this feature, probably it is hard, but the hardest part is maintaining the CPU usage.


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

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