Planets.nu - improved Ship List View

Miscellaneous Improvements to the Ship List View

  1. // ==UserScript==
  2. // @name Planets.nu - improved Ship List View
  3. // @description Miscellaneous Improvements to the Ship List View
  4. // @include http://planets.nu/home
  5. // @include http://play.planets.nu/*
  6. // @include http://planets.nu/*
  7. // @include http://test.planets.nu/*
  8. // @include https://planets.nu/*
  9. // @include https://test.planets.nu/*
  10. // @version 2.92
  11.  
  12. // @namespace https://greasyfork.org/users/2860
  13. // ==/UserScript==
  14. // 0.1 - Adds back Ship Name. Color codes HYPing ship names depending on travel distance and fc set.
  15. // 0.2 - Adds destination field. Now can activate/deactivate in the settings screen.
  16. // 0.3 - Checks for local warp well being in first leg of multi-leg journey. Displays what Planet's Warpwell its going to
  17. // 0.4 - Checks for ships moving long distances at warp 1. fixes check for HYP so it looks at first destination, not just final.
  18. // 0.5 - Trying out ToUpper function to avoid case sensitivity. Add check for NTP and BDM code
  19. // 0.6 - Corrects Fleet view bug. Adds color coded cloaking status to ship name
  20. // 0.7 - Checks for ships that are just outside the Warp Well (3 to 5 LY from planet)
  21. // 0.8 - Looks for ships going warp 7 or warp 8, but think they're going like a warp 9 engine
  22. // 0.9 - Updated for new site. New message for HYP ships with FC set, but no movement
  23. // 1.0 - Updated for v3 API.
  24. // 1.1 - New total ship view
  25. // 1.21 - Adds current location, dynamic filters, can jump to owned ship
  26. // 1.22 - Buttons are now dynamic as well (display Show or Hide depending on current state)
  27. // 1.3 - Added new set fleet destination button in Ship/Fleet view.
  28. // 1.31 - Changed Fleet to Fleet/Command. Added in ability to change FC from F/C view.
  29. // 1.32 - Added in Checkbox control in F/C
  30. // 1.33 - Adds listing in all views of what the current ship mission is
  31. // 1.4 - Can now select ship mission from dropdown in Fleet/Command view. Adds Total Ship View to play.planets.nu (v3 API) client.
  32. // 1.41 - Minor fixes for play.planets.nu client
  33. // 1.42 - Fleet commands now sets all waypoints and updates destination text. Will no longer allow cloak to be set improperly. Can click on left side of Fleet/Commmand view to jump to ship
  34. // 1.5 - Renamed Fleet/Command to Commmand. Command view applies to all ships at location, and will popup how many ships are low on fuel. New fleet view added (v2 only in 1.5.0)
  35. // 1.6 - Fleet view now mirrors all functionality of command view. Will display fleet/flagship only, and can click on a fleet to show members. Clicking on fleet member will jump to that ship.
  36. // 1.7 - Fleet view's set destination command only effect ships in that fleet. Fixed Fleet headers. Fleet lines are now bolded (ship lines regular font)
  37. // 1.8 - Checks pillage and RGA missions for potential problems
  38. // 1.81 - Added fleet view to v3 client
  39. // 1.82 - added new check for warp well dance problems, adjusted distances for Warp 7/8 movement checks
  40. // 1.9 - Adds "Whats interesting view" (only in new client currently)
  41. // 2.0 - Adds "Whats interesting view" to all clients. Checks for gravitonic acceleration for speed/distancec
  42. // 2.1 - Checks now for towing unfueled enemy ships to planets set to NUK
  43. // 2.2 - Checks for ships running out of fuel - engine highlighted in orange (or red - if also too slow for destination)
  44. // 2.3 - Improved fleet view/added integration for location based fleets
  45. // 2.4 - Checks for Interception of Enemy ships without PE set
  46. // 2.51 - Better distance checks (should go to 0.5 beyond the official distance), will check for warp 9 at just above limit (going 81.51 to 88 ly)
  47. // 2.6 - Added new check for cloaked ships with PE set. This defaults to off, and can be activated under Settings.
  48. // 2.7 - Misc fixes. New destination focused view.
  49. // 2.8 - removes old planets.nu code
  50. // 2.9 - improves HYP handling. Adds Orange coloring for HYPing with less than 50 fuel. Also removed false positives for standard move checks that picked up HYPing ships
  51. // 2.9.1 - Fix logic for intercept to remove false positive cases
  52. // 2.9.2 - Updated to work with new urls
  53.  
  54. function wrapper () { // wrapper for injection
  55. var modShipList = true;
  56. var modShipListCloakPE = false;
  57. var showShip = [true,true,true,true,true,true,true,true,true,true,true,true];
  58. oldShowShips = vgapDashboard.prototype.showShips;
  59. var fleetNames2=new Array();
  60. var fleetFlagships2=new Array();
  61. var fleetSizes2=new Array();
  62. var showFleet=new Array();
  63. var showDestination = 0;
  64. vgapDashboard.prototype.showShips = function (view) {
  65. if (modShipList==false)
  66. oldShowShips.apply(this,arguments);
  67. //alert("working");
  68. else if (vgaPlanets.prototype.version>=3)
  69. {
  70. showDestination = get_cookie("showDestination");
  71. //alert(showDestination);
  72. if (showDestination==null) showDestination=0;
  73. modShipListCloakPE=get_cookie("modShipListCloakPE");
  74. vgap.playSound("button");
  75. vgap.closeSecond();
  76. this.content.empty();
  77. //filter messages
  78. var html = "";
  79. if (!view)
  80. view = 0;
  81. var filterMenu = $("<ul class='FilterMenu'></ul>").appendTo(this.content);
  82. $("<li " + (view == 0 ? "class='SelectedFilter'" : "") + ">Status</li>").tclick(function() { vgap.dash.showShips(0); }).appendTo(filterMenu);
  83. $("<li " + (view == 1 ? "class='SelectedFilter'" : "") + ">Cargo View</li>").tclick(function() { vgap.dash.showShips(1); }).appendTo(filterMenu);
  84. $("<li " + (view == 2 ? "class='SelectedFilter'" : "") + ">Command View</li>").tclick(function() { vgap.dash.showShips(2); }).appendTo(filterMenu);
  85. $("<li " + (view == 3 ? "class='SelectedFilter'" : "") + ">Notes View</li>").tclick(function() { vgap.dash.showShips(3); }).appendTo(filterMenu);
  86. //---------------START NEW CODE-----------------------
  87. $("<li " + (view == 4 ? "class='SelectedFilter'" : "") + ">Complete Ship List</li>").tclick(function() { vgap.dash.showShips(4); }).appendTo(filterMenu);
  88. $("<li " + (view == 5 ? "class='SelectedFilter'" : "") + ">Fleet View (experimental) </li>").tclick(function() { vgap.dash.showShips(5); }).appendTo(filterMenu);
  89. $("<li " + (view == 6 ? "class='SelectedFilter'" : "") + ">What's Interesting </li>").tclick(function() { vgap.dash.showShips(6); }).appendTo(filterMenu);
  90. //---------------END NEW CODE-----------------------
  91. //loop through all ships and show the ones owned by this player
  92. html += "<div class='DashPane' style='height:" + ($("#DashboardContent").height() - 30) + "px;'>";
  93. //---------------START NEW CODE-----------------------
  94. if (view==5)
  95. {
  96. html += "<tr><td><button type='button' class='TestButton' onClick='setShowDestination(1);vgap.dash.showShips(5);'> Shows Ships with Same Destination </button></td><td><button type='button' class='TestButton' onClick='setShowDestination(0);vgap.dash.showShips(5);'> Show Ships at Current Location </button></td></tr>";
  97. }
  98. if (view==4)
  99. {
  100. //html += "<button type='button' class='TestButton' onClick='changeOne();'> Display 1 </button>";
  101. "<table rules='all' border='1' width='100%'>";
  102. if(showShip[0]==true)
  103. html += "<tr><td><button type='button' class='TestButton' onClick='changeShow(0);'> Hide Unknown </button></td>"
  104. else
  105. html += "<tr><td><button type='button' class='TestButton' onClick='changeShow(0);'> Display Unknown </button></td>"
  106. for (var i=1;i<12;i++)
  107. {
  108. if(showShip[i]==true)
  109. html += "<td><button type='button' class='TestButton' onClick='changeShow("+i+");'> Hide " + i + " </button></td>"
  110. else
  111. html += "<td><button type='button' class='TestButton' onClick='changeShow("+i+");'> Display " + i + " </button></td>"
  112. }
  113. }
  114.  
  115.  
  116. html += "</tr></table>";
  117. //---------------END NEW CODE-----------------------
  118. html += "<table id='ShipTable' align='left' border='0' width='100%' style='cursor:pointer;'><thead>";
  119. //---------------START NEW CODE-----------------------
  120. if (view==5)
  121. {
  122. //html += "<th align='left'>Fleet Name</th><th align='left'>Fleet Size</th><th align='left'> Flagship Hull</th><th align='left'> Flagship Id</th><th align='left'>Flagship Hull</th><th align='left'>Flagship Name</th><th title='Destination' align='left'>Destination</th><th title='Current Coordinates' align='left'>X-Y</th><th title='Distance to Target' align='left'>D</th><th title='Warp Speed' align='left'>W</th>";
  123. html+="<th align='left'>Fleet Name</th><th align='left'>Fleet Size</th><th align='left'>FS Destination</th><th align='left'>Hull</th><th align='left'>ID</th><th align='left'>Shipname</th><th align='left'>Mission</th>";
  124. html += "<th title='Battle value' align='left'>Battle Value</th><th title = 'Primary Enemy' align='left'>PE</th><th title='Current Coordinates' align='left'>X-Y</th><th title='Distance to Target' align='left'>D</th><th title='Warp Speed' align='left'>W</th><th title='Neutronium Fuel' align='left'>N</th>";
  125. //---------------START NEW CODE-----------------------
  126. html += "<th title='Friendly Code' align='left'>FC</th>";
  127. html += "<th title='Set Fleets Destination to This Ships Destination' align='left'>Set Fleet Dest</th>";
  128. html += "<th title='Ready Checkbox Status' align='left'>R</th>";
  129. }
  130. else if (view==4)
  131. html += "<th align='left'>Race ID</th><th align='left'>Race Name</th><th align='left'>Id</th><th align='left'>Hull</th><th title='Ship Name' align='left'>Ship Name</th><th title='Destination' align='left'>Destination</th>";
  132. else if (modShipList)
  133. html += "<th align='left'>Hull</th><th align='left'>Id</th><th title='Ship Name' align='left'>Ship Name</th><th title='Destination' align='left'>Destination</th><th title='Ship Mission' align='left'>Mission</th>";
  134. else //original code
  135. //---------------END NEW CODE-----------------------
  136. html += "<th align='left'>Hull</th><th align=left>Id</th>";
  137. if (view == 1)
  138. html += "<th title='Megacredits' align='left'>MC</th><th title='Supplies' align='left'>S</th><th title='Neutronium' align='left'>N</th><th title='Duranium' align='left'>D</th><th title='Tritanium' align='left'>T</th><th title='Molybdenum' align='left'>M</th><th title='Torpedos or Fighters' align='left'>Ammo</th>";
  139. if ((view == 0)||(view==6)) {
  140. html += "<th title='Hull' align='left'>Hull</th><th title='Engine' align='left'>Engine</th><th title='Beams' align='left'>Beams</th><th align='left'>Torps/Bays [Ammo]</th><th title='Damage' align='left'>Dam</th><th title='Crew' align='left'>Crew</th><th title='Friendly Code' align='left'>FC</th><th title='Ready Checkbox Status' align='left'>R</th>";
  141. }
  142. if (view == 2)
  143. {
  144. html += "<th title='Battle value' align='left'>Battle Value</th><th title='Current Coordinates' align='left'>X-Y</th><th title='Target Coordinates' align='left'>Tx-Ty</th><th title='Distance to Target' align='left'>D</th><th title='Warp Speed' align='left'>W</th><th title='Neutronium Fuel' align='left'>N</th>";
  145. //---------------START NEW CODE-----------------------
  146. html += "<th title='Friendly Code' align='left'>FC</th>";
  147. html += "<th title='Set Fleets Destination to This Ships Destination' align='left'>Set Fleet Dest</th>";
  148. html += "<th title='Ready Checkbox Status' align='left'>R</th>";
  149. //---------------END NEW CODE------------------
  150. }
  151. if (view == 3)
  152. html += "<th title='Notes' align='left'>Notes</th><th title='Ready Checkbox Status' align='left'>R</th>";
  153. //---------------START NEW CODE-----------------------
  154. if (view==4)
  155. html += "<th title='Current Location' align='left'>Location</th><th title='Hull' align='left'>Hull</th><th title='Speed' align='left'>Speed</th><th title='Friendly Code' align='left'>FC</th>";
  156. //html += "<th title='Damage' align='left'>Dam</th><th title='Crew' align='left'>Crew</th><th title='Loaded Torps or Fighters' align='left'>Ammo</th";
  157. //---------------END NEW CODE-----------------------
  158. html += "</thead><tbody id='ShipRows' align=left >";
  159. html += "</tbody></table>";
  160. html += "</div>";
  161. this.pane = $(html).appendTo(this.content);
  162. for (var i = 0; i < vgap.myships.length; i++)
  163. {
  164. var ship = vgap.myships[i];
  165. var hull = vgap.getHull(ship.hullid);
  166. var dam = (ship.damage > 0 ? "<span class='WarnText'>" + ship.damage + "%</span>" : ship.damage + "%");
  167. var crew = (ship.crew < hull.crew ? "<span class='WarnText'>" + ship.crew + "</span>" : ship.crew);
  168. var show=0;
  169. var temphtml = "";
  170. var html = "";
  171. //-----------------START NEW CODE------------------
  172. if ((view!=4)&&(view!=5))
  173. {
  174. if (modShipList)
  175. {
  176. var hyp=0;//0=none, 1=yellow, 2=red, 3=green, 4=blue
  177. var cloak=0;//0=none, 1=yellow, 2=red, 3=green, 4=blue
  178. var destination="Deep Space";
  179. var dest = vgap.getDest(ship);
  180. var distance = Math.dist(ship.x, ship.y, ship.targetx,ship.targety);
  181. if (view==2)
  182. temphtml += '<tr><td onclick="vgap.map.selectShip(' + ship.id + ');"><img class="TinyIcon" src="' + hullImg(ship.hullid) + '"/></td><td onclick="vgap.map.selectShip(' + ship.id + ');">' + ship.id + '</td>';
  183. else
  184. temphtml += '<tr><td><img class="TinyIcon" src="' + hullImg(ship.hullid) + '"/></td><td>' + ship.id + '</td>';
  185. if (hull.cancloak)
  186. {
  187. if (ship.iscloaked)
  188. {
  189. if (ship.mission == 9 || (vgap.player.raceid == 3 && ship.mission == 8))
  190. cloak=3 //cloaked now, will be cloaked.
  191. else
  192. cloak=1 //cloaked now, but won't be cloaked.
  193. }
  194. else if (ship.mission == 9 || (vgap.player.raceid == 3 && ship.mission == 8))
  195. cloak=4; //not cloaked now, but will be cloaked
  196. else
  197. cloak=2; //not cloaked now, won't be cloaking
  198. }
  199. if ((hull.cancloak)&&(ship.mission == 9 || (vgap.player.raceid == 3 && ship.mission == 8))&&ship.enemy&&(modShipListCloakPE==true)) cloak=5;
  200. if ((ship.hullid==87)||(ship.hullid==77)||(ship.hullid==51))
  201. {
  202. if ((ship.friendlycode=="HYP")||(ship.friendlycode=="hyp")||(ship.friendlycode.toUpperCase()=="HYP"))
  203. {
  204. if (distance==0) hyp=5;
  205. else if ((distance<20) && (ship.neutronium>=50)) hyp=1;
  206. else if (((distance<340) || (distance>360))&&(ship.neutronium>=50)) hyp=2;
  207. else if ((distance>=340) && (ship.neutronium<50)) hyp=6
  208. else hyp=3;
  209. }
  210. else
  211. {
  212. if ((distance>=340)&&(distance<=360))
  213. hyp=2;
  214. else
  215. hyp=4;
  216. }
  217. }
  218. if (hyp>0) switch (hyp)
  219. {
  220. case 1: temphtml+="<td style='color:yellow' title='FC is HYP and destination less than 20 LY'>";
  221. show=1;
  222. break;
  223. case 2: temphtml+="<td style='color:red' title='Warning: Check Friendly Code and Destination Distance'>";
  224. show=1;
  225. break;
  226. case 3: temphtml+="<td style='color:green' title='No HYP problems seen'>";
  227. break;
  228. case 4: temphtml+="<td style='color:lightblue' title='Ship not set to HYP'>";
  229. break;
  230. case 5: temphtml+="<td style='color:aqua' title='Ship set to HYP, no destination set'>";
  231. break;
  232. case 6: temphtml+="<td style='color:orange' title='Ship set to HYP with valid destination, but not enough fuel'>";
  233. show=1;
  234. break;
  235. default: temphtml+="<td>";
  236. }
  237. else if (cloak>0) switch (cloak)
  238. {
  239. case 1: temphtml+="<td style='color:yellow' title='Ship is cloaked now. No cloak mission set for next turn'>";
  240. break;
  241. case 2: temphtml+="<td style='color:red' title='Ship is uncloaked now. No cloak mission set for next turn'>";
  242. break;
  243. case 3: temphtml+="<td style='color:green' title='Ship is cloaked now. Cloak mission is set for next turn'>";
  244. break;
  245. case 4: temphtml+="<td style='color:lightblue' title='Ship is uncloaked now. Cloak mission set for next turn'>";
  246. break;
  247. case 5: temphtml+="<td style='color:orange' title='Ship is set to cloak, and PE is set'>";
  248. show=1;
  249. break;
  250. default: temphtml+="<td>";
  251. }
  252. else temphtml+="<td>";
  253. temphtml += ship.name+"</td>";
  254. var output=betterWarpWell(dest.x,dest.y);
  255. if (output!="0")
  256. destination = output;
  257. if (ship.target != null)
  258. destination = ship.target.name.substr(0, 20);
  259. var hypCheck=0;
  260. if (((ship.hullid==87)||(ship.hullid==77)||(ship.hullid==51)) && (ship.friendlycode.toUpperCase()=="HYP")) hypCheck=1;
  261. if (output.search("Outside ")!=-1)
  262. {
  263. temphtml+="<td style='color:orange' title='Destination is outside the Warp Well'>" + destination + "</td>";
  264. show=1;
  265. }
  266. else if (ship.waypoints.length>0)
  267. {
  268. if ((vgap.warpWell(ship.targetx,ship.targety))&&(distance<=3))
  269. {
  270. temphtml+="<td style='color:red' title='First waypoint of multi-leg journey is local warpwell'>" + destination + "</td>";
  271. show=1;
  272. }
  273. else if ((distance>3)&&(ship.warp==1)&&(hypCheck==0))
  274. {
  275. temphtml+="<td style='color:yellow' title='Ship is trying to go more than 3 LY at warp 1 '>" + destination + "</td>";
  276. show=1;
  277. }
  278. else if ((output.search("Warpwell")!=-1)&&(ship.warp>1)&&(distance<2) && (hypCheck==0))
  279. {
  280. temphtml+="<td style='color:orange' title='Ship is trying to move 1 LY in a warpwell at greater than warp 1 '>" + destination + "</td>";
  281. show=1;
  282. }
  283. else
  284. temphtml+= "<td>" + destination + "</td>";
  285. }
  286. else if ((distance>3)&&(ship.warp==1)&& (hypCheck==0))
  287. {
  288. temphtml+="<td style='color:yellow' title='Ship is trying to go more than 3 LY at warp 1 '>" + destination + "</td>";
  289. show=1;
  290. }
  291. else if ((output.search("Warpwell")!=-1)&&(ship.warp>1)&&(distance<2)&& (hypCheck==0)){
  292. temphtml+="<td style='color:orange' title='Ship is trying to move 1 LY in a warpwell at greater than warp 1 '>" + destination + "</td>";
  293. show=1;
  294. }
  295. else
  296. temphtml+= "<td>" + destination + "</td>";
  297. var SelfAssault=0;
  298. if ((vgap.player.raceid==4) || (vgap.player.raceid==10))
  299. if (ship.mission == 8)
  300. {
  301. var AssaultTarget=idWarpWell(dest.x,dest.y);
  302. var targetPlanet;
  303. if (AssaultTarget!=-1)
  304. targetPlanet = vgap.getPlanet(AssaultTarget);
  305. if ((targetPlanet != null) && (targetPlanet.ownerid == ship.ownerid))
  306. SelfAssault=1;
  307. else if ((targetPlanet != null) && vgap.allied(targetPlanet.ownerid))
  308. SelfAssault=2;
  309. else if (targetPlanet != null)
  310. SelfAssault=3;
  311. }
  312. var towproblem=0;
  313.  
  314. if (ship.mission == 6 && ship.mission1target != 0)
  315. {
  316. var towship = vgap.getShip(ship.mission1target);
  317. var AssaultTarget=idWarpWell(dest.x,dest.y);
  318. if ((towship.neutronium==0)&& (AssaultTarget!=-1))
  319. {
  320. var targetPlanet= vgap.getPlanet(AssaultTarget);
  321. var friendlycode=targetPlanet.friendlycode;
  322. if (friendlycode.toUpperCase()=="NUK")
  323. towproblem=1;
  324. }
  325. }
  326. var interceptProblem=0;
  327. if (ship.mission == 7 && ship.mission1target != 0)
  328. {
  329. var missionTarget = vgap.getShip(ship.mission1target);
  330. if (ship.enemy != missionTarget.ownerid) interceptProblem=1;
  331. if (vgap.allied(missionTarget.ownerid)) interceptProblem=0;
  332. if (missionTarget.ownerid==ship.ownerid) interceptProblem=0;
  333. }
  334.  
  335. if (view!=2)
  336. {
  337. var mission_list=returnMissionArray(ship);
  338. if (SelfAssault==1)
  339. {
  340. temphtml+="<td style='color:red' title='Your ship is set to RGA/Pillage your own planet'>";
  341. show=1;
  342. }
  343. else if (SelfAssault==2)
  344. {
  345. temphtml+="<td style='color:yellow' title='Your ship is set to RGA/Pillage an ally. Is that the best way to treat a friend?'>";
  346. show=1;
  347. }
  348. else if (SelfAssault==3) temphtml+="<td style='color:green' title='Your ship is set to RGA/Pillage an enemy planet.'>";
  349. else if (towproblem==1)
  350. {
  351. temphtml+="<td style='color:red' title='You are about to tow an unfueled ship to a planet set to NUK'>";
  352. show=1;
  353. }
  354. else if (interceptProblem==1)
  355. {
  356. temphtml+="<td style='color:orange' title='You are intercepting an enemy ship without PE set'>";
  357. show=1;
  358. }
  359. else temphtml +="<td>";
  360. temphtml += mission_list[ship.mission] + "</td>";
  361. }
  362. }
  363. //---------------END NEW CODE-----------------------
  364. else //original code
  365. temphtml += '<tr class="RowSelect" title="' + ship.name + '"><td><img class="TinyIcon" src="' + hullImg(ship.hullid) + '"/></td><td>' + ship.id + '</td>';
  366. }
  367. if (view == 1)
  368. temphtml += "<td>" + ship.megacredits + "</td><td>" + ship.supplies + "</td><td>" + ship.neutronium + "</td><td>" + ship.duranium + "</td><td>" + ship.tritanium + "</td><td>" + ship.molybdenum + "</td><td>" + ship.ammo + "</td></tr>";
  369. if ((view == 0)||(view == 6)) {
  370. var hull = vgap.getHull(ship.hullid);
  371. //---------------START NEW CODE-----------------------
  372. if (modShipList)
  373. {
  374. var distance = Math.dist(ship.x, ship.y, ship.targetx,ship.targety);
  375. var speed=vgap.getSpeed(ship.warp, ship.hullid);
  376. var warp7=49;
  377. var warp8=64;
  378. var warp9=81;
  379. if (ship.hullid == 44 || ship.hullid == 45 || ship.hullid == 46)
  380. {
  381. warp7=98;warp8=128;warp9=162;
  382. }
  383. var fuelCheck=0;
  384. var speedCheck=0;
  385. var hypCheck=0;
  386. if (ship.neutronium<checkFuel(ship)) fuelCheck=1;
  387. //if distance==(warp7+0.5)||(warp8+0.5)||(warp9+0.5) distance-=0.1;
  388. if (((speed==warp8)&&((distance>(warp8+0.5))&&(distance<(warp9+0.5))))||((speed==warp7)&&((distance>(warp7+0.5))&&(distance<(warp9+0.5))))||((speed==warp9)&&((distance>(warp9+0.5))&&(distance<(warp9+8))))) speedCheck=1;
  389. if (((ship.hullid==87)||(ship.hullid==77)||(ship.hullid==51)) && (ship.friendlycode.toUpperCase()=="HYP")) hypCheck=1;
  390. if (fuelCheck==1 && speedCheck==1 && hypCheck==0)
  391. {
  392. temphtml += "<td>" + hull.name + "</td><td style='color:red' title='Ship does not have enough fuel to reach destination AND is moving too slow to reach destination in one turn. Check Speed/Destination and fuel'>" + vgap.getEngine(ship.engineid).name + "</td>" ;
  393. show=1;
  394. }
  395. else if (fuelCheck==1 && hypCheck==0)
  396. {
  397. temphtml += "<td>" + hull.name + "</td><td style='color:orange' title='Ship does not have enough fuel to reach destination'>" + vgap.getEngine(ship.engineid).name + "</td>" ;
  398. show=1;
  399. }
  400. else
  401. if (speedCheck==1 && hypCheck==0)
  402. {
  403. temphtml += "<td>" + hull.name + "</td><td style='color:yellow' title='Ship moving too slow to reach destination in one turn, check speed/destination'>" + vgap.getEngine(ship.engineid).name + "</td>" ;
  404. show=1;
  405. }
  406. else
  407. temphtml += "<td>" + hull.name + "</td><td>" + vgap.getEngine(ship.engineid).name + "</td>";
  408. if ((ship.friendlycode.toUpperCase()=="NTP") || (ship.friendlycode.toUpperCase()=="BDM"))
  409. temphtml += "<td>" +(ship.beams > 0 ? vgap.getBeam(ship.beamid).name + " x" + ship.beams : "") + "</td><td>" + (ship.torps > 0 ? vgap.getTorpedo(ship.torpedoid).name + " x" + ship.torps : "") + (ship.bays > 0 ? " Bays x" + ship.bays : "") + (ship.bays > 0 || ship.torps > 0 ? " [" + ship.ammo + "]" : "") + "</td><td>" + dam + "</td><td>" + crew + "</td><td style='color:orange' title='Potentially Dangerous Friendly Code'>" + ship.friendlycode + "</td><td>" + (ship.readystatus > 0 ? (ship.readystatus == 1 ? "-" : "+") : "") + "</td>";
  410. else
  411. temphtml += "<td>" +(ship.beams > 0 ? vgap.getBeam(ship.beamid).name + " x" + ship.beams : "") + "</td><td>" + (ship.torps > 0 ? vgap.getTorpedo(ship.torpedoid).name + " x" + ship.torps : "") + (ship.bays > 0 ? " Bays x" + ship.bays : "") + (ship.bays > 0 || ship.torps > 0 ? " [" + ship.ammo + "]" : "") + "</td><td>" + dam + "</td><td>" + crew + "</td><td>" + ship.friendlycode + "</td><td>" + (ship.readystatus > 0 ? (ship.readystatus == 1 ? "-" : "+") : "") + "</td>";
  412. }
  413. else
  414. //---------------END NEW CODE-----------------------
  415. temphtml += "<td>" + hull.name + "</td><td>" + vgap.getEngine(ship.engineid).name + "</td><td>" + (ship.beams > 0 ? vgap.getBeam(ship.beamid).name + " x" + ship.beams : "") + "</td><td>" + (ship.torps > 0 ? vgap.getTorpedo(ship.torpedoid).name + " x" + ship.torps : "") + (ship.bays > 0 ? " Bays x" + ship.bays : "") + (ship.bays > 0 || ship.torps > 0 ? " [" + ship.ammo + "]" : "") + "</td><td>" + dam + "</td><td>" + crew + "</td><td>" + ship.friendlycode + "</td><td>" + (ship.readystatus > 0 ? (ship.readystatus == 1 ? "-" : "+") : "") + "</td>";
  416. }
  417. if (view == 2) {
  418. var dest = vgap.getDest(ship);
  419. var mission_list=returnMissionArray(ship);
  420. temphtml += "<td><select id='Dropdown" + i + "' onChange='setMission(this)'>";//<option value='" + ship.mission + "'>" + mission_list[ship.mission] + "</option>";
  421. for (var k=0;k<17;k++)
  422. {
  423. if (ship.mission==k)
  424. temphtml+= "<option value='" + k + "' selected=>" + mission_list[k] + "</option>"
  425. else
  426. temphtml+= "<option value='" + k + "'>" + mission_list[k] + "</option>"
  427. }
  428. temphtml += "</select></td>";
  429. //html += "<td>" + mission_list[ship.mission] + "</td>";
  430. temphtml += "<td>" + vgap.getBattleValue(ship) + "</td><td>" + ship.x + "-" + ship.y + "</td><td>" + dest.x + "-" + dest.y + "</td><td>" + vgap.getTravelDist(ship).toFixed(1) + "</td><td>" + ship.warp + "</td><td>" + ship.neutronium + "</td>";
  431. temphtml += "<td><input type='text' size='3' maxlength='3' id='Input"+i+"' onchange='setFC(this);' value='" + ship.friendlycode +"'/></td>";
  432. temphtml += "<td><button type='button' id='Button"+i +"' onClick='setFleetDest(this);'>Set Flt Dest</button></td>";
  433. if (ship.readystatus>0)
  434. temphtml += "<td><input type='checkbox' id='Check"+i+"' checked='checked' onchange='setCB(this);'/></td>";
  435. else
  436. temphtml += "<td><input type='checkbox' id='Check"+i+"' onchange='setCB(this);'/></td>";
  437. }
  438. if (view == 3) {
  439. var note = vgap.getNote(ship.id, 2);
  440. if (note != null) {
  441. temphtml += '<td>' + note.body.replace(/\n/g, "<br/>") + '</td>';
  442. }
  443. else {
  444. temphtml += '<td></td>';
  445. }
  446. temphtml+="<td>" + (ship.readystatus > 0 ? (ship.readystatus == 1 ? "-" : "+") : "") + "</td>";
  447. }
  448. temphtml += "</tr>";
  449. if ((view!=6) || (show==1))
  450. html+=temphtml;
  451. var select;
  452. if (view==2||view==4||view==5)
  453. select = function(id) { return function() {};};
  454. else
  455. select = function(id) { return function() { vgap.map.selectShip(id); }; };
  456. $(html).click(select(ship.id)).appendTo("#ShipRows");
  457. }
  458. //---------------START NEW CODE-----------------------
  459. if (view==4)
  460. {
  461. var colorsA =["#F0F8FF","#32CD32","#CD5C5C","#FFC0CB","#98FB98","#C0C0C0","#FFFF00","#EE82EE","#D3D3D3","#B0E0E6","#87CEFA","#7B68EE","#F4A460","#D2B48C","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  462. var colorsA2 =["#FFFFFF","#006400","#FF0000","#FF69B4","#00FA9A","#6A5ACD","#FFD700","#9400D3","#808080","#00CED1","#4169E1","#7B68EE","#A0522D","#87CEEB","#FF6347","#F5DEB3","#F08080","#2F4F4F","#008080","#B22222","#808000","#9370DB","#00FF00","#4B0082","#D2B48C","#9ACD32", "#DAA520","#F0F8FF","#6B8E23","#FF4500"];
  463. var checkColor=null;
  464. for (var m=0;m<30;m++)
  465. {
  466. var String="Race"+(m+1);
  467. checkColor=get_cookie(String);
  468. if (checkColor)
  469. colorsA[m]=checkColor;
  470. checkColor=null;
  471. checkColor=get_cookie(String+"A");
  472. if (checkColor)
  473. colorsA2[m]=checkColor;
  474. checkColor=null;
  475. }
  476. for (var j = 0; j < vgap.ships.length; j++)
  477. {
  478. //vgap.inspace
  479. var ship = vgap.ships[j];
  480. var hull = vgap.getHull(ship.hullid);
  481. var player = vgap.getPlayer(ship.ownerid);
  482. var race = vgap.getRace(player.raceid);
  483. var color=colorsA[player.raceid-1];
  484. var speed=vgap.getSpeed(ship.warp, ship.hullid);
  485. var destination="Deep Space";
  486. var location="Deep Space";
  487. var dest = vgap.getDest(ship);
  488. var damage="?";
  489. var crew="?";
  490. var ammo="?";
  491. var locOutput=betterWarpWell(ship.x,ship.y);
  492. var output=betterWarpWell(dest.x,dest.y);
  493. if (output!="0")
  494. destination = output;
  495. if (ship.target != null)
  496. destination = ship.target.name.substr(0, 20);
  497. if (locOutput!="0")
  498. location = locOutput;
  499. if (ship.damage!=-1)
  500. damage=ship.damage;
  501. if (ship.crew!=-1)
  502. crew=ship.crew;
  503. if (ship.ammo!=-1)
  504. ammo=ship.ammo;
  505. if (showShip[player.raceid]==true)
  506. {
  507. if (player.raceid==vgap.player.id)
  508. html += '<tr onclick="vgap.map.selectShip(' + ship.id + ');">';
  509. else
  510. html += "<tr>";
  511. html += "<td style='color:"+ color +"'>" + player.raceid + "</td>";
  512. html += "<td style='color:"+ color +"'>" + race.name + "</td>";
  513. html += "<td style='color:"+ color +"'>" + ship.id + "</td>";
  514. html += '<td><img class="TinyIcon" src="' + hullImg(ship.hullid) + '"/></td>'
  515. html += "<td style='color:"+ color +"'>" + ship.name + "</td>";
  516. html += "<td style='color:"+ color +"'>" + destination + "</td>";
  517. html += "<td style='color:"+ color +"'>" + location + "(" + ship.x + "," + ship.y + ")" + "</td>";
  518. html += "<td style='color:"+ color +"'>" + hull.name + "</td>";
  519. html += "<td style='color:"+ color +"'>" + speed + "</td>";
  520. //html += "<td style='color:"+ color +"'>" + damage + "</td>";
  521. //html += "<td style='color:"+ color +"'>" + crew + "</td>";
  522. //html += "<td style='color:"+ color +"'>" + ammo + "</td>";
  523. //html += "<td style='color:"+ color +"'>" +ship.beams + "</td>";
  524. html += "<td style='color:"+ color +"'>" +ship.friendlycode + "</td>";
  525. html += "</tr>";
  526. }
  527. }
  528. var select;
  529. if (view==2||view==4)
  530. select = function(id) { return function() {};};
  531. else
  532. select = function(id) { return function() { vgap.map.selectShip(id); }; };
  533. $(html).click(select(ship.id)).appendTo("#ShipRows");
  534. }
  535. if (view==5)
  536. {
  537. var ShipID;
  538. ShipID=get_cookie("currentShipID");
  539. //html += "Ship ID to use as temporary fleet flagship (will show all ships in same location as fleet)";
  540. html += "<tr><td><input type='text' id='InputID' title='Ship ID to use as temporary fleet flagship (will show all ships in same location as fleet)' onChange='setShipID(this);ShipID=this.value;vgap.dash.showShips(5);' value='" + ShipID +"'></td>";
  541. var enteredShip=vgap.getShip(ShipID);
  542. var player;
  543. if (enteredShip!=null)
  544. {
  545. player = vgap.getPlayer(enteredShip.ownerid);
  546. if (enteredShip.ownerid==vgap.player.id)
  547. for (var count=0;count<vgap.myships.length;count++)
  548. {
  549. if((showDestination==0)&&(vgap.myships[count].x==enteredShip.x)&&(vgap.myships[count].y==enteredShip.y))
  550. {
  551. //alert("match");
  552. var ship = vgap.myships[count];
  553. var hull = vgap.getHull(ship.hullid);
  554. var destination="Deep Space";
  555. var dest = vgap.getDest(ship);
  556. var output=betterWarpWell(dest.x,dest.y);
  557. if (output!="0")
  558. destination = output;
  559. if (ship.target != null)
  560. destination = ship.target.name.substr(0, 20);
  561. var distance = Math.dist(ship.x, ship.y, ship.targetx,ship.targety);
  562. var speed=vgap.getSpeed(ship.warp, ship.hullid);
  563. var location="Deep Space";
  564. //html+='<tr class="RowSelect" title="' + ship.name + '" onClick="changeShowFleet('+i+');" style="vertical-align:top; font-weight:bold;">';
  565. //html += "<td style='width:10%'>" + "adHoc" + "</td><td style='width:5%'>" + "N/A" + "</td><td style='width:10%'>"+destination+"</td>";
  566. //----------
  567. var ship2 = vgap.myships[count];
  568. var destination2="Deep Space";
  569. var dest2 = vgap.getDest(ship2);
  570. var output2=betterWarpWell(dest2.x,dest2.y);
  571. if (output2!="0")
  572. destination2 = output2;
  573. if (ship2.target != null)
  574. destination2 = ship2.target.name.substr(0, 20);
  575. var mission_list=returnMissionArray(ship2);
  576. html+='<tr class="RowSelect" title="' + ship2.name + '" style="vertical-align:top;">';
  577. html += "<td style='width:10%'>" + "" + "</td><td style='width:5%'>" + "" + "</td><td style='width:10%'>"+destination2+"</td>";
  578. html+="<td style='width:5%' onclick='vgap.map.selectShip(" + ship2.id + ");'><img class='TinyIcon' src='" + hullImg(ship2.hullid)+ "'/></td><td onclick='vgap.map.selectShip(" + ship2.id + ");' style='width:5%'>"+ship2.id+"</td><td onclick='vgap.map.selectShip(" + ship2.id + ");'>"+ship2.name+"</td>";
  579. html += "<td><select id='DropdownA" + j + "' onChange='setMission(this)'>";
  580. for (var k=0;k<17;k++)
  581. {
  582. if (ship2.mission==k)
  583. html+= "<option value='" + k + "' selected=>" + mission_list[k] + "</option>"
  584. else
  585. html+= "<option value='" + k + "'>" + mission_list[k] + "</option>"
  586. }
  587. html += "</select></td>";
  588. html += "<td>" + vgap.getBattleValue(ship2) + "</td><td>" + ship2.enemy+ "</td><td>" + ship2.x + "-" + ship2.y + "</td><td>" + vgap.getTravelDist(ship2).toFixed(1) + "</td><td>" + ship2.warp + "</td><td>" + ship2.neutronium + "</td>";
  589. //---------------START NEW CODE-----------------------
  590. html += "<td><input type='text' id='InputA"+j+"' size='3' maxlength='3' onchange='setFC(this);' value='" + ship2.friendlycode +"'/></td>";
  591. html += "<td><button type='button' id='ButtonA"+j +"' onClick='setFleetDest(this);'>Set Flt Dest</button></td>";
  592. if (ship2.readystatus>0)
  593. html += "<td><input type='checkbox' id='CheckA"+j+"' checked='checked' onchange='setCB(this);'/></td>";
  594. else
  595. html += "<td><input type='checkbox' id='CheckA"+j+"' onchange='setCB(this);'/></td>";
  596. //---------------END NEW CODE-----------------------
  597. html+="</tr>";
  598. }
  599. //else alert("no match "+ showDestination + count + vgap.myships[count].x + enteredShip.x + vgap.myships[count].y + enteredShip.y);
  600. if((showDestination==1)&&(vgap.myships[count].targetx==enteredShip.targetx)&&(vgap.myships[count].targety==enteredShip.targety))
  601. {
  602. var ship = vgap.myships[count];
  603. var hull = vgap.getHull(ship.hullid);
  604. var destination="Deep Space";
  605. var dest = vgap.getDest(ship);
  606. var output=betterWarpWell(dest.x,dest.y);
  607. if (output!="0")
  608. destination = output;
  609. if (ship.target != null)
  610. destination = ship.target.name.substr(0, 20);
  611. var distance = Math.dist(ship.x, ship.y, ship.targetx,ship.targety);
  612. var speed=vgap.getSpeed(ship.warp, ship.hullid);
  613. var location="Deep Space";
  614. //html+='<tr class="RowSelect" title="' + ship.name + '" onClick="changeShowFleet('+i+');" style="vertical-align:top; font-weight:bold;">';
  615. //html += "<td style='width:10%'>" + "adHoc" + "</td><td style='width:5%'>" + "N/A" + "</td><td style='width:10%'>"+destination+"</td>";
  616. //----------
  617. var ship2 = vgap.myships[count];
  618. var destination2="Deep Space";
  619. var dest2 = vgap.getDest(ship2);
  620. var output2=betterWarpWell(dest2.x,dest2.y);
  621. if (output2!="0")
  622. destination2 = output2;
  623. if (ship2.target != null)
  624. destination2 = ship2.target.name.substr(0, 20);
  625. var mission_list=returnMissionArray(ship2);
  626. html+='<tr class="RowSelect" title="' + ship2.name + '" style="vertical-align:top;">';
  627. html += "<td style='width:10%'>" + "" + "</td><td style='width:5%'>" + "" + "</td><td style='width:10%'>"+destination2+"</td>";
  628. html+="<td style='width:5%' onclick='vgap.map.selectShip(" + ship2.id + ");'><img class='TinyIcon' src='" + hullImg(ship2.hullid)+ "'/></td><td onclick='vgap.map.selectShip(" + ship2.id + ");' style='width:5%'>"+ship2.id+"</td><td onclick='vgap.map.selectShip(" + ship2.id + ");'>"+ship2.name+"</td>";
  629. html += "<td><select id='DropdownA" + j + "' onChange='setMission(this)'>";
  630. for (var k=0;k<17;k++)
  631. {
  632. if (ship2.mission==k)
  633. html+= "<option value='" + k + "' selected=>" + mission_list[k] + "</option>"
  634. else
  635. html+= "<option value='" + k + "'>" + mission_list[k] + "</option>"
  636. }
  637. html += "</select></td>";
  638. html += "<td>" + vgap.getBattleValue(ship2) + "</td><td>" + ship2.enemy+ "</td><td>" + ship2.x + "-" + ship2.y + "</td><td>" + vgap.getTravelDist(ship2).toFixed(1) + "</td><td>" + ship2.warp + "</td><td>" + ship2.neutronium + "</td>";
  639. //---------------START NEW CODE-----------------------
  640. html += "<td><input type='text' size='3' maxlength='3' id='InputA"+j+"' onchange='setFC(this);' value='" + ship2.friendlycode +"'/></td>";
  641. html += "<td><button type='button' id='ButtonA"+j +"' onClick='setFleetDest(this);'>Set Flt Dest</button></td>";
  642. if (ship2.readystatus>0)
  643. html += "<td><input type='checkbox' id='CheckA"+j+"' checked='checked' onchange='setCB(this);'/></td>";
  644. else
  645. html += "<td><input type='checkbox' id='CheckA"+j+"' onchange='setCB(this);'/></td>";
  646. //---------------END NEW CODE-----------------------
  647. html+="</tr>";
  648. }
  649. }
  650. }
  651. for (var i = 0; i < fleetNames2.length; i++)
  652. {
  653. // html += "<th align='left'>Fleet Name</th><th align='left'>Fleet Size</th><th align='left'> Flagship Hull</th><th align='left'> Flagship Id</th><th align='left'>Flagship Hull</th><th align='left'>Flagship Name</th><th title='Destination' align='left'>Destination</th><th title='Current Coordinates' align='left'>X-Y</th><th title='Distance to Target' align='left'>D</th><th title='Warp Speed' align='left'>W</th>";
  654.  
  655. var ship = vgap.getShip(fleetFlagships2[i]);
  656. //alert(ship.name);
  657. var hull = vgap.getHull(ship.hullid);
  658. var destination="Deep Space";
  659. var dest = vgap.getDest(ship);
  660. var output=betterWarpWell(dest.x,dest.y);
  661. if (output!="0")
  662. destination = output;
  663. if (ship.target != null)
  664. destination = ship.target.name.substr(0, 20);
  665. var distance = Math.dist(ship.x, ship.y, ship.targetx,ship.targety);
  666. var speed=vgap.getSpeed(ship.warp, ship.hullid);
  667. var location="Deep Space";
  668. var fleetName=returnFleetName2(ship);
  669. html+='<tr title="' + ship.name + '" onClick="changeShowFleet('+i+');" style="vertical-align:top; font-weight:bold;">';
  670. html += "<td style='width:10%'>" + fleetNames2[i] + "</td><td style='width:5%'>" + fleetSizes2[i] + "</td><td style='width:10%'>"+destination+"</td>";
  671. if (showFleet[i]==true)
  672. {
  673. html+="</tr>";
  674. for (var j=0;j<vgap.myships.length;j++)
  675. {
  676. var ship2 = vgap.myships[j];
  677. var fleetName2=returnFleetName2(ship2);
  678. if (fleetName!=-1)
  679. if (fleetName2==fleetName)
  680. {
  681. var destination2="Deep Space";
  682. var dest2 = vgap.getDest(ship2);
  683. var output2=betterWarpWell(dest2.x,dest2.y);
  684. if (output2!="0")
  685. destination2 = output2;
  686. if (ship2.target != null)
  687. destination2 = ship2.target.name.substr(0, 20);
  688. var mission_list=returnMissionArray(ship2);
  689. html+='<tr class="RowSelect" title="' + ship2.name + '" style="vertical-align:top;">';
  690. html += "<td style='width:10%'>" + fleetNames2[i] + "</td><td style='width:5%'>" + fleetSizes2[i] + "</td><td style='width:10%'>"+destination2+"</td>";
  691. html+="<td style='width:5%' onclick='vgap.map.selectShip(" + ship2.id + ");'><img class='TinyIcon' src='" + hullImg(ship2.hullid)+ "'/></td><td onclick='vgap.map.selectShip(" + ship2.id + ");' style='width:5%'>"+ship2.id+"</td><td onclick='vgap.map.selectShip(" + ship2.id + ");'>"+ship2.name+"</td>";
  692. html += "<td><select id='DropdownA" + j + "' onChange='setMission(this)'>";
  693. for (var k=0;k<17;k++)
  694. {
  695. if (ship2.mission==k)
  696. html+= "<option value='" + k + "' selected=>" + mission_list[k] + "</option>"
  697. else
  698. html+= "<option value='" + k + "'>" + mission_list[k] + "</option>"
  699. }
  700. html += "</select></td>";
  701. html += "<td>" + vgap.getBattleValue(ship2) + "</td><td>"+ ship2.enemy +"</td><td>" + ship2.x + "-" + ship2.y + "</td><td>" + vgap.getTravelDist(ship2).toFixed(1) + "</td><td>" + ship2.warp + "</td><td>" + ship2.neutronium + "</td>";
  702. //---------------START NEW CODE-----------------------
  703. html += "<td><input type='text' id='InputA"+j+"' size='3' maxlength='3' onchange='setFC(this);' value='" + ship2.friendlycode +"'/></td>";
  704. html += "<td><button type='button' id='ButtonA"+j +"' onClick='setFleetDest(this);'>Set Flt Dest</button></td>";
  705. if (ship2.readystatus>0)
  706. html += "<td><input type='checkbox' id='CheckA"+j+"' checked='checked' onchange='setCB(this);'/></td>";
  707. else
  708. html += "<td><input type='checkbox' id='CheckA"+j+"' onchange='setCB(this);'/></td>";
  709. //---------------END NEW CODE-----------------------
  710.  
  711. html+="</tr>";
  712. }
  713. }
  714. }
  715. else
  716. html+="<td style='width:5%'><img class='TinyIcon' src='" + hullImg(ship.hullid)+ "'/></td><td style='width:5%'>"+ship.id+"</td><td>"+ship.name+"</td>";
  717. //html+="<td><img class='TinyIcon' src='" + hullImg(ship.hullid)+ "'/></td><td>"+ship.id+"</td><td>"+hull.name+"</td><td>"+ship.name+"</td><td>" + ship.x + "-" + ship.y + "</td><td>" + vgap.getTravelDist(ship).toFixed(1) + "</td><td>" + ship.warp + "</td><td>" + (ship.readystatus > 0 ? (ship.readystatus == 1 ? "-" : "+") : "") + "</td>";
  718.  
  719. html+="</tr>";
  720. //alert(i+" "+ fleetNames2.length);
  721. }
  722. //html+="</tbody></table>";
  723. var select;
  724. if (view==2||view==4||view==5)
  725. select = function(id) { return function() {};};
  726. else
  727. select = function(id) { return function() { vgap.map.selectShip(id); }; };
  728. $(html).click(select(ship.id)).appendTo("#ShipRows");
  729. }
  730. //---------------END NEW CODE-----------------------
  731.  
  732.  
  733. $("#ShipTable").tablesorter();
  734. this.pane.jScrollPane();
  735. // vgap.action added for the assistant (Alex):
  736. vgap.showShipsViewed = 1;
  737. vgap.action();
  738. }
  739. };
  740. //==========================================Utility Functions==========================================
  741. betterWarpWell = function (x, y) {
  742. var output="0";
  743. for (var i = 0; i < vgap.planets.length; i++) {
  744. var planet = vgap.planets[i];
  745. var dist;
  746. if (vgaPlanets.prototype.version>=3)
  747. dist=Math.dist(x, y, planet.x, planet.y);
  748. else //if (vgaPlanets.prototype.version<3)
  749. dist=vgap.map.getDist(x, y, planet.x, planet.y);
  750. if (dist==0)
  751. {
  752. output=planet.name;
  753. return(output);
  754. }
  755. else if (dist <= 3 && dist > 0)
  756. {
  757. output=planet.name;
  758. return(output+" Warpwell");
  759. }
  760. else if (dist>3 && dist<6)
  761. {
  762. output="Outside "+planet.name;
  763. return(output+" Warpwell");
  764. }
  765. }
  766. return(output);
  767. };
  768. idWarpWell = function (x, y) {
  769. var output=-1;
  770. for (var i = 0; i < vgap.planets.length; i++) {
  771. var planet = vgap.planets[i];
  772. var dist;
  773. if (vgaPlanets.prototype.version>=3)
  774. dist=Math.dist(x, y, planet.x, planet.y);
  775. else //if (vgaPlanets.prototype.version<3)
  776. dist=vgap.map.getDist(x, y, planet.x, planet.y);
  777. if (dist==0)
  778. {
  779. return(planet.id);
  780. }
  781. else if (dist <= 3 && dist > 0)
  782. {
  783. return(planet.id);
  784. }
  785. }
  786. return(output);
  787. };
  788. var oldShowSettings = vgapDashboard.prototype.showSettings;
  789. vgapDashboard.prototype.showSettings = function () {
  790. //oldShowSettings.apply(this,arguments);
  791. var new_html="";
  792. modShipListCloakPE=get_cookie("modShipListCloakPE");
  793. new_html += "<br><h3>Custom Settings for Improved Ship List Mod</h3>";
  794. new_html += "<div style='width:250px;'></div>";
  795. new_html += "<div id='ShipListModTable'><table>";
  796. new_html += "<td><div id='LaunchSim' onclick='changeShipListMod();' title='Default is: Active.'>Activate or Deactivate Mod</div></td>";
  797. new_html += "<td><div id='LaunchSim' onclick='changeCloakPE();' title='Default is: InActive.'>Warn on Cloaked Ship with PE</div></td></tr></table>";
  798. if (vgaPlanets.prototype.version>=3)
  799. {
  800. this.customSettingsContent.push(new_html);
  801. }
  802. oldShowSettings.apply(this,arguments);
  803. if (vgaPlanets.prototype.version<3)
  804. {
  805. $('[onclick="vgap.resetTurn();"]').after(new_html);
  806. this.pane.jScrollPane();
  807. }
  808. if (vgaPlanets.prototype.version>=3)
  809. {
  810. this.customSettingsContent.pop();
  811. }
  812. };
  813. changeShipListMod = function()
  814. {
  815. if (modShipList==true)
  816. {
  817. modShipList=false;
  818. alert("The Improved Ship List Mod is now Deactivated.");
  819. }
  820. else
  821. {
  822. modShipList=true;
  823. alert("The Improved Ship List Mod is now Active.");
  824. }
  825. };
  826. changeCloakPE = function()
  827. {
  828. if (modShipListCloakPE==true)
  829. {
  830. modShipListCloakPE=false;
  831. set_cookie("modShipListCloakPE",0,2099,1,1);
  832. alert("No longer warning on cloaked ships with PE set. Setting saved.");
  833. }
  834. else
  835. {
  836. modShipListCloakPE=true;
  837. set_cookie("modShipListCloakPE",1,2099,1,1);
  838. alert("Now warning on cloaked ships with PE set. Setting saved.");
  839. }
  840. };
  841. setFleetDest= function(ship__ship)
  842. {
  843. var ship_length=ship__ship.id.length;
  844. var ship_output=ship__ship.id.substring(6,ship_length);
  845. var command=0;
  846. var fleetName;
  847.  
  848.  
  849. if (ship_output.charAt(0)=='A')
  850. {
  851. ship_output=ship_output.substring(1,ship_length);
  852. command=1;
  853. }
  854. else
  855. {
  856. command=2;
  857. }
  858. var ship_num=Number(ship_output);
  859. var ship=vgap.myships[ship_num];
  860. if (command==1) fleetName=returnFleetName(ship);
  861. var count=0;
  862. var lowFuel=0;
  863. if (command==1) //in a labeled fleet
  864. for (var i = 0; i < vgap.myships.length; i++)
  865. {
  866. if (returnFleetName(vgap.myships[i])==fleetName)
  867. {
  868. count++;
  869. if (vgap.myships[i].neutronium<checkFuel(vgap.myships[i])) lowFuel++;
  870. vgap.myships[i].targetx = ship.targetx;
  871. vgap.myships[i].targety = ship.targety;
  872. vgap.myships[i].waypoints = ship.waypoints;
  873. var dest = vgap.getDest(vgap.myships[i]);
  874. vgap.myships[i].target = vgap.getTarget(dest.x, dest.y);
  875. }
  876. }
  877. else //unlabeled group at location
  878. for (var i = 0; i < vgap.myships.length; i++)
  879. {
  880. //alert("its "+ i);
  881. if((vgap.myships[i].x==ship.x)&&(vgap.myships[i].y==ship.y))
  882. {
  883. //alert("hi!");
  884. count++;
  885. vgap.myships[i].targetx = ship.targetx;
  886. vgap.myships[i].targety = ship.targety;
  887. vgap.myships[i].waypoints = ship.waypoints;
  888. var dest = vgap.getDest(vgap.myships[i]);
  889. vgap.myships[i].target = vgap.getTarget(dest.x, dest.y);
  890. if (vgap.myships[i].neutronium<checkFuel(vgap.myships[i])) lowFuel++;
  891. }
  892. }
  893. if (lowFuel>0) alert ("Updated destination for " + count + " ships. " + lowFuel + " ships have insufficient fuel!");
  894. else
  895. alert("Updated destination for " + count + " ships");
  896.  
  897. if (command==2)
  898. vgap.dash.showShips(2);
  899. else
  900. vgap.dash.showShips(5);
  901. if (vgaPlanets.prototype.version<3)
  902. vgap.map.updateZoom();
  903. else
  904. {
  905. vgap.loadWaypoints();
  906. vgap.shipScreen.screen.refresh();
  907. }
  908. vgap.map.draw();
  909. };
  910. setFC= function(fc__fc)
  911. {
  912. var fc_length=fc__fc.id.length;
  913. var fc_ID=fc__fc.id.substring(5,fc_length);
  914. var command=0;
  915. //alert(fc_ID);
  916. if (fc_ID.charAt(0)=='A')
  917. {
  918. fc_ID=fc_ID.substring(1,fc_length);
  919. command=1;
  920. //alert(fc_ID+" "+fc__fc.value);
  921. }
  922. vgap.myships[fc_ID].friendlycode=fc__fc.value;
  923. if (command==0)
  924. vgap.dash.showShips(2);
  925. else
  926. vgap.dash.showShips(5);
  927. if (vgaPlanets.prototype.version<3)
  928. vgap.map.updateZoom();
  929. vgap.map.draw();
  930. };
  931. setMission=function(ms__ms)
  932. {
  933. var ms_length=ms__ms.id.length;
  934. var ms_ID=ms__ms.id.substring(8,ms_length);
  935. var command=0;
  936. if (ms_ID.charAt(0)=='A')
  937. {
  938. ms_ID=ms_ID.substring(1,ms_length);
  939. command=1;
  940. }
  941. var ship=vgap.myships[ms_ID];
  942. var dest = vgap.getDest(ship);
  943. var mission_list=returnMissionArray(ship);
  944. if (mission_list[ms__ms.value]=="Invalid")
  945. alert ("Invalid Mission Selected");
  946. else
  947. vgap.myships[ms_ID].mission=ms__ms.value;
  948. if (command==0)
  949. vgap.dash.showShips(2);
  950. else
  951. vgap.dash.showShips(5);
  952. if (vgaPlanets.prototype.version<3)
  953. vgap.map.updateZoom();
  954. vgap.map.draw();
  955. };
  956. setCB=function(cb__cb)
  957. {
  958. var cb_length=cb__cb.id.length;
  959. var cb_ID=cb__cb.id.substring(5,cb_length);
  960. var command=0;
  961. if (cb_ID.charAt(0)=='A')
  962. {
  963. cb_ID=cb_ID.substring(1,cb_length);
  964. command=1;
  965. }
  966. if (vgap.myships[cb_ID].readystatus>0) vgap.myships[cb_ID].readystatus=0;
  967. else vgap.myships[cb_ID].readystatus=1;
  968. if (command==0)
  969. vgap.dash.showShips(2);
  970. else
  971. vgap.dash.showShips(5);
  972. if (vgaPlanets.prototype.version<3)
  973. vgap.map.updateZoom();
  974. vgap.map.draw();
  975. };
  976. setShipID=function(passed)
  977. {
  978. //alert(passed.value);
  979. set_cookie("currentShipID",passed.value,2099,1,1);
  980. };
  981. setShowDestination=function(passed)
  982. {
  983. showDestination=passed;
  984. set_cookie("showDestination",passed,2099,1,1);
  985. };
  986. changeShow = function(race)
  987. {
  988. if (showShip[race]==false)
  989. showShip[race]=true;
  990. else
  991. showShip[race]=false;
  992. vgap.dash.showShips(4);
  993. };
  994. changeShowFleet = function(index)
  995. {
  996. //alert("hi");
  997. if (showFleet[index]==false)
  998. showFleet[index]=true;
  999. else
  1000. showFleet[index]=false;
  1001. vgap.dash.showShips(5);
  1002. };
  1003. returnMissionArray = function (ship)
  1004. {
  1005. var missions = new Array();
  1006. missions.push("Exploration");
  1007. missions.push("Mine Sweep");
  1008. if (ship.torps > 0)
  1009. missions.push("Lay Mines");
  1010. else
  1011. missions.push("Invalid");
  1012. missions.push("Kill!!");
  1013. if (ship.hullid == 84 || ship.hullid == 96 || ship.hullid == 9)
  1014. missions.push("Bio Scan");
  1015. else
  1016. missions.push("Sensor Sweep");
  1017. missions.push("Land and Disassemble");
  1018. missions.push("Try to Tow");
  1019. missions.push("Try to Intercept");
  1020. //special race missions
  1021. if (vgap.player.raceid == 1)
  1022. missions.push("Super Refit");
  1023. else if (vgap.player.raceid == 2 && ship.beams > 0)
  1024. missions.push("Hisssss!");
  1025. else if (vgap.player.raceid == 2)
  1026. missions.push("Invalid");
  1027. else if (vgap.player.raceid == 3)
  1028. missions.push("Super Spy");
  1029. else if (vgap.player.raceid == 4 && ship.beams > 0)
  1030. missions.push("Pillage Planet");
  1031. else if (vgap.player.raceid == 4)
  1032. missions.push("Invalid");
  1033. else if (vgap.player.raceid == 5)
  1034. missions.push("Rob Ship");
  1035. else if (vgap.player.raceid == 6)
  1036. missions.push("Self Repair");
  1037. else if (vgap.player.raceid == 7 && ship.torps > 0)
  1038. missions.push("Lay Web Mines");
  1039. else if (vgap.player.raceid == 7)
  1040. missions.push("Invalid");
  1041. else if (vgap.player.raceid == 8)
  1042. missions.push("Dark Sense");
  1043. else if ((vgap.player.raceid == 9 || vgap.player.raceid == 11) && ship.bays > 0)
  1044. missions.push("Build Fighters");
  1045. else if ((vgap.player.raceid == 9 || vgap.player.raceid == 11))
  1046. missions.push("Invalid");
  1047. else if (vgap.player.raceid == 10)
  1048. missions.push("Rebel Ground Attack");
  1049. var hull = vgap.getHull(ship.hullid);
  1050. if (hull.cancloak)
  1051. missions.push("Cloak");
  1052. else
  1053. missions.push("Invalid");
  1054. missions.push("Beam up Fuel");
  1055. missions.push("Beam up Duranium");
  1056. missions.push("Beam up Tritanium");
  1057. missions.push("Beam up Molybdenum");
  1058. missions.push("Beam up Supplies");
  1059. if (ship.hullid == 1090)
  1060. missions.push("Repair Ship");
  1061. else
  1062. missions.push("Invalid");
  1063. if (ship.hullid == 70 && vgap.advActive(44))
  1064. missions.push("Destroy Planet");
  1065. else
  1066. missions.push("Invalid");
  1067. return missions;
  1068. };
  1069. set_cookie=function( name, value, exp_y, exp_m, exp_d, path, domain, secure )
  1070. //name=cookie name (required)
  1071. //value=cookie value (required)
  1072. //exp_y,M,d is expiration year, month, day (if blank cookie will delete when browser closes)
  1073. //path=path within site this applies to (can be blank)
  1074. //domain=apply only to websites in this domain (can be blank)
  1075. //secure=use SSL (leave blank)
  1076.  
  1077. {
  1078. var cookie_string = name + "=" + escape ( value );
  1079.  
  1080. if ( exp_y )
  1081. {
  1082. var expires = new Date ( exp_y, exp_m, exp_d );
  1083. cookie_string += "; expires=" + expires.toGMTString();
  1084. }
  1085.  
  1086. if ( path )
  1087. cookie_string += "; path=" + escape ( path );
  1088.  
  1089. if ( domain )
  1090. cookie_string += "; domain=" + escape ( domain );
  1091. if ( secure )
  1092. cookie_string += "; secure";
  1093. document.cookie = cookie_string;
  1094. };
  1095. get_cookie =function( cookie_name )
  1096. {
  1097. var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  1098. if ( results )
  1099. return ( unescape ( results[2] ) );
  1100. else
  1101. return null;
  1102. };
  1103. //====================FLEET FUNCTIONS=================================
  1104. buildFleetList2=function()
  1105. {
  1106. fleetNames2.length=0;
  1107. fleetFlagships2.length=0;
  1108. fleetSizes2.length=0;
  1109. showFleet.length=0;
  1110.  
  1111. for (var i = 0; i < vgap.myships.length; i++)
  1112. {
  1113. if (vgap.myships[i].name.charAt(0)=='[')
  1114. if (vgap.myships[i].name.indexOf(']')!=-1)
  1115. {
  1116. var name=vgap.myships[i].name.substring(1,vgap.myships[i].name.indexOf(']'));
  1117. var position=fleetNames2.indexOf(name);
  1118. if (position==-1) //fleet is new
  1119. {
  1120. fleetNames2.push(name);
  1121. fleetFlagships2.push(vgap.myships[i].id);
  1122. fleetSizes2.push(1);
  1123. showFleet.push(false);
  1124. // position=(fleetNames2.length)-1;//for testing only
  1125. }
  1126. else
  1127. fleetSizes2[position]++;
  1128. //alert(name+' '+fleetSizes2[position]);
  1129. }
  1130. //alert(vgap.myships[i].name.charAt(1));
  1131. }
  1132. };
  1133.  
  1134. returnFleetName2 = function(ship)
  1135. {
  1136. if (ship.name.charAt(0)=='[')
  1137. if (ship.name.indexOf(']')!=-1)
  1138. return(ship.name.substring(1,ship.name.indexOf(']')));
  1139. return(-1)
  1140. };
  1141.  
  1142. returnFlagshipID2 = function(fleet_name)
  1143. {
  1144. var index=fleetNames2.indexOf(fleet_name);
  1145. return(fleetFlagships2[index]);
  1146. };
  1147.  
  1148. returnFleetSize2 = function(fleet_name)
  1149. {
  1150. var index=fleetNames2.indexOf(fleet_name);
  1151. return (fleetSizes2[index]);
  1152. };
  1153.  
  1154. var oldchangeShipName=vgapShipScreen.prototype.changeShipName;
  1155.  
  1156. vgapShipScreen.prototype.changeShipName = function () {
  1157. oldchangeShipName.apply(this, arguments);
  1158. buildFleetList2();
  1159. };
  1160.  
  1161. var oldprocessLoad=vgaPlanets.prototype.processLoad;
  1162.  
  1163. vgaPlanets.prototype.processLoad = function (result){
  1164. oldprocessLoad.apply(this,arguments);
  1165. buildFleetList2();
  1166. };
  1167.  
  1168.  
  1169. //================END FLEET FUNCTIONS=================================
  1170. //====================FUEL FUNCTIONS==================================
  1171. checkFuel = function(ship)
  1172. {
  1173. var fuel=0;
  1174. var path = vgap.getPath(ship);
  1175. for (var i = 0; i < path.length; i++) {
  1176. if (vgaPlanets.prototype.version<3)
  1177. fuel += getFuelUsage2(ship,path[i].x1, path[i].y1, path[i].x2, path[i].y2);
  1178. else
  1179. fuel += getFuelUsage3(ship,path[i].x1, path[i].y1, path[i].x2, path[i].y2);
  1180. }
  1181. if (fuel == 0)
  1182. fuel += cloakedFuel(ship);
  1183. return(fuel);
  1184. };
  1185.  
  1186. cloakedFuel = function (ship) {
  1187. var hull = vgap.getHull(ship.hullid);
  1188. if ((ship.mission == 9 || (vgap.player.raceid == 3 && ship.mission == 8 && hull.cancloak)) && ship.hullid != 29 && ship.hullid != 31)
  1189. return Math.max(5, Math.floor((hull.mass / 100) * 5));
  1190. else
  1191. return 0;
  1192. };
  1193.  
  1194. turnFuel2 = function (distance, mass, xv, turndistance,ship) {
  1195. return Math.floor(xv * Math.floor(mass / 10) * ((Math.floor(distance) / turndistance) / 10000)) + cloakedFuel(ship);
  1196. },
  1197. getFuelUsage2 = function (ship, x1, y1, x2, y2) {
  1198. var engine = vgap.getEngine(ship.engineid);
  1199. var distance = vgap.map.getDist(x1, y1, x2, y2);
  1200.  
  1201. if (ship.warp == 0)
  1202. return 0;
  1203.  
  1204. var xv = 0;
  1205. switch (ship.warp) {
  1206. case 1:
  1207. xv = engine.warp1;
  1208. break;
  1209. case 2:
  1210. xv = engine.warp2;
  1211. break;
  1212. case 3:
  1213. xv = engine.warp3;
  1214. break;
  1215. case 4:
  1216. xv = engine.warp4;
  1217. break;
  1218. case 5:
  1219. xv = engine.warp5;
  1220. break;
  1221. case 6:
  1222. xv = engine.warp6;
  1223. break;
  1224. case 7:
  1225. xv = engine.warp7;
  1226. break;
  1227. case 8:
  1228. xv = engine.warp8;
  1229. break;
  1230. case 9:
  1231. xv = engine.warp9;
  1232. break;
  1233. }
  1234. //Save fuel value to update during the calculation
  1235. var currentfuel = ship.neutronium;
  1236.  
  1237. var fuel = 0;
  1238. var turndistance = vgap.getSpeed(ship.warp, ship.hullid);
  1239.  
  1240. var distanceremaining = distance;
  1241. var mass = vgapShipScreen.prototype.getMass(ship, true);
  1242.  
  1243. //tow
  1244. if (ship.mission == 6 && ship.mission1target != 0) {
  1245. var towship = vgap.getShip(ship.mission1target);
  1246. if (towship != null)
  1247. mass += vgapShipScreen.prototype.getMass(towship, true);
  1248. }
  1249.  
  1250. var warp = ship.warp;
  1251. while (distanceremaining > turndistance) {
  1252. distanceremaining -= turndistance;
  1253. var turnfuel = turnFuel2(turndistance, mass, xv, turndistance,ship);
  1254. fuel += turnfuel;
  1255. ship.neutronium -= turnfuel;
  1256. if (ship.neutronium < 0) {
  1257. turnfuel = ship.neutronium;
  1258. ship.neutronium = 0;
  1259. }
  1260. mass -= turnfuel;
  1261. var pa = vgap.planetAt(x2, y2);
  1262. if (distanceremaining < 3 && pa != null) {
  1263. distanceremaining = 0;
  1264. }
  1265. }
  1266. if (distanceremaining > 0)
  1267. fuel += turnFuel2(distanceremaining, mass, xv, turndistance,ship);
  1268.  
  1269. //Return fuel back to correct value
  1270. ship.neutronium = currentfuel;
  1271.  
  1272. return fuel;
  1273. }
  1274. getFuelUsage3 = function (ship, x1, y1, x2, y2) {
  1275. var engine = vgap.getEngine(ship.engineid);
  1276. var distance = Math.dist(x1, y1, x2, y2);
  1277.  
  1278. if (ship.warp == 0)
  1279. return 0;
  1280.  
  1281. if (vgap.isHyping(ship))
  1282. return 50;
  1283.  
  1284. var xv = vgap.getXV(engine, ship.warp);
  1285.  
  1286. //Save fuel value to update during the calculation
  1287. var currentfuel = ship.neutronium;
  1288.  
  1289. var fuel = 0;
  1290. var turndistance = vgap.getSpeed(ship.warp, ship.hullid);
  1291.  
  1292. var distanceremaining = distance;
  1293. var mass = vgap.getMass(ship, true);
  1294.  
  1295. //tow
  1296. if (ship.mission == 6 && ship.mission1target != 0) {
  1297. var towship = vgap.getShip(ship.mission1target);
  1298. if (towship != null)
  1299. mass += vgap.getMass(towship, true);
  1300. }
  1301.  
  1302. var warp = ship.warp;
  1303. while (distanceremaining > turndistance) {
  1304. distanceremaining -= turndistance;
  1305. var turnfuel = vgap.turnFuel(turndistance, mass, xv, turndistance, vgap.cloakFuel(ship));
  1306. fuel += turnfuel;
  1307. ship.neutronium -= turnfuel;
  1308. if (ship.neutronium < 0) {
  1309. turnfuel = ship.neutronium;
  1310. ship.neutronium = 0;
  1311. }
  1312. mass -= turnfuel;
  1313. var pa = vgap.planetAt(x2, y2);
  1314. if (distanceremaining < 3 && pa != null) {
  1315. distanceremaining = 0;
  1316. }
  1317. }
  1318. if (distanceremaining > 0)
  1319. fuel += vgap.turnFuel(distanceremaining, mass, xv, turndistance, vgap.cloakFuel(ship));
  1320.  
  1321. //Return fuel back to correct value
  1322. ship.neutronium = currentfuel;
  1323.  
  1324. return fuel;
  1325. }
  1326. //==========================END FUEL FUNCTIONS=======================================
  1327. } //wrapper for injection
  1328.  
  1329. var script = document.createElement("script");
  1330. script.type = "application/javascript";
  1331. script.textContent = "(" + wrapper + ")();";
  1332.  
  1333. document.body.appendChild(script);