#pragma once

#include "pickup.qh"
CLASS(Armor, Pickup)
/* color      */ ATTRIB(Armor, m_color, vector, '0 1 0');
#ifdef SVQC
/* pickupfunc */ ATTRIB(Armor, m_pickupevalfunc, float(entity player, entity item), healtharmor_pickupevalfunc);
/* botvalue   */ ATTRIB(Armor, m_botvalue, int, 5000);
#endif
ENDCLASS(Armor)

#ifdef SVQC
    #include <server/items/items.qh>
#endif

// small armor
#ifdef GAMEQC
MODEL(ArmorSmall_ITEM, Item_Model("item_armor_small.md3"));
SOUND(ArmorSmall, Item_Sound("armor1"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_armorsmall_anyway;
int autocvar_g_pickup_armorsmall;
int autocvar_g_pickup_armorsmall_max;
float autocvar_g_pickup_respawntime_armor_small;
float autocvar_g_pickup_respawntimejitter_armor_small;
void item_armorsmall_init(Pickup this, entity item)
{
    if(!item.max_armorvalue)
        item.max_armorvalue = autocvar_g_pickup_armorsmall_max;
    if(!GetResource(item, RES_ARMOR))
        SetResourceExplicit(item, RES_ARMOR, autocvar_g_pickup_armorsmall);
}
#endif

CLASS(ArmorSmall, Armor)
/* spawnfunc    */ ATTRIB(ArmorSmall, m_canonical_spawnfunc, string, "item_armor_small");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(ArmorSmall, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(ArmorSmall, m_model, Model, MDL_ArmorSmall_ITEM);
/* sound        */ ATTRIB(ArmorSmall, m_sound, Sound, SND_ArmorSmall);
#endif
/* refname      */ ATTRIB(ArmorSmall, netname, string, "armor_small");
/* itemname     */ ATTRIB(ArmorSmall, m_name, string, _("Small armor"));
/* icon         */ ATTRIB(ArmorSmall, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "armor_small")) == "")
        ? "armor" // compatible with Xonotic v0.8.2 or lower
        : "armor_small"
#else
    "armor_small"
#endif
);
#ifdef SVQC
/* minsize      */ ATTRIB(ArmorSmall, m_mins, vector, ITEM_S_MINS);
/* maxsize      */ ATTRIB(ArmorSmall, m_maxs, vector, ITEM_S_MAXS);
/* itemid       */ ATTRIB(ArmorSmall, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(ArmorSmall, m_respawntime, float, autocvar_g_pickup_respawntime_armor_small);
/*              */ ATTRIB(ArmorSmall, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_armor_small);
/* pickupanyway */ ATTRIB(ArmorSmall, m_pickupanyway, bool, autocvar_g_pickup_armorsmall_anyway);
/* iteminit     */ ATTRIB(ArmorSmall, m_iteminit, void(Pickup this, entity item), item_armorsmall_init);
#endif
ENDCLASS(ArmorSmall)
REGISTER_ITEM(ArmorSmall, NEW(ArmorSmall));

SPAWNFUNC_ITEM(item_armor_small, ITEM_ArmorSmall)

// medium armor
#ifdef GAMEQC
MODEL(ArmorMedium_ITEM, Item_Model("item_armor_medium.md3"));
SOUND(ArmorMedium, Item_Sound("armor10"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_armormedium_anyway;
int autocvar_g_pickup_armormedium;
int autocvar_g_pickup_armormedium_max;
float autocvar_g_pickup_respawntime_armor_medium;
float autocvar_g_pickup_respawntimejitter_armor_medium;
void item_armormedium_init(Pickup this, entity item)
{
    if(!item.max_armorvalue)
        item.max_armorvalue = autocvar_g_pickup_armormedium_max;
    if(!GetResource(item, RES_ARMOR))
        SetResourceExplicit(item, RES_ARMOR, autocvar_g_pickup_armormedium);
}
#endif

CLASS(ArmorMedium, Armor)
/* spawnfunc    */ ATTRIB(ArmorMedium, m_canonical_spawnfunc, string, "item_armor_medium");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(ArmorMedium, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(ArmorMedium, m_model, Model, MDL_ArmorMedium_ITEM);
/* sound        */ ATTRIB(ArmorMedium, m_sound, Sound, SND_ArmorMedium);
#endif
/* refname      */ ATTRIB(ArmorMedium, netname, string, "armor_medium");
/* itemname     */ ATTRIB(ArmorMedium, m_name, string, _("Medium armor"));
/* icon         */ ATTRIB(ArmorMedium, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "armor_medium")) == "")
        ? "armor" // compatible with Xonotic v0.8.2 or lower
        : "armor_medium"
#else
    "armor_medium"
#endif
);
#ifdef SVQC
/* minsize      */ ATTRIB(ArmorMedium, m_mins, vector, ITEM_S_MINS);
/* maxsize      */ ATTRIB(ArmorMedium, m_maxs, vector, ITEM_S_MAXS);
/* itemid       */ ATTRIB(ArmorMedium, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(ArmorMedium, m_respawntime, float, autocvar_g_pickup_respawntime_armor_medium);
/*              */ ATTRIB(ArmorMedium, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_armor_medium);
/* pickupanyway */ ATTRIB(ArmorMedium, m_pickupanyway, bool, autocvar_g_pickup_armormedium_anyway);
/* iteminit     */ ATTRIB(ArmorMedium, m_iteminit, void(Pickup this, entity item), item_armormedium_init);
#endif
ENDCLASS(ArmorMedium)
REGISTER_ITEM(ArmorMedium, NEW(ArmorMedium));

SPAWNFUNC_ITEM(item_armor_medium, ITEM_ArmorMedium)

// big armor
#ifdef GAMEQC
MODEL(ArmorBig_ITEM, Item_Model("item_armor_big.md3"));
SOUND(ArmorBig, Item_Sound("armor17_5"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_armorbig_anyway;
int autocvar_g_pickup_armorbig;
int autocvar_g_pickup_armorbig_max;
float autocvar_g_pickup_respawntime_armor_big;
float autocvar_g_pickup_respawntimejitter_armor_big;
void item_armorbig_init(Pickup this, entity item)
{
    if(!item.max_armorvalue)
        item.max_armorvalue = autocvar_g_pickup_armorbig_max;
    if(!GetResource(item, RES_ARMOR))
        SetResourceExplicit(item, RES_ARMOR, autocvar_g_pickup_armorbig);
}
#endif

CLASS(ArmorBig, Armor)
/* spawnfunc    */ ATTRIB(ArmorBig, m_canonical_spawnfunc, string, "item_armor_big");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(ArmorBig, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(ArmorBig, m_model, Model, MDL_ArmorBig_ITEM);
/* sound        */ ATTRIB(ArmorBig, m_sound, Sound, SND_ArmorBig);
#endif
/* refname      */ ATTRIB(ArmorBig, netname, string, "armor_big");
/* itemname     */ ATTRIB(ArmorBig, m_name, string, _("Big armor"));
/* icon         */ ATTRIB(ArmorBig, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "armor_big")) == "")
        ? "armor" // compatible with Xonotic v0.8.2 or lower
        : "armor_big"
#else
    "armor_big"
#endif
);
/* color        */ ATTRIB(ArmorBig, m_color, vector, '0 1 0');
/* wptext       */ ATTRIB(ArmorBig, m_waypoint, string, _("Big armor"));
#ifdef SVQC
/* itemid       */ ATTRIB(ArmorBig, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(ArmorBig, m_respawntime, float, autocvar_g_pickup_respawntime_armor_big);
/*              */ ATTRIB(ArmorBig, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_armor_big);
/* pickupanyway */ ATTRIB(ArmorBig, m_pickupanyway, bool, autocvar_g_pickup_armorbig_anyway);
/* iteminit     */ ATTRIB(ArmorBig, m_iteminit, void(Pickup this, entity item), item_armorbig_init);
#endif
ENDCLASS(ArmorBig)
REGISTER_ITEM(ArmorBig, NEW(ArmorBig));

SPAWNFUNC_ITEM(item_armor_big, ITEM_ArmorBig)

// mega armor
#ifdef GAMEQC
MODEL(ArmorMega_ITEM, Item_Model("item_armor_large.md3"));
SOUND(ArmorMega, Item_Sound("armor25"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_armormega_anyway;
int autocvar_g_pickup_armormega;
int autocvar_g_pickup_armormega_max;
float autocvar_g_pickup_respawntime_armor_mega;
float autocvar_g_pickup_respawntimejitter_armor_mega;
void item_armormega_init(Pickup this, entity item)
{
    if(!item.max_armorvalue)
        item.max_armorvalue = autocvar_g_pickup_armormega_max;
    if(!GetResource(item, RES_ARMOR))
        SetResourceExplicit(item, RES_ARMOR, autocvar_g_pickup_armormega);
}
#endif

CLASS(ArmorMega, Armor)
/* spawnfunc    */ ATTRIB(ArmorMega, m_canonical_spawnfunc, string, "item_armor_mega");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(ArmorMega, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(ArmorMega, m_model, Model, MDL_ArmorMega_ITEM);
/* sound        */ ATTRIB(ArmorMega, m_sound, Sound, SND_ArmorMega);
#endif
/* refname      */ ATTRIB(ArmorMega, netname, string, "armor_mega");
/* itemname     */ ATTRIB(ArmorMega, m_name, string, _("Mega armor"));
/* icon         */ ATTRIB(ArmorMega, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "armor_mega")) == "")
        ? "item_large_armor" // compatible with Xonotic v0.8.2 or lower
        : "armor_mega"
#else
    "armor_mega"
#endif
);
/* color        */ ATTRIB(ArmorMega, m_color, vector, '0 1 0');
/* wptext       */ ATTRIB(ArmorMega, m_waypoint, string, _("Mega armor"));
/* wpblink      */ ATTRIB(ArmorMega, m_waypointblink, int, 2);
#ifdef SVQC
/* maxsize      */ ATTRIB(ArmorMega, m_maxs, vector, ITEM_L_MAXS);
/* itemid       */ ATTRIB(ArmorMega, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(ArmorMega, m_respawntime, float, autocvar_g_pickup_respawntime_armor_mega);
/*              */ ATTRIB(ArmorMega, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_armor_mega);
/* pickupanyway */ ATTRIB(ArmorMega, m_pickupanyway, bool, autocvar_g_pickup_armormega_anyway);
/* iteminit     */ ATTRIB(ArmorMega, m_iteminit, void(Pickup this, entity item), item_armormega_init);
#endif
ENDCLASS(ArmorMega)
REGISTER_ITEM(ArmorMega, NEW(ArmorMega));

SPAWNFUNC_ITEM(item_armor_mega, ITEM_ArmorMega)
