mw:Hausregeln/Mechreichweitenrechner

<script type="text/javascript"> function calculateMechRanges() { const hexMin = parseInt($("#minRange").val()); const hexShort = parseInt($("#shortRange").val()); const hexMedium = parseInt($("#mediumRange").val()); const hexLong = parseInt($("#longRange").val()); const damage = parseInt($("#weaponDamage").val()); const weaponType = parseInt($("#weaponType").val()); if (isNaN(hexMin) || isNaN(hexShort) || isNaN(hexMedium) || isNaN(hexLong) || isNaN(damage)) { return; } const hexExtreme = hexMedium * 2; let dmgExtreme = damage; switch (weaponType) { case 1: case 3: dmgExtreme = Math.max(0, damage - 1); break; case 2: dmgExtreme = Math.max(0, damage >> 1); break; case 4: dmgExtreme = Math.max(0, damage * 3 >> 2); break; } const mMin = hexMin * 30; const mShort = hexShort * 30; const mMedium = hexMedium * 30; const mLong = hexLong * 30; const mExtreme = hexExtreme * 30; let metersSrt = i => hexShort * 10 * (i + 1); let metersMed = i => mShort + (hexMedium - hexShort) * 10 * (i + 1); let metersLng = i => mMedium + (hexLong - hexMedium) * 10 * (i + 1); let metersExt = i => mLong + (hexExtreme - hexLong) * 10 * (i + 1); const mLosSteps = metersLng(1) - metersLng(0); function metersAll(i) { if (i < 0) { return 0; } if (i < 3) { return metersSrt(i); } if (i < 6) { return metersMed(i - 3); } if (i < 9) { return metersLng(i - 6); } if (i < 12) { return metersExt(i - 9); } return mExtreme + (i - 11) * mLosSteps; } function damageAll(i) { if (i <= mLong) { return weaponType == 5 ? 0 : damage; } switch (weaponType) { case 1: case 3: return i <= mExtreme ? damage - 1 : Math.max(0, damage - 1 - Math.floor((i - mExtreme) / mLosSteps)); case 2: return Math.ceil(Math.max(0, damage - damage * (i - mLong) / (mExtreme - mLong) / 2.0)); case 4: return Math.floor(Math.max(0, damage - damage * (i - mLong) / (mExtreme - mLong) / 4.0)); case 5: return -Math.ceil((i - mLong) / mLosSteps); } } $("#weaponRangesHex30 > td").slice(1, 2).text(hexMin == 0 ? "" : hexMin); $("#weaponRangesHex15 > td").slice(1, 2).text(hexMin == 0 ? "" : hexMin * 2); $("#weaponRangesM > td").slice(1, 2).text(mMin == 0 ? "" : mMin); let prev = 0; function range(i, size) { const meters = metersAll(i); let value = Math.floor(meters / size); const _prev = prev; prev = value; if (weaponType != 5 && damageAll(meters) == 0) { value = ""; } else if (value == _prev) { value = "" } else if (value != _prev + 1) { value = (_prev + 1) + "-" + value; } return value; } $("#weaponRangesHex30 > td").slice( 2 ).text(i => range(i, 30)); prev = 0; $("#weaponRangesHex15 > td").slice( 2 ).text(i => range(i, 15)); $("#weaponRangesM > td").slice( 2 ).text(i => weaponType != 5 && damageAll(metersAll(i)) == 0 ? "" : (metersAll(i) + "m")); $("#weaponRangesDmg > td").slice( 2 ).text(i => damageAll(metersAll(i)) == 0 ? "" : damageAll(metersAll(i))); if (weaponType != 5) { } } </script> <style> #weaponRanges { text-align: center; } #weaponRanges tr td { padding: 0.2em 0.1em; } </style> <form action="#"> <table> <tr> <td>Waffenname</td> <td>Schaden</td> <td>Min</td> <td>Kurz</td> <td>Mittel</td> <td>Lang</td> <td>Type</td> </tr> <tr> <td><input type="text" id="weaponName" onchange="calculateMechRanges()"/></td> <td><input type="number" size="3" min="0" value="5" id="weaponDamage" onchange="calculateMechRanges()"/></td> <td><input type="number" size="3" min="0" value="0" id="minRange" onchange="calculateMechRanges()"/></td> <td><input type="number" size="3" min="0" value="3" id="shortRange" onchange="calculateMechRanges()"/></td> <td><input type="number" size="3" min="0" value="6" id="mediumRange" onchange="calculateMechRanges()"/></td> <td><input type="number" size="3" min="0" value="9" id="longRange" onchange="calculateMechRanges()"/></td> <td><select id="weaponType" onchange="calculateMechRanges()"> <option value="1">Energiewaffe</option> <option value="2">Impulslaser</option> <option value="3">Gauss</option> <option value="4">Ballistisch</option> <option value="5">Cluster</option> </select></td> </tr> </table> </form>
Waffenreichweite
Min Nah Mittel Weit Extrem Sichtlinie
-1 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +13 +13 +13 +13 +13 +13 +13 +13 +13 +13
30m Hexfelder
15m Hexfelder
Meter
Schaden

Benutzung

Einfach oben den Namen der Waffe, den Schaden der Waffe und die Standard-BattleTech-Reichweiten eingeben. Zusätzlich noch auswählen um welche Art von Waffe es sich handelt.