From 50e4bcf71818f33175eecbbbbe25c8729d1798f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Sat, 10 Oct 2020 20:44:53 +0200 Subject: [PATCH 01/10] =?UTF-8?q?=E2=9C=A8=20Added=20getItemInEquipmentSlo?= =?UTF-8?q?t=20function=20to=20Player=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/world/actor/player/player.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/world/actor/player/player.ts b/src/world/actor/player/player.ts index 3d01eb496..3fda405ea 100644 --- a/src/world/actor/player/player.ts +++ b/src/world/actor/player/player.ts @@ -15,7 +15,7 @@ import { } from './player-data'; import { PlayerWidget, widgets, widgetScripts } from '../../config/widget'; import { ContainerUpdateEvent, ItemContainer } from '../../items/item-container'; -import { EquipmentBonuses, ItemDetails } from '../../config/item-data'; +import { EquipmentBonuses, EquipmentSlot,ItemDetails } from '@server/world/config/item-data'; import { Item } from '../../items/item'; import { Npc } from '../npc/npc'; import { NpcUpdateTask } from './updating/npc-update-task'; @@ -640,6 +640,10 @@ export class Player extends Actor { return this._equipment.has(item); } + public getItemInEquipmentSlot(slot: string) { + return this._equipment.items[EquipmentSlot[slot]]; + } + public hasItemOnPerson(item: number | Item): boolean { return this.hasItemInInventory(item) || this.hasItemInEquipment(item); } From 34a5e943cfcd84dcc4d6f49f689525fed9d83552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Sun, 11 Oct 2020 00:24:29 +0200 Subject: [PATCH 02/10] =?UTF-8?q?=E2=9C=A8=20Added=20skillcape=20emotes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/buttons/player-emotes-plugin.ts | 40 +++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/plugins/buttons/player-emotes-plugin.ts b/src/plugins/buttons/player-emotes-plugin.ts index 3afa41d14..0aa9667d3 100644 --- a/src/plugins/buttons/player-emotes-plugin.ts +++ b/src/plugins/buttons/player-emotes-plugin.ts @@ -10,6 +10,36 @@ interface Emote { graphicId?: number; } +interface SkillcapeEmote extends Emote { + itemIds: Array; +}; + +export const skillcapeEmotes: SkillcapeEmote[] = [ + { animationId: 4959, name: 'Attack', itemIds: [9747, 9748], graphicId: 823 }, + { animationId: 4981, name: 'Strength', itemIds: [9750, 9751], graphicId: 828 }, + { animationId: 4961, name: 'Defence', itemIds: [9753, 9754], graphicId: 824 }, + { animationId: 4973, name: 'Ranged', itemIds: [9756, 9757], graphicId: 832 }, + { animationId: 4979, name: 'Prayer', itemIds: [9759, 9760], graphicId: 829 }, + { animationId: 4939, name: 'Magic', itemIds: [9762, 9763], graphicId: 813 }, + { animationId: 4947, name: 'Runecrafting', itemIds: [9765, 9766], graphicId: 817 }, + { animationId: 4971, name: 'Constitution', itemIds: [9768, 9769], graphicId: 833 }, + { animationId: 4977, name: 'Agility', itemIds: [9771, 9772], graphicId: 830 }, + { animationId: 4969, name: 'Herblore', itemIds: [9774, 9775], graphicId: 835 }, + { animationId: 4965, name: 'Thieving', itemIds: [9777, 9778], graphicId: 826 }, + { animationId: 4949, name: 'Crafting', itemIds: [9780, 9781], graphicId: 818 }, + { animationId: 4937, name: 'Fletching', itemIds: [9786, 9787], graphicId: 812 }, + { animationId: 4967, name: 'Slayer', itemIds: [9783, 9784], graphicId: 827 }, + { animationId: 4953, name: 'Construction', itemIds: [9789, 9790], graphicId: 820 }, + { animationId: 4941, name: 'Mining', itemIds: [9792, 9793], graphicId: 814 }, + { animationId: 4943, name: 'Smithing', itemIds: [9795, 9796], graphicId: 815 }, + { animationId: 4951, name: 'Fishing', itemIds: [9798, 9799], graphicId: 819 }, + { animationId: 4955, name: 'Cooking', itemIds: [9801, 9802], graphicId: 821 }, + { animationId: 4975, name: 'Firemaking', itemIds: [9804, 9805], graphicId: 831 }, + { animationId: 4957, name: 'Woodcutting', itemIds: [9807, 9808], graphicId: 822 }, + { animationId: 4963, name: 'Farming', itemIds: [9810, 9811], graphicId: 825 }, + { animationId: 4945, name: 'Quest point', itemIds: [9813], graphicId: 816 }, +]; + export const emotes: { [key: number]: Emote } = { 1: { animationId: 855, name: 'YES' }, 2: { animationId: 856, name: 'NO' }, @@ -117,9 +147,15 @@ export const action: buttonAction = (details) => { const { player, buttonId } = details; const emote = emotes[buttonId]; - + if(emote.name === 'SKILLCAPE') { - player.sendMessage(`You need to be wearing a skillcape in order to perform that emote.`); + if (skillcapeEmotes.some(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId))) { + const skillcapeEmote = skillcapeEmotes.filter(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId)); + player.playAnimation(skillcapeEmote[0].animationId); + player.playGraphics({id: skillcapeEmote[0].graphicId, delay: 0, height: 0}); + } else { + player.sendMessage(`You need to be wearing a skillcape in order to perform that emote.`); + } } else { if(emote.unlockable) { const unlockedEmotes: string[] = player.savedMetadata.unlockedEmotes || []; From 83628082d8fe46a801277e42a660b055625cde57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Tue, 13 Oct 2020 20:14:02 +0200 Subject: [PATCH 03/10] =?UTF-8?q?=F0=9F=8E=A8Changed=20sendMessage=20type?= =?UTF-8?q?=20of=20skillcape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/buttons/player-emotes-plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/buttons/player-emotes-plugin.ts b/src/plugins/buttons/player-emotes-plugin.ts index 0aa9667d3..a42a1364b 100644 --- a/src/plugins/buttons/player-emotes-plugin.ts +++ b/src/plugins/buttons/player-emotes-plugin.ts @@ -154,7 +154,7 @@ export const action: buttonAction = (details) => { player.playAnimation(skillcapeEmote[0].animationId); player.playGraphics({id: skillcapeEmote[0].graphicId, delay: 0, height: 0}); } else { - player.sendMessage(`You need to be wearing a skillcape in order to perform that emote.`); + player.sendMessage(`You need to be wearing a skillcape in order to perform that emote.`, true); } } else { if(emote.unlockable) { From c41ae7d5101bf1962b2ad136a5cbc60141918061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Tue, 13 Oct 2020 20:14:28 +0200 Subject: [PATCH 04/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8FFixed=20linting=20error?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/world/actor/player/player.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/world/actor/player/player.ts b/src/world/actor/player/player.ts index 3fda405ea..340319917 100644 --- a/src/world/actor/player/player.ts +++ b/src/world/actor/player/player.ts @@ -15,7 +15,7 @@ import { } from './player-data'; import { PlayerWidget, widgets, widgetScripts } from '../../config/widget'; import { ContainerUpdateEvent, ItemContainer } from '../../items/item-container'; -import { EquipmentBonuses, EquipmentSlot,ItemDetails } from '@server/world/config/item-data'; +import { EquipmentBonuses, EquipmentSlot, ItemDetails } from '@server/world/config/item-data'; import { Item } from '../../items/item'; import { Npc } from '../npc/npc'; import { NpcUpdateTask } from './updating/npc-update-task'; @@ -640,7 +640,7 @@ export class Player extends Actor { return this._equipment.has(item); } - public getItemInEquipmentSlot(slot: string) { + public getItemInEquipmentSlot(slot: string): Item { return this._equipment.items[EquipmentSlot[slot]]; } From 7d445ad8c8d41efb9e0b39fbb7060e754bb01cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Wed, 14 Oct 2020 14:08:00 +0200 Subject: [PATCH 05/10] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20issue=20in=20unequ?= =?UTF-8?q?ip=20plugin=20when=20removing=20an=20item=20without=20overridin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/equipment/equip-item-plugin.ts | 3 --- src/plugins/equipment/unequip-item-plugin.ts | 28 +++----------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/plugins/equipment/equip-item-plugin.ts b/src/plugins/equipment/equip-item-plugin.ts index 5eba0b148..ad03ced49 100644 --- a/src/plugins/equipment/equip-item-plugin.ts +++ b/src/plugins/equipment/equip-item-plugin.ts @@ -3,9 +3,6 @@ import { widgets } from '@server/world/config/widget'; import { itemAction } from '@server/world/actor/player/action/item-action'; import { equipmentSlotIndex } from '@server/world/config/item-data'; - - - export const action: itemAction = (details) => { const { player, itemId, itemSlot, itemDetails } = details; diff --git a/src/plugins/equipment/unequip-item-plugin.ts b/src/plugins/equipment/unequip-item-plugin.ts index be94acfee..4c388ad8f 100644 --- a/src/plugins/equipment/unequip-item-plugin.ts +++ b/src/plugins/equipment/unequip-item-plugin.ts @@ -1,10 +1,10 @@ import { ActionType, RunePlugin } from '@server/plugins/plugin'; import { widgets } from '@server/world/config/widget'; import { getItemFromContainer, itemAction } from '@server/world/actor/player/action/item-action'; -import { updateBonusStrings } from '@server/plugins/equipment/equipment-stats-plugin'; +import { equipmentSlotIndex } from '@server/world/config/item-data'; export const action: itemAction = (details) => { - const { player, itemId, itemSlot, widgetId } = details; + const { player, itemId, itemSlot, itemDetails } = details; const equipment = player.equipment; const item = getItemFromContainer(itemId, itemSlot, equipment); @@ -14,28 +14,8 @@ export const action: itemAction = (details) => { return; } - const inventory = player.inventory; - const inventorySlot = inventory.getFirstOpenSlot(); - - if(inventorySlot === -1) { - player.sendMessage(`You don't have enough free space to do that.`); - return; - } - - equipment.remove(itemSlot); - inventory.set(inventorySlot, item); - - player.updateBonuses(); - - player.outgoingPackets.sendUpdateSingleWidgetItem(widgets.inventory, inventorySlot, item); - player.outgoingPackets.sendUpdateSingleWidgetItem(widgets.equipment, itemSlot, null); - - if(widgetId === widgets.equipmentStats.widgetId) { - player.outgoingPackets.sendUpdateSingleWidgetItem(widgets.equipmentStats, itemSlot, null); - updateBonusStrings(player); - } - - player.updateFlags.appearanceUpdateRequired = true; + const equipmentSlot = equipmentSlotIndex(itemDetails.equipment.slot); + player.unequipItem(equipmentSlot); }; export default new RunePlugin({ From 504aefddb25bfff932d489b544e856496e99d533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Wed, 14 Oct 2020 14:08:28 +0200 Subject: [PATCH 06/10] =?UTF-8?q?=E2=9C=A8Added=20stopAnimation=20&=20stop?= =?UTF-8?q?Graphics=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/world/actor/actor.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/world/actor/actor.ts b/src/world/actor/actor.ts index aa9cba990..bc177dea4 100644 --- a/src/world/actor/actor.ts +++ b/src/world/actor/actor.ts @@ -174,6 +174,11 @@ export abstract class Actor { this.updateFlags.animation = animation; } + public stopAnimation(): void { + let animation = {id: -1, delay: 0}; + this.updateFlags.animation = animation; + } + public playGraphics(graphics: number | Graphic): void { if(typeof graphics === 'number') { graphics = {id: graphics, delay: 0, height: 120}; @@ -182,6 +187,11 @@ export abstract class Actor { this.updateFlags.graphics = graphics; } + public stopGraphics(): void { + let graphics = {id: -1, delay: 0, height: 120}; + this.updateFlags.graphics = graphics; + } + public removeItem(slot: number): void { this._inventory.remove(slot); } From 09398d79adc1e3eb572e5a29061d925bee9fcdd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Wed, 14 Oct 2020 14:08:54 +0200 Subject: [PATCH 07/10] =?UTF-8?q?=E2=9C=A8=20Added=20skillcape=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/items/capes/skillcape-emotes.ts | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/plugins/items/capes/skillcape-emotes.ts diff --git a/src/plugins/items/capes/skillcape-emotes.ts b/src/plugins/items/capes/skillcape-emotes.ts new file mode 100644 index 000000000..080f5eab6 --- /dev/null +++ b/src/plugins/items/capes/skillcape-emotes.ts @@ -0,0 +1,34 @@ +import { lockEmote, unlockEmote } from '@server/plugins/buttons/player-emotes-plugin'; +import { ActionType, RunePlugin } from '@server/plugins/plugin'; +import { equipAction } from '@server/world/actor/player/action/equip-action'; + +export const skillcapes: Array = [ + 9747, 9748, 9750, 9751, 9753, 9754, 9756, 9757, 9759, 9760, + 9762, 9763, 9765, 9766, 9768, 9769, 9771, 9772, 9774, 9775, + 9777, 9778, 9780, 9781, 9786, 9787, 9783, 9784, 9789, 9790, + 9792, 9793, 9795, 9796, 9798, 9799, 9801, 9802, 9804, 9805, + 9807, 9808, 9810, 9811, 9813 +]; + +export const equip: equipAction = (details) => { + const {player} = details; + unlockEmote(player, 'SKILLCAPE'); +}; +export const unequip: equipAction = (details) => { + const {player} = details; + lockEmote(player, 'SKILLCAPE'); + player.stopAnimation(); + player.stopGraphics(); +}; + +export default new RunePlugin([{ + type: ActionType.EQUIP_ACTION, + equipType: 'EQUIP', + action: equip, + itemIds: skillcapes +}, { + type: ActionType.EQUIP_ACTION, + equipType: 'UNEQUIP', + action: unequip, + itemIds: skillcapes +}]); From 2a5e03e652de6ffebab446f41cc631f83f787b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Wed, 14 Oct 2020 14:23:49 +0200 Subject: [PATCH 08/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fixed=20linter=20iss?= =?UTF-8?q?ues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/buttons/player-emotes-plugin.ts | 2 +- src/world/actor/actor.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/buttons/player-emotes-plugin.ts b/src/plugins/buttons/player-emotes-plugin.ts index a42a1364b..1bfaf90b8 100644 --- a/src/plugins/buttons/player-emotes-plugin.ts +++ b/src/plugins/buttons/player-emotes-plugin.ts @@ -12,7 +12,7 @@ interface Emote { interface SkillcapeEmote extends Emote { itemIds: Array; -}; +} export const skillcapeEmotes: SkillcapeEmote[] = [ { animationId: 4959, name: 'Attack', itemIds: [9747, 9748], graphicId: 823 }, diff --git a/src/world/actor/actor.ts b/src/world/actor/actor.ts index bc177dea4..f2471e0a0 100644 --- a/src/world/actor/actor.ts +++ b/src/world/actor/actor.ts @@ -175,7 +175,7 @@ export abstract class Actor { } public stopAnimation(): void { - let animation = {id: -1, delay: 0}; + const animation = {id: -1, delay: 0}; this.updateFlags.animation = animation; } @@ -188,7 +188,7 @@ export abstract class Actor { } public stopGraphics(): void { - let graphics = {id: -1, delay: 0, height: 120}; + const graphics = {id: -1, delay: 0, height: 120}; this.updateFlags.graphics = graphics; } From 8030daff483026ac4e644fc382bf7392ddce3969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Fri, 16 Oct 2020 22:25:42 +0200 Subject: [PATCH 09/10] =?UTF-8?q?=E2=9C=A8=20Added=20item-ids?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/buttons/player-emotes-plugin.ts | 55 ++++++------ src/plugins/items/capes/skillcape-emotes.ts | 16 ++-- src/world/config/item-ids.ts | 93 +++++++++++++++++++++ 3 files changed, 129 insertions(+), 35 deletions(-) diff --git a/src/plugins/buttons/player-emotes-plugin.ts b/src/plugins/buttons/player-emotes-plugin.ts index 1bfaf90b8..a17110023 100644 --- a/src/plugins/buttons/player-emotes-plugin.ts +++ b/src/plugins/buttons/player-emotes-plugin.ts @@ -2,6 +2,7 @@ import { buttonAction } from '@server/world/actor/player/action/button-action'; import { ActionType, RunePlugin } from '@server/plugins/plugin'; import { widgets } from '@server/world/config/widget'; import { Player } from '@server/world/actor/player/player'; +import { itemIds } from '@server/world/config/item-ids'; interface Emote { animationId: number; @@ -14,30 +15,32 @@ interface SkillcapeEmote extends Emote { itemIds: Array; } -export const skillcapeEmotes: SkillcapeEmote[] = [ - { animationId: 4959, name: 'Attack', itemIds: [9747, 9748], graphicId: 823 }, - { animationId: 4981, name: 'Strength', itemIds: [9750, 9751], graphicId: 828 }, - { animationId: 4961, name: 'Defence', itemIds: [9753, 9754], graphicId: 824 }, - { animationId: 4973, name: 'Ranged', itemIds: [9756, 9757], graphicId: 832 }, - { animationId: 4979, name: 'Prayer', itemIds: [9759, 9760], graphicId: 829 }, - { animationId: 4939, name: 'Magic', itemIds: [9762, 9763], graphicId: 813 }, - { animationId: 4947, name: 'Runecrafting', itemIds: [9765, 9766], graphicId: 817 }, - { animationId: 4971, name: 'Constitution', itemIds: [9768, 9769], graphicId: 833 }, - { animationId: 4977, name: 'Agility', itemIds: [9771, 9772], graphicId: 830 }, - { animationId: 4969, name: 'Herblore', itemIds: [9774, 9775], graphicId: 835 }, - { animationId: 4965, name: 'Thieving', itemIds: [9777, 9778], graphicId: 826 }, - { animationId: 4949, name: 'Crafting', itemIds: [9780, 9781], graphicId: 818 }, - { animationId: 4937, name: 'Fletching', itemIds: [9786, 9787], graphicId: 812 }, - { animationId: 4967, name: 'Slayer', itemIds: [9783, 9784], graphicId: 827 }, - { animationId: 4953, name: 'Construction', itemIds: [9789, 9790], graphicId: 820 }, - { animationId: 4941, name: 'Mining', itemIds: [9792, 9793], graphicId: 814 }, - { animationId: 4943, name: 'Smithing', itemIds: [9795, 9796], graphicId: 815 }, - { animationId: 4951, name: 'Fishing', itemIds: [9798, 9799], graphicId: 819 }, - { animationId: 4955, name: 'Cooking', itemIds: [9801, 9802], graphicId: 821 }, - { animationId: 4975, name: 'Firemaking', itemIds: [9804, 9805], graphicId: 831 }, - { animationId: 4957, name: 'Woodcutting', itemIds: [9807, 9808], graphicId: 822 }, - { animationId: 4963, name: 'Farming', itemIds: [9810, 9811], graphicId: 825 }, - { animationId: 4945, name: 'Quest point', itemIds: [9813], graphicId: 816 }, +const { skillCapes } = itemIds; + +export const skillCapeEmotes: SkillcapeEmote[] = [ + { animationId: 4959, name: 'Attack', itemIds: [skillCapes.attack.untrimmed, skillCapes.attack.trimmed], graphicId: 823 }, + { animationId: 4981, name: 'Strength', itemIds: [skillCapes.strength.untrimmed, skillCapes.strength.trimmed], graphicId: 828 }, + { animationId: 4961, name: 'Defence', itemIds: [skillCapes.defence.untrimmed, skillCapes.defence.trimmed], graphicId: 824 }, + { animationId: 4973, name: 'Ranged', itemIds: [skillCapes.ranged.untrimmed, skillCapes.ranged.trimmed], graphicId: 832 }, + { animationId: 4979, name: 'Prayer', itemIds: [skillCapes.prayer.untrimmed, skillCapes.prayer.trimmed], graphicId: 829 }, + { animationId: 4939, name: 'Magic', itemIds: [skillCapes.magic.untrimmed, skillCapes.magic.trimmed], graphicId: 813 }, + { animationId: 4947, name: 'Runecrafting', itemIds: [skillCapes.runecrafting.untrimmed, skillCapes.runecrafting.trimmed], graphicId: 817 }, + { animationId: 4971, name: 'Constitution', itemIds: [skillCapes.constitution.untrimmed, skillCapes.constitution.trimmed], graphicId: 833 }, + { animationId: 4977, name: 'Agility', itemIds: [skillCapes.agility.untrimmed, skillCapes.agility.trimmed], graphicId: 830 }, + { animationId: 4969, name: 'Herblore', itemIds: [skillCapes.herblore.untrimmed, skillCapes.herblore.trimmed], graphicId: 835 }, + { animationId: 4965, name: 'Thieving', itemIds: [skillCapes.thieving.untrimmed, skillCapes.thieving.trimmed], graphicId: 826 }, + { animationId: 4949, name: 'Crafting', itemIds: [skillCapes.crafting.untrimmed, skillCapes.crafting.trimmed], graphicId: 818 }, + { animationId: 4937, name: 'Fletching', itemIds: [skillCapes.fletching.untrimmed, skillCapes.fletching.trimmed], graphicId: 812 }, + { animationId: 4967, name: 'Slayer', itemIds: [skillCapes.slayer.untrimmed, skillCapes.slayer.trimmed], graphicId: 827 }, + { animationId: 4953, name: 'Construction', itemIds: [skillCapes.construction.untrimmed, skillCapes.construction.trimmed], graphicId: 820 }, + { animationId: 4941, name: 'Mining', itemIds: [skillCapes.mining.untrimmed, skillCapes.mining.trimmed], graphicId: 814 }, + { animationId: 4943, name: 'Smithing', itemIds: [skillCapes.smithing.untrimmed, skillCapes.smithing.trimmed], graphicId: 815 }, + { animationId: 4951, name: 'Fishing', itemIds: [skillCapes.fishing.untrimmed, skillCapes.fishing.trimmed], graphicId: 819 }, + { animationId: 4955, name: 'Cooking', itemIds: [skillCapes.cooking.untrimmed, skillCapes.cooking.trimmed], graphicId: 821 }, + { animationId: 4975, name: 'Firemaking', itemIds: [skillCapes.firemaking.untrimmed, skillCapes.firemaking.trimmed], graphicId: 831 }, + { animationId: 4957, name: 'Woodcutting', itemIds: [skillCapes.woodcutting.untrimmed, skillCapes.woodcutting.trimmed], graphicId: 822 }, + { animationId: 4963, name: 'Farming', itemIds: [skillCapes.farming.untrimmed, skillCapes.farming.trimmed], graphicId: 825 }, + { animationId: 4945, name: 'Quest point', itemIds: [skillCapes.questpoint.untrimmed], graphicId: 816 }, ]; export const emotes: { [key: number]: Emote } = { @@ -149,8 +152,8 @@ export const action: buttonAction = (details) => { const emote = emotes[buttonId]; if(emote.name === 'SKILLCAPE') { - if (skillcapeEmotes.some(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId))) { - const skillcapeEmote = skillcapeEmotes.filter(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId)); + if (skillCapeEmotes.some(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId))) { + const skillcapeEmote = skillCapeEmotes.filter(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId)); player.playAnimation(skillcapeEmote[0].animationId); player.playGraphics({id: skillcapeEmote[0].graphicId, delay: 0, height: 0}); } else { diff --git a/src/plugins/items/capes/skillcape-emotes.ts b/src/plugins/items/capes/skillcape-emotes.ts index 080f5eab6..f173869d0 100644 --- a/src/plugins/items/capes/skillcape-emotes.ts +++ b/src/plugins/items/capes/skillcape-emotes.ts @@ -1,19 +1,17 @@ import { lockEmote, unlockEmote } from '@server/plugins/buttons/player-emotes-plugin'; import { ActionType, RunePlugin } from '@server/plugins/plugin'; import { equipAction } from '@server/world/actor/player/action/equip-action'; +import { itemIds } from '@server/world/config/item-ids'; -export const skillcapes: Array = [ - 9747, 9748, 9750, 9751, 9753, 9754, 9756, 9757, 9759, 9760, - 9762, 9763, 9765, 9766, 9768, 9769, 9771, 9772, 9774, 9775, - 9777, 9778, 9780, 9781, 9786, 9787, 9783, 9784, 9789, 9790, - 9792, 9793, 9795, 9796, 9798, 9799, 9801, 9802, 9804, 9805, - 9807, 9808, 9810, 9811, 9813 -]; +export const skillcapeIds: Array = Object.keys( + itemIds.skillCapes).flatMap(skill => [itemIds.skillCapes[skill].untrimmed, itemIds.skillCapes[skill].trimmed] +); export const equip: equipAction = (details) => { const {player} = details; unlockEmote(player, 'SKILLCAPE'); }; + export const unequip: equipAction = (details) => { const {player} = details; lockEmote(player, 'SKILLCAPE'); @@ -25,10 +23,10 @@ export default new RunePlugin([{ type: ActionType.EQUIP_ACTION, equipType: 'EQUIP', action: equip, - itemIds: skillcapes + itemIds: skillcapeIds }, { type: ActionType.EQUIP_ACTION, equipType: 'UNEQUIP', action: unequip, - itemIds: skillcapes + itemIds: skillcapeIds }]); diff --git a/src/world/config/item-ids.ts b/src/world/config/item-ids.ts index 7357e9b3d..0c8d1e982 100644 --- a/src/world/config/item-ids.ts +++ b/src/world/config/item-ids.ts @@ -52,4 +52,97 @@ export const itemIds = { runiteBar: 2363, runiteOre: 451, beer: 1917, + skillCapes: { + attack: { + untrimmed: 9747, + trimmed: 9748, + }, + strength: { + untrimmed: 9750, + trimmed: 9751, + }, + defence: { + untrimmed: 9753, + trimmed: 9754, + }, + ranged: { + untrimmed: 9756, + trimmed: 9757, + }, + prayer: { + untrimmed: 9759, + trimmed: 9760, + }, + magic: { + untrimmed: 9762, + trimmed: 9763, + }, + runecrafting: { + untrimmed: 9765, + trimmed: 9766, + }, + constitution: { + untrimmed: 9768, + trimmed: 9769, + }, + agility: { + untrimmed: 9771, + trimmed: 9772, + }, + herblore: { + untrimmed: 9774, + trimmed: 9775, + }, + thieving: { + untrimmed: 9777, + trimmed: 9775, + }, + crafting: { + untrimmed: 9780, + trimmed: 9781, + }, + fletching: { + untrimmed: 9783, + trimmed: 9784, + }, + slayer: { + untrimmed: 9786, + trimmed: 9786, + }, + construction: { + untrimmed: 9789, + trimmed: 9790, + }, + mining: { + untrimmed: 9792, + trimmed: 9793, + }, + smithing: { + untrimmed: 9795, + trimmed: 9796, + }, + fishing: { + untrimmed: 9798, + trimmed: 9799, + }, + cooking: { + untrimmed: 9801, + trimmed: 9802, + }, + firemaking: { + untrimmed: 9804, + trimmed: 9805, + }, + woodcutting: { + untrimmed: 9807, + trimmed: 9808, + }, + farming: { + untrimmed: 9810, + trimmed: 9811, + }, + questpoint: { + untrimmed: 9813, + }, + }, }; From c38559d53bce42f52c3fc1e6afb30020c82c07ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Schauwers?= Date: Fri, 16 Oct 2020 22:37:00 +0200 Subject: [PATCH 10/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Added=20check=20to?= =?UTF-8?q?=20see=20if=20player=20is=20wearing=20something=20in=20the=20BA?= =?UTF-8?q?CK=20slot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/buttons/player-emotes-plugin.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/buttons/player-emotes-plugin.ts b/src/plugins/buttons/player-emotes-plugin.ts index a17110023..f83d15e11 100644 --- a/src/plugins/buttons/player-emotes-plugin.ts +++ b/src/plugins/buttons/player-emotes-plugin.ts @@ -152,11 +152,13 @@ export const action: buttonAction = (details) => { const emote = emotes[buttonId]; if(emote.name === 'SKILLCAPE') { - if (skillCapeEmotes.some(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId))) { - const skillcapeEmote = skillCapeEmotes.filter(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId)); - player.playAnimation(skillcapeEmote[0].animationId); - player.playGraphics({id: skillcapeEmote[0].graphicId, delay: 0, height: 0}); - } else { + if (player.getItemInEquipmentSlot('BACK')) { + if (skillCapeEmotes.some(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId))) { + const skillcapeEmote = skillCapeEmotes.filter(item => item.itemIds.includes(player.getItemInEquipmentSlot('BACK')?.itemId)); + player.playAnimation(skillcapeEmote[0].animationId); + player.playGraphics({id: skillcapeEmote[0].graphicId, delay: 0, height: 0}); + } + } else { player.sendMessage(`You need to be wearing a skillcape in order to perform that emote.`, true); } } else {