diff --git a/src/plugins/commands/bank-command.ts b/src/plugins/commands/bank-command.ts new file mode 100644 index 000000000..edd635865 --- /dev/null +++ b/src/plugins/commands/bank-command.ts @@ -0,0 +1,13 @@ +import { ActionType, RunePlugin } from '@server/plugins/plugin'; +import { commandAction } from '@server/world/actor/player/action/input-command-action'; +import { openBankInterface } from '@server/plugins/objects/bank/bank-plugin'; + +const action: commandAction = (details) => { + openBankInterface(details as any); +}; + +export default new RunePlugin({ + type: ActionType.COMMAND, + commands: [ 'bank' ], + action +}); diff --git a/src/world/actor/skills.ts b/src/world/actor/skills.ts index 85f83b573..3bae3b845 100644 --- a/src/world/actor/skills.ts +++ b/src/world/actor/skills.ts @@ -39,29 +39,29 @@ export interface SkillDetail { } export const skillDetails: SkillDetail[] = [ - { name: 'Attack', advancementWidgetId: 158 }, - { name: 'Defence', advancementWidgetId: 161 }, - { name: 'Strength', advancementWidgetId: 175 }, - { name: 'Hitpoints', advancementWidgetId: 167 }, - { name: 'Ranged', advancementWidgetId: 171 }, - { name: 'Prayer', advancementWidgetId: 170 }, - { name: 'Magic', advancementWidgetId: 168 }, - { name: 'Cooking', advancementWidgetId: 159 }, - { name: 'Woodcutting', advancementWidgetId: 177 }, - { name: 'Fletching', advancementWidgetId: 165 }, - { name: 'Fishing', advancementWidgetId: 164 }, - { name: 'Firemaking', advancementWidgetId: 163 }, - { name: 'Crafting', advancementWidgetId: 160 }, - { name: 'Smithing', advancementWidgetId: 174 }, - { name: 'Mining', advancementWidgetId: 169 }, - { name: 'Herblore', advancementWidgetId: 166 }, - { name: 'Agility', advancementWidgetId: 157 }, - { name: 'Thieving', advancementWidgetId: 176 }, - { name: 'Slayer', advancementWidgetId: 173 }, - { name: 'Farming', advancementWidgetId: 162 }, - { name: 'Runecrafting', advancementWidgetId: 172 }, + {name: 'Attack', advancementWidgetId: 158}, + {name: 'Defence', advancementWidgetId: 161}, + {name: 'Strength', advancementWidgetId: 175}, + {name: 'Hitpoints', advancementWidgetId: 167}, + {name: 'Ranged', advancementWidgetId: 171}, + {name: 'Prayer', advancementWidgetId: 170}, + {name: 'Magic', advancementWidgetId: 168}, + {name: 'Cooking', advancementWidgetId: 159}, + {name: 'Woodcutting', advancementWidgetId: 177}, + {name: 'Fletching', advancementWidgetId: 165}, + {name: 'Fishing', advancementWidgetId: 164}, + {name: 'Firemaking', advancementWidgetId: 163}, + {name: 'Crafting', advancementWidgetId: 160}, + {name: 'Smithing', advancementWidgetId: 174}, + {name: 'Mining', advancementWidgetId: 169}, + {name: 'Herblore', advancementWidgetId: 166}, + {name: 'Agility', advancementWidgetId: 157}, + {name: 'Thieving', advancementWidgetId: 176}, + {name: 'Slayer', advancementWidgetId: 173}, + {name: 'Farming', advancementWidgetId: 162}, + {name: 'Runecrafting', advancementWidgetId: 172}, null, - { name: 'Construction' } + {name: 'Construction'} ]; export interface SkillValue { @@ -135,7 +135,7 @@ export class Skills extends SkillShortcuts { this[skillName] = new SkillShortcut(this, skillName as SkillName) ); - if(values) { + if (values) { this._values = values; } else { this._values = this.defaultValues(); @@ -148,18 +148,17 @@ export class Skills extends SkillShortcuts { } public hasLevel(skill: number | SkillName, level: number, ignoreLevelModifications: boolean = false): boolean { - const s = this.get(skill); - return (ignoreLevelModifications ? s.level : s.modifiedLevel) >= level; + return this.getLevel(skill, ignoreLevelModifications) >= level; } public getLevelForExp(exp: number): number { let points = 0; let output = 0; - for(let i = 1; i <= 99; i++) { + for (let i = 1; i <= 99; i++) { points += Math.floor(i + 300 * Math.pow(2, i / 7)); output = Math.floor(points / 4); - if(output >= exp) { + if (output >= exp) { return i; } } @@ -171,7 +170,7 @@ export class Skills extends SkillShortcuts { const currentExp = this.get(skill).exp; const currentLevel = this.getLevelForExp(currentExp); let finalExp = currentExp + (exp * serverConfig.expRate); - if(finalExp > 200000000) { + if (finalExp > 200000000) { finalExp = 200000000; } @@ -179,28 +178,28 @@ export class Skills extends SkillShortcuts { this.setExp(skill, finalExp); - if(this.actor instanceof Player) { + if (this.actor instanceof Player) { this.actor.outgoingPackets.updateSkill(this.getSkillId(skill), finalLevel, finalExp); } - if(currentLevel !== finalLevel) { + if (currentLevel !== finalLevel) { this.setLevel(skill, finalLevel); - if(this.actor instanceof Player) { + if (this.actor instanceof Player) { const achievementDetails = skillDetails[this.getSkillId(skill)]; - if(!achievementDetails) { + if (!achievementDetails) { return; } this.actor.sendMessage(`Congratulations, you just advanced a ` + - `${ achievementDetails.name.toLowerCase() } level.`); + `${achievementDetails.name.toLowerCase()} level.`); this.showLevelUpDialogue(skill, finalLevel); } } } public showLevelUpDialogue(skill: number | SkillName, level: number): void { - if(!(this.actor instanceof Player)) { + if (!(this.actor instanceof Player)) { return; } @@ -208,7 +207,7 @@ export class Skills extends SkillShortcuts { const achievementDetails = skillDetails[this.getSkillId(skill)]; const widgetId = achievementDetails.advancementWidgetId; - if(!widgetId) { + if (!widgetId) { return; } @@ -219,21 +218,25 @@ export class Skills extends SkillShortcuts { type: 'CHAT', closeOnWalk: true, beforeOpened: () => { - player.modifyWidget(widgetId, { childId: 0, - text: `Congratulations, you just advanced ${ startsWithVowel(skillName) ? 'an' : 'a' } ` + - `${ skillName } level.` }); - player.modifyWidget(widgetId, { childId: 1, - text: `Your ${skillName} level is now ${ level }.` }); + player.modifyWidget(widgetId, { + childId: 0, + text: `Congratulations, you just advanced ${startsWithVowel(skillName) ? 'an' : 'a'} ` + + `${skillName} level.` + }); + player.modifyWidget(widgetId, { + childId: 1, + text: `Your ${skillName} level is now ${level}.` + }); }, afterOpened: () => { - player.playGraphics({ id: gfxIds.levelUpFireworks, delay: 0, height: 125 }); + player.playGraphics({id: gfxIds.levelUpFireworks, delay: 0, height: 125}); // @TODO sounds } }); } - public getSkillId(skill: number | SkillName) : number { - if(typeof skill === 'number') { + public getSkillId(skill: number | SkillName): number { + if (typeof skill === 'number') { return skill; } else { const skillName = skill.toString().toUpperCase(); @@ -242,7 +245,7 @@ export class Skills extends SkillShortcuts { } public get(skill: number | SkillName): SkillValue { - if(typeof skill === 'number') { + if (typeof skill === 'number') { return this._values[skill]; } else { const skillName = skill.toString().toUpperCase(); @@ -252,8 +255,8 @@ export class Skills extends SkillShortcuts { private defaultValues(): SkillValue[] { const values: SkillValue[] = []; - skillDetails.forEach(s => values.push({ exp: 0, level: 1 })); - values[Skill.HITPOINTS] = { exp: 1154, level: 10 }; + skillDetails.forEach(s => values.push({exp: 0, level: 1})); + values[Skill.HITPOINTS] = {exp: 1154, level: 10}; return values; } diff --git a/src/world/config/harvest-tool.ts b/src/world/config/harvest-tool.ts index be7f95198..6cb83d3e0 100644 --- a/src/world/config/harvest-tool.ts +++ b/src/world/config/harvest-tool.ts @@ -5,8 +5,6 @@ export interface HarvestTool { itemId: number; level: number; animation: number; - pulses: number; - modifier: number; } @@ -31,23 +29,23 @@ export enum Axe { const Pickaxes: HarvestTool[] = [ - {itemId: 1265, level: 1, animation: 625, pulses: 8, modifier: 0}, - {itemId: 1267, level: 1, animation: 626, pulses: 7, modifier: 0}, - {itemId: 1269, level: 6, animation: 627, pulses: 6, modifier: 0}, - {itemId: 1273, level: 21, animation: 629, pulses: 5, modifier: 0}, - {itemId: 1271, level: 31, animation: 628, pulses: 4, modifier: 0}, - {itemId: 1275, level: 41, animation: 624, pulses: 3, modifier: 0} + {itemId: 1265, level: 1, animation: 625}, + {itemId: 1267, level: 1, animation: 626}, + {itemId: 1269, level: 6, animation: 627}, + {itemId: 1273, level: 21, animation: 629}, + {itemId: 1271, level: 31, animation: 628}, + {itemId: 1275, level: 41, animation: 624} ]; const Axes: HarvestTool[] = [ - {itemId: 1351, level: 1, animation: 879, pulses: 8, modifier: 0}, - {itemId: 1349, level: 1, animation: 877, pulses: 7, modifier: 0}, - {itemId: 1353, level: 6, animation: 875, pulses: 6, modifier: 0}, - {itemId: 1355, level: 21, animation: 871, pulses: 5, modifier: 0}, - {itemId: 1357, level: 31, animation: 869, pulses: 4, modifier: 0}, - {itemId: 1359, level: 41, animation: 867, pulses: 3, modifier: 0}, - {itemId: 6739, level: 61, animation: 2846, pulses: 3, modifier: 10} + {itemId: 1351, level: 1, animation: 879}, + {itemId: 1349, level: 1, animation: 877}, + {itemId: 1353, level: 6, animation: 875}, + {itemId: 1355, level: 21, animation: 871}, + {itemId: 1357, level: 31, animation: 869}, + {itemId: 1359, level: 41, animation: 867}, + {itemId: 6739, level: 61, animation: 2846} ]; /** diff --git a/src/world/config/harvestable-object.ts b/src/world/config/harvestable-object.ts index 8a0d4ab5c..a56a895f6 100644 --- a/src/world/config/harvestable-object.ts +++ b/src/world/config/harvestable-object.ts @@ -5,124 +5,54 @@ export interface IHarvestable { itemId: number; level: number; experience: number; - respawn: number; - chance: number; - chanceOffset: number; + respawnLow: number; + respawnHigh: number; + baseChance: number; break: number; } // Object maps work with key is mineable object, value is empty ore const CLAY_OBJECTS: Map = new Map([ - [2108, 450], - [2109, 451], - [14904, 14896], - [14905, 14897] -]); + ...objectIds.default.clay.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const COPPER_OBJECTS: Map = new Map([ - [11960, 11555], - [11961, 11556], - [11962, 11557], - [11936, 11552], - [11937, 11553], - [11938, 11554], - [2090, 450], - [2091, 451], - [14906, 14898], - [14907, 14899], - [14856, 14832], - [14857, 14833], - [14858, 14834] -]); + ...objectIds.default.copper.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const TIN_OBJECTS: Map = new Map([ - [11597, 11555], - [11958, 11556], - [11959, 11557], - [11933, 11552], - [11934, 11553], - [11935, 11554], - [2094, 450], - [2095, 451], - [14092, 14894], - [14903, 14895] -]); + ...objectIds.default.tin.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const IRON_OBJECTS: Map = new Map([ - [11954, 11555], - [11955, 11556], - [11956, 11557], - [2092, 450], - [2093, 451], - [14900, 14892], - [14901, 14893], - [14913, 14915], - [14914, 14916] -]); + ...objectIds.default.iron.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const COAL_OBJECTS: Map = new Map([ - [11963, 11555], - [11964, 11556], - [11965, 11557], - [11930, 11552], - [11931, 11553], - [11932, 11554], - [2096, 450], - [2097, 451], - [14850, 14832], - [14851, 14833], - [14852, 14834] -]); + ...objectIds.default.coal.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const SILVER_OBJECTS: Map = new Map([ - [11948, 11555], - [11949, 11556], - [11950, 11557], - [2100, 450], - [2101, 451] -]); + ...objectIds.default.silver.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const GOLD_OBJECTS: Map = new Map([ - [11951, 11555], - [11952, 11556], - [11953, 11557], - [2098, 450], - [2099, 451] -]); + ...objectIds.default.gold.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const MITHRIL_OBJECTS: Map = new Map([ - [11945, 11555], - [11946, 11556], - [11947, 11557], - [11942, 11552], - [11943, 11553], - [11944, 11554], - [2102, 450], - [2103, 451], - [14853, 14832], - [14854, 14833], - [14855, 14834] -]); + ...objectIds.default.mithril.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); + const ADAMANT_OBJECTS: Map = new Map([ - [11939, 11552], - [11940, 11553], - [11941, 11554], - [2104, 450], - [2105, 451], - [14862, 14832], - [14863, 14833], - [14864, 14834] -]); + ...objectIds.default.adamant.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const RUNITE_OBJECTS: Map = new Map([ - [2106, 450], - [2107, 451], - [14859, 14832], - [14860, 14833], - [14861, 14834] -]); + ...objectIds.default.runite.map((tree) => [tree.default, tree.empty]), +] as [number, number][]); const NORMAL_OBJECTS: Map = new Map([ ...objectIds.tree.normal.map((tree) => [tree.default, tree.stump]), @@ -139,43 +69,32 @@ const OAK_OBJECTS: Map = new Map([ const WILLOW_OBJECTS: Map = new Map([ - [5551, 8489], - [1308, 8489], - [5552, 8489], - [5553, 8489], - [8481, 8489], - [8482, 8489], - [8483, 8489], - [8484, 8489], - [8485, 8489], - [8486, 8489], - [8487, 8489], - [8488, 8489], -]); + ...objectIds.tree.willow.map((tree) => [tree.default, tree.stump]), +] as [number, number][]); const TEAK_OBJECTS: Map = new Map([ - [9036, 1342], -]); + ...objectIds.tree.teak.map((tree) => [tree.default, tree.stump]), +] as [number, number][]); const MAPLE_OBJECTS: Map = new Map([ - [1307, 1342], - [4674, 1342], -]); + ...objectIds.tree.maple.map((tree) => [tree.default, tree.stump]), +] as [number, number][]); + const MAHOGANY_OBJECTS: Map = new Map([ - [9034, 1342], -]); + ...objectIds.tree.mahogany.map((tree) => [tree.default, tree.stump]), +] as [number, number][]); + const YEW_OBJECTS: Map = new Map([ - [1309, 1342], -]); + ...objectIds.tree.yew.map((tree) => [tree.default, tree.stump]), +] as [number, number][]); const MAGIC_OBJECTS: Map = new Map([ - [1292, 1324], -]); - + ...objectIds.tree.magic.map((tree) => [tree.default, tree.stump]), +] as [number, number][]); export enum Ore { CLAY, @@ -210,9 +129,9 @@ const Ores: IHarvestable[] = [ itemId: 434, level: 1, experience: 5.0, - respawn: 1, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 5, + respawnHigh: 10, + baseChance: 70, break: 100 }, { @@ -220,9 +139,9 @@ const Ores: IHarvestable[] = [ itemId: 436, level: 1, experience: 17.5, - respawn: 4, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 10, + respawnHigh: 20, + baseChance: 70, break: 100 }, { @@ -230,9 +149,9 @@ const Ores: IHarvestable[] = [ itemId: 438, level: 1, experience: 17.5, - respawn: 4, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 10, + respawnHigh: 20, + baseChance: 70, break: 100 }, { @@ -240,9 +159,9 @@ const Ores: IHarvestable[] = [ itemId: 440, level: 15, experience: 35.0, - respawn: 9, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 9, + respawnHigh: 9, + baseChance: 0.0085, break: 100 }, { @@ -250,9 +169,9 @@ const Ores: IHarvestable[] = [ itemId: 453, level: 30, experience: 50.0, - respawn: 50, - chance: 0.004, - chanceOffset: 0, + respawnLow: 20, + respawnHigh: 30, + baseChance: 50, break: 100 }, { @@ -260,9 +179,9 @@ const Ores: IHarvestable[] = [ itemId: 442, level: 20, experience: 40.0, - respawn: 100, - chance: 0.0085, - chanceOffset: 0, + respawnLow: 30, + respawnHigh: 40, + baseChance: 40, break: 100 }, { @@ -270,19 +189,19 @@ const Ores: IHarvestable[] = [ itemId: 444, level: 40, experience: 65.0, - respawn: 100, - chance: 0.003, - chanceOffset: 0, + respawnLow: 50, + respawnHigh: 70, + baseChance: 30, break: 100 }, { objects: MITHRIL_OBJECTS, itemId: 447, level: 55, - experience: 80.0, - respawn: 200, - chance: 0.002, - chanceOffset: 0, + experience: 65.0, + respawnLow: 90, + respawnHigh: 120, + baseChance: 20, break: 100 }, { @@ -290,9 +209,9 @@ const Ores: IHarvestable[] = [ itemId: 449, level: 70, experience: 95.0, - respawn: 800, - chance: 0.001, - chanceOffset: 0, + respawnLow: 200, + respawnHigh: 400, + baseChance: 0, break: 100 }, { @@ -300,9 +219,9 @@ const Ores: IHarvestable[] = [ itemId: 451, level: 85, experience: 125.0, - respawn: 1200, - chance: 0.0008, - chanceOffset: 0, + respawnLow: 1200, + respawnHigh: 1200, + baseChance: -10, break: 100 } ]; @@ -313,9 +232,9 @@ const Trees: IHarvestable[] = [ itemId: 1511, level: 1, experience: 25, - respawn: 1, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 10, + respawnHigh: 20, + baseChance: 70, break: 100 }, { @@ -323,9 +242,9 @@ const Trees: IHarvestable[] = [ itemId: 2862, level: 1, experience: 25, - respawn: 4, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 10, + respawnHigh: 20, + baseChance: 70, break: 100 }, { @@ -333,9 +252,9 @@ const Trees: IHarvestable[] = [ itemId: 1521, level: 15, experience: 37.5, - respawn: 4, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 20, + respawnHigh: 30, + baseChance: 50, break: 100 / 8 }, { @@ -343,9 +262,9 @@ const Trees: IHarvestable[] = [ itemId: 1519, level: 30, experience: 67.5, - respawn: 9, - chance: 0.0085, - chanceOffset: 0.45, + respawnLow: 40, + respawnHigh: 50, + baseChance: 30, break: 100 / 8 }, { @@ -353,9 +272,9 @@ const Trees: IHarvestable[] = [ itemId: 6333, level: 35, experience: 85, - respawn: 50, - chance: 0.004, - chanceOffset: 0, + respawnLow: 50, + respawnHigh: 60, + baseChance: 0, break: 100 / 8 }, { @@ -363,9 +282,9 @@ const Trees: IHarvestable[] = [ itemId: 1517, level: 45, experience: 100, - respawn: 100, - chance: 0.0085, - chanceOffset: 0, + respawnLow: 100, + respawnHigh: 120, + baseChance: 0, break: 100 / 8 }, { @@ -373,9 +292,9 @@ const Trees: IHarvestable[] = [ itemId: 6332, level: 50, experience: 125, - respawn: 100, - chance: 0.003, - chanceOffset: 0, + respawnLow: 200, + respawnHigh: 220, + baseChance: -5, break: 100 / 8 }, { @@ -383,9 +302,9 @@ const Trees: IHarvestable[] = [ itemId: 1515, level: 60, experience: 175, - respawn: 200, - chance: 0.002, - chanceOffset: 0, + respawnLow: 300, + respawnHigh: 320, + baseChance: -15, break: 100 / 8 }, { @@ -393,9 +312,9 @@ const Trees: IHarvestable[] = [ itemId: 1513, level: 75, experience: 250, - respawn: 800, - chance: 0.001, - chanceOffset: 0, + respawnLow: 800, + respawnHigh: 820, + baseChance: -25, break: 100 / 8 }, ]; diff --git a/src/world/config/object-ids.ts b/src/world/config/object-ids.ts index ee1dd875b..af651ef40 100644 --- a/src/world/config/object-ids.ts +++ b/src/world/config/object-ids.ts @@ -24,52 +24,155 @@ export const objectIds = { skeletonLayingAgainstWall: 5359, tree: { normal: [ - { - default: 1276, - stump: 1342, - }, - { - default: 1278, - stump: 1342, - } + {default: 1276, stump: 1342}, + {default: 1278, stump: 1342} ], dead: [ - { - default: 1282, - stump: 1347, - }, - { - default: 1283, - stump: 1347, - }, - { - default: 1286, - stump: 1351, - }, - { - default: 1289, - stump: 1353, - }, - { - default: 1365, - stump: 1352, - } + {default: 1282, stump: 1347}, + {default: 1283, stump: 1347}, + {default: 1286, stump: 1351}, + {default: 1289, stump: 1353}, + {default: 1365, stump: 1352} ], archey: [ - { - default: 2023, - stump: 3371 - } + {default: 2023, stump: 3371} ], oak: [ - { - default: 1281, - stump: 1342 - }, - { - default: 3037, - stump: 1342 - } + {default: 1281, stump: 1342}, + {default: 3037, stump: 1342} + ], + willow: [ + {default: 5551, stump: 1324}, + {default: 1308, stump: 1324}, + {default: 5552, stump: 1324}, + {default: 5553, stump: 1324}, + {default: 8481, stump: 1324}, + {default: 8482, stump: 1324}, + {default: 8483, stump: 1324}, + {default: 8484, stump: 1324}, + {default: 8485, stump: 1324}, + {default: 8486, stump: 1324}, + {default: 8487, stump: 1324}, + {default: 8488, stump: 1324}, + ], + teak: [ + {default: 9036, stump: 1342}, + ], + maple: [ + {default: 1307, stump: 1342}, + {default: 4674, stump: 1342}, + ], + mahogany: [ + {default: 9034, stump: 1342}, + ], + yew: [ + {default: 1309, stump: 1342}, + ], + magic: [ + {default: 1292, stump: 1324}, + ], + }, + default: { + clay: [ + {default: 2108, empty: 450}, + {default: 2109, empty: 451}, + {default: 14904, empty: 14896}, + {default: 14905, empty: 14897} + ], + copper: [ + {default: 11960, empty: 11555}, + {default: 11961, empty: 11556}, + {default: 11962, empty: 11557}, + {default: 11936, empty: 11552}, + {default: 11937, empty: 11553}, + {default: 11938, empty: 11554}, + {default: 2090, empty: 450}, + {default: 2091, empty: 451}, + {default: 14906, empty: 14898}, + {default: 14907, empty: 14899}, + {default: 14856, empty: 14832}, + {default: 14857, empty: 14833}, + {default: 14858, empty: 14834} + ], + tin: [ + {default: 11597, empty: 11555}, + {default: 11958, empty: 11556}, + {default: 11959, empty: 11557}, + {default: 11933, empty: 11552}, + {default: 11934, empty: 11553}, + {default: 11935, empty: 11554}, + {default: 2094, empty: 450}, + {default: 2095, empty: 451}, + {default: 14092, empty: 14894}, + {default: 14903, empty: 14895} + ], + iron: [ + {default: 11954, empty: 11555}, + {default: 11955, empty: 11556}, + {default: 11956, empty: 11557}, + {default: 2092, empty: 450}, + {default: 2093, empty: 451}, + {default: 14900, empty: 14892}, + {default: 14901, empty: 14893}, + {default: 14913, empty: 14915}, + {default: 14914, empty: 14916} + ], + coal: [ + {default: 11963, empty: 11555}, + {default: 11964, empty: 11556}, + {default: 11965, empty: 11557}, + {default: 11930, empty: 11552}, + {default: 11931, empty: 11553}, + {default: 11932, empty: 11554}, + {default: 2096, empty: 450}, + {default: 2097, empty: 451}, + {default: 14850, empty: 14832}, + {default: 14851, empty: 14833}, + {default: 14852, empty: 14834} + ], + silver: [ + {default: 11948, empty: 11555}, + {default: 11949, empty: 11556}, + {default: 11950, empty: 11557}, + {default: 2100, empty: 450}, + {default: 2101, empty: 451} + ], + gold: [ + {default: 11951, empty: 11555}, + {default: 11952, empty: 11556}, + {default: 11953, empty: 11557}, + {default: 2098, empty: 450}, + {default: 2099, empty: 451} + ], + mithril: [ + {default: 11945, empty: 11555}, + {default: 11946, empty: 11556}, + {default: 11947, empty: 11557}, + {default: 11942, empty: 11552}, + {default: 11943, empty: 11553}, + {default: 11944, empty: 11554}, + {default: 2102, empty: 450}, + {default: 2103, empty: 451}, + {default: 14853, empty: 14832}, + {default: 14854, empty: 14833}, + {default: 14855, empty: 14834} + ], + adamant: [ + {default: 11939, empty: 11552}, + {default: 11940, empty: 11553}, + {default: 11941, empty: 11554}, + {default: 2104, empty: 450}, + {default: 2105, empty: 451}, + {default: 14862, empty: 14832}, + {default: 14863, empty: 14833}, + {default: 14864, empty: 14834} + ], + runite: [ + {default: 2106, empty: 450}, + {default: 2107, empty: 451}, + {default: 14859, empty: 14832}, + {default: 14860, empty: 14833}, + {default: 14861, empty: 14834} ] } }; diff --git a/src/world/skill-util/harvest-skill.ts b/src/world/skill-util/harvest-skill.ts index 240d49ebc..ffc5f4e2c 100644 --- a/src/world/skill-util/harvest-skill.ts +++ b/src/world/skill-util/harvest-skill.ts @@ -101,11 +101,17 @@ export function handleHarvesting(details: ObjectActionDetails, tool: HarvestTool let elapsedTicks = 0; loop.event.subscribe(() => { + // Check if the amount of ticks passed equal the tools pulses - if (elapsedTicks % tool.pulses === 0 && elapsedTicks != 0) { - const successChance = randomBetween(0, 100); - const percentNeeded = (target.chance * details.player.skills.values[skill].level + target.chanceOffset) * 100; - if (successChance < percentNeeded) { + if (elapsedTicks % 3 === 0 && elapsedTicks != 0) { + const successChance = randomBetween(0, 255); + let toolLevel = tool.level - 1; + if (tool.itemId === 1349 || tool.itemId === 1267) { + toolLevel = 2; + } + const percentNeeded = target.baseChance + toolLevel + details.player.skills.values[skill].level; + details.player.sendMessage(`roll: ${successChance}, needed: ${percentNeeded}`); + if (successChance <= percentNeeded) { if (details.player.inventory.hasSpace()) { switch (skill) { @@ -120,7 +126,7 @@ export function handleHarvesting(details: ObjectActionDetails, tool: HarvestTool details.player.skills.addExp(skill, target.experience); if (randomBetween(0, 100) <= target.break) { details.player.playSound(soundIds.oreDepeleted); - world.replaceLocationObject(target.objects.get(details.object.objectId), details.object, target.respawn); + world.replaceLocationObject(target.objects.get(details.object.objectId), details.object, randomBetween(target.respawnLow, target.respawnHigh)); loop.cancel(); details.player.playAnimation(null); return; @@ -144,11 +150,11 @@ export function handleHarvesting(details: ObjectActionDetails, tool: HarvestTool break; } } - if (elapsedTicks % 3 == 0 && elapsedTicks != 0) { - details.player.playAnimation(tool.animation); - } } - + if (elapsedTicks % 3 == 0 && elapsedTicks != 0) { + details.player.playAnimation(tool.animation); + } elapsedTicks++; - }, () => {}, () => details.player.playAnimation(null)); + }, () => { + }, () => details.player.playAnimation(null)); }