<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AMagic_damage_calculator</id>
	<title>Module:Magic damage calculator - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.runerealm.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AMagic_damage_calculator"/>
	<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Magic_damage_calculator&amp;action=history"/>
	<updated>2026-05-03T17:14:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://wiki.runerealm.org/index.php?title=Module:Magic_damage_calculator&amp;diff=35037&amp;oldid=prev</id>
		<title>Alex: Created page with &quot;local p = {}  -- For rendering the tables local yesno = require(&#039;Module:Yesno&#039;) local skillpic = require(&#039;Module:SCP&#039;)._main local SPELL_TABLE = require(&#039;Module:Magic damage calculator/data&#039;)  local PRAYER_MODIFIER = { 	0, 	0.01, 	0.02, 	0.04, }  function p.main(frame) 	-- Parse the args 	local args = frame.args  	local selectedSpell = string.gsub(args.spell, &quot;&amp;#039;&quot;, &quot;&#039;&quot;) 	local selectedSpellData = SPELL_TABLE[selectedSpell] 	local selectedWeapon = string.gsub(args.wea...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.runerealm.org/index.php?title=Module:Magic_damage_calculator&amp;diff=35037&amp;oldid=prev"/>
		<updated>2024-10-16T23:12:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local p = {}  -- For rendering the tables local yesno = require(&amp;#039;Module:Yesno&amp;#039;) local skillpic = require(&amp;#039;Module:SCP&amp;#039;)._main local SPELL_TABLE = require(&amp;#039;Module:Magic damage calculator/data&amp;#039;)  local PRAYER_MODIFIER = { 	0, 	0.01, 	0.02, 	0.04, }  function p.main(frame) 	-- Parse the args 	local args = frame.args  	local selectedSpell = string.gsub(args.spell, &amp;quot;&amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;quot;) 	local selectedSpellData = SPELL_TABLE[selectedSpell] 	local selectedWeapon = string.gsub(args.wea...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
-- For rendering the tables&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
local skillpic = require(&amp;#039;Module:SCP&amp;#039;)._main&lt;br /&gt;
local SPELL_TABLE = require(&amp;#039;Module:Magic damage calculator/data&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local PRAYER_MODIFIER = {&lt;br /&gt;
	0,&lt;br /&gt;
	0.01,&lt;br /&gt;
	0.02,&lt;br /&gt;
	0.04,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	-- Parse the args&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
&lt;br /&gt;
	local selectedSpell = string.gsub(args.spell, &amp;quot;&amp;amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;quot;)&lt;br /&gt;
	local selectedSpellData = SPELL_TABLE[selectedSpell]&lt;br /&gt;
	local selectedWeapon = string.gsub(args.weapon or &amp;#039;&amp;#039;, &amp;quot;&amp;amp;#039;&amp;quot;, &amp;quot;&amp;#039;&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	local magicStrength = (tonumber(args.magicStrength) or 0) / 100&lt;br /&gt;
	local specialModifier = tostring(args.specialModifier)&lt;br /&gt;
	&lt;br /&gt;
	local inTombsOfAmascut = yesno(args.inTombsOfAmascut)&lt;br /&gt;
	local haveForinthrySurge = yesno(args.haveForinthrySurge)&lt;br /&gt;
	&lt;br /&gt;
	local equipTome = yesno(args.equipTome)&lt;br /&gt;
	local equipChaosGauntlets = yesno(args.equipChaosGauntlets)&lt;br /&gt;
	&lt;br /&gt;
	local castMarkOfDarkness = yesno(args.castMarkOfDarkness)&lt;br /&gt;
	local castCharge = yesno(args.castCharge)&lt;br /&gt;
	&lt;br /&gt;
	local elementalWeakness = (tonumber(args.elementalWeakness) or 0) / 100&lt;br /&gt;
	&lt;br /&gt;
	local calculatedDamage = p.calc(selectedSpell, selectedSpellData, selectedWeapon, magicStrength, specialModifier,&lt;br /&gt;
		inTombsOfAmascut, haveForinthrySurge, equipTome, equipChaosGauntlets, castMarkOfDarkness, castCharge, elementalWeakness)&lt;br /&gt;
	&lt;br /&gt;
	return renderTable(calculatedDamage)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.calc(selectedSpell, selectedSpellData, selectedWeapon, magicStrength, specialModifier,&lt;br /&gt;
	inTombsOfAmascut, haveForinthrySurge, equipTome, equipChaosGauntlets, castMarkOfDarkness, castCharge, elementalWeakness)&lt;br /&gt;
	&lt;br /&gt;
	-- Tumeken&amp;#039;s multiplier to (visible) % magic strength&lt;br /&gt;
	if selectedSpell == &amp;quot;Tumeken&amp;#039;s shadow&amp;quot; then&lt;br /&gt;
		if inTombsOfAmascut then&lt;br /&gt;
			magicStrength = magicStrength * 4&lt;br /&gt;
		else&lt;br /&gt;
			magicStrength = magicStrength * 3&lt;br /&gt;
		end&lt;br /&gt;
	&lt;br /&gt;
		magicStrength = math.min(magicStrength, 1)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Boosts that are additive w/ % magic strength (Salve, Avarice, Forinthry Surge)&lt;br /&gt;
	if specialModifier == &amp;#039;Salve amulet (i)&amp;#039; then&lt;br /&gt;
		magicStrength = magicStrength + 0.15&lt;br /&gt;
	end&lt;br /&gt;
	if specialModifier == &amp;#039;Salve amulet (ei)&amp;#039; then&lt;br /&gt;
		magicStrength = magicStrength + 0.2&lt;br /&gt;
	end&lt;br /&gt;
	if specialModifier == &amp;#039;Amulet of avarice (Revenants)&amp;#039; then&lt;br /&gt;
		if haveForinthrySurge then&lt;br /&gt;
			magicStrength = magicStrength + 0.35&lt;br /&gt;
		else&lt;br /&gt;
			magicStrength = magicStrength + 0.2&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if selectedWeapon == &amp;#039;Smoke battlestaff&amp;#039; then&lt;br /&gt;
		magicStrength = magicStrength + 0.1&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Iterate through weapon damage table&lt;br /&gt;
	for i, v in ipairs(selectedSpellData) do&lt;br /&gt;
		&lt;br /&gt;
		-- get base max hit, add pre-mult bonuses&lt;br /&gt;
		local baseMaxHit = tonumber(selectedSpellData[i][2])&lt;br /&gt;
		if equipChaosGauntlets then&lt;br /&gt;
			baseMaxHit = baseMaxHit + 3&lt;br /&gt;
		elseif castCharge then&lt;br /&gt;
			baseMaxHit = baseMaxHit + 10&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- iterate over prayers&lt;br /&gt;
		for p = 1, 4, 1 do&lt;br /&gt;
			-- apply % magic strength&lt;br /&gt;
			local maxHit = math.modf(baseMaxHit * (1 + magicStrength + PRAYER_MODIFIER[p]))&lt;br /&gt;
			&lt;br /&gt;
			-- slayer helmet&lt;br /&gt;
			if specialModifier == &amp;#039;Slayer helmet (i)&amp;#039; then&lt;br /&gt;
				maxHit = math.modf(maxHit * 1.15)&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- rev sceptre&lt;br /&gt;
			if selectedWeapon == &amp;quot;Thammaron&amp;#039;s sceptre (Wilderness)&amp;quot; or selectedWeapon == &amp;#039;Accursed sceptre (Wilderness)&amp;#039; then&lt;br /&gt;
				maxHit = math.modf(maxHit * 1.5)&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			-- elemental weakness&lt;br /&gt;
			maxHit = maxHit + math.modf(elementalWeakness * baseMaxHit)&lt;br /&gt;
			&lt;br /&gt;
			-- elemental tome&lt;br /&gt;
			if equipTome then&lt;br /&gt;
				maxHit = math.modf(maxHit * 1.1)&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			if castMarkOfDarkness then&lt;br /&gt;
				if selectedWeapon == &amp;#039;Purging staff&amp;#039; then&lt;br /&gt;
					maxHit = math.modf(maxHit * 1.5)&lt;br /&gt;
				else&lt;br /&gt;
					maxHit = math.modf(maxHit * 1.25)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			selectedSpellData[i][p+2] = maxHit&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return selectedSpellData&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function renderTable(calculatedDamage)&lt;br /&gt;
	frame = mw.getCurrentFrame()&lt;br /&gt;
	&lt;br /&gt;
	-- Create the table&lt;br /&gt;
	local hTable = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
		:addClass(&amp;#039;wikitable align-center-1&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;text-align&amp;#039;, &amp;#039;right&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;style&amp;#039;, &amp;#039;text-align:right&amp;#039;)&lt;br /&gt;
	-- Add the headers&lt;br /&gt;
	hTable&lt;br /&gt;
		:tag(&amp;#039;caption&amp;#039;):wikitext(&amp;#039;Maximum hit&amp;#039;)&lt;br /&gt;
		:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;rowspan&amp;#039;, 2):wikitext(skillpic(&amp;#039;Magic&amp;#039;,nil,false) .. &amp;#039;Level&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;rowspan&amp;#039;, 2):wikitext(&amp;#039;Before&amp;lt;br/&amp;gt;boosts&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;):attr(&amp;#039;colspan&amp;#039;, 4):wikitext(skillpic(&amp;#039;Prayer&amp;#039;,nil,true) .. &amp;#039; used&amp;#039;)&lt;br /&gt;
		:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;None&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;[[File:Mystic_Lore.png|link=Mystic Lore|x21px]]&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;[[File:Mystic_Might.png|link=Mystic Might|x21px]]&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;[[File:Augury.png|link=Augury|x21px]]&amp;#039;)&lt;br /&gt;
		:done()&lt;br /&gt;
		&lt;br /&gt;
	-- Add the rows&lt;br /&gt;
	for _, i in ipairs(calculatedDamage) do&lt;br /&gt;
		hTable:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;):wikitext(i[1])&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;):wikitext(i[2])&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;):wikitext(i[3])&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;):wikitext(i[4])&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;):wikitext(i[5])&lt;br /&gt;
			:tag(&amp;#039;td&amp;#039;):wikitext(i[6])&lt;br /&gt;
		:done()&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local div = mw.html.create(&amp;#039;div&amp;#039;)&lt;br /&gt;
	&lt;br /&gt;
	div	&lt;br /&gt;
		:node(hTable)&lt;br /&gt;
		:done()&lt;br /&gt;
		&lt;br /&gt;
	return tostring(div)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Alex</name></author>
	</entry>
</feed>