Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Inferno KC to impact Fightcaves #5689

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 @@

// 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 @@
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 @@
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 @@

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 @@ -139,7 +152,7 @@
fakeDuration
});

updateBankSetting('economyStats_fightCavesCost', fightCavesCost);

Check warning on line 155 in src/mahoji/lib/abstracted_commands/fightCavesCommand.ts

View workflow job for this annotation

GitHub Actions / ESLint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

const totalDeathChance = (((100 - preJadDeathChance) * (100 - jadDeathChance)) / 100).toFixed(1);

Expand All @@ -148,6 +161,7 @@
**Boosts:** ${debugStr}
**Range Attack Bonus:** ${usersRangeStats.attack_ranged}
**Jad KC:** ${jadKC}
**Zuk KC:** ${zukKC}
**Attempts:** ${attempts}

**Removed from your bank:** ${fightCavesCost}`,
Expand Down
Loading