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>
17 float pickup_crosshair_time, pickup_crosshair_size;
18 float hitindication_crosshair_size;
19 float use_vortex_chargepool;
24 float wcross_scale_prev, wcross_alpha_prev;
25 vector wcross_color_prev;
26 float wcross_scale_goal_prev, wcross_alpha_goal_prev;
27 vector wcross_color_goal_prev;
28 float wcross_changedonetime;
30 string wcross_name_goal_prev, wcross_name_goal_prev_prev;
31 float wcross_resolution_goal_prev, wcross_resolution_goal_prev_prev;
32 float wcross_name_changestarttime, wcross_name_changedonetime;
33 float wcross_name_alpha_goal_prev, wcross_name_alpha_goal_prev_prev;
35 float wcross_ring_prev;
40 const float SHOTTYPE_HITTEAM = 1;
41 const float SHOTTYPE_HITOBSTRUCTION = 2;
42 const float SHOTTYPE_HITWORLD = 3;
43 const float SHOTTYPE_HITENEMY = 4;
47 (trueaim = new_pure(trueaim)).dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
48 (trueaim_rifle = new_pure(trueaim_rifle)).dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
54 wcross_origin = project_3d_to_2d(trace_endpos);
59 n = trace_networkentity;
61 return SHOTTYPE_HITWORLD;
63 return SHOTTYPE_HITWORLD;
64 t = entcs_GetTeam(n - 1);
67 return SHOTTYPE_HITTEAM;
68 if(t == NUM_SPECTATOR)
69 return SHOTTYPE_HITWORLD;
70 return SHOTTYPE_HITENEMY;
73 float TrueAimCheck(entity wepent)
75 if(wepent.activeweapon.spawnflags & WEP_FLAG_NOTRUEAIM)
76 return SHOTTYPE_HITWORLD;
78 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?
79 vector vecs, trueaimpoint, w_shotorg;
89 switch(wepent.activeweapon) // WEAPONTODO
92 case WEP_OVERKILL_NEX:
101 tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * max_shot_distance, mv, ta);
102 return EnemyHitCheck();
105 case WEP_DEVASTATOR: // projectile has a size!
109 case WEP_FIREBALL: // projectile has a size!
113 case WEP_SEEKER: // projectile has a size!
117 case WEP_ELECTRO: // projectile has a size!
123 vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * STAT(VIEWHEIGHT));
125 vecs = decompressShotOrigin(STAT(SHOTORG));
127 traceline(traceorigin, traceorigin + view_forward * max_shot_distance, mv, ta);
128 trueaimpoint = trace_endpos;
129 // move trueaimpoint a little bit forward to make the final tracebox reliable
130 // since it sometimes doesn't reach a teammate by a hair
131 trueaimpoint += view_forward;
133 if(vdist((trueaimpoint - traceorigin), <, g_trueaim_minrange))
134 trueaimpoint = traceorigin + view_forward * g_trueaim_minrange;
141 dv = view_right * vecs.y + view_up * vecs.z;
142 w_shotorg = traceorigin + dv;
144 // now move the vecs forward as much as requested if possible
145 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
146 w_shotorg = trace_endpos - view_forward * nudge;
148 tracebox(w_shotorg, mi, ma, trueaimpoint, MOVE_NORMAL, ta);
149 shottype = EnemyHitCheck();
150 if(shottype != SHOTTYPE_HITWORLD)
154 // FIXME WHY DOES THIS NOT WORK FOR THE ROCKET LAUNCHER?
155 // or rather, I know why, but see no fix
156 if(vlen(trace_endpos - trueaimpoint) > vlen(ma) + vlen(mi) + 1)
157 // 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
158 return SHOTTYPE_HITOBSTRUCTION;
161 return SHOTTYPE_HITWORLD;
164 void HUD_Crosshair_Vehicle(entity this)
166 if(hud != HUD_BUMBLEBEE_GUN)
168 Vehicle info = REGISTRY_GET(Vehicles, hud);
169 info.vr_crosshair(info, this);
173 vector crosshair_getcolor(entity this, float health_stat)
175 static float rainbow_last_flicker;
176 static vector rainbow_prev_color;
177 vector wcross_color = '0 0 0';
178 switch(autocvar_crosshair_color_special)
180 case 1: // weapon color
182 if(this != WEP_Null && hud == HUD_NORMAL)
184 wcross_color = this.wpcolor;
187 else { goto normalcolor; }
190 case 2: // color based on health and armor
192 vector v = healtharmor_maxdamage(health_stat, STAT(ARMOR), armorblockpercent, DEATH_WEAPON.m_id);
193 float health_and_armor = floor(v.x + 1);
194 wcross_color = HUD_Get_Num_Color(health_and_armor, 200, false);
198 case 3: // rainbow/random color
200 if(time >= rainbow_last_flicker)
202 rainbow_prev_color = randomvec() * autocvar_crosshair_color_special_rainbow_brightness;
203 rainbow_last_flicker = time + autocvar_crosshair_color_special_rainbow_delay;
205 wcross_color = rainbow_prev_color;
209 default: { wcross_color = stov(autocvar_crosshair_color); break; }
215 void HUD_Crosshair(entity this)
217 // reset player's alpha here upon death since forced scoreboard prevents running the crosshair_chase code
218 if(autocvar_chase_active > 0 && autocvar_crosshair_chase && STAT(HEALTH) <= 0 && csqcplayer)
219 csqcplayer.alpha = csqcplayer.m_alpha;
221 if (autocvar_chase_active > 0 && autocvar_chase_front)
223 csqcplayer.alpha = csqcplayer.m_alpha;
229 if(!scoreboard_active && !camera_active && intermission != 2 && !STAT(GAME_STOPPED) && !autocvar_cl_lockview
230 && spectatee_status != -1 && (!csqcplayer.viewloc || (!spectatee_status && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM))) && !MUTATOR_CALLHOOK(DrawCrosshair)
231 && !HUD_MinigameMenu_IsOpened())
233 if (!autocvar_crosshair_enabled) // main toggle for crosshair rendering
236 if (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2)
239 if (hud != HUD_NORMAL)
241 HUD_Crosshair_Vehicle(this);
246 float wcross_alpha, wcross_resolution;
247 wcross_style = autocvar_crosshair;
248 if (csqcplayer.viewloc && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM) && autocvar_crosshair_2d != "")
249 wcross_style = autocvar_crosshair_2d;
250 if (wcross_style == "0")
252 wcross_resolution = autocvar_crosshair_size;
253 if (wcross_resolution == 0)
255 wcross_alpha = autocvar_crosshair_alpha;
256 if (wcross_alpha == 0)
262 // wcross_origin = '0.5 0 0' * vid_conwidth + '0 0.5 0' * vid_conheight;
263 if(csqcplayer.viewloc && (csqcplayer.viewloc.spawnflags & VIEWLOC_FREEAIM))
264 wcross_origin = viewloc_mousepos;
265 else if(autocvar_chase_active > 0 && autocvar_crosshair_chase)
267 vector player_org = ((csqcplayer) ? csqcplayer.origin + csqcplayer.view_ofs : view_origin);
268 if(csqcplayer && autocvar_crosshair_chase_playeralpha && autocvar_crosshair_chase_playeralpha < 1)
270 traceline(view_origin, view_origin + max_shot_distance * view_forward, MOVE_NORMAL, NULL);
271 float myalpha = (!csqcplayer.m_alpha) ? 1 : csqcplayer.m_alpha;
272 if(trace_ent == csqcplayer)
273 csqcplayer.alpha = min(autocvar_crosshair_chase_playeralpha, myalpha);
275 csqcplayer.alpha = csqcplayer.m_alpha;
277 traceline(player_org, player_org + max_shot_distance * view_forward, MOVE_WORLDONLY, NULL);
278 wcross_origin = project_3d_to_2d(trace_endpos);
281 wcross_origin = project_3d_to_2d(view_origin + max_shot_distance * view_forward);
283 if(autocvar_crosshair_hittest)
285 vector wcross_oldorigin;
286 entity thiswep = viewmodels[0]; // TODO: unhardcode
287 wcross_oldorigin = wcross_origin;
288 shottype = TrueAimCheck(thiswep);
289 if(shottype == SHOTTYPE_HITWORLD)
291 v = wcross_origin - wcross_oldorigin;
293 v.y /= vid_conheight;
294 if(vdist(v, >, 0.01))
295 shottype = SHOTTYPE_HITOBSTRUCTION;
297 if(!autocvar_crosshair_hittest_showimpact)
298 wcross_origin = wcross_oldorigin;
301 shottype = SHOTTYPE_HITWORLD;
303 vector wcross_color = '0 0 0', wcross_size = '0 0 0';
304 string wcross_name = "";
305 float wcross_scale, wcross_blur;
308 if(autocvar_crosshair_per_weapon || (autocvar_crosshair_color_special == 1))
310 entity wepent = viewmodels[0]; // TODO: unhardcode
311 e = wepent.switchingweapon;
314 if(autocvar_crosshair_per_weapon)
316 // WEAPONTODO: access these through some general settings (with non-balance config settings)
317 //wcross_resolution *= cvar(strcat("crosshair_", wcross_wep, "_size"));
318 //if (wcross_resolution == 0)
321 //wcross_style = cvar_string(strcat("crosshair_", wcross_wep));
322 wcross_resolution *= e.w_crosshair_size;
323 wcross_name = e.w_crosshair;
328 if(wcross_name == "")
329 wcross_name = strcat("gfx/crosshair", wcross_style);
331 // MAIN CROSSHAIR COLOR DECISION
332 wcross_color = crosshair_getcolor(e, STAT(HEALTH));
334 if(autocvar_crosshair_effect_scalefade)
336 wcross_scale = wcross_resolution;
337 wcross_resolution = 1;
344 if(autocvar_crosshair_pickup)
346 float stat_pickup_time = STAT(LAST_PICKUP);
348 if(pickup_crosshair_time < stat_pickup_time)
350 if(time - stat_pickup_time < 5) // don't trigger the animation if it's too old
351 pickup_crosshair_size = 1;
353 pickup_crosshair_time = stat_pickup_time;
356 if(pickup_crosshair_size > 0)
357 pickup_crosshair_size -= autocvar_crosshair_pickup_speed * frametime;
359 pickup_crosshair_size = 0;
361 wcross_scale += sin(pickup_crosshair_size) * autocvar_crosshair_pickup;
364 // todo: make crosshair hit indication dependent on damage dealt
365 if(autocvar_crosshair_hitindication)
367 vector col = ((autocvar_crosshair_color_special == 1) ? stov(autocvar_crosshair_hitindication_per_weapon_color) : stov(autocvar_crosshair_hitindication_color));
369 if(unaccounted_damage)
371 hitindication_crosshair_size = 1;
374 if(hitindication_crosshair_size > 0)
375 hitindication_crosshair_size -= autocvar_crosshair_hitindication_speed * frametime;
377 hitindication_crosshair_size = 0;
379 wcross_scale += sin(hitindication_crosshair_size) * autocvar_crosshair_hitindication;
380 wcross_color.x += sin(hitindication_crosshair_size) * col.x;
381 wcross_color.y += sin(hitindication_crosshair_size) * col.y;
382 wcross_color.z += sin(hitindication_crosshair_size) * col.z;
385 // no effects needed for targeting enemies, this can't possibly span all valid targets!
386 // just show for teammates to give a sign that they're an invalid target
387 //if(shottype == SHOTTYPE_HITENEMY)
388 //wcross_scale *= autocvar_crosshair_hittest; // is not queried if hittest is 0
389 if(shottype == SHOTTYPE_HITTEAM)
390 wcross_scale /= autocvar_crosshair_hittest; // is not queried if hittest is 0
392 f = fabs(autocvar_crosshair_effect_time);
393 if(wcross_scale != wcross_scale_goal_prev || wcross_alpha != wcross_alpha_goal_prev || wcross_color != wcross_color_goal_prev)
395 wcross_changedonetime = time + f;
397 if(wcross_name != wcross_name_goal_prev || wcross_resolution != wcross_resolution_goal_prev)
399 wcross_name_changestarttime = time;
400 wcross_name_changedonetime = time + f;
401 if(wcross_name_goal_prev_prev)
402 strunzone(wcross_name_goal_prev_prev);
403 wcross_name_goal_prev_prev = wcross_name_goal_prev;
404 wcross_name_goal_prev = strzone(wcross_name);
405 wcross_name_alpha_goal_prev_prev = wcross_name_alpha_goal_prev;
406 wcross_resolution_goal_prev_prev = wcross_resolution_goal_prev;
407 wcross_resolution_goal_prev = wcross_resolution;
410 wcross_scale_goal_prev = wcross_scale;
411 wcross_alpha_goal_prev = wcross_alpha;
412 wcross_color_goal_prev = wcross_color;
414 if((shottype == SHOTTYPE_HITTEAM && autocvar_crosshair_hittest_blur_teammate)
415 || (shottype == SHOTTYPE_HITOBSTRUCTION && autocvar_crosshair_hittest_blur_wall && !autocvar_chase_active))
418 wcross_alpha *= 0.75;
422 // *_prev is at time-frametime
423 // * is at wcross_changedonetime+f
424 // what do we have at time?
425 if(time < wcross_changedonetime)
427 f = frametime / (wcross_changedonetime - time + frametime);
428 wcross_scale = f * wcross_scale + (1 - f) * wcross_scale_prev;
429 wcross_alpha = f * wcross_alpha + (1 - f) * wcross_alpha_prev;
430 wcross_color = f * wcross_color + (1 - f) * wcross_color_prev;
433 wcross_scale_prev = wcross_scale;
434 wcross_alpha_prev = wcross_alpha;
435 wcross_color_prev = wcross_color;
437 MUTATOR_CALLHOOK(UpdateCrosshair);
439 wcross_scale *= 1 - autocvar__menu_alpha;
440 wcross_alpha *= 1 - autocvar__menu_alpha;
441 wcross_size = draw_getimagesize(wcross_name) * wcross_scale;
443 if(wcross_scale >= 0.001 && wcross_alpha >= 0.001)
445 // crosshair rings for weapon stats
446 if (autocvar_crosshair_ring || autocvar_crosshair_ring_reload)
448 // declarations and stats
449 float ring_value = 0, ring_scale = 0, ring_alpha = 0, ring_inner_value = 0, ring_inner_alpha = 0;
450 string ring_image = string_null, ring_inner_image = string_null;
451 vector ring_rgb = '0 0 0', ring_inner_rgb = '0 0 0';
453 ring_scale = autocvar_crosshair_ring_size;
455 entity wepent = viewmodels[0]; // TODO: unhardcode
457 int weapon_clipload = wepent.clip_load;
458 int weapon_clipsize = wepent.clip_size;
460 float arc_heat = wepent.arc_heat_percent;
462 if(vortex_charge_movingavg == 0) // this should only happen if we have just loaded up the game
463 vortex_charge_movingavg = wepent.vortex_charge;
466 float chargepool = 0;
467 bool ring_vortex_enabled = false;
468 if (autocvar_crosshair_ring && autocvar_crosshair_ring_vortex)
470 if (wepent.activeweapon == WEP_VORTEX)
472 charge = wepent.vortex_charge;
473 chargepool = wepent.vortex_chargepool_ammo;
475 else if (wepent.activeweapon == WEP_OVERKILL_NEX)
477 charge = wepent.oknex_charge;
478 chargepool = wepent.oknex_chargepool_ammo;
481 ring_vortex_enabled = true;
484 if (ring_vortex_enabled)
486 if (chargepool || use_vortex_chargepool) {
487 use_vortex_chargepool = 1;
488 ring_inner_value = chargepool;
490 float rate = autocvar_crosshair_ring_vortex_currentcharge_movingavg_rate;
491 vortex_charge_movingavg = (1 - rate) * vortex_charge_movingavg + rate * charge;
492 ring_inner_value = bound(0, autocvar_crosshair_ring_vortex_currentcharge_scale * (charge - vortex_charge_movingavg), 1);
495 ring_inner_alpha = autocvar_crosshair_ring_vortex_inner_alpha;
496 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);
497 ring_inner_image = "gfx/crosshair_ring_inner.tga";
499 // draw the outer ring to show the current charge of the weapon
501 ring_alpha = autocvar_crosshair_ring_vortex_alpha;
502 ring_rgb = wcross_color;
503 ring_image = "gfx/crosshair_ring_nexgun.tga";
505 else if (autocvar_crosshair_ring && wepent.activeweapon == WEP_MINE_LAYER && WEP_CVAR(minelayer, limit) && autocvar_crosshair_ring_minelayer)
507 ring_value = bound(0, wepent.minelayer_mines / WEP_CVAR(minelayer, limit), 1);
508 ring_alpha = autocvar_crosshair_ring_minelayer_alpha;
509 ring_rgb = wcross_color;
510 ring_image = "gfx/crosshair_ring.tga";
512 else if (wepent.activeweapon == WEP_HAGAR && wepent.hagar_load && autocvar_crosshair_ring_hagar)
514 ring_value = bound(0, wepent.hagar_load / WEP_CVAR_SEC(hagar, load_max), 1);
515 ring_alpha = autocvar_crosshair_ring_hagar_alpha;
516 ring_rgb = wcross_color;
517 ring_image = "gfx/crosshair_ring.tga";
519 else if(autocvar_crosshair_ring_reload && weapon_clipsize) // forces there to be only an ammo ring
521 ring_value = bound(0, weapon_clipload / weapon_clipsize, 1);
522 ring_scale = autocvar_crosshair_ring_reload_size;
523 ring_alpha = autocvar_crosshair_ring_reload_alpha;
524 ring_rgb = wcross_color;
526 // Note: This is to stop Taoki from complaining that the image doesn't match all potential balances.
527 // if a new image for another weapon is added, add the code (and its respective file/value) here
528 if ((wepent.activeweapon == WEP_RIFLE) && (weapon_clipsize == 80))
529 ring_image = "gfx/crosshair_ring_rifle.tga";
531 ring_image = "gfx/crosshair_ring.tga";
533 else if ( autocvar_crosshair_ring && autocvar_crosshair_ring_arc && arc_heat && wepent.activeweapon == WEP_ARC )
535 ring_value = arc_heat;
536 ring_alpha = (1-arc_heat)*autocvar_crosshair_ring_arc_cold_alpha +
537 arc_heat*autocvar_crosshair_ring_arc_hot_alpha;
538 ring_rgb = (1-arc_heat)*wcross_color + arc_heat*autocvar_crosshair_ring_arc_hot_color;
539 ring_image = "gfx/crosshair_ring.tga";
542 // if in weapon switch animation, fade ring out/in
543 if(autocvar_crosshair_effect_time > 0)
545 f = (time - wcross_name_changestarttime) / autocvar_crosshair_effect_time;
548 wcross_ring_prev = ((ring_image) ? true : false);
554 ring_alpha *= fabs(1 - bound(0, f, 1));
559 ring_alpha *= bound(0, f, 1);
563 if (autocvar_crosshair_ring_inner && ring_inner_value) // lets draw a ring inside a ring so you can ring while you ring
564 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);
567 DrawCircleClippedPic(wcross_origin, wcross_size.x * wcross_resolution * ring_scale, ring_image, ring_value, ring_rgb, wcross_alpha * ring_alpha, DRAWFLAG_ADDITIVE);
570 #define CROSSHAIR_DO_BLUR(M,sz,wcross_name,wcross_alpha) \
572 vector scaled_sz = sz * wcross_size; \
573 if(wcross_blur > 0) \
575 for(i = -2; i <= 2; ++i) \
576 for(j = -2; j <= 2; ++j) \
577 M(i,j,sz,scaled_sz,wcross_name,wcross_alpha*0.04); \
581 M(0,0,sz,scaled_sz,wcross_name,wcross_alpha); \
585 #define CROSSHAIR_DRAW_SINGLE(i,j,sz,scaled_sz,wcross_name,wcross_alpha) \
586 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)
588 #define CROSSHAIR_DRAW(sz,wcross_name,wcross_alpha) \
589 CROSSHAIR_DO_BLUR(CROSSHAIR_DRAW_SINGLE,sz,wcross_name,wcross_alpha)
591 if(time < wcross_name_changedonetime && wcross_name != wcross_name_goal_prev_prev && wcross_name_goal_prev_prev)
593 f = (wcross_name_changedonetime - time) / (wcross_name_changedonetime - wcross_name_changestarttime);
594 wcross_size = draw_getimagesize(wcross_name_goal_prev_prev) * wcross_scale;
595 CROSSHAIR_DRAW(wcross_resolution_goal_prev_prev, wcross_name_goal_prev_prev, wcross_alpha * f * wcross_name_alpha_goal_prev_prev);
602 wcross_name_alpha_goal_prev = f;
604 wcross_size = draw_getimagesize(wcross_name) * wcross_scale;
605 CROSSHAIR_DRAW(wcross_resolution, wcross_name, wcross_alpha * f);
607 if(autocvar_crosshair_dot)
609 vector wcross_color_old;
610 wcross_color_old = wcross_color;
612 if((autocvar_crosshair_dot_color_custom) && (autocvar_crosshair_dot_color != "0"))
613 wcross_color = stov(autocvar_crosshair_dot_color);
615 CROSSHAIR_DRAW(wcross_resolution * autocvar_crosshair_dot_size, "gfx/crosshairdot.tga", f * autocvar_crosshair_dot_alpha);
616 // FIXME why don't we use wcross_alpha here?
617 wcross_color = wcross_color_old;
623 wcross_scale_prev = 0;
624 wcross_alpha_prev = 0;
625 wcross_scale_goal_prev = 0;
626 wcross_alpha_goal_prev = 0;
627 wcross_changedonetime = 0;
628 strfree(wcross_name_goal_prev);
629 strfree(wcross_name_goal_prev_prev);
630 wcross_name_changestarttime = 0;
631 wcross_name_changedonetime = 0;
632 wcross_name_alpha_goal_prev = 0;
633 wcross_name_alpha_goal_prev_prev = 0;
634 wcross_resolution_goal_prev = 0;
635 wcross_resolution_goal_prev_prev = 0;
639 void DrawReticle(entity this)
641 if(!autocvar_cl_reticle || MUTATOR_CALLHOOK(DrawReticle))
647 float is_dead = (STAT(HEALTH) <= 0);
648 string reticle_image = string_null;
649 bool wep_zoomed = false;
650 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
652 entity wepe = viewmodels[slot];
653 Weapon wep = wepe.activeweapon;
654 if(wep != WEP_Null && wep.wr_zoom)
656 bool do_zoom = wep.wr_zoom(wep, NULL);
657 if(!reticle_image && wep.w_reticle && wep.w_reticle != "")
658 reticle_image = wep.w_reticle;
659 wep_zoomed += do_zoom;
662 // Draw the aiming reticle for weapons that use it
663 // reticle_type is changed to the item we are zooming / aiming with, to decide which reticle to use
664 // It must be a persisted float for fading out to work properly (you let go of the zoom button for
665 // the view to go back to normal, so reticle_type would become 0 as we fade out)
666 if(spectatee_status || is_dead || hud != HUD_NORMAL || this.viewloc)
668 // no zoom reticle while dead
671 else if(wep_zoomed && autocvar_cl_reticle_weapon)
673 if(reticle_image) { reticle_type = 2; }
674 else { reticle_type = 0; }
676 else if(button_zoom || zoomscript_caught)
684 vector reticle_pos = '0 0 0', reticle_size = '0 0 0';
685 if(autocvar_cl_reticle_stretch)
687 reticle_size.x = vid_conwidth;
688 reticle_size.y = vid_conheight;
694 reticle_size.x = max(vid_conwidth, vid_conheight);
695 reticle_size.y = max(vid_conwidth, vid_conheight);
696 reticle_pos.x = (vid_conwidth - reticle_size.x) / 2;
697 reticle_pos.y = (vid_conheight - reticle_size.y) / 2;
700 float f = (zoomscript_caught) ? 1 : current_zoomfraction;
706 case 1: drawpic(reticle_pos, "gfx/reticle_normal", reticle_size, '1 1 1', f * autocvar_cl_reticle_normal_alpha, DRAWFLAG_NORMAL); break;
707 case 2: if(reticle_image) drawpic(reticle_pos, reticle_image, reticle_size, '1 1 1', f * autocvar_cl_reticle_weapon_alpha, DRAWFLAG_NORMAL); break;