MediaWiki:Calculators.js: Difference between revisions

From AoP Wiki
No edit summary
(Updated Bleed Resistance formula.)
 
(6 intermediate revisions by the same user not shown)
Line 4: Line 4:
   var ag = Number(document.getElementById("ag").value);
   var ag = Number(document.getElementById("ag").value);
   var lk = Number(document.getElementById("lk").value);
   var lk = Number(document.getElementById("lk").value);
   var bonus = Number(document.getElementById("lk").value);
   var bonus = Number(document.getElementById("bonus").value);
   var bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2);
   var bleedRes = Math.floor(((65 * (1 - Math.pow(0.825, lk))) - 15 + ag + 2*en + 2*st) / 2);
   bleedRes += bonus;
   bleedRes += bonus;
  bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2);
   var bleedDmg = Math.floor((1.0 - Math.pow(2.0,-1.0/Math.max(1.0,bleedRes/5.0)))*100);
   var bleedDmg = Math.floor((1.0 - Math.pow(2.0,-1.0/Math.max(1.0,bleedRes/5.0)))*100);
   document.getElementById("bleedRes").innerHTML = bleedRes;
   document.getElementById("bleedRes").innerHTML = bleedRes;
Line 20: Line 19:
       '<input id="ag" type="number" value="5" min ="1" max="15" style="width: 40px"> Agility<br>' +
       '<input id="ag" type="number" value="5" min ="1" max="15" style="width: 40px"> Agility<br>' +
       '<input id="lk" type="number" value="5" min ="1" max="15" style="width: 40px"> Luck<br>' +
       '<input id="lk" type="number" value="5" min ="1" max="15" style="width: 40px"> Luck<br>' +
       '<input id="bonus" type="number" value="0" min ="-100" max="100" style="width: 40px"> Further Stats Value from Table<br>' +
       '<input id="bonus" type="number" value="0" min ="-100" max="100" step="10" style="width: 40px"> Bonus (Perks, Drugs, etc.)<br>' +
       '<button type="button" onclick="bleedResistanceCalculator()">Submit</button>' +
       '<button id="button" type="button" onclick="bleedResistanceCalculator()">Calculate</button>' +
       '<p><b><a id="bleedRes"></a> Bleed Resistance</b></p>' +
       '<p><b><a id="bleedRes"></a> Bleed Resistance</b></p>' +
       '<p><b><a id="bleedDmg"></a> % of bleed into damage per second</b></p>';
       '<p><b><a id="bleedDmg"></a> % of bleed into damage per second</b></p>';
   }
   }
});
});

Latest revision as of 01:01, 3 May 2024

function bleedResistanceCalculator() {
  var st = Number(document.getElementById("st").value);
  var en = Number(document.getElementById("en").value);
  var ag = Number(document.getElementById("ag").value);
  var lk = Number(document.getElementById("lk").value);
  var bonus = Number(document.getElementById("bonus").value);
  var bleedRes = Math.floor(((65 * (1 - Math.pow(0.825, lk))) - 15 + ag + 2*en + 2*st) / 2);
  bleedRes += bonus;
  var bleedDmg = Math.floor((1.0 - Math.pow(2.0,-1.0/Math.max(1.0,bleedRes/5.0)))*100);
  document.getElementById("bleedRes").innerHTML = bleedRes;
  document.getElementById("bleedDmg").innerHTML = bleedDmg;
}

$(function () {
  if ($('#bleedResistanceCalculator').length) {
    document.getElementById('bleedResistanceCalculator').innerHTML =
      '<input id="st" type="number" value="5" min ="1" max="15" style="width: 40px"> Strength<br>' +
      '<input id="en" type="number" value="5" min ="1" max="15" style="width: 40px"> Endurance<br>' +
      '<input id="ag" type="number" value="5" min ="1" max="15" style="width: 40px"> Agility<br>' +
      '<input id="lk" type="number" value="5" min ="1" max="15" style="width: 40px"> Luck<br>' +
      '<input id="bonus" type="number" value="0" min ="-100" max="100" step="10" style="width: 40px"> Bonus (Perks, Drugs, etc.)<br>' +
      '<button id="button" type="button" onclick="bleedResistanceCalculator()">Calculate</button>' +
      '<p><b><a id="bleedRes"></a> Bleed Resistance</b></p>' +
      '<p><b><a id="bleedDmg"></a> % of bleed into damage per second</b></p>';
  }
});