commit 947f6a33599d15da05c66748d19c379b519bbf3f
parent 25abc67483b7bda09148d42dc83e50ac48205d43
Author: Jake Bauer <jbauer@paritybit.ca>
Date: Fri, 27 Dec 2019 02:56:42 -0500
Add Borderlands 3 DPS calculator project [WIP]
Diffstat:
3 files changed, 212 insertions(+), 0 deletions(-)
diff --git a/build/borderlands.css b/build/borderlands.css
@@ -0,0 +1,47 @@
+input:not(#tvhm) {
+ width: 100px;
+}
+
+select {
+ width: 106px;
+}
+
+.td-label {
+ text-align: right;
+ padding-right: 10px;
+}
+
+#flesh, #shields, #armour {
+ margin: 0px;
+}
+
+#results {
+ margin-left: 120px;
+}
+
+@media all and (max-width: 900px) {
+ #results {
+ margin-left: 0px;
+ }
+
+ button {
+ width: 10em;
+ }
+
+ input:not(#tvhm){
+ width: 7em;
+ }
+
+ select {
+ width: 7.5em;
+ }
+
+ table {
+ width: 16em;
+ }
+
+ #form-table {
+ margin-left: -40px;
+ width: 20em;
+ }
+}
diff --git a/pages/projects/borderlands-3-dps-calculator.md b/pages/projects/borderlands-3-dps-calculator.md
@@ -0,0 +1,51 @@
+## Borderlands 3 DPS Calculator
+
+[//]: # "Use this utility to calculate the DPS of weapons in Borderlands 3."
+
+[//]: # "base.min.css borderlands.min.css"
+
+[//]: #
+
+<script src=/js/borderlands-3-dps-calculator.js></script>
+<noscript>Your browser must support or enable Javascript for this applet to
+function.</noscript>
+
+This project was submitted by Leon Baram, please direct comments and/or
+suggestions to [Leon's email](balding@protonmail.com).
+
+Use this utility to calculate the DPS of weapons in Borderlands 3.
+
+<div>
+ <form>
+ <table id="form-table">
+ <tr><td class="td-label">Damage: </td><td><input id="dmg" type="number" min="0" placeholder="0"/></td></tr>
+ <tr><td class="td-label">Accuracy (%): </td><td><input id="acc" type="number" max="100" min="0" placeholder="0-100"/></td></tr>
+ <tr><td class="td-label">Reload Time (s): </td><td><input id="rload" type="number" min="0" placeholder="0"/></td></tr>
+ <tr><td class="td-label">Fire Rate (shots/s): </td><td><input id="frate" type="number" min="0" placeholder="0"/></td></tr>
+ <tr><td class="td-label">Magazine Size: </td><td><input id="mag" type="number" min="0" placeholder="0"/></td></tr>
+ <tr><td class="td-label">Elemental Type: </td><td><select id="elmnt" type="text">
+ <option value="None">None</option>
+ <option value="Fire">Fire</option>
+ <option value="Shock">Shock</option>
+ <option value="Acid">Acid</option>
+ <option value="Cryo">Cryo</option>
+ <option value="Rad">Rad</option>
+ </select></td></tr>
+ <tr><td class="td-label">Effect Damage: </td><td><input id="e-dmg" type="number" min="0" placeholder="0"/></td></tr>
+ <tr><td class="td-label">Elemental Effect Chance (%): </td><td><input id="e-chance" type="number" max="100" min="0" placeholder="0-100"/></td></tr>
+ <tr><td class="td-label">True Vault Hunter Mode: </td><td id="checkbox-cell"><input id="tvhm" type="checkbox"/></td></tr>
+ </table>
+ </form>
+
+ <br />
+
+ <div id="results">
+ <button onClick=gamerMoment()> Calculate DPS </button>
+ <br />
+ <table>
+ <tr><td><b>DPS against flesh: </b></td><td><p id="flesh"> -- </p></td></tr>
+ <tr><td><b>DPS against shields: </b></td><td><p id="shields"> -- </p></td></tr>
+ <tr><td><b>DPS against armour: </b></td><td><p id="armour"> -- </p></td></tr>
+ </table>
+ </div>
+</div>
diff --git a/public/js/borderlands-3-dps-calculator.js b/public/js/borderlands-3-dps-calculator.js
@@ -0,0 +1,114 @@
+/*
+ * borderlands-3-dps-calculator.js
+ * Contains backend code for generation of game parameters
+ *
+ * Copyright (C) 2019 Leon Baram, Jake Bauer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Preconditions:
+ * dmg (base gun damage) and mag (magazine size) are positive ints > 0
+ * acc (gun accuracy) is a float within (0,1]
+ * rload (reload time in seconds) and frate (shots fired per second) are positive floats
+ * element (elemental effect type) is a string
+ * edmg (elemental effect damage) is a nonnegative int >= 0
+ * echance (elemental effect chance) is a float within [0,1]
+ * TVHM (True Vault Hunter Mode) is a boolean
+ *
+ * postconditions:
+ * multipliers is an array of three floats
+ * multipliers[0] is average DPS against flesh (red health bar)
+ * multipliers[1] is average DPS against shields (blue health bar)
+ * multipliers[2] is average DPS against armor (yellow health bar)
+ *
+ * multiplier values assigned in switch statement sourced from
+ * https://borderlands.fandom.com/wiki/Elemental_damage#Borderlands_3
+ * in particular, the following table:
+ * Flesh Shield Armor
+ Normal TVHM Normal TVHM Normal TVHM
+Kinetic 100% 100% 100% 100% 80% 80%
+Incendiary 150% 175% 70% 50% 70% 50%
+Shock 80% 65% 200% 250% 80% 65%
+Corrosive 80% 65% 70% 50% 150% 175%
+Cryo 100% 100% 70% 50% 120% 150%
+Radiation 100% 100% 100% 150% 70% 50%
+*/
+function dps(dmg, acc, rload, frate, mag, element, edmg, echance, TVHM = false) {
+ //multipliers represent health, shields, and armor, in that order
+ let dps,
+ multipliers,
+ eduration,
+ adj_dmg,
+ adj_acc,
+ adj_frate;
+
+ switch(element) {
+ case 'fire':
+ multipliers = TVHM ? [1.75, 0.5, 0.5] : [1.5, 0.7, 0.7];
+ eduration = 5.0;
+ break;
+ case 'shock':
+ multipliers = TVHM ? [0.65, 2.5, 0.65] : [0.8, 2.0, 0.8];
+ eduration = 2.0;
+ break;
+ case 'acid':
+ multipliers = TVHM ? [0.65, 0.5, 1.75] : [0.8, 0.7, 1.5];
+ eduration = 5.0;
+ break;
+ case 'cryo':
+ multipliers = TVHM ? [1.0, 0.5, 1.5] : [1.0, 0.7, 1.2];
+ eduration = 0;
+ break;
+ case 'rad':
+ multipliers = TVHM ? [1.0, 1.5, 0.5] : [1.0, 1.0, 0.7];
+ eduration = 8.0;
+ edmg *= 1.25;
+ break;
+ default: //kinetic, i.e. non-elemental
+ multipliers = [1.0, 1.0, 0.8];
+ eduration = 0;
+ break;
+ }
+ adj_dmg = dmg + (edmg * echance * eduration);
+
+ adj_acc = (acc * 0.2) + 0.8;
+
+ adj_frate = ((frate * (mag - 1)) + (1/rload)) / mag;
+
+ dps = adj_dmg * adj_acc * adj_frate;
+ for (m of multipliers) {
+ m *= dps;
+ }
+ return multipliers;
+}
+
+function gamerMoment() {
+ let dmg = document.getElementById("dmg").value,
+ acc = document.getElementById("acc").value,
+ frate = document.getElementById("rload").value,
+ rload = document.getElementById("frate").value,
+ mag = document.getElementById("mag").value,
+ elmnt = document.getElementById("elmnt").value,
+ edmg = document.getElementById("e-dmg").value,
+ echance = document.getElementById("e-chance").value,
+ tvhm = document.getElementById("tvhm").value;
+
+ let result = dps(dmg,acc,frate,rload,mag,elmnt,edmg,echance,tvhm);
+
+ document.getElementById("flesh").innerHTML = result[0];
+ document.getElementById("shields").innerHTML = result[1];
+ document.getElementById("armour").innerHTML = result[2];
+ }