]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/items/item/pickup.qh
Support #ifdef in item declarations
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item / pickup.qh
1 #ifndef PICKUP_H
2 #define PICKUP_H
3 #include "../item.qh"
4 CLASS(Pickup, GameItem)
5     METHOD(Pickup, respondTo, bool(entity, int))
6     ATTRIB(Pickup, m_model, string, string_null)
7     ATTRIB(Pickup, m_sound, string, string_null)
8     ATTRIB(Pickup, m_name, string, string_null)
9     ATTRIB(Pickup, m_itemid, int, 0)
10 #ifdef SVQC
11     ATTRIB(Pickup, m_botvalue, int, 0)
12     ATTRIB(Pickup, m_respawntime, int, 0)
13     ATTRIB(Pickup, m_respawntimejitter, int, 0)
14 #endif
15 ENDCLASS(Pickup)
16
17 #define SPAWNTIMES(_) \
18     _(WEAPON, weapon) \
19     _(AMMO, ammo) \
20     _(SHORT, short) \
21     _(MEDIUM, medium) \
22     _(LONG, long) \
23     /**/
24
25 #define SPAWNTIMES_ENUM(id, idlc) SPAWNTIME_##id ,
26 enum { SPAWNTIMES(SPAWNTIMES_ENUM) };
27 #undef SPAWNTIMES_ENUM
28
29 #ifdef SVQC
30 #include "../../../server/defs.qh"
31
32 #define SPAWNTIMES_MAP(id, idlc) i == SPAWNTIME_##id ? g_pickup_respawntime_##idlc :
33 [[inline]] int spawntime(int i) { return SPAWNTIMES(SPAWNTIMES_MAP) 0; }
34 #undef SPAWNTIMES_MAP
35
36 #define SPAWNTIMES_MAP(id, idlc) i == SPAWNTIME_##id ? g_pickup_respawntimejitter_##idlc :
37 [[inline]] int spawntimejitter(int i) { return SPAWNTIMES(SPAWNTIMES_MAP) 0; }
38 #undef SPAWNTIMES_MAP
39 #endif
40
41 bool Pickup_respondTo(entity this, int request)
42 {
43     switch (request) {
44         default: return false;
45         case ITEM_SIGNAL(Default):
46             print(strcat(this.m_name, " responding\n"));
47             return true;
48     }
49 }
50
51 #endif