'commandturret', 'commandturretmkiii' => 'commandturret', 'commandturretmkiv' => 'commandturret', 'commandturretii' => 'commandturret', 'commandturretiii' => 'commandturret', 'commandturretiv' => 'commandturret', 'vtolclusterbombsbay' => 'vtolclusterbombbay', 'cannon' => 'lightcannon', 'minirocket' => 'minirocketpod', 'mrlemplacement' => 'minirocketbattery', 'archangelmissileemplacement' => 'archangelmissilebattery', 'angelmissileemplacement' => 'angelmissilebattery', 'seraphmissilearray' => 'angelmissile', 'seraphmissilebattery' => 'angelmissilebattery', 'transport' => 'cyborgtransport', 'transportbody' => 'cyborgtransport', 'hypervelocitycannonemplacement' => 'hpvcannonemplacement', 'hypervelocitycannonhardpoint' => 'hpvcannonhardpoint', 'cyborgchaingun1ground' => 'heavygunner', 'cyborgpropulsion' => 'heavygunner', 'empmortar' => 'empmortarpit', 'massdriver' => 'massdriverfortress', 'plasmacannonemplacement' => 'heavylaseremplacement', 'empcannontower' => 'empmissilehardpoint', 'hardcretecornerwall' => 'hardcretewall', 'engineering' => 'truck', ); $imgroot = ''; if (is_dir('../icon/')) $imgroot = '../'; function geticon($id, $type=false) { global $icons, $imgroot, $wz_research; if ((!$type || $type == 'w') && file_exists($imgroot.'icon/w/'.$id.'.gif')) return $imgroot.'icon/w/'.$id.'.gif'; if ((!$type || $type == 'c') && file_exists($imgroot.'icon/c/'.$id.'.gif')) return $imgroot.'icon/c/'.$id.'.gif'; if ((!$type || $type == 'bp') && file_exists($imgroot.'icon/bp/'.$id.'.gif')) return $imgroot.'icon/bp/'.$id.'.gif'; if ((!$type || $type == 'd') && file_exists($imgroot.'icon/d/'.$id.'.gif')) return $imgroot.'icon/d/'.$id.'.gif'; if ((!$type || $type == 'b') && file_exists($imgroot.'icon/b/'.$id.'.gif')) return $imgroot.'icon/b/'.$id.'.gif'; if ($type) { if ($icon = geticon($id)) return $icon; if ($type == 'r' && $wz_research[$id]['results'][0][1]) return geticon($wz_research[$id]['results'][0][1]); } if (isset($icons[$id])) return geticon($icons[$id]); if (substr($id,0,4) == 'vtol') return geticon(substr($id,4)); if (substr($id,-1) == '2') return geticon(substr($id,0,-1)); return false; } function iconimg($id, $type=false, $prefix='../') { if ($icon = geticon($id, $type)) return ' '; return ''; } $isadmin = false; $isauth = false; if (substr($_COOKIE['name'],-strlen($adminpass)-1)===':'.$adminpass) { $isadmin = $isauth = true; $_COOKIE['name'] = substr($_COOKIE['name'],0,-strlen($adminpass)-1); } else if ($_REQUEST['captcha'] === $adminpass) $isadmin = $isauth = true; else if (substr($_COOKIE['name'],-3) == ':mg') { $isauth = true; $_COOKIE['name'] = substr($_COOKIE['name'],0,-3); } else if ($_COOKIE['name']) $_POST['forget'] = true; @include_once 'cache/research.inc.php'; @include_once 'cache/weapons.inc.php'; @include_once 'cache/weapontable.inc.php'; @include_once 'cache/wsubclasses.inc.php'; @include_once 'cache/functions.inc.php'; @include_once 'cache/structures.inc.php'; @include_once 'cache/bodies.inc.php'; @include_once 'cache/propulsions.inc.php'; @include_once 'cache/templates.inc.php'; @include_once 'persist.lib.php'; @include_once 'guide.inc.php'; $idr = array_keys($_GET); $id = ''; if (!$_GET[$idr[0]]) { $id = $idr[0]; } else if ($_GET['w'] && $_GET['b'] && $_GET['p']) { $id = true; } if (!$id && $run) { header("HTTP/1.0 404 Not Found"); include('404.php'); die(); } else if ($id && $id !== true && ( substr($_SERVER['REQUEST_URI'],0,3)=='/b/' && !$wz_structures[$id] || substr($_SERVER['REQUEST_URI'],0,3)=='/d/' && !$wz_structures[$id] || substr($_SERVER['REQUEST_URI'],0,3)=='/w/' && !$wz_weapons[$id] || substr($_SERVER['REQUEST_URI'],0,3)=='/c/' && !$wz_cyborgs[$id] && !$wz_templates[$id] || substr($_SERVER['REQUEST_URI'],0,4)=='/bp/' && !$wz_bodies[$id] && !$wz_propulsions[$id] || substr($_SERVER['REQUEST_URI'],0,3)=='/r/' && !$wz_research[$id] )) { header("HTTP/1.0 404 Not Found"); include('404.php'); die(); } $ar = array(); $dt = array('weaponacc' => 'accuracy', 'weapondam' => 'damage', 'weaponsdam' => 'splash damage', 'weaponfdam' => 'burn damage', 'weaponrof' => 'rate of fire'); $upgrades = array('powerupgrade' => 'power production', 'researchupgrade' => 'research speed', 'repairupgrade' => 'repair facility speed', 'rearmupgrade' => 'VTOL rearming pad speed', 'vehicleconstupgrade' => 'construction speed', 'factoryupgrade' => 'factory production speed', 'cyborgfactoryupgrade' => 'cyborg factory production speed', 'vtolfactoryupgrade' => 'VTOL factory production speed', 'vehiclesensorupgrade' => 'vehicle sensor range', 'vehicleecmupgrade' => 'vehicle ECM range', 'vehicleengine' => 'vehicle engine output', 'vehiclearmor' => 'vehicle kinetic armor', 'vehiclehp' => 'vehicle HP', 'vehiclethermal' => 'vehicle thermal armor', 'cyborgengine' => 'cyborg engine output', 'cyborghp' => 'cyborg HP', 'cyborgarmor' => 'cyborg kinetic armor', 'cyborgthermal' => 'cyborg thermal armor', 'wallarmor' => 'hardcrete kinetic/thermal armor', 'wallhp' => 'hardcrete HP', 'structurearmor' => 'base structure kinetic/thermal armor', 'structurehp' => 'base structure HP', 'structureresist' => 'base structure Nexus link resistance'); $directions = array('direct' => '', 'indirect' => 'indirect ', 'indirecthoming' => 'indirect-homing ', 'homingdirect' => 'homing ', 'erraticdirect' => 'erratic '); $classes = array('kinetic' => 'kinetic', 'heat' => 'thermal'); $types = array('antiaircraft' => 'anti-air', 'antipersonnel' => 'anti-personnel', 'antitank' => 'anti-tank', 'artilleryround' => 'artillery', 'bunkerbuster' => 'anti-structure', 'flamer' => 'fire', 'allrounder' => 'all-rounder'); $subclasses = array('machinegun' => 'machinegun', 'cannon' => 'cannon', 'flame' => 'flamer', 'mortars' => 'mortar', 'howitzers' => 'howitzer', 'rocket' => 'mini-rocket', 'missile' => 'missile', 'slowrocket' => 'rocket', 'gauss' => 'rail gun', 'energy' => 'laser', 'electronic' => 'electronic weapon', 'command' => 'commander', 'emp' => 'EMP cannon', 'aagun' => 'AA-gun', 'bomb' => 'bomb', 'lassat' => 'laser satellite'); $props = array('legged' => 'Cyborg', 'wheeled' => 'Wheels', 'halftracked' => 'Half-Tracks', 'tracked' => 'Tracks', 'lift' => 'VTOL', 'hover' => 'Hover', 'soft' => 'Soft structures', 'medium' => 'Medium structures', 'hard' => 'Hard structures', 'bunker' => 'Bunkers'); $sensors = array('standard' => 'Sensor', 'indirectcb' => 'Counter-Battery', 'vtolintercept' => 'VTOL Sensor', 'vtolcb' => 'VTOL Counter-Battery', 'super' => 'Sensor, VTOL, CB, VTOL CB', 'radardetector' => 'Sensor Detector', 'uplink' => 'Reveal entire map'); $strengths = array('soft' => 'Soft', 'medium' => 'Medium', 'hard' => 'Hard', 'bunker' => 'Bunker'); $rebalance = false; if ($wz_weapons['heavycannon']['type'] == 'antiaircraft') { $rebalance = true; $types['antiaircraft'] = 'all-rounder'; } function simplify($name,$array=array()) { $name = strtr($name, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"); $in = ($name[0]=='*'); $name = preg_replace('/[^a-z0-9]+/','',$name); $i = 1; if ($name) $id = 'internal-'.$name; //if (strpos($wzid,'R-') === 0) $name = 'r-'.$name; //else if (strpos($wzid,'Cyborg-Wpn-') !== false || strpos($wzid,'Cyb-') || //strpos($wzid,'Cyborg') !== false) $name = 'c-'.$name; $id = $name; while (in_array($id,$array)) $id = $name.(++$i); return $id; } function tourl($id) { if (!$id) return ''; return $id; } /* * GENERATOR FUNCTIONS */ function upg($val, $upg=0) { return round($val*(100+$upg)/100,1); } function iupg($val, $upg=0) { return intval($val*(100+$upg)/100); } function mktemplate($weapon,$body,$prop) { global $wz_weapons, $wz_bodies, $wz_propulsions; if (is_string($weapon)) $weapon = $wz_weapons[$weapon]; if (is_string($body)) $body = $wz_bodies[$body]; if (is_string($prop)) $prop = $wz_propulsions[$prop]; return array( 'tid' => '', 'name' => $weapon['name'].' '.$body['name'].' '.$prop['name'], 'turrets' => array( $weapon['wid'] ), 'body' => $body['bid'], 'propulsion' => $prop['pid'], 'brain' => '', 'construct' => '', 'ecm' => '', 'repair' => NULL, 'sensor' => NULL, 'prereq' => '', 'hp' => iupg($body['hp'],$prop['hp']), 'armor' => $body['armor'], 'thermal' => $body['thermal'], 'engine' => $body['engine'], 'maxspeed' => $prop['maxspeed'], 'weight' => $weapon['weight']+iupg($body['weight'],$prop['weight']), 'bp' => $weapon['bp']+iupg($body['bp'],$prop['bp']), 'price' => $weapon['price']+$body['price']+$prop['price'], 'aionly' => FALSE ); } function weapontype($weapon, $upg=0) { global $directions, $classes, $types, $subclasses; $res = ''; if ($weapon['splash']) $res = 'Splash: '.iupg($weapon['splashdamage'],$upg).($weapon['splashacc']==100?'':' - '.$weapon['splashacc'].'%').' - radius '.round($weapon['splash']/128,1).' | '; if ($weapon['burn']) $res .= 'Burn: '.iupg($weapon['burndamage'],$upg).' - '.($weapon['burntime']/10).' sec - radius '.round($weapon['burn']/128,1).' | '; return $res.$directions[$weapon['direction']].$classes[$weapon['class']].' '.$types[$weapon['type']].' '.$subclasses[$weapon['subclass']]; } function weapondam($weapon, $upg=0) { if ($weapon['subclass']=='emp' && $weapon['damage']==0) { return "EMP".($weapon['splash']?'s':'').($weapon['burn']?'f':'').""; } return "".iupg($weapon['damage'],$upg)."".($weapon['splash']?'s':'').($weapon['burn']?'f':'').($weapon['subclass']=='emp'?'+EMPs':'').""; } function weaponrof($weapon, $upg=0) { if ($weapon['numattackruns']) return "".$weapon['nrounds']."×".$weapon['numattackruns'].""; return "".round($weapon['rof']*100/(100-$upg),1).""; } function templatehp($template, $upg=0) { global $wz_bodies, $wz_propulsions; return ''.iupg($template['hp'],$upg).""; } function structurehp($structure, $upg=0) { global $wz_weapons; if (!$structure['turrets']) return ''.$structure['hp']; return ''.iupg($structure['hp'],$upg).""; } function bodyarmor($body, $upg1=0, $upg2=0) { //if ($body['body']) $body = $GLOBALS['wz_bodies'][$body['body']]; return ''.iupg($body['armor'],$upg1).'/'.iupg($body['thermal'],$upg2).''; } function structurearmor($struct, $upg=0) { //if ($body['body']) $body = $GLOBALS['wz_bodies'][$body['body']]; return ''.iupg($struct['armor'],$upg).'/'.iupg($struct['armor'],$upg).''; } function templatespeed($template, $upg=0) { global $wz_propulsions, $wz_proptypes, $wz_bodies; $prop = $wz_propulsions[$template['propulsion']]; if (!$template['weight']) return 0; return intval(min( $prop['maxspeed'], $wz_proptypes[$prop['prop']]['speed']*iupg($wz_bodies[$template['body']]['engine'],$upg)/$template['weight'] )); } function weaponupgrades($weapon, $root='') { global $wz_wsubclasses, $wz_research, $wz_functions; if (is_string($weapon)) $weapon = $GLOBALS['wz_weapons'][$weapon]; $tout = ''; if ($weapon['turret'] == 'weapon' && $wz_wsubclasses[$weapon['subclass']]['upgrades']) { foreach ($wz_wsubclasses[$weapon['subclass']]['upgrades'] as $upgrade) { if ($wz_functions[$wz_research[$upgrade]['result'][0][1]]['funcs'][0]['type'] == 'weapondam') $tout .= '
  • '.($wz_functions[$wz_research[$upgrade]['result'][0][1]]['funcs'][0]['amt']+100).'% - '.$wz_research[$upgrade]['name']."
  • \n"; } if ($tout) $out .= "

    Damage upgrades

    \n\n"; else $out .= "

    Damage upgrades

    \n

    No damage upgrades available.

    \n"; $tout = ''; foreach ($wz_wsubclasses[$weapon['subclass']]['upgrades'] as $upgrade) if ($wz_functions[$wz_research[$upgrade]['result'][0][1]]['funcs'][0]['type'] == 'weaponrof') $tout .= '
  • '.round(10000/(100-$wz_functions[$wz_research[$upgrade]['result'][0][1]]['funcs'][0]['amt']),0).'% - '.$wz_research[$upgrade]['name']."
  • \n"; if ($tout) $out .= "

    ROF upgrades

    \n\n"; else $out .= "

    ROF upgrades

    \n

    No ROF upgrades available.

    \n"; $tout = ''; foreach ($wz_wsubclasses[$weapon['subclass']]['upgrades'] as $upgrade) if ($wz_functions[$wz_research[$upgrade]['result'][0][1]]['funcs'][0]['type'] == 'weaponacc') $tout .= '
  • '.($wz_functions[$wz_research[$upgrade]['result'][0][1]]['funcs'][0]['amt']+100).'% - '.$wz_research[$upgrade]['name']."
  • \n"; if ($tout) $out .= "

    Accuracy upgrades

    \n\n"; else $out .= "

    Accuracy upgrades

    \n

    No accuracy upgrades available.

    \n"; } else if ($weapon['turret'] == 'construct') { $out .= "\n"; } else if ($weapon['turret'] == 'sensor') { $out .= "\n"; } else $out .= "

    No upgrades available.

    \n"; return $out; } function bodyupgrades($cyborg=true, $root='') { global $wz_upgrades, $wz_research, $wz_functions; $out = '

    HP / kinetic-armor upgrades

    '; $out .= "\n"; $out .= '

    Thermal-armor upgrades

    '; $out .= "\n"; $out .= '

    Engine upgrades

    '; $out .= "\n"; return $out; } function structureupgrades($structid, $root='', $base=false) { global $wz_upgrades, $wz_research, $wz_functions; if (!is_string($structid)) $structid = $structid['sid']; $out = ''; if ($structid == 'researchfacility' || $structid == 'researchmodule') { $out .= "\n"; } if ($structid == 'factory' || $structid == 'vtolfactory' || $structid == 'cyborgfactory' || $structid == 'factorymodule') { $out .= "\n"; } if ($structid == 'powergenerator' || $structid == 'powermodule' || $structid == 'oilderrick') { $out .= "\n"; } if ($structid == 'vtolrearmingpad') { $out .= "\n"; } if ($structid == 'repairfacility') { $out .= "\n"; } $out .= '

    HP / armor upgrades

    '; $out .= "\n"; return $out; } function weapondesc($weapon, $root='') { global $wz_wsubclasses, $wz_research, $wz_wids, $sensors; if (is_string($weapon)) $weapon = $GLOBALS['wz_weapons'][$weapon]; $out = '

    '.iconimg($weapon['tid']?$weapon['tid']:$weapon['wid'],'w').' $'.$weapon['price'].' Turret ID: '.aval(array_keys($wz_wids,$weapon['wid']),0).'

    '; if ($weapon['turret'] == 'weapon') $out .= '

    ['.weapontype($weapon)."]

    \n"; $out .= '
    '; $out .= ''; if ($weapon['turret'] == 'weapon') { $out .= ''; $out .= ''; if ($weapon['subclass'] != 'emp') $out .= ''; $out .= ''; $out .= '"; if ($weapon['numattackruns']) $out .= ''; if ($weapon['subclass'] != 'emp' && $weapon['numattackruns']) $out .= ''; } else if ($weapon['turret'] == 'sensor') { $out .= ''; $out .= ''; } else { $out .= ''; } $out .= ''; $out .= '"; $out .= '"; $out .= "
     BaseUpgraded
    Damage:'.weapondam($weapon).''.weapondam($weapon,$wz_wsubclasses[$weapon['subclass']]['maxdam']).'
    ROF:'.weaponrof($weapon).''.weaponrof($weapon,$wz_wsubclasses[$weapon['subclass']]['maxrof']).'
    DPS:'.$weapon['dps'].''.round($weapon['dps']*100/(100-$wz_wsubclasses[$weapon['subclass']]['maxrof'])*($wz_wsubclasses[$weapon['subclass']]['maxdam']+100)/100*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'
    Accuracy:
    (close-long)
    '.$weapon['sacc'].'-'.$weapon['lacc'].'%'.round($weapon['sacc']*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'-'.round($weapon['lacc']*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'%
    Range:
    (close-long)
    '."".round($weapon['srange']/128,1)."- ".round($weapon['lrange']/128,1)."
    Attack runs:'.$weapon['numattackruns'].'
    DPR:'.($weapon['damage']*$weapon['lacc']/100*$weapon['nrounds']*$weapon['numattackruns']).''.round($weapon['damage']*$weapon['lacc']/100*$weapon['nrounds']*$weapon['numattackruns']*($wz_wsubclasses[$weapon['subclass']]['maxdam']+100)/100*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'
    Sensor:'.$sensors[$weapon['sensor']].'
    Range:'.round($weapon['lrange']/128,1).''.round($weapon['lrange']*($wz_wsubclasses['sensor']['maxrange']+100)/100/128,1).'
    Build points:'.$weapon['build'].''.round($weapon['build']*($wz_wsubclasses[$weapon['subclass']]['maxbuild']+100)/100,1).'
     BaseUpgraded
    HP:'.$weapon['hp']."
    Weight:'.$weapon['weight']."
    \n"; if ($weapon['prereq']) $out .= "

    Prerequisites: {$wz_research[$weapon['prereq']]['name']}

    "; return $out; } function templatedesc($template, $root='', $cyborg=true) { global $wz_wsubclasses, $wz_research, $wz_wids, $wz_tids, $sensors, $wz_upgrades, $wz_templates, $wz_bodies; if (is_string($template)) $template = $GLOBALS['wz_templates'][$template]; $weapon = $GLOBALS['wz_weapons'][$template['turrets'][0]]; if (iconimg($template['tid'],'c')) { $icon = iconimg($template['tid'],'c'); } else { $icon = iconimg($template['turrets'][0],'w').iconimg($template['body'],'bp').iconimg($template['propulsion'],'bp'); } $out = '

    '.$icon.' $'.$template['price'].' Template ID: '.aval(array_keys($wz_tids,$template['tid']),0).'

    '; if ($weapon['turret'] == 'weapon') $out .= '

    ['.weapontype($weapon)."]

    \n"; $out .= '
    '; $out .= ''; if ($weapon['turret'] == 'weapon') { $out .= ''; $out .= ''; if ($weapon['subclass'] != 'emp') $out .= ''; $out .= ''; $out .= '"; if ($weapon['numattackruns']) $out .= ''; if ($weapon['subclass'] != 'emp' && $weapon['numattackruns']) $out .= ''; } else if ($weapon['turret'] == 'sensor') { $out .= ''; $out .= ''; } else { $out .= ''; } $out .= ''; $out .= '"; $out .= '"; $out .= '"; $out .= '"; $out .= "
     BaseUpgraded
    Damage:'.weapondam($weapon).''.weapondam($weapon,$wz_wsubclasses[$weapon['subclass']]['maxdam']).'
    ROF:'.weaponrof($weapon).''.weaponrof($weapon,$wz_wsubclasses[$weapon['subclass']]['maxrof']).'
    DPS:'.$weapon['dps'].''.round($weapon['dps']*100/(100-$wz_wsubclasses[$weapon['subclass']]['maxrof'])*($wz_wsubclasses[$weapon['subclass']]['maxdam']+100)/100*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'
    Accuracy:
    (close-long)
    '.$weapon['sacc'].'-'.$weapon['lacc'].'%'.round($weapon['sacc']*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'-'.round($weapon['lacc']*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'%
    Range:
    (close-long)
    '."".round($weapon['srange']/128,1)."- ".round($weapon['lrange']/128,1)."
    Attack runs:'.$weapon['numattackruns'].'
    DPR:'.($weapon['damage']*$weapon['lacc']/100*$weapon['nrounds']*$weapon['numattackruns']).''.round($weapon['damage']*$weapon['lacc']/100*$weapon['nrounds']*$weapon['numattackruns']*($wz_wsubclasses[$weapon['subclass']]['maxdam']+100)/100*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'
    Sensor:'.$sensors[$weapon['sensor']].'
    Range:'.round($weapon['lrange']/128,1).''.round($weapon['lrange']*($wz_wsubclasses['sensor']['maxrange']+100)/100/128,1).'
    Build points:'.$weapon['build'].''.round($weapon['build']*($wz_wsubclasses[$weapon['subclass']]['maxbuild']+100)/100,1).'
     BaseUpgraded
    HP:'.templatehp($template).''.templatehp($template,$cyborg?$wz_upgrades['cyborghp']['max']:$wz_upgrades['vehiclehp']['max'])."
    Armor:'.bodyarmor($wz_bodies[$template['body']]).''.bodyarmor($wz_bodies[$template['body']],$cyborg?$wz_upgrades['cyborgarmor']['max']:$wz_upgrades['vehiclearmor']['max'],$cyborg?$wz_upgrades['cyborgthermal']['max']:$wz_upgrades['vehiclethermal']['max'])."
    Speed:'.templatespeed($template).''.templatespeed($template,$wz_upgrades['vehicleengine']['max'])."
    Weight:'.$template['weight']."
    \n"; if ($template['prereq']) $out .= "

    Prerequisites: {$wz_research[$template['prereq']]['name']}

    "; return $out; } function structuredesc($struct, $root='', $base=false) { global $wz_wsubclasses, $wz_research, $wz_wids, $wz_sids, $sensors, $wz_upgrades; if (is_string($struct)) $struct = $GLOBALS['wz_structures'][$struct]; $weapon = array(); if ($struct['turrets']) { $weapon = $GLOBALS['wz_weapons'][$struct['turrets'][0]]; } $out = '

    '.iconimg($struct['sid'],'c').' $'.$struct['price'].' Structure ID: '.aval(array_keys($wz_sids,$struct['sid']),0).'

    '; if ($weapon && $weapon['turret'] == 'weapon') $out .= '

    ['.weapontype($weapon)."]

    \n"; $out .= '
    '; $out .= ''; if ($weapon['turret'] == 'weapon') { $out .= ''; $out .= ''; if ($weapon['subclass'] != 'emp') $out .= ''; $out .= ''; $out .= '"; if ($weapon['numattackruns']) $out .= ''; if ($weapon['subclass'] != 'emp' && $weapon['numattackruns']) $out .= ''; $out .= ''; } else if ($weapon['turret'] == 'sensor') { $out .= ''; $out .= ''; $out .= ''; } else if ($weapon) { $out .= ''; $out .= ''; } $out .= '"; $out .= '"; $out .= '"; $out .= '"; $out .= '"; $out .= "
     BaseUpgraded
    Damage:'.weapondam($weapon).''.weapondam($weapon,$wz_wsubclasses[$weapon['subclass']]['maxdam']).'
    ROF:'.weaponrof($weapon).''.weaponrof($weapon,$wz_wsubclasses[$weapon['subclass']]['maxrof']).'
    DPS:'.$weapon['dps'].''.round($weapon['dps']*100/(100-$wz_wsubclasses[$weapon['subclass']]['maxrof'])*($wz_wsubclasses[$weapon['subclass']]['maxdam']+100)/100*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'
    Accuracy:
    (close-long)
    '.$weapon['sacc'].'-'.$weapon['lacc'].'%'.round($weapon['sacc']*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'-'.round($weapon['lacc']*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'%
    Range:
    (close-long)
    '."".round($weapon['srange']/128,1)."- ".round($weapon['lrange']/128,1)."
    Attack runs:'.$weapon['numattackruns'].'
    DPR:'.($weapon['damage']*$weapon['lacc']/100*$weapon['nrounds']*$weapon['numattackruns']).''.round($weapon['damage']*$weapon['lacc']/100*$weapon['nrounds']*$weapon['numattackruns']*($wz_wsubclasses[$weapon['subclass']]['maxdam']+100)/100*($wz_wsubclasses[$weapon['subclass']]['maxacc']+100)/100,1).'
     BaseUpgraded
    Sensor:'.$sensors[$weapon['sensor']].'
    Range:'.round($weapon['lrange']/128,1).''.round($weapon['lrange']*($wz_wsubclasses['sensor']['maxrange']+100)/100/128,1).'
     BaseUpgraded
    Build points:'.$weapon['build'].''.round($weapon['build']*($wz_wsubclasses[$weapon['subclass']]['maxbuild']+100)/100,1).'
     BaseUpgraded
    HP:'.structurehp($struct).''.structurehp($struct,$base?$wz_upgrades['structurehp']['max']:$wz_upgrades['wallhp']['max'])."
    Armor:'.structurearmor($struct).''.structurearmor($struct,$base?$wz_upgrades['structurearmor']['max']:$wz_upgrades['wallarmor']['max'])."
    Strength:'.($GLOBALS['strengths'][$struct['strength']])."
    Size:'.$struct['w'].'×'.$struct['h']."
    Height:'.$struct['z']."
    \n"; if ($struct['prereq']) $out .= "

    Prerequisites: {$wz_research[$struct['prereq']]['name']}

    "; if ($base) $out .= guide('b/'.$struct['sid']); return $out; } function bodydesc($body, $root='', $cyborg=false) { global $wz_research, $wz_upgrades, $wz_bids; if (is_string($body)) $body = $GLOBALS['wz_bodies'][$body]; $out = '

    '.iconimg($body['bid'],'bp').' $'.$body['price'].' Body ID: '.aval(array_keys($wz_bids,$body['bid']),0).'

    '; $out .= '
    '; $out .= ''; $out .= '"; $out .= '"; $out .= '"; $out .= '"; $out .= "
     BaseUpgraded
    HP:'.$body['hp'].''.iupg($body['hp'],$cyborg?$wz_upgrades['cyborghp']['max']:$wz_upgrades['vehiclehp']['max'])."
    Armor:'.bodyarmor($body).''.bodyarmor($body,$cyborg?$wz_upgrades['cyborgarmor']['max']:$wz_upgrades['vehiclearmor']['max'],$cyborg?$wz_upgrades['cyborgthermal']['max']:$wz_upgrades['vehiclethermal']['max'])."
    Engine:'.$body['engine'].''.iupg($body['engine'],$wz_upgrades['vehicleengine']['max'])."
    Weight:'.$body['weight']."
    \n"; if ($body['prereq']) $out .= "

    Prerequisites: {$wz_research[$body['prereq']]['name']}

    "; return $out; } function showprereqs($id, &$ar, $root='', $last=false) { global $wz_research, $wz_structures; if (in_array($id,$ar)) return "
    {$wz_research[$id]['name']} (See above)
    \n"; if (substr($id,0,5)=='../s/') return "
    ".$wz_structures[substr($id,5)]['name']." built
    \n"; $ar[] = $id; $out = ''; $out .= ($id==$GLOBALS['id']?('
    '.$wz_research[$id]['name']):((($wz_research[$id]['prereqs'])&&(substr($wz_research[$wz_research[$id]['prereqs'][0]]['name'],0,4) !== 'CAM1' && $wz_research[$id]['prereqs'][0] != $id)?"":($id!=$GLOBALS['id']?'':'')).'
    '.$wz_research[$id]['name'].'')); if ($wz_research[$id]['prereqs']) { if (substr($wz_research[$wz_research[$id]['prereqs'][0]]['name'],0,4) === 'CAM1') $out .= ' [base]
    '; else if ($wz_research[$id]['prereqs'][0] == $id) $out .= ' [automatic]
    '; else { $out .= "\n
      \n"; $n = count($wz_research[$id]['prereqs']); //if ($wz_research[$id]['prereqs'][$n-1] == 'synapticlink') $n--; foreach ($wz_research[$id]['prereqs'] as $i => $prereq) $out .= showprereqs($prereq, $ar, $root, $i==($n-1)); $out .= "
    \n"; } } else $out .= ''; return $out."\n"; } function gentechtree($id, &$ar, $root='', $last=false, $depth=0, $parent='') { global $wz_research, $wz_structures, $deepest, $deepests; if ($depth>$deepest) { $deepest = $depth; $deepests = array($id); } else if ($depth == $deepest) $deepests[] = $id; if (in_array($id,$ar)) return "\n"; $ar[] = $id; $out = ''; $out .= (in_array($id,array('machinegun','sensorturret','engineering'))?('
    '.$wz_research[$id]['name'].''):((($wz_research[$id]['allows'])&&(substr($wz_research[$wz_research[$id]['allows'][0]]['name'],0,4) !== 'CAM1' && $wz_research[$id]['allows'][0] != $id)?"":($id!=$GLOBALS['id']?'':'')).'
    '.$wz_research[$id]['name'].'')); if ($wz_research[$id]['allows']) { $out .= "
    \n
      \n"; $n = count($wz_research[$id]['allows']); foreach ($wz_research[$id]['allows'] as $i => $allow) $out .= gentechtree($allow, $ar, $root, $i==($n-1), $depth+1, $id); $out .= "
    \n"; } else $out .= '
    '; return $out."\n"; } function showallows($id,$root='') { global $wz_research, $wz_structures; $out = "
      \n"; if (!$wz_research[$id]['allows']) return '

      '.$wz_research[$id]['name'].' is not required for any research.

      '; else foreach ($wz_research[$id]['allows'] as $allow) { if ($allow == $id) continue; $prereqs = $wz_research[$allow]['prereqs']; $fprereqs = array($wz_research[$id]['name']); foreach ($prereqs as $prereq) if ($prereq != $id) $fprereqs[] = (substr($prereq,0,5)=='../s/'?''.$wz_structures[substr($prereq,5)]['name'].' built':''.$wz_research[$prereq]['name'].''); $out .= '
    • '.$wz_research[$allow]['name'].' « '.implode(' + ',$fprereqs)."
    • \n"; } return $out.'
    '; } function aval($array, $i) { return $array[$i]; } function showdesc($id, $root='') { if (!$id) return 'Error: No ID provided.'; if ($id == 'NOID') $id = ''; global $wz_research, $wz_weapons, $wz_templates, $wz_functions, $wz_bodies, $wz_propulsions, $wz_structures, $upgrades, $dt, $wz_rids, $subclasses; $out = '

    '.iconimg($id,'r').'$'.min(intval($wz_research[$id]['price']/32),450).' '.aval(array_keys($wz_rids,$id),0).'

    '; $out .= '

    '.($wz_research[$id]['major']?'[Major research]':'[Minor research]').'

    '; if ($wz_research[$id]['desc']) $out .= '
    '.implode('
    ',$wz_research[$id]['desc']).'
    '; if (count($wz_research[$id]['result'])) { $out .= "
      \n"; foreach ($wz_research[$id]['result'] as $result) { if ($result[0]=='function') { $funcs = $wz_functions[$result[1]]; foreach ($funcs['funcs'] as $func) { if ($func['subclass'] && $func['type']=='weaponrof') $out .= '
    • Upgrades '.$subclasses[$func['subclass']].' rate of fire to '.round(10000/(100-$func['amt']),0).'%
    • '; else if ($func['subclass']) $out .= '
    • Upgrades '.$subclasses[$func['subclass']].' '.$dt[$func['type']].' to '.($func['amt']+100).'%
    • '; else if (isset($upgrades[$func['type']])) $out .= '
    • Upgrades '.$upgrades[$func['type']].' to '.($func['amt']+100).'%
    • '; else $out .= '
    • Unknown upgrade: '.$func['type'].'
    • '; } } else if ($result[0]=='weapon' && $result[1]=='autorepair') $out .= '
    • Enables auto-repair
    • '; else if ($result[0]=='weapon') $out .= '
    • Gives new turret: '.$wz_weapons[$result[1]]['name'].'
    • '; else if ($result[0]=='cyborg') $out .= '
    • Gives new cyborg: '.$wz_templates[$result[1]]['name'].'
    • '; else if ($result[0]=='rplcweapon') $out .= '
    • Automatically replaces: '.$wz_weapons[$result[1]]['name'].'
    • '; else if ($result[0]=='redweapon') $out .= '
    • Makes turret obsolete: '.$wz_weapons[$result[1]]['name'].'
    • '; else if ($result[0]=='redstructure') $out .= '
    • Makes structure obsolete: '.$wz_structures[$result[1]]['name'].'
    • '; else if ($result[0]=='struct') $out .= '
    • Gives new structure: '.$wz_structures[$result[1]]['name'].'
    • '; else if ($result[0]=='body') $out .= '
    • Gives new body: '.$wz_bodies[$result[1]]['name'].'
    • '; else if ($result[0]=='propulsion') $out .= '
    • Gives new propulsion: '.$wz_propulsions[$result[1]]['name'].'
    • '; else $out .= '
    • Unknown result: '.$result[0].'
    • '; } $out .= "
    \n"; } if ($wz_research[$id]['prereqs'][0] == $id) $out .= '

    Automatic – This does not need to be researched; it has already been researched in every game.

    '; if (substr($wz_research[$wz_research[$id]['prereqs'][0]]['name'],0,4) === 'CAM1') $out .= '

    Base – This does not have any prerequisites, and can be researched at the beginning of any game.

    '; return $out; } /* * COMMENTARY FUNCTIONS */ $forgotten = false; $falsecookie = false; if (!$_POST['forget'] && $_POST['remember'] && ($_COOKIE['name'] != trim($_POST['name']) && ($isauth || simplify($_POST['captcha'])=='mg' || simplify($_POST['captcha'])=='machinegun'))) { setcookie('name', trim($_POST['name']).($isadmin?':'.$adminpass:':mg'), time()+365*24*60*60,'/'); $_COOKIE['name'] = trim($_POST['name']); $falsecookie = true; } else if ($_POST['forget'] && $_COOKIE['name']) { setcookie('name', '', time()-60*60,'/'); $forgotten = true; $_COOKIE['name'] = ''; $_POST['name'] = ''; $_REQUEST['name'] = ''; $isauth = $isadmin = false; } function onreldate($time) { if (!$time) return 'never'; $suf = 'ago'; $rtime = ($ctime=time()) - $time; if (!$rtime) return 'just now'; if ($rtime < 0) { $suf = 'from now'; $rtime = -$rtime; } if ($rtime < 60) return $rtime.' second'.($rtime==1?'':'s').' '.$suf; $rtime = intval($rtime/60); if ($rtime < 60) return $rtime.' minute'.($rtime==1?'':'s').' '.$suf; if ($rtime < 120) return 'an hour and '.($rtime-60).' minute'.($rtime==61?'':'s').' '.$suf; //$rtime = intval($rtime/60); //echo '[rtime '.$rtime.']'; if (intval($time/86400)==intval($ctime/86400)) // same day return intval($rtime/60).($rtime%60>=30?' and a half':'').' hour'.($rtime<90?'':'s').' '.$suf; if (($daysago=intval($ctime/86400)-intval($time/86400))==1) return 'yesterday'; if ($daysago==-1) return 'tomorrow'; if ($daysago<=3) return $daysago.' days ago'; $ctimea=getdate($ctime);$timea=getdate($time); if ($ctimea['year']==$timea['year']) return 'on '.date('M j',$time); return 'on '.date('M j, Y',$time); } function comments($id, $root='') { global $_PERSIST, $isauth, $isadmin, $falsecookie, $forgotten; $posted = false; if ($id[1] == '/') $comments = &$_PERSIST[$id[0]]['subdirs'][substr($id,2)]; else $comments = &$_PERSIST[$id]; echo '

    Commentary

    '; if ($_POST['msg']) { if (!($_POST['name']=trim($_POST['name'])) || strlen($_POST['name'])>64) echo '

    Error: Name is invalid.

    '; if (!$isauth && simplify($_REQUEST['captcha'])!='machinegun' && simplify($_REQUEST['captcha'])!='mg') echo '

    Error: Wrong answer.

    '; else { if ($isadmin) { $comments[] = array( 'name' => stripslashes($_POST['name']), 'msg' => stripslashes($_POST['msg']), 'time' => time(), 'admin' => true ); } else { $comments[] = array( 'name' => stripslashes($_POST['name']), 'msg' => stripslashes($_POST['msg']), 'time' => time() ); } if (persist_update()) $posted = true; else echo '

    Error: Internal server error. Please try again later.

    '; } } else if ($_POST['remember'] && !$isauth && simplify($_REQUEST['captcha'])!='machinegun' && simplify($_REQUEST['captcha'])!='mg') { echo '

    Error: Wrong answer.

    '; } if ($comments) { foreach ($comments as $i => $comment) { if (count($comments)>10 && $i == 0) echo '
    '; if (count($comments)>10 && $i == count($comments)-10) { ?>
    '.htmlspecialchars($comment['name']).''.($comment['admin']?' [Admin]':'').' wrote '.onreldate($comment['time']).':

    '.($comment['htmlcomment']?$comment['msg']:nl2br(htmlspecialchars($comment['msg']))).'

    '; } } else echo '

    No comments yet.

    '; echo '

    Add a comment

    '; if ($posted) echo '

    Success!

    '; echo '

    Name:
    ':' />').'
    Message:

    '.($isauth&&$_COOKIE['name']&&!$falsecookie||$isadmin?'':'To prove you are not a spammer, you must correctly answer this question:
    The first weapon you get in the single-player campaign is?

    (Hint: The answer is machinegun)
    ').'

    '; ?> Your name has been forgotten.

    '; if ($_COOKIE['name']) echo '
    '; } function guide($id, $gen = false, $editbtn = true) { global $guide, $isadmin; $root = '../'; if ($id[1] == '/') $msg = &$guide[$id[0]]['subdirs'][substr($id,2)]; else { $msg = &$guide[$id]; $root = ''; } $out = ''; if (isset($msg)) $out = $msg['text']; else if ($gen && $gen !== 'php') { $msg['gen'] = $gen; persist_update('guide'); } if ($editbtn) { if ($gen === 'php') $out = 'Edit

    \'; ?>'.($id=='index'||$id=='panel'?'
    ':'').$out; else if ($id == 'index' && $isadmin) $out = '

    Edit

    '.$out; else if ($msg['gen']) $out = ''.$out; else if ($_COOKIE['name'] && $isadmin) $out = '

    Edit

    '.$out; } return $out; } function getguide($id) { echo '<'.'?php echo guide(\''.$id.'\'); ?'.'>'; } function leftnav($id) { global $guide; if ($id[1] == '/') $msg = &$guide[$id[0]]['subdirs'][substr($id,2)]; else $msg = &$guide[$id]; if ($msg['cachedsb']) return $msg['cachedsb']; else { $msg['cachedsb'] = genleftnav($msg['text']); persist_update('guide'); } return $msg['cachedsb']; } function genleftnav($text) { preg_match_all('/]* id="([a-z0-9]+)">([^<]*)<\/h(3|4)>/', $text, $matches, PREG_SET_ORDER); $depth = 0; $ln = ''; //print_r($matches); foreach ($matches as $match) { if ($match[1]=='3' && $depth==2) { $ln .= ''; $depth = 1; } if ($match[1]=='3') { if ($depth) $ln .= ''; $depth = 1; $ln .= '
  • '.$match[3].''; } else { if ($depth <= 1) $ln .= '
      '; $depth = 2; $ln .= '
    • '.$match[3].'
    • '; } } return $ln; } function editguide($id, $edit, $gen=false) { global $guide; $success = true; if ($id[1] == '/') $msg = &$guide[$id[0]]['subdirs'][substr($id,2)]; else $msg = &$guide[$id]; if (!isset($msg) && $gen) $msg['gen'] = $gen; $msg['text'] = $edit; unset($msg['cachedsb']); persist_update('guide') || $success = false; if ($step = $msg['gen']) include 'generate.php'; return $success; } //print_r($_REQUEST); echo $isadmin.$isauth; ?>