Module:Augmented degrade

From the RuneScape Wiki, the wiki for all things RuneScape
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:Augmented degrade/doc. [edit]
Module:Augmented degrade's function main is invoked by Template:Augmented degrade.
Module:Augmented degrade's function main_tooltip is invoked by Template:Charge drain.
Module:Augmented degrade requires Module:Charge drain.
Module:Augmented degrade requires Module:Coins.
Module:Augmented degrade requires Module:Exchange.
Module:Augmented degrade requires Module:Tooltip.
Module:Augmented degrade transcludes Template:Custom-fit trimmed masterwork degradation using frame:preprocess().
Module:Augmented degrade transcludes Template:Mainonly using frame:preprocess().
Module:Augmented degrade is required by Module:Infobox Bonuses new.
Module:Augmented degrade is required by Module:Infobox Bonuses/sandbox.
Module:Augmented degrade is required by Module:Sandbox/User:Nephr/Infobox custom.

-- <nowiki>
local p = {}

local exchange = require( 'Module:Exchange') --for coins per charge
local coins = require( 'Module:Coins') --for printing above
local tooltips = require('Module:Tooltip')
local draintable = require('Module:Charge drain').oneslot

local slots = {
	['2h'] = 1.5,
	mh = 1,
	['1h'] = 1,
	armour = 1,
	a = 1,
	body = 1,
	legs = 1,
	shield = 0.5,
	oh = 0.5,
	t = 0.25,
	tool = 0.25,
}

function p.get_base(tier, slot)
	if tier < 67 then
		tier = 67
	end
	return math.floor(((tier-60)/8 * slots[slot] * 100 + .05)) / 100
end

function p.main_tooltip(frame)
	local args = frame:getParent().args
	local s,d = p.get_tooltip(args.level, args.slot)
	return tostring(s)..tostring(d)
end

function p.get_tooltip(tier, slot)
	local name = string.format('charge_drain_%s_%s', slot, tier)
	local span = tooltips._span({ name })
	local divstr = ''
	
	local function get_slot_str()
		local slot_str = {
			['2h'] = 'a tier %s two-handed weapon',
			['mh'] = 'a tier %s main-handed weapon',
			['body'] = 'tier %s body armour',
			['legs'] = 'tier %s leg armour',
			['shield'] = 'a tier %s shield',
			['oh'] = 'a tier %s off-handed weapon',
			['tool'] = 'a tier %s skilling tool',
		}
		return string.format(slot_str[slot], tier)
	end
	
	div = tooltips._div({
		name = name,
		hasarrow = true,
		limitwidth = true,
		content = string.format('Your current drain rate for %s is given by the following table.<br />It depends on your current reduction researched, the [[equipment level|item level]], and [[Efficient]]/[[Enhanced Efficient]] perk presence.<br />%s<br />For more information, see [[Charge pack#Charge drain]].', get_slot_str(), tostring(draintable(tier,slot)))
		})
	
	return span, div
end

function p.main(frame)
	local args = frame:getParent().args
	local level = tonumber(args.level or 1)
	local slot = string.lower(args.slot or '')
	local slot_multiplier = slots[slot] or 1
	page_title = mw.title.getCurrentTitle().fullText
	local drain, hours

	if args.drain then
		drain = args.drain
	else
		if level < 70 then
			drain = 0.87
		else
			drain = (level-60)/8.0
		end

		drain = math.floor((drain * slot_multiplier * 100 + .05)) / 100
	end
	

	local ret
	local level_10_limit = "The item can be trained and [[equipment siphon|siphoned]] as normal while it has charges. Once it runs out of charges, it will retain its equipment bonuses until it reaches equipment level 10, where it will become unusable and has to be recharged or be disassembled. "
	
	if args.tmw == 'y' or args.cftmw == 'y' then --this item is a piece of augmented trimmed masterwork armour
		local num_charges = args.cftmw == 'y' and "200,000" or "100,000"
		
		ret = string.format("The %s only uses the normal [[equipment degradation]] mechanic and not the [[charge pack|invention charge drain]] system.\nIt has %s charges of combat, and will degrade to a broken, unusable state. It can be fully repaired at any time at an [[anvil]] using a new, untrimmed masterwork variant of the same item plus 32 [[divine charge]]s. If the armour is fully depleted, it can also be repaired from the inventory.", page_title, num_charges)
		
		if args.cftmw == 'y' then
			ret = ret..'\n\n'..mw.getCurrentFrame():preprocess('{{Custom-fit trimmed masterwork degradation}}')
		end
		
		ret = ret..'\n\n'..level_10_limit
		
	    ret = ret..'\n\n'.."Unlike normal augmented items, this item is made at an [[Inventor's workbench]] from the unaugmented item, an [[augmentor]], and 36 [[divine charge]]s. It can be made from a partially used component. [[Augmentation dissolver]]s cannot be used on this item."
	else
		if args.d2d then --this item degrades to dust
		    --open with standard d2d text
	        ret = string.format("The %s uses charges stored within the item (not in the universal [[charge pack]]). It degrades exactly as the non-augmented version does: it has [[equipment degradation|100,000 charges of combat]]. These charges can be replenished by combining it with a non-dyed, augmented variant of the same item. This will combine the charges of both items but any excess charge will be lost, furthermore only one version may have perks on it. When combining two items the greater item experience of the two items is retained.\n\n", page_title)
	        
			if args.d2d:lower() == 'dyed' then
				ret = ret..level_10_limit..string.format(" This will return an un-augmented, broken [[%s]]. It can then be repaired and re-augmented as normal. A dye can be used on an augmented, undyed version to produce this item.\n\n", page_title:gsub('[Aa]ugmented', ''))
				    
			elseif args.ancientspec and string.sub(args.ancientspec:lower(),1,string.len('y'))=='y' then
				ret = ret..level_10_limit.." Additionally, using the weapon's special attack will drain 100 charges, or 0.1% of maximum charge. The special attack cannot be used if there are 0 charges remaining.\n\n"
			--in the above concat we add on special attack cost text
			
		    elseif args.refac and string.sub(args.refac:lower(),1,string.len('y'))=='y' then
		        ret = ret..level_10_limit..string.format(" This will return an unrefined [[%s]]. It can then be refined and re-augmented as normal.\n\n", page_title:gsub('[Aa]ugmented [Rr]efined', ''))
		    --in the above comcat, we present heart of gielinor refined armour degradation
		    else
	            ret = ret..level_10_limit
	        end
	    ret = ret.."Unlike normal augmented items, this item is made at an [[Inventor's workbench]] from a new, fully charged item, an [[augmentor]], and 36 [[divine charge]]s. It cannot be made from a partially used component. [[Augmentation dissolver]]s cannot be used on this item."
	
	    else --this is a typical augmented item
			local span, div = p.get_tooltip(level, slot)
			local coindrain = coins._amount(exchange._price("Divine charge") / 3000 * drain)
		    ret = string.format("The %s uses charges stored in the universal [[charge pack]]. When the charge pack runs out of charges, the item loses stats and gizmo effects, and can also no longer gain any equipment experience. Function will resume when the pack is recharged with [[divine charge]]s.",page_title)
	    end
	end
	
	local sort_name = (string.gsub(page_title, 'Augmented ', '')):gsub('^%l', string.upper)
   ret = ret..mw.getCurrentFrame():preprocess('{{Mainonly|[[Category:Augmented items|'..sort_name..']]}}')

	return ret
end

return p