From 846a30a897021b7acff894619c1dad3aca9f2214 Mon Sep 17 00:00:00 2001 From: TastyPumPum <79149170+TastyPumPum@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:00:18 +0100 Subject: [PATCH] Add quantity to Wintertodt Allows users to specify the quantity of Wintertodt. If no quantity is provided do a max trip as always. Also adds "Loot from x Wintertodt" into the loot image. --- src/lib/util/minionStatus.ts | 3 ++- src/lib/util/repeatStoredTrip.ts | 5 +++-- .../lib/abstracted_commands/minionKill.ts | 2 +- .../abstracted_commands/wintertodtCommand.ts | 18 ++++++++++++++---- .../minions/minigames/wintertodtActivity.ts | 1 + 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/lib/util/minionStatus.ts b/src/lib/util/minionStatus.ts index 431f6e8c1a..12fc1ca867 100644 --- a/src/lib/util/minionStatus.ts +++ b/src/lib/util/minionStatus.ts @@ -322,7 +322,8 @@ export function minionStatus(user: MUser) { }. ${formattedDuration} Your ${Emoji.Cooking} Cooking level is ${user.skillLevel(SkillsEnum.Cooking)}`; } case 'Wintertodt': { - return `${name} is currently fighting the Wintertodt. ${formattedDuration}`; + const data = currentTask as ActivityTaskOptionsWithQuantity; + return `${name} is currently fighting Wintertodt ${data.quantity}x times. ${formattedDuration}`; } case 'Tempoross': { return `${name} is currently fighting Tempoross. ${formattedDuration}`; diff --git a/src/lib/util/repeatStoredTrip.ts b/src/lib/util/repeatStoredTrip.ts index 15bd678cb5..a4c2966fe0 100644 --- a/src/lib/util/repeatStoredTrip.ts +++ b/src/lib/util/repeatStoredTrip.ts @@ -436,8 +436,9 @@ export const tripHandlers = { }, [activity_type_enum.Wintertodt]: { commandName: 'k', - args: () => ({ - name: 'wintertodt' + args: (data: ActivityTaskOptionsWithQuantity) => ({ + name: 'wintertodt', + quantity: data.quantity }) }, [activity_type_enum.Nightmare]: { diff --git a/src/mahoji/lib/abstracted_commands/minionKill.ts b/src/mahoji/lib/abstracted_commands/minionKill.ts index 984e7d0852..e95634c71e 100644 --- a/src/mahoji/lib/abstracted_commands/minionKill.ts +++ b/src/mahoji/lib/abstracted_commands/minionKill.ts @@ -160,7 +160,7 @@ export async function minionKillCommand( if (stringMatches(name, 'zalcano')) return zalcanoCommand(user, channelID); if (stringMatches(name, 'tempoross')) return temporossCommand(user, channelID, quantity); if (name.toLowerCase().includes('nightmare')) return nightmareCommand(user, channelID, name, quantity); - if (name.toLowerCase().includes('wintertodt')) return wintertodtCommand(user, channelID); + if (name.toLowerCase().includes('wintertodt')) return wintertodtCommand(user, channelID, quantity); let monster = findMonster(name); let revenants = false; diff --git a/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts b/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts index 523ed0c86d..ff74a6fa07 100644 --- a/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts +++ b/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts @@ -2,6 +2,7 @@ import { Time, calcWhatPercent, reduceNumByPercent } from 'e'; import { Bank } from 'oldschooljs'; import { SkillsEnum } from 'oldschooljs/dist/constants'; +import { floor } from 'lodash'; import { Eatables } from '../../../lib/data/eatables'; import { warmGear } from '../../../lib/data/filterables'; import { trackLoot } from '../../../lib/lootTrack'; @@ -11,7 +12,7 @@ import addSubTaskToActivityTask from '../../../lib/util/addSubTaskToActivityTask import { calcMaxTripLength } from '../../../lib/util/calcMaxTripLength'; import { updateBankSetting } from '../../../lib/util/updateBankSetting'; -export async function wintertodtCommand(user: MUser, channelID: string) { +export async function wintertodtCommand(user: MUser, channelID: string, quantity?: number) { const fmLevel = user.skillLevel(SkillsEnum.Firemaking); const wcLevel = user.skillLevel(SkillsEnum.Woodcutting); if (fmLevel < 50) { @@ -45,7 +46,18 @@ export async function wintertodtCommand(user: MUser, channelID: string) { healAmountNeeded -= warmGearAmount * 15; durationPerTodt = reduceNumByPercent(durationPerTodt, 5 * warmGearAmount); - const quantity = Math.floor(calcMaxTripLength(user, 'Wintertodt') / durationPerTodt); + const maxTripLength = calcMaxTripLength(user, 'Wintertodt'); + if (!quantity) quantity = floor(maxTripLength / durationPerTodt); + quantity = Math.max(1, quantity); + const duration = durationPerTodt * quantity; + + if (quantity > 1 && duration > maxTripLength) { + return `${user.minionName} can't go on PvM trips longer than ${formatDuration( + maxTripLength + )}, try a lower quantity. The highest amount you can do for Wintertodt is ${floor( + maxTripLength / durationPerTodt + )}.`; + } for (const food of Eatables) { const healAmount = typeof food.healAmount === 'number' ? food.healAmount : food.healAmount(user); @@ -98,8 +110,6 @@ export async function wintertodtCommand(user: MUser, channelID: string) { break; } - const duration = durationPerTodt * quantity; - await addSubTaskToActivityTask({ minigameID: 'wintertodt', userID: user.id, diff --git a/src/tasks/minions/minigames/wintertodtActivity.ts b/src/tasks/minions/minigames/wintertodtActivity.ts index fd2b757961..000cf5bf74 100644 --- a/src/tasks/minions/minigames/wintertodtActivity.ts +++ b/src/tasks/minions/minigames/wintertodtActivity.ts @@ -113,6 +113,7 @@ export const wintertodtTask: MinionTask = { incrementMinigameScore(user.id, 'wintertodt', quantity); const image = await makeBankImage({ + title: `Loot From ${quantity}x Wintertodt`, bank: itemsAdded, user, previousCL