Announcement

Collapse
No announcement yet.

Mod question reguarding centerprint.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mod question reguarding centerprint.

    So, about yesterday, I added (well, cobalt did) a bit of code to show the name of players when you look at them.

    It works fine, but the only problem is that the centerprint lasts too long, so I was wondering how to shorten the time of display.

  • #2
    try posting the code so some one can edit it

    Comment


    • #3
      Originally posted by JDSTONE View Post
      try posting the code so some one can edit it
      d00d, it's literally just centerprint, but okay.

      void () TraceID =
      {
      makevectors (self.v_angle);
      traceline (self.origin, (self.origin + (v_forward * 1000)), FALSE, self);
      if ((trace_ent.classname == "player"))
      {
      centerprint (self, trace_ent.netname);
      }
      };

      void() W_WeaponFrame =
      {
      if (time < self.attack_finished)
      return;

      if (self.impulse)
      ImpulseCommands ();

      // check for attack
      if (self.button0)
      {
      SuperDamageSound ();
      W_Attack ();
      }

      if (self.velocity == VEC_ORIGIN && (self.flags & FL_CLIENT))
      TraceID ();
      };

      Comment


      • #4
        The only obvious thing that I can think of is sending a blank centerprint when there's no player under the crosshairs. But that could end up being a lot of centerprint spam (some engines log centerprints to the console). What you could do is create a field to store a cutoff time (.float cprintname_finished;), and set that on self to time + 0.5 whenever a name is detected. Then add an else if clause for that time having passed, and sending a blank centerprint if time has expired.

        The velocity comparison won't work as you intend it to. There's an obnoxious bug in the way that the engine does comparisons on vectors, where it only compares the x components. As a workaround, with added flexibility of "if the player is moving slowly", you can take the player's speed (velocity without direction, so it's just a number) and work with that instead. Something like if (vlen(self.velocity) < 50) would do it, although there's a trick that you can do that skips a function call (which is slow, although this kinda stopped mattering about 10-15 years ago), which is to multiply the vector by itself (which computes the dot product), and compare that to the speed limit squared.

        Also, you don't need to check for FL_CLIENT, as W_WeaponFrame() is only ever called from PlayerPostThink(), which the engine only ever calls for players.
        Intelligence is knowing that there is an 'i' in "community".
        Wisdom is knowing that there is no 'i' in "community".

        Comment


        • #5
          This could probably be done a lot simpler and more professionally in CSQC I would imagine, if you ever plan on going client-side with your mod. You have complete control of what appears on the player's screen. You might even be able to make the letters smaller and slightly transparent to make them less obnoxious in the center of the player's view.

          I may be wrong though. Never really dug into myself. All I'm saying is it might be worth looking into.
          'Replacement Player Models' Project

          Comment


          • #6
            here's what i do in CAx
            just ignore the code you dont understand, youll understand whats going on enough..
            in player_postthink after W_WeaponFrame();
            Code:
            	if (ca_gametype & CA_MATCH_MODE)
            	{
            		if (!mode_duel())//duel is one on one no team mates to identify...		
            		{
            			if (time > self.id_time)
            			{
            				ident_get_target();
            				self.id_time = (time + 0.3);
            			}
            		}
            	}

            which calls this
            Code:
            void () ident_update_display =
            {
            	string aval,hval;
            	
            	aval = strings_get_armour_val(trace_ent);
            	hval = ftos(trace_ent.health);
            	centerprint6 (self, trace_ent.netname, "\n\b[\b", aval,"œ",hval,"\b]\b\n\n\n\n");
            };
            
            void () ident_get_target =
            {
            	makevectors (self.v_angle);
            	traceline (self.origin, self.origin + v_forward * 1200, FALSE, self);
            	if (trace_fraction < 1)
            	{
            		if (trace_ent.classname == "player" && trace_ent.style & CA_CONNECTED)
            		{
            			if (trace_ent.team2 == self.team2)
            				ident_update_display ();
            		}
            	}
            };
            I have created a timer (.float id_time), so the centerprint is only every 0.3 seconds, not each frame.

            There is also a client console command that determines the time the centerprint lasts.
            I cant remember, "con_notify_time' or something like that...
            Last edited by R00k; 08-08-2016, 09:25 PM.
            www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

            Comment


            • #7
              scr_centertime 2; this cvar controls how long centerprints are visible for.
              of course, if you were to change it to something smaller then you mess up mapper-placed centerprint triggers.
              instead, use both a timer and a last-displayed entity. tweak all those trigger .message things to reset the timer to not break centerprints for two secs. tweak your id thing to be run every frame, but only display if the entity isn't the last displayed one or the timer expired. really the timer is just there to keep it displayed rather than anything else. if the identified player becomes world, just send a centerprint with an empty string to clear it out instantly, reducing the latency.
              or something.
              300ms delays are quite a long time in the heat of battle, imho.
              Some Game Thing

              Comment


              • #8
                Code:
                		if (time > self.id_time)
                		{
                			ident_get_target();
                			self.id_time = (time + 0.3);
                		}
                		else
                		{
                			if (time == self.id_time)
                			{
                				centerprint(self,"");
                			}
                		}
                you dont really need it to traceline every frame, just to find a team-mate around you. 90% of the time i dont notice the overhead name i just see the color and keep rolling.
                I had to tweak the timing as too long and it would strobe affect with the engine timer, too short and your spamming.
                Last edited by R00k; 08-09-2016, 11:13 AM.
                www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

                Comment


                • #9
                  I personally dislike the variable response times nor the latency from that. it otherwise doesn't matter too much.

                  actually sending something every frame isn't needed (and can easily overflow buffers if the reliables don't get acked for a while with large menu-like centerprints - fte actually has some mitigation to avoid this). doing the check every frame doesn't mean you have to resend a centerprint every frame, thereby actually reducing the network spam (not that its too significant when its just a player's name).

                  remember that reliables can block other reliables, so if you're spamming centerprints then you're potentially delaying any reliable sounds etc, if you're using those, anyway.
                  its a shame that MSG_ONE is exclusively reliable, meaning there's no real way around it with most engines. or maybe I'm just overthinking everything. yet again.
                  Some Game Thing

                  Comment


                  • #10
                    still unreachable bro...right?

                    Code:
                    	if (time >[color="red"]=[/color] self.id_time)
                    	{
                    		if (time == self.id_time) //how can it be equal if you come in greater than
                    			return centerprint(self,""); //clear centerprint and get out of here in one line
                    
                    		ident_get_target();
                    		self.id_time = (time + 0.3);
                    	}
                    I don't understand how your first version will never reach the second condition. Are you saying time will always be greater than id_time? if so, how could it ever be equal?
                    Last edited by MadGypsy; 08-10-2016, 09:10 AM.
                    http://www.nextgenquake.com

                    Comment


                    • #11
                      you're right, the first version was correct; i was re-reading the message 8 hours later after beer.
                      Last edited by R00k; 08-10-2016, 10:35 AM.
                      www.quakeone.com/qrack | www.quakeone.com/cax| http://en.twitch.tv/sputnikutah

                      Comment


                      • #12
                        self.beer ? return later : nextthink;

                        lol
                        http://www.nextgenquake.com

                        Comment

                        Working...
                        X