Skip to content

Commit

Permalink
Monster gp/loot per hour simulating (#5782)
Browse files Browse the repository at this point in the history
  • Loading branch information
gc authored Mar 17, 2024
1 parent b740676 commit c5882ca
Showing 1 changed file with 67 additions and 7 deletions.
74 changes: 67 additions & 7 deletions src/mahoji/commands/rates.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { bold } from '@discordjs/builders';
import { InteractionReplyOptions } from 'discord.js';
import { Time } from 'e';
import { increaseNumByPercent, reduceNumByPercent, sumArr, Time } from 'e';
import { ApplicationCommandOptionType, CommandRunOptions } from 'mahoji';
import { Bank } from 'oldschooljs';
import { Item } from 'oldschooljs/dist/meta/types';

import { calcAtomicEnergy, divinationEnergies, memoryHarvestTypes } from '../../lib/bso/divination';
import { ClueTiers } from '../../lib/clues/clueTiers';
import { GLOBAL_BSO_XP_MULTIPLIER, PeakTier } from '../../lib/constants';
import { inventionBoosts } from '../../lib/invention/inventions';
import { marketPriceOfBank } from '../../lib/marketPrices';
import killableMonsters from '../../lib/minions/data/killableMonsters';
import { stoneSpirits } from '../../lib/minions/data/stoneSpirits';
import Agility from '../../lib/skilling/skills/agility';
Expand All @@ -26,7 +28,7 @@ import Mining from '../../lib/skilling/skills/mining';
import Smithing from '../../lib/skilling/skills/smithing';
import { HunterTechniqueEnum } from '../../lib/skilling/types';
import { Gear } from '../../lib/structures/Gear';
import { convertBankToPerHourStats, stringMatches } from '../../lib/util';
import { convertBankToPerHourStats, stringMatches, toKMB } from '../../lib/util';
import { calcMaxTripLength } from '../../lib/util/calcMaxTripLength';
import { deferInteraction } from '../../lib/util/interactionReply';
import itemID from '../../lib/util/itemID';
Expand Down Expand Up @@ -192,18 +194,76 @@ ${zygomiteFarmingSource
if (options.monster?.monster) {
const monster = killableMonsters.find(m => stringMatches(m.name, options.monster!.monster!.name));
if (!monster) {
return 'HUH?';
return 'Invalid monster.';
}

if (user.id !== '157797566833098752') {
return 'This command is currently disabled.';
}

let { timeToFinish } = monster;
// 10% for learning
timeToFinish = reduceNumByPercent(timeToFinish, 10);

// 2x for BSO
timeToFinish /= 2;

if (monster.pohBoosts) {
const totalBoostPercent = sumArr(Object.values(monster.pohBoosts).map(val => Object.values(val)[0]));
timeToFinish = reduceNumByPercent(timeToFinish, totalBoostPercent);
}

if (monster.itemInBankBoosts) {
const boosts = sumArr(monster.itemInBankBoosts.map(b => Object.values(b)[0]));
timeToFinish = reduceNumByPercent(timeToFinish, boosts);
}

if (!monster.wildy) {
// boosts.push('40% boost for Dwarven warhammer');
timeToFinish = reduceNumByPercent(timeToFinish, 40);
} else if (monster.wildy) {
timeToFinish /= 3;
// boosts.push('3x boost for Hellfire bow');
}

timeToFinish = reduceNumByPercent(timeToFinish, 15);

if (monster.equippedItemBoosts) {
for (const boostSet of monster.equippedItemBoosts) {
const equippedInThisSet = boostSet.items[0];
if (equippedInThisSet) {

Check warning on line 234 in src/mahoji/commands/rates.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

Unexpected object value in conditional. The condition is always true

Check warning on line 234 in src/mahoji/commands/rates.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected object value in conditional. The condition is always true
timeToFinish = reduceNumByPercent(timeToFinish, equippedInThisSet.boostPercent);
}
}
}

const sampleSize = 100_000;
const loot = monster.table.kill(sampleSize, {});
let totalTime = monster.timeToFinish * sampleSize;
let boostedSize = increaseNumByPercent(sampleSize, 25);

let str = "''";
const loot = monster.table.kill(boostedSize, {});
let totalTime = timeToFinish * sampleSize;

let str = `${monster.name}\n`;

const results: { item: Item; qty: number; perHour: number; valuePerHour: number }[] = [];
for (const [item, qty] of loot.items()) {
const perHour = calcPerHour(qty, totalTime);
str += `${item.name}: ${perHour}/hr\n`;
const valuePerHour = calcPerHour(marketPriceOfBank(new Bank().add(item, qty)), totalTime);
results.push({ item, qty, perHour, valuePerHour });
}
results.sort((a, b) => b.valuePerHour - a.valuePerHour);
str += '\nTop 10 most valuable item drops:\n';
for (const { item, perHour, valuePerHour } of results.slice(0, 10)) {
str += `${item.name}: ${perHour.toFixed(2)}/hr ${toKMB(valuePerHour)} GP/hr\n`;
}

str += '\n';

str += `Based on market/bot prices, this monster produces ${toKMB(
calcPerHour(marketPriceOfBank(loot), totalTime)
)}/hr in GP.`;

str += '\n\nAssumes max learning, poh boosts, all item boosts, DWWH/HFB, Ori.';
return str;
}
if (options.xphr?.hunter) {
Expand Down

0 comments on commit c5882ca

Please sign in to comment.