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

BSO Forestry #5792

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
EventOrganizer: '1149907536749801542'
};

export const enum DefaultPingableRoles {

Check warning on line 87 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'DefaultPingableRoles' is already declared in the upper scope on line 87 column 19
// Tester roles:
Tester = '682052620809928718',
BSOTester = '829368646182371419',
Expand All @@ -92,7 +92,7 @@
BSOMass = '759573020464906242'
}

export const enum Emoji {

Check warning on line 95 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'Emoji' is already declared in the upper scope on line 95 column 19
MoneyBag = '<:MoneyBag:493286312854683654>',
OSBot = '<:OSBot:601768469905801226>',
Joy = '😂',
Expand Down Expand Up @@ -205,14 +205,14 @@
BronzeTrophy = '<:BronzeTrophy:1152881057788592188>'
}

export enum ActivityGroup {

Check warning on line 208 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'ActivityGroup' is already declared in the upper scope on line 208 column 13
Skilling = 'Skilling',
Clue = 'Clue',
Monster = 'Monster',
Minigame = 'Minigame'
}

export const enum Events {

Check warning on line 215 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'Events' is already declared in the upper scope on line 215 column 19
Error = 'error',
Log = 'log',
Verbose = 'verbose',
Expand All @@ -225,7 +225,7 @@

export const COINS_ID = 995;

export const enum PerkTier {

Check warning on line 228 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'PerkTier' is already declared in the upper scope on line 228 column 19
/**
* Boosters
*/
Expand Down Expand Up @@ -256,7 +256,7 @@
Seven = 7
}

export enum BitField {

Check warning on line 259 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'BitField' is already declared in the upper scope on line 259 column 13
IsPatronTier1 = 2,
IsPatronTier2 = 3,
IsPatronTier3 = 4,
Expand Down Expand Up @@ -537,7 +537,7 @@
}
} as const;

export const enum PatronTierID {

Check warning on line 540 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'PatronTierID' is already declared in the upper scope on line 540 column 19
One = '4608201',
Two = '4608226',
Three = '4720356',
Expand Down Expand Up @@ -774,6 +774,9 @@
export const UNDERWATER_AGILITY_THIEVING_TRAINING_SKILL = ['agility', 'thieving', 'agility+thieving'] as const;
export type UnderwaterAgilityThievingTrainingSkill = (typeof UNDERWATER_AGILITY_THIEVING_TRAINING_SKILL)[number];

export const TWITCHERS_GLOVES = ['egg', 'ring', 'seed', 'clue'] as const;
export type TwitcherGloves = (typeof TWITCHERS_GLOVES)[number];

export const busyImmuneCommands = ['admin', 'rp'];
export const usernameCache = new Map<string, string>();
export const badgesCache = new Map<string, string>();
Expand Down Expand Up @@ -829,7 +832,7 @@
'Bluey'
]);

export enum PeakTier {

Check warning on line 835 in src/lib/constants.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'PeakTier' is already declared in the upper scope on line 835 column 13
High = 'high',
Medium = 'medium',
Low = 'low'
Expand Down
35 changes: 31 additions & 4 deletions src/lib/minions/functions/addSkillingClueToLoot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { sumArr } from 'e';
import { percentChance, sumArr } from 'e';
import { Bank } from 'oldschooljs';

import { birdsNestID, nestTable, strungRabbitFootNestTable } from '../../simulation/birdsNest';
import {
birdsNestID,
eggNest,
nestTable,
ringNests,
strungRabbitFootNestTable,
treeSeedsNest
} from '../../simulation/birdsNest';
import { SkillsEnum } from '../../skilling/types';
import { randFloat, roll } from '../../util';
import itemID from '../../util/itemID';
Expand All @@ -22,17 +29,37 @@ export default function addSkillingClueToLoot(
loot: Bank,
clueNestsOnly?: boolean,
strungRabbitFoot?: boolean,
twitcherSetting?: string,
wcCapeNestBoost?: boolean
) {
const userLevel = typeof userOrLevel === 'number' ? userOrLevel : userOrLevel.skillLevel(skill);
const chance = Math.floor(clueChance / (100 + userLevel));
const nestChance = wcCapeNestBoost ? Math.floor(256 * 0.9) : 256;
const cluesTotalWeight = sumArr(clues.map(c => c[1]));
let chance = Math.floor(clueChance / (100 + userLevel));
let nests = 0;

if (skill === SkillsEnum.Woodcutting && twitcherSetting === 'clue') {
chance = Math.floor((clueChance * 0.8) / (100 + userLevel));
}

for (let i = 0; i < quantity; i++) {
if (skill === SkillsEnum.Woodcutting && !clueNestsOnly && roll(nestChance)) {
if (strungRabbitFoot) {
if (twitcherSetting && percentChance(20)) {
switch (twitcherSetting) {
case 'egg':
loot.add(eggNest.roll());
nests++;
continue;
case 'seed':
loot.add(treeSeedsNest.roll());
nests++;
continue;
case 'ring':
loot.add(ringNests.roll());
nests++;
continue;
}
} else if (strungRabbitFoot) {
loot.add(strungRabbitFootNestTable.roll());
continue;
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/types/minions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CropUpgradeType } from '@prisma/client';

import { BathhouseTierName } from '../baxtorianBathhouses';
import { NMZStrategy, UnderwaterAgilityThievingTrainingSkill } from '../constants';
import { NMZStrategy, TwitcherGloves, UnderwaterAgilityThievingTrainingSkill } from '../constants';
import { Kibble } from '../data/kibble';
import { IMaterialBank, MaterialType } from '../invention';
import type { IPatchData } from '../minions/farming/types';
Expand Down Expand Up @@ -211,6 +211,8 @@ export interface WoodcuttingActivityTaskOptions extends ActivityTaskOptions {
fakeDurationMax: number;
fakeDurationMin: number;
powerchopping: boolean;
forestry?: boolean;
twitchers?: TwitcherGloves;
logID: number;
quantity: number;
iQty?: number;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/util/repeatStoredTrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@
args: (data: WoodcuttingActivityTaskOptions) => ({
name: itemNameFromID(data.logID),
quantity: data.iQty,
powerchop: data.powerchopping
powerchop: data.powerchopping,
forestry_events: data.forestry,
twitchers_gloves: data.twitchers
})
},
[activity_type_enum.VasaMagus]: {
Expand Down Expand Up @@ -810,7 +812,7 @@
} as const;

for (const type of Object.values(activity_type_enum)) {
if (!tripHandlers[type]) {

Check warning on line 815 in src/lib/util/repeatStoredTrip.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected object value in conditional. The condition is always true
throw new Error(`Missing trip handler for ${type}`);
}
}
Expand Down
37 changes: 33 additions & 4 deletions src/mahoji/commands/chop.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { increaseNumByPercent, reduceNumByPercent } from 'e';
import { ApplicationCommandOptionType, CommandRunOptions } from 'mahoji';

import { IVY_MAX_TRIP_LENGTH_BOOST } from '../../lib/constants';
import { IVY_MAX_TRIP_LENGTH_BOOST, TwitcherGloves, TWITCHERS_GLOVES } from '../../lib/constants';
import { InventionID, inventionItemBoost } from '../../lib/invention/inventions';
import { determineWoodcuttingTime } from '../../lib/skilling/functions/determineWoodcuttingTime';
import Woodcutting from '../../lib/skilling/skills/woodcutting';
Expand Down Expand Up @@ -87,7 +87,7 @@
required: true,
autocomplete: async (value: string) => {
return Woodcutting.Logs.filter(i =>
!value ? true : i.name.toLowerCase().includes(value.toLowerCase())

Check warning on line 90 in src/mahoji/commands/chop.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected string value in conditional. An explicit empty string check is required
).map(i => ({
name: i.name,
value: i.name
Expand All @@ -106,6 +106,19 @@
name: 'powerchop',
description: 'Set this to true to powerchop. Higher xp/hour, No loot (default false, optional).',
required: false
},
{
type: ApplicationCommandOptionType.Boolean,
name: 'forestry_events',
description: 'Set this to true to participate in forestry events. (default false, optional).',
required: false
},
{
type: ApplicationCommandOptionType.String,
name: 'twitchers_gloves',
description: "Change the settings of your Twitcher's gloves. (default egg, optional)",
required: false,
choices: TWITCHERS_GLOVES.map(i => ({ name: `${i} nest`, value: i }))
}
],
run: async ({
Expand All @@ -116,6 +129,8 @@
name: string;
quantity?: number;
powerchop?: boolean;
forestry_events?: boolean;
twitchers_gloves?: TwitcherGloves;
}>) => {
const user = await mUserFetch(userID);
const log = Woodcutting.Logs.find(
Expand All @@ -127,7 +142,7 @@

if (!log) return "That's not a valid log to chop.";

let { quantity, powerchop } = options;
let { quantity, powerchop, forestry_events, twitchers_gloves } = options;

const skills = user.skillsAsLevels;

Expand All @@ -150,11 +165,19 @@
let wcLvl = skills.woodcutting;

// Invisible wc boost for woodcutting guild, forestry events don't happen in woodcutting guild
if (resolveItems(['Redwood logs', 'Logs']).includes(log.id) || log.lootTable) {
if (
!forestry_events ||
resolveItems(['Redwood logs', 'Logs']).includes(log.id) ||
log.lootTable ||
log.name === 'Ivy'
) {
forestry_events = false;
if (skills.woodcutting >= 60 && log.wcGuild) {
boosts.push('+7 invisible WC lvls at the Woodcutting guild');
wcLvl += 7;
}
} else {
boosts.push('Participating in Forestry events');
}

// Enable 1.5 tick teaks half way to 99
Expand All @@ -164,6 +187,7 @@

// Default bronze axe, last in the array
let axeMultiplier = 1;
boosts.push(`**${axeMultiplier}x** success multiplier for Bronze axe`);

if (user.hasEquippedOrInBank(['Drygore axe'])) {
let [predeterminedTotalTime] = determineWoodcuttingTime({
Expand All @@ -181,9 +205,11 @@
});
if (boostRes.success) {
axeMultiplier = 10;
boosts.pop();
boosts.push(`**10x** success multiplier for Drygore axe (${boostRes.messages})`);
} else {
axeMultiplier = 8;
boosts.pop();
boosts.push('**8x** success multiplier for Dwarven greataxe');
}
} else {
Expand All @@ -196,7 +222,8 @@
}
}

if (log.name === 'Ivy') {
// Ivy choping
if (!forestry_events && log.name === 'Ivy') {
boosts.push(`+${formatDuration(IVY_MAX_TRIP_LENGTH_BOOST, true)} max trip length for Ivy`);
powerchop = false;
}
Expand Down Expand Up @@ -244,6 +271,8 @@
quantity: newQuantity,
iQty: options.quantity ? options.quantity : undefined,
powerchopping: powerchop,
forestry: forestry_events,
twitchers: twitchers_gloves,
duration,
fakeDurationMin,
fakeDurationMax,
Expand Down
38 changes: 38 additions & 0 deletions src/mahoji/lib/abstracted_commands/statCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { barChart, lineChart, pieChart } from '../../../lib/util/chart';
import { getItem } from '../../../lib/util/getOSItem';
import { makeBankImage } from '../../../lib/util/makeBankImage';
import resolveItems from '../../../lib/util/resolveItems';
import { ForestryEvents } from '../../../tasks/minions/woodcuttingActivity';
import { Cooldowns } from '../Cooldowns';
import { collectables } from './collectCommand';

Expand Down Expand Up @@ -1160,6 +1161,43 @@ GROUP BY "bankBackground";`);
.join('\n')}`;
}
},
{
name: 'Personal XP gained from Forestry events',
perkTierNeeded: PerkTier.Four,
run: async (user: MUser) => {
const result = await prisma.$queryRawUnsafe<any>(
`SELECT skill,
SUM(xp)::int AS total_xp
FROM xp_gains
WHERE source = 'ForestryEvents'
AND user_id = ${BigInt(user.id)}
GROUP BY skill
ORDER BY CASE
WHEN skill = 'woodcutting' THEN 0
ELSE 1
END`
);

return `**Personal XP gained from Forestry events**\n${result
.map(
(i: any) =>
`${skillEmoji[i.skill as keyof typeof skillEmoji] as keyof SkillsScore} ${toKMB(i.total_xp)}`
)
.join('\n')}`;
}
},
{
name: 'Forestry events completed',
perkTierNeeded: PerkTier.Four,
run: async (_, userStats) => {
let str = 'You have completed...\n\n';
for (const event of ForestryEvents) {
const qty = (userStats.forestry_event_completions_bank as ItemBank)[event.id] ?? 0;
str += `${event.name}: ${qty}\n`;
}
return str;
}
},
{
name: 'Bird Eggs Offered',
perkTierNeeded: null,
Expand Down
Loading
Loading