Skip to content

Commit

Permalink
Add Slayers Enchantment
Browse files Browse the repository at this point in the history
  • Loading branch information
TastyPumPum committed Oct 13, 2023
1 parent 465b45f commit 928609b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/structures/SimpleMonster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getAncientShardChanceFromHP,
getBrimKeyChanceFromCBLevel,
getLarranKeyChanceFromCBLevel,
getSlayersEnchantmentChanceFromHP,
getTotemChanceFromHP
} from '../util/util';
import Bank from './Bank';
Expand Down Expand Up @@ -43,16 +44,23 @@ export default class SimpleMonster extends Monster {
public kill(quantity = 1, options: MonsterKillOptions = {}): Bank {
const loot = new Bank();
const canGetBrimKey = options.onSlayerTask && options.slayerMaster === MonsterSlayerMaster.Konar;
const canGetSlayersEnchantment = options.onSlayerTask && options.slayerMaster === MonsterSlayerMaster.Krystilia;
const canGetLarranKey = options.onSlayerTask && options.slayerMaster === MonsterSlayerMaster.Krystilia;
const slayerMonster: boolean = Boolean(options.onSlayerTask && this.data.slayerLevelRequired > 1);

for (let i = 0; i < quantity; i++) {
if (canGetBrimKey) {
if (roll(getBrimKeyChanceFromCBLevel(this.data.combatLevel))) {
loot.add('Brimstone key');
}
}
if (canGetSlayersEnchantment && this.data.hitpoints) {
if (roll(getSlayersEnchantmentChanceFromHP(this.data.hitpoints))) {
loot.add("Slayer's enchantment");
}
}
if (canGetLarranKey) {
if (roll(getLarranKeyChanceFromCBLevel(this.data.combatLevel))) {
if (roll(getLarranKeyChanceFromCBLevel(this.data.combatLevel, slayerMonster))) {
loot.add("Larran's key");
}
}
Expand Down
21 changes: 17 additions & 4 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,21 @@ export function getBrimKeyChanceFromCBLevel(combatLevel: number): number {
return Math.max(Math.round((-1 / 5) * combatLevel + 120), 50);
}

export function getLarranKeyChanceFromCBLevel(combatLevel: number): number {
export function getLarranKeyChanceFromCBLevel(combatLevel: number, slayerMonster: boolean): number {
let baseChance = 0;

if (combatLevel <= 80) {
return (3 / 10) * Math.pow(80 - combatLevel, 2) + 100;
baseChance = (3 / 10) * Math.pow(80 - combatLevel, 2) + 100;
} else if (combatLevel <= 350) {
return (-5 / 27) * combatLevel + 115;
baseChance = (-5 / 27) * combatLevel + 115;
} else {
baseChance = 50;
}
return 50;

// Reduce the base chance by 20% if slayerMonster is true
const adjustedChance = slayerMonster ? baseChance * 0.8 : baseChance;

return adjustedChance;
}

export function JSONClone<O>(object: O): O {
Expand All @@ -191,6 +199,11 @@ export function getTotemChanceFromHP(hitpoints: number): number {
return 500 - hitpoints;
}

export function getSlayersEnchantmentChanceFromHP(hitpoints: number): number {
let chanceHitpoints = Math.min(hitpoints, 300);
return Math.round(320 - (chanceHitpoints * 8) / 10);
}

export interface RevTable {
uniqueTable: RevTableItem;
ancientEmblem: RevTableItem;
Expand Down

0 comments on commit 928609b

Please sign in to comment.