-
Notifications
You must be signed in to change notification settings - Fork 92
empty buckets, item option 2 packet #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { incomingPacket } from '../incoming-packet'; | ||
| import { RsBuffer } from '@server/net/rs-buffer'; | ||
| import { Player } from '../../world/actor/player/player'; | ||
| import { itemAction } from '@server/world/actor/player/action/item-action'; | ||
|
|
||
| export const itemOption2Packet: incomingPacket = (player: Player, packetId: number, packetSize: number, packet: RsBuffer): void => { | ||
| const slot = packet.readShortBE(); | ||
| const widgetId = packet.readShortLE(); | ||
| const containerId = packet.readShortLE(); | ||
| const itemId = packet.readShortBE(); | ||
| // packet.readNegativeOffsetShortBE(); | ||
| // packet.readUnsignedShortLE(); | ||
| // packet.readShortLE(); // either widget id or container id | ||
| // packet.readShortLE(); // either widget id or container id | ||
| // | ||
| // Class32.packetBuffer.putShortBE(i); | ||
| // Class32.packetBuffer.putIntME1(i_10_); | ||
| // Class32.packetBuffer.putShortBE(i_12_); | ||
| // | ||
| // Class32.packetBuffer.putCustomNegativeOffsetShortBE(i_12_, -128); | ||
| // Class32.packetBuffer.putShortLE(i); | ||
| // Class32.packetBuffer.putIntME1(i_10_); | ||
|
|
||
| // @TODO parse widgets and find actual item option NAME to pass to this | ||
| itemAction(player, itemId, slot, widgetId, containerId, 'option-2'); | ||
|
|
||
| /* | ||
| // Handles the value option in shops. | ||
| if(widgetId === widgetIds.shop.shopInventory) { | ||
| buyItemValueAction(player, itemId, slot); | ||
| return; | ||
| } | ||
|
|
||
| // Handles the value option in the shop inventory interface. | ||
| if(widgetId === widgetIds.shop.playerInventory) { | ||
| sellItemValueAction(player, itemId, slot); | ||
| return; | ||
| } | ||
|
|
||
| let container: ItemContainer = null; | ||
|
|
||
| if(widgetId === widgetIds.equipment.widgetId && containerId === widgetIds.equipment.containerId) { | ||
| container = player.equipment; | ||
| } | ||
|
|
||
| if(!container) { | ||
| logger.info(`Unhandled item option 1: ${widgetId}, ${slot}, ${itemId}`); | ||
| return; | ||
| } | ||
|
|
||
| if(slot < 0 || slot > container.size - 1) { | ||
| logger.warn(`${player.username} attempted item option 1 on ${itemId} in invalid slot ${slot}.`); | ||
| return; | ||
| } | ||
|
|
||
| const itemInSlot = container.items[slot]; | ||
|
|
||
| if(!itemInSlot) { | ||
| logger.warn(`${player.username} attempted item option 1 on ${itemId} in slot ${slot}, but they do not have that item.`); | ||
| return; | ||
| } | ||
|
|
||
| if(itemInSlot.itemId !== itemId) { | ||
| logger.warn(`${player.username} attempted item option 1 on ${itemId} in slot ${slot}, but ${itemInSlot.itemId} was found there instead.`); | ||
| return; | ||
| } | ||
|
|
||
| if(widgetId === widgetIds.equipment.widgetId && containerId === widgetIds.equipment.containerId) { | ||
| unequipItemAction(player, itemId, slot); | ||
| }*/ | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { getItemFromContainer, itemAction } from '@server/world/actor/player/action/item-action'; | ||
| import { widgets } from '@server/world/config/widget'; | ||
| import { soundIds } from '@server/world/config/sound-ids'; | ||
| import { ActionType, RunePlugin } from '@server/plugins/plugin'; | ||
| import { itemIds } from '@server/world/config/item-ids'; | ||
|
|
||
| export const action: itemAction = (details) => { | ||
| const { player, itemId, itemSlot } = details; | ||
|
|
||
| const inventory = player.inventory; | ||
| const item = getItemFromContainer(itemId, itemSlot, inventory); | ||
|
|
||
| if(!item) { | ||
| // The specified item was not found in the specified slot. | ||
| return; | ||
| } | ||
|
|
||
| inventory.remove(itemSlot); | ||
| player.outgoingPackets.playSound(soundIds.emptyBucket, 5); | ||
| player.giveItem(itemIds.bucket); | ||
| player.outgoingPackets.sendUpdateAllWidgetItems(widgets.inventory, inventory); | ||
| }; | ||
|
|
||
| export default new RunePlugin({ | ||
| type: ActionType.ITEM_ACTION, | ||
| widgets: widgets.inventory, | ||
| options: 'option-2', | ||
| itemIds: [itemIds.bucketOfMilk, itemIds.bucketOfWater], | ||
| action, | ||
| cancelOtherActions: false | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️