Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/oldschoolgg/oldschoolbot
Browse files Browse the repository at this point in the history
…into wildy-slayer
  • Loading branch information
TastyPumPum committed Feb 17, 2024
2 parents 161c721 + dbf35dd commit a2f3902
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ export enum BitField {
SelfGamblingLocked = 36,
DisabledFarmingReminders = 37,
DisableClueButtons = 38,
DisableAutoSlayButton = 39
DisableAutoSlayButton = 39,
DisableHighPeakTimeWarning = 40
}

interface BitFieldData {
Expand Down Expand Up @@ -350,6 +351,11 @@ export const BitFieldData: Record<BitField, BitFieldData> = {
name: 'Disable Auto Slay Button',
protected: false,
userConfigurable: true
},
[BitField.DisableHighPeakTimeWarning]: {
name: 'Disable Wilderness High Peak Time Warning',
protected: false,
userConfigurable: true
}
} as const;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/data/Collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function kcProg(mon: Monster): FormatProgressFunction {
}

function mgProg(minigameName: MinigameName): FormatProgressFunction {
return ({ minigames }) => `${minigames[minigameName]} KC`;
return ({ minigames }) => `${minigames[minigameName]} Completions`;
}

function skillProg(skillName: SkillsEnum): FormatProgressFunction {
Expand Down Expand Up @@ -807,7 +807,7 @@ export const allCollectionLogs: ICollection = {
"Shades of Mort'ton": {
items: shadesOfMorttonCL,
isActivity: true,
fmtProg: () => '0 KC'
fmtProg: mgProg('shades_of_morton')
},
'Soul Wars': {
alias: ['soul wars', 'sw'],
Expand Down
4 changes: 4 additions & 0 deletions src/mahoji/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ const toggles: UserConfigToggle[] = [
{
name: 'Disable Clue Buttons',
bit: BitField.DisableClueButtons
},
{
name: 'Disable wilderness high peak time warning',
bit: BitField.DisableHighPeakTimeWarning
}
];

Expand Down
28 changes: 21 additions & 7 deletions src/mahoji/lib/abstracted_commands/fightCavesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Bank, Monsters } from 'oldschooljs';
import TzTokJad from 'oldschooljs/dist/simulation/monsters/special/TzTokJad';
import { itemID } from 'oldschooljs/dist/util';

import { getMinigameScore } from '../../../lib/settings/minigames';
import { getUsersCurrentSlayerInfo } from '../../../lib/slayer/slayerUtil';
import { FightCavesActivityTaskOptions } from '../../../lib/types/minions';
import { formatDuration } from '../../../lib/util';
Expand All @@ -24,7 +25,9 @@ async function determineDuration(user: MUser): Promise<[number, string]> {

// Reduce time based on KC
const jadKC = await user.getKC(TzTokJad.id);
const percentIncreaseFromKC = Math.min(50, jadKC);
const zukKC = await getMinigameScore(user.id, 'inferno');
const experienceKC = jadKC + zukKC * 3;
const percentIncreaseFromKC = Math.min(50, experienceKC);
baseTime = reduceNumByPercent(baseTime, percentIncreaseFromKC);
debugStr += `${percentIncreaseFromKC}% from KC`;

Expand All @@ -43,9 +46,12 @@ async function determineDuration(user: MUser): Promise<[number, string]> {
return [baseTime, debugStr];
}

function determineChanceOfDeathPreJad(user: MUser, attempts: number) {
function determineChanceOfDeathPreJad(user: MUser, attempts: number, hasInfernoKC: boolean) {
let deathChance = Math.max(14 - attempts * 2, 5);

// If user has killed inferno, give them the lowest chance of death pre Jad.
if (hasInfernoKC) deathChance = 5;

// -4% Chance of dying before Jad if you have SGS.
if (user.hasEquipped(itemID('Saradomin godsword'))) {
deathChance -= 4;
Expand All @@ -54,8 +60,12 @@ function determineChanceOfDeathPreJad(user: MUser, attempts: number) {
return deathChance;
}

function determineChanceOfDeathInJad(attempts: number) {
const chance = Math.floor(100 - (Math.log(attempts) / Math.log(Math.sqrt(15))) * 50);
function determineChanceOfDeathInJad(attempts: number, hasInfernoKC: boolean) {
let chance = Math.floor(100 - (Math.log(attempts) / Math.log(Math.sqrt(15))) * 50);

if (hasInfernoKC) {
chance /= 1.5;
}

// Chance of death cannot be 100% or <5%.
return Math.max(Math.min(chance, 99), 5);
Expand Down Expand Up @@ -98,11 +108,14 @@ export async function fightCavesCommand(user: MUser, channelID: string): Command

const { fight_caves_attempts: attempts } = await user.fetchStats({ fight_caves_attempts: true });

const jadDeathChance = determineChanceOfDeathInJad(attempts);
const preJadDeathChance = determineChanceOfDeathPreJad(user, attempts);
const jadKC = await user.getKC(TzTokJad.id);
const zukKC = await getMinigameScore(user.id, 'inferno');
const hasInfernoKC = zukKC > 0;

const jadDeathChance = determineChanceOfDeathInJad(attempts, hasInfernoKC);
const preJadDeathChance = determineChanceOfDeathPreJad(user, attempts, hasInfernoKC);

const usersRangeStats = user.gear.range.stats;
const jadKC = await user.getKC(TzTokJad.id);

duration += (randInt(1, 5) * duration) / 100;

Expand Down Expand Up @@ -148,6 +161,7 @@ export async function fightCavesCommand(user: MUser, channelID: string): Command
**Boosts:** ${debugStr}
**Range Attack Bonus:** ${usersRangeStats.attack_ranged}
**Jad KC:** ${jadKC}
**Zuk KC:** ${zukKC}
**Attempts:** ${attempts}
**Removed from your bank:** ${fightCavesCost}`,
Expand Down
4 changes: 2 additions & 2 deletions src/mahoji/lib/abstracted_commands/minionKill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Bank, Monsters } from 'oldschooljs';
import { MonsterAttribute } from 'oldschooljs/dist/meta/monsterData';
import { itemID } from 'oldschooljs/dist/util';

import { PeakTier, PvMMethod } from '../../../lib/constants';
import { BitField, PeakTier, PvMMethod } from '../../../lib/constants';
import { Eatables } from '../../../lib/data/eatables';
import { getSimilarItems } from '../../../lib/data/similarItems';
import { checkUserCanUseDegradeableItem, degradeablePvmBoostItems, degradeItem } from '../../../lib/degradeableItems';
Expand Down Expand Up @@ -720,7 +720,7 @@ export async function minionKillCommand(
break;
}
}
if (wildyPeak?.peakTier === PeakTier.High) {
if (wildyPeak?.peakTier === PeakTier.High && !user.bitfield.includes(BitField.DisableHighPeakTimeWarning)) {
if (interaction) {
await handleMahojiConfirmation(
interaction,
Expand Down

0 comments on commit a2f3902

Please sign in to comment.