X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=0707d717dcc11e89dcf6e6bf9bfb59a4a2e2c710;hp=d8505ab4f5ba6761f8c2c9a035e6d88be14b1eed;hb=4aabbcbfcb5d689c7553db92012b7db84b867afa;hpb=8fcd0c450de9abff136129f32279ed0542e224d2 diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index d8505ab4f5..0707d717dc 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -963,7 +963,7 @@ string GetAmmoPicture(float i) } } -void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected) +void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected, float infinite_ammo) { float a; if(autocvar__hud_configure) @@ -975,7 +975,9 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode? vector color; - if(a < 10) + if(infinite_ammo) + color = '0 0.5 0.75'; + else if(a < 10) color = '0.7 0 0'; else color = '1 1 1'; @@ -1006,12 +1008,12 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s if(autocvar_hud_panel_ammo_text) { - if(a > 0) + if(a > 0 || infinite_ammo) drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL); else // "ghost" ammo count drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL); } - if(a > 0) + if(a > 0 || infinite_ammo) drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL); else // "ghost" ammo icon drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL); @@ -1071,20 +1073,23 @@ void HUD_Ammo(void) ammo_size_y = newSize; } - float i, stat_items, currently_selected; + float i, stat_items, currently_selected, infinite_ammo; + infinite_ammo = FALSE; if (autocvar_hud_panel_ammo_onlycurrent) { if(autocvar__hud_configure) { - DrawAmmoItem(pos, ammo_size, 2, true); //show rockets + DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets return; } stat_items = getstati(STAT_ITEMS); + if (stat_items & IT_UNLIMITED_WEAPON_AMMO) + infinite_ammo = TRUE; for (i = 0; i < AMMO_COUNT; ++i) { currently_selected = stat_items & GetAmmoItemCode(i); if (currently_selected) { - DrawAmmoItem(pos, ammo_size, i, true); + DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo); return; } } @@ -1092,9 +1097,11 @@ void HUD_Ammo(void) } stat_items = getstati(STAT_ITEMS); + if (stat_items & IT_UNLIMITED_WEAPON_AMMO) + infinite_ammo = TRUE; for (i = 0; i < AMMO_COUNT; ++i) { currently_selected = stat_items & GetAmmoItemCode(i); - DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected); + DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo); ++row; if(row >= rows) { @@ -1300,10 +1307,19 @@ void HUD_Powerups(void) // Health/armor (#3) // -float health_time, prev_health; -float armor_time, prev_armor; -var float saved_health = -2; -var float saved_armor = -2; + +// prev_* vars contain the health/armor at the previous FRAME +// set to -1 when player is dead or was not playing +float prev_health, prev_armor; +float health_damagetime, armor_damagetime; +float health_beforedamage, armor_beforedamage; +// old_p_* vars keep track of previous values when smoothing value changes of the progressbar +float old_p_health, old_p_armor; +float old_p_healthtime, old_p_armortime; +// prev_p_* vars contain the health/armor progressbar value at the previous FRAME +// set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h) +float prev_p_health, prev_p_armor; + void HUD_HealthArmor(void) { float armor, health, fuel; @@ -1315,36 +1331,36 @@ void HUD_HealthArmor(void) health = getstati(STAT_HEALTH); if(health <= 0) { - health_time = -1; + prev_health = -1; return; } - if (autocvar_hud_panel_healtharmor_progressbar_gfx) - { - if ( (prev_spectatee_status == -1 && spectatee_status > 0) //before observing, now spectating - || (prev_spectatee_status > 0 && spectatee_status > 0 && prev_spectatee_status != spectatee_status) //changed spectated player - ) - { - //no effect - saved_health = 0; - saved_armor = 0; - health_time = 0; - armor_time = 0; - } - else if(prev_spectatee_status == -1 || (prev_spectatee_status > 0 && !spectatee_status)) //before spectating/observing, now playing - health_time = -1; + armor = getstati(STAT_ARMOR); - if (health_time == -1) - { - //start the load effect - saved_health = -2; - saved_armor = -2; - health_time = time; - armor_time = time; - prev_health = 0; - prev_armor = 0; - } + // code to check for spectatee_status changes is in Ent_ClientData() + // prev_p_health and prev_health can be set to -1 there + + if (prev_p_health == -1) + { + // no effect + health_beforedamage = 0; + armor_beforedamage = 0; + health_damagetime = 0; + armor_damagetime = 0; + prev_health = health; + prev_armor = armor; + old_p_health = health; + old_p_armor = armor; + prev_p_health = health; + prev_p_armor = armor; + } + else if (prev_health == -1) + { + //start the load effect + health_damagetime = 0; + armor_damagetime = 0; + prev_health = 0; + prev_armor = 0; } - armor = getstati(STAT_ARMOR); fuel = getstati(STAT_FUEL); } else @@ -1467,34 +1483,39 @@ void HUD_HealthArmor(void) pain_health_alpha = 1; if (autocvar_hud_panel_healtharmor_progressbar_gfx) { - if (saved_health == -1) + if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0) { - if (prev_health == 0 || prev_health - health >= 3) + if (fabs(prev_health - health) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth) { - health_time = time; - saved_health = prev_health; + if (time - old_p_healthtime < 1) + old_p_health = prev_p_health; + else + old_p_health = prev_health; + old_p_healthtime = time; + } + if (time - old_p_healthtime < 1) + { + p_health += (old_p_health - health) * (1 - (time - old_p_healthtime)); + prev_p_health = p_health; } } - if (saved_health != -1) + if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0) { - float d = time - health_time; - if (d < 1) + if (prev_health - health >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage) { - if (saved_health == -2) - p_health *= sqrt(d); - else - { - HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, saved_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL); - if (prev_health - health >= 1) //refresh the effect if repeatedly damaged - health_time = time; - } + if (time - health_damagetime >= 1) + health_beforedamage = prev_health; + health_damagetime = time; + } + if (time - health_damagetime < 1) + { + float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime); + HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL); } - else - saved_health = -1; //damage effect ended } prev_health = health; - if (health <= 40 && saved_health != -2) + if (health <= autocvar_hud_panel_healtharmor_progressbar_gfx_lowhealth) { float BLINK_FACTOR = 0.15; float BLINK_BASE = 0.85; @@ -1517,30 +1538,35 @@ void HUD_HealthArmor(void) p_armor = armor; if (autocvar_hud_panel_healtharmor_progressbar_gfx) { - if (saved_armor == -1) + if (autocvar_hud_panel_healtharmor_progressbar_gfx_smooth > 0) { - if (prev_armor == 0 || prev_armor - armor >= 3) + if (fabs(prev_armor - armor) >= autocvar_hud_panel_healtharmor_progressbar_gfx_smooth) + { + if (time - old_p_armortime < 1) + old_p_armor = prev_p_armor; + else + old_p_armor = prev_armor; + old_p_armortime = time; + } + if (time - old_p_armortime < 1) { - armor_time = time; - saved_armor = prev_armor; + p_armor += (old_p_armor - armor) * (1 - (time - old_p_armortime)); + prev_p_armor = p_armor; } } - if (saved_armor != -1) + if (autocvar_hud_panel_healtharmor_progressbar_gfx_damage > 0) { - float d = time - armor_time; - if (d < 1) + if (prev_armor - armor >= autocvar_hud_panel_healtharmor_progressbar_gfx_damage) { - if (saved_armor == -2) - p_armor *= sqrt(d); - else - { - HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, saved_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * (1 - d * d), DRAWFLAG_NORMAL); - if (prev_armor - armor >= 1) //refresh the effect if repeatedly damaged - armor_time = time; - } + if (time - armor_damagetime >= 1) + armor_beforedamage = prev_armor; + armor_damagetime = time; + } + if (time - armor_damagetime < 1) + { + float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime); + HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL); } - else - saved_armor = -1; //damage effect ended } prev_armor = armor; } @@ -1831,7 +1857,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s print (sprintf(_("%s^7 is a ^1BERSERKER!\n"), s1)); } else if(type == KILL_SPREE_25) { if(gentle) - print (sprintf(_("%s^7 made ^1TWENTY FIFE SCORES IN A ROW!\n"), s1)); + print (sprintf(_("%s^7 made ^1TWENTY FIVE SCORES IN A ROW!\n"), s1)); else print (sprintf(_("%s^7 inflicts ^1CARNAGE!\n"), s1)); } else if(type == KILL_SPREE_30) { @@ -2560,6 +2586,128 @@ void HUD_Radar(void) // Score (#7) // void HUD_UpdatePlayerTeams(); +void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count) +{ + float score; + entity tm, pl; +#define SCOREPANEL_MAX_ENTRIES 6 +#define SCOREPANEL_ASPECTRATIO 2 + const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES); + const vector fontsize = '1 1 0' * (mySize_y/entries); + + vector rgb, score_color; + rgb = '1 1 1'; + score_color = '1 1 1'; + + const float name_size = mySize_x*0.75; + const float spacing_size = mySize_x*0.04; + const float highlight_alpha = 0.2; + float i, me_printed, first_pl; + string s; + i, first_pl = 0; + if (autocvar__hud_configure) + { + float players_per_team; + if (team_count) + { + // show team scores in the first line + float score_size = mySize_x / team_count; + players_per_team = max(2, ceil((entries - 1) / team_count)); + for(i=0; i