get rid of lots of prydon cursor trace use, only tZork's vehicles are left
authordiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Sat, 27 Feb 2010 18:26:56 +0000 (18:26 +0000)
committerdiv0 <div0@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Sat, 27 Feb 2010 18:26:56 +0000 (18:26 +0000)
git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8678 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

data/qcsrc/server/cheats.qc
data/qcsrc/server/cl_client.qc
data/qcsrc/server/cl_impulse.qc
data/qcsrc/server/cl_player.qc
data/qcsrc/server/cl_weaponsystem.qc
data/qcsrc/server/miscfunctions.qc
data/qcsrc/server/vehicles/racer.qc
data/qcsrc/server/vehicles/spiderbot.qc

index 2d7e269..0243704 100644 (file)
@@ -290,7 +290,8 @@ float CheatCommand(float argc)
                                //   howmany
                                effectnum = particleeffectnum(argv(1));
                                f = stof(argv(2));
-                               start = (1-f) * self.origin + f * self.cursor_trace_endpos;
+                               crosshair_trace(self);
+                               start = (1-f) * self.origin + f * trace_endpos;
                                end = stov(argv(3));
                                f = stof(argv(4));
                                pointparticles(effectnum, start, end, f);
@@ -395,7 +396,10 @@ float CheatCommand(float argc)
                        if(argc == 4)
                                setorigin(e.aiment, stov(argv(2)));
                        else
-                               setorigin(e.aiment, self.cursor_trace_endpos);
+                       {
+                               crosshair_trace(self);
+                               setorigin(e.aiment, trace_endpos);
+                       }
 
                        e.enemy = spawn();
                        e.enemy.classname = "dragbox_corner_2";
@@ -403,7 +407,7 @@ float CheatCommand(float argc)
                        setmodel(e.enemy, "models/marker.md3");
                        e.enemy.skin = 1;
                        setsize(e.enemy, '0 0 0', '0 0 0');
-                       end = normalize(self.cursor_trace_start - e.aiment.origin);
+                       end = normalize(self.origin + self.view_ofs - e.aiment.origin);
                        end_x = (end_x > 0) * 2 - 1;
                        end_y = (end_y > 0) * 2 - 1;
                        end_z = (end_z > 0) * 2 - 1;
@@ -442,7 +446,8 @@ float CheatCommand(float argc)
                                setorigin(e, stov(argv(2)));
                        else
                        {
-                               setorigin(e, self.cursor_trace_endpos + normalize(self.cursor_trace_start - self.cursor_trace_endpos));
+                               crosshair_trace(self);
+                               setorigin(e, trace_endpos + normalize(self.origin + self.view_ofs - trace_endpos));
                                move_out_of_solid(e);
                        }
 
@@ -461,10 +466,11 @@ float CheatCommand(float argc)
                case "drag_remove":
                        IS_CHEAT(0, argc, 0);
                        RandomSelection_Init();
+                       crosshair_trace(self);
                        for(e = world; (e = find(e, classname, "dragbox_box")); )
-                               RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+                               RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                        for(e = world; (e = find(e, classname, "dragpoint")); )
-                               RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+                               RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                        if(RandomSelection_chosen_ent)
                        {
                                remove(RandomSelection_chosen_ent.killindicator.killindicator);
@@ -482,10 +488,11 @@ float CheatCommand(float argc)
                        if(argc == 2)
                        {
                                RandomSelection_Init();
+                               crosshair_trace(self);
                                for(e = world; (e = find(e, classname, "dragbox_box")); )
-                                       RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+                                       RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                                for(e = world; (e = find(e, classname, "dragpoint")); )
-                                       RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - self.cursor_trace_endpos));
+                                       RandomSelection_Add(e, 0, string_null, 1, 1 / vlen(e.origin + (e.mins + e.maxs) * 0.5 - trace_endpos));
                                if(RandomSelection_chosen_ent)
                                {
                                        if(substring(argv(1), 0, 1) == "*")
@@ -721,20 +728,23 @@ float CheatFrame()
        {
                if(Drag_CanDrag(self))
                        if(self.BUTTON_DRAG)
-                               if(self.cursor_trace_ent)
-                                       if(Drag_IsDraggable(self.cursor_trace_ent))
+                       {
+                               crosshair_trace(self);
+                               if(trace_ent)
+                                       if(Drag_IsDraggable(trace_ent))
                                                switch(0)
                                                {
                                                        default:
                                                                IS_CHEAT(0, 0, CHRAME_DRAG);
-                                                               if(self.cursor_trace_ent.draggedby)
-                                                                       Drag_Finish(self.cursor_trace_ent.draggedby);
-                                                               if(self.cursor_trace_ent.tag_entity)
-                                                                       detach_sameorigin(self.cursor_trace_ent);
-                                                               Drag_Begin(self, self.cursor_trace_ent, self.cursor_trace_endpos);
+                                                               if(trace_ent.draggedby)
+                                                                       Drag_Finish(trace_ent.draggedby);
+                                                               if(trace_ent.tag_entity)
+                                                                       detach_sameorigin(trace_ent);
+                                                               Drag_Begin(self, trace_ent, trace_endpos);
                                                                DID_CHEAT();
                                                                break;
                                                }
+                       }
        }
 
        END_CHEAT_FUNCTION();
index 6b60833..64c5bd2 100644 (file)
@@ -1292,6 +1292,8 @@ void FixClientCvars(entity e)
        stuffcmd(e, "\nin_bindmap 0 0\n");
        if(g_race || g_cts)
                stuffcmd(e, "cl_cmd settemp cl_movecliptokeyboard 2\n");
+       if(cvar("g_antilag") == 3) // client side hitscan
+               stuffcmd(e, "cl_cmd settemp cl_prydoncursor -1\n");
        /*
         * we no longer need to stuff this. Remove this comment block if you feel
         * 2.3 and higher (or was it 2.2.3?) don't need these any more
index fd1dd64..1c191b9 100644 (file)
@@ -140,7 +140,8 @@ void ImpulseCommands (void)
                                sprint(self, "personal waypoint spawned at location\n");
                                break;
                        case 31:
-                               wp = WaypointSprite_DeployPersonal("waypoint", self.cursor_trace_endpos);
+                               crosshair_trace(self);
+                               wp = WaypointSprite_DeployPersonal("waypoint", trace_endpos);
                                if(wp)
                                {
                                        WaypointSprite_UpdateTeamRadar(wp, RADARICON_WAYPOINT, '0 1 1');
@@ -183,7 +184,8 @@ void ImpulseCommands (void)
                                sprint(self, "HERE spawned at location\n");
                                break;
                        case 35:
-                               wp = WaypointSprite_DeployFixed("here", FALSE, self.cursor_trace_endpos);
+                               crosshair_trace(self);
+                               wp = WaypointSprite_DeployFixed("here", FALSE, trace_endpos);
                                if(wp)
                                {
                                        WaypointSprite_UpdateTeamRadar(wp, RADARICON_HERE, '0 1 0');
@@ -213,7 +215,8 @@ void ImpulseCommands (void)
                                sprint(self, "DANGER spawned at location\n");
                                break;
                        case 38:
-                               wp = WaypointSprite_DeployFixed("danger", FALSE, self.cursor_trace_endpos);
+                               crosshair_trace(self);
+                               wp = WaypointSprite_DeployFixed("danger", FALSE, trace_endpos);
                                if(wp)
                                {
                                        WaypointSprite_UpdateTeamRadar(wp, RADARICON_DANGER, '1 0.5 0');
index 56c9c64..bfeb75c 100644 (file)
@@ -811,9 +811,10 @@ void UpdateSelectedPlayer()
        makevectors(self.v_angle); // sets v_forward
 
        // 1. cursor trace is always right
-       if(self.cursor_trace_ent && self.cursor_trace_ent.classname == "player" && !self.cursor_trace_ent.deadflag)
+       crosshair_trace(self);
+       if(trace_ent && trace_ent.classname == "player" && !trace_ent.deadflag)
        {
-               selected = self.cursor_trace_ent;
+               selected = trace_ent;
        }
        else
        {
index d2d4141..07ecdb6 100644 (file)
@@ -208,6 +208,7 @@ void W_SetupShot_Dir_ProjectileSize(entity ent, vector s_forward, vector mi, vec
                }
                else if(cvar("g_antilag") == 3) // client side hitscan
                {
+                       // this part MUST use prydon cursor
                        if (ent.cursor_trace_ent)                 // client was aiming at someone
                        if (ent.cursor_trace_ent != ent)         // just to make sure
                        if (ent.cursor_trace_ent.takedamage)      // and that person is killable
index 9fbac8f..eaf7282 100644 (file)
@@ -3,6 +3,13 @@ void objerror(string s);
 void droptofloor();
 .vector dropped_origin;
 
+void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag);
+void crosshair_trace(entity pl)
+{
+       makevectors(pl.v_angle);
+       traceline_antilag(pl, pl.origin + pl.view_ofs, pl.origin + pl.view_ofs + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, pl, ANTILAG_LATENCY(pl));
+}
+
 void() spawnfunc_info_player_deathmatch; // needed for the other spawnpoints
 void() spawnpoint_use;
 float race_GetTime(float pos);
@@ -440,11 +447,17 @@ string formatmessage(string msg)
 {
        float p, p1, p2;
        float n;
+       vector cursor;
+       entity cursor_ent;
        string escape;
        string replacement;
        p = 0;
        n = 7;
 
+       crosshair_trace(self);
+       cursor = trace_endpos;
+       cursor_ent = trace_ent;
+
        while (1) {
                if (n < 1)
                        break; // too many replacements
@@ -480,7 +493,7 @@ string formatmessage(string msg)
                else if (escape == "l")
                        replacement = NearestLocation(self.origin);
                else if (escape == "y")
-                       replacement = NearestLocation(self.cursor_trace_endpos);
+                       replacement = NearestLocation(cursor);
                else if (escape == "d")
                        replacement = NearestLocation(self.death_origin);
                else if (escape == "w") {
@@ -498,8 +511,8 @@ string formatmessage(string msg)
                        else if (self.items & IT_CELLS) replacement = "cells";
                        else replacement = "batteries"; // ;)
                } else if (escape == "x") {
-                       replacement = self.cursor_trace_ent.netname;
-                       if (!replacement || !self.cursor_trace_ent)
+                       replacement = cursor_ent.netname;
+                       if (!replacement || !cursor_ent)
                                replacement = "nothing";
                } else if (escape == "p") {
                        if (self.last_selected_player)
index caa0694..3e36dc8 100644 (file)
@@ -200,6 +200,7 @@ void racer_fire_cannon(string tagname)
     setorigin(bolt, gettaginfo(self,gettagindex(self,tagname)));
 
     vector v;
+       // FIXME this uses prydon cursor
     v = normalize(self.owner.cursor_trace_endpos - bolt.origin);
     v_forward_z = v_z * 0.5;
     //v_forward_z *= 0.5;
@@ -454,6 +455,7 @@ float racer_pplug()
 
     /*
     // for homing rockets
+       // FIXME this uses prydon cursor
     if(self.owner.cursor_trace_ent)
     {
         self.tur_head.gun1 = self.owner.cursor_trace_ent;
index b50aa4a..a6d21f7 100644 (file)
@@ -70,6 +70,7 @@ void spiderbot_rocket_think()
     self.solid      = SOLID_BBOX;
     self.touch      = spiderbot_rocket_touch;
     olddir = normalize(self.velocity);
+       // FIXME this uses prydon cursor
     //newdir = normalize(self.owner.cursor_trace_endpos - self.origin);
     newdir = normalize(self.pos1 - self.origin);
     newdir += randomvec() * cvar("g_vehicle_spiderbot_rocket_noise");
@@ -129,6 +130,7 @@ void spiderbot_rocket_do()
     rocket.think           = spiderbot_rocket_think;
     rocket.flags           = FL_PROJECTILE;
     rocket.solid           = SOLID_NOT;
+       // FIXME this uses prydon cursor
     rocket.pos1            = self.owner.cursor_trace_endpos;
 
        CSQCProjectile(rocket, FALSE, PROJECTILE_ROCKET, FALSE); // no culling, has fly sound