osrs-tools
Version:
A comprehensive TypeScript library for Old School RuneScape (OSRS) data and utilities, including quest data, skill requirements, and game item information
219 lines (218 loc) • 8.73 kB
JavaScript
/**
* PRACTICAL IMPLEMENTATION EXAMPLE
* ==============================================================
*
* This file demonstrates how to implement drops for multiple NPCs
* following the recommendations from IMPLEMENTATION_STRATEGY.md
* and using the utilities from DropImplementationUtils.ts
*
* BATCH 1: Dragon Types (5 NPCs)
* - Baby Black Dragon
* - Baby Blue Dragon
* - Baby Green Dragon
* - Baby Red Dragon
* - Chromatic Dragons (parent type)
*/
import { Npc } from '../Npc';
import { NpcDrop } from '../NpcDrop';
import { createDragonDrops, DROP_RATES, createBossNPCDrops } from './DropImplementationUtils';
// ============================================================================
// BATCH 1: Dragon Implementation Example
// ============================================================================
/**
* Baby Black Dragon
* Location: Taverly Dungeon
* Level: 79 Combat
* Wiki: https://oldschool.runescape.wiki/w/Baby_black_dragon
*/
export const BabyBlackDragon = new Npc(1590, 'Baby black dragon', 'A small black dragon.', false, 79, 'https://oldschool.runescape.wiki/w/Baby_black_dragon', 80, true, true, false, true, // Can be venom'd
true, // Can use cannon
false, true, // Can use thralls
['Magic', 'Melee'], 15, 6, 30, ['Taverly Dungeon'], createDragonDrops({
tier: 'baby',
hasUniqueDrops: false,
}), ['Stab', 'Slash', 'Crush', 'Magic', 'Ranged']);
/**
* Baby Blue Dragon
* Location: Taverley Dungeon
* Level: 49 Combat
* Wiki: https://oldschool.runescape.wiki/w/Baby_blue_dragon
*/
export const BabyBlueDragon = new Npc(1594, 'Baby blue dragon', 'A small blue dragon.', false, 49, 'https://oldschool.runescape.wiki/w/Baby_blue_dragon', 50, true, true, false, false, true, // Can use cannon
false, false, ['Magic', 'Melee'], 10, 6, 30, ['Taverly Dungeon'], createDragonDrops({
tier: 'baby',
hasUniqueDrops: false,
}), ['Stab', 'Slash', 'Crush', 'Magic', 'Ranged']);
/**
* Baby Green Dragon
* Location: Taverly Dungeon
* Level: 42 Combat
* Wiki: https://oldschool.runescape.wiki/w/Baby_green_dragon
*
* NOTE: This could use shared drops via template since all baby dragons
* have essentially identical drops
*/
export const BabyGreenDragon = new Npc(1591, 'Baby green dragon', 'A small green dragon.', false, 42, 'https://oldschool.runescape.wiki/w/Baby_green_dragon', 40, true, true, false, false, true, false, false, ['Magic', 'Melee'], 8, 6, 30, ['Taverly Dungeon'], createDragonDrops({
tier: 'baby',
hasUniqueDrops: false,
}), ['Stab', 'Slash', 'Crush', 'Magic', 'Ranged']);
// ============================================================================
// BATCH 2: Demon Implementation Example
// ============================================================================
import { createDemonDrops } from './DropImplementationUtils';
/**
* Lesser Demon
* Locations: Dungeons across RuneScape
* Level: 7 Combat
* Wiki: https://oldschool.runescape.wiki/w/Lesser_demon
*/
export const LesserDemon = new Npc(1629, 'Lesser demon', 'An evil demon.', false, 7, 'https://oldschool.runescape.wiki/w/Lesser_demon', 10, true, true, false, false, false, false, false, ['Melee', 'Magic'], 4, 5, 30, ['Dungeons'], createDemonDrops({
tier: 'lesser',
}), ['Slash', 'Crush']);
/**
* Greater Demon
* Location: Demonic Ruins, Wilderness
* Level: 82 Combat
* Wiki: https://oldschool.runescape.wiki/w/Greater_demon
*/
export const GreaterDemon = new Npc(2025, 'Greater demon', 'A powerful demon.', false, 82, 'https://oldschool.runescape.wiki/w/Greater_demon', 100, true, true, false, false, false, false, false, ['Melee', 'Magic'], 16, 5, 30, ['Demonic Ruins'], createDemonDrops({
tier: 'greater',
}), ['Slash', 'Crush', 'Magic']);
// ============================================================================
// BATCH 3: Basic Animal Implementation Example
// ============================================================================
/**
* Chicken
* Location: Various (Lumbridge, Falador, etc.)
* Level: 1 Combat
* Wiki: https://oldschool.runescape.wiki/w/Chicken
*
* Simple template - easily replicable for other animals
*/
export const ChickenDrops = [
// Guaranteed drops (rare, but possible)
new NpcDrop('Chicken', 1, '1/8', false, 'Can be caught with Hunting'),
// Flesh drops
new NpcDrop('Raw Chicken', 1, '1/4'),
// Clue scrolls
new NpcDrop('Clue Scroll (Beginner)', 1, DROP_RATES.UNCOMMON_1_128),
];
export const Chicken = new Npc(1017, 'Chicken', 'A young fowl.', false, 1, 'https://oldschool.runescape.wiki/w/Chicken', 3, false, true, false, false, false, false, false, ['Melee'], 1, 5, 15, ['Lumbridge', 'Falador', 'Ardougne'], ChickenDrops, ['Stab']);
// ============================================================================
// BATCH 4: Complex Boss Implementation Example
// ============================================================================
/**
* Cerberus
* Location: Cerberus' Lair (Taverley Dungeon)
* Level: 203 Combat
* Wiki: https://oldschool.runescape.wiki/w/Cerberus
*
* Multi-roll boss example
*/
function createCerberusDrops() {
return createBossNPCDrops({
// Primary drops - always present
primaryDrops: [
new NpcDrop('Cerberus\' Prime', [1, 2], 'Always'),
new NpcDrop('Hellhound Bones', 1, 'Always'),
new NpcDrop('Coins', [500, 1000], 'Always'),
],
// Tertiary drops - guaranteed
tertiaryDrops: [
new NpcDrop('Ashes', [1, 2], 'Always'),
new NpcDrop('Mithril Ore', [2, 4], 'Always'),
],
// Rare unique drops from a weighted table
rareDrops: [
{ item: new NpcDrop('Primordial Boots', 1, 'Always'), weight: 1 },
{ item: new NpcDrop('Pegasian Boots', 1, 'Always'), weight: 1 },
{ item: new NpcDrop('Eternal Boots', 1, 'Always'), weight: 1 },
],
uniqueRate: DROP_RATES.RARE_1_512,
});
}
export const Cerberus = new Npc(5862, 'Cerberus', 'The three-headed hellhound.', true, 203, 'https://oldschool.runescape.wiki/w/Cerberus', 600, true, true, false, true, false, false, true, ['Melee', 'Magic'], 58, 6, 0, // Boss doesn't respawn like normal monsters
['Cerberus\' Lair'], createCerberusDrops().getAllPossibleDrops(), ['Stab', 'Slash', 'Crush', 'Magic', 'Ranged'], undefined, // No products
undefined, // No dialogue
['Cerberus was added in version 1.0.0']);
// ============================================================================
// IMPLEMENTATION CHECKLIST TEMPLATE
// ============================================================================
/**
* Copy this for each new batch:
*
* BATCH [X]: [Category] NPCs ([Count] NPCs)
* ==========================================
*
* NPCs to implement:
* [ ] NPC Name 1
* [ ] NPC Name 2
* [ ] NPC Name 3
*
* Research phase:
* [ ] All wiki pages reviewed
* [ ] Drop rates verified
* [ ] Shared drops identified
*
* Implementation:
* [ ] Drop utilities/templates prepared
* [ ] Code written and reviewed
* [ ] Tests added
* [ ] Validation passes
* [ ] No syntax errors
*
* Quality assurance:
* [ ] All drop rates match wiki
* [ ] No duplicate item drops
* [ ] Proper probability distribution
* [ ] Edge cases handled
*
* Documentation:
* [ ] Wiki URLs included in code
* [ ] Comments explain non-obvious drops
* [ ] Team notified of new drops
*/
// ============================================================================
// KEY TAKEAWAYS FROM THIS EXAMPLE
// ============================================================================
/**
* 1. USE TEMPLATES FOR SIMILAR NPCs
* - All baby dragons use createDragonDrops({ tier: 'baby' })
* - Reduces duplication and maintains consistency
*
* 2. INCLUDE WIKI REFERENCES
* - Every NPC has officialWikiUrl
* - Comments reference wiki for verification
*
* 3. USE HELPER FUNCTIONS
* - createDragonDrops()
* - createDemonDrops()
* - createBossNPCDrops()
* - Makes code cleaner and more maintainable
*
* 4. LEVERAGE CONSTANTS
* - DROP_RATES.RARE_1_512 is clearer than '1/512'
* - STANDARD_DROPS.bones is reusable
*
* 5. BATCH SIMILAR NPCS TOGETHER
* - Dragons together (share templates)
* - Demons together (share templates)
* - Makes it easier to verify consistency
*
* 6. VALIDATE BEFORE COMMITTING
* - Use validateNPCDrops() to check for errors
* - Run tests to ensure no breaking changes
*
* 7. DOCUMENT NON-OBVIOUS DROPS
* - Note when drops are special/quest-only
* - Include conditions that affect drops
*/
export default {
BabyBlackDragon,
BabyBlueDragon,
BabyGreenDragon,
LesserDemon,
GreaterDemon,
Chicken,
Cerberus,
};