]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into samual/menu_updates
authorSamual <samual@xonotic.org>
Mon, 16 Jan 2012 17:31:30 +0000 (12:31 -0500)
committerSamual <samual@xonotic.org>
Mon, 16 Jan 2012 17:31:30 +0000 (12:31 -0500)
defaultXonotic.cfg
qcsrc/csqcmodellib/cl_player.qc
qcsrc/server/cheats.qc
qcsrc/server/cl_weapons.qc
qcsrc/server/t_items.qc

index b04e49c921fbbdc29886c29d1d6b235716afb5e8..c61d7d7ed91adaa5d5fec67aa6a53deec6ea01c0 100644 (file)
@@ -1782,6 +1782,7 @@ seta cl_forceplayercolors 0 "make everyone look like your own color (requires se
 seta cl_forcemyplayermodel "" "set to the model file name you want to show yourself as (requires server to have sv_use_csqc_players 1; does not affect how enemies look with cl_forceplayermodels)"
 seta cl_forcemyplayerskin 0 "set to the skin number you want to show yourself as (requires server to have sv_use_csqc_players 1; does not affect how enemies look with cl_forceplayermodels)"
 seta cl_forcemyplayercolors 0 "set to the color value (encoding is same as _cl_color) for your own player model (requires server to have sv_use_csqc_players 1, and is ignored in teamplay; does not affect how enemies look with cl_forceplayermodels)"
+seta cl_predictionerrorcompensation 0 "try to compensate for prediction errors and reduce preceived lag (requires server to have sv_use_csqc_players 1)"
 
 // debug cvars for keyhunt attaching
 set _angles "0 0 0"
index dc9627d9e8173fcc86a9c3a45408d71e101f0b6d..40ba3f7a9f73c4d0a283dc6578b54a396211f00e 100644 (file)
@@ -35,24 +35,43 @@ entity csqcplayer;
 vector csqcplayer_origin, csqcplayer_velocity;
 float csqcplayer_sequence, player_pmflags;
 float csqcplayer_moveframe;
-vector csqcplayer_predictionerror;
+vector csqcplayer_predictionerroro;
+vector csqcplayer_predictionerrorv;
 float csqcplayer_predictionerrortime;
+float csqcplayer_predictionerrorfactor;
 
-vector CSQCPlayer_GetPredictionError()
+vector CSQCPlayer_GetPredictionErrorO()
 {
-       if(!autocvar_cl_predictionerrorcompensation)
+       if(time >= csqcplayer_predictionerrortime)
+               return '0 0 0';
+       return csqcplayer_predictionerroro * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
+}
+
+vector CSQCPlayer_GetPredictionErrorV()
+{
+       if(time >= csqcplayer_predictionerrortime)
                return '0 0 0';
-       if(time < csqcplayer_predictionerrortime)
-               return csqcplayer_predictionerror * (csqcplayer_predictionerrortime - time) * autocvar_cl_predictionerrorcompensation;
-       return '0 0 0';
+       return csqcplayer_predictionerrorv * (csqcplayer_predictionerrortime - time) * csqcplayer_predictionerrorfactor;
 }
 
-void CSQCPlayer_SetPredictionError(vector v)
+void CSQCPlayer_SetPredictionError(vector o, vector v)
 {
        if(!autocvar_cl_predictionerrorcompensation)
+       {
+               csqcplayer_predictionerrorfactor = 0;
                return;
-       csqcplayer_predictionerror = (csqcplayer_predictionerrortime - time) * autocvar_cl_predictionerrorcompensation * csqcplayer_predictionerror + v;
-       csqcplayer_predictionerrortime = time + 1.0 / autocvar_cl_predictionerrorcompensation;
+       }
+
+       // error too big to compensate, we LIKELY hit a teleport or a
+       // jumppad, or it's a jump time disagreement that'll get fixed
+       // next frame
+       if(vlen(o) > 32 || vlen(v) > 128)
+               return;
+
+       csqcplayer_predictionerroro = CSQCPlayer_GetPredictionErrorO() + o;
+       csqcplayer_predictionerrorv = CSQCPlayer_GetPredictionErrorV() + v;
+       csqcplayer_predictionerrorfactor = autocvar_cl_predictionerrorcompensation / ticrate;
+       csqcplayer_predictionerrortime = time + 1.0 / csqcplayer_predictionerrorfactor;
 }
 
 void CSQCPlayer_Unpredict()
@@ -92,9 +111,14 @@ void CSQCPlayer_SavePrediction()
        csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
 }
 
-void CSQCPlayer_PredictTo(float endframe)
+void CSQCPlayer_PredictTo(float endframe, float apply_error)
 {
        CSQCPlayer_Unpredict();
+       if(apply_error)
+       {
+               self.origin += CSQCPlayer_GetPredictionErrorO();
+               self.velocity += CSQCPlayer_GetPredictionErrorV();
+       }
        CSQCPlayer_SetMinsMaxs();
 
        csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
@@ -183,11 +207,12 @@ void CSQCPlayer_SetCamera()
                        {
                                vector o, v;
                                o = self.origin;
+                               v = v0;
                                csqcplayer_status = CSQCPLAYERSTATUS_PREDICTED;
-                               CSQCPlayer_PredictTo(servercommandframe + 1);
-                               CSQCPlayer_SetPredictionError(o - self.origin);
+                               CSQCPlayer_PredictTo(servercommandframe + 1, FALSE);
+                               CSQCPlayer_SetPredictionError(self.origin - o, self.velocity - v);
                                self.origin = o;
-                               self.velocity = v0;
+                               self.velocity = v;
 
                                // get crouch state from the server
                                if(getstati(STAT_VIEWHEIGHT) == PL_VIEW_OFS_z)
@@ -203,7 +228,7 @@ void CSQCPlayer_SetCamera()
 
                                CSQCPlayer_SavePrediction();
                        }
-                       CSQCPlayer_PredictTo(clientcommandframe + 1);
+                       CSQCPlayer_PredictTo(clientcommandframe + 1, TRUE);
 
                        CSQCPlayer_SetMinsMaxs();
 
index 57a09fe3808ac8997b2a557010fb442e24827dc8..e7154b7f52f17617b9a79c7560aba4e551f99161 100644 (file)
@@ -92,6 +92,11 @@ float CheatsAllowed(float i, float argc, float fr) // the cheat gets passed as a
        if((++attempting, !CheatsAllowed(i,argc,fr))) \
                break
 
+void spawnfunc_info_autoscreenshot()
+{
+       // empty spawnfunc just so this entity can exist
+}
+
 float CheatImpulse(float i)
 {
        BEGIN_CHEAT_FUNCTION();
@@ -214,8 +219,25 @@ float CheatImpulse(float i)
                        break;
                case CHIMPULSE_TELEPORT:
                        IS_CHEAT(i, 0, 0);
+                       if(self.movetype == MOVETYPE_NOCLIP)
+                       {
+                               e = find(world, classname, "info_autoscreenshot");
+                               if(e)
+                               {
+                                       sprint(self, "Emergency teleport used info_autoscreenshot location\n");
+                                       setorigin(self, e.origin);
+                                       self.angles = e.angles;
+                                       remove(e);
+                                       // should we? self.angles_x = -self.angles_x;
+                                       self.fixangle = TRUE;
+                                       self.velocity = '0 0 0';
+                                       DID_CHEAT();
+                                       break;
+                               }
+                       }
                        if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, ((gamestart_sv_cheats >= 2) ? 100000 : 100), 1024, 256))
                        {
+                               sprint(self, "Emergency teleport used random location\n");
                                self.angles_x = -self.angles_x;
                                self.fixangle = TRUE;
                                self.velocity = '0 0 0';
index 8c0cb96e0eb4f0627867800f7691eb979aa53af2..4a12ce1850323e10f7b11282a76874cb0f426e66 100644 (file)
@@ -173,11 +173,17 @@ float W_AmmoItemCode(float wpn)
        return (get_weaponinfo(wpn)).items & IT_AMMO;
 }
 
+.float savenextthink;
 void thrown_wep_think()
 {
-       self.solid = SOLID_TRIGGER;
        self.owner = world;
-       SUB_SetFade(self, time + 20, 1);
+       float timeleft = self.savenextthink - time;
+       if(timeleft > 1)
+               SUB_SetFade(self, self.savenextthink - 1, 1);
+       else if(timeleft > 0)
+               SUB_SetFade(self, time, timeleft);
+       else
+               SUB_VanishOrRemove(self);
 }
 
 // returns amount of ammo used as string, or -1 for failure, or 0 for no ammo count
@@ -197,6 +203,33 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
        wep.flags |= FL_TOSSED;
        wep.colormap = own.colormap;
 
+       if(W_WeaponBit(wpn) & WEPBIT_SUPERWEAPONS)
+       {
+               if(own.items & IT_UNLIMITED_SUPERWEAPONS)
+               {
+                       wep.superweapons_finished = time + autocvar_g_balance_superweapons_time;
+               }
+               else
+               {
+                       float superweapons = 1;
+                       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+                               if(own.weapons & WEPBIT_SUPERWEAPONS & W_WeaponBit(i))
+                                       ++superweapons;
+                       if(superweapons <= 1)
+                       {
+                               wep.superweapons_finished = own.superweapons_finished;
+                               own.superweapons_finished = 0;
+                       }
+                       else
+                       {
+                               float timeleft = own.superweapons_finished - time;
+                               float weptimeleft = timeleft / superweapons;
+                               wep.superweapons_finished = time + weptimeleft;
+                               own.superweapons_finished -= weptimeleft;
+                       }
+               }
+       }
+
        wa = W_AmmoItemCode(wpn);
        if(wa == 0)
        {
@@ -208,7 +241,9 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                        return string_null;
                wep.glowmod = own.weaponentity_glowmod;
                wep.think = thrown_wep_think;
-               wep.nextthink = time + 0.5;
+               wep.savenextthink = wep.nextthink;
+               wep.nextthink = min(wep.nextthink, time + 0.5);
+               wep.pickup_anyway = TRUE; // these are ALWAYS pickable
                return "";
        }
        else
@@ -262,7 +297,8 @@ string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vecto
                }
                wep.glowmod = own.weaponentity_glowmod;
                wep.think = thrown_wep_think;
-               wep.nextthink = time + 0.5;
+               wep.savenextthink = wep.nextthink;
+               wep.nextthink = min(wep.nextthink, time + 0.5);
                wep.pickup_anyway = TRUE; // these are ALWAYS pickable
                return s;
        }
@@ -288,8 +324,6 @@ float W_IsWeaponThrowable(float w)
        wb = W_WeaponBit(w);
        if(!wb)
                return 0;
-       if(wb & WEPBIT_SUPERWEAPONS) // can't throw a superweapon, they don't work
-               return 0;
        wa = W_AmmoItemCode(w);
        if(start_weapons & wb)
        {
index 11688ae36a67cbdca3117edb78df76df93f94786..cd4ab6ceb21d29f956d3ce8af4cab46bdc66a1cb 100644 (file)
@@ -168,7 +168,7 @@ void Item_Show (entity e, float mode)
                e.spawnshieldtime = 1;
        }
 
-       if (e.strength_finished || e.invincible_finished)
+       if (e.items & (IT_STRENGTH | IT_INVINCIBLE))
                e.effects |= EF_ADDITIVE | EF_FULLBRIGHT;
        if (autocvar_g_nodepthtestitems)
                e.effects |= EF_NODEPTHTEST;
@@ -510,8 +510,24 @@ void Item_Touch (void)
        if (self.owner == other)
                return;
 
+       if (self.classname == "droppedweapon")
+       {
+               self.strength_finished = max(0, self.strength_finished - time);
+               self.invincible_finished = max(0, self.invincible_finished - time);
+               self.superweapons_finished = max(0, self.superweapons_finished - time);
+       }
+
        if(!Item_GiveTo(self, other))
-               return;
+       {
+               if (self.classname == "droppedweapon")
+               {
+                       // undo what we did above
+                       self.strength_finished += time;
+                       self.invincible_finished += time;
+                       self.superweapons_finished += time;
+                       return;
+               }
+       }
 
        other.last_pickup = time;
 
@@ -546,11 +562,15 @@ void Item_Reset()
 {
        Item_Show(self, !self.state);
        setorigin (self, self.origin);
-       self.think = SUB_Null;
-       self.nextthink = 0;
 
-       if((self.flags & FL_POWERUP) | (self.weapons & WEPBIT_SUPERWEAPONS)) // do not spawn powerups initially!
-               Item_ScheduleInitialRespawn(self);
+       if(self.classname != "droppedweapon")
+       {
+               self.think = SUB_Null;
+               self.nextthink = 0;
+
+               if((self.flags & FL_POWERUP) | (self.weapons & WEPBIT_SUPERWEAPONS)) // do not spawn powerups initially!
+                       Item_ScheduleInitialRespawn(self);
+       }
 }
 
 void Item_FindTeam()
@@ -654,7 +674,7 @@ float weapon_pickupevalfunc(entity player, entity item)
 
 float commodity_pickupevalfunc(entity player, entity item)
 {
-       float c, i, need_shells, need_nails, need_rockets, need_cells;
+       float c, i, need_shells, need_nails, need_rockets, need_cells, need_fuel;
        entity wi;
        c = 0;
 
@@ -674,6 +694,8 @@ float commodity_pickupevalfunc(entity player, entity item)
                        need_rockets = TRUE;
                else if(wi.items & IT_CELLS)
                        need_cells = TRUE;
+               else if(wi.items & IT_FUEL)
+                       need_cells = TRUE;
        }
 
        // TODO: figure out if the player even has the weapon this ammo is for?
@@ -695,6 +717,10 @@ float commodity_pickupevalfunc(entity player, entity item)
        if (item.ammo_cells)
        if (player.ammo_cells < g_pickup_cells_max)
                c = c + max(0, 1 - player.ammo_cells / g_pickup_cells_max);
+       if (need_fuel)
+       if (item.ammo_fuel)
+       if (player.ammo_fuel < g_pickup_fuel_max)
+               c = c + max(0, 1 - player.ammo_fuel / g_pickup_fuel_max);
        if (item.armorvalue)
        if (player.armorvalue < item.max_armorvalue)
                c = c + max(0, 1 - player.armorvalue / item.max_armorvalue);
@@ -721,9 +747,28 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                self.reset = SUB_Remove;
                // it's a dropped weapon
                self.movetype = MOVETYPE_TOSS;
+
                // Savage: remove thrown items after a certain period of time ("garbage collection")
                self.think = RemoveItem;
-               self.nextthink = time + 60;
+               self.nextthink = time + 20;
+
+               if(self.strength_finished || self.invincible_finished || self.superweapons_finished)
+               /*
+               if(self.items == 0)
+               if(self.weapons == (self.weapons & WEPBIT_SUPERWEAPONS)) // only superweapons
+               if(self.ammo_nails == 0)
+               if(self.ammo_cells == 0)
+               if(self.ammo_rockets == 0)
+               if(self.ammo_shells == 0)
+               if(self.ammo_fuel == 0)
+               if(self.health == 0)
+               if(self.armorvalue == 0)
+               */
+               {
+                       // if item is worthless after a timer, have it expire then
+                       self.nextthink = max(self.strength_finished, self.invincible_finished, self.superweapons_finished);
+               }
+
                // don't drop if in a NODROP zone (such as lava)
                traceline(self.origin, self.origin, MOVE_NORMAL, self);
                if (trace_dpstartcontents & DPCONTENTS_NODROP)
@@ -856,7 +901,6 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                self.colormap = 1024; // color shirt=0 pants=0 grey
        }
 
-       Item_Show(self, 1);
        self.state = 0;
        if(self.team)
        {