Show native rewards after manual coupon redemption

Open the stock reward window after a successful coupon activation using its existing reward definition.
This commit is contained in:
N0VAN0M4LY committed 2026-11-26 10:24:08 +08:00
1 parent 55846a91e9
commit 2d9ac527fb
1 file changed
+32
@@ -0,0 +1,32 @@
{
"id": "inventory/show-coupon-redemption-reward",
"title": "Show the granted reward after manual coupon redemption",
"file": "scripts/items/itemsclasses/itemexternal.nut",
"program_behaviour": {
"stock": "The coupon confirmation previews the reward from item metadata. The successful request updates the inventory stack.",
"patched": "The same reward metadata opens the existing native reward dialog after the successful redemption."
},
"derivation": {
"requirement": "Show the actual contents of a manually redeemed vehicle, decoration, or unlock coupon.",
"cause": "A successful coupon activation updates the profile and consumes the coupon. Its existing success handler does not open a native reward dialog.",
"lighter_options_ruled_out": [
"Use the reward confirmation before sending the grant. A refused exchange would then look as though it had succeeded.",
"Use the same receipt for automatic consumption. Supply chest rewards already have a native result path."
],
"if_not_applied": "A redeemed coupon updates the inventory and profile without a native receipt."
},
"features": [
"G-Marketplace",
"H-External inventory"
],
"evidence": [
"2.61.0.37 scripts/items/itemsclasses/itemexternal.nut: consume previews metaBlk and consumeImpl uses the task success callback.",
"2.61.0.37 scripts/items/trophyrewardwnd.nut and trophyreward.nut: guiStartOpenTrophy accepts unit, resource, unlock and item rewards.",
"2.61.0.37 scripts/items/itemsmanagerchecks.nut and inventory/inventoryclient.nut: the definition cache outlives a consumed stack.",
"packages/local-service/src/inventory/coupons and recycling-defs.ts: coupon metadata matches the successful grant."
],
"edit": {
"find": " let taskCallback = function() {\r\n let item = findItemByUid(uid)\r\n \n \n if (item && item.amountByUids[uid] == itemAmountByUid) {\r\n item.amountByUids[uid] -= consumeAmount\r\n item.amount -= consumeAmount\r\n if (item.amountByUids[uid] <= 0) {\r\n inventoryClient.removeItem(uid)\r\n if (item.uids?[0] == uid)\r\n item.uids.remove(0)\r\n }\r\n }\r\n if (cb)\r\n cb({ success = true })\r\n }\r\n let itemId = this.id\r\n let taskId = char_send_blk(\"cln_consume_inventory_item\", blk)",
"replace": " let couponReward = this.shouldAutoConsume || this.metaBlk == null\r\n ? null\r\n : require(\"%sqstd/datablock.nut\").convertBlk(this.metaBlk)\r\n if (couponReward != null)\r\n couponReward.itemDefId <- this.id\r\n\r\n let taskCallback = function() {\r\n let item = findItemByUid(uid)\r\n \n \n if (item && item.amountByUids[uid] == itemAmountByUid) {\r\n item.amountByUids[uid] -= consumeAmount\r\n item.amount -= consumeAmount\r\n if (item.amountByUids[uid] <= 0) {\r\n inventoryClient.removeItem(uid)\r\n if (item.uids?[0] == uid)\r\n item.uids.remove(0)\r\n }\r\n }\r\n if (cb)\r\n cb({ success = true })\r\n\r\n if (couponReward != null) {\r\n let { eventbus_send } = require(\"eventbus\")\r\n eventbus_send(\"guiStartOpenTrophy\", {\r\n [couponReward.itemDefId.tostring()] = [couponReward]\r\n rewardTitle = loc(\"mainmenu/you_received\")\r\n isHidePrizeActionBtn = true\r\n })\r\n }\r\n }\r\n let itemId = this.id\r\n let taskId = char_send_blk(\"cln_consume_inventory_item\", blk)"
}
}