FANDOM


-- <pre>
local p = {}
 
local addcommas = require( 'Module:Addcommas' )._add
 
-- Skilling data
 
local data = mw.loadData('Module:Augmented skilling xp/data')
 
--
-- augmentXP contains the experience needed to reach various levels.
--
local augmentXP = {
	0, 1160, 2607, 5167, 8286,
	11760, 15835, 21152, 28761, 40120,
	57095, 81960, 117397, 166496, 232886,
	320080, 432785, 575592, 753631, 972440
}
 
-- multipliers of actual XP -> item XP
local augmentMultiplier = {
	mining = 118,
	fishing = 118,
	woodcutting = 118,
	firemaking = 65,
	smithing = 78,
	smelting = 78
}
 
 
--
-- Testing revealed that augment xp has 3 extra digits.
-- This method returns the raw XP gained for a certain skilling xp amount.
-- This raw amount is 1000x the visible amount.
--
function p.skillingXPToRawAugmentXP(skill, xp, enlightened)
    local multiplier = augmentMultiplier[skill:lower()] or 118
	return math.floor(xp * multiplier * (1 + (0.03 * enlightened)))
end
 
--
-- Calculates the actions required to get a certain augmented level based on the skilling xp
--
function p.getActions(skill, level, actionXP, enlightened)
	local requiredAugmentationXP = augmentXP[level]*1000
	return math.ceil(requiredAugmentationXP/p.skillingXPToRawAugmentXP(skill, actionXP, enlightened))
end
 
--
-- Wrapper function for skills.
--
function p.getData(skill)
	return data[skill:lower()] or {}
end
 
-- 
-- adjustSkillingXP is here so we can account for certain bonuses
--
function p.adjustSkillingXP(xp, multiplier, divider)
	local adjustedXP = math.floor((xp * 10 * multiplier)/divider)
	return adjustedXP / 10
end
 
function p.plink(name,image,article)
	return string.format('[[File:%s.png|link=%s]]&nbsp;[[%s|%s]]', image or name, article or name , article or name, name)
end
 
function p.getEffectiveSkillingXP(inXP,bonuses,xp_m,xp_d)
	local xp = 10 * inXP
 
	if bonuses.aquarium then
		xp = math.floor(xp * 1.02)
	end
 
	if bonuses.crystallise_with_prayer then
		xp = math.floor(xp * 1.875)
	elseif bonuses.crystallise then
		xp = math.floor(xp * 1.50)
	end
 
	return p.adjustSkillingXP(xp/10,xp_m,xp_d)
end
 
--
-- showSkill generates a table to display.
--
function p.showSkill(frame, level, skill, xp_multiplier, xp_divider, bonuses)
	local ret = mw.html.create('table')
				:addClass('wikitable')
				:addClass('align-left-1')
				:css('text-align', 'right')
	ret
		:tag('tr')
			:tag('th'):wikitext('Item'):done()
			:tag('th'):wikitext('Level'):done()
			:tag('th'):wikitext('Item XP each'):done()
			:tag('th'):wikitext('Actions'):done()
			:tag('th'):wikitext('Enlightened 1'):done()
			:tag('th'):wikitext('Enlightened 2'):done()
			:tag('th'):wikitext('Enlightened 3'):done()
		:done()
 
	local skill_data = p.getData(skill)
 
	for n, k in pairs(skill_data) do
		local skip = false
 
		skip = skip or (bonuses.aquarium and not k.aquarium)
		skip = skip or (bonuses.crystallise and not k.crystallise)
 
		if not skip then
			local actionXP = p.getEffectiveSkillingXP(k.xp, bonuses, xp_multiplier, xp_divider)
			ret
				:tag('tr')
					:tag('td'):wikitext(p.plink(k.name,k.image,k.article)):done()
					:tag('td'):wikitext(k.level):done()
					:tag('td'):wikitext(p.skillingXPToRawAugmentXP(skill, actionXP, 0)/1000):done()
					:tag('td'):wikitext(addcommas(p.getActions(skill, level, actionXP, 0))):done()
					:tag('td'):wikitext(addcommas(p.getActions(skill, level, actionXP, 1))):done()
					:tag('td'):wikitext(addcommas(p.getActions(skill, level, actionXP, 2))):done()
					:tag('td'):wikitext(addcommas(p.getActions(skill, level, actionXP, 3))):done()
				:done()
		end
	end
 
	return ret:done()
end
 
function p.bonuses(args)
	local bonuses = {}
	bonuses.aquarium = (args.aquarium or 'no') == 'yes'
	bonuses.crystallise_with_prayer = (args.crystallise_with_prayer or 'no') == 'yes'
	bonuses.crystallise = ((args.crystallise or 'no') == 'yes') or bonuses.crystallise_with_prayer
	return bonuses
end
 
function p.main(frame)
	local args = frame:getParent().args
	local skill = args.skill or 'Fishing'
	local level = tonumber(args.level,10) or 10
	local xp_multiplier = args.xp_mul or 1
	local xp_divider = args.xp_div or 1
 
	return p.showSkill(frame, level, skill, xp_multiplier, xp_divider, p.bonuses(args))
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.