MediaWiki:PetControl.js
MediaWiki interface page
More actions
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
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>';
}());