osrs-tools
Version:
A comprehensive TypeScript library for Old School RuneScape (OSRS) data and utilities, including quest data, skill requirements, and game item information
166 lines • 4.94 kB
TypeScript
/**
* Enhanced NPC Drop System for Complex Drop Mechanics
* Handles drop tables, rare drops, secondary rolls, and weighted systems
* This file shows how to extend the basic NpcDrop model for scalability
*/
import { NpcDrop } from './NpcDrop';
/**
* Weighted drop - An item with a weight in a weighted selection
* Useful for "rare drop table" mechanics where one of several items is chosen
*/
export declare class WeightedDrop {
drop: NpcDrop;
weight: number;
constructor(drop: NpcDrop, weight: number);
/**
* Calculate the probability of this drop being selected
* Only valid when used in a WeightedDropTable
*/
getProbabilityInTable(totalWeight: number): number;
}
/**
* Weighted drop table - Roll a single drop from weighted options
* Example: Boss drops either Sword (weight 30), Shield (weight 15), or Helm (weight 5)
* Chance to get Sword = 30/50 = 60%
*/
export declare class WeightedDropTable {
private drops;
private totalWeight;
/**
* Add a drop to the weighted table
*/
addDrop(drop: NpcDrop, weight: number): void;
/**
* Get all drops in this table
*/
getDrops(): WeightedDrop[];
/**
* Sort by weight (most common first)
*/
sortByWeight(descending?: boolean): void;
/**
* Calculate probability of each drop
*/
getDropProbabilities(): Map<NpcDrop, number>;
/**
* Get the most likely drop
*/
getMostLikelyDrop(): WeightedDrop | undefined;
toString(): string;
}
/**
* Drop roll - Represents one "roll" in a multi-roll system
* Example: Zulrah drops coins (always) THEN rolls rare drop table
*/
export declare class DropRoll {
name: string;
drops: NpcDrop[] | WeightedDropTable;
chanceString: string;
constructor(name: string, // e.g., "Primary", "Secondary", "Tertiary", "Rare"
drops: NpcDrop[] | WeightedDropTable, chanceString?: string);
/**
* Check if this roll is guaranteed
*/
get isGuaranteed(): boolean;
/**
* Check if drops are weighted or a flat list
*/
get isWeighted(): boolean;
getDrop(itemId: string): NpcDrop | undefined;
toString(): string;
}
/**
* Complete NPC drop table with multiple rolls
* Replaces the old flat drop array
*
* OSRS Example - Zulrah Boss:
* - Roll 1 (Always): 2-3 drops from primary table
* - Roll 2 (Always): 1 drop from secondary table
* - Roll 3 (4/128): 1 drop from rare table
*
* OSRS Example - Woman NPC:
* - Roll 1 (Always): Bones (100%)
* (Note: Woman only has one simple roll)
*/
export declare class CompleteDropTable {
private rolls;
private name;
constructor(npcName?: string);
/**
* Add a roll to the drop table
*/
addRoll(roll: DropRoll): void;
/**
* Add a simple guaranteed roll with flat drops
*/
addSimpleRoll(name: string, drops: NpcDrop[]): void;
/**
* Add a weighted roll (e.g., rare drop table)
*/
addWeightedRoll(name: string, table: WeightedDropTable, chance?: string | number): void;
/**
* Get all rolls
*/
getRolls(): DropRoll[];
/**
* Get all possible drops (flattened)
*/
getAllPossibleDrops(): NpcDrop[];
/**
* Find a specific drop by item ID
*/
findDrop(itemId: string): NpcDrop | undefined;
/**
* Get conditional drops only
*/
getConditionalDrops(): NpcDrop[];
/**
* Estimate average drops per kill (simplified)
*/
estimateAverageDrops(): number;
toString(): string;
}
/**
* Shared rare drop table - Used by multiple NPCs
* OSRS Example: Many bosses share the same rare drop table
*/
export declare class SharedRareDropTable {
private rarities;
/**
* Add a weighted drop table for a specific rarity tier
* Example: tier 1 = very rare (1/512), tier 2 = rare (1/128), etc.
*/
addTier(tier: number, table: WeightedDropTable): void;
/**
* Get a specific tier
*/
getTier(tier: number): WeightedDropTable | undefined;
/**
* Get all tiers
*/
getAllTiers(): number[];
toString(): string;
}
/**
* Example 1: Simple NPC (Woman)
* - Always drops Bones (100%)
*/
export declare function createWomanDropTable(): CompleteDropTable;
/**
* Example 2: Boss with multiple rolls (Zulrah simplified)
* - Always get 2-3 primary drops
* - Always get 1 secondary drop
* - 4/128 chance for 1 rare drop
*/
export declare function createZulrahDropTable(): CompleteDropTable;
/**
* Example 3: Boss with shared rare drop table
* Many GWD bosses share a common rare table
*/
export declare function createSharedGWDRareTable(): SharedRareDropTable;
/**
* Example 4: Using shared rare table in an NPC
*/
export declare function createGeneralGraardorDropTable(sharedRareTable: SharedRareDropTable): CompleteDropTable;
export declare function demonstrateComplexDropSystems(): void;
//# sourceMappingURL=ComplexDropSystems.d.ts.map