From bea16daee0633d968ae150f26b42885dee23ba95 Mon Sep 17 00:00:00 2001 From: DayV Date: Sun, 10 Nov 2024 15:20:42 +0000 Subject: [PATCH] Prevent repeat /k trip when task finished --- src/lib/types/minions.ts | 1 + src/lib/util/repeatStoredTrip.ts | 3 ++- src/mahoji/commands/k.ts | 4 +++- .../lib/abstracted_commands/minionKill/minionKill.ts | 12 +++++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/lib/types/minions.ts b/src/lib/types/minions.ts index 555f0eb4b1..03c7937b75 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/lib/util/repeatStoredTrip.ts b/src/lib/util/repeatStoredTrip.ts index afbbac35a5..362d2c17f4 100644 --- a/src/lib/util/repeatStoredTrip.ts +++ b/src/lib/util/repeatStoredTrip.ts @@ -435,7 +435,8 @@ const tripHandlers = { name: autocompleteMonsters.find(i => i.id === data.mi)?.name ?? data.mi.toString(), quantity: data.iQty, method, - wilderness: data.isInWilderness + wilderness: data.isInWilderness, + onTask: data.onTask }; } }, diff --git a/src/mahoji/commands/k.ts b/src/mahoji/commands/k.ts index 1678248572..237ce40af6 100644 --- a/src/mahoji/commands/k.ts +++ b/src/mahoji/commands/k.ts @@ -141,6 +141,7 @@ export const minionKCommand: OSBMahojiCommand = { show_info?: boolean; wilderness?: boolean; solo?: boolean; + onTask?: boolean; }>) => { const user = await mUserFetch(userID); if (options.show_info) { @@ -154,7 +155,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 b874105d7e..cbc98f0cdf 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), @@ -128,7 +133,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