Forum

DP_EF_NODEPTHTEST

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Re: DP_EF_NODEPTHTEST

Postby mh » Sat Feb 11, 2012 12:13 am

6. The "shouldn't really happen, but does occasionally" stuff - more pointcontents and in cases where it does happen (i.e. the trace leaves you stuck in solid) even more.

pointcontents is another killer by the way. If I modify PF_pointcontents to always return CONTENTS_EMPTY I can get a 4-5 x speedup in some maps.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: DP_EF_NODEPTHTEST

Postby Ghost_Fang » Sat Feb 11, 2012 5:14 am

Spike wrote:customizeentityforclient is your friend...

Code: Select all
float() somecustomizefunction =
{
    traceline(other.origin + other.view_ofs, self.owner.origin, TRUE, other);
    if (trace_fraction == 1 || trace_entity == self.owner)
        return FALSE; /*trace hit our owner, so tell the server to not send us to this player*/

    /*the trace hit something first, we are obscured, so we should make ourselves explicitly visible*/
    setorigin(self, self.owner.origin + '0 0 48'); /*might as well update the entity in here*/
    return TRUE; /*allow the server to send this entity to the client*/
};

.float() customizeentityforclient; /*including this in case you don't have a suitable header*/

void() spawn_head_sprite =
{
    local entity foo;
    foo = spawn();
    setmodel(foo, "progs/p_ind.spr");
    foo.owner = self;
    foo.customizeentityforclient = somecustomizefunction;
    foo.effects = EF_NODEPTHTEST;
};


will give you an indicator above some victim's head that is only visible when that victim is obscured, that should also work fine in coop/deathmatch/whatever.
Uses EF_NODEPTHTEST and DP_SV_CUSTOMIZEENTITYFORCLIENT extensions.


Either I'm not fully understanding customizeentityforclient entirely, or it may have been just my sloppy way of doing team markers. But I can't seem to get it.
who is the returned value for? the entity being customized? or the client that wants the entity customized?

Well here is what I did, i rewrote it, a tad bit cleaner, everyone spawns their OWN marker above their own heads, I then just use nodrawtoclient = self.owner.
Under what terms and conditions would i use customizeentityforclient if I wanted other players to only see my icon if their view of me is obstructed?

Here is my new code:

Code: Select all
void() markerloop =
   {
   if(self.owner.health < 1)
      setmodel(self, "progs/ind_die.spr");
   else if (self.owner.health > 0)
      setmodel(self, "progs/p_ind.spr");
   else
      setmodel(self, "progs/flash.spr");
   if(self.owner.health > 0)
      setorigin(self, self.owner.origin + '0 0 35');
   self.think = markerloop;
   self.nextthink = time + 0.01;
   }
   
void() spawn_marker =
   {
   if(deathmatch)
      return;
      
   local entity entheader
   
   entheader = spawn();
   entheader.owner = self;
   
   setorigin(entheader, self.origin + '0 0 35');
   entheader.movetype = MOVETYPE_NONE;
   entheader.solid = SOLID_NOT;
   entheader.effects = entheader.effects | EF_NODEPTHTEST;
   entheader.nodrawtoclient = self;
   entheader.think = markerloop;
   entheader.nextthink = time + 0.05;
   
   };
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Re: DP_EF_NODEPTHTEST

Postby Spike » Sat Feb 11, 2012 5:50 am

customizeentityforclient is called by the engine just before it sends the data to the client.

if it returns false, then the server will consider the entity(self) to be invisible to the player(other).
the function is generally expected to modify the entity's various fields to be player-specific (note that the changes will not be undone, so changing origin will affect physics later on).
so you can return false to filter the entity, and you can call setorigin inside to ensure that the model moves with whatever rate the server is sending out packets.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: DP_EF_NODEPTHTEST

Postby Ghost_Fang » Sun Feb 12, 2012 1:03 am

So i don't have to specify who "other" is? It just automatically assumes all clients? And only the client(s) (other) who return TRUE can see it and/or the changes?
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Re: DP_EF_NODEPTHTEST

Postby Spike » Sun Feb 12, 2012 1:39 am

the engine calls it for every single client, even spectators.
self is the entity who's self.customizeentityforclient is set.
other is whatever client the server is currently trying to send a message to.
you don't call it from qc code, you only set the field so the engine knows what to call at the appropriate time.

'other' is each and every client, in turn. the engine will call your function as many times per (network)frame as there are clients that need new messages.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: DP_EF_NODEPTHTEST

Postby Ghost_Fang » Sun Feb 12, 2012 5:19 pm

Ok i think i understand, but do I gotta set the conditions of it to be viewed my a specific client?
I did something simple like if(self.owner != other)
Or would I put more arguments in there such as if(self.owner == other) self.nodrawtoclient = other;
Man, I apologize, for some reason this one isnt clicking for me :/
Ghost_Fang
 
Posts: 336
Joined: Thu Nov 12, 2009 4:37 am

Previous

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest