#ifndef BUFFS_H #define BUFFS_H // Welcome to the stuff behind the scenes // Below, you will find the list of buffs // Add new buffs here! // Note: Buffs also need spawnfuncs, which are set below #include "teams.qh" #include "util.qh" void RegisterBuffs(); const int BUFFS_MAX = 16; entity BUFFS[BUFFS_MAX], BUFFS_first, BUFFS_last; int BUFFS_COUNT; #define REGISTER_BUFF(id) \ REGISTER(RegisterBuffs, BUFF, BUFFS, BUFFS_COUNT, id, m_id, NEW(Buff)); \ REGISTER_INIT_POST(BUFF, id) { \ this.netname = this.m_name; \ this.m_itemid = BIT(this.m_id - 1); \ this.m_sprite = strzone(strcat("buff-", this.m_name)); \ } \ REGISTER_INIT(BUFF, id) REGISTER_REGISTRY(RegisterBuffs) #include "items/item/pickup.qh" CLASS(Buff, Pickup) /** bit index */ ATTRIB(Buff, m_itemid, int, 0) ATTRIB(Buff, m_name, string, "buff") ATTRIB(Buff, m_color, vector, '1 1 1') ATTRIB(Buff, m_prettyName, string, "Buff") ATTRIB(Buff, m_skin, int, 0) ATTRIB(Buff, m_sprite, string, "") METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) { returns(this.m_prettyName, sprintf("/gfx/hud/%s/buff_%s", cvar_string("menu_skin"), this.m_name)); } #ifdef SVQC METHOD(Buff, m_time, float(entity)); float Buff_m_time(entity this) { return cvar(strcat("g_buffs_", this.netname, "_time")); } #endif ENDCLASS(Buff) REGISTER_BUFF(Null); REGISTER_BUFF(AMMO) { this.m_prettyName = _("Ammo"); this.m_name = "ammo"; this.m_skin = 3; this.m_color = '0.76 1 0.1'; } REGISTER_BUFF(RESISTANCE) { this.m_prettyName = _("Resistance"); this.m_name = "resistance"; this.m_skin = 0; this.m_color = '0.36 1 0.07'; } REGISTER_BUFF(SPEED) { this.m_prettyName = _("Speed"); this.m_name = "speed"; this.m_skin = 9; this.m_color = '0.1 1 0.84'; } REGISTER_BUFF(MEDIC) { this.m_prettyName = _("Medic"); this.m_name = "medic"; this.m_skin = 1; this.m_color = '1 0.12 0'; } REGISTER_BUFF(BASH) { this.m_prettyName = _("Bash"); this.m_name = "bash"; this.m_skin = 5; this.m_color = '1 0.39 0'; } REGISTER_BUFF(VAMPIRE) { this.m_prettyName = _("Vampire"); this.m_name = "vampire"; this.m_skin = 2; this.m_color = '1 0 0.24'; } REGISTER_BUFF(DISABILITY) { this.m_prettyName = _("Disability"); this.m_name = "disability"; this.m_skin = 7; this.m_color = '0.94 0.3 1'; } REGISTER_BUFF(VENGEANCE) { this.m_prettyName = _("Vengeance"); this.m_name = "vengeance"; this.m_skin = 15; this.m_color = '1 0.23 0.61'; } REGISTER_BUFF(JUMP) { this.m_prettyName = _("Jump"); this.m_name = "jump"; this.m_skin = 10; this.m_color = '0.24 0.78 1'; } REGISTER_BUFF(FLIGHT) { this.m_prettyName = _("Flight"); this.m_name = "flight"; this.m_skin = 11; this.m_color = '0.33 0.56 1'; } REGISTER_BUFF(INVISIBLE) { this.m_prettyName = _("Invisible"); this.m_name = "invisible"; this.m_skin = 12; this.m_color = '0.5 0.5 1'; } REGISTER_BUFF(INFERNO) { this.m_prettyName = _("Inferno"); this.m_name = "inferno"; this.m_skin = 16; this.m_color = '1 0.62 0'; } REGISTER_BUFF(SWAPPER) { this.m_prettyName = _("Swapper"); this.m_name = "swapper"; this.m_skin = 17; this.m_color = '0.63 0.36 1'; } REGISTER_BUFF(MAGNET) { this.m_prettyName = _("Magnet"); this.m_name = "magnet"; this.m_skin = 18; this.m_color = '1 0.95 0.18'; } #ifdef SVQC .int buffs; void buff_Init(entity ent); void buff_Init_Compat(entity ent, entity replacement); #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \ self.buffs = b.m_itemid; \ self.team = t; \ buff_Init(self); \ } #define BUFF_SPAWNFUNCS(e, b) \ BUFF_SPAWNFUNC(e, b, 0) \ BUFF_SPAWNFUNC(e##_team1, b, NUM_TEAM_1) \ BUFF_SPAWNFUNC(e##_team2, b, NUM_TEAM_2) \ BUFF_SPAWNFUNC(e##_team3, b, NUM_TEAM_3) \ BUFF_SPAWNFUNC(e##_team4, b, NUM_TEAM_4) #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); } BUFF_SPAWNFUNCS(resistance, BUFF_RESISTANCE) BUFF_SPAWNFUNCS(ammo, BUFF_AMMO) BUFF_SPAWNFUNCS(speed, BUFF_SPEED) BUFF_SPAWNFUNCS(medic, BUFF_MEDIC) BUFF_SPAWNFUNCS(bash, BUFF_BASH) BUFF_SPAWNFUNCS(vampire, BUFF_VAMPIRE) BUFF_SPAWNFUNCS(disability, BUFF_DISABILITY) BUFF_SPAWNFUNCS(vengeance, BUFF_VENGEANCE) BUFF_SPAWNFUNCS(jump, BUFF_JUMP) BUFF_SPAWNFUNCS(flight, BUFF_FLIGHT) BUFF_SPAWNFUNCS(invisible, BUFF_INVISIBLE) BUFF_SPAWNFUNCS(inferno, BUFF_INFERNO) BUFF_SPAWNFUNCS(swapper, BUFF_SWAPPER) BUFF_SPAWNFUNCS(magnet, BUFF_MAGNET) BUFF_SPAWNFUNCS(random, BUFF_Null) BUFF_SPAWNFUNC_Q3TA_COMPAT(doubler, BUFF_MEDIC) BUFF_SPAWNFUNC_Q3TA_COMPAT(resistance, BUFF_RESISTANCE) BUFF_SPAWNFUNC_Q3TA_COMPAT(scout, BUFF_SPEED) BUFF_SPAWNFUNC_Q3TA_COMPAT(ammoregen, BUFF_AMMO) // actually Q3 BUFF_SPAWNFUNC_Q3TA_COMPAT(haste, BUFF_SPEED) BUFF_SPAWNFUNC_Q3TA_COMPAT(invis, BUFF_INVISIBLE) BUFF_SPAWNFUNC_Q3TA_COMPAT(medic, BUFF_MEDIC) #undef BUFF_SPAWNFUNC #undef BUFF_SPAWNFUNC_Q3TA_COMPAT #undef BUFF_SPAWNFUNCS #endif #endif