From: TimePath Date: Tue, 12 May 2015 09:15:29 +0000 (+1000) Subject: Add powerups X-Git-Tag: xonotic-v0.8.1~53^2~10 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=b1f6de909c221e0250aaeb9561cdd44b9e16a76c;p=xonotic%2Fxonotic-data.pk3dir.git Add powerups --- diff --git a/qcsrc/common/items/all.inc b/qcsrc/common/items/all.inc index aeee8d3e6..6e2a6ba8c 100644 --- a/qcsrc/common/items/all.inc +++ b/qcsrc/common/items/all.inc @@ -4,3 +4,4 @@ #include "item/armor.qc" #include "item/buff.qc" #include "item/health.qc" +#include "item/powerup.qc" diff --git a/qcsrc/common/items/item/ammo.qh b/qcsrc/common/items/item/ammo.qh index b7fcd13b2..41e2ac831 100644 --- a/qcsrc/common/items/item/ammo.qh +++ b/qcsrc/common/items/item/ammo.qh @@ -2,5 +2,8 @@ #define AMMO_H #include "pickup.qh" CLASS(Ammo, Pickup) +#ifdef SVQC + ATTRIB(Ammo, m_pickupevalfunc, float(entity player, entity item), commodity_pickupevalfunc) +#endif ENDCLASS(Ammo) #endif diff --git a/qcsrc/common/items/item/armor.qh b/qcsrc/common/items/item/armor.qh index 3ce853c0a..48a80f886 100644 --- a/qcsrc/common/items/item/armor.qh +++ b/qcsrc/common/items/item/armor.qh @@ -2,5 +2,8 @@ #define ARMOR_H #include "pickup.qh" CLASS(Armor, Pickup) +#ifdef SVQC + ATTRIB(Armor, m_pickupevalfunc, float(entity player, entity item), commodity_pickupevalfunc) +#endif ENDCLASS(Armor) #endif diff --git a/qcsrc/common/items/item/health.qh b/qcsrc/common/items/item/health.qh index 26d926ac3..15f1f8dd9 100644 --- a/qcsrc/common/items/item/health.qh +++ b/qcsrc/common/items/item/health.qh @@ -2,5 +2,8 @@ #define HEALTH_H #include "pickup.qh" CLASS(Health, Pickup) +#ifdef SVQC + ATTRIB(Health, m_pickupevalfunc, float(entity player, entity item), commodity_pickupevalfunc) +#endif ENDCLASS(Health) #endif diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index 67ddcd74e..edff6e592 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -9,6 +9,8 @@ CLASS(Pickup, GameItem) ATTRIB(Pickup, m_itemid, int, 0) #ifdef SVQC ATTRIB(Pickup, m_botvalue, int, 0) + ATTRIB(Pickup, m_itemflags, int, 0) + ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc) ATTRIB(Pickup, m_respawntime, int, 0) ATTRIB(Pickup, m_respawntimejitter, int, 0) #endif diff --git a/qcsrc/common/items/item/powerup.qc b/qcsrc/common/items/item/powerup.qc new file mode 100644 index 000000000..2bf0ddfd5 --- /dev/null +++ b/qcsrc/common/items/item/powerup.qc @@ -0,0 +1,36 @@ +#include "powerup.qh" +#include "../../../server/t_items.qh" + +#define WITH(it) this.m_##it; +#define CONFIGURE(...) MAP(WITH, __VA_ARGS__) +#define DEFINE(id, ...) \ + REGISTER_ITEM(id, Ammo, LAMBDA( \ + IF(SV, CONFIGURE \ + , botvalue = 100000 \ + , itemflags = FL_POWERUP \ + , respawntime = g_pickup_respawntime_powerup \ + , respawntimejitter = g_pickup_respawntimejitter_powerup \ + ) \ + MAP(IDENTITY, __VA_ARGS__) \ + )) + +DEFINE(Strength + ,IF(ALL, CONFIGURE + , model = "models/items/g_strength.md3" + , sound = "misc/powerup.wav" + , name = "Strength Powerup" + , itemid = IT_STRENGTH + ) +) +DEFINE(Shield + ,IF(ALL, CONFIGURE + , model = "models/items/g_invincible.md3" + , sound = "misc/powerup_shield.wav" + , name = "Shield" + , itemid = IT_INVINCIBLE + ) +) + +#undef WITH +#undef CONFIGURE +#undef DEFINE diff --git a/qcsrc/common/items/item/powerup.qh b/qcsrc/common/items/item/powerup.qh new file mode 100644 index 000000000..d27c1e60f --- /dev/null +++ b/qcsrc/common/items/item/powerup.qh @@ -0,0 +1,12 @@ +#ifndef POWERUP_H +#define POWERUP_H +#include "pickup.qh" +CLASS(Powerup, Pickup) +ENDCLASS(Powerup) + +#ifdef SVQC +// For FL_POWERUP +#include "../../../server/constants.qh" +#endif + +#endif diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 625bdf71d..0b0b1a6ed 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -1156,7 +1156,7 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, void StartItemA (entity a) { - StartItem(a.m_model, a.m_sound, a.m_respawntime, a.m_respawntimejitter, a.m_name, a.m_itemid, 0, 0, commodity_pickupevalfunc, a.m_botvalue); + StartItem(a.m_model, a.m_sound, a.m_respawntime, a.m_respawntimejitter, a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue); } void spawnfunc_item_rockets (void) { @@ -1311,13 +1311,13 @@ void spawnfunc_item_strength (void) { precache_sound("weapons/strength_fire.wav"); if(!self.strength_finished) self.strength_finished = autocvar_g_balance_powerup_strength_time; - StartItem ("models/items/g_strength.md3", "misc/powerup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Strength Powerup", IT_STRENGTH, 0, FL_POWERUP, generic_pickupevalfunc, 100000); + StartItemA (ITEM_Strength); } void spawnfunc_item_invincible (void) { if(!self.invincible_finished) self.invincible_finished = autocvar_g_balance_powerup_invincible_time; - StartItem ("models/items/g_invincible.md3", "misc/powerup_shield.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Shield", IT_INVINCIBLE, 0, FL_POWERUP, generic_pickupevalfunc, 100000); + StartItemA (ITEM_Shield); } // compatibility: