Author: Pheonix KageDesu
RPG Maker Versions: MZ, MV
URL: https://kdworkshop.net/loot-box-system
PKD Loot Box adds a configurable loot box / chest opening scene with a spinning reward carousel.
- Loot boxes are configured in plugin parameters.
- Each loot box can contain items, weapons, armors, gold, and common event rewards.
- Each reward has a roll weight, so you can control reward chances.
- The spin scene, sounds, reward icons, and UI layout can be customized.
- The plugin uses NUI JSON files for interface layout and animation settings.
- Place the plugin in your project's
js/pluginsfolder. - Enable PKD_LootBox in the RPG Maker Plugin Manager.
- Make sure the project contains the resource folders:
data/PKD_LootBoximg/PKD_LootBox
- If you use custom reward icons from pictures, place them in:
img/pictures
- If you use custom sound effects, place them in:
audio/se
Loot boxes are configured in the plugin parameter Loot Boxes (lootBoxesList).
Each entry in this list is a LootBoxConfig structure.
- ID (
id): unique loot box ID. You will use this ID when opening the loot box in game. - Background Image (
backgroundImageName): optional background image fromimg/PKD_LootBox.- If empty, the plugin uses Default Background Image (
spinBackgroundImageName).
- If empty, the plugin uses Default Background Image (
- Rewards (
rewards): list of rewards that can be rolled from this loot box.
Example loot box ID:
test
You can open it with:
OpenLootBoxSpin("test");Each reward is a LootRewardConfig structure.
- ID (
id): optional unique reward ID. If empty, the plugin generates one automatically. - Kind (
kind): reward type.itemweaponarmorgoldevent
- Data ID (
dataId): database ID for item, weapon, or armor rewards.- Use
0for gold and common event rewards.
- Use
- Amount (
amount): amount of items or gold to give. - Weight (
weight): roll weight. Higher value means higher chance. - Card Back Image (
rarity): optional card back image fromimg/PKD_LootBox. - Custom Icon Image (
customIcon): optional reward icon image fromimg/pictures. - Custom Name (
customName): optional display name for the reward. - Common Event ID (
commonEventId): common event to reserve whenkindisevent. - Custom SE (
customSE): optional sound effect fromaudio/seplayed when this reward is selected.
Item reward:
kind: item
dataId: 7
amount: 3
weight: 60
Weapon reward:
kind: weapon
dataId: 1
amount: 1
weight: 40
Gold reward:
kind: gold
dataId: 0
amount: 500
weight: 15
Common event reward:
kind: event
dataId: 0
amount: 1
weight: 15
commonEventId: 1
customName: Level Up!
customIcon: scroll_06_t
rarity: epic
The plugin uses reward weights to choose the result.
Example:
- Potion weight:
60 - Sword weight:
30 - Gold weight:
10
Total weight is 100, so the approximate chances are:
- Potion: 60%
- Sword: 30%
- Gold: 10%
Weights do not need to add up to 100. The plugin compares each reward weight against the total weight.
Use a Script event command:
OpenLootBoxSpin("lootBoxId");Replace lootBoxId with the ID from the Loot Boxes plugin parameter.
Example:
OpenLootBoxSpin("test");If the ID is not found, the plugin writes a warning to the console and does not open the scene.
- Loot Boxes (
lootBoxesList): all configured loot boxes and their rewards.
- Default Background Image (
spinBackgroundImageName): default scene background fromimg/PKD_LootBox. - Spin Duration (
spinDuration): main spin duration in frames. - Win Index Min (
spinWinIndexMin): minimum carousel index where the winning reward is placed. - Win Index Random Range (
spinWinIndexRandomRange): random extra range added to the winning index. - Extra Trailing Items (
spinTrailingItemsExtra): extra visual items created after the winning reward. - Minimum Item Scale (
spinMinScale): scale for items far from the carousel center. - Maximum Item Scale (
spinMaxScale): scale for items near the carousel center. - Item Gap (
spinBaseGap): base gap between carousel items. - Fast Stop Duration (
spinFastStopDuration): skip button fast-stop duration in frames. - Close Delay (
spinTakeRewardCloseDelay): delay in milliseconds before closing the scene after taking the reward. - Refresh Interval (
spinPostCreateRefreshInterval): short binding refresh interval after scene creation. - Refresh Count (
spinPostCreateRefreshCount): number of refresh ticks after scene creation. - Focus Animation Duration (
spinFocusAnimationDuration): final reward focus animation duration. - Focus Scale Bonus (
spinFocusScaleBonus): extra scale for the winning reward during focus animation. - Other Items Scale Multiplier (
spinFocusOtherScaleMultiplier): scale multiplier for non-winning rewards during focus animation. - Focus Lift (
spinFocusLift): vertical lift of the winning reward in pixels. - Side Spread (
spinFocusSideSpread): horizontal spread of surrounding rewards in pixels.
- Spin Tick SE (
spinTickSE): SE played when the carousel center changes. - Spin Finish SE (
spinFinishSE): default SE played when the final reward is selected.
- Gold Default Icon (
goldRewardDefaultIcon): default picture icon for gold rewards. - Common Event Default Icon (
commonEventRewardDefaultIcon): default picture icon for common event rewards.
Each reward can be customized directly in the loot box parameters:
rarity: card back image fromimg/PKD_LootBoxcustomIcon: icon image fromimg/picturescustomSE: reward sound effect fromaudio/se
Database items, weapons, and armors can also use notetags:
<lbBack:rare>
<lbIcon:potion_big>
<lbSE:Item3>
Direct reward settings have higher priority than notetags.
Card back image priority:
- Reward
rarity - Database object notetag
<lbBack:imageName> - Default card back
common
Reward icon priority:
- Reward
customIcon - Database object notetag
<lbIcon:imageName> - Database icon index for items, weapons, and armors
- Default icon for gold or common event rewards
Reward sound priority:
- Reward
customSE - Database object notetag
<lbSE:seName> - Plugin parameter Spin Finish SE (
spinFinishSE)
Notes:
- Notetags are used only for database-backed rewards: items, weapons, and armors.
- Gold and common event rewards do not have database objects, so use
customIcon,customName, andcustomSEfor them. - Image names should be written without file extension.
- Sound effect names should be written without file extension.
The loot box interface is built with NUI JSON layout files.
Note: You need a PRO version to use custom NUI layouts.
Main files:
data/PKD_LootBox/NUI_LootBoxCarouselScene.jsondata/PKD_LootBox/NUI_LootBoxCarouselItem.json
You can edit these .json files to customize:
- scene layout
- button images and positions
- background element
- reward name frame
- carousel item layout
- text positions and styles
- finish animations
- image bindings
Images used by the default interface are stored in:
img/PKD_LootBox
NUI_LootBoxCarouselScene.json can contain finishupAnimations constants.
The scene reads animation groups by element ID:
buttonnameTextitemsrewardbackground
These animation rules are applied when the player takes the reward.
- Add or verify images in
img/PKD_LootBox. - Add optional custom reward icons in
img/pictures. - Add optional reward SE files in
audio/se. - Open Plugin Manager and edit Loot Boxes (
lootBoxesList). - Create a loot box and set its unique ID.
- Add rewards to the loot box.
- Set reward
kind,dataId,amount, andweight. - Optionally set
rarity,customIcon,customName,customSE, orcommonEventId. - Open the loot box with:
OpenLootBoxSpin("yourLootBoxId");Create a loot box with ID:
forest_chest
Add rewards:
Potion:
kind = item
dataId = 7
amount = 3
weight = 60
Iron Sword:
kind = weapon
dataId = 1
amount = 1
weight = 20
Gold:
kind = gold
dataId = 0
amount = 500
weight = 20
Open it from an event with Script:
OpenLootBoxSpin("forest_chest");Optional database item notetags:
<lbBack:rare>
<lbIcon:potion_big>
<lbSE:Item3>
rarity, customIcon, or customSE, those values override the notetags.