From 7251d4b16ee1f7c81e1c924629a8d17d79966813 Mon Sep 17 00:00:00 2001 From: DayV Date: Sun, 24 Nov 2024 11:03:19 +0000 Subject: [PATCH] init --- src/lib/minions/functions/index.ts | 2 +- src/lib/util/repeatStoredTrip.ts | 2 +- .../minionKill/newMinionKill.ts | 28 ++++--------------- .../minionKill/speedBoosts.ts | 5 +++- .../minionKill/timeAndSpeed.ts | 18 +++++++++++- src/tasks/minions/monsterActivity.ts | 3 +- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/lib/minions/functions/index.ts b/src/lib/minions/functions/index.ts index 9b9e36813e3..243156a5280 100644 --- a/src/lib/minions/functions/index.ts +++ b/src/lib/minions/functions/index.ts @@ -175,7 +175,7 @@ export function addMonsterXPRaw(params: { }); // Add cannon xp last so it's easy to distinguish - if (params.usingCannon) { + if (params.usingCannon || params.cannonMulti) { xpBank.add('ranged', Math.floor(hp * 2 * cannonQty), { duration: params.duration, minimal: params.minimal ?? true diff --git a/src/lib/util/repeatStoredTrip.ts b/src/lib/util/repeatStoredTrip.ts index afbbac35a54..ee5e56399be 100644 --- a/src/lib/util/repeatStoredTrip.ts +++ b/src/lib/util/repeatStoredTrip.ts @@ -427,7 +427,7 @@ const tripHandlers = { commandName: 'k', args: (data: MonsterActivityTaskOptions) => { let method: PvMMethod = 'none'; - if (data.usingCannon) method = 'cannon'; + if (data.usingCannon || data.cannonMulti) method = 'cannon'; if (data.chinning) method = 'chinning'; else if (data.bob === SlayerActivityConstants.IceBarrage) method = 'barrage'; else if (data.bob === SlayerActivityConstants.IceBurst) method = 'burst'; diff --git a/src/mahoji/lib/abstracted_commands/minionKill/newMinionKill.ts b/src/mahoji/lib/abstracted_commands/minionKill/newMinionKill.ts index 0565943c498..934811c1c4b 100644 --- a/src/mahoji/lib/abstracted_commands/minionKill/newMinionKill.ts +++ b/src/mahoji/lib/abstracted_commands/minionKill/newMinionKill.ts @@ -5,7 +5,7 @@ import { mergeDeep } from 'remeda'; import z from 'zod'; import type { BitField, PvMMethod } from '../../../../lib/constants'; import { getSimilarItems } from '../../../../lib/data/similarItems'; -import { type CombatOptionsEnum, SlayerActivityConstants } from '../../../../lib/minions/data/combatConstants'; +import type { CombatOptionsEnum } from '../../../../lib/minions/data/combatConstants'; import { revenantMonsters } from '../../../../lib/minions/data/killableMonsters/revs'; import { type AttackStyles, @@ -19,18 +19,11 @@ import { type CurrentSlayerInfo, determineCombatBoosts } from '../../../../lib/s import type { GearBank } from '../../../../lib/structures/GearBank'; import { UpdateBank } from '../../../../lib/structures/UpdateBank'; import type { Peak } from '../../../../lib/tickers'; -import { - checkRangeGearWeapon, - formatDuration, - isWeekend, - itemNameFromID, - numberEnum, - zodEnum -} from '../../../../lib/util'; +import { checkRangeGearWeapon, formatDuration, isWeekend, itemNameFromID, zodEnum } from '../../../../lib/util'; import getOSItem from '../../../../lib/util/getOSItem'; import { killsRemainingOnTask } from './calcTaskMonstersRemaining'; import { type PostBoostEffect, postBoostEffects } from './postBoostEffects'; -import { speedCalculations } from './timeAndSpeed'; +import { CombatMethodOptionsSchema, speedCalculations } from './timeAndSpeed'; const newMinionKillReturnSchema = z.object({ duration: z.number().int().positive(), @@ -38,22 +31,11 @@ const newMinionKillReturnSchema = z.object({ isOnTask: z.boolean(), isInWilderness: z.boolean(), attackStyles: z.array(z.enum(zodEnum(attackStylesArr))), - currentTaskOptions: z.object({ - bob: z - .number() - .superRefine(numberEnum([SlayerActivityConstants.IceBarrage, SlayerActivityConstants.IceBurst])) - .optional(), - usingCannon: z.boolean().optional(), - cannonMulti: z.boolean().optional(), - chinning: z.boolean().optional(), - hasWildySupplies: z.boolean().optional(), - died: z.boolean().optional(), - pkEncounters: z.number().int().min(0).optional(), - isInWilderness: z.boolean().optional() - }), + currentTaskOptions: CombatMethodOptionsSchema, messages: z.array(z.string()), updateBank: z.instanceof(UpdateBank) }); + export type MinionKillReturn = z.infer; export interface MinionKillOptions { attackStyles: AttackStyles[]; diff --git a/src/mahoji/lib/abstracted_commands/minionKill/speedBoosts.ts b/src/mahoji/lib/abstracted_commands/minionKill/speedBoosts.ts index 5e481f33484..8d3d1de0861 100644 --- a/src/mahoji/lib/abstracted_commands/minionKill/speedBoosts.ts +++ b/src/mahoji/lib/abstracted_commands/minionKill/speedBoosts.ts @@ -109,7 +109,10 @@ const cannonBoost: Boost = { return { percentageReduction: boostCannon, consumables: [cannonSingleConsumables], - message: `${boostCannon}% for Cannon in singles` + message: `${boostCannon}% for Cannon in singles`, + changes: { + usingCannon: true + } }; } diff --git a/src/mahoji/lib/abstracted_commands/minionKill/timeAndSpeed.ts b/src/mahoji/lib/abstracted_commands/minionKill/timeAndSpeed.ts index aebcb659d46..168d11ba48a 100644 --- a/src/mahoji/lib/abstracted_commands/minionKill/timeAndSpeed.ts +++ b/src/mahoji/lib/abstracted_commands/minionKill/timeAndSpeed.ts @@ -3,19 +3,35 @@ import { Bank } from 'oldschooljs'; import { mergeDeep } from 'remeda'; import z from 'zod'; +import { SlayerActivityConstants } from '../../../../lib/minions/data/combatConstants'; import { type AttackStyles, getAttackStylesContext } from '../../../../lib/minions/functions'; import reducedTimeFromKC from '../../../../lib/minions/functions/reducedTimeFromKC'; import type { Consumable } from '../../../../lib/minions/types'; import { ChargeBank } from '../../../../lib/structures/Bank'; import { UpdateBank } from '../../../../lib/structures/UpdateBank'; import type { SkillsRequired } from '../../../../lib/types'; +import { numberEnum } from '../../../../lib/util'; import { getItemCostFromConsumables } from './handleConsumables'; import { type BoostArgs, type BoostResult, type CombatMethodOptions, mainBoostEffects } from './speedBoosts'; +export const CombatMethodOptionsSchema = z.object({ + bob: z + .number() + .superRefine(numberEnum([SlayerActivityConstants.IceBarrage, SlayerActivityConstants.IceBurst])) + .optional(), + usingCannon: z.boolean().optional(), + cannonMulti: z.boolean().optional(), + chinning: z.boolean().optional(), + hasWildySupplies: z.boolean().optional(), + died: z.boolean().optional(), + pkEncounters: z.number().int().min(0).optional(), + isInWilderness: z.boolean().optional() +}); + const schema = z.object({ timeToFinish: z.number().int().positive(), messages: z.array(z.string()), - currentTaskOptions: z.object({}), + currentTaskOptions: CombatMethodOptionsSchema, finalQuantity: z.number().int().positive().min(1), confirmations: z.array(z.string()), updateBank: z.instanceof(UpdateBank) diff --git a/src/tasks/minions/monsterActivity.ts b/src/tasks/minions/monsterActivity.ts index 6bc5748106b..2dc3142a84e 100644 --- a/src/tasks/minions/monsterActivity.ts +++ b/src/tasks/minions/monsterActivity.ts @@ -286,7 +286,8 @@ export function doMonsterTrip(data: newOptions) { }); const superiorTable = slayerContext.hasSuperiorsUnlocked && monster.superior ? monster.superior : undefined; - const isInCatacombs = (!usingCannon ? (monster.existsInCatacombs ?? undefined) : undefined) && !isInWilderness; + const isInCatacombs = + (!(usingCannon || cannonMulti) ? (monster.existsInCatacombs ?? undefined) : undefined) && !isInWilderness; const hasRingOfWealthI = gearBank.gear.wildy.hasEquipped('Ring of wealth (i)') && isInWilderness; if (hasRingOfWealthI) {