Skip to content

Commit

Permalink
Allow Inferno KC to impact Fightcaves (#5689)
Browse files Browse the repository at this point in the history
  • Loading branch information
TastyPumPum authored Feb 14, 2024
1 parent 3267641 commit dbf35dd
Showing 1 changed file with 21 additions and 7 deletions.
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

0 comments on commit dbf35dd

Please sign in to comment.