Advertisement
ZergurVorghiz

Zergur's Modified Unit Info

Feb 2nd, 2020
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. // Changes the unit info feature to include many more stats, and do a much better job at hiding useless information
  2. // If you are installing this script with the R26 mod loader, it is recommended you use the online installation so in case this gets updated, you will always have the newest version. To use online mods, you need the raw URL: https://pastebin.com/raw/tSR1HQVi
  3. // - - - - - - - - - - - - - - - - - - - -
  4. /* Changelog (note i am from the US so dates are in month/day/year format)
  5. 2/2/2020
  6. - Initial release
  7. - Some unit changes
  8. - Fixed issue with shield stat disappearing when a ship with shield generators runs out of shield
  9. 2/3/2020
  10. - Changed Brawling Value image to rank14.png (skull icon)
  11. - Reused instant.png (old BV icon) as hp*dps (basically brawling value with the cost factor removed)
  12. - Changed energy image to rank12.png (thicker, easier to see lightning bolt)
  13. 5/15/2020
  14. - Added ship name, shows only one ship is selected
  15. - Made quantity hide if one ship is selected
  16. - - - - - - - - - - - - - - - - - - - - */
  17. buildBar.selectedInfo = function() {
  18. var cost, j, len, name, stat, stats, unit, units;
  19. units = commander.selection;
  20. cost = units.reduce((function(acc, unit) {
  21. return acc + unit.cost;
  22. }), 0);
  23. name = null;
  24. if (units.length > 0 && units.every(function(u) {
  25. return u.spec.name === units[0].spec.name;
  26. })) {
  27. name = units[0].spec.name || null;
  28. }
  29. stats = {};
  30. stat = function(icon, unit, value, maxValue, opts) {
  31. if (maxValue == null) {
  32. maxValue = 0;
  33. }
  34. if (opts == null) {
  35. opts = {
  36. hideZero: false,
  37. largest: false,
  38. sum: true,
  39. hideMultiple: false,
  40. fixed: 1,
  41. };
  42. }
  43. if (opts.hideZero && value === 0) {
  44. return;
  45. }
  46. if (!stats[icon]) {
  47. return stats[icon] = {
  48. value: value,
  49. maxValue: maxValue,
  50. unit: unit,
  51. fixed: opts.fixed,
  52. count: 1
  53. };
  54. } else {
  55. if (opts.hideMultiple) {
  56. stats[icon].hidden = true;
  57. } else if (opts.largest) {
  58. stats[icon].value = Math.max(stats[icon].value, value);
  59. stats[icon].maxValue = Math.max(stats[icon].maxValue, maxValue);
  60. } else {
  61. stats[icon].value += value;
  62. stats[icon].maxValue += maxValue;
  63. }
  64. if (!opts.sum && !opts.largest) {
  65. return stats[icon].count++;
  66. }
  67. }
  68. };
  69. for (j = 0, len = units.length; j < len; j++) {
  70. unit = units[j];
  71. if (commander.selection[0].name != "") {
  72. stat("letters.png", " " + unit.name, 0, 0, {
  73. hideMultiple: true,
  74. fixed: 0
  75. });
  76. } else {
  77. stat("letters.png", " Unnamed ship", 0, 0, {
  78. hideMultiple: true,
  79. fixed: 0
  80. });
  81. }
  82. if (units.length > 1) {
  83. stat("count.png", "", 1, 0, {
  84. sum: true,
  85. fixed: 0
  86. });
  87. }
  88. stat("cost.png", "$", unit.cost, 0, {
  89. sum: true,
  90. fixed: 0
  91. });
  92. stat("rank/rank14.png", "BV", unit.hp * unit.weaponDPS * 16 / unit.cost, unit.maxHP * unit.weaponDPS * 16 / unit.cost, {
  93. sum: false,
  94. hideZero: true,
  95. fixed: 0
  96. });
  97. stat("instant.png", "hp*dps", unit.hp * unit.weaponDPS * 16, unit.maxHP * unit.weaponDPS * 16, {
  98. sum: true,
  99. hideZero: true,
  100. fixed: 0
  101. });
  102. stat("armor.png", "hp", unit.hp, unit.maxHP, {
  103. sum: true,
  104. fixed: 0
  105. });
  106. if(unit.maxShield>0){
  107. stat("shield.png", "sh", unit.shield, unit.maxShield, {
  108. sum: true,
  109. fixed: 0
  110. });
  111. stat("symmetry.png", "sh/s", unit.genShield * 16, 0, {
  112. fixed: 0,
  113. sum: true
  114. });
  115. stat("armor2.png", "hp+sh", unit.hp+unit.shield, unit.maxHP+unit.maxShield, {
  116. fixed: 0,
  117. sum: true
  118. });
  119. }
  120. stat("burnDamage.png", "d", unit.burn, 0, {
  121. hideZero: true
  122. });
  123. if(unit.weaponDPS > 0) {
  124. stat("dps.png", "dps", unit.weaponDPS * 16);
  125. stat("damage.png", "d", unit.weaponDamage);
  126. }
  127. stat("range.png", "m", unit.weaponRange, 0, {
  128. largest: true,
  129. fixed: 0,
  130. hideZero: true
  131. });
  132. stat("rank/rank12.png", "K e", unit.energy/1000, unit.storeEnergy/1000, {
  133. sum: true,
  134. fixed: 0
  135. });
  136. if(unit.genEnergy > 2.6) {
  137. stat("energyGen.png", "e/s", unit.genEnergy*16, 0, {
  138. sum: true,
  139. fixed: 0
  140. });
  141. }
  142. stat("energyMove.png", "e/s", unit.moveEnergy * 16, 0, {
  143. sum: true
  144. });
  145. stat("energyFire.png", "e/s", unit.fireEnergy * 16, 0, {
  146. sum: true,
  147. hideZero: true
  148. });
  149. stat("speed.png", "m/s", unit.maxSpeed * 16, 0, {
  150. sum: false
  151. });
  152. stat("turnSpeed.png", "°/s", unit.turnSpeed * 180 / Math.PI * 16, 0, {
  153. hideMultiple: true,
  154. fixed: 0
  155. });
  156. stat("mass.png", "T", unit.mass, 0, {
  157. hideMultiple: true,
  158. fixed: 0
  159. });
  160. stat("arc360.png", "m radius", unit.radius, 0, {
  161. hideMultiple: true,
  162. fixed: 0
  163. });
  164. stat("cloak.png", "T", unit.cloak, unit.mass, {
  165. hideZero: true,
  166. fixed: 0
  167. });
  168. stat("jump.png", "m", unit.jump, unit.jumpDistance, {
  169. hideZero: true,
  170. largest: true,
  171. fixed: 0
  172. });
  173. }
  174. return {
  175. name: name,
  176. cost: cost,
  177. stats: stats
  178. };
  179. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement