]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'remotes/origin/master' into TimePath/itemsys
authorTimePath <andrew.hardaker1995@gmail.com>
Fri, 3 Jul 2015 06:29:25 +0000 (16:29 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Fri, 3 Jul 2015 06:29:25 +0000 (16:29 +1000)
# Conflicts:
# qcsrc/client/main.qc
# qcsrc/client/progs.src
# qcsrc/menu/menu.qc
# qcsrc/menu/progs.src
# qcsrc/server/g_world.qc

35 files changed:
qcsrc/client/main.qc
qcsrc/client/progs.src
qcsrc/common/command/generic.qc
qcsrc/common/constants.qh
qcsrc/common/items/all.inc [new file with mode: 0644]
qcsrc/common/items/all.qc [new file with mode: 0644]
qcsrc/common/items/all.qh [new file with mode: 0644]
qcsrc/common/items/inventory.qh [new file with mode: 0644]
qcsrc/common/items/item.qh [new file with mode: 0644]
qcsrc/common/items/item/ammo.qc [new file with mode: 0644]
qcsrc/common/items/item/ammo.qh [new file with mode: 0644]
qcsrc/common/items/item/armor.qc [new file with mode: 0644]
qcsrc/common/items/item/armor.qh [new file with mode: 0644]
qcsrc/common/items/item/buff.qc [new file with mode: 0644]
qcsrc/common/items/item/buff.qh [new file with mode: 0644]
qcsrc/common/items/item/health.qc [new file with mode: 0644]
qcsrc/common/items/item/health.qh [new file with mode: 0644]
qcsrc/common/items/item/jetpack.qc [new file with mode: 0644]
qcsrc/common/items/item/pickup.qc [new file with mode: 0644]
qcsrc/common/items/item/pickup.qh [new file with mode: 0644]
qcsrc/common/items/item/powerup.qc [new file with mode: 0644]
qcsrc/common/items/item/powerup.qh [new file with mode: 0644]
qcsrc/common/oo.qh [new file with mode: 0644]
qcsrc/common/util-pre.qh
qcsrc/menu/menu.qc
qcsrc/menu/oo/base.qh
qcsrc/menu/progs.src
qcsrc/server/cl_client.qc
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/mutator_instagib.qc
qcsrc/server/progs.src
qcsrc/server/t_items.qc
qcsrc/server/t_items.qh

index 298bcdbefefff66e1b26993c8dd3b23a41f1e842..7648b129775afa875f38ff5e16de5339c62c3a80 100644 (file)
@@ -39,6 +39,8 @@
 #include "../common/stats.qh"
 #include "../common/teams.qh"
 
+#include "../common/items/all.qh"
+
 #include "../common/weapons/all.qh"
 
 #include "../csqcmodellib/cl_model.qh"
@@ -136,6 +138,7 @@ void CSQC_Init(void)
        // needs to be done so early because of the constants they create
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
        CALL_ACCUMULATED_FUNCTION(RegisterMonsters);
+       CALL_ACCUMULATED_FUNCTION(RegisterItems);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
@@ -856,6 +859,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_WARPZONE_TELEPORTED: WarpZone_Teleported_Read(bIsNewEntity); break;
                case ENT_CLIENT_TRIGGER_MUSIC: Ent_ReadTriggerMusic(); break;
                case ENT_CLIENT_HOOK: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_HOOK); break;
+               case ENT_CLIENT_INVENTORY: Inventory_Read(self); break;
                case ENT_CLIENT_ARC_BEAM: Ent_ReadArcBeam(bIsNewEntity); break;
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
index 843ae12a47f6b4b1860744929bde122136ed898e..8ba12b9e71d957c7260fcbd09dbf80b562c9b4ee 100644 (file)
@@ -55,6 +55,8 @@ weapons/projectile.qc // TODO
 ../common/urllib.qc
 ../common/util.qc
 
+../common/items/all.qc
+
 ../common/monsters/all.qc
 
 ../common/weapons/all.qc // TODO
index f0b6d0de5aecf72f81231100431fbc908a0fb037..6aa93a024ed209475f9a4b5d673e4654b46312a5 100644 (file)
@@ -241,6 +241,25 @@ void GenericCommand_dumpcommands(float request)
        }
 }
 
+void GenericCommand_dumpitems(float request)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       Dump_Items();
+                       return;
+               }
+
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       printf("\nUsage:^3 %s dumpitems", GetProgramCommandPrefix());
+                       return;
+               }
+       }
+}
+
 void GenericCommand_dumpnotifs(float request)
 {
        switch(request)
@@ -651,6 +670,7 @@ void GenericCommand_(float request)
 #define GENERIC_COMMANDS(request,arguments,command) \
        GENERIC_COMMAND("addtolist", GenericCommand_addtolist(request, arguments), "Add a string to a cvar") \
        GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \
+       GENERIC_COMMAND("dumpitems", GenericCommand_dumpitems(request), "Dump all items to the console") \
        GENERIC_COMMAND("dumpnotifs", GenericCommand_dumpnotifs(request), "Dump all notifications into notifications_dump.txt") \
        GENERIC_COMMAND("dumpweapons", GenericCommand_dumpweapons(request), "Dump all weapons into weapons_dump.txt") \
        GENERIC_COMMAND("maplist", GenericCommand_maplist(request, arguments), "Automatic control of maplist") \
index 45a65abbe96bd904bae1c3e93007637ba5d8b581..8c7cb6b3af6c8ec46693b0bce89511f1a191c1b8 100644 (file)
@@ -64,6 +64,7 @@ const int ENT_CLIENT_WARPZONE = 24;
 const int ENT_CLIENT_WARPZONE_CAMERA = 25;
 const int ENT_CLIENT_TRIGGER_MUSIC = 26;
 const int ENT_CLIENT_HOOK = 27;
+const int ENT_CLIENT_INVENTORY = 28;
 const int ENT_CLIENT_ARC_BEAM = 29; // WEAPONTODO: fix numbers
 const int ENT_CLIENT_ACCURACY = 30;
 const int ENT_CLIENT_SHOWNAMES = 31;
diff --git a/qcsrc/common/items/all.inc b/qcsrc/common/items/all.inc
new file mode 100644 (file)
index 0000000..2c4f1de
--- /dev/null
@@ -0,0 +1,7 @@
+#include "item/ammo.qc"
+#include "item/armor.qc"
+#include "item/buff.qc"
+#include "item/health.qc"
+#include "item/jetpack.qc"
+#include "item/pickup.qc"
+#include "item/powerup.qc"
diff --git a/qcsrc/common/items/all.qc b/qcsrc/common/items/all.qc
new file mode 100644 (file)
index 0000000..fa198bb
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef ALL_C
+#define ALL_C
+#include "all.qh"
+
+#include "all.inc"
+
+void Dump_Items()
+{
+    ITEMS_FOREACH(true, LAMBDA({
+        ITEM_HANDLE(Show, it);
+    }));
+}
+
+#endif
diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh
new file mode 100644 (file)
index 0000000..1786b42
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef ALL_H
+#define ALL_H
+
+const int MAX_ITEMS = 24;
+entity ITEMS[MAX_ITEMS];
+
+#define ITEMS_FOREACH(pred, body) do {      \
+    for (int i = 0; i < ITEM_COUNT; i++) {  \
+        const noref entity it = ITEMS[i];   \
+        if (pred) { body }                  \
+    }                                       \
+} while(0)
+
+void RegisterItems();
+void Dump_Items();
+
+#endif
+
+#include "inventory.qh"
diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh
new file mode 100644 (file)
index 0000000..89abc97
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef INVENTORY_H
+#define INVENTORY_H
+
+#include "all.qh"
+#include "item/pickup.qh"
+
+entityclass(Inventory);
+/** Stores counts of items, the id being the index */
+class(Inventory) .int inv_items[MAX_ITEMS];
+
+/** Player inventory; Inventories also have one inventory for storing the previous state */
+.Inventory inventory;
+
+#ifdef CSQC
+void Inventory_Read(Inventory data)
+{
+    const int bits = ReadInt24_t();
+    ITEMS_FOREACH(bits & BIT(i), LAMBDA({
+        .int fld = inv_items[i];
+        int prev = data.(fld);
+        int next = data.(fld) = ReadByte();
+        dprintf("%s: %.0f -> %.0f\n", ITEMS[i].m_name, prev, next);
+    }));
+}
+#endif
+
+#ifdef SVQC
+void Inventory_Write(Inventory data)
+{
+    int bits = 0;
+    ITEMS_FOREACH(true, LAMBDA({
+        .int fld = inv_items[i];
+        bits = BITSET(bits, BIT(i), data.inventory.(fld) != (data.inventory.(fld) = data.(fld)));
+    }));
+    WriteInt24_t(MSG_ENTITY, bits);
+    ITEMS_FOREACH(bits & BIT(i), LAMBDA({
+        WriteByte(MSG_ENTITY, data.inv_items[i]);
+    }));
+}
+#endif
+
+#ifdef SVQC
+bool Inventory_Send(entity to, int sf)
+{
+    WriteByte(MSG_ENTITY, ENT_CLIENT_INVENTORY);
+    entity e = self.owner;
+    if (IS_SPEC(e)) e = e.enemy;
+    Inventory data = e.inventory;
+    Inventory_Write(data);
+    return true;
+}
+
+void Inventory_new(entity e)
+{
+    Inventory inv = new(Inventory), bak = new(Inventory);
+    inv.classname = "inventory", bak.classname = "inventory";
+    inv.inventory = bak;
+    inv.drawonlytoclient = e;
+    Net_LinkEntity((inv.owner = e).inventory = inv, false, 0, Inventory_Send);
+}
+void Inventory_delete(entity e) { remove(e.inventory.inventory); remove(e.inventory); }
+void Inventory_update(entity e) { e.inventory.SendFlags = 0xFFFFFF; }
+#endif
+
+#endif
diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh
new file mode 100644 (file)
index 0000000..da4e7a4
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef GAMEITEM_H
+#define GAMEITEM_H
+#include "../oo.qh"
+#define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
+CLASS(GameItem, Object)
+    ATTRIB(GameItem, m_id, int, 0)
+    METHOD(GameItem, show, void(entity this))
+    void GameItem_show(entity this) { print("A game item\n"); }
+    void ITEM_HANDLE(Show, entity this) { this.show(this); }
+ENDCLASS(GameItem)
+
+
+int ITEM_COUNT;
+#define REGISTER_ITEM(id, class, body)          \
+    entity ITEM_##id;                           \
+    void RegisterItems_##id() {                 \
+        const entity this = NEW(class);         \
+        ITEM_##id = this;                       \
+        this.m_id = ITEM_COUNT;                 \
+        ITEMS[ITEM_COUNT++] = this;             \
+        body                                    \
+    }                                           \
+    ACCUMULATE_FUNCTION(RegisterItems, RegisterItems_##id)
+
+#endif
diff --git a/qcsrc/common/items/item/ammo.qc b/qcsrc/common/items/item/ammo.qc
new file mode 100644 (file)
index 0000000..032fcc3
--- /dev/null
@@ -0,0 +1,70 @@
+#include "ammo.qh"
+#ifdef SVQC
+    #include "../../../server/t_items.qh"
+#endif
+
+#define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+#define DEFINE(id, ...)                                                 \
+    REGISTER_ITEM(id, Ammo, LAMBDA(                                     \
+        IF(SV, CONFIGURE                                                \
+        ,   respawntime         =       GET(g_pickup_respawntime_ammo)  \
+        ,   respawntimejitter   = GET(g_pickup_respawntimejitter_ammo)  \
+        )                                                               \
+        UNWORDS(__VA_ARGS__)                                            \
+    ))
+
+DEFINE(Bullets
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/a_bullets.mdl"
+    ,   name                =   "bullets"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   2000
+    ,   itemid              =   IT_NAILS
+    )
+)
+DEFINE(Cells
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/a_cells.md3"
+    ,   name                =   "cells"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   2000
+    ,   itemid              =   IT_CELLS
+    )
+)
+DEFINE(Plasma
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/a_cells.md3"
+    ,   name                =   "plasma"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   2000
+    ,   itemid              =   IT_PLASMA
+    )
+)
+DEFINE(Rockets
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/a_rockets.md3"
+    ,   name                =   "rockets"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   3000
+    ,   itemid              =   IT_ROCKETS
+    )
+)
+DEFINE(Shells
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/a_shells.md3"
+    ,   name                =   "shells"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   500
+    ,   itemid              =   IT_SHELLS
+    )
+)
+
+#undef WITH
+#undef CONFIGURE
+#undef DEFINE
diff --git a/qcsrc/common/items/item/ammo.qh b/qcsrc/common/items/item/ammo.qh
new file mode 100644 (file)
index 0000000..41e2ac8
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef AMMO_H
+#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.qc b/qcsrc/common/items/item/armor.qc
new file mode 100644 (file)
index 0000000..8fed098
--- /dev/null
@@ -0,0 +1,68 @@
+#include "armor.qh"
+#ifdef SVQC
+    #include "../../../server/t_items.qh"
+#endif
+
+#define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+#define DEFINE(id, ...) REGISTER_ITEM(id, Armor, UNWORDS(__VA_ARGS__))
+
+DEFINE(ArmorSmall
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/item_armor_small.md3"
+    ,   sound               =   "misc/armor1.wav"
+    ,   name                =   "5 Armor"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_LOW
+    ,   itemid              =   IT_ARMOR_SHARD
+    ,   respawntime         =         GET(g_pickup_respawntime_short)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_short)
+    )
+)
+
+DEFINE(ArmorMedium
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/item_armor_medium.md3"
+    ,   sound               =   "misc/armor10.wav"
+    ,   name                =   "25 Armor"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_MID
+    ,   itemid              =   IT_ARMOR
+    ,   respawntime         =         GET(g_pickup_respawntime_medium)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_medium)
+    )
+)
+
+DEFINE(ArmorBig
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/item_armor_big.md3"
+    ,   sound               =   "misc/armor17_5.wav"
+    ,   name                =   "50 Armor"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH?
+    ,   itemid              =   IT_ARMOR
+    ,   respawntime         =         GET(g_pickup_respawntime_long)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_long)
+    )
+)
+
+DEFINE(ArmorLarge
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/item_armor_large.md3"
+    ,   sound               =   "misc/armor25.wav"
+    ,   name                =   "100 Armor"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_HIGH
+    ,   itemid              =   IT_ARMOR
+    ,   respawntime         =         GET(g_pickup_respawntime_long)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_long)
+    )
+)
+
+#undef WITH
+#undef CONFIGURE
+#undef DEFINE
diff --git a/qcsrc/common/items/item/armor.qh b/qcsrc/common/items/item/armor.qh
new file mode 100644 (file)
index 0000000..48a80f8
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef ARMOR_H
+#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/buff.qc b/qcsrc/common/items/item/buff.qc
new file mode 100644 (file)
index 0000000..d9420d1
--- /dev/null
@@ -0,0 +1,3 @@
+#include "buff.qh"
+
+REGISTER_ITEM(DefaultBuff, Buff, LAMBDA())
diff --git a/qcsrc/common/items/item/buff.qh b/qcsrc/common/items/item/buff.qh
new file mode 100644 (file)
index 0000000..4ad93cb
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef BUFF_H
+#define BUFF_H
+#include "pickup.qh"
+CLASS(Buff, Pickup)
+    ATTRIB(Buff, m_name, string, "Buff")
+ENDCLASS(Buff)
+#endif
diff --git a/qcsrc/common/items/item/health.qc b/qcsrc/common/items/item/health.qc
new file mode 100644 (file)
index 0000000..08b422d
--- /dev/null
@@ -0,0 +1,68 @@
+#include "health.qh"
+#ifdef SVQC
+    #include "../../../server/t_items.qh"
+#endif
+
+#define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+#define DEFINE(id, ...) REGISTER_ITEM(id, Health, UNWORDS(__VA_ARGS__))
+
+DEFINE(HealthSmall
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_h1.md3"
+    ,   sound               =   "misc/minihealth.wav"
+    ,   name                =   "5 Health"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_LOW
+    ,   itemid              =   IT_5HP
+    ,   respawntime         =         GET(g_pickup_respawntime_short)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_short)
+    )
+)
+
+DEFINE(HealthMedium
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_h25.md3"
+    ,   sound               =   "misc/mediumhealth.wav"
+    ,   name                =   "25 Health"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_MID
+    ,   itemid              =   IT_25HP
+    ,   respawntime         =         GET(g_pickup_respawntime_short)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_short)
+    )
+)
+
+DEFINE(HealthLarge
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_h50.md3"
+    ,   sound               =   "misc/mediumhealth.wav"
+    ,   name                =   "50 Health"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_MID
+    ,   itemid              =   IT_25HP
+    ,   respawntime         =         GET(g_pickup_respawntime_medium)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_medium)
+    )
+)
+
+DEFINE(HealthMega
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_h100.md3"
+    ,   sound               =   "misc/megahealth.wav"
+    ,   name                =   "100 Health"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_HIGH
+    ,   itemid              =   IT_HEALTH
+    ,   respawntime         =         GET(g_pickup_respawntime_long)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_long)
+    )
+)
+
+#undef WITH
+#undef CONFIGURE
+#undef DEFINE
diff --git a/qcsrc/common/items/item/health.qh b/qcsrc/common/items/item/health.qh
new file mode 100644 (file)
index 0000000..15f1f8d
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef HEALTH_H
+#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/jetpack.qc b/qcsrc/common/items/item/jetpack.qc
new file mode 100644 (file)
index 0000000..9ff4ed0
--- /dev/null
@@ -0,0 +1,56 @@
+#ifdef SVQC
+    #include "../../../server/t_items.qh"
+    #include "../../../server/constants.qh"
+#endif
+
+#define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+#define DEFINE(id, ...) REGISTER_ITEM(id, Pickup, UNWORDS(__VA_ARGS__))
+
+DEFINE(Jetpack
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_jetpack.md3"
+    ,   name                =   "Jet pack"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_LOW
+    ,   itemflags           =   FL_POWERUP
+    ,   itemid              =   IT_JETPACK
+    ,   pickupevalfunc      =   commodity_pickupevalfunc
+    ,   respawntime         =         GET(g_pickup_respawntime_powerup)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup)
+    )
+)
+
+DEFINE(JetpackFuel
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_fuel.md3"
+    ,   name                =   "Fuel"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_LOW
+    ,   itemid              =   IT_FUEL
+    ,   pickupevalfunc      =   commodity_pickupevalfunc
+    ,   respawntime         =         GET(g_pickup_respawntime_ammo)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_ammo)
+    )
+)
+
+DEFINE(JetpackRegen
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_fuelregen.md3"
+    ,   name                =   "Fuel regenerator"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_LOW
+    ,   itemflags           =   FL_POWERUP
+    ,   itemid              =   IT_FUEL_REGEN
+    ,   pickupevalfunc      =   commodity_pickupevalfunc
+    ,   respawntime         =         GET(g_pickup_respawntime_powerup)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup)
+    )
+)
+
+#undef WITH
+#undef CONFIGURE
+#undef DEFINE
diff --git a/qcsrc/common/items/item/pickup.qc b/qcsrc/common/items/item/pickup.qc
new file mode 100644 (file)
index 0000000..35aac2b
--- /dev/null
@@ -0,0 +1,13 @@
+#include "pickup.qh"
+
+#ifdef SVQC
+bool ITEM_HANDLE(Pickup, entity this, entity item, entity player) {
+    bool b = this.giveTo(this, item, player);
+    if (b) {
+        dprintf("entity %i picked up %s\n", player, this.m_name);
+        player.inventory.inv_items[this.m_id]++;
+        Inventory_update(player);
+    }
+    return b;
+}
+#endif
diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh
new file mode 100644 (file)
index 0000000..1875517
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef PICKUP_H
+#define PICKUP_H
+#include "../item.qh"
+CLASS(Pickup, GameItem)
+    ATTRIB(Pickup, m_model, string, string_null)
+    ATTRIB(Pickup, m_sound, string, "misc/itempickup.wav")
+    ATTRIB(Pickup, m_name, string, string_null)
+    METHOD(Pickup, show, void(entity this))
+    void Pickup_show(entity this) { printf("%s: %s\n", etos(this), this.m_name); }
+#ifdef SVQC
+    ATTRIB(Pickup, m_botvalue, int, 0)
+    ATTRIB(Pickup, m_itemflags, int, 0)
+    ATTRIB(Pickup, m_itemid, int, 0)
+    ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc)
+    ATTRIB(Pickup, m_respawntime, float(), func_null)
+    ATTRIB(Pickup, m_respawntimejitter, float(), func_null)
+    METHOD(Pickup, giveTo, bool(entity this, entity item, entity player))
+    bool Pickup_giveTo(entity this, entity item, entity player) { return Item_GiveTo(item, player); }
+    bool ITEM_HANDLE(Pickup, entity this, entity item, entity player);
+#endif
+ENDCLASS(Pickup)
+
+#ifdef SVQC
+// For g_pickup_respawntime
+#include "../../../server/defs.qh"
+// Getters to dynamically retrieve the values of g_pickup_respawntime*
+GETTER(float, g_pickup_respawntime_weapon)
+GETTER(float, g_pickup_respawntime_superweapon)
+GETTER(float, g_pickup_respawntime_ammo)
+GETTER(float, g_pickup_respawntime_short)
+GETTER(float, g_pickup_respawntime_medium)
+GETTER(float, g_pickup_respawntime_long)
+GETTER(float, g_pickup_respawntime_powerup)
+GETTER(float, g_pickup_respawntimejitter_weapon)
+GETTER(float, g_pickup_respawntimejitter_superweapon)
+GETTER(float, g_pickup_respawntimejitter_ammo)
+GETTER(float, g_pickup_respawntimejitter_short)
+GETTER(float, g_pickup_respawntimejitter_medium)
+GETTER(float, g_pickup_respawntimejitter_long)
+GETTER(float, g_pickup_respawntimejitter_powerup)
+
+#endif
+
+#endif
diff --git a/qcsrc/common/items/item/powerup.qc b/qcsrc/common/items/item/powerup.qc
new file mode 100644 (file)
index 0000000..f10a97e
--- /dev/null
@@ -0,0 +1,40 @@
+#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         =         GET(g_pickup_respawntime_powerup) \
+        ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup) \
+        )                                                                   \
+        UNWORDS(__VA_ARGS__)                                          \
+    ))
+
+DEFINE(Strength
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_strength.md3"
+    ,   sound               =   "misc/powerup.wav"
+    ,   name                =   "Strength Powerup"
+    )
+    ,IF(SV, CONFIGURE
+    ,   itemid              =   IT_STRENGTH
+    )
+)
+DEFINE(Shield
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_invincible.md3"
+    ,   sound               =   "misc/powerup_shield.wav"
+    ,   name                =   "Shield"
+    )
+    ,IF(SV, CONFIGURE
+    ,   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
diff --git a/qcsrc/common/oo.qh b/qcsrc/common/oo.qh
new file mode 100644 (file)
index 0000000..63b1708
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef OO_H
+#define OO_H
+
+#ifdef MENUQC
+       #define NULL (null_entity)
+#else
+       #define NULL (world)
+#endif
+
+.string classname;
+.string vtblname;
+.entity vtblbase;
+entity spawnVtbl(entity this, entity base)
+{
+       entity vtbl = spawn();
+       copyentity(this, vtbl);
+       vtbl.vtblname = vtbl.classname;
+       vtbl.classname = "vtbl";
+       vtbl.vtblbase = base ? base : vtbl; // Top level objects use vtbl as base
+       return vtbl;
+}
+
+entity Object_vtbl;
+entity spawnObject(entity this, entity)
+{
+       this = spawn();
+       this.classname = "Object";
+       if (!Object_vtbl) Object_vtbl = spawnVtbl(this, NULL);
+       return this;
+}
+
+// Classes have a `spawn##cname(entity, entity)` constructor
+// The parameters are used as locals for [[accumulate]]
+
+// Macro to hide this implementation detail
+#define NEW(cname) (spawn##cname(NULL, NULL))
+
+#define CLASS(cname, base)                                                     \
+entity spawn##cname(entity this, entity basevtbl) {                            \
+    this = NEW(base); basevtbl = base##_vtbl;                                  \
+}
+
+#define METHOD(cname, name, prototype)                                         \
+prototype cname##_##name;                                                      \
+.prototype name;                                                               \
+[[accumulate]] entity spawn##cname(entity this, entity basevtbl) {             \
+    this.name = cname##_##name;                                                \
+}
+
+#define ATTRIB(cname, name, type, val)                                         \
+.type name;                                                                    \
+[[accumulate]] entity spawn##cname(entity this, entity basevtbl) {             \
+    this.name = val;                                                           \
+}
+
+#define ATTRIBARRAY(cname, name, type, cnt)                                    \
+.type name[cnt];
+
+#define ENDCLASS(cname)                                                        \
+.bool instanceOf##cname;                                                       \
+entity cname##_vtbl;                                                           \
+[[accumulate]] [[last]] entity spawn##cname(entity this, entity basevtbl) {    \
+    this.instanceOf##cname = true;                                             \
+    this.classname = #cname;                                                   \
+    if (!cname##_vtbl) cname##_vtbl = spawnVtbl(this, basevtbl);               \
+    return this;                                                               \
+}
+
+#define SUPER(cname) (cname##_vtbl.vtblbase)
+
+#endif
index a1ac7dc7adeabd5793fd129a19e19a366431d67e..9d60ae0a9ae2797bfdaedea9632237e81554f564 100644 (file)
 [[deprecated("use true")]] [[alias("true")]] const bool TRUE;
 [[deprecated("use false")]] [[alias("false")]] const bool FALSE;
 
+#ifdef GMQCC
+    #define OVERLOAD(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
+#else
+    #define OVERLOAD_(F,_9,_8,_7,_6,_5,_4,_3,_2,_1,n,...) F##_##n
+    #define OVERLOAD(F, ...) OVERLOAD_(F,__VA_ARGS__,9,8,7,6,5,4,3,2,1)(__VA_ARGS__)
+#endif
+
+#define LAMBDA(...) { __VA_ARGS__ ; }
+
+#define MAP(f, ...) OVERLOAD(MAP, f, __VA_ARGS__)
+#define MAP_2(f, it) f(it)
+#define MAP_3(f, it, ...) f(it)MAP_2(f, __VA_ARGS__)
+#define MAP_4(f, it, ...) f(it)MAP_3(f, __VA_ARGS__)
+#define MAP_5(f, it, ...) f(it)MAP_4(f, __VA_ARGS__)
+#define MAP_6(f, it, ...) f(it)MAP_5(f, __VA_ARGS__)
+#define MAP_7(f, it, ...) f(it)MAP_6(f, __VA_ARGS__)
+#define MAP_8(f, it, ...) f(it)MAP_7(f, __VA_ARGS__)
+#define MAP_9(f, it, ...) f(it)MAP_8(f, __VA_ARGS__)
+#define MAP_10(f, it, ...) f(it)MAP_9(f, __VA_ARGS__)
+#define MAP_11(f, it, ...) f(it)MAP_10(f, __VA_ARGS__)
+#define MAP_12(f, it, ...) f(it)MAP_11(f, __VA_ARGS__)
+#define MAP_13(f, it, ...) f(it)MAP_12(f, __VA_ARGS__)
+#define MAP_14(f, it, ...) f(it)MAP_13(f, __VA_ARGS__)
+#define MAP_15(f, it, ...) f(it)MAP_14(f, __VA_ARGS__)
+#define MAP_16(f, it, ...) f(it)MAP_15(f, __VA_ARGS__)
+#define MAP_17(f, it, ...) f(it)MAP_16(f, __VA_ARGS__)
+#define MAP_18(f, it, ...) f(it)MAP_17(f, __VA_ARGS__)
+#define MAP_19(f, it, ...) f(it)MAP_18(f, __VA_ARGS__)
+#define MAP_20(f, it, ...) f(it)MAP_19(f, __VA_ARGS__)
+
+#define IDENTITY(it) it
+
+#define UNWORDS(...) MAP(IDENTITY, __VA_ARGS__)
+
+#define APPLY(f, ...) f(__VA_ARGS__)
+
+#ifdef SVQC
+    #define SV(f, ...) f(__VA_ARGS__)
+#else
+    #define SV(f, ...)
+#endif
+
+#ifdef CSQC
+    #define CL(f, ...) f(__VA_ARGS__)
+#else
+    #define CL(f, ...)
+#endif
+
+#define IF(cond, f, ...) cond(f, __VA_ARGS__)
+
+#define GET(name) name##get
+#define GETTER(type, name) type GET(name)() { return name; }
+
 #define BIT(n) (1 << (n))
-#define BITSET(var, mask, flag) (flag ? (var) | (mask) : (var) &~ (mask))
+#ifndef BRANCHLESS_BITSET
+    #define BITSET(var, mask, flag) (flag ? (var) | (mask) : (var) &~ (mask))
+#else
+    #define BITSET(var, mask, flag) ((var) ^ (-(flag) ^ (var)) & (mask))
+#endif
 
 #endif
index 70f4249d038436088a5d5b05ab19aefdf23208a5..d8a3ede2e7d8988afd29865a409af7de2defe772 100644 (file)
@@ -2,6 +2,7 @@
 #include "oo/classes.qc"
 #include "xonotic/util.qh"
 
+#include "../common/items/all.qh"
 #include "../common/weapons/all.qh"
 #include "../common/mapinfo.qh"
 
@@ -80,6 +81,7 @@ void m_init()
 
        // needs to be done so early because of the constants they create
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
+       CALL_ACCUMULATED_FUNCTION(RegisterItems);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
 
        RegisterSLCategories();
index 5c74f0d6dffaca4a914b2ea2aedeceb5d7d4ef6b..28b87ab7fca7e13d74ed3c6e12b3d04049c9cb41 100644 (file)
@@ -1,71 +1,11 @@
 #ifndef BASE_H
 #define BASE_H
 
+#include "../../common/oo.qh"
+
 #include "../../common/util.qh"
 #include "../../dpdefs/keycodes.qh"
 
-#define NULL (null_entity)
 #define world NULL
 
-.string classname;
-.string vtblname;
-.entity vtblbase;
-entity spawnVtbl(entity this, entity base)
-{
-       entity vtbl = spawn();
-       copyentity(this, vtbl);
-       vtbl.vtblname = vtbl.classname;
-       vtbl.classname = "vtbl";
-       vtbl.vtblbase = base ? base : vtbl; // Top level objects use vtbl as base
-       return vtbl;
-}
-
-entity Object_vtbl;
-entity spawnObject(entity this, entity)
-{
-       this = spawn();
-       this.classname = "Object";
-       if (!Object_vtbl) Object_vtbl = spawnVtbl(this, null_entity);
-       return this;
-}
-
-// Classes have a `spawn##cname(entity, entity)` constructor
-// The parameters are used as locals for [[accumulate]]
-
-// Macro to hide this implementation detail
-#define NEW(cname) (spawn##cname(null_entity, null_entity))
-
-#define CLASS(cname, base)                                          \
-entity spawn##cname(entity this, entity basevtbl) {                 \
-    this = NEW(base); basevtbl = base##_vtbl;                       \
-}
-
-#define METHOD(cname, name, prototype)                              \
-prototype cname##_##name;                                           \
-.prototype name;                                                    \
-[[accumulate]] entity spawn##cname(entity this, entity basevtbl) {  \
-    this.name = cname##_##name;                                     \
-}
-
-#define ATTRIB(cname, name, type, val)                              \
-.type name;                                                         \
-[[accumulate]] entity spawn##cname(entity this, entity basevtbl) {  \
-    this.name = val;                                                \
-}
-
-#define ATTRIBARRAY(cname, name, type, cnt)                         \
-.type name[cnt];
-
-#define ENDCLASS(cname)                                             \
-.bool instanceOf##cname;                                            \
-entity cname##_vtbl;                                                \
-[[last]] entity spawn##cname(entity this, entity basevtbl) {        \
-    this.instanceOf##cname = true;                                  \
-    this.classname = #cname;                                        \
-    if (!cname##_vtbl) cname##_vtbl = spawnVtbl(this, basevtbl);    \
-    return this;                                                    \
-}
-
-#define SUPER(cname) (cname##_vtbl.vtblbase)
-
-#endif
\ No newline at end of file
+#endif
index 636c862b7d0148f3915ca58e2f63ae1327fb89df..2315616d1701bfc29dbdbe8cc7c6ce04e8433092 100644 (file)
@@ -21,6 +21,8 @@ xonotic/util.qc
 ../common/urllib.qc
 ../common/util.qc
 
+../common/items/all.qc
+
 ../common/monsters/all.qc
 
 ../common/weapons/all.qc // TODO
index 259b7e260c3d2025707bb6e83f5964fda5cac480..b73eebbf4a021b95d270a97fb81ae62586d44287 100644 (file)
@@ -35,6 +35,8 @@
 
 #include "../common/net_notice.qh"
 
+#include "../common/items/inventory.qh"
+
 #include "../common/monsters/sv_monsters.qh"
 
 #include "../warpzonelib/server.qh"
@@ -1096,6 +1098,7 @@ void ClientConnect (void)
        PlayerScore_Attach(self);
        ClientData_Attach();
        accuracy_init(self);
+       Inventory_new(self);
 
        bot_clientconnect();
 
@@ -1338,6 +1341,7 @@ void ClientDisconnect (void)
        bot_relinkplayerlist();
 
        accuracy_free(self);
+       Inventory_delete(self);
        ClientData_Detach();
        PlayerScore_Detach(self);
 
index 3806d5eb240d84ca5a2f82a4bcacc4583cb1b3f3..a31670a08a050f6997b9eb6f81e2277e3cdfe584 100644 (file)
@@ -32,6 +32,7 @@
 #include "../common/stats.qh"
 #include "../common/teams.qh"
 #include "../common/util.qh"
+#include "../common/items/all.qh"
 #include "../common/weapons/all.qh"
 
 const float LATENCY_THINKRATE = 10;
@@ -558,6 +559,7 @@ void spawnfunc___init_dedicated_server(void)
        // needs to be done so early because of the constants they create
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
        CALL_ACCUMULATED_FUNCTION(RegisterMonsters);
+       CALL_ACCUMULATED_FUNCTION(RegisterItems);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
@@ -606,6 +608,7 @@ void spawnfunc_worldspawn (void)
        // needs to be done so early because of the constants they create
        CALL_ACCUMULATED_FUNCTION(RegisterWeapons);
        CALL_ACCUMULATED_FUNCTION(RegisterMonsters);
+       CALL_ACCUMULATED_FUNCTION(RegisterItems);
        CALL_ACCUMULATED_FUNCTION(RegisterGametypes);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
index 079df60f81fc501b03b411f4eb196006427f53ac..e8a1529e4e872209c96abef938ebde04875449fc 100644 (file)
@@ -1270,7 +1270,7 @@ void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer)
 }
 
 
-void Net_LinkEntity(entity e, float docull, float dt, bool(entity, int) sendfunc)
+void Net_LinkEntity(entity e, bool docull, float dt, bool(entity, int) sendfunc)
 {
     vector mi, ma;
 
index a8a9117d59e07307cc6677af1086fb776b0af8e9..3acc883608567ce81ac3051ddf77e508a4fd8e8d 100644 (file)
@@ -468,6 +468,6 @@ entity initialize_entity_first;
 float sound_allowed(float dest, entity e);
 void InitializeEntity(entity e, void(void) func, float order);
 void SetCustomizer(entity e, float(void) customizer, void(void) uncustomizer);
-void Net_LinkEntity(entity e, float docull, float dt, float(entity, float) sendfunc);
+void Net_LinkEntity(entity e, bool docull, float dt, bool(entity, int) sendfunc);
 
 #endif
index 2e6b195809da44ad840071cc7bebe7df1ef54eef..161dba90deb0c68d22f65ee5e65b96d4cf87de33 100644 (file)
@@ -5,23 +5,61 @@
 #include "../cl_client.qh"
 #include "../../common/buffs.qh"
 
+#include "../../common/items/item.qh"
+
+#define WITH(it) this.m_##it;
+#define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
+
+float instagib_respawntime_ammo = 45;
+float instagib_respawntimejitter_ammo = 0;
+GETTER(float, instagib_respawntime_ammo)
+GETTER(float, instagib_respawntimejitter_ammo)
+
+REGISTER_ITEM(VaporizerCells, Pickup, APPLY(UNWORDS
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/a_cells.md3"
+    ,   sound               =   "misc/itempickup.wav"
+    ,   name                =   "Vaporizer Ammo"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   100
+    ,   itemid              =   IT_CELLS
+    ,   respawntime         =         GET(instagib_respawntime_ammo)
+    ,   respawntimejitter   =   GET(instagib_respawntimejitter_ammo)
+    )
+))
+
+REGISTER_ITEM(ExtraLife, Pickup, APPLY(UNWORDS
+    ,APPLY(CONFIGURE
+    ,   model               =   "models/items/g_h100.md3"
+    ,   sound               =   "misc/megahealth.wav"
+    ,   name                =   "Extralife"
+    )
+    ,IF(SV, CONFIGURE
+    ,   botvalue            =   BOT_PICKUP_RATING_HIGH
+    ,   itemflags           =   FL_POWERUP
+    ,   itemid              =   IT_NAILS
+    ,   respawntime         =         GET(g_pickup_respawntime_powerup)
+    ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup)
+    )
+))
+
+#undef WITH
+#undef CONFIGURE
+
 void spawnfunc_item_minst_cells (void)
 {
        if (!g_instagib) { remove(self); return; }
        if (!self.ammo_cells)
                self.ammo_cells = autocvar_g_instagib_ammo_drop;
 
-       StartItem ("models/items/a_cells.md3",
-                          "misc/itempickup.wav", 45, 0,
-                          "Vaporizer Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
+       StartItemA (ITEM_VaporizerCells);
 }
 
 void instagib_health_mega()
 {
        self.max_health = 1;
-       StartItem ("models/items/g_h100.md3",
-                          "misc/megahealth.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
-                          "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+       StartItemA (ITEM_ExtraLife);
 }
 
 .float instagib_nextthink;
index a812de46a4c612e7f96641b6690ee92881c6ac49..75301d592972ee3e67ade8b01a84a72c7d188f19 100644 (file)
@@ -107,6 +107,9 @@ weapons/weaponsystem.qc
 ../common/test.qc
 ../common/urllib.qc
 ../common/util.qc
+
+../common/items/all.qc
+
 ../common/weapons/config.qc
 ../common/weapons/all.qc // TODO
 
index 515677bfa74decd23c7852262c92c979e1f1acb6..f817957c8213d62df0ea1dd856bb446760708728 100644 (file)
@@ -1,5 +1,7 @@
 #include "t_items.qh"
 
+#include "../common/items/all.qc"
+
 #if defined(SVQC)
     #include "_all.qh"
 
@@ -663,6 +665,8 @@ float Item_GiveTo(entity item, entity player)
        return 1;
 }
 
+.entity itemdef;
+
 void Item_Touch (void)
 {
        entity e, head;
@@ -702,8 +706,9 @@ void Item_Touch (void)
                self.invincible_finished = max(0, self.invincible_finished - time);
                self.superweapons_finished = max(0, self.superweapons_finished - time);
        }
-
-       if(!Item_GiveTo(self, other))
+       entity it = self.itemdef;
+       bool gave = (it && it.instanceOfPickup) ? ITEM_HANDLE(Pickup, it, self, other) : Item_GiveTo(self, other);
+       if (!gave)
        {
                if (self.classname == "droppedweapon")
                {
@@ -724,9 +729,7 @@ void Item_Touch (void)
 
        if (self.classname == "droppedweapon")
                remove (self);
-       else if (!self.spawnshieldtime)
-               return;
-       else
+       else if (self.spawnshieldtime)
        {
                if(self.team)
                {
@@ -1151,12 +1154,19 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                return;
        }
 }
+
+void StartItemA (entity a)
+{
+    self.itemdef = a;
+    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) {
        if(!self.ammo_rockets)
                self.ammo_rockets = g_pickup_rockets;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_rockets.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "rockets", IT_ROCKETS, 0, 0, commodity_pickupevalfunc, 3000);
+    StartItemA (ITEM_Rockets);
 }
 
 void spawnfunc_item_bullets (void) {
@@ -1174,7 +1184,7 @@ void spawnfunc_item_bullets (void) {
                self.ammo_nails = g_pickup_nails;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_bullets.mdl", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "bullets", IT_NAILS, 0, 0, commodity_pickupevalfunc, 2000);
+    StartItemA (ITEM_Bullets);
 }
 
 void spawnfunc_item_cells (void) {
@@ -1182,7 +1192,7 @@ void spawnfunc_item_cells (void) {
                self.ammo_cells = g_pickup_cells;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "cells", IT_CELLS, 0, 0, commodity_pickupevalfunc, 2000);
+       StartItemA (ITEM_Cells);
 }
 
 void spawnfunc_item_plasma()
@@ -1191,7 +1201,7 @@ void spawnfunc_item_plasma()
                self.ammo_plasma = g_pickup_plasma;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_cells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "plasma", IT_PLASMA, 0, 0, commodity_pickupevalfunc, 2000);
+       StartItemA (ITEM_Plasma);
 }
 
 void spawnfunc_item_shells (void) {
@@ -1209,7 +1219,7 @@ void spawnfunc_item_shells (void) {
                self.ammo_shells = g_pickup_shells;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/a_shells.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "shells", IT_SHELLS, 0, 0, commodity_pickupevalfunc, 500);
+       StartItemA (ITEM_Shells);
 }
 
 void spawnfunc_item_armor_small (void) {
@@ -1219,7 +1229,7 @@ void spawnfunc_item_armor_small (void) {
                self.max_armorvalue = g_pickup_armorsmall_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorsmall_anyway;
-       StartItem ("models/items/item_armor_small.md3", "misc/armor1.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Armor", IT_ARMOR_SHARD, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_ArmorSmall);
 }
 
 void spawnfunc_item_armor_medium (void) {
@@ -1229,7 +1239,7 @@ void spawnfunc_item_armor_medium (void) {
                self.max_armorvalue = g_pickup_armormedium_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armormedium_anyway;
-       StartItem ("models/items/item_armor_medium.md3", "misc/armor10.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "25 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+       StartItemA (ITEM_ArmorMedium);
 }
 
 void spawnfunc_item_armor_big (void) {
@@ -1239,7 +1249,7 @@ void spawnfunc_item_armor_big (void) {
                self.max_armorvalue = g_pickup_armorbig_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorbig_anyway;
-       StartItem ("models/items/item_armor_big.md3", "misc/armor17_5.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "50 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, 20000);
+       StartItemA (ITEM_ArmorBig);
 }
 
 void spawnfunc_item_armor_large (void) {
@@ -1249,7 +1259,7 @@ void spawnfunc_item_armor_large (void) {
                self.max_armorvalue = g_pickup_armorlarge_max;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_armorlarge_anyway;
-       StartItem ("models/items/item_armor_large.md3", "misc/armor25.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Armor", IT_ARMOR, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+       StartItemA (ITEM_ArmorLarge);
 }
 
 void spawnfunc_item_health_small (void) {
@@ -1259,7 +1269,7 @@ void spawnfunc_item_health_small (void) {
                self.health = g_pickup_healthsmall;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_healthsmall_anyway;
-       StartItem ("models/items/g_h1.md3", "misc/minihealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "5 Health", IT_5HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_HealthSmall);
 }
 
 void spawnfunc_item_health_medium (void) {
@@ -1269,7 +1279,7 @@ void spawnfunc_item_health_medium (void) {
                self.health = g_pickup_healthmedium;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_healthmedium_anyway;
-       StartItem ("models/items/g_h25.md3", "misc/mediumhealth.wav", g_pickup_respawntime_short, g_pickup_respawntimejitter_short, "25 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+    StartItemA (ITEM_HealthMedium);
 }
 
 void spawnfunc_item_health_large (void) {
@@ -1279,17 +1289,17 @@ void spawnfunc_item_health_large (void) {
                self.health = g_pickup_healthlarge;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_healthlarge_anyway;
-       StartItem ("models/items/g_h50.md3", "misc/mediumhealth.wav", g_pickup_respawntime_medium, g_pickup_respawntimejitter_medium, "50 Health", IT_25HP, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_MID);
+       StartItemA (ITEM_HealthLarge);
 }
 
 void spawnfunc_item_health_mega (void) {
-               if(!self.max_health)
-                       self.max_health = g_pickup_healthmega_max;
-               if(!self.health)
-                       self.health = g_pickup_healthmega;
-               if(!self.pickup_anyway)
-                       self.pickup_anyway = g_pickup_healthmega_anyway;
-               StartItem ("models/items/g_h100.md3", "misc/megahealth.wav", g_pickup_respawntime_long, g_pickup_respawntimejitter_long, "100 Health", IT_HEALTH, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+    if(!self.max_health)
+        self.max_health = g_pickup_healthmega_max;
+    if(!self.health)
+        self.health = g_pickup_healthmega;
+    if(!self.pickup_anyway)
+        self.pickup_anyway = g_pickup_healthmega_anyway;
+    StartItemA (ITEM_HealthMega);
 }
 
 // support old misnamed entities
@@ -1303,13 +1313,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:
@@ -1470,7 +1480,7 @@ void spawnfunc_item_fuel(void)
                self.ammo_fuel = g_pickup_fuel;
        if(!self.pickup_anyway)
                self.pickup_anyway = g_pickup_ammo_anyway;
-       StartItem ("models/items/g_fuel.md3", "misc/itempickup.wav", g_pickup_respawntime_ammo, g_pickup_respawntimejitter_ammo, "Fuel", IT_FUEL, 0, 0, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_JetpackFuel);
 }
 
 void spawnfunc_item_fuel_regen(void)
@@ -1480,7 +1490,7 @@ void spawnfunc_item_fuel_regen(void)
                spawnfunc_item_fuel();
                return;
        }
-       StartItem ("models/items/g_fuelregen.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Fuel regenerator", IT_FUEL_REGEN, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_JetpackRegen);
 }
 
 void spawnfunc_item_jetpack(void)
@@ -1492,7 +1502,7 @@ void spawnfunc_item_jetpack(void)
                spawnfunc_item_fuel();
                return;
        }
-       StartItem ("models/items/g_jetpack.md3", "misc/itempickup.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup, "Jet pack", IT_JETPACK, 0, FL_POWERUP, commodity_pickupevalfunc, BOT_PICKUP_RATING_LOW);
+       StartItemA (ITEM_Jetpack);
 }
 
 float GiveWeapon(entity e, float wpn, float op, float val)
index 7470d2f05b70feedf6a15e1a6e06095ec6c2b4c6..a33e45a82c388acbb55dd9cf59fe4c1819752803 100644 (file)
@@ -11,13 +11,13 @@ const int IT_FUEL_REGEN                     =      32; // fuel regeneration trigger
 // where is 64... ?
 const int IT_FUEL                                      =     128;
 // -Wdouble-declaration
-// const int IT_SHELLS                                 =     256;
+#define IT_SHELLS                                        256
 // -Wdouble-declaration
-// const int IT_NAILS                                  =     512;
+#define IT_NAILS                                         512
 // -Wdouble-declaration
-// const int IT_ROCKETS                                =    1024;
+#define IT_ROCKETS                                      1024
 // -Wdouble-declaration
-// const int IT_CELLS                                  =    2048;
+#define IT_CELLS                                        2048
 const int IT_SUPERWEAPON                               =    4096;
 const int IT_STRENGTH                                  =    8192;
 const int IT_INVINCIBLE                                =   16384;