#pragma once

#include <common/weapons/weapon.qh>

bool autocvar_camera_chase_smoothly;
bool autocvar_camera_enable;
bool autocvar_camera_forward_follows;
bool autocvar_camera_free;
float autocvar_camera_look_attenuation;
float autocvar_camera_look_player;
float autocvar_camera_mouse_threshold;
bool autocvar_camera_reset;
float autocvar_camera_speed_attenuation;
float autocvar_camera_speed_chase;
float autocvar_camera_speed_free;
float autocvar_camera_speed_roll;
int autocvar_chase_active;
bool autocvar_chase_front;
int autocvar_cl_gentle_damage;
bool autocvar_cl_lockview;
bool autocvar_cl_orthoview;
bool autocvar_cl_orthoview_nofog;
bool autocvar_cl_spawnzoom = 1;
float autocvar_cl_spawnzoom_speed = 1;
float autocvar_cl_spawnzoom_factor = 2;
bool autocvar_cl_stripcolorcodes;
bool autocvar_cl_velocityzoom_enabled;
float autocvar_cl_velocityzoom_factor;
int autocvar_cl_velocityzoom_type = 3;
float autocvar_cl_velocityzoom_speed;
float autocvar_cl_velocityzoom_time;
float autocvar_cl_zoomfactor;
float autocvar_cl_zoomsensitivity;
float autocvar_cl_zoomspeed;
bool autocvar_cl_zoomscroll = 1;
float autocvar_cl_zoomscroll_scale = 0.2;
float autocvar_cl_zoomscroll_speed = 16;
float autocvar_fov;
float autocvar_hud_colorflash_alpha;
bool autocvar_hud_contents;
float autocvar_hud_contents_blur;
float autocvar_hud_contents_blur_alpha;
float autocvar_hud_contents_fadeintime;
float autocvar_hud_contents_fadeouttime;
float autocvar_hud_contents_lava_alpha;
string autocvar_hud_contents_lava_color;
float autocvar_hud_contents_slime_alpha;
string autocvar_hud_contents_slime_color;
float autocvar_hud_contents_water_alpha;
string autocvar_hud_contents_water_color;
bool autocvar_hud_damage;
float autocvar_hud_damage_blur;
float autocvar_hud_damage_blur_alpha;
string autocvar_hud_damage_color;
float autocvar_hud_damage_factor;
float autocvar_hud_damage_fade_rate;
float autocvar_hud_damage_gentle_alpha_multiplier;
string autocvar_hud_damage_gentle_color;
float autocvar_hud_damage_maxalpha;
float autocvar_hud_damage_pain_threshold;
float autocvar_hud_damage_pain_threshold_lower;
float autocvar_hud_damage_pain_threshold_lower_health;
float autocvar_hud_damage_pain_threshold_pulsating_min;
float autocvar_hud_damage_pain_threshold_pulsating_period;
bool autocvar_hud_powerup;
bool autocvar_hud_postprocessing;
float autocvar_hud_postprocessing_maxbluralpha;
float autocvar_hud_postprocessing_maxblurradius;
float autocvar_menu_mouse_speed;
int autocvar_r_fakelight;
bool autocvar_r_fullbright;
float autocvar_r_letterbox;
bool autocvar_v_flipped;
int autocvar_vid_conheight;
int autocvar_vid_conwidth;
float autocvar_vid_pixelheight;
float autocvar_viewsize;
bool autocvar_cl_eventchase_vehicle = 1;
vector autocvar_cl_eventchase_vehicle_viewoffset = '0 0 80';
float autocvar_cl_eventchase_vehicle_distance = 250;
int autocvar_cl_hitsound;
float autocvar_cl_hitsound_min_pitch = 0.75;
float autocvar_cl_hitsound_max_pitch = 1.5;
float autocvar_cl_hitsound_nom_damage = 25;
float autocvar_cl_hitsound_antispam_time;
bool autocvar_cl_eventchase_spectated_change = false;
float autocvar_cl_eventchase_spectated_change_time = 1;
int autocvar_cl_eventchase_death = 2;
float autocvar_cl_eventchase_distance = 140;
bool autocvar_cl_eventchase_frozen = false;
float autocvar_cl_eventchase_speed = 1.3;
vector autocvar_cl_eventchase_maxs = '12 12 8';
vector autocvar_cl_eventchase_mins = '-12 -12 -8';
vector autocvar_cl_eventchase_viewoffset = '0 0 20';
string autocvar__togglezoom;
int autocvar_cl_nade_timer;
bool autocvar_r_drawviewmodel;
vector autocvar_cl_gunoffset;

void calc_followmodel_ofs(entity view);

vector project_3d_to_2d(vector vec);

void update_mousepos();

void CSQC_Demo_Camera();

entity viewmodels[MAX_WEAPONSLOTS];

vector viewloc_mousepos;

int cursor_active;
int cursor_type;
const int CURSOR_NORMAL = 0;
const int CURSOR_MOVE = 1;
const int CURSOR_RESIZE = 2;
const int CURSOR_RESIZE2 = 3;

float drawtime;
float unaccounted_damage = 0;
float zoomscript_caught;

float dmg_take;
// float dmg_save;
// vector dmg_origin;

#ifdef BLURTEST
float blurtest_time0, blurtest_time1, blurtest_radius, blurtest_power;
#endif

float intermission_time;
float game_stopped_time;

bool View_InputEvent(int bInputType, float nPrimary, float nSecondary);
