Skip to content

Commit

Permalink
Revs Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TastyPumPum committed Oct 16, 2023
1 parent ee8fc12 commit b725cee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
28 changes: 26 additions & 2 deletions src/mahoji/lib/abstracted_commands/revsCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChatInputCommandInteraction } from 'discord.js';
import { calcWhatPercent, randInt, reduceNumByPercent, Time } from 'e';
import { floor } from 'lodash';
import { CommandResponse } from 'mahoji/dist/lib/structures/ICommand';
import { Bank } from 'oldschooljs';

Expand All @@ -8,6 +9,7 @@ import { trackLoot } from '../../../lib/lootTrack';
import { revenantMonsters } from '../../../lib/minions/data/killableMonsters/revs';
import { convertAttackStylesToSetup } from '../../../lib/minions/functions';
import { SkillsEnum } from '../../../lib/skilling/types';
import { getUsersCurrentSlayerInfo } from '../../../lib/slayer/slayerUtil';
import { maxDefenceStats, maxOffenceStats } from '../../../lib/structures/Gear';
import { RevenantOptions } from '../../../lib/types/minions';
import { formatDuration, percentChance, stringMatches } from '../../../lib/util';
Expand All @@ -31,6 +33,7 @@ export async function revsCommand(
name: string,
quantity: number | undefined
): CommandResponse {
const { minionName } = user;
const style = convertAttackStylesToSetup(user.user.attack_style);
const userGear = user.gear.wildy;

Expand All @@ -45,6 +48,12 @@ export async function revsCommand(
return `That's not a valid Revenant. The valid Revenants are: ${revenantMonsters.map(m => m.name).join(', ')}.`;
}

const usersTask = await getUsersCurrentSlayerInfo(user.id);
const isOnTask =
usersTask.assignedTask !== null &&
usersTask.currentTask !== null &&
usersTask.assignedTask.monsters.includes(monster.id);

const key = ({ melee: 'attack_crush', mage: 'attack_magic', range: 'attack_ranged' } as const)[style];
const gearStat = userGear.getStats()[key];
const gearPercent = Math.max(0, calcWhatPercent(gearStat, maxOffenceStats[key]));
Expand All @@ -70,14 +79,29 @@ export async function revsCommand(

const maxTripLength = Math.floor(calcMaxTripLength(user, 'Revenants'));
if (!quantity) {
quantity = Math.max(1, Math.floor(maxTripLength / timePerMonster));
quantity = floor(maxTripLength / timePerMonster);
}

if (isOnTask) {
let effectiveQtyRemaining = usersTask.currentTask!.quantity_remaining;
quantity = Math.min(quantity, effectiveQtyRemaining);
}

quantity = Math.max(1, quantity);

let duration = quantity * timePerMonster;

if (quantity > 1 && duration > maxTripLength) {
return `${minionName} can't go on PvM trips longer than ${formatDuration(
maxTripLength
)}, try a lower quantity. The highest amount you can do for ${monster.name} is ${floor(
maxTripLength / timePerMonster
)}.`;
}

const cost = new Bank();

let hasPrayerPots = true;

const initialPrayerPots = 1; // At least 1 prayer potion
const millisecondsPer8Minutes = 480_000; // 8 minutes in milliseconds
const additionalPrayerPots = Math.round(duration / millisecondsPer8Minutes);
Expand Down
4 changes: 3 additions & 1 deletion src/mahoji/lib/abstracted_commands/slayerTaskCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { notEmpty, randInt, removeFromArr, Time } from 'e';
import { Monsters } from 'oldschooljs';

import killableMonsters from '../../../lib/minions/data/killableMonsters';
import { revenantMonsters } from '../../../lib/minions/data/killableMonsters/revs';
import { prisma } from '../../../lib/settings/prisma';
import { runCommand } from '../../../lib/settings/settings';
import { slayerMasters } from '../../../lib/slayer/slayerMasters';
Expand Down Expand Up @@ -68,7 +69,8 @@ const returnSuccessButtons = [
function getAlternateMonsterList(assignedTask: AssignableSlayerTask | null) {
if (assignedTask) {
const altMobs = assignedTask.monsters;
const alternateMonsters = killableMonsters
const allMonsters = [...killableMonsters, ...revenantMonsters];
const alternateMonsters = allMonsters
.filter(m => {
return altMobs.includes(m.id) && m!.id !== assignedTask.monster.id;
})
Expand Down

0 comments on commit b725cee

Please sign in to comment.