From 38c4018ae88cc2ee4ace2ee2832ba2421c2079be Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 7 May 2023 15:28:22 +0200 Subject: [PATCH] LMS and Instagib: fix extralife not counted in the Itemstats panel and wrongly displayed in the Pickup panel --- qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc | 1 + qcsrc/common/items/inventory.qh | 9 +++++++++ qcsrc/common/items/item/pickup.qc | 8 ++------ qcsrc/common/mutators/mutator/instagib/sv_instagib.qc | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc index 82899e421..d53b21349 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc +++ b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc @@ -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; } diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index 6f6ebdc45..118b7079d 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -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 diff --git a/qcsrc/common/items/item/pickup.qc b/qcsrc/common/items/item/pickup.qc index a3c2d779e..52cf8c3e8 100644 --- a/qcsrc/common/items/item/pickup.qc +++ b/qcsrc/common/items/item/pickup.qc @@ -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; } diff --git a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc index 3a7d563d8..a6ac55d93 100644 --- a/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/sv_instagib.qc @@ -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; } -- 2.39.2