D:\cygwin\wf_fusion_src_r8\CVSROOT\cgame\weaponsfactory\cg_hud_milli.c

/*
==============================================================================
The Weapons Factory - 
  
Modified code by Keith Pase

Copyright (C) 1997-2003 Weapons Factory Software
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

  $Id: cg_hud_milli.c,v 1.1 2004/03/07 18:40:10 keith Exp $
  
==============================================================================
*/

#include "../cg_local.h"

#define DISPLAY_ITEMS   17

void SCR_DrawWeaponDamage (int x, int y)
{
    char    string[16];
    int     damage =  cg.frame.playerState.stats[STAT_DAMAGE];
    int     value = cg.frame.playerState.stats[STAT_SELECTED_ICON];

    if (damage < 1)
    {
        cg.weapondamage = 0;
        return;
    }

    if ((damage > cg.weapondamage + 2) && cg.normalfps > 1)
        cg.weapondamage += 2*cg.normalfps;
    else if (damage > cg.weapondamage)
        cg.weapondamage ++;
    if ((damage < cg.weapondamage + 2) && cg.normalfps > 1)
        cg.weapondamage -= 2*cg.normalfps;
    else if (damage < cg.weapondamage)
        cg.weapondamage --;

    Q_snprintfz (string, sizeof(string), "Damage:%3i",cg.weapondamage);
    CG_DrawString ( x+40, y, string, FONT_SMALL, colorWhite );

    if ( cgs.configStrings[CS_IMAGES+value] )
        trap_R_DrawStretchPic (x-6, y-4, 18, 18, 0, 0, 1, 1, colorWhite, trap_R_RegisterPic(cgs.configStrings[CS_IMAGES+value]) );
}

void SCR_DrawWeaponAccuracy (int x, int y)
{
    char    string[8];
    int     accuracy = cg.frame.playerState.persistant[PERS_ACCURACY];

//  Com_Printf("DEBUG: accuracy %i\n",accuracy);
    CG_DrawString ( x+4, y, "Acc", FONT_SMALL, colorWhite );
    Q_snprintfz (string, sizeof(string), "%3i",accuracy);
    CG_DrawString ( x, y+8, string, FONT_SMALL, colorWhite );
}


void SCR_DrawMiliSrCharge (int x, int y)
{
    int     damage =  cg.frame.playerState.stats[STAT_FLASHES];
    char    string[8];
    vec4_t  color = {1,1,0,.2};
    float   damage2;
    vec4_t  color2 = {1,1,1,.2};
    int     charlength;

    if (damage < 1)
        return;

    if (damage == 1)
        damage = 0;

    if (damage > cg.damage  && damage == 110)
        cg.damage = 110;

    if ((damage > cg.damage + 2) && cg.normalfps > 1)
        cg.damage += 2*cg.normalfps;
    else if (damage > cg.damage)
        cg.damage ++;
    if (damage < cg.damage)
        cg.damage = damage;

    if (damage > 0)
    {
        damage2 = cg.damage;
        color[0]    = damage2/160;
        color[1]    = 1-(damage2/160);
        color[3]    +=damage2/160;
        color2[3]   = color[3];
        trap_Draw_FillRect (608+x, (400+y)-cg.damage, 16, cg.damage, color);
    }

    Q_snprintfz (string, sizeof(string), "%i",cg.damage);
    charlength = strlen(string) * 4;
    CG_DrawString ( x+618-charlength, y+410, string, FONT_SMALL, color2 );
    CG_DrawString ( x+592, y+400, "Damage", FONT_SMALL, color2 );

    trap_Draw_Border (608+x, 238+y, 16, 162, color2, 1);
}

void SCR_HUDCompass ( int x, int y, int w, int h, struct model_s *model, struct shader_s *shader, int pitch, int yaw, int roll )
{
    vec3_t origin, angles;

    VectorSet ( origin, 90, 10, 10 );
    VectorSet ( angles, pitch, yaw, roll );
    
    CG_DrawModel ( x, y, w, h, .3f, model, shader, origin, angles );

}

void SCR_HUDCompass2 ( int x, int y, int w, int h, struct model_s *model, struct shader_s *shader, int pitch, int yaw, int roll )
{
    vec3_t origin, angles;

    VectorSet ( origin, 90, 0, 0 );
    VectorSet ( angles, pitch, yaw, roll );
    
    CG_DrawModel ( x, y, w, h,.57f, model, shader, origin, angles );

}

void ChangeCompassYaw (vec3_t angles, float ideal2, float speed2,int team)
{
    float   ideal;
    float   current;
    float   move;
    float   speed;
    
    if (team == 1)
        current = anglemod(cg.compassroll);
    else
        current = anglemod(cg.compassroll2);

    ideal = ideal2;

    if (current == ideal)
        return;

    move = ideal - current;
    speed = speed2;
    if (ideal > current)
    {
        if (move >= 180)
            move = move - 360;
    }
    else
    {
        if (move <= -180)
            move = move + 360;
    }
    if (move > 0)
    {
        if (move > speed)
            move = speed;
    }
    else
    {
        if (move < -speed)
            move = -speed;
    }
    if (team == 1)  
        cg.compassroll =  anglemod (current + move);
    else
        cg.compassroll2 =  anglemod (current + move);

}
void SCR_DrawMilliCompass(float scale,int roll)
{
    int x, y;
    int w, h;
    vec4_t  color2= {1,.5,0,.5};
    vec4_t  color3= {0,.6,1,.5};
    char string [16];
    int x1,y1;
    int yaw = (int)(cg.refdef.viewangles[2] * -2.5);

    x = (int)cg_Compass_x->value;
    y = (int)cg_Compass_y->value;
    w = (int)(scale * 166);
    h = (int)(scale * 166);

    x = scr_vrect.x + x + ((scr_vrect.width - w)>>1);
    y = scr_vrect.y + y + ((scr_vrect.height- h)>>1);

    x1=(int)(x+(166 * scale));
    y1=(int)(y+(166 * scale));

    trap_R_DrawStretchPic (x,y, w, h,0, 0, 1, 1, colorWhite, CG_MediaShader (cgs.media.shaderCompassbody));

    SCR_HUDCompass2(x,y,w,h,CG_MediaModel(cgs.media.modCompassbody),CG_MediaShader (cgs.media.shaderCompassinner) ,cg.innerpitch,yaw,roll);


    if (!(cg.team2 && cg.flagpic))
    {
        if (cg.noflagdata)
            Q_snprintfz (string, sizeof(string), "---");
        else
        {
            Q_snprintfz (string, sizeof(string), "%i",cg.compassdist);
            SCR_HUDCompass2(x-1,y,w,h,CG_MediaModel(cgs.media.modCompassbody),CG_MediaShader (cgs.media.shaderRedcomparrow) ,cg.compasspitch,yaw,yaw+(cg.compassroll-roll)*-1);
        }

        CG_DrawString (x1,y1, string, FONT_SMALL, color2 );
    }

    if (!(cg.team1 && cg.flagpic))
    {
        if (cg.noflagdata)
            Q_snprintfz (string, sizeof(string), "---");
        else
        {
            SCR_HUDCompass2(x-1,y,w,h,CG_MediaModel(cgs.media.modCompassbody),CG_MediaShader (cgs.media.shaderBluecomparrow) ,cg.compasspitch2,yaw,yaw+(cg.compassroll2-roll)*-1);
            Q_snprintfz (string, sizeof(string), "%i",cg.compassdist2);
        }

        CG_DrawString (x,y1, string, FONT_SMALL, color3 );
    }

}
void SCR_DrawCompass(int x, int y)
{
    int     distance,distance2;
    vec3_t  v,v2;
    char    string[16];
    vec4_t  color = {1,1,1,.5};
    vec4_t  color2= {1,.5,0,.5};
    vec4_t  color3= {0,.6,1,.5};
    vec3_t  normal = {0,0,-1};
    vec3_t  dp1,dp2;
    int     pitch,roll,innerpitch,mode;
    float   bestyaw;
    int     x1, y1;
    int     offset = 74;
    int     fps = cg.intnormalfps;
    int     type = cg_Compass->value;
    int     x2 = cg_Compass_x->value + 8;
    int     y2 = cg_Compass_y->value + 40;
    float   scale = cg_CompassScale->value;
    int     q2wfscale;

    if (!type)
        return;
    if (cg.frame.playerState.stats[STAT_HEALTH] <=0)
        return;

    if (scale >= 3)
        scale = 3;
    if (scale <= 0)
        scale = .01;

    q2wfscale = (int)(scale * 96);

    if (type < 3)
    {
        if ((cg.team1 && type == 1) || (cg.team2 && type == 2))
            mode = 2;

        if ((cg.team1 && type == 2) || (cg.team2 && type == 1))
            mode = 1;

        if (cg.flagpic)
            if (cg.team1)
                mode = 1;
            else if (cg.team2)
                mode = 2;
    }
    else
        mode = 3;

    innerpitch = cg.predictedAngles[0];

    if (innerpitch < -1*offset) innerpitch = -1*offset;
    if (innerpitch > offset) innerpitch = offset;

    if (innerpitch > (cg.innerpitch+2))
        cg.innerpitch += (2*fps);
    if (innerpitch < (cg.innerpitch-2))
        cg.innerpitch -= (2*fps);


    x1 =  scr_vrect.x +((scr_vrect.width - 186)>>1);
    y1 =  scr_vrect.y + ((scr_vrect.height - 186)>>1);

    if (cg.flag1origin[0] == 0 && cg.flag1origin[1] ==0 && cg.flag1origin[2] ==0)
        cg.noflagdata = qtrue;
    else
        cg.noflagdata = qfalse;

    VectorSubtract (cg.flag1origin, cg.predictedOrigin, v);
    VectorSubtract (cg.flag2origin, cg.predictedOrigin, v2);
    distance = VectorLength (v) / 32;
    distance2 = VectorLength (v2) / 32;

    if (distance > cg.compassdist)
        cg.compassdist +=fps;
    if (distance < cg.compassdist)
        cg.compassdist -=fps;
    if (distance2 > cg.compassdist2)
        cg.compassdist2 +=fps;
    if (distance2 < cg.compassdist2)
        cg.compassdist2 -=fps;

    bestyaw = vectoyaw(v);
    ChangeCompassYaw (cg.predictedAngles,bestyaw,4,1);

    bestyaw = vectoyaw(v2);
    ChangeCompassYaw (cg.predictedAngles,bestyaw,4,2);

    VectorNormalize(v);
    RotatePointAroundVector( dp2, normal, v, cg.predictedAngles[0]);
    if (mode < 3)
        pitch = (dp2[2] * -90) + cg.predictedAngles[0];
    else
        pitch = ((dp2[2] * -90) - (cg.predictedAngles[0] ))+offset;

    if (pitch > offset && pitch < 90) pitch = offset;
    if (pitch < 90+(90-offset) && pitch > offset) pitch = 90+(90-offset);
    if (pitch > cg.compasspitch)
        cg.compasspitch +=fps;
    if (pitch < cg.compasspitch)
        cg.compasspitch -=fps;

    VectorNormalize(v2);
    RotatePointAroundVector( dp1, normal, v2, cg.predictedAngles[0]);
    if (mode < 3)
        pitch = (dp1[2] * -90) + cg.predictedAngles[0];
    else
        pitch = ((dp1[2] * -90) - (cg.predictedAngles[0] ))+offset;

    if (pitch > offset && pitch < 90) pitch = offset;
    if (pitch < 90+(90-offset) && pitch > offset) pitch = 90+(90-offset);
    if (pitch > cg.compasspitch2)
        cg.compasspitch2 +=fps;
    if (pitch < cg.compasspitch2)
        cg.compasspitch2 -=fps;

    roll = (int)cg.predictedAngles[1];

    if (roll < 0)
        roll +=360;

    if (cg.GasTime > cg.time)
    {
        cg.compasspitch2 += cg.GasViewOffset[1][1]/4;
        cg.compasspitch  -= cg.GasViewOffset[1][1]/4;
        cg.compassroll2  += cg.GasViewOffset[0][1]/4;
        cg.compassroll   -= cg.GasViewOffset[0][1]/4;
        cg.innerpitch    -= (((cg.GasViewOffset[0][1]/4)+(cg.GasViewOffset[1][1]/4))/2);
        roll += ((cg.GasViewOffset[0][1]/2)+(cg.GasViewOffset[1][1])/2);
    }

    if (mode == 1)
    {
        Q_snprintfz (string, sizeof(string), "Dist: %i",cg.compassdist);
        CG_DrawString (x2*scale,(y2+56)*scale, string, FONT_SMALL, color2 );
        SCR_HUDCompass(x2,y2,q2wfscale,q2wfscale,CG_MediaModel(cgs.media.modCompass),NULL,cg.compasspitch,2,(cg.compassroll-roll)*-1);
    }
    
    if (mode == 2)
    {
        Q_snprintfz (string, sizeof(string), "Dist: %i",cg.compassdist2);
        CG_DrawString (x2*scale,(y2+56)*scale, string, FONT_SMALL, color3 );
        SCR_HUDCompass(x2,y2,q2wfscale,q2wfscale,CG_MediaModel(cgs.media.modCompass),NULL,cg.compasspitch2,2,(cg.compassroll2-roll)*-1);
    }


    if (mode == 3)
    {
        SCR_DrawMilliCompass(scale,roll);
    }
}

void SCR_DrawMiliTimer (void)
{
    int     seconds = cg.frame.playerState.stats[STAT_TIMER];
    int     minutes;
    char    string[8];
    vec4_t  color = {1,1,1,1};

    if (seconds < 0)
        return;

    minutes = seconds/60;
    if (minutes < 0)
        minutes = 0;
    if (minutes > 999)
        minutes = 999;

    if (minutes < 5)
        Vector4Copy(colorYellow,color);
    if (minutes < 1)
        Vector4Copy(colorRed,color);

    seconds = seconds%60;

    if (seconds < 10)
        Q_snprintfz (string, sizeof(string), "%3i:0%i",minutes,seconds);
    else
        Q_snprintfz (string, sizeof(string), "%3i:%i",minutes,seconds);

    color[3] = .6;

    CG_DrawString ( cgs.vidWidth - 100, 26, string, FONT_BIG, color );

}


char *typeofammo[6] = 
{
    "Bullets",
    "Shells",
    "Grenades",
    "Rockets",
    "Slugs",
    "Cells"
};

vec4_t ammocolor[6] =
{
    {1, 1, 0, .33},
    {1, .5, 0, .33},
    {.1, .6, .2, .33},
    {1, 0, 0, .33},
    {0, 1, 0, .33},
    {1, 0, .9, .33}
};

void SCR_DrawMiliId (void)
{
    vec4_t  color;
    cg_clientInfo_t *ci;
    int i = cg.frame.playerState.stats[STAT_CTF_ID_VIEW];
    char string1[32];
    int lastsighted; 
    int x;
    int y = (cgs.vidHeight / 2) + 24;

    Vector4Copy (colorWhite,color);

    if (!cg.lastsighted)
    {
        if (!i)
            return;
        else
        {
            cg.lastsighted = i;
            cg.lastsighttime = 1;
        }
    }

    if (!i)
    {
        cg.lastsighttime -= .05;
        color[3] = cg.lastsighttime;
        if (color[3] <=0)
        {
            cg.lastsighted = 0;
            return;
        }
    }


    lastsighted = cg.lastsighted;
//
    Q_snprintfz (string1, sizeof(string1), "%s",cgs.configStrings[lastsighted]);
    x = (cgs.vidWidth - CG_PropStringLength (string1, FONT_SMALL|FONT_SHADOWED)) / 1.8;
    CG_DrawString ( x, y, string1, FONT_SMALL|FONT_SHADOWED, color );

    if (i)
    {
        ci = &cgs.clientInfo[i];
    }
}


void SCR_DrawMiliInventory (int x, int y)
{
    int     i;
    char    string[16];
    int     count;
    float   width;
    float   count2;
    vec4_t  color, color2;

    for (i= 0; i<6; i++)
    {
        count = cg.frame.playerState.ammo[i];
        if (count <= 0) continue;
        count2= cg.frame.playerState.ammo[i+6];
        Vector4Copy (ammocolor[i], color2);
        if (count > 999) count = 999;
        if (count != cg.ammo[i]) color2[3] = .66;
        if (count < cg.ammo[i]) cg.ammo[i]--;
        if (count > cg.ammo[i]) cg.ammo[i]++;
        width = (cg.ammo[i]/count2) * 80;
        if (width < 8)
            Vector4Copy (colorRed,color);
        else if (width < 20)
            Vector4Copy (colorYellow,color);
        else
            Vector4Copy (colorWhite,color);
        trap_Draw_FillRect (x+48, y+1, width, 8, color2);
        Q_snprintfz (string, sizeof(string), "%3i",cg.ammo[i]);
        CG_DrawString ( x+12, y, string, FONT_SMALL|FONT_SHADOWED, color );
        trap_R_DrawStretchPic ( x, y, 10, 10, 0, 0, 1, 1, colorWhite, CG_MediaShader(cgs.media.AmNums[i])  );
        CG_DrawString ( x+48, y, typeofammo[i], FONT_SMALL|FONT_SHADOWED, color );
        y=y+8;
    }
}

void SCR_DrawHealthBar (int x, int y)
{
    int w, h,i;
    float value,value2,value3,barvalue;
    float r;
    float g;
    vec4_t color;
    int nw,nx,nwh,nxh;
    int armortype;
    char block[3];
    float armor,health,alpha,barhealth;

    w = 79;
    h = 20;

    value = cg.frame.playerState.stats[STAT_HEALTH];
    value2 = cg.frame.playerState.stats[STAT_CHASE];
    value3 = cg.frame.playerState.stats[STAT_ARMOR];
    armortype = cg.frame.playerState.stats[STAT_SPECTATOR];
    armor = cg.armor;
    health = cg.health;

    if (value > health)
        if (value-health > 8)
            cg.health += ((value-health)/2);
        else
        cg.health ++;
    else if (value < health)
        if (health-value > 8)
            cg.health -= ((health-value)/2);
        else
            cg.health --;

    if (value3 > armor)
        if (value3-armor > 8)
            cg.armor += ((value3-armor)/2);
        else
            cg.armor ++;
    else if (value3 < armor)
        if (armor-value3 > 8)
            cg.armor -= ((armor-value3)/2);
        else
            cg.armor --;

    if (health < 0) health = 0;

    barhealth = health;
    barvalue = value;

    if (barvalue > 100)
        barvalue = 100;

    if (barhealth >100)
        barhealth = 100;

    r = 1 - (barhealth / 100);
    g = (barhealth / 100);

    if (value < 66) r = r*2;
    if (barhealth > 33) g = g*2;
    alpha = abs(value-cg.health) * .01;

    color[0] = r;
    color[1] = g;
    color[2] = 0;
    color[3] = .33;

    if (alpha > 0)
        for (i=0; i<4; i++)
            color[i] += alpha;

    nw = (79*(barhealth / 100));
    nwh= (79*(barvalue / 100));
    nxh= x + (w - nwh);
    nx = x + (w - nw);
    trap_Draw_FillRect (nxh, y, nwh, h, color);
    color[3] = .75;
    trap_Draw_FillRect (nx, y+5, nw, h-10, color);
    sprintf ( block, "%.0f", health);

    CG_DrawString ( x+w-60, y-12, "Health", FONT_SMALL|FONT_SHADOWED, colorWhite );
    CG_DrawString ( x+w-24, y+5, block, FONT_SMALL|FONT_SHADOWED, colorWhite );

    nw = (armor/value2) * w;
    nwh= (value3/value2) * w;
    alpha = abs(value3-cg.armor) * .02;

    color[0] = color[1] = color[2] = 0;

    if (armortype == 1)
        color[0] = 1;
    else if (armortype == 2)
    {
        color[0] = 1;
        color[1] = 1;
    }
    else if (armortype == 3)
        color[1] = .7;
    else
    {
        color[0] = 0;
        color[1] = 0;
        color[2] = 0;
    }

    if (alpha > 0)
        for (i=0; i<4; i++)
            color[i] += alpha;

    color[3] = .33;
    trap_Draw_FillRect (x+w, y, nwh, h, color);
    color[3] = .75;
    trap_Draw_FillRect (x+w, y+5, nw, h-10, color);

    sprintf ( block, "%.0f", armor);
    CG_DrawString ( x+w+20, y-12, "Armor", FONT_SMALL|FONT_SHADOWED, colorWhite );
    CG_DrawString ( x+w, y+5, block, FONT_SMALL|FONT_SHADOWED, colorWhite );

}

void SCR_DrawHudMilli (void)
{
    vec4_t DEFAULT_HUD_BORDERCOLOR = {1,1,1,.75};
    vec4_t bordercolor2 = {1, .5, .5, .75};
    vec4_t blueborder = {0, 0, 1, .75};
    vec4_t blueback = {0, 0, 1, .33};
    vec4_t redborder = {1, 0, 0, .75};
    vec4_t redback = {1, 0, 0, .33};
    vec4_t shaded = {0, 0, 0, .33};
    int borderwidth = 1;
    int y = cgs.vidHeight - 480;
    int x = (scr_vrect.x + ((scr_vrect.width)>>1)) - 320;
    int y2 = y + 460;
    char block[3];
    
    cg.team1 = cg.frame.playerState.stats[STAT_CTF_JOINED_TEAM1_PIC];
    cg.team2 = cg.frame.playerState.stats[STAT_CTF_JOINED_TEAM2_PIC];
    cg.flagpic = cg.frame.playerState.stats[STAT_CTF_FLAG_PIC];

    if (!cg.team1 && !cg.team2) //todo fix spectator
        return;

//  trap_Draw_FillRect (0, 432, 128, 48, DEFAULT_HUD_BORDERCOLOR);

//  trap_Draw_Border (0, 334, 172, 98, DEFAULT_HUD_BORDERCOLOR, borderwidth); // teaminfo

    // accuracy
    trap_Draw_FillRect (192+x, y2, 32, 20, shaded);
    trap_Draw_Border (192+x, y2, 32, 20, DEFAULT_HUD_BORDERCOLOR, borderwidth); 
    SCR_DrawWeaponAccuracy(192+x,y2+2);
    

    // weapon/damage indicator
    trap_Draw_Border (384+x, 440+y, 128, 20, DEFAULT_HUD_BORDERCOLOR, borderwidth);
    SCR_DrawWeaponDamage(390+x,446+y);

    trap_Draw_Border (128+x, y2, 32, 20, DEFAULT_HUD_BORDERCOLOR, borderwidth); // health

    // headshots
//  trap_Draw_FillRect (160+x, y2, 32, 20, shaded);
    trap_Draw_Border (160+x, y2, 32, 20, DEFAULT_HUD_BORDERCOLOR, borderwidth);
    

     // Flag Indicator

    if (cg.flagpic)
    {
        trap_R_DrawStretchPic ( 512+x, 432+y, 128, 48, 0, 0, 1, 1, shaded, trap_R_RegisterPic("hudalert2") );
        trap_R_DrawStretchPic ( x, 432+y, 128, 48, 0, 0, 1, 1, shaded, trap_R_RegisterPic("hudalert2") );
        if (cg.flagpic == 2)
        {
            trap_R_DrawStretchPic ( 512+x, 432+y, 64, 48, 0, 0, 1, 1, colorBlue, trap_R_RegisterPic("flagcapture") );
        }
        else
        {
            trap_R_DrawStretchPic ( 576+x, 432+y, 64, 48, 0, 0, 1, 1, colorRed, trap_R_RegisterPic("flagcapture") );
        }
    }

    // flag indicator
    trap_Draw_Border (512+x, 432+y, 128, 48, DEFAULT_HUD_BORDERCOLOR, borderwidth); 


    // ammo
    trap_Draw_Border (x, 432+y, 128, 48, DEFAULT_HUD_BORDERCOLOR, borderwidth); 
    SCR_DrawMiliInventory (x, 432+y);


     // miniscore
//  trap_Draw_FillRect (128, 440, 80, 20, shaded);
//  trap_Draw_FillRect (152, 440, 26, 9, redback);
//  trap_Draw_FillRect (152, 449, 26, 9, blueback);
//  trap_Draw_Border (128, 440, 80, 20, DEFAULT_HUD_BORDERCOLOR, borderwidth);

     // redteamscore
    trap_Draw_FillRect (480+x, y2, 32, 20, redback);
    if (cg.team1)
        trap_R_DrawStretchPic ( 480+x, y2, 32, 20, 0, 0, 1, 1, colorRed, trap_R_RegisterPic("flaginbase") );
    trap_Draw_Border (480+x, y2, 32, 20, redborder, borderwidth);
    sprintf ( block, "%i", cg.frame.playerState.stats[STAT_CTF_TEAM1_CAPS]);
    CG_DrawString ( 492+x, y2+8, block, FONT_SMALL|FONT_SHADOWED, colorWhite );
    
     // blueteamscore
    trap_Draw_FillRect (416+x, y2, 32, 20, blueback);
    if (cg.team2)
        trap_R_DrawStretchPic ( 416+x, y2, 32, 20, 0, 0, 1, 1, colorBlue, trap_R_RegisterPic("flaginbase") );
    trap_Draw_Border (416+x, y2, 32, 20, blueborder, borderwidth);
    sprintf ( block, "%i", cg.frame.playerState.stats[STAT_CTF_TEAM2_CAPS]);
    CG_DrawString ( 428+x, y2+8, block, FONT_SMALL|FONT_SHADOWED, colorWhite );

    // personalscore
    trap_Draw_FillRect (385+x, y2+1, 30, 18, shaded);
    trap_Draw_Border (384+x, y2, 32, 20, bordercolor2, borderwidth);
    sprintf ( block, "%i", cg.frame.playerState.stats[STAT_FRAGS]);
    CG_DrawString ( 386+x, y2+8, block, FONT_SMALL|FONT_SHADOWED, colorWhite );

     // healthbars
    trap_Draw_FillRect (225+x, y2+1, 158, 18, shaded);
    SCR_DrawHealthBar(225+x, y2);
    trap_Draw_Border (224+x, y2, 160, 20, DEFAULT_HUD_BORDERCOLOR, borderwidth);

    SCR_DrawMiliId();
    SCR_DrawMiliTimer();
    SCR_DrawMiliSrCharge(x,y);
    SCR_DrawCompass(x,y);
}