Skip to content

Commit

Permalink
Prevent repeat /k trip when task finished
Browse files Browse the repository at this point in the history
  • Loading branch information
DayV-git committed Nov 10, 2024
1 parent e03afd6 commit bea16da
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/lib/types/minions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export interface MonsterActivityTaskOptions extends ActivityTaskOptions {
hasWildySupplies?: boolean;
isInWilderness?: boolean;
attackStyles?: AttackStyles[];
onTask?: boolean;
}

export interface ClueActivityTaskOptions extends ActivityTaskOptions {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/util/repeatStoredTrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
},
Expand Down
4 changes: 3 additions & 1 deletion src/mahoji/commands/k.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -154,7 +155,8 @@ export const minionKCommand: OSBMahojiCommand = {
options.quantity,
options.method,
options.wilderness,
options.solo
options.solo,
options.onTask
);
}
};
12 changes: 9 additions & 3 deletions src/mahoji/lib/abstracted_commands/minionKill/minionKill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | InteractionReplyOptions> {
if (user.minionIsBusy) {
return 'Your minion is busy.';
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bea16da

Please sign in to comment.