#pragma once

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

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

// small health
#ifdef GAMEQC
MODEL(HealthSmall_ITEM, Item_Model("g_h1.md3"));
SOUND(HealthSmall, Item_Sound("minihealth"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_healthsmall_anyway;
int autocvar_g_pickup_healthsmall;
int autocvar_g_pickup_healthsmall_max;
float autocvar_g_pickup_respawntime_health_small;
float autocvar_g_pickup_respawntimejitter_health_small;
void item_healthsmall_init(Pickup this, entity item)
{
    if(!item.max_health)
        item.max_health = autocvar_g_pickup_healthsmall_max;
    if(!GetResource(item, RES_HEALTH))
        SetResourceExplicit(item, RES_HEALTH, q3compat && item.count ? item.count : autocvar_g_pickup_healthsmall);
}
#endif

CLASS(HealthSmall, Health)
/* spawnfunc    */ ATTRIB(HealthSmall, m_canonical_spawnfunc, string, "item_health_small");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(HealthSmall, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(HealthSmall, m_model, Model, MDL_HealthSmall_ITEM);
/* sound        */ ATTRIB(HealthSmall, m_sound, Sound, SND_HealthSmall);
#endif
/* refname      */ ATTRIB(HealthSmall, netname, string, "health_small");
/* itemname     */ ATTRIB(HealthSmall, m_name, string, _("Small health"));
/* icon         */ ATTRIB(HealthSmall, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "health_small")) == "")
        ? "health" // compatible with Xonotic v0.8.2 or lower
        : "health_small"
#else
    "health_small"
#endif
);
#ifdef SVQC
/* minsize      */ ATTRIB(HealthSmall, m_mins, vector, ITEM_S_MINS);
/* maxsize      */ ATTRIB(HealthSmall, m_maxs, vector, ITEM_S_MAXS);
/* itemid       */ ATTRIB(HealthSmall, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(HealthSmall, m_respawntime, float, autocvar_g_pickup_respawntime_health_small);
/*              */ ATTRIB(HealthSmall, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_health_small);
/* pickupanyway */ ATTRIB(HealthSmall, m_pickupanyway, bool, autocvar_g_pickup_healthsmall_anyway);
/* iteminit     */ ATTRIB(HealthSmall, m_iteminit, void(Pickup this, entity item), item_healthsmall_init);
#endif
ENDCLASS(HealthSmall)
REGISTER_ITEM(HealthSmall, NEW(HealthSmall));

SPAWNFUNC_ITEM(item_health_small, ITEM_HealthSmall)

// medium health
#ifdef GAMEQC
MODEL(HealthMedium_ITEM, Item_Model("g_h25.md3"));
SOUND(HealthMedium, Item_Sound("mediumhealth"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_healthmedium_anyway;
int autocvar_g_pickup_healthmedium;
int autocvar_g_pickup_healthmedium_max;
float autocvar_g_pickup_respawntime_health_medium;
float autocvar_g_pickup_respawntimejitter_health_medium;
void item_healthmedium_init(Pickup this, entity item)
{
    if(!item.max_health)
        item.max_health = autocvar_g_pickup_healthmedium_max;
    if(!GetResource(item, RES_HEALTH))
        SetResourceExplicit(item, RES_HEALTH, q3compat && item.count ? item.count : autocvar_g_pickup_healthmedium);
}
#endif

CLASS(HealthMedium, Health)
/* spawnfunc    */ ATTRIB(HealthMedium, m_canonical_spawnfunc, string, "item_health_medium");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(HealthMedium, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(HealthMedium, m_model, Model, MDL_HealthMedium_ITEM);
/* sound        */ ATTRIB(HealthMedium, m_sound, Sound, SND_HealthMedium);
#endif
/* refname      */ ATTRIB(HealthMedium, netname, string, "health_medium");
/* itemname     */ ATTRIB(HealthMedium, m_name, string, _("Medium health"));
/* icon         */ ATTRIB(HealthMedium, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "health_medium")) == "")
        ? "health" // compatible with Xonotic v0.8.2 or lower
        : "health_medium"
#else
    "health_medium"
#endif
);
#ifdef SVQC
/* minsize      */ ATTRIB(HealthMedium, m_mins, vector, ITEM_S_MINS);
/* maxsize      */ ATTRIB(HealthMedium, m_maxs, vector, ITEM_S_MAXS);
/* itemid       */ ATTRIB(HealthMedium, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(HealthMedium, m_respawntime, float, autocvar_g_pickup_respawntime_health_medium);
/*              */ ATTRIB(HealthMedium, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_health_medium);
/* pickupanyway */ ATTRIB(HealthMedium, m_pickupanyway, bool, autocvar_g_pickup_healthmedium_anyway);
/* iteminit     */ ATTRIB(HealthMedium, m_iteminit, void(Pickup this, entity item), item_healthmedium_init);
#endif
ENDCLASS(HealthMedium)
REGISTER_ITEM(HealthMedium, NEW(HealthMedium));

SPAWNFUNC_ITEM(item_health_medium, ITEM_HealthMedium)

// big health
#ifdef GAMEQC
MODEL(HealthBig_ITEM, Item_Model("g_h50.md3"));
SOUND(HealthBig, Item_Sound("mediumhealth"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_healthbig_anyway;
int autocvar_g_pickup_healthbig;
int autocvar_g_pickup_healthbig_max;
float autocvar_g_pickup_respawntime_health_big;
float autocvar_g_pickup_respawntimejitter_health_big;
void item_healthbig_init(Pickup this, entity item)
{
    if(!item.max_health)
        item.max_health = autocvar_g_pickup_healthbig_max;
    if(!GetResource(item, RES_HEALTH))
        SetResourceExplicit(item, RES_HEALTH, q3compat && item.count ? item.count : autocvar_g_pickup_healthbig);
}
#endif

CLASS(HealthBig, Health)
/* spawnfunc    */ ATTRIB(HealthBig, m_canonical_spawnfunc, string, "item_health_big");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(HealthBig, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(HealthBig, m_model, Model, MDL_HealthBig_ITEM);
/* sound        */ ATTRIB(HealthBig, m_sound, Sound, SND_HealthBig);
#endif
/* refname      */ ATTRIB(HealthBig, netname, string, "health_big");
/* itemname     */ ATTRIB(HealthBig, m_name, string, _("Big health"));
/* icon         */ ATTRIB(HealthBig, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "health_big")) == "")
        ? "health" // compatible with Xonotic v0.8.2 or lower
        : "health_big"
#else
    "health_big"
#endif
);
/* color        */ ATTRIB(HealthBig, m_color, vector, '1 0 0');
/* wptext       */ ATTRIB(HealthBig, m_waypoint, string, _("Big health"));
#ifdef SVQC
/* itemid       */ ATTRIB(HealthBig, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(HealthBig, m_respawntime, float, autocvar_g_pickup_respawntime_health_big);
/*              */ ATTRIB(HealthBig, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_health_big);
/* pickupanyway */ ATTRIB(HealthBig, m_pickupanyway, bool, autocvar_g_pickup_healthbig_anyway);
/* iteminit     */ ATTRIB(HealthBig, m_iteminit, void(Pickup this, entity item), item_healthbig_init);
#endif
ENDCLASS(HealthBig)
REGISTER_ITEM(HealthBig, NEW(HealthBig));

SPAWNFUNC_ITEM(item_health_big, ITEM_HealthBig)

#ifdef GAMEQC
MODEL(HealthMega_ITEM, Item_Model("g_h100.md3"));
SOUND(HealthMega, Item_Sound("megahealth"));
#endif
#ifdef SVQC
bool autocvar_g_pickup_healthmega_anyway;
int autocvar_g_pickup_healthmega;
int autocvar_g_pickup_healthmega_max;
float autocvar_g_pickup_respawntime_health_mega;
float autocvar_g_pickup_respawntimejitter_health_mega;
void item_healthmega_init(Pickup this, entity item)
{
    if(!item.max_health)
        item.max_health = autocvar_g_pickup_healthmega_max;
    if(!GetResource(item, RES_HEALTH))
        SetResourceExplicit(item, RES_HEALTH, q3compat && item.count ? item.count : autocvar_g_pickup_healthmega);
}
#endif

CLASS(HealthMega, Health)
/* spawnfunc    */ ATTRIB(HealthMega, m_canonical_spawnfunc, string, "item_health_mega");
#ifdef GAMEQC
/* spawnflags   */ ATTRIB(HealthMega, spawnflags, int, ITEM_FLAG_NORMAL | ITEM_FLAG_RESOURCE);
/* model        */ ATTRIB(HealthMega, m_model, Model, MDL_HealthMega_ITEM);
/* sound        */ ATTRIB(HealthMega, m_sound, Sound, SND_HealthMega);
#endif
/* refname      */ ATTRIB(HealthMega, netname, string, "health_mega");
/* itemname     */ ATTRIB(HealthMega, m_name, string, _("Mega health"));
/* icon         */ ATTRIB(HealthMega, m_icon, string, // ...
#ifdef CSQC
    (precache_pic(strcat("gfx/hud/luma/", "health_mega")) == "")
        ? "item_mega_health" // compatible with Xonotic v0.8.2 or lower
        : "health_mega"
#else
    "health_mega"
#endif
);
/* color        */ ATTRIB(HealthMega, m_color, vector, '1 0 0');
/* wptext       */ ATTRIB(HealthMega, m_waypoint, string, _("Mega health"));
/* wpblink      */ ATTRIB(HealthMega, m_waypointblink, int, 2);
#ifdef SVQC
/* maxsize      */ ATTRIB(HealthMega, m_maxs, vector, ITEM_L_MAXS);
/* itemid       */ ATTRIB(HealthMega, m_itemid, int, IT_RESOURCE);
/* respawntime  */ ATTRIB(HealthMega, m_respawntime, float, autocvar_g_pickup_respawntime_health_mega);
/*              */ ATTRIB(HealthMega, m_respawntimejitter, float, autocvar_g_pickup_respawntimejitter_health_mega);
/* pickupanyway */ ATTRIB(HealthMega, m_pickupanyway, bool, autocvar_g_pickup_healthmega_anyway);
/* iteminit     */ ATTRIB(HealthMega, m_iteminit, void(Pickup this, entity item), item_healthmega_init);
#endif
ENDCLASS(HealthMega)
REGISTER_ITEM(HealthMega, NEW(HealthMega));

SPAWNFUNC_ITEM(item_health_mega, ITEM_HealthMega)
