]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
LMS and Instagib: fix extralife not counted in the Itemstats panel and wrongly displa...
authorterencehill <piuntn@gmail.com>
Sun, 7 May 2023 13:28:22 +0000 (15:28 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 9 May 2023 22:23:19 +0000 (00:23 +0200)
qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc
qcsrc/common/items/inventory.qh
qcsrc/common/items/item/pickup.qc
qcsrc/common/mutators/mutator/instagib/sv_instagib.qc

index 82899e42172e685ebcf4a8f15aaf5e2ec5da656d..d53b213492d81e5140c14be648defa93c2fbefba 100644 (file)
@@ -686,6 +686,7 @@ MUTATOR_HOOKFUNCTION(lms, ItemTouch)
        {
                Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES, autocvar_g_lms_extra_lives);
                GameRules_scoring_add(toucher, LMS_LIVES, autocvar_g_lms_extra_lives);
+               Inventory_pickupitem(item.itemdef, toucher);
                return MUT_ITEMTOUCH_PICKUP;
        }
 
index 6f6ebdc452a9f768b2626fc5aecf00e9f054876c..118b7079d0c832303ae7aa563172515fea190273 100644 (file)
@@ -154,9 +154,18 @@ void Inventory_new(PlayerState this)
        inv.owner = this;
        Net_LinkEntity(inv, false, 0, Inventory_Send);
 }
+
 void Inventory_delete(entity e) { delete(e.inventory); }
 void Inventory_update(entity e) { e.inventory.SendFlags = 0xFFFFFF; }
 
+void Inventory_pickupitem(Pickup this, entity player)
+{
+       //LOG_DEBUGF("entity %i picked up %s", player, this.m_name);
+       entity store = IS_PLAYER(player) ? PS(player) : player;
+       ++store.inventory.inv_items[this.m_id];
+       Inventory_update(store);
+}
+
 void Inventory_clear(entity store)
 {
     // NOTE: you will need to perform Inventory_update after this to update the storage entity
index a3c2d779edcde089ac3d4f7e142693de8e47070b..52cf8c3e8d07af1b933dc5eda7e05a81a518f74d 100644 (file)
@@ -10,12 +10,8 @@ METHOD(Pickup, giveTo, bool(Pickup this, entity item, entity player))
 {
     TC(Pickup, this);
     bool b = Item_GiveTo(item, player);
-    if (b) {
-        //LOG_DEBUGF("entity %i picked up %s", player, this.m_name);
-        entity store = IS_PLAYER(player) ? PS(player) : player;
-        store.inventory.inv_items[this.m_id]++;
-        Inventory_update(store);
-    }
+    if (b)
+        Inventory_pickupitem(this, player);
     return b;
 }
 
index 3a7d563d8b77ef0964c75b7de770b37a85f2159e..a6ac55d9308f41f54ed60035b52fe1c13811a830 100644 (file)
@@ -416,6 +416,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch)
        {
                GiveResource(toucher, RES_ARMOR, autocvar_g_instagib_extralives);
                Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES, autocvar_g_instagib_extralives);
+               Inventory_pickupitem(item.itemdef, toucher);
                return MUT_ITEMTOUCH_PICKUP;
        }