]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add powerups
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 12 May 2015 09:15:29 +0000 (19:15 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 12 May 2015 09:15:29 +0000 (19:15 +1000)
qcsrc/common/items/all.inc
qcsrc/common/items/item/ammo.qh
qcsrc/common/items/item/armor.qh
qcsrc/common/items/item/health.qh
qcsrc/common/items/item/pickup.qh
qcsrc/common/items/item/powerup.qc [new file with mode: 0644]
qcsrc/common/items/item/powerup.qh [new file with mode: 0644]
qcsrc/server/t_items.qc

index aeee8d3e6e1dffc8e75aa5e369bdf1ddb5549d2d..6e2a6ba8c4f7216f6179046f2c2b7652ff056881 100644 (file)
@@ -4,3 +4,4 @@
 #include "item/armor.qc"
 #include "item/buff.qc"
 #include "item/health.qc"
+#include "item/powerup.qc"
index b7fcd13b291f66c9bc2c7a8a3555f14081faa80a..41e2ac831c25b1dca2e7b1a54d635cf9864eb666 100644 (file)
@@ -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
index 3ce853c0a9cc0cde19bce5cbe2ff2d96d4e93c54..48a80f886af4f8278d0326e0f85d17969cdfc2b3 100644 (file)
@@ -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
index 26d926ac3fdf34fa374e2032960fbee74282788d..15f1f8dd91a4213b32c3bd51c10673e2fe76e466 100644 (file)
@@ -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
index 67ddcd74ed3f815ef312033be6043422338882e5..edff6e5928ae746d99810e7b6d14b21df5418e3e 100644 (file)
@@ -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 (file)
index 0000000..2bf0ddf
--- /dev/null
@@ -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 (file)
index 0000000..d27c1e6
--- /dev/null
@@ -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
index 625bdf71dddc6cc5ca28ddcb72632ba0387dded1..0b0b1a6ed7b7fee7c8f7883161f9b685249b5c50 100644 (file)
@@ -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: