#pragma once

#include <common/weapons/_all.qh>
#include <common/stats.qh>

int autocvar_g_showweaponspawns;
bool autocvar_g_weaponswitch_debug;
bool autocvar_g_weaponswitch_debug_alternate;

.int selectweapon; // last selected weapon of the player

.WepSet dual_weapons;

// switch between weapons
void Send_WeaponComplain(entity e, float wpn, float type);

.float hasweapon_complain_spam;
bool client_hasweapon(entity this, Weapon wpn, .entity weaponentity, float andammo, bool complain);

.int weaponcomplainindex;
float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, bool complain, bool skipmissing, .entity weaponentity);

#define w_getbestweapon(ent,wepent) REGISTRY_GET(Weapons, W_GetCycleWeapon(ent, CS_CVAR(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent))

void W_SwitchWeapon_Force(Player this, Weapon w, .entity weaponentity);

// perform weapon to attack (weaponstate and attack_finished check is here)
void W_SwitchToOtherWeapon(entity this, .entity weaponentity);
bool W_SwitchWeapon(entity this, Weapon imp, .entity weaponentity); // returns false if the player does not have the weapon
void W_SwitchWeapon_TryOthers(entity this, Weapon imp, .entity weaponentity);

void W_CycleWeapon(entity this, string weaponorder, float dir, .entity weaponentity);

void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity);

// next weapon
void W_NextWeapon(entity this, float list, .entity weaponentity);

// prev weapon
void W_PreviousWeapon(entity this, float list, .entity weaponentity);

// previously used if exists and has ammo, (second) best otherwise
void W_LastWeapon(entity this, .entity weaponentity);
