Skip to content

Commit

Permalink
Add quantity to Wintertodt
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TastyPumPum committed Jul 3, 2024
1 parent db87f7c commit 846a30a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/lib/util/minionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
5 changes: 3 additions & 2 deletions src/lib/util/repeatStoredTrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]: {
Expand Down
2 changes: 1 addition & 1 deletion src/mahoji/lib/abstracted_commands/minionKill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 14 additions & 4 deletions src/mahoji/lib/abstracted_commands/wintertodtCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -98,8 +110,6 @@ export async function wintertodtCommand(user: MUser, channelID: string) {
break;
}

const duration = durationPerTodt * quantity;

await addSubTaskToActivityTask<MinigameActivityTaskOptionsWithNoChanges>({
minigameID: 'wintertodt',
userID: user.id,
Expand Down
1 change: 1 addition & 0 deletions src/tasks/minions/minigames/wintertodtActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 846a30a

Please sign in to comment.