Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion src/lib/BaseCalc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DREADNOTH_JELLY_ID,
ICE_DEMON_IDS,
IMMUNE_TO_BURN_DAMAGE_NPC_IDS,
XARTH_CORPSE_ID,
YAMA_IDS,
YAMA_VOID_FLARE_IDS,
} from '@/lib/constants';
Expand All @@ -21,7 +22,7 @@ import { getCombatStylesForCategory, isDefined } from '@/utils';
import { EquipmentCategory } from '@/enums/EquipmentCategory';
import { getRangedDamageType } from '@/types/PlayerCombatStyle';
import { AttackDistribution, HitDistribution } from '@/lib/HitDist';
import { Spellement } from '@/types/Spell';
import { isFreezeSpell, Spellement } from '@/types/Spell';

export interface CalcOpts {
loadoutName?: string,
Expand Down Expand Up @@ -720,6 +721,12 @@ export default class BaseCalc {
&& this.isUsingMeleeStyle();
}

protected isUsingFreeze(): boolean {
return this.player.style.type === 'magic'
&& (isFreezeSpell(this.player.spell)
|| (this.monster.id === XARTH_CORPSE_ID && this.getSpellement() === 'water'));
}

protected addIssue(type: UserIssueType, message: string) {
this.userIssues.push({ type, message });
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/CalcDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export enum DetailKey {
PLAYER_ACCURACY_INQ = 'Player accuracy inquisitor\'s',
PLAYER_ACCURACY_BRIMSTONE = 'Player accuracy brimstone ring',
PLAYER_ACCURACY_SPEC = 'Player accuracy spec',
PLAYER_ACCURACY_FREEZE_THRESHOLD = 'Player accuracy freeze threshold',
PLAYER_ACCURACY_ROLL_FINAL = 'Player accuracy roll',
DAMAGE_LEVEL = 'Damage level',
DAMAGE_LEVEL_PRAYER = 'Damage level prayer',
Expand Down
20 changes: 20 additions & 0 deletions src/lib/PlayerVsNPCCalc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
BORK_IDS,
DOOM_OF_MOKHAIOTL_IDS,
ECLIPSE_MOON_IDS,
FREEZE_THRESHOLD_NPCS,
GLOWING_CRYSTAL_IDS,
GUARANTEED_ACCURACY_MONSTERS,
GUARDIAN_IDS,
Expand Down Expand Up @@ -1364,6 +1365,25 @@ export default class PlayerVsNPCCalc extends BaseCalc {
hitChance = this.track(DetailKey.PLAYER_ACCURACY_CONFLICTION_GAUNTLETS, BaseCalc.getConflictionGauntletsAccuracyRoll(atk, def));
}

// According to Mod Ash on the OSRS Discord, monsters with a magic accuracy threshold for freezes work like this:
// - min accuracy roll (m) = (base_magic + 9) * (0 + 64)
// - max accuracy roll (M) = (base_magic + 9) * (threshold + 64)
// - player's max accuracy roll (a) = this.getMaxAttackRoll() (i.e., normal max accuracy roll with everything included)
// a >= M -> 100% hit chance
// a < m -> 0% hit chance
// m <= a < M -> hit chance scales linearly as (a - m + 1) / (M - m)
const threshold = FREEZE_THRESHOLD_NPCS[this.monster.id];
if (threshold !== undefined && this.isUsingFreeze()) {
const level = this.player.skills.magic + 9;
const minRoll = level * 64;
const maxRoll = level * (threshold + 64);

hitChance = this.track(
DetailKey.PLAYER_ACCURACY_FREEZE_THRESHOLD,
Math.max(0, Math.min(1, (atk - minRoll + 1) / (maxRoll - minRoll))),
);
}

return this.track(DetailKey.PLAYER_ACCURACY_FINAL, hitChance);
}

Expand Down
12 changes: 12 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,15 @@ export const TFA_DEF_FLOOR_NPCS = [
export const DREADNOTH_JELLY_ID = 16666;

export const TANGLEFOOT_IDS = [5848, 5853, 5854, 6291, 6353];

export const XARTH_CORPSE_ID = 16687;

export const FREEZE_THRESHOLD_NPCS: { [npcId: number]: number } = {
10820: 140, // Nylocas Matomenos (maiden, entry)
8366: 140, // Nylocas Matomenos (maiden, normal)
10828: 140, // Nylocas Matomenos (maiden, hard)
12814: 140, // Fremennik warband archer
12815: 140, // Fremennik warband seer
12816: 140, // Fremennik warband berserker
[XARTH_CORPSE_ID]: 75, // Xarth corpse
};
7 changes: 7 additions & 0 deletions src/types/Spell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export function isBindSpell(spell: Spell | null): boolean {
.includes(spell.name);
}

export function isFreezeSpell(spell: Spell | null): boolean {
return spell !== null
&& (isBindSpell(spell)
|| ['Ice Rush', 'Ice Burst', 'Ice Blitz', 'Ice Barrage', 'Ghostly Grasp', 'Skeletal Grasp', 'Undead Grasp']
.includes(spell.name));
}

export function canUseSunfireRunes(spell: Spell | null): boolean {
return spell?.element === 'fire';
}
Expand Down