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

[TUT] Usage EngFunc_EntitiesInPVS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 09-14-2009 , 19:04   [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #1

This is my first tutorial.

After interpreting trigger.cpp (from HLDS), I decided to make this tutorial.

EngFunc_EntitiesInPVS (maybe the same for EngFunc_FindClientInPVS)
It returns an entity in PVS (potential visible set) of a player.
It never returns worldspawn.

In that entity returned, you have a set of chained entities using pev_chain.

Example
Code:
public whatisonPVS(id) {     static next, chain;     static class[32];     next = engfunc(EngFunc_EntitiesInPVS, id);     while(next)     {         pev(next, pev_classname, class, charsmax(class));         chain = pev(next, pev_chain);         server_print("Found entity in player (%i) PVS: ent(%i) class(%s)", id, next, class);         if(!chain)             break;         next = chain;     } }

So this function iterates over and over every entity until pev_chain is NULL.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.

Last edited by joropito; 10-16-2009 at 19:40.
joropito is offline
Send a message via MSN to joropito
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-15-2009 , 02:32   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #2

Good job! This will be useful for some tests.
It would have been better if you have added it here->
http://forums.alliedmods.net/showthread.php?t=93229

Also it would be a good idea to tell people how PVS works (not as function) as a system.
If you are interested I can give you some info about it.

Edit: Tested and it works!
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 09-15-2009 at 02:51.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-15-2009 , 03:19   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #3

Quote:
(maybe the same for EngFunc_FindClientInPVS)
When I was tested, I remember that you need to call severals times EngFunc_FindClientInPVS to get the next value of the list. Which is a pain is there is it seems a delay like 0.3s before it updates. So if you call a lot of times while 0.2s you will get the same value.

Quote:
It never returns a player entity
Just tested and it returns players. "player" is an entity.

Found entity in player (1) PVS: ent(5) class(player)
Found entity in player (1) PVS: ent(3) class(player)
Found entity in player (1) PVS: ent(1) class(player)
__________________

Last edited by Arkshine; 09-15-2009 at 03:23.
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-15-2009 , 03:40   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #4

Quote:
Originally Posted by Arkshine View Post
Just tested and it returns players. "player" is an entity.

Found entity in player (1) PVS: ent(5) class(player)
Found entity in player (1) PVS: ent(3) class(player)
Found entity in player (1) PVS: ent(1) class(player)
That is true, forgot to post that .

I haven't done any tests relating but since this function already does its job properly we don't really need EngFunc_FindClientInPVS.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 09-15-2009 , 07:34   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #5

Quote:
Originally Posted by ot_207 View Post
Good job! This will be useful for some tests.
It would have been better if you have added it here->
http://forums.alliedmods.net/showthread.php?t=93229
Please, could you add this there?

I use your tutorial a couple of times.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-15-2009 , 08:12   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #6

Ok.
After I do some tests.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 09-15-2009 , 13:30   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #7

Quote:
Originally Posted by ot_207 View Post
If you are interested I can give you some info about it.
Yes please!

I thought PVS was just what you can see (visual area) but it's like what you could see in a 360* fashion from the point where you are.

And, during my tests, I saw that the walls were ignored...
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 09-15-2009 , 15:06   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #8

Quote:
Originally Posted by joropito View Post
Yes please!

I thought PVS was just what you can see (visual area) but it's like what you could see in a 360* fashion from the point where you are.

And, during my tests, I saw that the walls were ignored...
Quote:
Originally Posted by ot_207 View Post
What is PVS?
PVS means potentially visible set, this means that the entities that we have in this list can be seen.
PVS does not hold just the entities that we see!
By knowing this we can get to the conclusion that PVS has the role of limiting data transfer for better internet connection/lower amount of data transfer!

So in small words I want to say something like this:
Code:
Entity that is in PVS => Can be seen => Data Transfer about that entity
Entity that it is not in PVS => Can not be seen => No data transfer => Save bandwidth
How does it work?
Well let's say that every room of the map is a cube.
We find ourselves in a room and that also means that we are in the cube of that room.
We can see the entities in the next rooms because the cubes of that room touch with the cube of the room we are in.
And yes the walls should be ignored! Because info about the worldspawn isn't sent to the client!
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 09-15-2009 , 15:35   Re: [TUT] Usage EngFunc_EntitiesInPVS
Reply With Quote #9

Quote:
Originally Posted by ot_207 View Post
And yes the walls should be ignored! Because info about the worldspawn isn't sent to the client!
Thanks!
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
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 10:13.


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