|
| 1 | +import { findItem, widgets } from '@engine/config'; |
| 2 | +import { objectInteractionActionHandler } from '@engine/world/action/object-interaction.action'; |
| 3 | +import { World } from '@engine/world'; |
| 4 | +import { itemIds } from '@engine/world/config/item-ids'; |
| 5 | +import { LandscapeObject } from '@runejs/filestore'; |
| 6 | + |
| 7 | +export const action: objectInteractionActionHandler = (details) => { |
| 8 | + const veggies = [itemIds.onion, itemIds.grain, itemIds.cabbage]; |
| 9 | + details.player.busy = true; |
| 10 | + details.player.playAnimation(827); |
| 11 | + |
| 12 | + const random = Math.floor(Math.random() * 3); |
| 13 | + const pickedItem = findItem(veggies[random]); |
| 14 | + |
| 15 | + details.player.outgoingPackets.sendUpdateAllWidgetItems(widgets.inventory, details.player.inventory); |
| 16 | + |
| 17 | + setTimeout(() => { |
| 18 | + details.player.sendMessage(`You found a ${pickedItem.name.toLowerCase()} chest!.`); |
| 19 | + details.player.playSound(2581, 7); |
| 20 | + details.player.instance.hideGameObjectTemporarily(details.object, 60); |
| 21 | + details.player.giveItem(pickedItem.gameId); |
| 22 | + details.player.busy = false; |
| 23 | + }, World.TICK_LENGTH); |
| 24 | +}; |
| 25 | + |
| 26 | +export default { |
| 27 | + pluginId: 'rs:crates', |
| 28 | + hooks: [ |
| 29 | + { |
| 30 | + type: 'object_interaction', |
| 31 | + objectIds: [ 366, 357, 355 ], |
| 32 | + options: ['loot', 'search', 'examine' ], |
| 33 | + walkTo: true, |
| 34 | + handler: action |
| 35 | + } |
| 36 | + ] |
| 37 | +}; |
0 commit comments