Skip to content

Commit

Permalink
Mining command/trip refactoring and wiki page
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Oct 16, 2024
1 parent 2355fdf commit c804bda
Show file tree
Hide file tree
Showing 21 changed files with 429 additions and 261 deletions.
40 changes: 15 additions & 25 deletions docs/src/content/docs/getting-started/wiki.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ This is an automatically generated list of pages with possible issues to be look

[/bso/leagues.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/leagues.md): Doesnt use the new command formatting

[/bso/Minigames/balthazars-big-bonanza.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Minigames/balthazars-big-bonanza.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)
[/bso/Minigames/balthazars-big-bonanza.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Minigames/balthazars-big-bonanza.md): Doesnt use the new command formatting

[/bso/Minigames/baxtorian-bathhouses.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Minigames/baxtorian-bathhouses.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)
[/bso/Minigames/baxtorian-bathhouses.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Minigames/baxtorian-bathhouses.md): Doesnt use the new command formatting

[/bso/Minigames/emerged-zuk-inferno.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Minigames/emerged-zuk-inferno.md): Doesnt use the new command formatting

Expand Down Expand Up @@ -227,13 +227,9 @@ This is an automatically generated list of pages with possible issues to be look

[/bso/Skills/crafting.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/crafting.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Skills/Divination/efficient-divination-training.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Divination/efficient-divination-training.md): Doesnt use the new command formatting
[/bso/Skills/divination.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/divination.md): Doesnt use the new command formatting

[/bso/Skills/Divination/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Divination/README.md): Doesnt use the new command formatting

[/bso/Skills/Dungeoneering Training/dg-rewards.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Dungeoneering%20Training/dg-rewards.md): Doesnt use the new command formatting

[/bso/Skills/Dungeoneering Training/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Dungeoneering%20Training/README.md): Doesnt use the new command formatting
[/bso/Skills/dungeoneering.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/dungeoneering.md): Doesnt use the new command formatting

[/bso/Skills/farming.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/farming.md): Doesnt use the new command formatting

Expand All @@ -247,9 +243,7 @@ This is an automatically generated list of pages with possible issues to be look

[/bso/Skills/hunter.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/hunter.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Skills/Invention/efficient-disassembling-to-99.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Invention/efficient-disassembling-to-99.md): Doesnt use the new command formatting

[/bso/Skills/Invention/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Invention/README.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)
[/bso/Skills/invention.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/invention.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Skills/mining.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/mining.md): Doesnt use the new command formatting

Expand All @@ -269,16 +263,12 @@ This is an automatically generated list of pages with possible issues to be look

[/bso/Tames/eagle-tame.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Tames/eagle-tame.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Tames/igne-equipment.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Tames/igne-equipment.md): Doesnt use the new command formatting

[/bso/Tames/igne-tame.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Tames/igne-tame.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Tames/monkey-staff-and-spells.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Tames/monkey-staff-and-spells.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)
[/bso/Tames/introduction.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Tames/introduction.md): Doesnt use the new command formatting

[/bso/Tames/monkey-tame.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Tames/monkey-tame.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Tames/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Tames/README.md): Doesnt use the new command formatting

[/getting-started/bingo.mdx](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/getting-started/bingo.mdx): Doesnt use the new command formatting

[/getting-started/BSO.mdx](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/getting-started/BSO.mdx): Doesnt use the new command formatting
Expand Down Expand Up @@ -307,6 +297,12 @@ This is an automatically generated list of pages with possible issues to be look

[/osb/Activities/mahogany-homes.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/mahogany-homes.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/osb/Activities/motherlode-mine.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/motherlode-mine.md): Doesnt use the new command formatting

[/osb/Activities/shooting-stars.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/shooting-stars.md): Doesnt use the new command formatting

[/osb/Activities/volcanic-mine.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/volcanic-mine.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/osb/Activities/wintertodt.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/wintertodt.md): Doesnt use the new command formatting

[/osb/Bosses/colosseum.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Bosses/colosseum.md): Doesnt use the new command formatting
Expand Down Expand Up @@ -387,6 +383,8 @@ This is an automatically generated list of pages with possible issues to be look

[/osb/Miscelleanous/tears-of-guthix.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Miscelleanous/tears-of-guthix.md): Doesnt use the new command formatting

[/osb/Miscelleanous/zalcano.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Miscelleanous/zalcano.md): Doesnt use the new command formatting

[/osb/monsters.mdx](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/monsters.mdx): Doesnt use the new command formatting

[/osb/quests.mdx](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/quests.mdx): Doesnt use the new command formatting
Expand Down Expand Up @@ -449,15 +447,7 @@ This is an automatically generated list of pages with possible issues to be look

[/osb/Skills/magic.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/magic.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/osb/Skills/mining/motherlode-mine.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/mining/motherlode-mine.md): Doesnt use the new command formatting

[/osb/Skills/mining/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/mining/README.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/osb/Skills/mining/shooting-stars.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/mining/shooting-stars.md): Doesnt use the new command formatting

[/osb/Skills/mining/volcanic-mine.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/mining/volcanic-mine.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/osb/Skills/mining/zalcano.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/mining/zalcano.md): Doesnt use the new command formatting
[/osb/Skills/mining.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/mining.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/osb/Skills/prayer.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/prayer.md): Doesnt use the new command formatting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,50 @@ The only other thing unidentified minerals can be used to purchase are:

- [[/buy name\:Bag full of gems (minerals)]] - 20 Unidentified minerals

## Ores

<table data-header-hidden><thead><tr><th width="172">Ore Name</th><th width="107" align="center">Minerals</th><th width="151" align="center">Required Level</th><th width="127" align="center">Experience</th><th width="131">XP/Hr @ 99</th></tr></thead><tbody><tr><td><strong>Ore Name</strong></td><td align="center"><strong>Minerals</strong></td><td align="center"><strong>Required Level</strong></td><td align="center"><strong>Experience</strong></td><td><strong>XP/Hr @ 99</strong></td></tr><tr><td>Rune essence</td><td align="center"></td><td align="center">1</td><td align="center">5</td><td>10,288</td></tr><tr><td>Copper ore</td><td align="center"></td><td align="center">1</td><td align="center">17.5</td><td>26,881</td></tr><tr><td>Tin ore</td><td align="center"></td><td align="center">1</td><td align="center">17.5</td><td>26,881</td></tr><tr><td>Saltpetre</td><td align="center"></td><td align="center">1</td><td align="center">0</td><td>0</td></tr><tr><td>Iron ore</td><td align="center">✔</td><td align="center">15</td><td align="center">35</td><td>50,332</td></tr><tr><td>Silver ore</td><td align="center"></td><td align="center">20</td><td align="center">40</td><td>22,454</td></tr><tr><td>Volcanic ash</td><td align="center"></td><td align="center">22</td><td align="center">10</td><td>9,810</td></tr><tr><td>Pure essence</td><td align="center"></td><td align="center">30</td><td align="center">5</td><td>10,288</td></tr><tr><td>Coal</td><td align="center">✔</td><td align="center">30</td><td align="center">50</td><td>31,644</td></tr><tr><td>Gold ore</td><td align="center"></td><td align="center">40</td><td align="center">65</td><td>36,556</td></tr><tr><td>Gem rock</td><td align="center"></td><td align="center">40</td><td align="center">65</td><td>20,865</td></tr><tr><td>Mithril ore</td><td align="center"></td><td align="center">55</td><td align="center">80</td><td>17,231</td></tr><tr><td>Adamantite ore</td><td align="center"></td><td align="center">70</td><td align="center">95</td><td>12,654</td></tr><tr><td>Runite ore</td><td align="center"></td><td align="center">85</td><td align="center">125</td><td>6,731</td></tr><tr><td>Amethyst</td><td align="center">✔</td><td align="center">92</td><td align="center">240</td><td>14,321</td></tr></tbody></table>
## XP/hr

[[embed.miningxphr.start]]
{/_ DO NOT EDIT - This section is auto-generated by the build script _/}
| Ore | XP/hr | Powermining |
| --- | --- | --- |
| [[6983]] | 114,000 | Yes |
| [[6975]] | 81,000 | Yes |
| [[440]] | 77,000 | Yes |
| [[6975]] | 73,000 | No |
| [[442]] | 62,000 | Yes |
| [[6983]] | 60,000 | No |
| [[442]] | 57,000 | No |
| [[440]] | 55,000 | No |
| [[453]] | 44,000 | Yes |
| [[453]] | 38,000 | No |
| [[436]] | 38,000 | Yes |
| [[1625]] | 38,000 | Yes |
| [[444]] | 38,000 | Yes |
| [[438]] | 38,000 | Yes |
| [[444]] | 37,000 | No |
| [[1625]] | 36,000 | No |
| [[447]] | 27,000 | Yes |
| [[447]] | 26,000 | No |
| [[21347]] | 23,000 | Yes |
| [[21347]] | 22,000 | No |
| [[436]] | 19,000 | No |
| [[438]] | 19,000 | No |
| [[449]] | 16,000 | Yes |
| [[449]] | 15,000 | No |
| [[21622]] | 13,000 | Yes |
| [[21622]] | 13,000 | No |
| [[434]] | 11,000 | Yes |
| [[24706]] | 10,000 | Yes |
| [[24706]] | 10,000 | No |
| [[7936]] | 10,000 | Yes |
| [[1436]] | 10,000 | Yes |
| [[451]] | 10,000 | Yes |
| [[451]] | 10,000 | No |
| [[7936]] | 7,000 | No |
| [[1436]] | 7,000 | No |
| [[434]] | 5,000 | No |
| [[13421]] | 0 | Yes |
| [[13421]] | 0 | No |

{/_ DO NOT EDIT - This section is auto-generated by the build script _/}
[[embed.miningxphr.end]]
6 changes: 5 additions & 1 deletion scripts/wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { glob } from 'glob';
import { Bank, Monsters } from 'oldschooljs';

import '../src/lib/safeglobals';
import process from 'node:process';
import { groupBy } from 'remeda';
import { type CombatAchievement, CombatAchievements } from '../src/lib/combat_achievements/combatAchievements';
import { COXMaxMageGear, COXMaxMeleeGear, COXMaxRangeGear, itemBoosts } from '../src/lib/data/cox';
Expand All @@ -12,6 +13,7 @@ import { quests } from '../src/lib/minions/data/quests';
import { sorts } from '../src/lib/sorts';
import { itemNameFromID } from '../src/lib/util';
import { Markdown, Tab, Tabs } from './markdown/markdown';
import { miningXpHr } from './wiki/miningXphr';

function combatAchievementHowToFinish(ca: CombatAchievement) {
if ('rng' in ca) {
Expand All @@ -27,7 +29,7 @@ function combatAchievementHowToFinish(ca: CombatAchievement) {
throw ca;
}

function handleMarkdownEmbed(identifier: string, filePath: string, contentToInject: string) {
export function handleMarkdownEmbed(identifier: string, filePath: string, contentToInject: string) {
const contentToReplace = readFileSync(`./docs/src/content/docs/${filePath}`, 'utf8');
const startMarker = `[[embed.${identifier}.start]]`;
const endMarker = `[[embed.${identifier}.end]]`;
Expand Down Expand Up @@ -435,7 +437,9 @@ async function wiki() {
renderQuestsMarkdown();
rendeCoxMarkdown();
wikiIssues();
miningXpHr();
await Promise.all([renderCAMarkdown(), renderMonstersMarkdown()]);
process.exit(0);
}

wiki();
54 changes: 54 additions & 0 deletions scripts/wiki/miningXphr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { calcPerHour } from '@oldschoolgg/toolkit';
import { Time } from 'e';

import Mining from '../../src/lib/skilling/skills/mining';
import type { Ore } from '../../src/lib/skilling/types';
import { determineMiningTrip } from '../../src/mahoji/commands/mine';
import { determineMiningResult } from '../../src/tasks/minions/miningActivity';
import { makeGearBank } from '../../tests/unit/utils';
import { Table } from '../markdown/markdown';
import { handleMarkdownEmbed } from '../wiki';

export function miningXpHr() {
const gearBank = makeGearBank();
gearBank.skillsAsLevels.mining = 99;
gearBank.skillsAsXP.mining = 13_500_000;
gearBank.gear.skilling.equip('Varrock armour 4');
gearBank.gear.skilling.equip('Expert mining gloves');
gearBank.gear.skilling.equip('Crystal pickaxe');
gearBank.skillsAsLevels.crafting = 99;

const results: { xpHr: number; ore: Ore; isPowermining: boolean }[] = [];
for (const ore of Mining.Ores) {
for (const isPowermining of [true, false]) {
const trip = determineMiningTrip({
gearBank,
ore,
maxTripLength: Time.Hour * 1000,
isPowermining,
quantityInput: undefined
});
const result = determineMiningResult({
ore,
quantity: trip.quantity,
gearBank,
duration: trip.duration,
isPowermining
});
const xp = result.updateBank.xpBank.amount('mining');
const xpHr = Math.floor(calcPerHour(xp, trip.duration) / 1000) * 1000;
results.push({ xpHr, ore, isPowermining });
}
}

results.sort((a, b) => a.ore.name.localeCompare(b.ore.name));
results.sort((a, b) => b.xpHr - a.xpHr);

const table = new Table();
table.addHeader('Ore', 'XP/hr', 'Powermining');
for (const result of results) {
table.addRow(`[[${result.ore.id}]]`, result.xpHr.toLocaleString(), result.isPowermining ? 'Yes' : 'No');
}

handleMarkdownEmbed('miningxphr', 'osb/Skills/mining.md', table.toString());
}
3 changes: 2 additions & 1 deletion src/lib/MUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export class MUserClass {
gear: this.gear,
bank: this.bank,
skillsAsLevels: this.skillsAsLevels,
chargeBank: this.ownedChargeBank()
chargeBank: this.ownedChargeBank(),
skillsAsXP: this.skillsAsXP
});
}

Expand Down
5 changes: 3 additions & 2 deletions src/lib/minions/functions/addSkillingClueToLoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
treeSeedsNest
} from '../../simulation/birdsNest';
import { SkillsEnum } from '../../skilling/types';
import { GearBank } from '../../structures/GearBank';
import { randFloat, roll } from '../../util';
import itemID from '../../util/itemID';

Expand All @@ -22,7 +23,7 @@ const clues = [
];

export default function addSkillingClueToLoot(
user: MUser,
user: MUser | GearBank,
skill: SkillsEnum,
quantity: number,
clueChance: number,
Expand All @@ -32,7 +33,7 @@ export default function addSkillingClueToLoot(
twitcherSetting?: string,
wcCapeNestBoost?: boolean
) {
const userLevel = user.skillLevel(skill);
const userLevel = user instanceof GearBank ? user.skillsAsLevels[skill] : user.skillLevel(skill);
const nestChance = wcCapeNestBoost ? Math.floor(256 * 0.9) : 256;
const cluesTotalWeight = sumArr(clues.map(c => c[1]));
let chance = Math.floor(clueChance / (100 + userLevel));
Expand Down
14 changes: 8 additions & 6 deletions src/lib/skilling/functions/determineMiningTime.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Time, percentChance } from 'e';

import { calcMaxTripLength } from '../../util/calcMaxTripLength';
import type { GearBank } from '../../structures/GearBank';
import type { Ore } from './../types';

interface MiningTimeOptions {
quantity: number | undefined;
user: MUser;
ore: Ore;
ticksBetweenRolls: number;
glovesRate: number;
Expand All @@ -15,11 +14,12 @@ interface MiningTimeOptions {
goldSilverBoost: boolean;
miningLvl: number;
passedDuration?: number;
maxTripLength: number;
gearBank: GearBank;
}

export function determineMiningTime({
quantity,
user,
ore,
ticksBetweenRolls,
glovesRate,
Expand All @@ -28,10 +28,12 @@ export function determineMiningTime({
powermining,
goldSilverBoost,
miningLvl,
passedDuration
passedDuration,
maxTripLength,
gearBank
}: MiningTimeOptions): [number, number] {
let { intercept } = ore;
if (ore.name === 'Gem rock' && user.hasEquipped('Amulet of glory')) {
if (ore.name === 'Gem rock' && gearBank.hasEquipped('Amulet of glory')) {
intercept *= 3;
}
let timeElapsed = 0;
Expand All @@ -46,7 +48,7 @@ export function determineMiningTime({
passedDuration = 0;
}

let userMaxTripTicks = (calcMaxTripLength(user, 'Mining') - passedDuration) / (Time.Second * 0.6);
let userMaxTripTicks = (maxTripLength - passedDuration) / (Time.Second * 0.6);

if (ore.name === 'Amethyst' || ore.name === 'Daeyalt essence rock') {
userMaxTripTicks *= 1.5;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/skilling/skills/mining.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ const prospectorItems: { [key: number]: number } = {
[itemID('Prospector boots')]: 0.2
};

export const prospectorItemsArr = Object.entries(prospectorItems).map(([itemID, bonus]) => ({
id: Number.parseInt(itemID),
boostPercent: bonus
}));

const Mining = {
aliases: ['mining'],
Ores: ores,
Expand Down
Loading

0 comments on commit c804bda

Please sign in to comment.