MediaWiki:PetControl.js: Difference between revisions
From Ultima Online Forever Wiki
(Created page with "function calculateControlChance() { var taming = parseFloat(document.PetControl.AnimalTaming.value); var lore = parseFloat(document.PetControl.AnimalLore.value); var req...") |
(No difference)
|
Latest revision as of 15:30, 13 February 2017
function calculateControlChance() { var taming = parseFloat(document.PetControl.AnimalTaming.value); var lore = parseFloat(document.PetControl.AnimalLore.value); var required = parseFloat(document.PetControl.RequiredSkill.value); var modifiedTaming = taming * 10.0; var modifiedLore = lore * 10.0; var chance = 700.0; var difficulty = required * 10.0; var weighted = ((modifiedTaming * 4.0) + modifiedLore) / 5.0; var bonus = weighted - difficulty; var modBonus = bonus * 6.0; var chanceBonus = chance + modBonus; var controlChance = (chanceBonus / 1000.0) * 100.0; controlChance = Math.min(controlChance, 100.0); document.PetControl.control.value = controlChance; } (function () { var myElement = document.getElementById('pet-control'); myElement.innerHTML = '<form name=\"PetControl\" action=\"\"><span style=\"clear: both;\">Animal Taming:</span> <input type=\"text\" name=\"AnimalTaming\" size=\"3\" style=\"float: right; text-align: center;\"> <br style=\"clear: both;\"/><span style=\"clear: both;\">Animal Lore: </span><input type=\"text\" name=\"AnimalLore\" size=\"3\" style=\"float: right; text-align: center;\"> <br style=\"clear: both;\"/><span style=\"clear: both;\">Required Skill: </span><input type=\"text\" name=\"RequiredSkill\" size=\"3\" style=\"float: right; text-align: center;\"> <br style=\"clear: both;\"/> <input type=\"button\" value=\"Calculate Control Chance\" onclick=\"calculateControlChance()\" style=\"font-weight: bold;\"><br style=\"clear: both;\"/><span style=\"clear: both; font-weight: bold;\">Resulting Control Chance:</span> <input type=\"text\" disabled name=\"control\" size=\"4\" style=\"float: right; text-align: right;\"> <br style=\"clear: both;\"/></form>'; }());