]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
overkill: optimise replacement of powerups with superweapons
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 18 Jun 2023 22:18:23 +0000 (08:18 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 21 Jun 2023 10:59:04 +0000 (20:59 +1000)
We can use the itemdefs to skip the classname search.

qcsrc/common/mutators/mutator/overkill/sv_overkill.qc

index d4a1f4aeb1ebf17b01cc59877efe92336f9355e5..53eb25575f2cd518cdff15351073a4226ba2bd32 100644 (file)
@@ -225,22 +225,26 @@ MUTATOR_HOOKFUNCTION(ok, FilterItem)
        }
        if (item.classname == "item_strength")
        {
-               entity wep = new(weapon_okhmg);
+               entity wep = spawn();
                Item_CopyFields(item, wep);
                wep.ok_item = true;
                wep.respawntime = g_pickup_respawntime_superweapon;
                wep.pickup_anyway = true;
-               Item_Initialize(wep, "weapon_okhmg"); // doesn't actually use spawnfunc
+               wep.itemdef = WEP_OVERKILL_HMG;
+               wep.lifetime = -1;
+               Item_Initialise(wep);
                return true;
        }
        else if (item.classname == "item_shield")
        {
-               entity wep = new(weapon_okrpc);
+               entity wep = spawn();
                Item_CopyFields(item, wep);
                wep.ok_item = true;
                wep.respawntime = g_pickup_respawntime_superweapon;
                wep.pickup_anyway = true;
-               Item_Initialize(wep, "weapon_okrpc"); // doesn't actually use spawnfunc
+               wep.itemdef = WEP_OVERKILL_RPC;
+               wep.lifetime = -1;
+               Item_Initialise(wep);
                return true;
        }
        return true;