Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nwjgit committed Mar 20, 2024
1 parent 4fe9683 commit 74cf5d9
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 31 deletions.
3 changes: 3 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ export type NMZStrategy = (typeof NMZ_STRATEGY)[number];
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
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 @@ export const tripHandlers = {
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
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 @@ -106,6 +106,19 @@ export const chopCommand: OSBMahojiCommand = {
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 @@ export const chopCommand: OSBMahojiCommand = {
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 @@ export const chopCommand: OSBMahojiCommand = {

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 @@ export const chopCommand: OSBMahojiCommand = {
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 @@ export const chopCommand: OSBMahojiCommand = {

// 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 @@ export const chopCommand: OSBMahojiCommand = {
});
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 @@ export const chopCommand: OSBMahojiCommand = {
}
}

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 @@ export const chopCommand: OSBMahojiCommand = {
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 @@ -39,6 +39,7 @@ import { makeBankImage } from '../../../lib/util/makeBankImage';
import resolveItems from '../../../lib/util/resolveItems';
import { Cooldowns } from '../Cooldowns';
import { collectables } from './collectCommand';
import { ForestryEvents } from '../../../tasks/minions/woodcuttingActivity';

interface DataPiece {
name: string;
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

0 comments on commit 74cf5d9

Please sign in to comment.