2022-02-08 18:42:28 +00:00
/*
client / hud . qc
HUD Drawing Code
2024-01-07 23:24:48 +00:00
Copyright ( C ) 2021 - 2024 NZ : P Team
2022-02-08 18:42:28 +00:00
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 :
Free Software Foundation , Inc .
59 Temple Place - Suite 330
Boston , MA 02111 - 1307 , USA
*/
2024-06-30 03:27:35 +00:00
float ( string bind ) Key_IsControllerGlyph ;
void ( vector position , string bind , vector scale ) Key_DrawControllerGlyph ;
2023-02-08 01:50:41 +00:00
// vid_ultrawide_limiter
# define ULTRAWIDE_OFFSET 250
float ( ) GetUltraWideOffset =
{
if ( cvar ( " vid_ultrawide_limiter " ) )
return ULTRAWIDE_OFFSET ;
return 0 ;
}
2022-02-08 18:42:28 +00:00
//return hud images, makes drawpic slightly cleaner..
string ( string img ) getImage = {
return strcat ( huddir , img ) ;
}
2025-01-22 04:03:58 +00:00
//
// HUD_GetAlphaForWeaponObjects()
// Used for objects on the ammo-corner, where
// they linger for X seconds and then fade after.
//
float ( ) HUD_GetAlphaForWeaponObjects =
{
if ( HUD_Change_time < = time )
return 0 ;
else if ( HUD_Change_time - time > 1 )
return 1 ;
else
return ( HUD_Change_time - time ) ;
} ;
//
// HUD_DrawStringWithBackdrop(position, text, size, rgb, alpha, drawflag)
// Wrapper for Draw_String that also drawfills with cl_textopacity.
//
void ( vector position , string text , vector size , vector rgb , float alpha , float drawflag ) HUD_DrawStringWithBackdrop =
{
drawfill ( [ position_x - 4 , position_y - 4 ] , [ getTextWidth ( text , size_x ) + 6 , size_y + 6 ] , [ 0 , 0 , 0 ] , cvar ( " cl_textopacity " ) * alpha , 0 ) ;
Draw_String ( position , text , size , rgb , alpha , drawflag ) ;
}
2022-02-08 18:42:28 +00:00
/*******************
* HUD_Health *
* * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
void ( ) HUD_Health =
2022-02-08 18:42:28 +00:00
{
2023-07-18 16:23:14 +00:00
float health ;
float max_health ;
2022-02-08 18:42:28 +00:00
float alpha ;
health = getstatf ( STAT_HEALTH ) ;
2023-07-18 16:23:14 +00:00
max_health = getstatf ( STAT_MAXHEALTH ) ;
2022-02-08 18:42:28 +00:00
2023-07-18 16:23:14 +00:00
if ( health < max_health )
2022-02-08 18:42:28 +00:00
{
2023-07-18 16:23:14 +00:00
alpha = 255 - ( ( health / max_health ) ) * 255 ;
2022-02-08 18:42:28 +00:00
if ( alpha < = 0.0 )
return ;
float modifier = ( sin ( time * 10 ) * 20 ) - 20 ; //always negative
if ( modifier < - 35.0 )
modifier = - 35.0 ;
alpha + = modifier ;
if ( alpha < 0.0 )
return ;
float color = 255.0 + modifier ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 0 , 0 , 0 ] , " gfx/hud/blood.tga " , [ g_width , g_height , 0 ] , [ 10 , 0 , 0 ] , alpha / 2000 ) ; // naievil -- alpha factor division here makes it easy to use legacy code
2022-02-08 18:42:28 +00:00
}
}
/*******************
* HUD_Ammo *
* * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
void ( ) HUD_Ammo =
2022-02-08 18:42:28 +00:00
{
2025-01-22 04:03:58 +00:00
if ( cl_viewent . modelindex = = 0 )
return ;
float alpha = HUD_GetAlphaForWeaponObjects ( ) ;
2024-09-12 02:12:20 +00:00
float ammo , curmag ;
2022-02-08 18:42:28 +00:00
string ammostring , ammostring_1 , ammostring_2 ;
vector color ;
curmag = getstatf ( STAT_CURRENTMAG ) ;
ammo = getstatf ( STAT_AMMO ) ;
2022-04-23 21:21:54 +00:00
if ( W_IsLowAmmo ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_CURRENTMAG ) , true ) )
2022-02-08 18:42:28 +00:00
color = [ 215 / 255 , 0 , 0 ] ;
else
color = [ 1 , 1 , 1 ] ;
2022-04-23 21:21:54 +00:00
if ( W_IsLowAmmo ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_AMMO ) , false ) )
2022-02-08 18:42:28 +00:00
vector color_2 = [ 215 / 255 , 0 , 0 ] ;
else
color_2 = [ 1 , 1 , 1 ] ;
if ( IsDualWeapon ( getstatf ( STAT_ACTIVEWEAPON ) ) ) {
float curmag2 = getstatf ( STAT_CURRENTMAG2 ) ;
ammostring = strcat ( ftos ( curmag2 ) , " " , ftos ( curmag ) , " / " , ftos ( ammo ) ) ;
2024-09-12 02:12:20 +00:00
float x2 = ( g_width - GetUltraWideOffset ( ) ) - 62 - getTextWidth ( ammostring , 12 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ x2 , g_height - 29 ] , ammostring , [ 12 , 12 ] , [ 1 , 1 , 1 ] , alpha , 0 ) ;
2022-02-08 18:42:28 +00:00
} else {
ammostring_1 = ftos ( curmag ) ;
2023-02-08 01:50:41 +00:00
ammostring_2 = strcat ( " / " , ftos ( ammo ) ) ;
string weapon_ammo_string = strcat ( ftos ( curmag ) , " / " , ftos ( ammo ) ) ;
2024-09-12 02:12:20 +00:00
float x = ( g_width - GetUltraWideOffset ( ) ) - 62 - getTextWidth ( weapon_ammo_string , 12 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ x , g_height - 29 ] , ammostring_1 , [ 12 , 12 ] , color , alpha , 0 ) ;
HUD_DrawStringWithBackdrop ( [ x + getTextWidth ( ammostring_1 , 12 ) , g_height - 29 ] , ammostring_2 , [ 12 , 12 ] , color_2 , alpha , 0 ) ;
2022-02-08 18:42:28 +00:00
}
}
2022-04-23 21:21:54 +00:00
//
// HUD_AmmoString()
// Draws the "LOW AMMO", "Reload", etc. text
//
2022-02-08 18:42:28 +00:00
float ammoopac , ammoloop ;
void ( ) HUD_AmmoString =
{
2025-01-22 04:03:58 +00:00
if ( cl_viewent . modelindex = = 0 )
return ;
2022-04-23 21:21:54 +00:00
vector textcolor = [ 1 , 1 , 1 ] ;
string message = " " ;
2025-02-09 19:55:05 +00:00
float reserve_is_empty ;
2022-04-23 21:21:54 +00:00
float mag_is_low ;
// Is the Reserve low?
2025-02-09 19:55:05 +00:00
reserve_is_empty = getstatf ( STAT_AMMO ) < = 0 ;
2022-04-23 21:21:54 +00:00
// Is the Magazine low?
2025-02-09 19:55:05 +00:00
mag_is_low = W_IsLowAmmo ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_CURRENTMAG ) , true ) ;
2022-04-23 21:21:54 +00:00
2025-02-09 19:55:05 +00:00
// When the mag isn't low, there's nothing to do here.
if ( mag_is_low = = false ) {
2022-04-23 21:21:54 +00:00
ammoopac = 1 ;
ammoloop = 0 ;
return ;
} else {
2025-02-09 19:55:05 +00:00
// Report NO AMMO if both current mag and reserve are empty
if ( getstatf ( STAT_CURRENTMAG ) < = 0 & & reserve_is_empty = = true )
2022-04-23 21:21:54 +00:00
{
2022-02-08 18:42:28 +00:00
message = " NO AMMO " ;
textcolor = [ 215 / 255 , 0 , 0 ] ;
}
2023-11-08 14:21:04 +00:00
// Display LOW AMMO if mag is low and reserve is empty
2025-02-09 19:55:05 +00:00
else if ( reserve_is_empty = = true )
2022-04-24 02:57:40 +00:00
{
message = " LOW AMMO " ;
2025-02-09 19:55:05 +00:00
textcolor = [ 219 / 255 , 203 / 255 , 19 / 255 ] ;
}
// Otherwise, just display reload text
else
{
message = " Reload " ;
textcolor = [ 1 , 1 , 1 ] ;
2022-04-24 02:57:40 +00:00
}
2022-04-23 21:21:54 +00:00
}
2022-02-08 18:42:28 +00:00
2022-04-23 21:21:54 +00:00
// Blink the text and draw it.
if ( ammoloop = = 0 ) {
2022-02-08 18:42:28 +00:00
ammoopac - = frametime ;
if ( ammoopac < 0.5 ) {
ammoopac = 0.5 ;
ammoloop = 1 ;
}
} else {
2022-04-23 21:21:54 +00:00
ammoopac + = frametime ;
if ( ammoopac > = 1 ) {
ammoopac = 1 ;
ammoloop = 0 ;
}
2022-02-08 18:42:28 +00:00
}
2022-04-23 21:21:54 +00:00
2024-09-12 02:12:20 +00:00
float x = ( g_width / 2 ) - ( getTextWidth ( message , 12 ) / 2 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ x , g_height / 2 + 40 , 0 ] , message , [ 12 , 12 , 0 ] , textcolor , ammoopac , 0 ) ;
2022-02-08 18:42:28 +00:00
}
/*******************
* HUD_Points *
* * * * * * * * * * * * * * * * * * */
# define MAX_POINT_ELEMENTS 64 // the maximum amount of point differential elements that can be spawned before
// we iterate back from 0
2022-10-25 16:23:24 +00:00
float active_point_elements ;
2022-02-08 18:42:28 +00:00
var struct
{
float difference ; // the difference of points
float x_position ; // current x position
float y_position ; // current y position
float x_velocity ; // how fast the element moves on the x axis
float y_velocity ; // how fast the element moves on the y axis
float opacity ; // the opacity of the text_string as it progresses
float string_width ; // the width of text_string
2022-10-25 16:23:24 +00:00
float occupied ; // is this array being used/occupied?
2023-01-25 01:41:11 +00:00
float playerid ; // who does this element belong to?
2022-02-08 18:42:28 +00:00
string text_string ; // either '+(difference)' or '-(difference)'
} point_elements [ MAX_POINT_ELEMENTS ] ;
float last_point_element_index ;
2023-01-25 01:41:11 +00:00
void ( float amount , float playernum ) RegisterPointChange =
2022-02-08 18:42:28 +00:00
{
if ( last_point_element_index > = MAX_POINT_ELEMENTS )
last_point_element_index = 0 ;
float index = last_point_element_index ;
// set the difference amount
point_elements [ index ] . difference = amount ;
2023-01-25 01:41:11 +00:00
// assign it to the player
point_elements [ index ] . playerid = playernum ;
2022-02-08 18:42:28 +00:00
// fill our text string
if ( point_elements [ index ] . difference > 0 ) {
point_elements [ index ] . text_string = strcat ( " + " , ftos ( point_elements [ index ] . difference ) ) ;
} else {
point_elements [ index ] . text_string = ftos ( point_elements [ index ] . difference ) ;
}
// determine the width of the text string
2024-09-12 02:12:20 +00:00
point_elements [ index ] . string_width = getTextWidth ( point_elements [ index ] . text_string , 12 ) ;
2022-02-08 18:42:28 +00:00
// generate a velocity
point_elements [ index ] . y_velocity = random ( ) / 4 ;
while ( point_elements [ index ] . x_velocity < 0.33 ) {
point_elements [ index ] . x_velocity = random ( ) ;
}
if ( point_elements [ index ] . x_velocity > 0.70 )
point_elements [ index ] . x_velocity - = 0.2 ;
// should the vertical velocity be positive or negative?
float rng = random ( ) ;
// negative
if ( rng < 0.5 ) {
point_elements [ index ] . y_velocity = - point_elements [ index ] . y_velocity ;
}
// set our x and y positions
point_elements [ index ] . x_position = 0 ;
2024-12-08 04:13:54 +00:00
point_elements [ index ] . y_position = ( g_height - 90 ) - ( 25 * ( playernum - 1 ) ) ;
2022-02-08 18:42:28 +00:00
// start with an opacity of 1
point_elements [ index ] . opacity = 1 ;
2022-10-25 16:23:24 +00:00
// the element is being used
point_elements [ index ] . occupied = true ;
2022-02-08 18:42:28 +00:00
// iterate
last_point_element_index + + ;
2022-10-25 16:23:24 +00:00
active_point_elements + + ;
2022-02-08 18:42:28 +00:00
}
2025-01-22 04:03:58 +00:00
void ( float pwidth , float playernum ) PointUpdate =
2022-02-08 18:42:28 +00:00
{
2022-10-25 16:23:24 +00:00
if ( active_point_elements = = 0 )
return ;
2022-02-08 18:42:28 +00:00
vector POINT_DIFF_COLOR ;
for ( float i = 0 ; i < MAX_POINT_ELEMENTS ; i + + ) {
2023-01-25 01:41:11 +00:00
if ( point_elements [ i ] . playerid ! = playernum )
continue ;
2022-10-25 16:23:24 +00:00
if ( point_elements [ i ] . opacity < = 0 & & point_elements [ i ] . occupied = = true ) {
point_elements [ i ] . occupied = false ;
active_point_elements - - ;
continue ;
}
2022-02-08 18:42:28 +00:00
// should the text be red or orange?
if ( point_elements [ i ] . difference > 0 ) {
POINT_DIFF_COLOR = TEXT_ORANGE ;
} else {
POINT_DIFF_COLOR = TEXT_RED ;
}
2023-02-08 01:50:41 +00:00
if ( point_elements [ i ] . difference ! = 0 & & point_elements [ i ] . opacity > 0 ) {
2024-09-12 02:12:20 +00:00
Draw_String ( [ pwidth - point_elements [ i ] . string_width - point_elements [ i ] . x_position ,
2023-02-08 01:50:41 +00:00
point_elements [ i ] . y_position ] , point_elements [ i ] . text_string , [ 12 , 12 ] ,
2022-02-08 18:42:28 +00:00
POINT_DIFF_COLOR , point_elements [ i ] . opacity , 0 ) ;
}
2023-02-08 01:50:41 +00:00
point_elements [ i ] . x_position - = point_elements [ i ] . x_velocity * ( frametime * 375 ) ;
2022-02-08 18:42:28 +00:00
point_elements [ i ] . y_position + = point_elements [ i ] . y_velocity * ( frametime * 375 ) ;
point_elements [ i ] . opacity - = ( frametime * 4 ) ;
}
}
2025-01-22 04:03:58 +00:00
void ( ) HUD_Points =
2022-02-08 18:42:28 +00:00
{
2023-12-28 15:49:30 +00:00
float pointlength = 0 , increm = 10 , pointwidth = 0 , x = 0 ;
2025-01-22 04:03:58 +00:00
float backwidth = 0.8 * g_width ;
2022-02-08 18:42:28 +00:00
vector TEXTCOLOR = ' 0 0 0 ' ;
2023-12-28 15:49:30 +00:00
for ( int i = 3 ; i > = 0 ; i = i - 1 )
2022-02-08 18:42:28 +00:00
{
2024-12-08 04:13:54 +00:00
float player_number = getplayerkeyfloat ( i , " client_index " ) ;
2023-12-28 15:49:30 +00:00
entity client = findfloat ( world , playernum , player_number ) ;
2024-12-08 04:13:54 +00:00
if ( ( client = = world | | ! client . classname ) & & ! client . is_spectator )
2022-02-08 18:42:28 +00:00
continue ;
2023-12-28 15:49:30 +00:00
2022-02-08 18:42:28 +00:00
switch ( i ) {
case 1 : TEXTCOLOR = TEXT_LIGHTBLUE ; break ;
case 2 : TEXTCOLOR = TEXT_ORANGE ; break ;
case 3 : TEXTCOLOR = TEXT_GREEN ; break ;
default : TEXTCOLOR = [ 1 , 1 , 1 ] ; break ;
}
2023-03-18 20:08:33 +00:00
2024-09-12 02:12:20 +00:00
pointwidth = getTextWidth ( ftos ( client . points ) , 12 ) ;
2023-03-18 20:08:33 +00:00
x = ( 99 - pointwidth ) / 2 + GetUltraWideOffset ( ) ;
2024-12-08 04:13:54 +00:00
if ( player_number = = getstatf ( STAT_PLAYERNUM ) ) {
2023-03-18 20:08:33 +00:00
drawpic ( [ 3 + GetUltraWideOffset ( ) , g_height - 97 - ( i * 25 ) ] , " gfx/hud/moneyback.tga " , [ 96 , 24 ] , [ 1 , 1 , 1 ] , 1 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ x , g_height - 92 - ( i * 25 ) ] , ftos ( client . points ) , [ 12 , 12 ] , TEXTCOLOR , 1 , 0 ) ;
2023-02-08 01:50:41 +00:00
} else {
2023-03-18 20:08:33 +00:00
drawpic ( [ - 7 + GetUltraWideOffset ( ) , g_height - 97 - ( i * 25 ) ] , " gfx/hud/moneyback_condensed.tga " , [ 96 , 24 ] , [ 1 , 1 , 1 ] , 1 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ x - 9 , g_height - 92 - ( i * 25 ) ] , ftos ( client . points ) , [ 12 , 12 ] , TEXTCOLOR , 1 , 0 ) ;
2022-02-08 18:42:28 +00:00
}
2023-03-18 20:08:33 +00:00
2025-01-22 04:03:58 +00:00
PointUpdate ( x + 70 , player_number ) ;
2022-02-08 18:42:28 +00:00
}
}
2023-11-22 03:35:25 +00:00
/************************
* HUD_CharacterName *
* * * * * * * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
void ( ) HUD_CharacterName =
2023-11-22 03:35:25 +00:00
{
2025-01-22 04:03:58 +00:00
if ( nameprint_time < = time )
return ;
2023-11-22 03:35:25 +00:00
float x = 100 + GetUltraWideOffset ( ) ;
float alpha = 1 ;
if ( nameprint_time - 1 < time ) {
alpha = ( nameprint_time - time ) ;
}
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ x , g_height - 92 - ( ( getstatf ( STAT_PLAYERNUM ) - 1 ) * 25 ) ] , character_name , [ 12 , 12 ] , [ 1 , 1 , 1 ] , alpha , 0 ) ;
2023-11-22 03:35:25 +00:00
}
2022-02-08 18:42:28 +00:00
/*******************
* HUD_Grenades *
* * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
void ( ) HUD_Grenades =
2022-02-08 18:42:28 +00:00
{
2023-02-08 01:50:41 +00:00
float grenades ;
float betties ;
2025-01-22 04:03:58 +00:00
float alpha = HUD_GetAlphaForWeaponObjects ( ) ;
2023-02-08 01:50:41 +00:00
vector grenade_text_color ;
vector betties_text_color ;
2022-02-08 18:42:28 +00:00
grenades = getstatf ( STAT_GRENADES ) ;
betties = getstatf ( STAT_SECGRENADES ) ;
2023-02-08 01:50:41 +00:00
if ( grenades = = 0 )
grenade_text_color = [ 1 , 0 , 0 ] ;
else
grenade_text_color = [ 1 , 1 , 1 ] ;
if ( betties = = 0 )
betties_text_color = [ 1 , 0 , 0 ] ;
else
betties_text_color = [ 1 , 1 , 1 ] ;
2025-01-22 04:03:58 +00:00
drawpic ( [ g_width - 3 - 56 - GetUltraWideOffset ( ) , g_height - 50 ] , " gfx/hud/frag.tga " , [ 32 , 32 ] , [ 1 , 1 , 1 ] , alpha ) ;
HUD_DrawStringWithBackdrop ( [ g_width - 3 - 38 - GetUltraWideOffset ( ) , g_height - 29 ] , ftos ( grenades ) , [ 12 , 12 ] , grenade_text_color , alpha , 0 ) ;
2023-02-08 01:50:41 +00:00
2022-02-08 18:42:28 +00:00
if ( betties ! = - 1 ) {
2025-01-22 04:03:58 +00:00
drawpic ( [ g_width - 3 - 28 - GetUltraWideOffset ( ) , g_height - 50 ] , " gfx/hud/betty.tga " , [ 32 , 32 ] , [ 1 , 1 , 1 ] , alpha ) ;
HUD_DrawStringWithBackdrop ( [ g_width - 3 - 10 - GetUltraWideOffset ( ) , g_height - 29 ] , ftos ( betties ) , [ 12 , 12 ] , betties_text_color , alpha , 0 ) ;
2022-02-08 18:42:28 +00:00
}
}
/*******************
* HUD_Rounds *
* * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
// This is 107 on Vril Engine, but since our RGB mode is different
// in FTE we tone it down considerably to still look blood-red.
# define ROUND_RED_SHIFT 20
2022-02-08 18:42:28 +00:00
float color_shift [ 3 ] ;
float color_shift_end [ 3 ] ;
float color_shift_steps [ 3 ] ;
int color_shift_init ;
int blinking ;
string sb_round [ 5 ] ;
string sb_round_num [ 10 ] ;
int alphabling ;
float endroundchange ;
float round_center_x ;
float round_center_y ;
//motolegacy -- 'round' text
float pwidth ;
float rcolor , rinit , ralpha , localpha ;
2025-01-22 04:03:58 +00:00
void ( ) HUD_Rounds =
2022-02-08 18:42:28 +00:00
{
2023-02-08 01:50:41 +00:00
float roundheight = 65 ;
float roundwidth = 15 ;
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
float roundwidth_4 = 81 ;
float roundheight_4 = 65 ;
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
float roundheight_num = 65 ;
float roundwidth_num = 43 ; // naievil -- was 32, but more square makes it look better
2022-02-08 18:42:28 +00:00
int i , x_offset , icon_num , savex ;
int num [ 3 ] ;
x_offset = 0 ;
savex = 0 ;
for ( float j = 0 ; j < 10 ; j + + ) {
if ( j < 5 ) {
sb_round [ j ] = getImage ( strcat ( " r " , ftos ( j + 1 ) , " .tga " ) ) ;
}
sb_round_num [ j ] = getImage ( strcat ( " r_num " , ftos ( j ) , " .tga " ) ) ;
}
if ( rounds_change = = 1 | | rounds_change = = 2 ) {
if ( ! rinit ) {
rcolor = rinit = 1 ;
ralpha = 1 ;
}
2024-09-12 02:12:20 +00:00
pwidth = getTextWidth ( " Round " , 24 ) / 2 ;
Draw_String ( [ ( g_width / 2 ) - pwidth , g_height / 2 - 70 ] , " Round " , [ 24 , 24 ] , [ 1 , rcolor , rcolor ] , ralpha , 0 ) ;
2022-02-08 18:42:28 +00:00
rcolor - = frametime / 2.5 ;
if ( rcolor < 0 ) {
rcolor = 0 ;
ralpha - = frametime / 2.5 ;
if ( ralpha > 0 ) {
localpha + = frametime * 0.4 ;
if ( localpha > 1 )
localpha = 1 ;
}
if ( ralpha < 0 ) {
ralpha = 0 ;
localpha - = frametime * 0.4 ;
if ( localpha < 0 )
localpha = 0 ;
}
}
2024-09-12 02:12:20 +00:00
Draw_String ( [ 3 + GetUltraWideOffset ( ) , g_height / 2 + 24 ] , chaptertitle , [ 12 , 12 ] , [ 1 , 1 , 1 ] , localpha , 0 ) ;
Draw_String ( [ 3 + GetUltraWideOffset ( ) , g_height / 2 + 36 ] , location , [ 12 , 12 ] , [ 1 , 1 , 1 ] , localpha , 0 ) ;
Draw_String ( [ 3 + GetUltraWideOffset ( ) , g_height / 2 + 48 ] , date , [ 12 , 12 ] , [ 1 , 1 , 1 ] , localpha , 0 ) ;
Draw_String ( [ 3 + GetUltraWideOffset ( ) , g_height / 2 + 60 ] , person , [ 12 , 12 ] , [ 1 , 1 , 1 ] , localpha , 0 ) ;
2022-02-08 18:42:28 +00:00
}
if ( rounds_change = = 1 ) //this is the rounds icon at the middle of the screen
{
alphabling = alphabling + ( frametime * 500 ) ;
if ( alphabling < 0 )
alphabling = 0 ;
else if ( alphabling > 255 )
alphabling = 255 ;
2023-02-08 01:50:41 +00:00
round_center_x = g_width / 2 - 6 ;
round_center_y = g_height / 2 - 36 ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
drawpic ( [ round_center_x , round_center_y , 0 ] , sb_round [ 0 ] , [ roundwidth , roundheight ] , [ ROUND_RED_SHIFT / 255 , 1 / 255 ] , alphabling / 255 ) ;
2022-02-08 18:42:28 +00:00
}
else if ( rounds_change = = 2 ) //this is the rounds icon moving from middle
{
2023-12-24 16:18:38 +00:00
stopwatch_round_isactive = true ;
2022-02-08 18:42:28 +00:00
float round_center_y_offset = 0 ;
float round_center_x_offset = 0 ;
2025-01-22 04:03:58 +00:00
drawpic ( [ round_center_x + round_center_x_offset , round_center_y + round_center_y_offset , 0 ] , sb_round [ 0 ] , [ roundwidth , roundheight , 1 ] , [ ROUND_RED_SHIFT / 255 , ( 1 / 255 ) , 0 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
round_center_x = round_center_x - ( ( ( 229 / 108 ) * 2 - 0.2 ) * ( ( g_width - GetUltraWideOffset ( ) ) / 480 ) / 8 ) * ( frametime * 250 ) ;
round_center_y = round_center_y + ( ( 2 * ( g_height / 272 ) ) / 8 ) * ( frametime * 250 ) ;
2023-02-08 01:50:41 +00:00
if ( round_center_x < = 3 + GetUltraWideOffset ( ) )
round_center_x = 3 + GetUltraWideOffset ( ) ;
if ( round_center_y > = g_height - 1 - roundheight )
round_center_y = g_height - 1 - roundheight ;
2022-02-08 18:42:28 +00:00
}
else if ( rounds_change = = 3 ) //shift to white
{
2023-12-24 16:18:38 +00:00
stopwatch_round_isactive = false ;
2022-02-08 18:42:28 +00:00
if ( ! color_shift_init )
{
2025-01-22 04:03:58 +00:00
color_shift [ 0 ] = ROUND_RED_SHIFT ;
2022-02-08 18:42:28 +00:00
color_shift [ 1 ] = 1 ;
color_shift [ 2 ] = 0 ;
for ( i = 0 ; i < 3 ; i = i + 1 )
{
color_shift_end [ i ] = 255 ;
color_shift_steps [ i ] = ( color_shift_end [ i ] - color_shift [ i ] ) / 60 ;
}
color_shift_init = 1 ;
}
for ( i = 0 ; i < 3 ; i = i + 1 )
{
if ( color_shift [ i ] < color_shift_end [ i ] )
color_shift [ i ] = color_shift [ i ] + color_shift_steps [ i ] * ( frametime * 100 ) ;
if ( color_shift [ i ] > = color_shift_end [ i ] )
color_shift [ i ] = color_shift_end [ i ] ;
}
if ( rounds > 0 & & rounds < 11 )
{
for ( i = 0 ; i < rounds ; i = i + 1 )
{
if ( i = = 4 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + GetUltraWideOffset ( ) , g_height - roundheight , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
savex = x_offset + ( 10 * g_width / 480 ) ;
x_offset = x_offset + ( 10 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i = = 9 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + savex + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i > 4 )
icon_num = i - 5 ;
else
icon_num = i ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ icon_num ] , [ roundwidth , roundheight , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth + ( 3 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else
{
if ( rounds > = 100 )
{
num [ 2 ] = ( int ) ( rounds / 100 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 2 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 2 ] = 0 ;
if ( rounds > = 10 )
{
num [ 1 ] = ( int ) ( ( rounds - num [ 2 ] * 100 ) / 10 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 1 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 1 ] = 0 ;
num [ 0 ] = rounds - num [ 2 ] * 100 - num [ 1 ] * 10 ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 0 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else if ( rounds_change = = 4 ) //blink white
{
if ( endroundchange > time )
{
2023-11-03 14:58:01 +00:00
blinking = ( ( int ) ( time * 475 ) & 510 ) - 255 ;
2022-02-08 18:42:28 +00:00
blinking = fabs ( blinking ) ;
}
else
{
if ( blinking )
blinking = blinking - 1 ;
else
blinking = 0 ;
}
if ( rounds > 0 & & rounds < 11 )
{
for ( i = 0 ; i < rounds ; i = i + 1 )
{
if ( i = = 4 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
savex = x_offset + ( 10 * g_width / 480 ) ;
x_offset = x_offset + ( 10 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i = = 9 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + savex + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i > 4 )
icon_num = i - 5 ;
else
icon_num = i ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ icon_num ] , [ roundwidth , roundheight , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth + ( 3 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else
{
if ( rounds > = 100 )
{
num [ 2 ] = ( int ) ( rounds / 100 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 2 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 2 ] = 0 ;
if ( rounds > = 10 )
{
num [ 1 ] = ( int ) ( ( rounds - num [ 2 ] * 100 ) / 10 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 1 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 1 ] = 0 ;
num [ 0 ] = rounds - num [ 2 ] * 100 - num [ 1 ] * 10 ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 0 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
2023-11-03 14:58:01 +00:00
if ( endroundchange = = 0 ) {
endroundchange = time + 7.5 ;
blinking = 0 ;
}
2022-02-08 18:42:28 +00:00
}
else if ( rounds_change = = 5 ) //blink white
{
if ( blinking > 0 )
blinking = blinking - ( frametime * 5000 ) ;
if ( blinking < 0 )
blinking = 0 ;
if ( rounds > 0 & & rounds < 11 )
{
for ( i = 0 ; i < rounds ; i = i + 1 )
{
if ( i = = 4 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
savex = x_offset + ( 10 * g_width / 480 ) ;
x_offset = x_offset + ( 10 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i = = 9 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + savex + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i > 4 )
icon_num = i - 5 ;
else
icon_num = i ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ icon_num ] , [ roundwidth , roundheight , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth + ( 3 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else
{
if ( rounds > = 100 )
{
num [ 2 ] = ( int ) ( rounds / 100 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 2 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 2 ] = 0 ;
if ( rounds > = 10 )
{
num [ 1 ] = ( int ) ( ( rounds - num [ 2 ] * 100 ) / 10 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 1 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 1 ] = 0 ;
num [ 0 ] = rounds - num [ 2 ] * 100 - num [ 1 ] * 10 ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 0 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else if ( rounds_change = = 6 ) //blink white while fading back
{
endroundchange = 0 ;
color_shift_init = 0 ;
2023-11-03 14:58:01 +00:00
blinking + = frametime * 500 ;
if ( blinking > 255 ) blinking = 255 ;
2022-02-08 18:42:28 +00:00
if ( rounds > 0 & & rounds < 11 )
{
for ( i = 0 ; i < rounds ; i = i + 1 )
{
if ( i = = 4 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
savex = x_offset + ( 10 * g_width / 480 ) ;
x_offset = x_offset + ( 10 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i = = 9 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + savex + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i > 4 )
icon_num = i - 5 ;
else
icon_num = i ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ icon_num ] , [ roundwidth , roundheight , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth + ( 3 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else
{
if ( rounds > = 100 )
{
num [ 2 ] = ( int ) ( rounds / 100 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 2 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 2 ] = 0 ;
if ( rounds > = 10 )
{
num [ 1 ] = ( int ) ( ( rounds - num [ 2 ] * 100 ) / 10 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 1 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 1 ] = 0 ;
num [ 0 ] = rounds - num [ 2 ] * 100 - num [ 1 ] * 10 ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 0 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ 1 , 1 , 1 ] , blinking / 255 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else if ( rounds_change = = 7 ) //blink white while fading back
{
2023-12-24 16:18:38 +00:00
stopwatch_round_isactive = true ;
2024-11-25 02:49:39 +00:00
stopwatch_round_hr = stopwatch_round_min = stopwatch_round_sec = 0 ;
2022-02-08 18:42:28 +00:00
if ( ! color_shift_init )
{
2025-01-22 04:03:58 +00:00
color_shift_end [ 0 ] = ROUND_RED_SHIFT ;
2022-02-08 18:42:28 +00:00
color_shift_end [ 1 ] = 1 ;
color_shift_end [ 2 ] = 0 ;
for ( i = 0 ; i < 3 ; i = i + 1 )
{
color_shift [ i ] = 255 ;
color_shift_steps [ i ] = ( color_shift [ i ] - color_shift_end [ i ] ) * ( frametime * 1.5 ) ;
}
color_shift_init = 1 ;
}
for ( i = 0 ; i < 3 ; i = i + 1 )
{
if ( color_shift [ i ] > color_shift_end [ i ] )
color_shift [ i ] = color_shift [ i ] - color_shift_steps [ i ] ;
if ( color_shift [ i ] < color_shift_end [ i ] )
color_shift [ i ] = color_shift_end [ i ] ;
}
if ( rounds > 0 & & rounds < 11 )
{
for ( i = 0 ; i < rounds ; i = i + 1 )
{
if ( i = = 4 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
savex = x_offset + ( 10 * g_width / 480 ) ;
x_offset = x_offset + ( 10 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i = = 9 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + savex + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i > 4 )
icon_num = i - 5 ;
else
icon_num = i ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ icon_num ] , [ roundwidth , roundheight , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth + ( 3 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else
{
if ( rounds > = 100 )
{
num [ 2 ] = ( int ) ( rounds / 100 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 2 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 2 ] = 0 ;
if ( rounds > = 10 )
{
num [ 1 ] = ( int ) ( ( rounds - num [ 2 ] * 100 ) / 10 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 1 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 1 ] = 0 ;
num [ 0 ] = rounds - num [ 2 ] * 100 - num [ 1 ] * 10 ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 0 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ color_shift [ 0 ] / 255 , color_shift [ 1 ] / 255 , color_shift [ 2 ] / 255 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else
{
2025-01-22 04:03:58 +00:00
color_shift [ 0 ] = ROUND_RED_SHIFT ;
2022-02-08 18:42:28 +00:00
color_shift [ 1 ] = 1 ;
color_shift [ 2 ] = 0 ;
color_shift_init = 0 ;
alphabling = 0 ;
if ( rounds > 0 & & rounds < 11 )
{
for ( i = 0 ; i < rounds ; i = i + 1 )
{
if ( i = = 4 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ ROUND_RED_SHIFT / 255 , 1 / 255 , 0 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
savex = x_offset + ( 10 * g_width / 480 ) ;
x_offset = x_offset + ( 10 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i = = 9 )
{
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + savex + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ 4 ] , [ roundwidth_4 , roundheight_4 , 1 ] , [ ROUND_RED_SHIFT / 255 , 1 / 255 , 0 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
continue ;
}
if ( i > 4 )
icon_num = i - 5 ;
else
icon_num = i ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 5 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round [ icon_num ] , [ roundwidth , roundheight , 1 ] , [ ROUND_RED_SHIFT / 255 , 1 / 255 , 0 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth + ( 3 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
else
{
if ( rounds > = 100 )
{
num [ 2 ] = ( int ) ( rounds / 100 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 2 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ ROUND_RED_SHIFT / 255 , 1 / 255 , 0 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 2 ] = 0 ;
if ( rounds > = 10 )
{
num [ 1 ] = ( int ) ( ( rounds - num [ 2 ] * 100 ) / 10 ) ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 1 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ ROUND_RED_SHIFT / 255 , 1 / 255 , 0 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
else
num [ 1 ] = 0 ;
num [ 0 ] = rounds - num [ 2 ] * 100 - num [ 1 ] * 10 ;
if ( rounds = = 0 )
return ;
2025-01-22 04:03:58 +00:00
drawpic ( [ 2 + x_offset + GetUltraWideOffset ( ) , g_height - roundheight - ( 4 * g_height / 272 ) , 0 ] , sb_round_num [ num [ 0 ] ] , [ roundwidth_num , roundheight_num , 1 ] , [ ROUND_RED_SHIFT / 255 , 1 / 255 , 0 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
x_offset = x_offset + roundwidth_num - ( 8 * g_width / 480 ) ;
2022-02-08 18:42:28 +00:00
}
}
}
/*******************
* HUD_Useprint *
* * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
void ( ) HUD_Useprint =
2022-02-08 18:42:28 +00:00
{
2025-01-22 04:03:58 +00:00
if ( useprint_time < = time )
return ;
2024-10-20 20:15:40 +00:00
string usestring , usespace ;
2023-02-08 01:50:41 +00:00
string usecost ;
2022-02-08 18:42:28 +00:00
float print_width , x , button_width ;
usestring = " " ;
usespace = " " ;
2023-02-08 01:50:41 +00:00
usecost = " " ;
2024-10-20 20:15:40 +00:00
string usebutton = " " ;
float argc = tokenize ( findkeysforcommandex ( " +button7 " ) ) ;
for ( int i = 0 ; i < argc ; i + + ) {
2025-02-08 06:44:49 +00:00
string temp_button = strtoupper ( argv ( i ) ) ;
float bind_is_gamepad = Key_IsControllerGlyph ( temp_button ) ;
2024-10-20 20:15:40 +00:00
2025-02-08 06:44:49 +00:00
// Always display the last button in the last.
2024-10-20 20:15:40 +00:00
if ( bind_is_gamepad & & last_input_was_gamepad )
2025-02-08 06:44:49 +00:00
usebutton = temp_button ;
2024-10-20 20:15:40 +00:00
else if ( ! bind_is_gamepad & & ! last_input_was_gamepad )
2025-02-08 06:44:49 +00:00
usebutton = temp_button ;
2024-10-20 20:15:40 +00:00
}
if ( usebutton = = " " )
usebutton = " UNBOUND " ;
2022-02-08 18:42:28 +00:00
2024-06-30 03:27:35 +00:00
// If this is a gamepad button, the space we want to reserve
// in the usestring should be a fixed width.
if ( Key_IsControllerGlyph ( usebutton ) ) {
usespace = " " ;
}
// Scale the space in the usestring for the bind according to
// the bind's name.
else {
for ( float i = 0 ; i < strlen ( usebutton ) ; i + + ) {
usespace = strcat ( usespace , " " ) ;
}
2022-02-08 18:42:28 +00:00
}
switch ( useprint_type ) {
case 0 : //clear
usestring = " " ;
break ;
case 1 : //door
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to open Door " ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 2 : //debris
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to remove Debris " ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 3 : //ammo
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to buy Ammo for " , GetWeaponName ( useprint_weapon ) ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 4 : //weapon
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to buy " , GetWeaponName ( useprint_weapon ) ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 5 : //window
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to Rebuild Barrier " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 6 : //box
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " for Mystery Box " ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 7 : //box take
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " for " , GetWeaponName ( useprint_weapon ) ) ;
2022-02-08 18:42:28 +00:00
break ;
case 8 : //power
usestring = " The Power must be Activated first " ;
break ;
case 9 : //perk
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to buy " , GetPerkName ( useprint_weapon ) ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 10 : //turn on power
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to Turn On the Power " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 11 : //turn on trap
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to Activate the Trap " ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 12 : //packapunch
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to Pack-a-Punch " ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 13 : //revive
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to Revive Player " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 14 : //use teleporter (free)
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to use Teleporter " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 15 : //use teleporter (cost)
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to use Teleporter " ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 16 : //tp cooldown
usestring = " Teleporter is cooling down " ;
break ;
case 17 : //link
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to initate link to pad " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 18 : //no link
usestring = " Link not active " ;
break ;
case 19 : //finish link
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to link pad with core " ) ;
2022-02-08 18:42:28 +00:00
break ;
case 20 : //buyable ending
2024-09-12 02:12:20 +00:00
usestring = strcat ( " Hold " , usespace , " to End the Game " ) ;
usecost = strcat ( " [Cost: " , ftos ( useprint_cost ) , " ] " ) ;
2022-02-08 18:42:28 +00:00
break ;
default :
usestring = " This should not happen you dum fuck " ; //yikes
break ;
}
2024-09-12 02:12:20 +00:00
print_width = getTextWidth ( usestring , 12 ) ;
2025-01-22 04:03:58 +00:00
x = ( g_width - print_width ) / 2 ;
HUD_DrawStringWithBackdrop ( [ x , g_height / 2 + 65 , 0 ] , usestring , [ 12 , 12 , 0 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
2023-02-08 01:50:41 +00:00
// Draw "Cost" text.
if ( usecost ! = " " ) {
2024-09-12 02:12:20 +00:00
float cost_width = getTextWidth ( usecost , 12 ) ;
2025-01-22 04:03:58 +00:00
float x3 = ( g_width - cost_width ) / 2 ;
HUD_DrawStringWithBackdrop ( [ x3 , g_height / 2 + 84 , 0 ] , usecost , [ 12 , 12 , 0 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
2023-02-08 01:50:41 +00:00
}
2022-02-08 18:42:28 +00:00
2024-06-30 03:27:35 +00:00
// Draw highlighted usebutton
2022-02-08 18:42:28 +00:00
if ( substring ( usestring , 0 , 4 ) = = " Hold " ) {
2024-09-12 02:12:20 +00:00
button_width = x + getTextWidth ( " Hold " , 12 ) ;
2024-06-30 03:27:35 +00:00
if ( Key_IsControllerGlyph ( usebutton ) )
2024-11-26 19:47:57 +00:00
Key_DrawControllerGlyph ( [ button_width - 5 , g_height / 2 + 62 ] , usebutton , [ 18 , 18 ] ) ;
2024-06-30 03:27:35 +00:00
else
2024-09-12 02:12:20 +00:00
Draw_String ( [ button_width , g_height / 2 + 65 , 0 ] , usebutton , [ 12 , 12 , 0 ] , [ 1 , 1 , 0 ] , 1 , 0 ) ;
2022-02-08 18:42:28 +00:00
}
}
/*******************
* HUD_Perks *
* * * * * * * * * * * * * * * * * * */
int perk_order [ 9 ] ;
int current_perk_order ;
2024-01-14 02:47:02 +00:00
void ( ) UpdatePerks =
{
float new_perks = getstatf ( STAT_PERKS ) ;
if ( perks = = new_perks )
return ;
float s ;
// avoids out of bounds err - moto
if ( new_perks = = 0 )
current_perk_order = 0 ;
for ( float i = 1 ; i < 129 ; i * = 2 ) {
if ( new_perks & i & & ! ( perks & i ) ) {
perk_order [ current_perk_order ] = i ;
current_perk_order + = 1 ;
}
}
for ( float i = 1 ; i < 129 ; i * = 2 ) {
if ( perks & i & & ! ( new_perks & i ) )
{
for ( s = 0 ; s < 8 ; s + + )
{
if ( perk_order [ s ] = = i )
{
perk_order [ s ] = 0 ;
while ( perk_order [ s + 1 ] )
{
perk_order [ s ] = perk_order [ s + 1 ] ;
perk_order [ s + 1 ] = 0 ;
}
break ;
}
}
}
}
perks = new_perks ;
}
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
void ( ) HUD_Perks =
2022-02-08 18:42:28 +00:00
{
2023-02-08 01:50:41 +00:00
float scale ;
float x , y ;
2024-01-14 02:47:02 +00:00
// Update Perk Order.
UpdatePerks ( ) ;
2023-02-08 01:50:41 +00:00
scale = 32 ;
x = 20 ;
y = 6 ;
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
if ( cvar ( " vid_ultrawide_limiter " ) )
x + = ULTRAWIDE_OFFSET ;
2023-11-28 16:34:39 +00:00
// Double-Tap can have 2 icons depending on
// machine-specified version.
string double_tap_icon ;
if ( double_tap_version = = 1 ) // damage buffed
double_tap_icon = " gfx/hud/double2.tga " ;
else // just rof
double_tap_icon = " gfx/hud/double.tga " ;
2023-02-08 01:50:41 +00:00
// Draw second column first -- these need to be
// overlayed below the first column.
for ( float i = 4 ; i < 8 ; i + + ) {
2022-02-08 18:42:28 +00:00
if ( perk_order [ i ] ) {
2023-02-08 01:50:41 +00:00
if ( perk_order [ i ] = = P_JUG ) { drawpic ( [ x , y ] , " gfx/hud/jug.tga " , [ scale , scale ] , [ 1 , 1 , 1 ] , 1 ) ; }
2023-11-28 16:34:39 +00:00
if ( perk_order [ i ] = = P_DOUBLE ) { drawpic ( [ x , y ] , double_tap_icon , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
2023-02-08 01:50:41 +00:00
if ( perk_order [ i ] = = P_SPEED ) { drawpic ( [ x , y ] , " gfx/hud/speed.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_REVIVE ) { drawpic ( [ x , y ] , " gfx/hud/revive.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_FLOP ) { drawpic ( [ x , y ] , " gfx/hud/flopper.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_STAMIN ) { drawpic ( [ x , y ] , " gfx/hud/stamin.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_DEAD ) { drawpic ( [ x , y ] , " gfx/hud/dead.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_MULE ) { drawpic ( [ x , y ] , " gfx/hud/mule.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
}
y + = scale ;
}
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
x = 3 ;
y = 6 ;
if ( cvar ( " vid_ultrawide_limiter " ) )
x + = ULTRAWIDE_OFFSET ;
// Now the first column.
for ( float i = 0 ; i < 4 ; i + + ) {
if ( perk_order [ i ] ) {
if ( perk_order [ i ] = = P_JUG ) { drawpic ( [ x , y ] , " gfx/hud/jug.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
2023-11-28 16:34:39 +00:00
if ( perk_order [ i ] = = P_DOUBLE ) { drawpic ( [ x , y ] , double_tap_icon , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
2023-02-08 01:50:41 +00:00
if ( perk_order [ i ] = = P_SPEED ) { drawpic ( [ x , y ] , " gfx/hud/speed.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_REVIVE ) { drawpic ( [ x , y ] , " gfx/hud/revive.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_FLOP ) { drawpic ( [ x , y ] , " gfx/hud/flopper.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_STAMIN ) { drawpic ( [ x , y ] , " gfx/hud/stamin.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_DEAD ) { drawpic ( [ x , y ] , " gfx/hud/dead.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
if ( perk_order [ i ] = = P_MULE ) { drawpic ( [ x , y ] , " gfx/hud/mule.tga " , [ scale , scale , 1 ] , [ 1 , 1 , 1 ] , 1 ) ; }
2022-02-08 18:42:28 +00:00
}
2023-02-08 01:50:41 +00:00
y + = scale ;
2022-02-08 18:42:28 +00:00
}
}
/*******************
* HUD Weapons *
* * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
float weapon_name_time ;
string weapon_name_last ;
void ( ) HUD_WeaponString =
2022-02-08 18:42:28 +00:00
{
2025-01-22 04:03:58 +00:00
if ( cl_viewent . modelindex = = 0 )
return ;
string weapon_name = GetWeaponName ( getstatf ( STAT_ACTIVEWEAPON ) ) ;
// If the string matches our last store, bail out.
if ( weapon_name = = weapon_name_last & & weapon_name_time < = time ) {
return ;
} else if ( weapon_name ! = weapon_name_last ) {
// three seconds: one for display, two for fade out.
weapon_name_time = time + 3 ;
// Update last string storage.
weapon_name_last = weapon_name ;
}
float weapon_name_alpha ;
if ( weapon_name_time - time > 2 ) {
weapon_name_alpha = 1 ;
} else {
weapon_name_alpha = ( weapon_name_time - time ) / 2 ;
}
float x = g_width - 62 - getTextWidth ( weapon_name , 12 ) ;
HUD_DrawStringWithBackdrop ( [ x - GetUltraWideOffset ( ) , g_height - 49 ] , weapon_name , [ 12 , 12 ] , [ 1 , 1 , 1 ] , weapon_name_alpha , 0 ) ;
2022-02-08 18:42:28 +00:00
}
2023-10-28 16:09:57 +00:00
/*********************
* HUD Bouncing Betty *
* * * * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
void ( ) HUD_BouncingBetty =
2023-10-28 16:09:57 +00:00
{
2025-01-22 04:03:58 +00:00
if ( bettyprompt_time < = time )
return ;
2023-10-28 16:09:57 +00:00
float top_x , bot_x , but_x ;
2024-11-30 06:30:24 +00:00
string betty_key = " " ;
2024-06-30 03:27:35 +00:00
string betty_space = " " ;
2023-10-28 16:09:57 +00:00
string activate_string , activate_string2 ;
2024-11-30 06:30:24 +00:00
float argc = tokenize ( findkeysforcommandex ( " impulse 33 " ) ) ;
2025-02-08 06:44:49 +00:00
for ( int i = 0 ; i < argc ; i + + ) {
string temp_button = strtoupper ( argv ( i ) ) ;
float bind_is_gamepad = Key_IsControllerGlyph ( temp_button ) ;
2024-11-30 06:30:24 +00:00
2025-02-08 06:44:49 +00:00
// Always display the last button in the last.
if ( bind_is_gamepad & & last_input_was_gamepad )
betty_key = temp_button ;
else if ( ! bind_is_gamepad & & ! last_input_was_gamepad )
betty_key = temp_button ;
}
2023-10-28 16:09:57 +00:00
2024-06-30 03:27:35 +00:00
// If this is a gamepad button, the space we want to reserve
// in the betty string should be a fixed width.
if ( Key_IsControllerGlyph ( betty_key ) ) {
2024-11-30 06:30:24 +00:00
betty_space = " " ;
2024-06-30 03:27:35 +00:00
}
// Scale the space in the betty string for the bind according to
// the bind's name.
else {
for ( float i = 0 ; i < strlen ( betty_key ) ; i + + ) {
betty_space = strcat ( betty_space , " " ) ;
}
2023-10-28 16:09:57 +00:00
}
activate_string = strcat ( " Press " , betty_space , " to place a " ) ;
activate_string2 = " Bouncing Betty " ;
2024-09-12 02:12:20 +00:00
top_x = ( g_width / 2 ) - ( getTextWidth ( activate_string , 12 ) / 2 ) ;
bot_x = ( g_width / 2 ) - ( getTextWidth ( activate_string2 , 12 ) / 2 ) ;
2023-10-28 16:09:57 +00:00
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ top_x , g_height - 303 ] , activate_string , [ 12 , 12 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
HUD_DrawStringWithBackdrop ( [ bot_x , g_height - 289 ] , activate_string2 , [ 12 , 12 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
2023-10-28 16:09:57 +00:00
// Draw the highlighted button
2024-09-12 02:12:20 +00:00
but_x = top_x + getTextWidth ( " Press " , 12 ) ;
2024-06-30 03:27:35 +00:00
if ( Key_IsControllerGlyph ( betty_key ) )
2024-11-30 06:30:24 +00:00
Key_DrawControllerGlyph ( [ but_x - 5 , g_height - 308 ] , betty_key , [ 18 , 18 ] ) ;
2024-06-30 03:27:35 +00:00
else
2024-09-12 02:12:20 +00:00
Draw_String ( [ but_x , g_height - 303 ] , betty_key , [ 12 , 12 ] , [ 1 , 1 , 0 ] , 1 , 0 ) ;
2023-10-28 16:09:57 +00:00
}
2022-02-08 18:42:28 +00:00
/*******************
* HUD Progress Bar *
* * * * * * * * * * * * * * * * * * */
2025-01-22 04:03:58 +00:00
void ( ) HUD_Progressbar =
2022-02-08 18:42:28 +00:00
{
float percent = getstatf ( STAT_PROGRESSBAR ) ;
2023-02-08 01:50:41 +00:00
if ( ! percent )
2022-02-08 18:42:28 +00:00
return ;
string progress ;
local float ws_offset ;
progress = ftos ( percent ) ;
ws_offset = ( strlen ( progress ) - 1 ) ;
2023-02-08 01:50:41 +00:00
float bar_width = 200 ;
float bar_height = 12 ;
2025-01-22 04:03:58 +00:00
float bar_x = ( g_width - bar_width ) / 2 ;
float bar_y = g_height * 0.75 ;
2022-02-08 18:42:28 +00:00
drawfill ( [ bar_x - 1 , bar_y - 1 , 0 ] , [ bar_width + 2 , bar_height , 0 ] , [ 0 , 0 , 0 ] , 0.4 , 0 ) ;
drawfill ( [ bar_x , bar_y , 0 ] , [ bar_width * percent , bar_height - 2 , 0 ] , [ 1 , 1 , 1 ] , 0.4 , 0 ) ;
2024-09-12 02:12:20 +00:00
float x = ( g_width / 2 ) - ( getTextWidth ( " Reviving... " , 12 ) / 2 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ x , g_height - 105 ] , " Reviving... " , [ 12 , 12 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
2022-02-08 18:42:28 +00:00
}
/*******************
* HUD Hitmark *
* * * * * * * * * * * * * * * * * * */
void ( ) HUD_Hitmark =
{
2025-01-22 04:03:58 +00:00
if ( hitmark_time < = time | | cvar ( " cl_hitmarkers " ) = = 0 )
return ;
float hitmark_alpha = 1 ;
vector hitmark_color = [ 1 , 1 , 1 ] ;
if ( hitmark_type = = 1 ) {
hitmark_alpha = ( hitmark_time - time ) * 5 ;
hitmark_color = [ 0.75 , 0 , 0 ] ;
} else {
hitmark_alpha = ( hitmark_time - time ) * 3.3 ;
}
drawpic ( [ g_width / 2 - 10 , g_height / 2 - 10 ] , " gfx/hud/hit_marker.tga " , [ 20 , 20 ] , hitmark_color , hitmark_alpha ) ;
2022-02-08 18:42:28 +00:00
}
/*******************
* HUD Crosshair *
* * * * * * * * * * * * * * * * * * */
float croshhairmoving ; // naievil --used t o see if we are moving or not
float cur_spread ;
float crosshair_offset_step ;
float crosshair_opacity ;
vector crosshair_color ;
2025-01-22 04:03:58 +00:00
void ( ) HUD_Crosshair =
2022-02-08 18:42:28 +00:00
{
2023-02-08 01:50:41 +00:00
if ( cvar ( " cl_crosshair_debug " ) ) {
drawline ( 2 , [ g_width / 2 , g_height / 2 , 0 ] , [ 0 , g_height , 0 ] , [ 1 , 0 , 0 ] , 0.5 ) ;
drawline ( 2 , [ g_width / 2 , g_height / 2 , 0 ] , [ g_width , 0 , 0 ] , [ 0 , 1 , 1 ] , 0.5 ) ;
drawline ( 2 , [ g_width , g_height , 0 ] , [ g_width / 2 , g_height / 2 , 0 ] , [ 0 , 1 , 0 ] , 0.5 ) ;
drawline ( 2 , [ 0 , 0 , 0 ] , [ g_width / 2 , g_height / 2 , 0 ] , [ 0 , 0 , 1 ] , 0.5 ) ;
}
2023-10-16 14:23:50 +00:00
hide_viewmodel = false ;
if ( getstatf ( STAT_WEAPONZOOM ) = = 2 & & zoom_2_time < time )
{
hide_viewmodel = true ;
drawfill ( ' 0 0 0 ' , [ g_width / 2 - g_height / 2 , g_height , 0 ] , ' 0 0 0 ' , 1 , 0 ) ;
drawpic ( [ ( g_width / 2 - g_height / 2 ) , 0 , 0 ] , " gfx/hud/scope_nb.tga " , [ g_height , g_height , 1 ] , [ 1 , 1 , 1 ] , 1 ) ;
drawfill ( [ ( g_width / 2 + g_height / 2 ) , 0 , 0 ] , [ g_width , g_height , 0 ] , ' 0 0 0 ' , 1 , 0 ) ;
2024-11-28 20:35:16 +00:00
// Draw "Hold Breath" text if we aren't already doing so and we don't have Deadshot Daiquiri.
if ( sniper_hold_breath ! = true & & ! ( getstatf ( STAT_PERKS ) & P_DEAD ) ) {
// Grab the bind for Sprint/Hold Breath
string breath_button = " " ;
string space_width = " " ;
float argc = tokenize ( findkeysforcommandex ( " impulse 23 " ) ) ;
for ( int i = 0 ; i < argc ; i + + ) {
2025-02-08 06:44:49 +00:00
string temp_button = strtoupper ( argv ( i ) ) ;
float bind_is_gamepad = Key_IsControllerGlyph ( temp_button ) ;
// Always display the last button in the last.
if ( bind_is_gamepad & & last_input_was_gamepad )
breath_button = temp_button ;
else if ( ! bind_is_gamepad & & ! last_input_was_gamepad )
breath_button = temp_button ;
2024-11-28 20:35:16 +00:00
}
if ( breath_button = = " " )
breath_button = " UNBOUND " ;
string breath_button_string = " " ;
// If this is a gamepad button, the space we want to reserve
// in the string should be a fixed width.
if ( ! Key_IsControllerGlyph ( breath_button ) ) {
breath_button_string = breath_button ;
}
string breath_string = strcat ( " Hold " , breath_button_string , " to steady " ) ;
float print_width = getTextWidth ( breath_string , 12 ) ;
float x = ( g_width - print_width ) / 2 ;
Draw_String ( [ x , 65 , 0 ] , breath_string , [ 12 , 12 , 0 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
// Draw highlighted button
float button_width = x + getTextWidth ( " Hold " , 12 ) ;
if ( Key_IsControllerGlyph ( breath_button ) )
Key_DrawControllerGlyph ( [ button_width - 5 , 62 ] , breath_button , [ 18 , 18 ] ) ;
else
Draw_String ( [ button_width , 65 , 0 ] , breath_button , [ 12 , 12 , 0 ] , [ 1 , 1 , 0 ] , 1 , 0 ) ;
}
2023-10-16 14:23:50 +00:00
return ;
}
float crosshair_value = cvar ( " crosshair " ) ;
2023-10-16 22:09:49 +00:00
if ( ! crosshair_value | | getstatf ( STAT_WEAPONZOOM ) = = 1 )
2023-10-15 20:06:01 +00:00
return ;
2022-02-08 18:42:28 +00:00
if ( ! crosshair_opacity )
crosshair_opacity = 1 ;
2023-11-11 22:42:23 +00:00
if ( ( K_BACKDOWN | | K_FORWARDDOWN | | K_LEFTDOWN | | K_RIGHTDOWN | | input_buttons = = 2 ) & & crosshair_value = = 1 ) {
2022-02-08 18:42:28 +00:00
croshhairmoving = 1 ;
crosshair_opacity - = frametime ;
if ( crosshair_opacity < 0.5 )
crosshair_opacity = 0.5 ;
if ( cur_spread > = CrossHairMaxSpread ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_PLAYERSTANCE ) ) ) {
cur_spread = CrossHairMaxSpread ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_PLAYERSTANCE ) ) ;
} else {
2023-03-03 03:06:26 +00:00
cur_spread + = ( frametime * 160 ) ;
2022-02-08 18:42:28 +00:00
}
} else {
croshhairmoving = 0 ;
if ( cur_spread > 0 )
2023-03-03 03:06:26 +00:00
cur_spread - = ( frametime * 160 ) ;
2022-02-08 18:42:28 +00:00
else
cur_spread = 0 ;
crosshair_opacity + = frametime ;
if ( crosshair_opacity > 1 )
crosshair_opacity = 1 ;
}
// Update values to be red if we're facing an enemy
if ( getstatf ( STAT_FACINGENEMY ) )
crosshair_color = TEXT_RED ;
else
crosshair_color = [ 1 , 1 , 1 ] ;
2023-03-09 18:58:00 +00:00
2023-03-10 17:20:43 +00:00
if ( getstatf ( STAT_HEALTH ) < 1 )
2022-02-08 18:42:28 +00:00
return ;
2023-02-08 01:50:41 +00:00
2023-10-16 14:23:50 +00:00
// Standard crosshair (+)
if ( crosshair_value = = 1 ) {
int x_value , y_value ;
int crosshair_offset ;
2023-03-22 16:02:53 +00:00
2023-10-16 14:23:50 +00:00
crosshair_offset = CrossHairWeapon ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_PLAYERSTANCE ) ) + cur_spread ;
2023-03-22 16:02:53 +00:00
2023-10-16 14:23:50 +00:00
if ( CrossHairMaxSpread ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_PLAYERSTANCE ) ) < crosshair_offset )
crosshair_offset = CrossHairMaxSpread ( getstatf ( STAT_ACTIVEWEAPON ) , getstatf ( STAT_PLAYERSTANCE ) ) ;
2023-03-22 16:02:53 +00:00
2023-10-16 14:23:50 +00:00
if ( perks & P_DEAD )
crosshair_offset * = 0.65 ;
2022-02-08 18:42:28 +00:00
2023-10-16 14:23:50 +00:00
crosshair_offset_step + = ( crosshair_offset - crosshair_offset_step ) * 0.5 ;
2022-02-08 18:42:28 +00:00
2023-10-16 14:23:50 +00:00
// Creds to heartologic for some actually good crosshair position stuff.
vector crossSize = [ 1 , 5 ] ;
vector screenSize = [ g_width , g_height ] ;
2022-02-08 18:42:28 +00:00
2023-10-16 14:23:50 +00:00
drawfill ( screenSize / 2 - [ crossSize . x , + crossSize . y * 2 + crosshair_offset_step ] , crossSize , crosshair_color , crosshair_opacity , 0 ) ; // top
drawfill ( screenSize / 2 - [ crossSize . x , - crossSize . y * 1 - crosshair_offset_step + 2 ] , crossSize , crosshair_color , crosshair_opacity , 0 ) ; // bottom
drawfill ( screenSize / 2 - [ + crossSize . y * 2 + crosshair_offset_step , crossSize . x ] , [ crossSize . y , crossSize . x ] , crosshair_color , crosshair_opacity , 0 ) ; // right
drawfill ( screenSize / 2 - [ - crossSize . y * 1 - crosshair_offset_step , crossSize . x ] , [ crossSize . y , crossSize . x ] , crosshair_color , crosshair_opacity , 0 ) ; // left
}
// Area of Effect (o)
else if ( crosshair_value = = 2 ) {
2024-09-12 02:12:20 +00:00
float circle_offset = getTextWidth ( " O " , 14 ) / 2 ;
Draw_String ( [ g_width / 2 - circle_offset , g_height / 2 - circle_offset ] , " O " , [ 14 , 14 ] , crosshair_color , 1 , 0 ) ;
2023-10-16 14:23:50 +00:00
}
// Dot crosshair (.)
else if ( crosshair_value = = 3 ) {
vector screenSize2 = [ g_width , g_height ] ;
drawfill ( screenSize2 / 2 - [ 2 , 2 ] , [ 4 , 4 ] , crosshair_color , crosshair_opacity , 0 ) ; // dot
}
// Grenade crosshair
else if ( crosshair_value = = 4 ) {
if ( crosshair_pulse_grenade ) {
crosshair_offset_step = 0 ;
cur_spread = 12 ;
2023-03-22 16:02:53 +00:00
}
2023-10-16 14:23:50 +00:00
crosshair_pulse_grenade = false ;
int crosshair_offset2 ;
crosshair_offset2 = 3 + cur_spread ;
crosshair_offset_step + = ( crosshair_offset2 - crosshair_offset_step ) * 0.05 ;
// Creds to heartologic for some actually good crosshair position stuff.
vector crossSize2 = [ 1 , 5 ] ;
vector screenSize3 = [ g_width , g_height ] ;
drawfill ( screenSize3 / 2 - [ crossSize2 . x , + crossSize2 . y * 2 + crosshair_offset_step ] , crossSize2 , crosshair_color , crosshair_opacity , 0 ) ; // top
drawfill ( screenSize3 / 2 - [ crossSize2 . x , - crossSize2 . y * 1 - crosshair_offset_step + 2 ] , crossSize2 , crosshair_color , crosshair_opacity , 0 ) ; // bottom
drawfill ( screenSize3 / 2 - [ + crossSize2 . y * 2 + crosshair_offset_step , crossSize2 . x ] , [ crossSize2 . y , crossSize2 . x ] , crosshair_color , crosshair_opacity , 0 ) ; // right
drawfill ( screenSize3 / 2 - [ - crossSize2 . y * 1 - crosshair_offset_step , crossSize2 . x ] , [ crossSize2 . y , crossSize2 . x ] , crosshair_color , crosshair_opacity , 0 ) ; // left
2023-02-08 01:50:41 +00:00
}
}
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
void ( ) HUD_Powerups =
{
float count = 0 ;
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
// horrible way to offset check :)))))))))))))))))) :DDDDDDDD XOXO
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
if ( getstatf ( STAT_X2 ) )
count + + ;
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
if ( getstatf ( STAT_INSTA ) )
count + + ;
2022-02-08 18:42:28 +00:00
2023-02-08 01:50:41 +00:00
// both are avail draw fixed order
if ( count = = 2 ) {
drawpic ( [ g_width / 2 - ( 2 + 32 ) , g_height - 38 ] , " gfx/hud/2x.tga " , [ 32 , 32 ] , [ 1 , 1 , 1 ] , 1 ) ;
drawpic ( [ g_width / 2 + 2 , g_height - 38 ] , " gfx/hud/in_kill.tga " , [ 32 , 32 ] , [ 1 , 1 , 1 ] , 1 ) ;
} else {
if ( getstatf ( STAT_X2 ) )
drawpic ( [ g_width / 2 - 16 , g_height - 38 ] , " gfx/hud/2x.tga " , [ 32 , 32 ] , [ 1 , 1 , 1 ] , 1 ) ;
else if ( getstatf ( STAT_INSTA ) )
drawpic ( [ g_width / 2 - 16 , g_height - 38 ] , " gfx/hud/in_kill.tga " , [ 32 , 32 ] , [ 1 , 1 , 1 ] , 1 ) ;
}
2022-02-08 18:42:28 +00:00
}
2024-01-14 02:47:02 +00:00
void ( ) HUD_Broadcast =
{
2025-01-22 04:03:58 +00:00
if ( broadcast_time < = time )
return ;
2024-12-26 22:11:50 +00:00
// broadcast_num refers to the playernum of the client. This
// does NOT correspond to player key indexes, so we need to
// grab the player with the matching playernum and use infokeys.
entity player_target = findfloat ( world , playernum , broadcast_num ) ;
string broadcast_name = infokey ( player_target , INFOKEY_P_NAME ) ;
2022-02-08 18:42:28 +00:00
string broadcast_msg = " " ;
2024-12-26 22:11:50 +00:00
2023-01-13 20:41:27 +00:00
switch ( broadcast_type ) {
2024-01-14 02:47:02 +00:00
case CSQC_BROADCAST_PLAYERDOWNED :
broadcast_msg = strcat ( broadcast_name , " needs to be revived " ) ;
break ;
case CSQC_BROADCAST_BEINGREVIVED :
broadcast_msg = strcat ( broadcast_name , " is reviving you " ) ;
break ;
case CSQC_BROADCAST_REVIVINGPLAYER :
broadcast_msg = strcat ( " Reviving " , broadcast_name ) ;
break ;
case CSQC_BROADCAST_NONE :
broadcast_msg = " " ;
break ;
default :
broadcast_msg = " Bad broadcast. " ;
break ;
2023-01-13 20:41:27 +00:00
}
2025-01-22 04:03:58 +00:00
float print_width = getTextWidth ( broadcast_msg , 12 ) ;
2022-02-08 18:42:28 +00:00
float x = ( g_width - print_width ) / 2 ;
2023-01-13 20:41:27 +00:00
2025-01-22 04:03:58 +00:00
if ( broadcast_msg ! = " " ) {
HUD_DrawStringWithBackdrop ( [ x , g_height / 2 , 0 ] , broadcast_msg , [ 12 , 12 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
}
2024-01-14 02:47:02 +00:00
} ;
2022-02-08 18:42:28 +00:00
2025-01-15 05:14:19 +00:00
void ( float y_pos ) HUD_DrawMoneyBackDisplay =
{
int i ;
// Center moneyback
drawpic ( [ g_width / 2 - 48 , y_pos ] , " gfx/hud/moneyback.tga " , [ 96 , 24 ] , [ 1 , 1 , 1 ] , 1 ) ;
// Left
for ( i = 0 ; i < 3 ; i + + ) {
drawpic ( [ ( g_width / 2 - 48 ) - ( 70 * ( i + 1 ) ) , y_pos ] , " gfx/hud/moneyback.tga " , [ 96 , 24 ] , [ 1 , 1 , 1 ] , 1 ) ;
}
// Right
for ( i = 0 ; i < 3 ; i + + ) {
drawpic ( [ ( g_width / 2 - 48 ) + ( 70 * ( i + 1 ) ) , y_pos ] , " gfx/hud/moneyback.tga " , [ 96 , 24 ] , [ 1 , 1 , 1 ] , 1 ) ;
}
} ;
2022-02-08 18:42:28 +00:00
void ( ) HUD_Scores =
{
vector TEXTCOLOR = [ 1 , 1 , 1 ] ;
2025-01-15 05:14:19 +00:00
float header_x_start = - 75 ;
float header_x_increment = 65 ;
float scoreboard_text_size = 10 ;
float header_x_pos = header_x_start ;
2022-02-08 18:42:28 +00:00
if ( serverkey ( " constate " ) ! = " disconnected " )
{
2025-01-15 05:14:19 +00:00
Draw_String ( [ 5 , g_height - scoreboard_text_size - 5 ] , sprintf ( " Nazi Zombies: Portable %s " , build_datetime ) , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
// Scoreboard header
drawfill ( [ g_width / 2 - 271 , 177 ] , [ 270 * 2 + 2 , 1 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
drawfill ( [ g_width / 2 - 271 , 178 + scoreboard_text_size + 4 ] , [ 270 * 2 + 2 , 1 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
drawfill ( [ g_width / 2 - 271 , 178 ] , [ 1 , scoreboard_text_size + 4 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
drawfill ( [ g_width / 2 + 270 , 178 ] , [ 1 , scoreboard_text_size + 4 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
drawfill ( [ g_width / 2 - 270 , 178 ] , [ 270 * 2 , scoreboard_text_size + 4 ] , [ 0 , 0 , 0 ] , 0.80 , 0 ) ;
// Name
string map_name = serverkey ( " mapname_pretty " ) ;
Draw_String ( [ g_width / 2 - 265 , 180 ] , map_name , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( " Score " , scoreboard_text_size ) / 2 ) , 180 ] , " Score " , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( " Kills " , scoreboard_text_size ) / 2 ) , 180 ] , " Kills " , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( " Downs " , scoreboard_text_size ) / 2 ) , 180 ] , " Downs " , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( " Revives " , scoreboard_text_size ) / 2 ) , 180 ] , " Revives " , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( " Headshots " , scoreboard_text_size ) / 2 ) , 180 ] , " Headshots " , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
2022-02-08 18:42:28 +00:00
2023-11-11 22:42:23 +00:00
for ( int i = 0 ; i < 4 ; i = i + 1 )
2022-02-08 18:42:28 +00:00
{
2024-12-08 04:13:54 +00:00
float player_number = getplayerkeyfloat ( i , " client_index " ) ;
2023-12-28 15:49:30 +00:00
entity client = findfloat ( world , playernum , player_number ) ;
2024-12-08 04:13:54 +00:00
if ( ( client = = world | | ! client . classname ) & & ! client . is_spectator )
continue ;
2022-02-08 18:42:28 +00:00
switch ( i ) {
case 1 : TEXTCOLOR = TEXT_LIGHTBLUE ; break ;
case 2 : TEXTCOLOR = TEXT_ORANGE ; break ;
case 3 : TEXTCOLOR = TEXT_GREEN ; break ;
default : TEXTCOLOR = [ 1 , 1 , 1 ] ; break ;
}
2023-11-11 22:42:23 +00:00
2025-01-15 05:14:19 +00:00
float y_pos = ( scoreboard_text_size + 5 ) * i ;
// Fill
drawfill ( [ g_width / 2 - 270 , 195 + y_pos ] , [ 270 * 2 , scoreboard_text_size + 5 ] , [ 0 , 0 , 0 ] , 0.80 , 0 ) ;
drawfill ( [ g_width / 2 + ( header_x_start - header_x_increment / 2 ) , 195 + y_pos ] , [ header_x_increment , scoreboard_text_size + 5 ] , [ 0.3 , 0 , 0 ] , 0.15 , 0 ) ;
drawfill ( [ g_width / 2 + ( ( header_x_start + header_x_increment * 2 ) - header_x_increment / 2 ) , 195 + y_pos ] , [ header_x_increment , scoreboard_text_size + 5 ] , [ 0.3 , 0 , 0 ] , 0.15 , 0 ) ;
drawfill ( [ g_width / 2 + ( ( header_x_start + header_x_increment * 4 ) - header_x_increment / 2 ) , 195 + y_pos ] , [ header_x_increment , scoreboard_text_size + 5 ] , [ 0.3 , 0 , 0 ] , 0.15 , 0 ) ;
// Top
if ( i = = 0 )
drawfill ( [ g_width / 2 - 271 , 194 + y_pos ] , [ 270 * 2 + 2 , 1 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
// Bottom
if ( player_count = = i + 1 )
drawfill ( [ g_width / 2 - 271 , 195 + y_pos + scoreboard_text_size + 4 ] , [ 270 * 2 + 2 , 1 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
2023-11-11 22:42:23 +00:00
// Left
2025-01-15 05:14:19 +00:00
drawfill ( [ g_width / 2 - 271 , 194 + y_pos ] , [ 1 , scoreboard_text_size + 6 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
// Right
drawfill ( [ g_width / 2 + 270 , 194 + y_pos ] , [ 1 , scoreboard_text_size + 6 ] , [ 0.2 , 0.2 , 0.2 ] , 1 , 0 ) ;
header_x_pos = header_x_start ;
2022-02-08 18:42:28 +00:00
2023-11-11 22:42:23 +00:00
// Name
2023-12-28 15:49:30 +00:00
string player_name = getplayerkeyvalue ( i , " name " ) ;
2025-01-15 05:14:19 +00:00
Draw_String ( [ g_width / 2 - 265 , 197 + y_pos ] , player_name , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
2023-11-11 22:42:23 +00:00
2025-01-15 05:14:19 +00:00
// Score
string score_string = ftos ( client . points ) ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( score_string , scoreboard_text_size ) / 2 ) , 197 + y_pos ] , score_string , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
2023-11-11 22:42:23 +00:00
// Kills
2025-01-15 05:14:19 +00:00
string kills_string = ftos ( client . kills ) ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( kills_string , scoreboard_text_size ) / 2 ) , 197 + y_pos ] , kills_string , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
// Downs
string downs_string = ftos ( client . downs ) ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( downs_string , scoreboard_text_size ) / 2 ) , 197 + y_pos ] , downs_string , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
// Revives
string revives_string = ftos ( client . revives ) ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( revives_string , scoreboard_text_size ) / 2 ) , 197 + y_pos ] , revives_string , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
header_x_pos + = header_x_increment ;
// Headshots
string headshots_string = ftos ( client . headshots ) ;
Draw_String ( [ g_width / 2 + ( header_x_pos - getTextWidth ( headshots_string , scoreboard_text_size ) / 2 ) , 197 + y_pos ] , headshots_string , [ scoreboard_text_size , scoreboard_text_size ] , TEXTCOLOR , 1 , 0 ) ;
// Ping
float ping_num_bars ;
vector ping_bar_color = [ 0 , 1 , 0 ] ;
if ( client . ping < 100 ) {
ping_num_bars = 4 ;
} else if ( client . ping < 200 ) {
ping_num_bars = 3 ;
} else if ( client . ping < 300 ) {
ping_num_bars = 2 ;
ping_bar_color = [ 1 , 0.5 , 0 ] ;
} else {
ping_num_bars = 1 ;
ping_bar_color = [ 1 , 0 , 0 ] ;
}
header_x_pos + = 5 + header_x_increment / 2 ;
float ping_bar_width = 2 ;
float ping_bar_height = 4 ;
float ping_bar_height_increment = 2 ;
string ping_string = sprintf ( " %dms " , client . ping ) ;
Draw_String ( [ g_width / 2 + ( ( header_x_pos + 28 ) - getTextWidth ( ping_string , scoreboard_text_size - 2 ) / 2 ) , 199 + y_pos ] , ping_string , [ scoreboard_text_size - 2 , scoreboard_text_size - 2 ] , TEXTCOLOR , 1 , 0 ) ;
for ( float bars = ping_num_bars ; bars > 0 ; bars - - ) {
drawfill ( [ g_width / 2 + header_x_pos , 197 + y_pos + ( 11 - ping_bar_height ) ] , [ ping_bar_width , ping_bar_height ] , ping_bar_color , 1 , 0 ) ;
ping_bar_height + = ping_bar_height_increment ;
header_x_pos + = 3 ;
}
2022-02-08 18:42:28 +00:00
}
}
}
void ( ) HUD_Endgame = {
2023-11-11 22:42:23 +00:00
string game_over = " GAME OVER " ;
string survive ;
string round ;
2022-02-08 18:42:28 +00:00
if ( rounds = = 1 )
2023-11-11 22:42:23 +00:00
round = " Round " ;
else
round = " Rounds " ;
2022-02-08 18:42:28 +00:00
2023-11-11 22:42:23 +00:00
survive = strcat ( " You Survived " , ftos ( rounds ) , round ) ;
2024-09-12 02:12:20 +00:00
float game_over_width = getTextWidth ( game_over , 24 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ g_width / 2 - game_over_width / 2 , 100 ] , game_over , [ 24 , 24 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
2023-11-11 22:42:23 +00:00
2024-09-12 02:12:20 +00:00
float survive_width = getTextWidth ( survive , 18 ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ g_width / 2 - survive_width / 2 , 135 ] , survive , [ 18 , 18 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
2022-02-08 18:42:28 +00:00
}
2024-01-15 01:48:42 +00:00
//
// HUD_Screenflash()
// Screen fade in and out behaviors.
//
void ( ) HUD_Screenflash =
2022-02-08 18:42:28 +00:00
{
2025-01-22 04:03:58 +00:00
if ( screenflash_duration < = time )
return ;
2024-01-15 01:48:42 +00:00
vector color = ' 0 0 0 ' ;
float flash_alpha = 0 ;
// Obtain the flash color
switch ( screenflash_color ) {
case SCREENFLASH_COLOR_BLACK : color = ' 0 0 0 ' ; break ;
case SCREENFLASH_COLOR_WHITE : color = ' 1 1 1 ' ; break ;
default : color = ' 1 0 0 ' ; break ;
2022-02-08 18:42:28 +00:00
}
2024-01-15 01:48:42 +00:00
float percentage_complete = screenflash_worktime / ( screenflash_duration - screenflash_starttime ) ;
// Fade Out
if ( screenflash_type = = SCREENFLASH_FADE_OUT ) {
flash_alpha = invertfloat ( percentage_complete ) ;
}
// Fade In
else if ( screenflash_type = = SCREENFLASH_FADE_IN ) {
flash_alpha = percentage_complete ;
2022-02-08 18:42:28 +00:00
}
2024-01-15 01:48:42 +00:00
// Fade In + Fade Out
else {
// Fade In
if ( percentage_complete < 0.5 ) {
flash_alpha = percentage_complete ;
}
// Fade Out
else {
flash_alpha = invertfloat ( percentage_complete ) ;
}
}
screenflash_worktime + = frametime ;
drawfill ( [ 0 , 0 ] , [ g_width , g_height , 0 ] , color , flash_alpha , 0 ) ;
2022-02-08 18:42:28 +00:00
}
2024-05-19 17:35:50 +00:00
//
// HUD_MaxAmmo(width, height)
// Displays the "Max Ammo!" text on the HUD.
//
2025-01-22 04:03:58 +00:00
void ( ) HUD_MaxAmmo =
2024-05-19 17:35:50 +00:00
{
2025-01-22 04:03:58 +00:00
if ( hud_maxammo_endtime < = time )
return ;
2024-05-19 17:35:50 +00:00
string maxammo_string = " Max Ammo! " ;
float start_y = 70 ;
float end_y = 55 ;
float diff_y = end_y - start_y ;
float text_alpha = 1 ;
2024-09-12 02:12:20 +00:00
float string_width = getTextWidth ( maxammo_string , 14 ) ;
2025-01-22 04:03:58 +00:00
float pos_x = ( g_width - string_width ) / 2 ;
2024-05-19 17:35:50 +00:00
float pos_y ;
float start_time , end_time ;
// For the first 0.5s, stay still while we fade in
if ( hud_maxammo_endtime > time + 1.5 ) {
start_time = hud_maxammo_starttime ;
end_time = hud_maxammo_starttime + 0.5 ;
text_alpha = ( time - start_time ) / ( end_time - start_time ) ;
pos_y = start_y ;
2022-02-08 18:42:28 +00:00
}
2024-05-19 17:35:50 +00:00
// For the remaining 1.5s, fade out while we fly upwards.
else {
start_time = hud_maxammo_starttime + 0.5 ;
end_time = hud_maxammo_endtime ;
float percent_time = ( time - start_time ) / ( end_time - start_time ) ;
pos_y = start_y + diff_y * percent_time ;
text_alpha = 1 - percent_time ;
}
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ pos_x , pos_y , 0 ] , maxammo_string , [ 14 , 14 ] , [ 1 , 1 , 1 ] , text_alpha , 0 ) ;
2024-05-19 17:35:50 +00:00
} ;
2022-02-08 18:42:28 +00:00
float achievement_init ;
float achievement_ypos ;
float achievement_desc_ypos ;
float achievement_img_ypos ;
float achievement_time ;
2025-01-22 04:03:58 +00:00
void ( ) HUD_Achievements = {
2022-02-08 18:42:28 +00:00
if ( active_achievement = = - 1 )
return ;
if ( ! achievement_init ) {
achievement_time = 0 ;
achievement_ypos = - 0.16 ;
achievement_desc_ypos = - 0.13 ;
achievement_img_ypos = - 0.164 ;
achievement_init = true ;
}
2025-01-22 04:03:58 +00:00
Draw_String ( [ 0.2 * g_width , achievement_ypos * g_height , 0 ] , " ACHIEVEMENT GET! " , [ 0.015 * g_width , 0.015 * g_width , 0 ] , [ 1 , 1 , 0 ] , 1 , 0 ) ;
Draw_String ( [ 0.2 * g_width , achievement_desc_ypos * g_height , 0 ] , achievements [ active_achievement ] . name , [ 0.015 * g_width , 0.015 * g_width , 0 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
drawpic ( [ 0.005 * g_width , achievement_img_ypos * g_height , 0 ] , achievements [ active_achievement ] . img , [ 0.16 * g_width , 0.08 * g_width , 0 ] , [ 1 , 1 , 1 ] , 1 ) ;
2022-02-08 18:42:28 +00:00
if ( achievement_time < = 120 ) {
achievement_ypos + = ( frametime * 0.15 ) ;
achievement_desc_ypos + = ( frametime * 0.15 ) ;
achievement_img_ypos + = ( frametime * 0.15 ) ;
} else {
achievement_ypos - = ( frametime * 0.15 ) ;
achievement_desc_ypos - = ( frametime * 0.15 ) ;
achievement_img_ypos - = ( frametime * 0.15 ) ;
if ( achievement_desc_ypos < = - 0.13 ) {
achievement_init = 0 ;
active_achievement = - 1 ;
}
}
if ( achievement_desc_ypos > 0.045 ) {
if ( achievement_time < = 120 ) {
achievement_ypos = 0.015 ;
achievement_desc_ypos = 0.045 ;
achievement_img_ypos = 0.01 ;
}
achievement_time + = ( frametime * 25 ) ;
}
}
2024-12-07 08:44:43 +00:00
void ( float x_position , float y_position , string command , string action ) HUD_DrawWaypointModeString =
2022-02-08 18:42:28 +00:00
{
2024-12-07 08:44:43 +00:00
string bind_button = " " ;
string bind_space = " " ;
2022-02-08 18:42:28 +00:00
2024-12-07 08:44:43 +00:00
float argc = tokenize ( findkeysforcommandex ( command ) ) ;
2022-02-08 18:42:28 +00:00
2025-02-08 06:44:49 +00:00
for ( int i = 0 ; i < argc ; i + + ) {
string temp_button = strtoupper ( argv ( i ) ) ;
float bind_is_gamepad = Key_IsControllerGlyph ( temp_button ) ;
2024-12-07 08:44:43 +00:00
2025-02-08 06:44:49 +00:00
// Always display the last button in the last.
if ( bind_is_gamepad & & last_input_was_gamepad )
bind_button = temp_button ;
else if ( ! bind_is_gamepad & & ! last_input_was_gamepad )
bind_button = temp_button ;
}
2024-12-07 08:44:43 +00:00
if ( bind_button = = " " )
bind_button = " UNBOUND " ;
// If this is a gamepad button, the space we want to reserve
// in the usestring should be a fixed width.
if ( Key_IsControllerGlyph ( bind_button ) ) {
bind_space = " " ;
}
// Scale the space in the usestring for the bind according to
// the bind's name.
else {
for ( float i = 0 ; i < strlen ( bind_button ) ; i + + ) {
bind_space = strcat ( bind_space , " " ) ;
}
}
string tooltip = sprintf ( " Press %s to %s " , bind_space , action ) ;
float bind_x = x_position + getTextWidth ( " Press " , 12 ) ;
Draw_String ( [ x_position , y_position ] , tooltip , [ 12 , 12 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
if ( Key_IsControllerGlyph ( bind_button ) ) {
Key_DrawControllerGlyph ( [ bind_x - 5 , y_position ] , bind_button , [ 15 , 15 ] ) ;
} else {
// FTE likes to use MOUSE1 and MOUSE2 for LMOUSE and RMOUSE respectively, which is obtuse.
string bind_display = " " ;
switch ( bind_button ) {
case " MOUSE1 " : bind_display = " LMOUSE " ; break ;
case " MOUSE2 " : bind_display = " RMOUSE " ; break ;
default : bind_display = bind_button ; break ;
}
Draw_String ( [ bind_x , y_position , 0 ] , bind_display , [ 12 , 12 , 0 ] , [ 1 , 1 , 0 ] , 1 , 0 ) ;
}
} ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
void ( ) HUD_Waypoint =
2022-02-08 18:42:28 +00:00
{
2025-01-22 04:03:58 +00:00
drawfill ( [ 0 , 4 ] , [ 450 , 190 ] , [ 0 , 0 , 0 ] , cvar ( " cl_textopacity " ) , 0 ) ;
2024-12-07 08:44:43 +00:00
Draw_String ( [ 5 , 8 ] , " WAYPOINT MODE " , [ 18 , 18 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
Draw_String ( [ 5 , 30 ] , " Create/Tweak Pathfind Nodes for Zombie AI " , [ 12 , 12 ] , [ 1 , 1 , 0 ] , 1 , 0 ) ;
Draw_String ( [ 5 , 45 ] , " (If you don't know what you're doing, you probably shouldn't be here!) " , [ 10 , 10 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
drawfill ( [ 5 , 60 ] , [ 440 , 3 ] , [ 0.3 , 0.3 , 0.3 ] , 1 , 0 ) ;
HUD_DrawWaypointModeString ( 5 , 70 , " +attack " , " Create a Waypoint " ) ;
HUD_DrawWaypointModeString ( 5 , 85 , " +button7 " , " Select a Waypoint " ) ;
HUD_DrawWaypointModeString ( 5 , 100 , " +button8 " , " Link a Waypoint " ) ;
HUD_DrawWaypointModeString ( 5 , 115 , " +button6 " , " Remove a Waypoint " ) ;
HUD_DrawWaypointModeString ( 5 , 130 , " +button4 " , " Move selected Waypoint Here " ) ;
HUD_DrawWaypointModeString ( 5 , 145 , " +button5 " , " Create a (Special) Waypoint " ) ;
HUD_DrawWaypointModeString ( 5 , 160 , " impulse 22 " , " Load Map's Waypoints " ) ;
HUD_DrawWaypointModeString ( 5 , 175 , " impulse 24 " , " Save current Waypoints " ) ;
2022-02-08 18:42:28 +00:00
}
2025-01-22 04:03:58 +00:00
void ( ) HUD_Spectator =
2024-12-08 04:13:54 +00:00
{
2025-01-22 04:03:58 +00:00
drawfill ( [ 0 , 4 ] , [ 250 , 60 ] , [ 0 , 0 , 0 ] , cvar ( " cl_textopacity " ) , 0 ) ;
2024-12-08 04:13:54 +00:00
Draw_String ( [ 5 , 8 ] , " SPECTATING " , [ 18 , 18 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
Draw_String ( [ 5 , 30 ] , " You will spawn next Round " , [ 12 , 12 ] , [ 1 , 1 , 0 ] , 1 , 0 ) ;
Draw_String ( [ 5 , 45 ] , " (Fly around or go grab a snack!) " , [ 10 , 10 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
drawfill ( [ 5 , 60 ] , [ 240 , 3 ] , [ 0.3 , 0.3 , 0.3 ] , 1 , 0 ) ;
}
2025-01-22 04:03:58 +00:00
void ( ) HUD_PlayerNames =
2023-01-13 21:40:00 +00:00
{
for ( float i = 3 ; i > = 0 ; i = i - 1 ) {
2024-12-08 04:13:54 +00:00
float player_number = getplayerkeyfloat ( i , " client_index " ) ;
if ( player_number = = getstatf ( STAT_PLAYERNUM ) )
2023-01-13 21:40:00 +00:00
continue ;
string text = getplayerkeyvalue ( i , " name " ) ;
2024-01-11 15:40:10 +00:00
entity client = findfloat ( world , playernum , player_number ) ;
2024-12-08 04:13:54 +00:00
if ( client = = world | | ! client . classname | | client . is_spectator )
2024-01-11 15:40:10 +00:00
continue ;
// Append "[CHAT] " to the player name if the user is in message mode
if ( client . is_in_menu = = 2 )
text = strcat ( " [CHAT] " , text ) ;
// Similarly, append "[PAUSED] " to the player name if the user is paused
else if ( client . is_in_menu = = 1 )
text = strcat ( " [PAUSED] " , text ) ;
2023-11-12 15:46:49 +00:00
entity plr = findfloat ( world , playernum , player_number ) ;
vector player_origin = plr . origin + ' 0 0 48 ' ;
2023-01-13 21:40:00 +00:00
vector screen_position = project ( player_origin ) ;
vector text_color = ' 1 1 1 ' ;
2023-02-08 21:10:56 +00:00
if ( player_origin = = ' 0 0 48 ' )
continue ;
2024-09-12 02:12:20 +00:00
screen_position_x - = getTextWidth ( text , 8 ) / 2 ;
2023-01-13 21:40:00 +00:00
switch ( i ) {
case 1 : text_color = TEXT_LIGHTBLUE ; break ;
case 2 : text_color = TEXT_ORANGE ; break ;
case 3 : text_color = TEXT_GREEN ; break ;
default : break ;
}
2025-01-22 04:03:58 +00:00
if ( screen_position_z > 0 ) {
HUD_DrawStringWithBackdrop ( screen_position , text , [ 8 , 8 ] , text_color , 1 , 0 ) ;
}
2023-01-13 21:40:00 +00:00
}
}
2025-01-22 04:03:58 +00:00
void ( ) HUD_ReviveIcons =
2023-01-13 22:53:54 +00:00
{
2024-06-25 04:29:49 +00:00
for ( float i = 3 ; i > = 0 ; i = i - 1 ) {
float player_index = i ;
// Don't render our own Icon.
if ( player_index + 1 = = getstatf ( STAT_PLAYERNUM ) )
continue ;
// Player is not in Last Stand.
if ( revive_icons [ player_index ] . state < = 0 )
continue ;
// Player is not being actively revived, so the
// Revive Icon should grow more and more red over time.
if ( revive_icons [ player_index ] . state = = 1 )
revive_icons [ player_index ] . timer + = frametime ;
2024-12-08 04:13:54 +00:00
float player_number = getplayerkeyfloat ( i , " client_index " ) ;
2024-06-25 04:29:49 +00:00
//string text = getplayerkeyvalue(i, "name");
entity client = findfloat ( world , playernum , player_number ) ;
2024-12-08 04:13:54 +00:00
// Client does not exist.
if ( client = = world | | ! client . classname | | client . is_spectator )
2024-06-25 04:29:49 +00:00
continue ;
entity plr = findfloat ( world , playernum , player_number ) ;
vector player_origin = plr . origin + ' 0 0 32 ' ;
vector screen_position = project ( player_origin ) ;
screen_position_x - = ( 32 ) / 2 ;
if ( player_origin = = ' 0 0 32 ' )
continue ;
if ( screen_position_z > 0 ) {
// Client is actively being revived, render white.
if ( revive_icons [ i ] . state = = 2 ) {
drawpic ( screen_position , " gfx/hud/revive_icon.tga " , [ 32 , 32 , 1 ] , [ 1 , 1 , 1 ] , 1 ) ;
}
// Draw with a yellow->red hue.
else {
drawpic ( screen_position , " gfx/hud/revive_icon.tga " , [ 32 , 32 , 1 ] , [ 1 , 1 - ( revive_icons [ i ] . timer / 30 ) , 0 ] , 1 ) ;
2023-01-13 22:53:54 +00:00
}
}
}
}
2025-01-22 04:03:58 +00:00
void ( ) HUD_StopWatch =
2023-08-27 14:15:16 +00:00
{
string sec , min , hr ;
string stopwatch ;
if ( stopwatch_sec < 10 ) {
sec = strcat ( " 0 " , substring ( ftos ( stopwatch_sec ) , 0 , 3 ) ) ;
} else {
sec = substring ( ftos ( stopwatch_sec ) , 0 , 4 ) ;
}
if ( stopwatch_min < 10 ) min = strcat ( " 0 " , ftos ( stopwatch_min ) ) ; else min = ftos ( stopwatch_min ) ;
if ( stopwatch_hr < 10 ) hr = strcat ( " 0 " , ftos ( stopwatch_hr ) ) ; else hr = ftos ( stopwatch_hr ) ;
stopwatch = strcat ( hr , " : " , min , " : " , sec ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ g_width - ( getTextWidth ( stopwatch , 12 ) ) - 2 , 2 ] , stopwatch , [ 12 , 12 ] , TEXT_ORANGE , 1 , 0 ) ;
2023-08-27 14:15:16 +00:00
}
2025-01-22 04:03:58 +00:00
void ( ) HUD_RoundStopWatch =
2023-12-24 16:18:38 +00:00
{
string sec , min , hr ;
string stopwatch ;
if ( stopwatch_round_sec < 10 ) {
sec = strcat ( " 0 " , substring ( ftos ( stopwatch_round_sec ) , 0 , 3 ) ) ;
} else {
sec = substring ( ftos ( stopwatch_round_sec ) , 0 , 4 ) ;
}
if ( sec = = " 00 " ) sec = " 00.0 " ;
if ( stopwatch_round_min < 10 ) min = strcat ( " 0 " , ftos ( stopwatch_round_min ) ) ; else min = ftos ( stopwatch_round_min ) ;
if ( stopwatch_round_hr < 10 ) hr = strcat ( " 0 " , ftos ( stopwatch_round_hr ) ) ; else hr = ftos ( stopwatch_round_hr ) ;
stopwatch = strcat ( hr , " : " , min , " : " , sec ) ;
2025-01-22 04:03:58 +00:00
HUD_DrawStringWithBackdrop ( [ g_width - ( getTextWidth ( stopwatch , 12 ) ) - 2 , 16 ] , stopwatch , [ 12 , 12 ] , [ 1 , 1 , 1 ] , 1 , 0 ) ;
2023-12-24 16:18:38 +00:00
}
2024-12-07 18:19:11 +00:00
/*******************
2024-12-08 14:24:56 +00:00
* HUD Debug Info *
2024-12-07 18:19:11 +00:00
* * * * * * * * * * * * * * * * * * */
2024-12-08 14:24:56 +00:00
// set from CSQC_Ent_Update
vector player_velocity ;
2025-01-22 04:03:58 +00:00
void ( ) HUD_PlayerDebugInfo =
2024-12-07 18:19:11 +00:00
{
static float lastupstime ;
static float lastups ;
2024-12-08 14:24:56 +00:00
if ( ! cvar ( " scr_playerdebuginfo " ) )
2024-12-07 18:19:11 +00:00
return ;
if ( ( time - lastupstime ) > = 1.0 / 20 )
{
2024-12-08 14:24:56 +00:00
lastups = vlen ( player_velocity ) ;
2024-12-07 18:19:11 +00:00
lastupstime = time ;
}
2024-12-08 14:24:56 +00:00
vector pos = [ cvar ( " scr_playerdebuginfo_x " ) , cvar ( " scr_playerdebuginfo_y " ) ] ;
2024-12-09 02:13:37 +00:00
pos . x + = GetUltraWideOffset ( ) ;
2024-12-10 01:50:04 +00:00
2024-12-10 02:15:47 +00:00
drawfill ( pos - [ 8 , 8 ] , [ 128 , 192 ] , [ 0 , 0 , 0 ] , 0.75 , 0 ) ;
2024-12-10 02:36:28 +00:00
Draw_FancyFloat ( pos , " Speed: " , lastups , " qu/s " ) ;
2024-12-08 14:24:56 +00:00
if ( cvar ( " scr_playerdebuginfo " ) > = 2 )
{
2024-12-10 02:36:28 +00:00
Draw_FancyVector ( pos + [ 0 , 36 ] , " Angles: " , getproperty ( VF_ANGLES ) ) ;
Draw_FancyVector ( pos + [ 0 , 106 ] , " Origin: " , getproperty ( VF_ORIGIN ) ) ;
2024-12-08 14:24:56 +00:00
}
2024-12-07 18:19:11 +00:00
} ;
2025-01-22 04:03:58 +00:00
//
// HUD_DrawElementsForEndGame()
// Heads-Up Display draw logic for when the server
// is in its "GAME OVER" state.
//
void ( ) HUD_DrawElementsForEndGame =
{
// Draws our "GAME OVER" text.
HUD_Endgame ( ) ;
// Draws the scoreboard.
HUD_Scores ( ) ;
} ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
//
// HUD_DrawElementsForSpectator()
// Heads-Up Display draw logic for Spectators.
//
void ( ) HUD_DrawElementsForSpectator =
2022-02-08 18:42:28 +00:00
{
2025-01-22 04:03:58 +00:00
// If the scoreboard is open, only draw it and nothing else.
if ( score_show ) {
HUD_Scores ( ) ;
2022-02-08 18:42:28 +00:00
return ;
2025-01-22 04:03:58 +00:00
}
2024-12-08 04:13:54 +00:00
2025-01-22 04:03:58 +00:00
// Networked names for all players.
HUD_PlayerNames ( ) ;
// Draws the current round.
HUD_Rounds ( ) ;
// Draws all player's points.
HUD_Points ( ) ;
// Draws Power-Up status.
HUD_Powerups ( ) ;
HUD_MaxAmmo ( ) ;
// "You are Spectating" message.
HUD_Spectator ( ) ;
} ;
//
// HUD_DrawElementsForWaypointMode()
// Heads-Up Display draw logic when in Waypoint Mode.
//
void ( ) HUD_DrawElementsForWaypointMode =
{
// Waypoint Mode tutorial.
HUD_Waypoint ( ) ;
//
// Everything below should be debug or cvar-related.
//
// Player origin, angles, etc. for debugging if cvar is enabled.
HUD_PlayerDebugInfo ( ) ;
} ;
//
// HUD_DrawElementsForPlayer()
// Heads-Up Display draw logic during normal play.
//
void ( ) HUD_DrawElementsForPlayer =
{
// We shouldn't draw anything during the game intro fade.
if ( screenflash_color = = SCREENFLASH_COLOR_BLACK & & screenflash_duration > time ) {
HUD_Screenflash ( ) ;
2024-12-08 04:13:54 +00:00
return ;
}
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
// Blood filter on screen to indicate health.
HUD_Health ( ) ;
// Networked names for all players.
HUD_PlayerNames ( ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
// If the scoreboard is open, only draw it and nothing else.
if ( score_show ) {
HUD_Scores ( ) ;
return ;
}
// Additionally, bail here if cl_cinematic is set.
else if ( cvar ( " cl_cinematic " ) ) {
return ;
}
2023-10-28 16:09:57 +00:00
2025-01-22 04:03:58 +00:00
// Crosshair for Player weapons.
HUD_Crosshair ( ) ;
2023-11-22 03:35:25 +00:00
2025-01-22 04:03:58 +00:00
// Being scoped-in hides all low-priority elements.
if ( getstatf ( STAT_WEAPONZOOM ) ! = 2 | | zoom_2_time > = time ) {
// "Low Ammo", "No Ammo", etc.
HUD_AmmoString ( ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
// Draws all player's points.
HUD_Points ( ) ;
2022-02-08 18:42:28 +00:00
2025-01-22 04:03:58 +00:00
// Draws the current player's character name.
HUD_CharacterName ( ) ;
2023-01-13 22:53:54 +00:00
2025-01-22 04:03:58 +00:00
// Draws the current player's Perk-A-Cola loadout.
HUD_Perks ( ) ;
2023-08-27 14:15:16 +00:00
2025-01-22 04:03:58 +00:00
// Draws Power-Up status.
HUD_Powerups ( ) ;
HUD_MaxAmmo ( ) ;
// Draws the current round.
HUD_Rounds ( ) ;
// Draw the player's Bouncing Betties and Grenades.
HUD_Grenades ( ) ;
// Draws the player's magazine and reserve count.
HUD_Ammo ( ) ;
// Draws the name of the player's active weapon.
HUD_WeaponString ( ) ;
// "Hold F to use" triggered strings.
HUD_Useprint ( ) ;
// Bouncing Betty tutorial.
HUD_BouncingBetty ( ) ;
// Revive status progress bar.
HUD_Progressbar ( ) ;
2022-02-08 18:42:28 +00:00
}
2024-01-13 15:39:11 +00:00
2025-01-22 04:03:58 +00:00
// Visual hit Feedback.
HUD_Hitmark ( ) ;
2024-12-07 18:19:11 +00:00
2025-01-22 04:03:58 +00:00
// Black/White/etc. total screen flashes.
HUD_Screenflash ( ) ;
//
// Everything below should always have maximum priority.
//
// Revive indicator for Players in Last Stand.
HUD_ReviveIcons ( ) ;
// "X" needs to be revived, or other important messages.
HUD_Broadcast ( ) ;
//
// Everything below should be debug or cvar-related.
//
// Total gametime stopwatch for Speedruns.
if ( cvar ( " scr_serverstopwatch " ) ) {
HUD_StopWatch ( ) ;
}
// Active round stopwatch for Speedruns.
if ( cvar ( " scr_serverstopwatch " ) > = 2 ) {
HUD_RoundStopWatch ( ) ;
}
// Player origin, angles, etc. for debugging if cvar is enabled.
HUD_PlayerDebugInfo ( ) ;
} ;
//
// HUD_DrawElements(width, height)
// Redirects to Heads-Up Display draw lists depending on
// client and game state.
//
void ( ) HUD_DrawElements =
{
//
// Game Over Sequence
//
if ( in_endgame_sequence ) {
HUD_DrawElementsForEndGame ( ) ;
return ;
}
//
// Spectator Mode
//
if ( getstatf ( STAT_SPECTATING ) ) {
HUD_DrawElementsForSpectator ( ) ;
return ;
}
//
// Waypoint Mode
//
if ( cvar ( " waypoint_mode " ) ) {
HUD_DrawElementsForWaypointMode ( ) ;
return ;
}
//
// Standard Play
//
HUD_DrawElementsForPlayer ( ) ;
} ;