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

Tertiary roll boosts don't apply for sub loot tables #6297

Open
DayV-git opened this issue Jan 23, 2025 · 0 comments
Open

Tertiary roll boosts don't apply for sub loot tables #6297

DayV-git opened this issue Jan 23, 2025 · 0 comments

Comments

@DayV-git
Copy link
Contributor

🐛 Bug Report

In loot table roll function

public roll(quantity = 1, options: LootTableRollOptions = {}): Bank | null {
const loot = options.targetBank ?? new Bank();
const effectiveTertiaryItems = options.tertiaryItemPercentageChanges
? this.tertiaryItems.map(i => {
if (typeof i.item !== 'number') return i;
if (i.options?.freeze === true) return i;
const change = options.tertiaryItemPercentageChanges?.get(Items.get(i.item)!.name);
if (!change) return i;
return {
...i,
chance: Math.ceil(reduceNumByPercent(i.chance, change))
};
})
: this.tertiaryItems;
const limit = this.limit || this.totalWeight;
if (this.table.every(i => Number.isInteger(i.weight)) && this.cachedOptimizedTable === null) {
this.cachedOptimizedTable = [];
for (const item of this.table) {
for (let j = 0; j < item.weight!; j++) {
this.cachedOptimizedTable.push(this.table.indexOf(item));
}
}
while (this.cachedOptimizedTable.length < limit) {
this.cachedOptimizedTable.push(-1);
}
}
outerLoop: for (let i = 0; i < quantity; i++) {
for (let j = 0; j < this.everyItems.length; j++) {
this.addResultToLoot(this.everyItems[j], loot);
}
for (let j = 0; j < effectiveTertiaryItems.length; j++) {
if (roll(effectiveTertiaryItems[j].chance)) {
this.addResultToLoot(effectiveTertiaryItems[j], loot);
}
}
for (let j = 0; j < this.oneInItems.length; j++) {
if (roll(this.oneInItems[j].chance)) {
this.addResultToLoot(this.oneInItems[j], loot);
continue outerLoop;
}
}
if (this.cachedOptimizedTable) {
this.addResultToLoot(this.table[randArrItem(this.cachedOptimizedTable)], loot);
} else {
const randomWeight = randFloat(0, limit);
let weight = 0;
for (let i = 0; i < this.table.length; i++) {
weight += this.table[i].weight!;
if (randomWeight <= weight) {
this.addResultToLoot(this.table[i], loot);
break;
}
}
}
}
if (!options.targetBank) {
return loot;
}
return null;
}
private addResultToLoot(result: LootTableItem, loot: Bank): void {
if (typeof result?.item === 'number') {
loot.addItem(result.item, this.determineQuantity(result.quantity));
return;
}
if (result?.item instanceof LootTable) {
const qty = this.determineQuantity(result.quantity);
if (result.options?.multiply) loot.add(result.item.roll(1).multiply(qty));
else result.item.roll(qty, { targetBank: loot });
return;
}
}
LootTableRollOptions is used for updated teritiary items (clues with CAs, row etc) which is passed into LootTable.roll but it isn't passed into the roll functions for any subtables in LootTable.addResultToLoot, so they aren't boosted. Examples are no boosted clue rates from any wildy bosses with ring of wealth (i).

@DayV-git DayV-git changed the title Add tertiary roll changes for sub loot tables Tertiary roll boosts don't apply for sub loot tables Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant