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

Fix dt items for tames #5684

Open
wants to merge 1 commit into
base: bso
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: 2 additions & 2 deletions src/lib/data/Collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
]
},
'The Leviathan': {
alias: ['the leviathan'],
alias: ['the leviathan', 'leviathan'],
kcActivity: {
Default: [Monsters.TheLeviathan.name, Monsters.AwakenedTheLeviathan.name],
Awakened: Monsters.AwakenedTheLeviathan.name
Expand Down Expand Up @@ -406,7 +406,7 @@
fmtProg: kcProg(BSOMonsters.VladimirDrakan.id)
},
'The Whisperer': {
alias: ['the whisperer'],
alias: ['the whisperer', 'whisperer'],
kcActivity: {
Default: [Monsters.TheWhisperer.name, Monsters.AwakenedTheWhisperer.name],
Awakened: Monsters.AwakenedTheWhisperer.name
Expand Down Expand Up @@ -1247,7 +1247,7 @@
'Monkey Backpacks': {
alias: ['monkey', 'monkey bps', 'backpacks'],
kcActivity: {
Default: async (_, __, u) => u.lapsScores[6] || 0

Check warning on line 1250 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
},
items: monkeyBackpacksCL,
isActivity: true
Expand Down Expand Up @@ -1405,7 +1405,7 @@
'Dyed Items': {
counts: false,
items: dyedItems
.map(i => i.dyedVersions.filter(i => i.dye.id !== itemID('Christmas dye')).map(i => i.item.id))

Check warning on line 1408 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

'i' is already declared in the upper scope on line 1408 column 11

Check warning on line 1408 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

'i' is already declared in the upper scope on line 1408 column 11
.flat(2)
},
'Clothing Mystery Box': {
Expand Down Expand Up @@ -1774,7 +1774,7 @@
)
.flat(100),
...Object.values(Monsters)
.map(m => (m && m.allItems ? m.allItems : []))

Check warning on line 1777 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected any value in conditional. An explicit comparison or type cast is required

Check warning on line 1777 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected any value in conditional. An explicit comparison or type cast is required
.flat(100)
]);

Expand Down Expand Up @@ -1915,7 +1915,7 @@

// get monsters
for (const monster of effectiveMonsters) {
categories.push(['Monsters', monster.name, monster.aliases ? monster.aliases.join(', ') : '']);

Check warning on line 1918 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected object value in conditional. The condition is always true
}
const normalTable = table([['Type', 'name: ', 'Alias'], ...[...categories, ...activities, ...roles]]);
return new AttachmentBuilder(Buffer.from(normalTable), { name: 'possible_logs.txt' });
Expand Down Expand Up @@ -1991,7 +1991,7 @@

const allItems = Boolean(flags.all);
if (logType === undefined) logType = 'collection';
if (flags.tame) {

Check warning on line 1994 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected value in conditional. A boolean expression is required
logType = 'tame';
}

Expand Down Expand Up @@ -2054,12 +2054,12 @@
let userKC: Record<string, number> | undefined = { Default: 0 };

// Defaults to the activity name
if (attributes.kcActivity) {

Check warning on line 2057 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected value in conditional. A boolean expression is required
if (typeof attributes.kcActivity === 'string') {
userKC.Default += (await user.getKCByName(attributes.kcActivity))[1];
} else {
for (const [type, value] of Object.entries(attributes.kcActivity)) {
if (!userKC[type]) userKC[type] = 0;

Check warning on line 2062 in src/lib/data/Collections.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
if (Array.isArray(value)) {
for (const name of value) {
userKC[type] += (await user.getKCByName(name))[1];
Expand Down
49 changes: 33 additions & 16 deletions src/lib/minions/data/killableMonsters/bosses/dt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { OSB_VIRTUS_IDS } from '../../../../constants';
import { dukeSucellusCL, theLeviathanCL, theWhispererCL, vardorvisCL } from '../../../../data/CollectionsExport';
import { GearStat } from '../../../../gear/types';
import { SkillsEnum } from '../../../../skilling/types';
import { ItemBank } from '../../../../types';
import { removeItemsFromLootTable } from '../../../../util';
import itemID from '../../../../util/itemID';
import resolveItems, { deepResolveItems } from '../../../../util/resolveItems';
Expand Down Expand Up @@ -77,8 +78,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 45 * 20,
attackStyleToUse: GearStat.AttackSlash,
attackStylesUsed: [GearStat.AttackSlash],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Frozen tablet') && user.cl.has('Frozen tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Frozen tablet')) return;
} else if (user.bank.has('Frozen tablet') && user.cl.has('Frozen tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down Expand Up @@ -161,8 +164,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 45 * 20 * 2.5,
attackStyleToUse: GearStat.AttackSlash,
attackStylesUsed: [GearStat.AttackSlash],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Frozen tablet') && user.cl.has('Frozen tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Frozen tablet')) return;
} else if (user.bank.has('Frozen tablet') && user.cl.has('Frozen tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down Expand Up @@ -263,8 +268,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 45 * 20 * 2.5,
attackStyleToUse: GearStat.AttackRanged,
attackStylesUsed: [GearStat.AttackRanged],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Scarred tablet') && user.cl.has('Scarred tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Scarred tablet')) return;
} else if (user.bank.has('Scarred tablet') && user.cl.has('Scarred tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down Expand Up @@ -352,8 +359,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 45 * 20,
attackStyleToUse: GearStat.AttackRanged,
attackStylesUsed: [GearStat.AttackRanged],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Scarred tablet') && user.cl.has('Scarred tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Scarred tablet')) return;
} else if (user.bank.has('Scarred tablet') && user.cl.has('Scarred tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down Expand Up @@ -442,8 +451,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 55 * 20,
attackStyleToUse: GearStat.AttackMagic,
attackStylesUsed: [GearStat.AttackMagic],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Sirenic tablet') && user.cl.has('Sirenic tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Sirenic tablet')) return;
} else if (user.bank.has('Sirenic tablet') && user.cl.has('Sirenic tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down Expand Up @@ -547,8 +558,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 45 * 20 * 2.5,
attackStyleToUse: GearStat.AttackMagic,
attackStylesUsed: [GearStat.AttackMagic],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Sirenic tablet') && user.cl.has('Sirenic tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Sirenic tablet')) return;
} else if (user.bank.has('Sirenic tablet') && user.cl.has('Sirenic tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down Expand Up @@ -640,8 +653,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 45 * 20,
attackStyleToUse: GearStat.AttackSlash,
attackStylesUsed: [GearStat.AttackSlash],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Strangled tablet') && user.cl.has('Strangled tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Strangled tablet')) return;
} else if (user.bank.has('Strangled tablet') && user.cl.has('Strangled tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down Expand Up @@ -724,8 +739,10 @@ export const desertTreasureKillableBosses: KillableMonster[] = [
healAmountNeeded: 45 * 20 * 2.5,
attackStyleToUse: GearStat.AttackSlash,
attackStylesUsed: [GearStat.AttackSlash],
effect: async ({ quantity, user, loot, messages }) => {
if (user.bank.has('Strangled tablet') && user.cl.has('Strangled tablet')) return;
effect: async ({ quantity, user, loot, messages, tame }) => {
if (tame) {
if (new Bank(tame.max_total_loot as ItemBank).has('Strangled tablet')) return;
} else if (user.bank.has('Strangled tablet') && user.cl.has('Strangled tablet')) return;
let gotTab = false;
for (let i = 0; i < quantity; i++) {
if (roll(25)) {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/minions/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Image } from '@napi-rs/canvas';
import { StoreBitfield } from '@oldschoolgg/toolkit';
import { XpGainSource } from '@prisma/client';
import { Tame, XpGainSource } from '@prisma/client';
import { Bank, MonsterKillOptions } from 'oldschooljs';
import SimpleMonster from 'oldschooljs/dist/structures/SimpleMonster';

Expand Down Expand Up @@ -113,8 +113,9 @@ export interface KillableMonster {
effect?: (opts: {
messages: string[];
user: MUser;
tame?: Tame;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change to use MTame, so you can do tame.totalLoot instead of new Bank(tame.max_total_loot as ItemBank). Merge at your discretion when its ready.

quantity: number;
monster: KillableMonster;
monster?: KillableMonster;
loot: Bank;
data: MonsterActivityTaskOptions;
}) => Promise<unknown>;
Expand Down
18 changes: 18 additions & 0 deletions src/lib/tames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import { getTemporossLoot } from './simulation/tempoross';
import { WintertodtCrate } from './simulation/wintertodt';
import Tanning from './skilling/skills/crafting/craftables/tanning';
import { MonsterActivityTaskOptions } from './types/minions';
import {
assert,
calcPerHour,
Expand All @@ -45,7 +46,7 @@
import { makeBankImage } from './util/makeBankImage';
import resolveItems from './util/resolveItems';

export enum TameSpeciesID {

Check warning on line 49 in src/lib/tames.ts

View workflow job for this annotation

GitHub Actions / ESLint

'TameSpeciesID' is already declared in the upper scope on line 49 column 13
Igne = 1,
Monkey = 2
}
Expand Down Expand Up @@ -738,6 +739,20 @@
}
}
const loot = mon.loot({ quantity: killQty, tame });
const messages: string[] = [];
const effectTaskData: MonsterActivityTaskOptions = {
type: 'MonsterKilling',
monsterID,
quantity,
duration: activity.duration,
userID: user.id,
finishDate: activity.finish_date.getTime(),
channelID: activity.channel_id,
id: 0 // Unused. Don't use tame activity ID unless the Type is changed to differentiate.
};
if (mon.effect) {
await mon.effect({ user, loot, messages, quantity: killQty, data: effectTaskData, tame });
}
let str = `${user}, ${tameName(tame)} finished killing ${quantity}x ${mon.name}.${
activity.deaths > 0 ? ` ${tameName(tame)} died ${activity.deaths}x times.` : ''
}`;
Expand All @@ -748,6 +763,9 @@
if (boosts.length > 0) {
str += `\n\n**Boosts:** ${boosts.join(', ')}.`;
}
if (messages.length > 0) {
str += `\n\n**Messages:** ${messages.join(' ')}`;
}
const { doubleLootMsg } = doubleLootCheck(tame, loot);
str += doubleLootMsg;
const { itemsAdded } = await user.addItemsToBank({ items: loot, collectionLog: false });
Expand Down
Loading