From 1cc856e76d6cc80f19530dfb00894390b75644c3 Mon Sep 17 00:00:00 2001 From: DayV <69717452+DayV-git@users.noreply.github.com> Date: Fri, 27 Dec 2024 04:12:35 +0000 Subject: [PATCH] Prevent repeating kill trips when slayer task is finished (#6213) --- src/lib/types/minions.ts | 1 + src/mahoji/commands/k.ts | 4 +++- .../lib/abstracted_commands/minionKill/minionKill.ts | 12 +++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/types/minions.ts b/src/lib/types/minions.ts index 555f0eb4b16..03c7937b753 100644 --- a/src/lib/types/minions.ts +++ b/src/lib/types/minions.ts @@ -147,6 +147,7 @@ export interface MonsterActivityTaskOptions extends ActivityTaskOptions { hasWildySupplies?: boolean; isInWilderness?: boolean; attackStyles?: AttackStyles[]; + onTask?: boolean; } export interface ClueActivityTaskOptions extends ActivityTaskOptions { diff --git a/src/mahoji/commands/k.ts b/src/mahoji/commands/k.ts index 7432ba58e60..9157d07aa69 100644 --- a/src/mahoji/commands/k.ts +++ b/src/mahoji/commands/k.ts @@ -148,6 +148,7 @@ export const minionKCommand: OSBMahojiCommand = { show_info?: boolean; wilderness?: boolean; solo?: boolean; + onTask?: boolean; }>) => { const user = await mUserFetch(userID); if (options.show_info) { @@ -161,7 +162,8 @@ export const minionKCommand: OSBMahojiCommand = { options.quantity, options.method, options.wilderness, - options.solo + options.solo, + options.onTask ); } }; diff --git a/src/mahoji/lib/abstracted_commands/minionKill/minionKill.ts b/src/mahoji/lib/abstracted_commands/minionKill/minionKill.ts index 630568ec611..c8dda9ea5a1 100644 --- a/src/mahoji/lib/abstracted_commands/minionKill/minionKill.ts +++ b/src/mahoji/lib/abstracted_commands/minionKill/minionKill.ts @@ -31,7 +31,8 @@ export async function minionKillCommand( inputQuantity: number | undefined, method: PvMMethod | undefined, wilderness: boolean | undefined, - solo: boolean | undefined + solo: boolean | undefined, + onTask: boolean | undefined ): Promise { if (user.minionIsBusy) { return 'Your minion is busy.'; @@ -63,12 +64,16 @@ export async function minionKillCommand( return typeof reason === 'string' ? reason : "You don't have the requirements to fight this monster"; } + const slayerInfo = await getUsersCurrentSlayerInfo(user.id); + + if (slayerInfo.assignedTask === null && onTask) return 'You are no longer on a slayer task for this monster!'; + const stats: { pk_evasion_exp: number } = await user.fetchStats({ pk_evasion_exp: true }); const result = newMinionKillCommand({ gearBank: user.gearBank, attackStyles: user.getAttackStyles(), - currentSlayerTask: await getUsersCurrentSlayerInfo(user.id), + currentSlayerTask: slayerInfo, monster, isTryingToUseWildy: wilderness ?? false, monsterKC: await user.getKC(monster.id), @@ -134,7 +139,8 @@ export async function minionKillCommand( bob: !bob ? undefined : bob, hasWildySupplies, isInWilderness: result.isInWilderness, - attackStyles: result.attackStyles + attackStyles: result.attackStyles, + onTask: slayerInfo.assignedTask !== null }); let response = `${minionName} is now killing ${result.quantity}x ${monster.name}, it'll take around ${formatDuration( result.duration