]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Stats: abstract engine stats
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 10 Dec 2015 03:58:18 +0000 (14:58 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 10 Dec 2015 03:58:18 +0000 (14:58 +1100)
13 files changed:
qcsrc/client/hud/panel/ammo.qc
qcsrc/client/hud/panel/healtharmor.qc
qcsrc/client/hud/panel/modicons.qc
qcsrc/client/hud/panel/powerups.qc
qcsrc/client/hud/panel/radar.qc
qcsrc/client/scoreboard.qc
qcsrc/client/view.qc
qcsrc/common/physics.qc
qcsrc/common/stats.qh
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/lib/csqcmodel/cl_player.qc

index 6c37aa13a89ea740d944d2a46aec0bd1d1c0bb9c..96343d6a9668567abfc10b06c7e47bbd04db8291 100644 (file)
@@ -160,7 +160,7 @@ void HUD_Ammo()
 
        Weapon wep = switchweapon;
        int i;
-       bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
+       bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO);
        row = column = 0;
        if(autocvar_hud_panel_ammo_onlycurrent)
        {
index bab17556d477bf9801af055822d450c2fa165a10..3b094d39d9f6b40849e3eb146ea8b6b93762689a 100644 (file)
@@ -8,13 +8,13 @@ void HUD_HealthArmor()
                if(hud != HUD_NORMAL) return;
                if(spectatee_status == -1) return;
 
-               health = getstati(STAT_HEALTH);
+               health = STAT(HEALTH);
                if(health <= 0)
                {
                        prev_health = -1;
                        return;
                }
-               armor = getstati(STAT_ARMOR);
+               armor = STAT(ARMOR);
 
                // code to check for spectatee_status changes is in Ent_ClientData()
                // prev_p_health and prev_health can be set to -1 there
index 8e3166b6ad8f23ef803bc0a779fdaf83c6cd0798..d57a23e1e90f6bc55ade27d6f806ecc94bc155b0 100644 (file)
@@ -415,7 +415,7 @@ void HUD_Mod_Keepaway(vector pos, vector mySize)
        float BLINK_FREQ = 5;
        float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
 
-       int stat_items = getstati(STAT_ITEMS, 0, 24);
+       int stat_items = STAT(ITEMS);
        int kaball = (stat_items/IT_KEY1) & 1;
 
        if(kaball != kaball_prevstatus)
@@ -451,7 +451,7 @@ void HUD_Mod_NexBall(vector pos, vector mySize)
        float nb_pb_starttime, dt, p;
        int stat_items;
 
-       stat_items = getstati(STAT_ITEMS, 0, 24);
+       stat_items = STAT(ITEMS);
        nb_pb_starttime = STAT(NB_METERSTART);
 
        if (stat_items & IT_KEY1)
index e75f21f3685a0112dc44b5c9a66d07b083a9d564..854ed594a0de49904ab2544f501ec23ff4ce916e 100644 (file)
@@ -56,7 +56,7 @@ int getPowerupItemAlign(int align, int column, int row, int columns, int rows, b
 
 void HUD_Powerups()
 {
-       int allItems = getstati(STAT_ITEMS, 0, 24);
+       int allItems = STAT(ITEMS);
        int allBuffs = STAT(BUFFS);
        int strengthTime, shieldTime, superTime;
 
@@ -65,7 +65,7 @@ void HUD_Powerups()
        {
                if(!autocvar_hud_panel_powerups) return;
                if(spectatee_status == -1) return;
-               if(getstati(STAT_HEALTH) <= 0) return;
+               if(STAT(HEALTH) <= 0) return;
                if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return;
 
                strengthTime = bound(0, STAT(STRENGTH_FINISHED) - time, 99);
index 33f4e1e649f2d69fb1fdaeb965e2237660ba867f..66d516960da4e88689c94441d3fd9eb7e7edd895 100644 (file)
@@ -79,7 +79,7 @@ float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary)
                                return false;
                }
 
-               if ( getstati(STAT_HEALTH) <= 0 )
+               if ( STAT(HEALTH) <= 0 )
                {
                        // Show scoreboard
                        if ( bInputType < 2 )
@@ -369,7 +369,7 @@ void HUD_Radar()
        {
                string message = "Click to select teleport destination";
 
-               if ( getstati(STAT_HEALTH) <= 0 )
+               if ( STAT(HEALTH) <= 0 )
                {
                        message = "Click to select spawn location";
                }
index 4d9a8c69d0c35c91fe9496da174b91d33ea29e9c..06c7363afecc101cfd76d0d983990b22051d352b 100644 (file)
@@ -986,7 +986,7 @@ float HUD_WouldDrawScoreboard() {
                return 1;
        else if (intermission == 2)
                return 0;
-       else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS && !active_minigame)
+       else if (spectatee_status != -1 && STAT(HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS && !active_minigame)
                return 1;
        else if (scoreboard_showscores_force)
                return 1;
index e24e5bdf23dde70f0bacad810b152fc3409ffa96..c1591497138e138daaf067b0933e00aaf85faf01 100644 (file)
@@ -115,7 +115,7 @@ void viewmodel_animate(entity this)
        prevtime = time;
 
        if (autocvar_chase_active) return;
-       if (getstati(STAT_HEALTH) <= 0) return;
+       if (STAT(HEALTH) <= 0) return;
 
        entity view = CSQCModel_server2csqc(player_localentnum - 1);
 
@@ -272,7 +272,7 @@ void viewmodel_animate(entity this)
 
 void viewmodel_draw(entity this)
 {
-       int mask = (intermission || (getstati(STAT_HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
+       int mask = (intermission || (STAT(HEALTH) <= 0) || autocvar_chase_active) ? 0 : MASK_NORMAL;
        float a = this.alpha;
        int c = stof(getplayerkeyvalue(current_player, "colors"));
        vector g;
@@ -356,7 +356,7 @@ void Porto_Draw(entity this)
                return;
        if(intermission == 2)
                return;
-       if (getstati(STAT_HEALTH) <= 0)
+       if (STAT(HEALTH) <= 0)
                return;
 
        dir = view_forward;
@@ -672,7 +672,7 @@ float TrueAimCheck()
                        break;
        }
 
-       vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * getstati(STAT_VIEWHEIGHT));
+       vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * STAT(VIEWHEIGHT));
 
        vecs = decompressShotOrigin(STAT(SHOTORG));
 
@@ -757,7 +757,7 @@ bool WantEventchase()
                        return true;
                if(autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(WepSet_GetFromStat() & WEPSET(NEXBALL)))
                        return true;
-               if(autocvar_cl_eventchase_death && (getstati(STAT_HEALTH) <= 0))
+               if(autocvar_cl_eventchase_death && (STAT(HEALTH) <= 0))
                {
                        if(autocvar_cl_eventchase_death == 2)
                        {
@@ -954,7 +954,7 @@ void HUD_Crosshair()
 
                        case 2: // crosshair_color_by_health
                        {
-                               float x = getstati(STAT_HEALTH);
+                               float x = STAT(HEALTH);
 
                                //x = red
                                //y = green
@@ -1432,7 +1432,7 @@ void CSQC_UpdateView(float w, float h)
 
        ticrate = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
 
-       float is_dead = (getstati(STAT_HEALTH) <= 0);
+       float is_dead = (STAT(HEALTH) <= 0);
 
        // FIXME do we need this hack?
        if(isdemo())
@@ -1710,7 +1710,7 @@ void CSQC_UpdateView(float w, float h)
        switchingweapon = Weapons_from(STAT(SWITCHINGWEAPON));
 
        // actually active weapon (for zoom)
-       activeweapon = Weapons_from(getstati(STAT_ACTIVEWEAPON));
+       activeweapon = Weapons_from(STAT(ACTIVEWEAPON));
 
        switchweapon = Weapons_from(STAT(SWITCHWEAPON));
 
@@ -2006,7 +2006,7 @@ void CSQC_UpdateView(float w, float h)
                splash_pos.y = (vid_conheight - splash_size.y) / 2;
 
                float myhealth_flash_temp;
-               myhealth = getstati(STAT_HEALTH);
+               myhealth = STAT(HEALTH);
 
                // fade out
                myhealth_flash = max(0, myhealth_flash - autocvar_hud_damage_fade_rate * frametime);
@@ -2115,7 +2115,7 @@ void CSQC_UpdateView(float w, float h)
                if (strength_finished - time > 0) { sharpen_intensity += (strength_finished - time); }
                if (invincible_finished - time > 0) { sharpen_intensity += (invincible_finished - time); }
 
-               sharpen_intensity = bound(0, ((getstati(STAT_HEALTH) > 0) ? sharpen_intensity : 0), 5); // Check to see if player is alive (if not, set 0) - also bound to fade out starting at 5 seconds.
+               sharpen_intensity = bound(0, ((STAT(HEALTH) > 0) ? sharpen_intensity : 0), 5); // Check to see if player is alive (if not, set 0) - also bound to fade out starting at 5 seconds.
 
                if(autocvar_hud_powerup && sharpen_intensity > 0)
                {
index 64b53b3a7dc8e9cbde06f6f3c5a3142747f2d1a9..dc1dcacde3ae0fdefb994972f704c9ea59ac1163 100644 (file)
@@ -1258,7 +1258,7 @@ void PM_Main(entity this)
 {
        int buttons = PHYS_INPUT_BUTTON_MASK(this);
 #ifdef CSQC
-       this.items = getstati(STAT_ITEMS, 0, 24);
+       this.items = STAT(ITEMS);
 
        this.movement = PHYS_INPUT_MOVEVALUES(this);
 
index d52329333ca400399984919a8e7857cb0ce1007b..3780a33fe8154139d2041c36d13ac6be7b7ac551 100644 (file)
@@ -9,16 +9,37 @@
 // 255 is the current limit (MAX_CL_STATS - 1), engine will need to be modified if you wish to add more stats
 
 const int MAX_CL_STATS = 256;
-#ifndef CSQC
-const int STAT_HEALTH = 0; // .health
-const int STAT_ARMOR = 4; // .armorvalue
-const int STAT_SHELLS = 6; // .ammo_shells
-const int STAT_NAILS = 7; // .ammo_nails
-const int STAT_ROCKETS = 8; // .ammo_rockets
-const int STAT_CELLS = 9; // .ammo_cells
-const int STAT_ACTIVEWEAPON = 10; // .weapon
-const int STAT_ITEMS = 15; // .items | .items2 << 23 | serverflags << 28
-const int STAT_VIEWHEIGHT = 16; // .view_ofs_z
+
+// const int STAT_HEALTH = 0;
+// const int STAT_ARMOR = 4;
+// const int STAT_SHELLS = 6;
+// const int STAT_NAILS = 7;
+// const int STAT_ROCKETS = 8;
+// const int STAT_CELLS = 9;
+// const int STAT_ACTIVEWEAPON = 10;
+// const int STAT_ITEMS = 15; // .items | .items2 << 23 | serverflags << 28
+// const int STAT_VIEWHEIGHT = 16;
+
+#if defined(CSQC)
+    #define g_stat_HEALTH getstat_int(STAT_HEALTH)
+    #define g_stat_ARMOR getstat_int(STAT_ARMOR)
+    #define g_stat_SHELLS getstat_int(STAT_SHELLS)
+    #define g_stat_NAILS getstat_int(STAT_NAILS)
+    #define g_stat_ROCKETS getstat_int(STAT_ROCKETS)
+    #define g_stat_CELLS getstat_int(STAT_CELLS)
+    #define g_stat_ACTIVEWEAPON getstat_int(STAT_ACTIVEWEAPON)
+    #define g_stat_ITEMS getstat_int(STAT_ITEMS)
+    #define g_stat_VIEWHEIGHT getstat_int(STAT_VIEWHEIGHT)
+#elif defined(SVQC)
+    #define stat_HEALTH health
+    #define stat_ARMOR armorvalue
+    #define stat_SHELLS ammo_shells
+    #define stat_NAILS ammo_nails
+    #define stat_ROCKETS ammo_rockets
+    #define stat_CELLS ammo_cells
+    #define stat_ACTIVEWEAPON weapon
+    #define stat_ITEMS items
+    #define stat_VIEWHEIGHT view_ofs_z
 #endif
 
 REGISTER_STAT(WEAPONS, vectori)
index 38e343f65e8827a9a9e5a7b3c33b1e0de5638b7b..22c3f1e021ad1164ec1522fb02ab14e16405168c 100644 (file)
@@ -532,17 +532,17 @@ void racer_draw()
        self.lastpushtime = time;
        if(!pushdeltatime) return;
 
-       tracebox(self.move_origin, self.mins, self.maxs, self.move_origin - ('0 0 1' * getstatf(STAT_VEH_RACER_SPRINGLENGTH)), MOVE_NOMONSTERS, self);
+       tracebox(self.move_origin, self.mins, self.maxs, self.move_origin - ('0 0 1' * STAT(VEH_RACER_SPRINGLENGTH)), MOVE_NOMONSTERS, self);
 
-       vector df = self.move_velocity * -getstatf(STAT_VEH_RACER_FRICTION);
-       df_z += (1 - trace_fraction) * getstatf(STAT_VEH_RACER_HOVERPOWER) + sin(time * 2) * (getstatf(STAT_VEH_RACER_SPRINGLENGTH) * 2);
+       vector df = self.move_velocity * -STAT(VEH_RACER_FRICTION);
+       df_z += (1 - trace_fraction) * STAT(VEH_RACER_HOVERPOWER) + sin(time * 2) * (STAT(VEH_RACER_SPRINGLENGTH) * 2);
 
-       float forced = getstatf(STAT_VEH_RACER_UPFORCEDAMPER);
+       float forced = STAT(VEH_RACER_UPFORCEDAMPER);
 
        int cont = pointcontents(self.move_origin - '0 0 64');
        if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
        {
-               forced = getstatf(STAT_VEH_RACER_WATER_UPFORCEDAMPER);
+               forced = STAT(VEH_RACER_WATER_UPFORCEDAMPER);
                self.move_velocity_z += 200;
        }
 
@@ -550,8 +550,8 @@ void racer_draw()
        if(self.move_velocity_z > 0)
                self.move_velocity_z *= 1 - forced * pushdeltatime;
 
-       self.move_angles_x *= 1 - (getstatf(STAT_VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
-       self.move_angles_z *= 1 - (getstatf(STAT_VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
+       self.move_angles_x *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
+       self.move_angles_z *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
 
        Movetype_Physics_MatchServer(false);
 }
index 5d468785060e5163ad093c37e8aea24ceb4c8790..13037eb7d4cdc904014d0866094d2d51dc3fb4f2 100644 (file)
@@ -1226,7 +1226,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
                else
                {
                        // use player origin so that third person display still works
-                       self.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * getstati(STAT_VIEWHEIGHT));
+                       self.origin = entcs_receiver(player_localnum).origin + ('0 0 1' * STAT(VIEWHEIGHT));
                }
        }
 
index d5445000c2e4ae3ec70608d053eeb80deeb01005..2905002d931622ec0ec68079206ab42c6da7fa6c 100644 (file)
@@ -128,7 +128,7 @@ void VaporizerBeam_Draw(entity this)
        Draw_VaporizerBeam_trace_callback_tex = string_null;
 
        /*if(!MUTATOR_CALLHOOK(Particles_VaporizerBeam, this.vorg1, this.vorg2))
-       if(autocvar_cl_particles_oldvortexbeam && (getstati(STAT_ALLOW_OLDVORTEXBEAM) || isdemo()))
+       if(autocvar_cl_particles_oldvortexbeam && (STAT(ALLOW_OLDVORTEXBEAM) || isdemo()))
                WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM_OLD), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);
        else
                WarpZone_TrailParticles_WithMultiplier(world, particleeffectnum(EFFECT_VORTEX_BEAM), this.vorg1, this.vorg2, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE);*/
index ecc98b1a3c96c326bf4f9dcfcb13cb47bd7632fc..3fdef9583aa3de66ac8131b045fdb707da35b859 100644 (file)
@@ -202,7 +202,7 @@ void CSQCPlayer_PredictTo(entity this, float endframe, bool apply_error)
 #if 0
        // we don't need this
        // darkplaces makes servercommandframe == 0 in these cases anyway
-       if (getstatf(STAT_HEALTH) <= 0)
+       if (STAT(HEALTH) <= 0)
        {
                csqcplayer_moveframe = clientcommandframe;
                getinputstate(csqcplayer_moveframe-1);
@@ -245,7 +245,7 @@ void CSQCPlayer_SetViewLocation()
 void CSQCPlayer_SetCamera()
 {
        const vector v0 = pmove_vel; // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
-       const float vh = getstati(STAT_VIEWHEIGHT);
+       const float vh = STAT(VIEWHEIGHT);
        const vector pl_viewofs = PL_VIEW_OFS;
        const vector pl_viewofs_crouch = PL_CROUCH_VIEW_OFS;
        const entity e = csqcplayer;
@@ -323,7 +323,7 @@ void CSQCPlayer_SetCamera()
                if (view.csqcmodel_teleported) refdefflags |= REFDEFFLAG_TELEPORTED;
                if (input_buttons & BIT(1)) refdefflags |= REFDEFFLAG_JUMPING;
                // note: these two only work in WIP2, but are harmless in WIP1
-               if (getstati(STAT_HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD;
+               if (STAT(HEALTH) <= 0) refdefflags |= REFDEFFLAG_DEAD;
                if (intermission) refdefflags |= REFDEFFLAG_INTERMISSION;
                V_CalcRefdef(view, refdefflags);
        }