Skip to content

Commit

Permalink
Larran's & Brimstone chest fish (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwjgit authored Feb 21, 2024
1 parent 5de5720 commit 735db97
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 147 deletions.
228 changes: 118 additions & 110 deletions src/simulation/openables/BonusOpenables.ts
Original file line number Diff line number Diff line change
@@ -1,165 +1,173 @@
import { SkillsEnum } from './../../constants';

export interface BonusOpenables {
export interface FishDropTable {
item: string;
qty: number | [number, number];
weight: number;
skill: SkillsEnum;
req: number | [number, number];
qty: [number, number];
low: number;
high: number;
req: number;
}

// Uses the skilling success rate formula: https://oldschool.runescape.wiki/w/Skilling_success_rate
export function chanceOfFish(fishLvl: number, low: number, high: number) {
const num1: number = (low * (99 - fishLvl)) / 98;
const num2: number = (high * (fishLvl - 1)) / 98;

const chanceOfSuccess = (num1 + num2 + 1) / 256;

return chanceOfSuccess * 100;
}

export const BrimstoneChestBonus: BonusOpenables[] = [
export const BrimstoneChestFish: FishDropTable[] = [
{
item: 'Raw tuna',
qty: [100, 350],
weight: 3,
skill: SkillsEnum.Fishing,
req: [1, 39]
item: 'Raw manta ray',
qty: [80, 160],
low: -10,
high: 20,
req: 31
},
{
item: 'Raw lobster',
qty: [100, 350],
weight: 3,
skill: SkillsEnum.Fishing,
req: [40, 59]
item: 'Raw sea turtle',
qty: [80, 200],
low: -10,
high: 50,
req: 17
},
{
item: 'Raw swordfish',
qty: [100, 300],
weight: 3,
skill: SkillsEnum.Fishing,
req: [50, 61]
item: 'Raw shark',
qty: [100, 250],
low: -60,
high: 140,
req: 27
},
{
item: 'Raw monkfish',
qty: [100, 300],
weight: 3,
skill: SkillsEnum.Fishing,
req: [62, 75]
low: 0,
high: 170,
req: 1
},
{
item: 'Raw shark',
qty: [100, 250],
weight: 3,
skill: SkillsEnum.Fishing,
req: [76, 78]
item: 'Raw swordfish',
qty: [100, 300],
low: 30,
high: 200,
req: 1
},
{
item: 'Raw sea turtle',
qty: [80, 200],
weight: 3,
skill: SkillsEnum.Fishing,
req: [79, 80]
item: 'Raw lobster',
qty: [100, 350],
low: 70,
high: 270,
req: 1
},
{
item: 'Raw manta ray',
qty: [80, 160],
weight: 3,
skill: SkillsEnum.Fishing,
req: [81, 99]
item: 'Raw tuna',
qty: [100, 350],
low: 225,
high: 324,
req: 1
}
];

export const LarransSmallChestBonus: BonusOpenables[] = [
export const LarransSmallChestFish: FishDropTable[] = [
{
item: 'Raw tuna',
qty: 204,
weight: 3,
skill: SkillsEnum.Fishing,
req: [1, 39]
item: 'Raw manta ray',
qty: [81, 177],
low: -10,
high: 20,
req: 31
},
{
item: 'Raw lobster',
qty: 214,
weight: 3,
skill: SkillsEnum.Fishing,
req: [40, 49]
item: 'Raw sea turtle',
qty: [81, 177],
low: -10,
high: 50,
req: 17
},
{
item: 'Raw swordfish',
qty: 224,
weight: 3,
skill: SkillsEnum.Fishing,
req: [50, 61]
item: 'Raw shark',
qty: [126, 250],
low: -60,
high: 140,
req: 27
},
{
item: 'Raw monkfish',
qty: 234,
weight: 3,
skill: SkillsEnum.Fishing,
req: [62, 75]
qty: [162, 297],
low: 0,
high: 170,
req: 1
},
{
item: 'Raw shark',
qty: 126,
weight: 3,
skill: SkillsEnum.Fishing,
req: [76, 78]
item: 'Raw swordfish',
qty: [113, 264],
low: 30,
high: 200,
req: 1
},
{
item: 'Raw sea turtle',
qty: 136,
weight: 3,
skill: SkillsEnum.Fishing,
req: [79, 80]
item: 'Raw lobster',
qty: [163, 342],
low: 70,
high: 270,
req: 1
},
{
item: 'Raw manta ray',
qty: 116,
weight: 3,
skill: SkillsEnum.Fishing,
req: 81
item: 'Raw tuna',
qty: [112, 307],
low: 225,
high: 324,
req: 1
}
];

export const LarransBigChestBonus: BonusOpenables[] = [
export const LarransBigChestFish: FishDropTable[] = [
{
item: 'Raw tuna',
qty: [150, 520],
weight: 3,
skill: SkillsEnum.Fishing,
req: [1, 39]
item: 'Raw manta ray',
qty: [120, 240],
low: -10,
high: 20,
req: 31
},
{
item: 'Raw lobster',
qty: [150, 525],
weight: 3,
skill: SkillsEnum.Fishing,
req: [40, 49]
item: 'Raw sea turtle',
qty: [120, 300],
low: -10,
high: 50,
req: 17
},
{
item: 'Raw swordfish',
qty: [150, 450],
weight: 3,
skill: SkillsEnum.Fishing,
req: [50, 61]
item: 'Raw shark',
qty: [150, 375],
low: -60,
high: 140,
req: 27
},
{
item: 'Raw monkfish',
qty: [150, 450],
weight: 3,
skill: SkillsEnum.Fishing,
req: [62, 75]
low: 0,
high: 170,
req: 1
},
{
item: 'Raw shark',
qty: [150, 375],
weight: 3,
skill: SkillsEnum.Fishing,
req: [76, 78]
item: 'Raw swordfish',
qty: [150, 450],
low: 30,
high: 200,
req: 1
},
{
item: 'Raw sea turtle',
qty: [120, 300],
weight: 3,
skill: SkillsEnum.Fishing,
req: [79, 80]
item: 'Raw lobster',
qty: [150, 525],
low: 70,
high: 270,
req: 1
},
{
item: 'Raw manta ray',
qty: [125, 235],
weight: 3,
skill: SkillsEnum.Fishing,
req: 81
item: 'Raw tuna',
qty: [150, 525],
low: 225,
high: 324,
req: 1
}
];
34 changes: 20 additions & 14 deletions src/simulation/openables/BrimstoneChest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { percentChance, randInt, roll } from 'e';

import { OpenableOpenOptions } from '../../meta/types';
import Bank from '../../structures/Bank';
import LootTable from '../../structures/LootTable';
import SimpleOpenable from '../../structures/SimpleOpenable';
import { BrimstoneChestBonus } from './BonusOpenables';
import { BrimstoneChestFish, chanceOfFish } from './BonusOpenables';

const BrimstoneChestTable = new LootTable()
.add('Uncut diamond', [25, 35], 5)
Expand Down Expand Up @@ -37,25 +39,29 @@ const BrimstoneChestTable = new LootTable()

export class BrimstoneChestOpenable extends SimpleOpenable {
public open(quantity = 1, options: OpenableOpenOptions = { fishLvl: 99 }) {
const tempTable = BrimstoneChestTable.clone();
const loot = new Bank();

const fishLvl = options.fishLvl ?? 99;

for (const fish of BrimstoneChestBonus) {
if (typeof fish.req === 'number') {
if (fishLvl >= fish.req) {
tempTable.add(fish.item, fish.qty, fish.weight);
const lobster = BrimstoneChestFish.find(fish => fish.item === 'Raw lobster');
for (let i = 0; i < quantity; i++) {
if (roll(20)) {
let fishRolled = false;
for (const fish of BrimstoneChestFish) {
if (fishLvl >= fish.req) {
if (percentChance(chanceOfFish(fishLvl, fish.low, fish.high))) {
loot.add(fish.item, randInt(fish.qty[0], fish.qty[1]));
fishRolled = true;
break;
}
}
}
if (!fishRolled) {
loot.add(lobster!.item, randInt(lobster!.qty[0], lobster!.qty[1]));
}
} else if (fishLvl >= fish.req[0] && fishLvl <= fish.req[1]) {
tempTable.add(fish.item, fish.qty, fish.weight);
} else {
loot.add(BrimstoneChestTable.roll());
}
}

for (let i = 0; i < quantity; i++) {
loot.add(tempTable.roll());
}

return loot;
}
}
Expand Down
Loading

0 comments on commit 735db97

Please sign in to comment.