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

userissues: fail calc on missing blowpipe ammo #319

Merged
merged 2 commits into from
Apr 24, 2024
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
1 change: 1 addition & 0 deletions src/enums/UserIssueType.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
enum UserIssueType {
EQUIPMENT_MISSING_AMMO = 'equipment_slot_ammo_missing',
EQUIPMENT_WRONG_AMMO = 'equipment_slot_ammo_wrong',
BLOWPIPE_MISSING_AMMO = 'equipment_slot_weapon_blowpipe_missing_ammo',
EQUIPMENT_SET_EFFECT_UNSUPPORTED = 'equipment_slot_body_unsupported_set_effect',
SPELL_WRONG_WEAPON = 'spell_wrong_weapon',
SPELL_WRONG_MONSTER = 'spell_wrong_monster',
Expand Down
5 changes: 5 additions & 0 deletions src/lib/BaseCalc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,11 @@ export default class BaseCalc {
};
}

if (eq.weapon && ['Toxic blowpipe', 'Blazing blowpipe'].includes(eq.weapon.name) && ['Empty', 'Charged'].includes(eq.weapon.version)) {
// this can happen on a load from runelite, since we can't detect the ammo loaded into the blowpipe
this.addIssue(UserIssueType.BLOWPIPE_MISSING_AMMO, 'This blowpipe does not contain ammo. Select another version in the equipment selector.');
}

if (this.player.style.stance !== 'Manual Cast' && ammoApplicability(eq.weapon?.id, eq.ammo?.id) === AmmoApplicability.INVALID) {
if (eq.ammo?.name) {
this.addIssue(UserIssueType.EQUIPMENT_WRONG_AMMO, 'This ammo does not work with your current weapon.');
Expand Down
28 changes: 13 additions & 15 deletions src/lib/PlayerVsNPCCalc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ import {
WeightedHit,
} from '@/lib/HitDist';
import {
canUseSunfireRunes,
isBindSpell,
isFireSpell,
isWaterSpell,
canUseSunfireRunes, isBindSpell, isFireSpell, isWaterSpell,
} from '@/types/Spell';
import {
PrayerData, PrayerMap,
} from '@/enums/Prayer';
import { PrayerData, PrayerMap } from '@/enums/Prayer';
import { isVampyre, MonsterAttribute } from '@/enums/MonsterAttribute';
import {
CAST_STANCES, DEFAULT_ATTACK_SPEED,
CAST_STANCES,
DEFAULT_ATTACK_SPEED,
GLOWING_CRYSTAL_IDS,
GUARDIAN_IDS,
IMMUNE_TO_MAGIC_DAMAGE_NPC_IDS,
Expand All @@ -30,21 +26,23 @@ import {
IMMUNE_TO_RANGED_DAMAGE_NPC_IDS,
OLM_HEAD_IDS,
OLM_MAGE_HAND_IDS,
OLM_MELEE_HAND_IDS, ONE_HIT_MONSTERS, SECONDS_PER_TICK,
OLM_MELEE_HAND_IDS,
ONE_HIT_MONSTERS,
SECONDS_PER_TICK,
TEKTON_IDS,
TOMBS_OF_AMASCUT_MONSTER_IDS, TTK_DIST_EPSILON, TTK_DIST_MAX_ITER_ROUNDS,
TOMBS_OF_AMASCUT_MONSTER_IDS,
TTK_DIST_EPSILON,
TTK_DIST_MAX_ITER_ROUNDS,
USES_DEFENCE_LEVEL_FOR_MAGIC_DEFENCE_NPC_IDS,
VERZIK_P1_IDS,
} from '@/lib/constants';
import { EquipmentCategory } from '@/enums/EquipmentCategory';
import { DetailKey } from '@/lib/CalcDetails';
import { Factor } from '@/lib/Math';
import {
AmmoApplicability,
ammoApplicability,
} from '@/lib/Equipment';
import { AmmoApplicability, ammoApplicability } from '@/lib/Equipment';
import BaseCalc, { CalcOpts, InternalOpts } from '@/lib/BaseCalc';
import { scaleMonsterHpOnly } from '@/lib/MonsterScaling';
import UserIssueType from '@/enums/UserIssueType';

/**
* Class for computing various player-vs-NPC metrics.
Expand Down Expand Up @@ -603,7 +601,7 @@ export default class PlayerVsNPCCalc extends BaseCalc {
if (this.player.style.stance !== 'Manual Cast') {
const weaponId = this.player.equipment.weapon?.id;
const ammoId = this.player.equipment.ammo?.id;
if (ammoApplicability(weaponId, ammoId) === AmmoApplicability.INVALID) {
if (ammoApplicability(weaponId, ammoId) === AmmoApplicability.INVALID || this.userIssues.some((ui) => ui.type === UserIssueType.BLOWPIPE_MISSING_AMMO)) {
return 0;
}
}
Expand Down
Loading