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 loot table options (for Araxxor) #407

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion src/simulation/monsters/bosses/Araxxor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ const AraxxorTable = new LootTable()
.add("Bark", 15, 1)
.add(RareDropTable);

const DestroyedTable = new LootTable().tertiary(50, "Clue scroll (elite)").tertiary(1500, "Nid");

export const Araxxor = new SimpleMonster({
id: 13668,
name: "Araxxor",
table: AraxxorTable,
table: [AraxxorTable, DestroyedTable],
aliases: ["araxxor"],
});
1 change: 1 addition & 0 deletions src/structures/LootTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface LootTableRollOptions {
*/
tertiaryItemPercentageChanges?: Map<string, number>;
targetBank?: Bank;
table?: number;
}

export default class LootTable {
Expand Down
21 changes: 14 additions & 7 deletions src/structures/SimpleMonster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import {
getTotemChanceFromHP,
} from "../util/util";
import Bank from "./Bank";
import type LootTable from "./LootTable";
import LootTable from "./LootTable";
import Monster from "./Monster";

interface SimpleMonsterOptions extends MonsterOptions {
table?: LootTable;
table?: LootTable | LootTable[];
onTaskTable?: LootTable;
wildyCaveTable?: LootTable;
pickpocketTable?: LootTable;
customKillLogic?: CustomKillLogic;
}

export default class SimpleMonster extends Monster {
public table?: LootTable;
public table?: LootTable | LootTable[];
public onTaskTable?: LootTable;
public wildyCaveTable?: LootTable;
public pickpocketTable?: LootTable;
Expand All @@ -31,7 +31,9 @@ export default class SimpleMonster extends Monster {
constructor(options: SimpleMonsterOptions) {
let allItems: number[] = [];
if (options.table) {
allItems = allItems.concat(options.table.allItems);
for (const table of options.table instanceof LootTable ? [options.table] : options.table) {
allItems = allItems.concat(table.allItems);
}
}
if (options.pickpocketTable) {
allItems = allItems.concat(options.pickpocketTable.allItems);
Expand All @@ -53,9 +55,14 @@ export default class SimpleMonster extends Monster {
...options.lootTableOptions,
targetBank: loot,
};
const rollTable = this.table
? this.table instanceof LootTable
? this.table
: this.table[lootTableOptions.table ? lootTableOptions.table : 0]
: undefined;

if (!canGetBrimKey && !wildySlayer && !options.inCatacombs && !options.onSlayerTask) {
this.table?.roll(quantity, lootTableOptions);
rollTable?.roll(quantity, lootTableOptions);
if (this.customKillLogic) {
for (let i = 0; i < quantity; i++) {
this.customKillLogic(options, loot);
Expand Down Expand Up @@ -96,11 +103,11 @@ export default class SimpleMonster extends Monster {
this.onTaskTable.roll(1, lootTableOptions);
} else {
// Monster doesn't have a unique on-slayer table
this.table?.roll(1, lootTableOptions);
rollTable?.roll(1, lootTableOptions);
}
} else {
// Not on slayer task
this.table?.roll(1, lootTableOptions);
rollTable?.roll(1, lootTableOptions);
}
if (this.customKillLogic) {
this.customKillLogic(options, loot);
Expand Down