103 bool spectating = entcs_GetSpecState(strafeplayer.sv_entnum) == ENTCS_SPEC_PURE;
105 float maxspeed_crouch_mod =
IS_DUCKED(strafeplayer) && !swimming ? .5 : 1;
106 float maxspeed_water_mod = swimming ? .7 : 1;
109 float vel_angle =
vectoangles(strafeplayer.velocity).y;
110 float view_angle = PHYS_INPUT_ANGLES(strafeplayer).y + 180;
113 int keys = STAT(PRESSED_KEYS);
125 float shift_offset = 0;
126 bool straight_overturn =
false;
127 bool immobile = speed <= (swimming ? antiflicker_speed : 0);
129 float neutral_offset;
132 float currentangle_offset;
133 vector currentangle_size =
'0 0 0';
136 bool bestangle_anywhere =
false;
137 float bestangle_offset;
138 float switch_bestangle_offset;
139 bool odd_angles =
false;
140 float odd_bestangle_offset = 0;
141 float switch_odd_bestangle_offset = 0;
142 float bestangle_width;
143 float accelzone_left_offset;
144 float accelzone_right_offset;
145 float accelzone_width;
146 float overturn_offset;
147 float overturn_width;
148 float slickdetector_height;
149 vector direction_size_vertical =
'0 0 0';
150 vector direction_size_horizontal =
'0 0 0';
151 float range_minangle;
160 else if(movement.x < 0)
171 if((keys & KEY_FORWARD) && !(keys & KEY_BACKWARD))
175 else if(!(keys & KEY_FORWARD) && (keys & KEY_BACKWARD))
194 else if(movement.y > 0)
211 wishangle =
RAD2DEG * atan2(movement.y, movement.x);
213 if(
fabs(wishangle) > 90)
215 if(wishangle < 0) wishangle += 180;
216 else wishangle -= 180;
217 wishangle = -wishangle;
224 if(keys & KEY_FORWARD || keys & KEY_BACKWARD)
236 else if(!(keys & KEY_RIGHT))
242 strafekeys =
fabs(wishangle) == 90;
245 range_minangle =
fabs(wishangle) % 90;
246 if(range_minangle > 45)
248 range_minangle = 45 -
fabs(wishangle) % 45;
250 range_minangle = 90 - range_minangle;
261 hudangle = range_minangle;
322 angle = vel_angle - view_angle;
325 if (angle > 180) angle -= 360;
326 else if(angle < -180) angle += 360;
329 if(angle < 0) angle += 180;
340 else if(keys_fwd < 0)
376 if(angle < 0) angle += 180;
381 if(angle > (180 - antiflicker_angle) || angle < (-180 + antiflicker_angle))
383 straight_overturn =
true;
410 wishangle = -wishangle;
417 wishangle = -wishangle;
427 direction = (angle > antiflicker_angle && angle < (180 - antiflicker_angle)) ? 1 : (angle < -antiflicker_angle && angle > (-180 + antiflicker_angle)) ? -1 : 0;
431 bestangle = (speed > maxspeed ? acos(maxspeed / speed) : 0) *
RAD2DEG * (
direction < 0 ? -1 : 1);
432 odd_bestangle = -bestangle - wishangle;
433 bestangle -= wishangle;
442 currentangle_offset = angle/hudangle *
panel_size.x;
454 if(((angle > -wishangle &&
direction < 0) || (angle < -wishangle && direction > 0)) && (
direction != 0))
458 switch_odd_bestangle_offset = (odd_bestangle+bestangle*2)/hudangle *
panel_size.x +
panel_size.x/2;
464 direction_size_horizontal.y = direction_size_vertical.x;
489 accelzone_width = overturn_offset = (90 -
fabs(bestangle + wishangle))/hudangle *
panel_size.x;
490 accelzone_right_offset = 0;
491 accelzone_left_offset = overturn_offset + overturn_width;
492 neutral_width = 360/hudangle *
panel_size.x - accelzone_width*2 - overturn_width;
493 neutral_offset =
direction < 0 ? accelzone_left_offset + accelzone_width : -neutral_width;
498 bestangle_offset -= bestangle_width;
499 switch_odd_bestangle_offset -= bestangle_width;
503 switch_bestangle_offset -= bestangle_width;
504 odd_bestangle_offset -= bestangle_width;
510 shift_offset = -currentangle_offset;
511 bestangle_offset += shift_offset;
512 switch_bestangle_offset += shift_offset;
513 odd_bestangle_offset += shift_offset;
514 switch_odd_bestangle_offset += shift_offset;
520 neutral_offset += shift_offset;
521 accelzone_left_offset += shift_offset;
522 accelzone_right_offset += shift_offset;
523 overturn_offset += shift_offset;
539 bool indicator_direction =
direction < 0;
542 if(!
fwd != odd_angles)
544 indicator_direction = !indicator_direction;
555 if(speed >= minspeed)
558 float offset = !odd_angles ? bestangle_offset : odd_bestangle_offset;
559 float switch_offset = !odd_angles ? switch_bestangle_offset : switch_odd_bestangle_offset;
574 bool slickdetected =
false;
580 for(
float i = 0; i < 360 && !slickdetected; i += slicksteps)
586 if(i != 0 && i != 180)
588 for(
float j = 0; j < 180 && !slickdetected; j += slicksteps)
590 slickoffset.x =
sin(j * DEG2RAD) * slickrotate;
591 slickoffset.y =
cos(j * DEG2RAD) * slickrotate;
593 traceline(strafeplayer.origin, strafeplayer.origin + slickoffset,
MOVE_WORLDONLY,
NULL);
599 slickoffset.x = slickoffset.y = 0;
600 traceline(strafeplayer.origin, strafeplayer.origin + slickoffset,
MOVE_WORLDONLY,
NULL);
609 slickdetector_size.y = slickdetector_height;
621 float text_alpha = 0;
655 static float height_min = 0, height_max = 0;
656 static float jumpheight = 0, jumptime = 0;
659 if((strafeplayer.velocity.z <= 0 && height_max >= strafeplayer.origin.z) || IS_ONGROUND(strafeplayer) || swimming ||
IS_DEAD(strafeplayer) || spectating)
661 height_min = height_max = strafeplayer.origin.z;
663 else if(strafeplayer.origin.z > height_max)
665 height_max = strafeplayer.origin.z;
666 jumpheight = (height_max - height_min) * length_conversion_factor;
683 if(speed < (maxspeed + antiflicker_speed) && !immobile)
685 bestangle_anywhere =
true;
689 if(!bestangle_anywhere && !immobile)
691 if((
direction > 0 && (angle >= bestangle || angle <= -(bestangle + wishangle*2))) ||
692 (
direction < 0 && (angle <= bestangle || angle >= -(bestangle + wishangle*2))))
696 if(
fabs(angle + wishangle) > 90)
700 else if(bestangle_anywhere)
705 if(mode == 0 || straight_overturn)
712 float moveangle = angle + wishangle;
713 float strafeangle = (bestangle + wishangle) * (
direction < 0 ? -1 : 1);
714 float strafe_ratio = 0;
715 if(
fabs(moveangle) > 90)
717 strafe_ratio = -((
fabs(moveangle) - 90) / 90);
718 if(strafe_ratio < -1) strafe_ratio = -2 - strafe_ratio;
722 if(moveangle >= strafeangle)
724 strafe_ratio = 1 - (moveangle - strafeangle) / (90 - strafeangle);
726 else if(moveangle <= -strafeangle)
728 strafe_ratio = 1 - (moveangle + strafeangle) / (-90 + strafeangle);
751 float mirror_offset, mirror_width;
755 float original_width = width;
756 float hiddencolor_width;
758 if(alpha <= 0 && type != 2 || width <= 0)
return;
760 if(type == 2 && gradientType == 0) type = 0;
764 mirror_width =
min(
fabs(offset), width);
778 if(mirror_offset < 0)
780 mirror_width += mirror_offset;
783 if((mirror_offset + mirror_width) >
panel_size.x)
788 if(width < 0) width = 0;
789 if(mirror_width < 0) mirror_width = 0;
790 hiddencolor_width = original_width - width - mirror_width;
794 offset += mirror_offset;
795 mirror_offset = offset - mirror_offset;
796 offset -= mirror_offset;
798 width += mirror_width;
799 mirror_width = width - mirror_width;
800 width -= mirror_width;
804 mirror_size.x = mirror_width;
828 if(ratio <= 0)
return color1;
829 if(ratio >= 1)
return color2;
830 mixedColor.x = color1.x + (color2.x - color1.x) * ratio;
831 mixedColor.y = color1.y + (color2.y - color1.y) * ratio;
832 mixedColor.z = color1.z + (color2.z - color1.z) * ratio;
838 float color_ratio, alpha1, alpha2;
840 alpha1 =
bound(0, alpha, 1);
842 if((alpha1+alpha2) == 0)
return;
843 color_ratio = alpha1/(alpha1+alpha2);
844 for(
int i = 0; i < size.x; ++i)
846 float ratio, alpha_ratio, combine_ratio1, combine_ratio2;
847 gradient_size.x = size.x - i < 1 ? size.x - i : 1;
848 ratio = (i + gradientOffset) / original_width * (gradientType == 3 ? 2 : 1);
849 if(ratio > 1) ratio = 2 - ratio;
850 if(gradientType != 2) ratio = 1 - ratio;
851 alpha_ratio = alpha1 - (alpha1 - alpha2) * ratio;
852 combine_ratio1 = ratio*(1-color_ratio);
853 combine_ratio2 = (1-ratio)*color_ratio;
854 ratio = (combine_ratio1 + combine_ratio2) == 0 ? 1 : combine_ratio1/(combine_ratio1 + combine_ratio2);
866 case 2:
return 0.0254;
867 case 3:
return 0.0254 * 0.001;
868 case 4:
return 0.0254 * 0.001 * 0.6213711922;
869 case 5:
return 0.0254 * 0.001 * 0.5399568035;
879 case 1:
return strcat(
" ", _(
"qu"));
880 case 2:
return strcat(
" ", _(
"m"));
881 case 3:
return strcat(
" ", _(
"km"));
882 case 4:
return strcat(
" ", _(
"mi"));
883 case 5:
return strcat(
" ", _(
"nmi"));
float autocvar_hud_panel_strafehud_switch_inactive_alpha
float autocvar_hud_panel_strafehud_direction_alpha
float autocvar_hud_panel_strafehud_bar_accel_alpha
float autocvar_hud_panel_strafehud_switch_minspeed
noref string autocvar_hud_panel_strafehud_bg
#define draw_endBoldFont()
#define PHYS_MAXAIRSPEED(s)
ERASEABLE string ftos_decimals(float number, int decimals)
converts a number to a string with the indicated number of decimals
float autocvar_hud_panel_strafehud_timeout_turn
float autocvar_hud_panel_strafehud_slickdetector_alpha
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
string GetLengthUnit(int length_unit)
entity CSQCModel_server2csqc(int i)
float state_onground_time
float trace_dphitq3surfaceflags
float autocvar_hud_panel_strafehud_angle_width
float autocvar_hud_panel_strafehud_angle_height
int autocvar_hud_panel_strafehud_style
bool autocvar__hud_configure
#define draw_beginBoldFont()
float autocvar_hud_panel_strafehud_jumpheight_size
vector autocvar_hud_panel_strafehud_switch_inactive_color
vector autocvar_hud_panel_strafehud_slickdetector_color
vector autocvar_hud_panel_strafehud_angle_accel_color
vector autocvar_hud_panel_strafehud_startspeed_color
bool autocvar_hud_panel_strafehud_dynamichud
float autocvar_hud_panel_strafehud_antiflicker_angle
float Q3SURFACEFLAG_SLICK
float autocvar_hud_panel_strafehud_range
bool autocvar__hud_panel_strafehud_demo
float GetLengthUnitFactor(int length_unit)
void HUD_Panel_DrawStrafeHUD(float offset, float width, vector color, float alpha, int type, int gradientType)
float autocvar_hud_panel_strafehud_startspeed_size
float autocvar_hud_panel_strafehud_switch_width
float autocvar_hud_panel_strafehud_bar_neutral_alpha
#define HUD_Panel_DrawBg()
float GetSpeedUnitFactor(int speed_unit)
float autocvar_hud_panel_strafehud_jumpheight_fade
float autocvar_hud_panel_strafehud_direction_width
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector autocvar_hud_panel_strafehud_jumpheight_color
float autocvar_hud_panel_strafehud_timeout_direction
float autocvar_hud_panel_strafehud_slickdetector_height
const float DRAWFLAG_NORMAL
noref string autocvar_hud_panel_strafehud_bg_alpha
void StrafeHUD_drawGradient(vector color1, vector color2, vector size, float original_width, float offset, float alpha, float gradientOffset, int gradientType)
float autocvar_hud_panel_strafehud_jumpheight_min
vector(float skel, float bonenum) _skel_get_boneabs_hidden
noref string autocvar_hud_panel_strafehud_size
int autocvar_hud_panel_strafehud
float autocvar_hud_panel_strafehud_slickdetector_range
float race_checkpointtime
noref string autocvar_hud_panel_strafehud_pos
void HUD_StrafeHUD_Export(int fh)
float autocvar_hud_panel_strafehud_timeout_ground
vector StrafeHUD_mixColors(vector color1, vector color2, float ratio)
const int ANIMIMPLICITSTATE_INAIR
vector autocvar_hud_panel_strafehud_bar_overturn_color
string GetSpeedUnit(int speed_unit)
const int WATERLEVEL_SWIMMING
float autocvar_hud_panel_strafehud_direction_length
#define MUTATOR_CALLHOOK(id,...)
#define PHYS_MAXAIRSTRAFESPEED(s)
float autocvar_hud_panel_strafehud_angle_alpha
float autocvar_hud_panel_strafehud_switch_active_alpha
noref string autocvar_hud_panel_strafehud_bg_padding
float autocvar_hud_panel_strafehud_bar_overturn_alpha
vector autocvar_hud_panel_strafehud_angle_neutral_color
vector autocvar_hud_panel_strafehud_bar_neutral_color
noref string autocvar_hud_panel_strafehud_bg_border
float autocvar_hud_panel_strafehud_antiflicker_speed
vector autocvar_hud_panel_strafehud_direction_color
int autocvar_hud_panel_strafehud_mode
float state_strafekeys_time
vector autocvar_hud_panel_strafehud_switch_active_color
noref string autocvar_hud_panel_strafehud_bg_color
vector autocvar_hud_panel_strafehud_angle_overturn_color
Header file that describes the resource system.
bool autocvar_hud_panel_strafehud_unit_show
int autocvar_hud_panel_strafehud_unit
float autocvar_hud_panel_strafehud_startspeed_fade
noref string autocvar_hud_panel_strafehud_bg_color_team
void HUD_Panel_LoadCvars()
vector autocvar_hud_panel_strafehud_bar_accel_color
int autocvar_hud_panel_strafehud_slickdetector_granularity
float autocvar_hud_panel_strafehud_timeout_air