<html><head>
<title>WLK Tester</title>
<script>
// -- base WLK --
var wlk_base = 20;
var global_wlk=0;
var global_penalty_done=0;
var offset=0;
function wkl(heat, multi, base) {
global_wlk += heat*multi;
var rest = global_wlk % base;
var heat_fact = (global_wlk-rest) / base;
var penalty = (rest*heat_fact) + base * (heat_fact-1)*heat_fact/2; // summ 1+2+3...
penalty -= global_penalty_done;
if (penalty>0) {
global_penalty_done += penalty;
} else {
penalty=0;
}
return heat + penalty;
}
function cooldown(base){
var step = base/10
if (global_wlk > offset+step){
global_wlk -= step;
} else {
global_wlk = offset;
}
if (global_penalty_done > step){
global_penalty_done -= step;
} else {
global_penalty_done = 0;
}
}
// -- intern --
var global_heat = 0;
var heat_dissipation = 2.5;
var wp = [
['S-Laser',2,1],
['M-Laser',4,1],
['L-Laser',7,1],
['SP-Laser',2.4,1],
['MP-Laser',5,1],
['LP-Laser',8,1],
['ER-L-Laser',8.5,1],
['PPC',10,1],
['ER-PPC',15,.8],
['SRM 2',2,2],
['SRM 4',3,2],
['SRM 6',4,2],
['S-SRM 2',2,2],
['LRM 5',2,2],
['LRM 10',4,2],
['LRM 15',5,2],
['LRM 20',6,2],
['AC 2',1,6],
['AC 5',1,6],
['AC 10',3,3],
['AC 20',6,3],
['U-AC 5',1,3],
['LB 10-X AC',2,3],
['Gauss',1,15]
];
function _printWeaponList(){
var txt="";
for (var i=0;i<wp.length;i++){
txt += _print(wp[i][0],wp[i][1],wp[i][2]);
}
document.write(txt);
}
function _print(name, heat, multi){
var retval = '<a href="javascript:apply('+heat+','+multi+',\''+name+'\')">';
retval += name+'<span>'+multi+'</span><span>'+heat+'</span></a>';
return retval;
}
var ticks=0
var _timer=0;
function timer(t){
if (_timer!=0)
clearInterval(_timer);
_timer = (t>0) ? setInterval('doTick()',t) : 0;
}
function _reset(){
ticks=-1;
global_heat=0;
global_wlk=0;
global_penalty_done=0;
_get('out').value='';
}
function _init(){
heat_dissipation = _get('dis').value;
var max = (2 * _get('cap').value)
_get('heat_max').style.bottom = max+'px';
var obj = _get('wlkBase');
wlk_base = obj[obj.selectedIndex].value;
_get('out').value = 'Max Heat: ' + _get('cap').value
+ ' - Dissipation: ' + heat_dissipation
+ ' - WLK'+wlk_base;
}
function _get(ID){
return document.getElementById(ID);
}
function doTick(){
ticks++;
cooldown(wlk_base);
updateHeat();
drawScreen();
}
function apply(heat,mult,name) {
if (ticks>0) {
_get('out').value = 'wait: '+(ticks/10)+' s'
+ "\n" + _get('out').value;
ticks = 0;
}
var heat_gen = wkl(heat*1,mult*1,wlk_base);
global_heat += heat_gen;
_get('out').value = 'apply: '+name+': '+heat+' (x'+mult+') -> +'+heat_gen+' Heat'
+ "\n" + _get('out').value ;
drawScreen();
}
function updateHeat(){
var step = heat_dissipation / 10
if (global_heat > step){
global_heat -= step;
} else {
global_heat = 0;
}
}
// -- view --
function drawScreen(){
if (_get('tick').value.length>=10)
_get('tick').value="";
_get('tick').value += '.';
// wlk scale
var scale_FG = '';
var scale_BG = '';
var obj_scale = _get('wlk_scale');
if (global_wlk>=wlk_base*3){
scale_FG = '#900';
scale_BG = '#f00';
} else if (global_wlk>=wlk_base*2){
scale_FG = '#f00';
scale_BG = '#fa0';
} else if (global_wlk>=wlk_base){
scale_FG = '#fa0';
scale_BG = '#39f';
} else {
scale_FG = '#39f';
scale_BG = '#fff';
}
var height = (global_wlk%wlk_base)*200/wlk_base;
_get('wlk_scale').style.height = height+'px';
obj_scale.style.backgroundColor = scale_FG;
obj_scale.parentElement.style.backgroundColor = scale_BG;
_get('wlk_val').innerHTML = Math.round(global_wlk*10)/10;
// heat scale
height = (global_heat<100) ? global_heat*2 : 200;
_get('heat_scale').style.height = height+'px';
_get('heat_val').innerHTML = Math.round(global_heat*10)/10;
}
</script>
<style>
*, body {margin:0; padding:0; font:normal 10px Verdana;}
body {padding:20px;}
fieldset {width:50%;padding:10px;margin:0 0 10px 0;}
input {padding:1px 3px;}
#screen{
float:left;
width:100px;
height:250px;
border:1px solid #999;
margin-right:50px;
}
.scale{
float:left;
width:30px;
height:200px;
margin:9px;
border:1px solid #333;
position:relative;
}
.scale div{
width:30px;
height:0px;
background-color:#39f;
position:absolute;
bottom:0;
}
.scale span{
width:30px;
text-align:center;
position:absolute;
bottom:-25px;
}
#heat_max {
position:absolute;
bottom:100px;
border-bottom:1px solid #900;
margin:0 -5px;
width:40px;
}
#weapons{
float:right;
width:25%;
}
#weapons a {
clear:right;
display:block;
xline-height:15px;
padding:2px 5px;
text-decoration:none;
color:#000;
}
#weapons a:hover {
background-color:#f90;
}
#weapons a span {
display:block;
float:right;
width:25px;
padding:0 10px;
text-align:right
}
</style>
</head><body><form>
<fieldset id="weapons">
<legend>| Weapons |</legend>
<script>_printWeaponList()</script>
</fieldset>
<fieldset id="screen">
<legend>| Heat Display |</legend>
<div class="scale">
<div id="heat_scale"></div>
<span id="heat_val">0</span>
<span id="heat_max">Max</span>
</div>
<div class="scale"><div id="wlk_scale"></div><span id="wlk_val">0</span></div>
</fieldset>
<fieldset>
<legend>| Config |</legend>
Dissipation: <input type="text" id="dis" size="3" value="2.5">
Max Capacity <input type="text" id="cap" size="3" value="50">
<br> WKL Base:
<select id="wlkBase">
<option value="15"> 15 - Lights
<option value="20" selected> 20 - Medium/Heavy
<option value="25"> 25 - Assault
</select>
<br><input type="button" value="set" onClick="_reset();_init();doTick()">
<br><br>
<textarea id="out" style="width:100%;height:80px;"></textarea>
</fieldset>
<fieldset>
<legend>| Actions |</legend>
Offset: <input type="text" value="0" id="of" size="2" onKeyUp="offset=1*this.value;"> (Walkin 1, Running 3, Jumping 5)
<br>Heat: <input type="text" id="in" size="3" value="10"> x <input type="text" id="mul" size="1" value="1">
<input type="button" value="apply" onClick="apply(_get('in').value, _get('mul').value, 'manual')">
- <input type="button" value="reset" onClick="_reset();doTick()">
<br>Speed:
<input type="button" value="1x" onClick="timer(100);">
<input type="button" value="1/2x" onClick="timer(200);">
<input type="button" value="1/5x" onClick="timer(500);">
<input type="button" value="1/10x" onClick="timer(1000);">
<input type="button" value=" ll " onClick="timer(-1);">
<input type="text" value="" id="tick" size="5">
</fieldset>
</form></body></html>