Skip to content

Commit

Permalink
Ghommal's lucky penny, Lower vial of blood cost (#5686)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwjgit authored Feb 19, 2024
1 parent 7dbda44 commit 389747f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/lib/degradeableItems.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { percentChance } from 'e';
import { Bank } from 'oldschooljs';
import { Item } from 'oldschooljs/dist/meta/types';
import Monster from 'oldschooljs/dist/structures/Monster';
Expand Down Expand Up @@ -211,7 +212,7 @@ export const degradeableItems: DegradeableItem[] = [
setup: 'melee',
aliases: ['scythe of vitur'],
chargeInput: {
cost: new Bank().add('Blood rune', 300).add('Vial of blood').freeze(),
cost: new Bank().add('Blood rune', 200).add('Vial of blood').freeze(),
charges: 100
},
unchargedItem: getOSItem('Scythe of vitur (uncharged)'),
Expand Down Expand Up @@ -297,6 +298,17 @@ export async function degradeItem({
const degItem = degradeableItems.find(i => i.item === item);
if (!degItem) throw new Error('Invalid degradeable item');

// 5% chance to not consume a charge when Ghommal's lucky penny is equipped
let pennyReduction = 0;
if (user.hasEquipped("Ghommal's lucky penny")) {
for (let i = 0; i < chargesToDegrade; i++) {
if (percentChance(5)) {
pennyReduction++;
}
}
}
chargesToDegrade -= pennyReduction;

const currentCharges = user.user[degItem.settingsKey];
assert(typeof currentCharges === 'number');
const newCharges = Math.floor(currentCharges - chargesToDegrade);
Expand Down Expand Up @@ -353,7 +365,11 @@ export async function degradeItem({
const chargesAfter = user.user[degItem.settingsKey];
assert(typeof chargesAfter === 'number' && chargesAfter > 0);
return {
userMessage: `Your ${item.name} degraded by ${chargesToDegrade} charges, and now has ${chargesAfter} remaining.`
userMessage: `Your ${
item.name
} degraded by ${chargesToDegrade} charges, and now has ${chargesAfter} remaining.${
pennyReduction > 0 ? ` Your Ghommal's lucky penny saved ${pennyReduction} charges` : ''
}`
};
}

Expand Down

0 comments on commit 389747f

Please sign in to comment.