Skip to content

Commit

Permalink
add arraxor
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Sep 25, 2024
1 parent 2375c00 commit 7fb784d
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 12 deletions.
12 changes: 1 addition & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts"
},
"./dist/*": {
"require": "./dist/cjs/*.js",
"import": "./dist/esm/*.js",
"types": "./dist/types/*.d.ts"
},
"./dist/util/": {
"require": "./dist/cjs/*.js",
"import": "./dist/esm/*.js",
"types": "./dist/types/util/util.d.ts"
}
},
"license": "MIT",
Expand All @@ -28,7 +18,7 @@
"url": "git+https://github.com/oldschoolgg/oldschooljs.git"
},
"scripts": {
"test": "tsc --noEmit -p src && concurrently \"yarn test:lint\" \"yarn test:unit\" \"tsc --noEmit -p test\"",
"test": "yarn build && concurrently \"yarn test:lint\" \"yarn test:unit\" \"tsc --noEmit -p test\"",
"test:unit": "vitest run --coverage",
"build": "tsc -p src && node esbuild.js",
"prepare": "tsx scripts/prepare",
Expand Down
2 changes: 2 additions & 0 deletions src/EMonster.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum EMonster {
ARAXXOR = 13668,
CORPOREAL_BEAST = 319,
DAGANNOTH_PRIME = 2266,
DAGANNOTH_REX = 2267,
Expand Down Expand Up @@ -309,6 +310,7 @@ export enum EMonster {
ZOMBIE_PIRATE = 13489,
TORMENTED_DEMON = 13600,
ARMOURED_ZOMBIE = 12720,
CRAB = 4819,
BARROWS = 1673,
TZTOKJAD = 3127,
HESPORI = 8583,
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const CLUES = ["all", "beginner", "easy", "medium", "hard", "elite", "mas
export const mappedBossNames = [
["abyssalSire", "Abyssal Sire"],
["alchemicalHydra", "Alchemical Hydra"],
["amoxliatl", "Amoxliatl"],
["araxxor", "Araxxor"],
["artio", "Artio"],
["barrowsChests", "Barrows Chests"],
Expand Down Expand Up @@ -90,6 +91,7 @@ export const mappedBossNames = [
["tempoross", "Tempoross"],
["theGauntlet", "The Gauntlet"],
["theCorruptedGauntlet", "The Corrupted Gauntlet"],
["theHueycoatl", "The Hueycoatl"],
["theLeviathan", "The Leviathan"],
["theWhisperer", "The Whisperer"],
["theatreofBlood", "Theatre of Blood"],
Expand Down
40 changes: 40 additions & 0 deletions src/data/monsters_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -14758,5 +14758,45 @@
"slayerLevelRequired": 0,
"slayerXP": 0,
"assignableSlayerMasters": []
},
"13668": {
"members": true,
"combatLevel": 890,
"hitpoints": 1020,
"maxHit": 38,
"attackType": ["melee", "magic"],
"attackSpeed": 6,
"aggressive": true,
"poisonous": true,
"immuneToPoison": true,
"immuneToVenom": true,
"attributes": [],
"category": ["araxytes", "bosses", "spiders"],
"examineText": "A seriously scary spider.",
"wikiName": "Araxxor",
"wikiURL": "https://oldschool.runescape.wiki/w/Araxxor",
"attackLevel": 320,
"strengthLevel": 320,
"defenceLevel": 135,
"magicLevel": 190,
"rangedLevel": 210,
"attackStab": 0,
"attackSlash": 0,
"attackCrush": 0,
"attackMagic": 260,
"attackRanged": 283,
"defenceStab": 160,
"defenceSlash": 75,
"defenceCrush": 15,
"defenceMagic": 237,
"defenceRanged": 0,
"attackAccuracy": 0,
"meleeStrength": 0,
"rangedStrength": 0,
"magicDamage": 0,
"isSlayerMonster": true,
"slayerLevelRequired": 92,
"slayerXP": 1708,
"assignableSlayerMasters": ["nieve", "duradel", "turael", "spria", "konar"]
}
}
68 changes: 68 additions & 0 deletions src/simulation/monsters/bosses/Araxxor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import LootTable from "../../../structures/LootTable";
import SimpleMonster from "../../../structures/SimpleMonster";
import RareDropTable from "../../subtables/RareDropTable";
import TreeHerbSeedTable from "../../subtables/TreeHerbSeedTable";

const AraxxorUniqueTable = new LootTable()
.add("Araxyte fang")
.add("Noxious blade")
.add("Noxious point")
.add("Noxious pommel");

const SupplyDrop = new LootTable()
.add(new LootTable().add("Araxyte venom sack").add("Super combat potion(1)"))
.add(new LootTable().add("Prayer potion(3)", [1, 2]).add("Prayer potion(4)"))
.add(new LootTable().add("Wild pie", [2, 3]).add("Shark", [2, 3]));

const AraxxorTable = new LootTable()
.tertiary(200, "Coagulated venom")
.tertiary(150, AraxxorUniqueTable)
.tertiary(250, "Araxyte head")
.tertiary(1500, "Jar of venom")
.tertiary(3000, "Nid")
.oneIn(8, SupplyDrop)

.add("Rune kiteshield", 2, 8)
.add("Rune platelegs", 2, 8)
.add("Dragon mace", 2, 6)
.add("Rune 2h sword", 5, 1)
.add("Dragon platelegs", 2, 1)

.add("Death rune", 250, 5)
.add("Nature rune", 80, 2)
.add("Mud rune", 100, 1)
.add("Blood rune", 180, 1)

.add("Yew seed", 1, 4)
.add("Toadflax seed", 4, 3)
.add("Ranarr seed", 3, 1)
.add("Snapdragon seed", 3, 1)
.add("Magic seed", 2, 1)
.add(TreeHerbSeedTable, 1, 1)

.add("Coal", 120, 4)
.add("Adamantite ore", 85, 4)
.add("Raw shark", 21, 4)
.add("Yew logs", 70, 3)
.add("Runite ore", 12, 2)
.add("Raw shark", 100, 1)
.add("Raw monkfish", 120, 1)
.add("Pure essence", 1200, 1)

.add("Spider cave teleport", 3, 8)
.add("Earth orb", 45, 6)
.add("Araxyte venom sack", 6, 5)
.add("Mort myre fungus", 24, 4)
.add("Antidote++(3)", 6, 4)
.add("Wine of zamorak", 8, 3)
.add("Red spiders' eggs", 40, 2)
.add("Araxyte venom sack", 12, 2)
.add("Bark", 15, 1)
.add(RareDropTable);

export const Araxxor = new SimpleMonster({
id: 13668,
name: "Araxxor",
table: AraxxorTable,
aliases: ["araxxor"],
});
2 changes: 2 additions & 0 deletions src/simulation/monsters/bosses/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Araxxor } from "./Araxxor";
import { AwakenedDukeSucellus } from "./AwakenedDukeSucellus";
import { AwakenedTheLeviathan } from "./AwakenedTheLeviathan";
import { AwakenedTheWhisperer } from "./AwakenedTheWhisperer";
Expand Down Expand Up @@ -29,6 +30,7 @@ import { allWildyBosses } from "./wildy";
import CorporealBeast from "./wildy/CorporealBeast";

export const allBosses = {
Araxxor,
CorporealBeast,
DagannothPrime,
DagannothRex,
Expand Down
10 changes: 10 additions & 0 deletions src/structures/Items.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import deepMerge from "deepmerge";

import _items from "../data/items/item_data.json";
import type { Item, ItemID } from "../meta/types";
import { cleanString } from "../util/cleanString";
Expand Down Expand Up @@ -55,6 +57,14 @@ class Items extends Collection<number, Item> {
return super.get(id);
}

modifyItem(itemName: ItemResolvable, data: Partial<Item>) {
if (data.id) throw new Error("Cannot change item ID");
const id = this.resolveID(itemName)!;
const item = this.get(id);
if (!id || !item) throw new Error(`Item ${itemName} does not exist`);
this.set(item.id, deepMerge(item, data));
}

private resolveID(input: ItemResolvable): ItemID | undefined {
if (typeof input === "number") {
return input;
Expand Down
75 changes: 75 additions & 0 deletions src/util/bank.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { Time, calcWhatPercent, increaseNumByPercent } from "e";
import type { ItemBank } from "../meta/types";
import Bank from "../structures/Bank";
import Items from "../structures/Items";
import itemID from "./itemID";

/**
Expand Down Expand Up @@ -54,3 +57,75 @@ export function fasterResolveBank(bank: ItemBank) {

return resolveBank(bank);
}

export function increaseBankQuantitesByPercent(bank: Bank, percent: number, whitelist: number[] | null = null) {
for (const [item, qty] of bank.items()) {
if (whitelist !== null && !whitelist.includes(item.id)) continue;
const increased = Math.floor(increaseNumByPercent(qty, percent));
bank.set(item.id, increased);
}
}

export function convertBankToPerHourStats(bank: Bank, time: number) {
const result = [];
for (const [item, qty] of bank.items()) {
result.push(`${(qty / (time / Time.Hour)).toFixed(1)}/hr ${item.name}`);
}
return result;
}

export function calcDropRatesFromBank(bank: Bank, iterations: number, uniques: number[]) {
const result = [];
let uniquesReceived = 0;
for (const [item, qty] of bank.items().sort((a, b) => a[1] - b[1])) {
if (uniques.includes(item.id)) {
uniquesReceived += qty;
}
const rate = Math.round(iterations / qty);
if (rate < 2) continue;
let { name } = item;
if (uniques.includes(item.id)) name = `**${name}**`;
result.push(`${qty}x ${name} (1 in ${rate})`);
}
result.push(
`\n**${uniquesReceived}x Uniques (1 in ${Math.round(iterations / uniquesReceived)} which is ${calcWhatPercent(
uniquesReceived,
iterations,
)}%)**`,
);
return result.join(", ");
}

export function calcDropRatesFromBankWithoutUniques(bank: Bank, iterations: number) {
const results = [];
for (const [item, qty] of bank.items().sort((a, b) => a[1] - b[1])) {
const rate = Math.round(iterations / qty);
if (rate < 2) continue;
results.push(`${qty}x ${item.name} (1 in ${rate})`);
}
return results;
}

export function addBanks(banks: ItemBank[]): Bank {
const bank = new Bank();
for (const _bank of banks) {
bank.add(_bank);
}
return bank;
}

export function averageBank(bank: Bank, kc: number) {
const newBank = new Bank();
for (const [item, qty] of bank.items()) {
newBank.add(item.id, Math.floor(qty / kc));
}
return newBank;
}

export function generateRandomBank(size = 100, amountPerItem = 10000) {
const bank = new Bank();
for (let i = 0; i < size; i++) {
bank.add(Items.random().id, amountPerItem);
}
return bank;
}
16 changes: 15 additions & 1 deletion test/Items.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeAll, describe, expect, test } from "vitest";

import { Items, Openables } from "../src";
import { Items, Openables, getItem } from "../src";
import { EquipmentSlot, type Item } from "../src/meta/types";

const expectedIDTuple = [
Expand Down Expand Up @@ -158,3 +158,17 @@ describe("Items", () => {
60_000,
);
});

test("modifyItem", () => {
const item = getItem("Coal");
if (!item) {
throw new Error("Item not found");
}
Items.modifyItem(item.id, {
price: 100,
});

for (const it of [getItem("Coal")!, Items.get("Coal")!]) {
expect(it.price).toEqual(100);
}
});

0 comments on commit 7fb784d

Please sign in to comment.