Module:Skill pet calc

From Old School RuneScape Wiki
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Template:No documentation/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Skill pet calc/doc. [edit]
Module:Skill pet calc requires Module:Addcommas.
Module:Skill pet calc requires Module:Skill calc/Helpers.

local p = {}

local commas = require('Module:Addcommas')._add
local helpers = require('Module:Skill calc/Helpers')

local pets = {
	['Baby chinchompa'] = {
		['Grey chinchompa'] = { base = 131395, level = 53 },
		['Red chinchompa'] = { base = 98373, level = 63 },
		['Black chinchompa'] = { base = 82758, level = 73 }
	},
	['Beaver'] = {
		['Achey'] = { base = 317647, level = 1 },
		['Regular'] = { base = 317647, level = 1 },
		['Oak'] = { base = 361146, level = 15 },
		['Willow'] = { base = 289286, level = 30 },
		['Teak'] = { base = 264336, level = 35 },
		['Juniper'] = { base = 360000, level = 42 },
		['Maple'] = { base = 221918, level = 45 },
		['Hollow'] = { base = 214367, level = 45 },
		['Mahogany'] = { base = 220623, level = 50 },
		['Arctic pine'] = { base = 145758, level = 54 },
		['Yew'] = { base = 145013, level = 60 },
		['Sulliusceps'] = { base = 343000, level = 65 },
		['Magic'] = { base = 72321, level = 75 },
		['Redwood'] = { base = 72321, level = 90 },
	},
	['Giant squirrel'] = {
		['Gnome Stronghold'] = { base = 35609, level = 1 },
		['Agility Pyramid'] = { base = 9901, level = 30 },
		['Penguin'] = { base = 9779, level = 30 },
		['Barbarian Outpost'] = { base = 44376, level = 35 },
		['Brimhaven Agility Arena'] = { base = 26404, level = 1 },
		['Ape Atoll'] = { base = 37720, level = 48 },
		['Wilderness'] = { base = 34666, level = 52 },
		['Werewolf'] = { base = 32597, level = 60 },
		['Dorgesh-Kaan'] = { base = 10561, level = 70 },
		['Prifddinas'] = { base = 25146, level = 75 },
		['Draynor Village Rooftop'] = { base = 33005, level = 10 },
		['Al Kharid Rooftop'] = { base = 26648, level = 20 },
		['Varrock Rooftop'] = { base = 24410, level = 30 },
		['Canifis Rooftop'] = { base = 36842, level = 40 },
		['Falador Rooftop'] = { base = 26806, level = 50 },
		['Seers\' Village Rooftop'] = { base = 35205, level = 60 },
		['Pollnivneach Rooftop'] = { base = 33422, level = 70 },
		['Rellekka Rooftop'] = { base = 31063, level = 80 },
		['East Ardougne Rooftop'] = { base = 34440, level = 90 },
	},
	['Heron'] = {
		['Shrimps'] = { base = 435165, level = 1 },
		['Anchovies'] = { base = 435165, level = 15 },
		['Karambwanji'] = { base = 443697, level = 5 },
		['Sardine'] = { base = 443697, level = 5 },
		['Herring'] = { base = 443697, level = 10 },
		['Big net fishing'] = { base = 382609, level = 16 },
		['Trout'] = { base = 461808, level = 20 },
		['Salmon'] = { base = 461808, level = 30 },
		['Pike'] = { base = 305792, level = 25 },
		['Rainbow fish'] = { base = 137739, level = 38 },
		['Tuna'] = { base = 128885, level = 35 },
		['Swordfish'] = { base = 128885, level = 50 },
		['Lobster'] = { base = 116129, level = 40 },
		['Aerial fishing'] = { base = 636833, level = 43 },
		['Monkfish'] = { base = 138583, level = 62 },
		['Karambwan'] = { base = 170874, level = 65 },
		['Heavy rod fishing'] = { base = 426954, level = 48 },
		['Shark'] = { base = 82243, level = 76 },
		['Infernal eel'] = { base = 160000, level = 80 },
		['Anglerfish'] = { base = 78649, level = 82 },
		['Minnow'] = { base = 977778, level = 82 },
		['Dark crab'] = { base = 149434, level = 85 },
		['Sacred eel'] = { base = 99000, level = 87 },
		['Fishing Trawler'] = { base = 5000, level = 15 },
	},
	['Rift guardian'] = {
		['Blood rune'] = { base = 804984, level = 77 },
		['Soul rune'] = { base = 782999, level = 90 },
		['Ourania Altar'] = { base = 1487213, level = 1 },
		['Everything else'] = { base = 1795758, level = 1 },
	},
	['Rock golem'] = {
		['Clay'] = { base = 741600, level = 1 },
		['Copper'] = { base = 741600, level = 1 },
		['Tin'] = { base = 741600, level = 1 },
		['Blurite'] = { base = 741600, level = 10 },
		['Limestone'] = { base = 741600, level = 10 },
		['Iron'] = { base = 741600, level = 15 },
		['Silver'] = { base = 741600, level = 20 },
		['Coal'] = { base = 290640, level = 30 },
		['Sandstone'] = { base = 741600, level = 35 },
		['Gold'] = { base = 296640, level = 40 },
		['Gem'] = { base = 211886, level = 40 },
		['Granite'] = { base = 741600, level = 45 },
		['Ash pile'] = { base = 741600, level = 22 },
		['Volcanic sulphur'] = { base = 710000, level = 42 },
		['Volcanic Mine'] = { base = 60000, level = 50 },
		['Mithril'] = { base = 148320, level = 55 },
		['Lovakite'] = { base = 245562, level = 65 },
		['Adamantite'] = { base = 59328, level = 70 },
		['Runite'] = { base = 42377, level = 85 },
		['Amethyst crystal'] = { base = 46350, level = 92 },
		['Blast mine'] = { base = 123600, level = 43 },
		['Motherlode Mine'] = { base = 247200, level = 30 },
	},
	['Rocky'] = {
		['Vegetable stall'] = { base = 206777, level = 2 },
		['Cake stall'] = { base = 124066, level = 5 },
		['Crafting stall'] = { base = 47718, level = 5 },
		['Monkey general stall'] = { base = 47718, level = 5 },
		['Silk stall'] = { base = 68926, level = 20 },
		['Wine stall'] = { base = 36490, level = 22 },
		['Fruit stall'] = { base = 124066, level = 25 },
		['Seed stall'] = { base = 36490, level = 27 },
		['Fur stall'] = { base = 36490, level = 35 },
		['Fish stall'] = { base = 36490, level = 42 },
		['Crossbow stall'] = { base = 36490, level = 49 },
		['Silver stall'] = { base = 36490, level = 50 },
		['Magic stall'] = { base = 36490, level = 65 },
		['Scimitar stall'] = { base = 36490, level = 65 },
		['Spice stall'] = { base = 36490, level = 65 },
		['Gem stall'] = { base = 36490, level = 75 },
		['Sorceress\'s Garden'] = { base = 10339, level = 1 },
		['Watchman'] = { base = 134625, level = 65 },
		['Paladin'] = { base = 127056, level = 70 },
		['Gnome'] = { base = 108718, level = 75 },
		['Hero'] = { base = 99175, level = 80 },
		['Elf'] = { base = 99175, level = 85 },
		['TzHaar-Hur'] = { base = 176743, level = 90 },
		['Remaining pickpockets'] = { base = 257211, level = 1 },
		['Pyramid Plunder (Room 1)'] = { base = 41355, level = 21 },
		['Pyramid Plunder (Room 2)'] = { base = 29540, level = 31 },
		['Pyramid Plunder (Room 3)'] = { base = 25847, level = 41 },
		['Pyramid Plunder (Room 4)'] = { base = 20678, level = 51 },
		['Pyramid Plunder (Room 5)'] = { base = 20678, level = 61 },
		['Pyramid Plunder (Room 6)'] = { base = 20678, level = 71 },
		['Pyramid Plunder (Room 7)'] = { base = 10339, level = 81 },
		['Pyramid Plunder (Room 8)'] = { base = 6893, level = 91 },
	},
	['Tangleroot'] = {
		['Potato'] = { base = 281040, level = 1 },
		['Marigolds'] = { base = 281040, level = 2 },
		['Barley'] = { base = 112416, level = 3 },
		['Hammerstone hops'] = { base = 112416, level = 4 },
		['Onion'] = { base = 281040, level = 5 },
		['Cabbage'] = { base = 281040, level = 7 },
		['Asgarnian hops'] = { base = 89933, level = 8 },
		['Guam'] = { base = 98364, level = 9 },
		['Redberries'] = { base = 44966, level = 10 },
		['Rosemary'] = { base = 281040, level = 11 },
		['Tomato'] = { base = 281040, level = 12 },
		['Jute fibre'] = { base = 89933, level = 13 },
		['Marrentill'] = { base = 98364, level = 14 },
		['Oak tree'] = { base = 22483, level = 15 },
		['Yanillian hops'] = { base = 74944, level = 16 },
		['Tarromin'] = { base = 98364, level = 19 },
		['Sweetcorn'] = { base = 224832, level = 20 },
		['Krandorian hops'] = { base = 64238, level = 21 },
		['Cadava berries'] = { base = 37472, level = 22 },
		['Giant seaweed'] = { base = 7500, level = 23 },
		['Nasturtiums'] = { base = 281040, level = 24 },
		['Woad leaf'] = { base = 281040, level = 25 },
		['Limpwurt root'] = { base = 224832, level = 26 },
		['Harralander'] = { base = 98364, level = 26 },
		['Apple tree'] = { base = 9000, level = 27 },
		['Wildblood hops'] = { base = 56208, level = 28 },
		['Goutweed'] = { base = 98364, level = 29 },
		['Willow tree'] = { base = 16059, level = 30 },
		['Strawberry'] = { base = 187360, level = 31 },
		['Ranarr'] = { base = 98364, level = 32 },
		['Banana tree'] = { base = 9000, level = 33 },
		['Tithe Farm'] = { base = 7494389, level = 34 },
		['Teak tree'] = { base = 5000, level = 35 },
		['Dwellberries'] = { base = 32119, level = 36 },
		['Grapes'] = { base = 385426, level = 36 },
		['Toadflax'] = { base = 98364, level = 38 },
		['Orange tree'] = { base = 9000, level = 39 },
		['Curry tree'] = { base = 9000, level = 42 },
		['Irit'] = { base = 98364, level = 44 },
		['Maple tree'] = { base = 14052, level = 45 },
		['Watermelon'] = { base = 160594, level = 47 },
		['Jangerberries'] = { base = 28104, level = 48 },
		['Avantoe'] = { base = 98364, level = 50 },
		['Pineapple plant'] = { base = 9000, level = 51 },
		['Mushroom'] = { base = 7500, level = 53 },
		['Cactus'] = { base = 7000, level = 55 },
		['Mahogany tree'] = { base = 5000, level = 55 },
		['Kwuarm'] = { base = 98364, level = 56 },
		['Papaya tree'] = { base = 9000, level = 57 },
		['White lily'] = { base = 281040, level = 58 },
		['White berries'] = { base = 28104, level = 59 },
		['Yew tree'] = { base = 11242, level = 60 },
		['Snape grass'] = { base = 173977, level = 61 },
		['Snapdragon'] = { base = 98364, level = 62 },
		['Cave nightshade'] = { base = 8000, level = 63 },
		['Potato cactus'] = { base = 160594, level = 64 },
		['Hespori'] = { base = 7000, level = 65 },
		['Cadantine'] = { base = 98364, level = 67 },
		['Palm tree'] = { base = 9000, level = 68 },
		['Poison ivy berries'] = { base = 28104, level = 70 },
		['Calquat tree'] = { base = 6000, level = 72 },
		['Lantadyme'] = { base = 98364, level = 73 },
		['Crystal tree'] = { base = 9000, level = 74 },
		['Magic tree'] = { base = 9368, level = 75 },
		['Dwarf weed'] = { base = 98364, level = 79 },
		['Dragonfruit tree'] = { base = 9000, level = 81 },
		['Spirit tree'] = { base = 5000, level = 83 },
		['Celastrus tree'] = { base = 9000, level = 85 },
		['Torstol'] = { base = 98364, level = 85 },
		['Redwood tree'] = { base = 5000, level = 90 },
	}
}

function p.main(frame)
	local args = frame:getParent().args
	local level = args.level
	local pet = args.pet
	local actionsPerHour = args.actionsPerHour or 1
	local petData = pets[pet]
	
	local ret = mw.html.create('table'):addClass('wikitable sortable sticky-header align-center-2 align-center-3 align-center-4 autosort=2,a')
	ret:tag('tr')
		:tag('th'):wikitext('Method')
		:tag('th'):wikitext('Level')
		:tag('th'):wikitext('Chance per action')
		:tag('th'):wikitext('Chance per hour<br />with APH')
	
	for i, v in next, petData, nil do
		ret:node(make_row(v, i, level, actionsPerHour))
	end
	
	return tostring(ret)
end

function make_row(data, method, level, actionsPerHour)
	local actionsCheck
	if method == 'Fishing Trawler' then
		if tonumber(actionsPerHour) > 12 then
			actionsCheck = 12
		else
			actionsCheck = actionsPerHour	
		end
	elseif ({ ['Oak tree'] = true, ['Willow tree'] = true, ['Maple tree'] = true, ['Yew tree'] = true, ['Magic tree'] = true, 
		['Redwood tree'] = true, ['Teak tree'] = true, ['Mahogany tree'] = true, ['Celastrus tree'] = true, ['Spirit tree'] = true, ['Dragonfruit tree'] = true })[method] then
		actionsCheck = 1
	else
		actionsCheck = actionsPerHour	
	end
	
	local doNotCalculate = ({ Minnow = true, ['Fishing Trawler'] = true })[method]
	local chancePerAction = doNotCalculate and data.base or tonumber(data.base) - (tonumber(level) * 25)
	local chancePerHour = helpers.jagexFloor(1/(1-math.pow(1-1/chancePerAction, actionsCheck)), 2)
	
	return mw.html.create('tr')
		:tag('td'):wikitext(method):done()
		:tag('td'):wikitext(data.level):done()
		:tag('td'):attr('data-sort-value', 1/chancePerAction):wikitext('1/' .. commas(chancePerAction)):done()
		:tag('td'):attr('data-sort-value', 1/chancePerHour):wikitext('1/' .. commas(chancePerHour)):done()
end

return p