Skip to content
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

Add KingGoldemar Sim #6188

Merged
merged 5 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/lib/simulation/simulatedKillables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { randArrItem, randInt, roll } from 'e';
import { DOANonUniqueTable } from '../bso/doa/doaLootTable';
import { nexUniqueDrops } from '../data/CollectionsExport';
import { chanceOfDOAUnique, pickUniqueToGiveUser } from '../depthsOfAtlantis';
import { KingGoldemarLootTable } from '../minions/data/killableMonsters/custom/bosses/KingGoldemar';
import { MoktangLootTable } from '../minions/data/killableMonsters/custom/bosses/Moktang';
import { NEX_UNIQUE_DROPRATE, nexLootTable } from '../nex';
import { zygomiteFarmingSource } from '../skilling/skills/farming/zygomites';
import { calcDwwhChance } from '../structures/Boss';
import { WintertodtCrate } from './wintertodt';

export const winterTodtPointsTable = new SimpleTable<number>()
Expand Down Expand Up @@ -36,6 +38,7 @@ export const winterTodtPointsTable = new SimpleTable<number>()
interface SimulatedKillable {
name: string;
isCustom: boolean;
message?: string;
loot: (quantity: number) => Bank;
}
const emptyBank = new Bank();
Expand Down Expand Up @@ -120,6 +123,21 @@ export const simulatedKillables: SimulatedKillable[] = [
return loot;
}
},
{
name: 'King Goldemar',
isCustom: true,
message: '**Assumptions**:\n- Solo\n- Ring of Luck equipped',
loot: (quantity: number): Bank => {
const loot = new Bank();
for (let i = 0; i < quantity; i++) {
if (roll(calcDwwhChance(1, true))) {
loot.add('Broken dwarven warhammer');
}
}
loot.add(KingGoldemarLootTable.roll(quantity));
return loot;
}
},
{
name: 'Moktang',
isCustom: true,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/structures/Boss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import type { Gear } from './Gear';
export const gpCostPerKill = (user: MUser) =>
user.gear.melee.hasEquipped(['Ring of charos', 'Ring of charos(a)'], false) ? 5_000_000 : 10_000_000;

export const calcDwwhChance = (users: MUser[]) => {
const size = Math.min(users.length, 10);
export const calcDwwhChance = (amount: number, hasROL: boolean) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calcDwwhChance function signature has changed, but this call still uses the old signature. Update the call to use the new parameters: calcDwwhChance(bossUsers.length, bossUsers.some(i => i.user.gear.melee.hasEquipped('Ring of luck'))).

const size = Math.min(amount, 10);
const baseRate = 850;
const modDenominator = 15;

const dropRate = (baseRate / 2) * (1 + size / modDenominator);
let groupRate = Math.ceil(dropRate / size);
groupRate = Math.ceil(groupRate);

if (users.some(u => u.gear.melee.hasEquipped('Ring of luck'))) {
if (hasROL) {
groupRate = Math.floor(reduceNumByPercent(groupRate, 15));
}
return groupRate;
Expand Down Expand Up @@ -506,7 +506,7 @@ export class BossInstance {
if (this.users.length !== bossUsers.length) {
console.error('wtfffffffff');
}
const dwwhChance = calcDwwhChance(bossUsers.map(i => i.user));
const dwwhChance = calcDwwhChance(bossUsers.length, false);
results.push([
bossUsers.length,
bossUsers[0].userPercentChange.toFixed(1),
Expand Down
25 changes: 13 additions & 12 deletions src/lib/workers/kill.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ export default async ({
limit,
lootTableTertiaryChanges
}: KillWorkerArgs): KillWorkerReturn => {
const osjsMonster = Monsters.find(mon => mon.aliases.some(alias => stringMatches(alias, bossName)));
const simulatedKillable = simulatedKillables.find(i => stringMatches(i.name, bossName));
if (simulatedKillable) {
if (quantity > limit) {
return {
error: `The quantity you gave exceeds your limit of ${limit.toLocaleString()}! *You can increase your limit by up to 1 million by becoming a patron at <https://www.patreon.com/oldschoolbot>`
};
}
return {
content: simulatedKillable.message,
bank: simulatedKillable.loot(quantity).toJSON()
};
}

const osjsMonster = Monsters.find(mon => mon.aliases.some(alias => stringMatches(alias, bossName)));
if (osjsMonster) {
if (osjsMonster.id === YETI_ID && production) {
return { error: 'The bot is too scared to simulate fighting the yeti.' };
Expand Down Expand Up @@ -51,16 +63,5 @@ export default async ({
return { bank: result.bank.toJSON() };
}

const simulatedKillable = simulatedKillables.find(i => stringMatches(i.name, bossName));
if (simulatedKillable) {
if (quantity > limit) {
return {
error: `The quantity you gave exceeds your limit of ${limit.toLocaleString()}! *You can increase your limit by up to 1 million by becoming a patron at <https://www.patreon.com/oldschoolbot>`
};
}

return { bank: simulatedKillable.loot(quantity).toJSON() };
}

return { error: "I don't have that monster!" };
};
6 changes: 4 additions & 2 deletions src/mahoji/commands/kill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ export const killCommand: OSBMahojiCommand = {
required: true,
autocomplete: async (value: string) => {
return [
...Monsters.map(i => ({ name: i.name, aliases: i.aliases })),
...simulatedKillables.map(i => ({ name: i.name, aliases: [i.name] }))
...Array.from(Monsters.values()).map(i => ({ name: i.name, aliases: i.aliases })),
...simulatedKillables
.filter(i => !Array.from(Monsters.values()).some(monster => monster.name === i.name))
.map(i => ({ name: i.name, aliases: [i.name] }))
]
.filter(i =>
!value ? true : i.aliases.some(alias => alias.toLowerCase().includes(value.toLowerCase()))
Expand Down
5 changes: 4 additions & 1 deletion src/tasks/minions/bso/kingGoldemarActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export const kingGoldemarTask: MinionTask = {

await Promise.all(users.map(u => u.incrementKC(KingGoldemar.id, 1)));

const dwwhChance = calcDwwhChance(users);
const dwwhChance = calcDwwhChance(
users.length,
users.some(u => u.gear.melee.hasEquipped('Ring of luck'))
);

const gotDWWH = roll(dwwhChance);
const dwwhRecipient = gotDWWH ? randArrItem(dwwhTable) : null;
Expand Down