1 #include "crosshair.qh"
3 #include <client/draw.qh>
4 #include <client/hud/panel/scoreboard.qh>
5 #include <client/view.qh>
6 #include <common/deathtypes/all.qh>
7 #include <common/ent_cs.qh>
8 #include <common/mapobjects/trigger/viewloc.qh>
9 #include <common/minigames/cl_minigames.qh>
10 #include <common/minigames/cl_minigames_hud.qh>
11 #include <common/mutators/mutator/overkill/oknex.qh>
12 #include <common/vehicles/all.qh>
13 #include <common/viewloc.qh>
14 #include <common/wepent.qh>
15 #include <lib/csqcmodel/cl_player.qh>
16 #include <lib/warpzone/common.qh>
18 float pickup_crosshair_time, pickup_crosshair_size;
19 float hitindication_crosshair_size;
20 float use_vortex_chargepool;
25 float wcross_scale_prev, wcross_alpha_prev;
26 vector wcross_color_prev;
27 float wcross_scale_goal_prev, wcross_alpha_goal_prev;
28 vector wcross_color_goal_prev;
29 float wcross_changedonetime;
31 string wcross_name_goal_prev, wcross_name_goal_prev_prev;
32 float wcross_resolution_goal_prev, wcross_resolution_goal_prev_prev;
33 float wcross_name_changestarttime, wcross_name_changedonetime;
34 float wcross_name_alpha_goal_prev, wcross_name_alpha_goal_prev_prev;
36 float wcross_ring_prev;
41 const float SHOTTYPE_HITTEAM = 1;
42 const float SHOTTYPE_HITOBSTRUCTION = 2;
43 const float SHOTTYPE_HITWORLD = 3;
44 const float SHOTTYPE_HITENEMY = 4;
48 (trueaim = new_pure(trueaim)).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
49 (trueaim_rifle = new_pure(trueaim_rifle)).dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
55 wcross_origin = project_3d_to_2d(trace_endpos);
60 n = trace_networkentity;
62 return SHOTTYPE_HITWORLD;
64 return SHOTTYPE_HITWORLD;
65 t = entcs_GetTeam(n - 1);
68 return SHOTTYPE_HITTEAM;
69 if(t == NUM_SPECTATOR)
70 return SHOTTYPE_HITWORLD;
71 return SHOTTYPE_HITENEMY;
74 float TrueAimCheck(entity wepent)
76 if(wepent.activeweapon.spawnflags & WEP_FLAG_NOTRUEAIM)
77 return SHOTTYPE_HITWORLD;
79 float nudge = 1; // added to traceline target and subtracted from result TOOD(divVerent): do we still need this? Doesn't the engine do this now for us?
80 vector vecs, trueaimpoint, w_shotorg;
90 switch(wepent.activeweapon) // WEAPONTODO
93 case WEP_OVERKILL_NEX:
100 if(zoomscript_caught)
102 tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * max_shot_distance, mv, ta);
103 return EnemyHitCheck();
106 case WEP_DEVASTATOR: // projectile has a size!
110 case WEP_FIREBALL: // projectile has a size!
114 case WEP_SEEKER: // projectile has a size!
118 case WEP_ELECTRO: // projectile has a size!
124 vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * STAT(VIEWHEIGHT));
126 vecs = decompressShotOrigin(STAT(SHOTORG));
128 traceline(traceorigin, traceorigin + view_forward * max_shot_distance, mv, ta);
129 trueaimpoint = trace_endpos;
130 // move trueaimpoint a little bit forward to make the final tracebox reliable
131 // since it sometimes doesn't reach a teammate by a hair
132 trueaimpoint += view_forward;
134 if(vdist((trueaimpoint - traceorigin), <, g_trueaim_minrange))
135 trueaimpoint = traceorigin + view_forward * g_trueaim_minrange;
142 dv = view_right * vecs.y + view_up * vecs.z;
143 w_shotorg = traceorigin + dv;
145 // now move the vecs forward as much as requested if possible
146 tracebox(w_shotorg, mi, ma, w_shotorg + view_forward * (vecs.x + nudge), MOVE_NORMAL, ta); // FIXME this MOVE_NORMAL part will misbehave a little in csqc
147 w_shotorg = trace_endpos - view_forward * nudge;
149 tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NORMAL, ta);
150 shottype = EnemyHitCheck();
151 if(shottype != SHOTTYPE_HITWORLD)
155 // FIXME WHY DOES THIS NOT WORK FOR THE ROCKET LAUNCHER?
156 // or rather, I know why, but see no fix
157 if(vlen(trace_endpos - trueaimpoint) > vlen(ma) + vlen(mi) + 1)
158 // yes, this is an ugly hack... but it seems good enough to find out whether the test hits the same place as the initial trace
159 return SHOTTYPE_HITOBSTRUCTION;
162 return SHOTTYPE_HITWORLD;
165 void HUD_Crosshair_Vehicle(entity this)
167 if(hud != HUD_BUMBLEBEE_GUN)
169 Vehicle info = REGISTRY_GET(Vehicles, hud);
170 info.vr_crosshair(info, this);
174 vector crosshair_getcolor(entity this, float health_stat)
176 static float rainbow_last_flicker;
177 static vector rainbow_prev_color;
178 vector wcross_color = '0 0 0';
179 switch(autocvar_crosshair_color_special)
181 case 1: // weapon color
183 if(this != WEP_Null && hud == HUD_NORMAL)
185 wcross_color = this.wpcolor;
188 else { goto normalcolor; }
191 case 2: // color based on health and armor
193 vector v = healtharmor_maxdamage(health_stat, STAT(ARMOR), armorblockpercent, DEATH_WEAPON.m_id);
194 float health_and_armor = floor(v.x + 1);
195 wcross_color = HUD_Get_Num_Color(health_and_armor, 200, false);
199 case 3: // rainbow/random color
201 if(time >= rainbow_last_flicker)
203 rainbow_prev_color = randomvec() * autocvar_crosshair_color_special_rainbow_brightness;
204 rainbow_last_flicker = time + autocvar_crosshair_color_special_rainbow_delay;
206 wcross_color = rainbow_prev_color;
210 default: { wcross_color = stov(autocvar_crosshair_color); break; }
217 void HUD_Crosshair_ApplyPlayerAlpha(float new_alpha)
219 csqcplayer.alpha = new_alpha;
220 FOREACH_ENTITY_CLASS("ENT_CLIENT_MODEL", it.tag_entity == csqcplayer,
222 it.alpha = new_alpha;
226 void HUD_Crosshair(entity this)
228 // reset player's alpha here upon death since forced scoreboard prevents running the crosshair_chase code
229 if(autocvar_chase_active > 0 && autocvar_crosshair_chase && STAT(HEALTH) <= 0 && csqcplayer)
230 csqcplayer.alpha = csqcplayer.m_alpha;
232 if (autocvar_chase_active > 0 && (autocvar_chase_front || autocvar_cl_lockview))
234 if (csqcplayer.alpha != csqcplayer.m_alpha)
235 HUD_Crosshair_ApplyPlayerAlpha(csqcplayer.m_alpha);
241 if(!scoreboard_active && !camera_active && intermission != 2 && !STAT(GAME_STOPPED) && !autocvar_cl_lockview
242 && spectatee_status != -1 && (!csqcplayer.viewloc || (!spectatee_status && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM))) && !MUTATOR_CALLHOOK(DrawCrosshair)
243 && !HUD_MinigameMenu_IsOpened())
245 if (!autocvar_crosshair_enabled) // main toggle for crosshair rendering
248 if (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2)
251 if (hud != HUD_NORMAL)
253 HUD_Crosshair_Vehicle(this);
258 float wcross_alpha, wcross_resolution;
259 wcross_style = autocvar_crosshair;
260 if (csqcplayer.viewloc && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM) && autocvar_crosshair_2d != "")
261 wcross_style = autocvar_crosshair_2d;
262 if (wcross_style == "0")
264 wcross_resolution = autocvar_crosshair_size;
265 if (wcross_resolution == 0)
267 wcross_alpha = autocvar_crosshair_alpha;
268 if (wcross_alpha == 0)
274 static int crosshair_chase_state = 0;
276 // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
277 if(csqcplayer.viewloc && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM))
278 wcross_origin = viewloc_mousepos;
279 else if(autocvar_chase_active > 0 && autocvar_crosshair_chase)
281 vector player_org = ((csqcplayer) ? csqcplayer.origin + csqcplayer.view_ofs : view_origin);
282 float my_alpha = (!csqcplayer.m_alpha) ? 1 : csqcplayer.m_alpha;
283 float chase_playeralpha = bound(0.001, autocvar_crosshair_chase_playeralpha, 1);
284 if(csqcplayer && chase_playeralpha < 1 && my_alpha > chase_playeralpha)
286 crosshair_chase_state = 2;
288 if (pointinsidebox(view_origin, csqcplayer.absmin, csqcplayer.absmax))
292 WarpZone_TraceLine(view_origin, view_origin + max_shot_distance * view_forward, MOVE_NORMAL, NULL);
293 if(trace_ent == csqcplayer)
296 float prev_alpha = csqcplayer.alpha;
299 new_alpha = max(csqcplayer.alpha - frametime * 5, chase_playeralpha);
301 new_alpha = min(csqcplayer.alpha + frametime * 5, my_alpha);
303 if (new_alpha != prev_alpha)
304 HUD_Crosshair_ApplyPlayerAlpha(new_alpha);
306 traceline(player_org, player_org + max_shot_distance * view_forward, MOVE_WORLDONLY, NULL);
307 wcross_origin = project_3d_to_2d(trace_endpos);
310 wcross_origin = project_3d_to_2d(view_origin + max_shot_distance * view_forward);
312 if (crosshair_chase_state == 2) // enabled (this frame)
313 crosshair_chase_state = 1;
314 else if (crosshair_chase_state == 1) // turned off in the previous frame
316 // reset player alpha only in this frame
318 HUD_Crosshair_ApplyPlayerAlpha(csqcplayer.m_alpha);
319 crosshair_chase_state = 0; // turned off and alpha reset
322 if(autocvar_crosshair_hittest)
324 vector wcross_oldorigin;
325 entity thiswep = viewmodels[0]; // TODO: unhardcode
326 wcross_oldorigin = wcross_origin;
327 shottype = TrueAimCheck(thiswep);
328 if(shottype == SHOTTYPE_HITWORLD)
330 v = wcross_origin - wcross_oldorigin;
332 v.y /= vid_conheight;
333 if(vdist(v, >, 0.01))
334 shottype = SHOTTYPE_HITOBSTRUCTION;
336 if(!autocvar_crosshair_hittest_showimpact)
337 wcross_origin = wcross_oldorigin;
340 shottype = SHOTTYPE_HITWORLD;
342 vector wcross_color = '0 0 0', wcross_size = '0 0 0';
343 string wcross_name = "";
344 float wcross_scale, wcross_blur;
347 if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
349 entity wepent = viewmodels[0]; // TODO: unhardcode
350 e = wepent.switchingweapon;
353 if(autocvar_crosshair_per_weapon)
355 // WEAPONTODO: access these through some general settings (with non-balance config settings)
356 //wcross_resolution *= cvar(strcat("crosshair_", wcross_wep, "_size"));
357 //if (wcross_resolution == 0)
360 //wcross_style = cvar_string(strcat("crosshair_", wcross_wep));
361 wcross_resolution *= e.w_crosshair_size;
362 wcross_name = e.w_crosshair;
367 if(wcross_name == "")
368 wcross_name = strcat("gfx/crosshair", wcross_style);
370 // MAIN CROSSHAIR COLOR DECISION
371 wcross_color = crosshair_getcolor(e, STAT(HEALTH));
373 if(autocvar_crosshair_effect_scalefade)
375 wcross_scale = wcross_resolution;
376 wcross_resolution = 1;
383 if(autocvar_crosshair_pickup)
385 float stat_pickup_time = STAT(LAST_PICKUP);
387 if(pickup_crosshair_time < stat_pickup_time)
389 if(time - stat_pickup_time < 5) // don't trigger the animation if it's too old
390 pickup_crosshair_size = 1;
392 pickup_crosshair_time = stat_pickup_time;
395 if(pickup_crosshair_size > 0)
396 pickup_crosshair_size -= autocvar_crosshair_pickup_speed * frametime;
398 pickup_crosshair_size = 0;
400 wcross_scale += sin(pickup_crosshair_size) * autocvar_crosshair_pickup;
403 // todo: make crosshair hit indication dependent on damage dealt
404 if(autocvar_crosshair_hitindication)
406 vector col = ((autocvar_crosshair_color_special == 1) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color));
408 if(unaccounted_damage)
410 hitindication_crosshair_size = 1;
413 if(hitindication_crosshair_size > 0)
414 hitindication_crosshair_size -= autocvar_crosshair_hitindication_speed * frametime;
416 hitindication_crosshair_size = 0;
418 wcross_scale += sin(hitindication_crosshair_size) * autocvar_crosshair_hitindication;
419 wcross_color.x += sin(hitindication_crosshair_size) * col.x;
420 wcross_color.y += sin(hitindication_crosshair_size) * col.y;
421 wcross_color.z += sin(hitindication_crosshair_size) * col.z;
424 // no effects needed for targeting enemies, this can't possibly span all valid targets!
425 // just show for teammates to give a sign that they're an invalid target
426 //if(shottype == SHOTTYPE_HITENEMY)
427 //wcross_scale *= autocvar_crosshair_hittest; // is not queried if hittest is 0
428 if(shottype == SHOTTYPE_HITTEAM)
429 wcross_scale /= autocvar_crosshair_hittest; // is not queried if hittest is 0
431 f = fabs(autocvar_crosshair_effect_time);
432 if(wcross_scale != wcross_scale_goal_prev || wcross_alpha != wcross_alpha_goal_prev || wcross_color != wcross_color_goal_prev)
434 wcross_changedonetime = time + f;
436 if(wcross_name != wcross_name_goal_prev || wcross_resolution != wcross_resolution_goal_prev)
438 wcross_name_changestarttime = time;
439 wcross_name_changedonetime = time + f;
440 if(wcross_name_goal_prev_prev)
441 strunzone(wcross_name_goal_prev_prev);
442 wcross_name_goal_prev_prev = wcross_name_goal_prev;
443 wcross_name_goal_prev = strzone(wcross_name);
444 wcross_name_alpha_goal_prev_prev = wcross_name_alpha_goal_prev;
445 wcross_resolution_goal_prev_prev = wcross_resolution_goal_prev;
446 wcross_resolution_goal_prev = wcross_resolution;
449 wcross_scale_goal_prev = wcross_scale;
450 wcross_alpha_goal_prev = wcross_alpha;
451 wcross_color_goal_prev = wcross_color;
453 if((shottype == SHOTTYPE_HITTEAM && autocvar_crosshair_hittest_blur_teammate)
454 || (shottype == SHOTTYPE_HITOBSTRUCTION && autocvar_crosshair_hittest_blur_wall && !autocvar_chase_active))
457 wcross_alpha *= 0.75;
461 // *_prev is at time-frametime
462 // * is at wcross_changedonetime+f
463 // what do we have at time?
464 if(time < wcross_changedonetime)
466 f = frametime / (wcross_changedonetime - time + frametime);
467 wcross_scale = f * wcross_scale + (1 - f) * wcross_scale_prev;
468 wcross_alpha = f * wcross_alpha + (1 - f) * wcross_alpha_prev;
469 wcross_color = f * wcross_color + (1 - f) * wcross_color_prev;
472 wcross_scale_prev = wcross_scale;
473 wcross_alpha_prev = wcross_alpha;
474 wcross_color_prev = wcross_color;
476 MUTATOR_CALLHOOK(UpdateCrosshair);
478 wcross_scale *= 1 - autocvar__menu_alpha;
479 wcross_alpha *= 1 - autocvar__menu_alpha;
480 wcross_size = draw_getimagesize(wcross_name) * wcross_scale;
482 if(wcross_scale >= 0.001 && wcross_alpha >= 0.001)
484 // crosshair rings for weapon stats
485 if (autocvar_crosshair_ring || autocvar_crosshair_ring_reload)
487 // declarations and stats
488 float ring_value = 0, ring_scale = 0, ring_alpha = 0, ring_inner_value = 0, ring_inner_alpha = 0;
489 string ring_image = string_null, ring_inner_image = string_null;
490 vector ring_rgb = '0 0 0', ring_inner_rgb = '0 0 0';
492 ring_scale = autocvar_crosshair_ring_size;
494 entity wepent = viewmodels[0]; // TODO: unhardcode
496 int weapon_clipload = wepent.clip_load;
497 int weapon_clipsize = wepent.clip_size;
499 float arc_heat = wepent.arc_heat_percent;
501 if(vortex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
502 vortex_charge_movingavg = wepent.vortex_charge;
505 float chargepool = 0;
506 bool ring_vortex_enabled = false;
507 if (autocvar_crosshair_ring && autocvar_crosshair_ring_vortex)
509 if (wepent.activeweapon == WEP_VORTEX)
511 charge = wepent.vortex_charge;
512 chargepool = wepent.vortex_chargepool_ammo;
514 else if (wepent.activeweapon == WEP_OVERKILL_NEX)
516 charge = wepent.oknex_charge;
517 chargepool = wepent.oknex_chargepool_ammo;
520 ring_vortex_enabled = true;
523 if (ring_vortex_enabled)
525 if (chargepool || use_vortex_chargepool) {
526 use_vortex_chargepool = 1;
527 ring_inner_value = chargepool;
529 float rate = autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate;
530 vortex_charge_movingavg = (1 - rate) * vortex_charge_movingavg + rate * charge;
531 ring_inner_value = bound(0, autocvar_crosshair_ring_vortex_currentcharge_scale * (charge - vortex_charge_movingavg), 1);
534 ring_inner_alpha = autocvar_crosshair_ring_vortex_inner_alpha;
535 ring_inner_rgb = vec3(autocvar_crosshair_ring_vortex_inner_color_red, autocvar_crosshair_ring_vortex_inner_color_green, autocvar_crosshair_ring_vortex_inner_color_blue);
536 ring_inner_image = "gfx/crosshair_ring_inner";
538 // draw the outer ring to show the current charge of the weapon
540 ring_alpha = autocvar_crosshair_ring_vortex_alpha;
541 ring_rgb = wcross_color;
542 ring_image = "gfx/crosshair_ring_nexgun";
544 else if (autocvar_crosshair_ring && wepent.activeweapon == WEP_MINE_LAYER && WEP_CVAR(minelayer, limit) && autocvar_crosshair_ring_minelayer)
546 ring_value = bound(0, wepent.minelayer_mines / WEP_CVAR(minelayer, limit), 1);
547 ring_alpha = autocvar_crosshair_ring_minelayer_alpha;
548 ring_rgb = wcross_color;
549 ring_image = "gfx/crosshair_ring";
551 else if (wepent.activeweapon == WEP_HAGAR && wepent.hagar_load && autocvar_crosshair_ring_hagar)
553 ring_value = bound(0, wepent.hagar_load / WEP_CVAR_SEC(hagar, load_max), 1);
554 ring_alpha = autocvar_crosshair_ring_hagar_alpha;
555 ring_rgb = wcross_color;
556 ring_image = "gfx/crosshair_ring";
558 else if(autocvar_crosshair_ring_reload && weapon_clipsize) // forces there to be only an ammo ring
560 ring_value = bound(0, weapon_clipload / weapon_clipsize, 1);
561 ring_scale = autocvar_crosshair_ring_reload_size;
562 ring_alpha = autocvar_crosshair_ring_reload_alpha;
563 ring_rgb = wcross_color;
565 // Note: This is to stop Taoki from complaining that the image doesn't match all potential balances.
566 // if a new image for another weapon is added, add the code (and its respective file/value) here
567 if ((wepent.activeweapon == WEP_RIFLE) && (weapon_clipsize == 80))
568 ring_image = "gfx/crosshair_ring_rifle";
570 ring_image = "gfx/crosshair_ring";
572 else if ( autocvar_crosshair_ring && autocvar_crosshair_ring_arc && arc_heat && wepent.activeweapon == WEP_ARC )
574 ring_value = arc_heat;
575 ring_alpha = (1-arc_heat)*autocvar_crosshair_ring_arc_cold_alpha +
576 arc_heat*autocvar_crosshair_ring_arc_hot_alpha;
577 ring_rgb = (1-arc_heat)*wcross_color + arc_heat*autocvar_crosshair_ring_arc_hot_color;
578 ring_image = "gfx/crosshair_ring";
581 // if in weapon switch animation, fade ring out/in
582 if(autocvar_crosshair_effect_time > 0)
584 f = (time - wcross_name_changestarttime) / autocvar_crosshair_effect_time;
587 wcross_ring_prev = ((ring_image) ? true : false);
593 ring_alpha *= fabs(1 - bound(0, f, 1));
598 ring_alpha *= bound(0, f, 1);
602 if (autocvar_crosshair_ring_inner && ring_inner_value) // lets draw a ring inside a ring so you can ring while you ring
603 DrawCircleClippedPic(wcross_origin, wcross_size.x * wcross_resolution * ring_scale, ring_inner_image, ring_inner_value, ring_inner_rgb, wcross_alpha * ring_inner_alpha, DRAWFLAG_ADDITIVE);
606 DrawCircleClippedPic(wcross_origin, wcross_size.x * wcross_resolution * ring_scale, ring_image, ring_value, ring_rgb, wcross_alpha * ring_alpha, DRAWFLAG_ADDITIVE);
609 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
611 vector scaled_sz = sz * wcross_size; \
612 if(wcross_blur > 0) \
614 for(i = -2; i <= 2; ++i) \
615 for(j = -2; j <= 2; ++j) \
616 M(i,j,sz,scaled_sz,wcross_name,wcross_alpha*0.04); \
620 M(0,0,sz,scaled_sz,wcross_name,wcross_alpha); \
624 #define CROSSHAIR_DRAW_SINGLE(i,j,sz,scaled_sz,wcross_name,wcross_alpha) \
625 drawpic(wcross_origin - ('0.5 0 0' * (scaled_sz.x + i * wcross_blur) + '0 0.5 0' * (scaled_sz.y + j * wcross_blur)), wcross_name, scaled_sz, wcross_color, wcross_alpha, DRAWFLAG_NORMAL)
627 #define CROSSHAIR_DRAW(sz,wcross_name,wcross_alpha) \
628 CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_SINGLE,sz,wcross_name,wcross_alpha)
630 if(time < wcross_name_changedonetime && wcross_name != wcross_name_goal_prev_prev && wcross_name_goal_prev_prev)
632 f = (wcross_name_changedonetime - time) / (wcross_name_changedonetime - wcross_name_changestarttime);
633 wcross_size = draw_getimagesize(wcross_name_goal_prev_prev) * wcross_scale;
634 CROSSHAIR_DRAW(wcross_resolution_goal_prev_prev, wcross_name_goal_prev_prev, wcross_alpha * f * wcross_name_alpha_goal_prev_prev);
641 wcross_name_alpha_goal_prev = f;
643 wcross_size = draw_getimagesize(wcross_name) * wcross_scale;
644 CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);
646 if(autocvar_crosshair_dot)
648 vector wcross_color_old;
649 wcross_color_old = wcross_color;
651 if((autocvar_crosshair_dot_color_custom) && (autocvar_crosshair_dot_color != "0"))
652 wcross_color = stov(autocvar_crosshair_dot_color);
654 CROSSHAIR_DRAW(wcross_resolution * autocvar_crosshair_dot_size, "gfx/crosshairdot", f * autocvar_crosshair_dot_alpha);
655 // FIXME why don't we use wcross_alpha here?
656 wcross_color = wcross_color_old;
662 wcross_scale_prev = 0;
663 wcross_alpha_prev = 0;
664 wcross_scale_goal_prev = 0;
665 wcross_alpha_goal_prev = 0;
666 wcross_changedonetime = 0;
667 strfree(wcross_name_goal_prev);
668 strfree(wcross_name_goal_prev_prev);
669 wcross_name_changestarttime = 0;
670 wcross_name_changedonetime = 0;
671 wcross_name_alpha_goal_prev = 0;
672 wcross_name_alpha_goal_prev_prev = 0;
673 wcross_resolution_goal_prev = 0;
674 wcross_resolution_goal_prev_prev = 0;
678 void DrawReticle(entity this)
680 if(!autocvar_cl_reticle || MUTATOR_CALLHOOK(DrawReticle))
686 float is_dead = (STAT(HEALTH) <= 0);
687 string reticle_image = string_null;
688 bool wep_zoomed = false;
689 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
691 entity wepe = viewmodels[slot];
692 Weapon wep = wepe.activeweapon;
693 if(wep != WEP_Null && wep.wr_zoom)
695 bool do_zoom = wep.wr_zoom(wep, NULL);
696 if(!reticle_image && wep.w_reticle && wep.w_reticle != "")
697 reticle_image = wep.w_reticle;
698 wep_zoomed += do_zoom;
701 // Draw the aiming reticle for weapons that use it
702 // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use
703 // It must be a persisted float for fading out to work properly (you let go of the zoom button for
704 // the view to go back to normal, so reticle_type would become 0 as we fade out)
705 if(spectatee_status || is_dead || hud != HUD_NORMAL || this.viewloc)
707 // no zoom reticle while dead
710 else if(wep_zoomed && autocvar_cl_reticle_weapon)
712 if(reticle_image) { reticle_type = 2; }
713 else { reticle_type = 0; }
715 else if(button_zoom || zoomscript_caught)
723 vector reticle_pos = '0 0 0', reticle_size = '0 0 0';
724 if(autocvar_cl_reticle_stretch)
726 reticle_size.x = vid_conwidth;
727 reticle_size.y = vid_conheight;
733 reticle_size.x = max(vid_conwidth, vid_conheight);
734 reticle_size.y = max(vid_conwidth, vid_conheight);
735 reticle_pos.x = (vid_conwidth - reticle_size.x) / 2;
736 reticle_pos.y = (vid_conheight - reticle_size.y) / 2;
739 float f = (zoomscript_caught) ? 1 : current_zoomfraction;
745 case 1: drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * autocvar_cl_reticle_normal_alpha, DRAWFLAG_NORMAL); break;
746 case 2: if(reticle_image) drawpic(reticle_pos, reticle_image, reticle_size, '1 1 1', f * autocvar_cl_reticle_weapon_alpha, DRAWFLAG_NORMAL); break;