rework.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. // FpsUtils3 indev-0.1 currently not functional.
  3. // Written by Saegusa with love<3 and memes
  4. //
  5. // This is a development structral version of
  6. // FpsUtils' new version, which will be the
  7. // third iteration of this mod, which includes
  8. // the same features as before but in a better
  9. // code structure to make it more understandable
  10. // and easier to work on for people other than gooses.
  11. //
  12. // FpsUtils3 currently includes the new command
  13. // system i thought up for "masterwork" and is beastin
  14. // Pls forward any future requests to my Patreon page:
  15. // https://www.patreon.com/saegusa
  16. //
  17. // Original code repository is placed at:
  18. // https://github.com/Saegusae/fps-utils
  19. */
  20. let config = require('./config.json');
  21. const format = require('./format'),
  22. fs = require('fs');
  23. module.exports = function FpsUtils3(dispatch) {
  24. const CLASSES = config.classes;
  25. let debug = config.debug || false;
  26. let player,
  27. cid,
  28. model,
  29. clss;
  30. let state = config.state || 0,
  31. lastState = state || 0,
  32. hiddenPlayers = {},
  33. hiddenIndividual = {};
  34. let flags = {
  35. fireworks: false,
  36. hide: {
  37. tanks: false,
  38. healers: false,
  39. dps: false
  40. }
  41. }
  42. function getClass(mdl) {
  43. return (m % 100);
  44. }
  45. const commands = {
  46. state: {
  47. alias: ["0", "1", "2", "3"],
  48. help: "Changes fps state to given argument.",
  49. run: function(args) {
  50. lastState = state;
  51. state = parseInt(args[0]);
  52. config.state = state;
  53. switch(state) {
  54. // State 0: Disable fps-utils optimization.
  55. case 0:
  56. if(lastState > 2) {
  57. // Display all hidden players.
  58. }
  59. break;
  60. // State 1: Hide skill particles and projectiles.
  61. case 1:
  62. if(lastState > 2) {
  63. // Display all hidden players, except individuals.
  64. }
  65. break;
  66. // State 2: Hide skill animations.
  67. case 2:
  68. if(lastState > 2) {
  69. // Display all hidden players, except individuals.
  70. }
  71. break;
  72. // State 3: Hide all players.
  73. case 3:
  74. if(lastState < 3) {
  75. // Hide all players.
  76. }
  77. break;
  78. default:
  79. break;
  80. }
  81. }
  82. },
  83. save: {
  84. alias: ['save', 'config'],
  85. help: "Saves current settings to config file for next launch.",
  86. run: function(args) {
  87. save((err) => {
  88. if(err) {
  89. log('Save to config failed.');
  90. } else {
  91. log('Settings successfully saved to config');
  92. }
  93. });
  94. }
  95. },
  96. fireworks: {
  97. alias: ['firework', 'fireworks', 'fw'],
  98. help: "Hide fireworks, and their pesky animations. (true = show | false = hide)",
  99. run: function(args) {
  100. flags.fireworks = !flags.fireworks;
  101. log(`toggled fireworks: ${flags.fireworks}`);
  102. }
  103. },
  104. hide: {
  105. alias: ['hide', 'h', 'delete'],
  106. help: "",
  107. run: function(args) {
  108. if(args.length < 2) {
  109. // Missing argument, throw help function.
  110. } else {
  111. if(state < 3)
  112. switch(args[1]) {
  113. case "dps":
  114. case "healers":
  115. case "tanks":
  116. // Hide all characters of said class.
  117. break;
  118. default:
  119. // Hide individuals by username.
  120. break;
  121. }
  122. }
  123. }
  124. },
  125. show: {
  126. alias: ['show', 's'],
  127. help: "",
  128. run: function(args) {
  129. if(args.length < 2) {
  130. // Missing argument, throw help.
  131. } else {
  132. if(state < 3)
  133. switch(args[1]) {
  134. case "dps":
  135. case "healers":
  136. case "tanks":
  137. // Show chosen class.
  138. break;
  139. default:
  140. // Show individual by name.
  141. break;
  142. }
  143. }
  144. }
  145. },
  146. list: {
  147. alias: ['list', 'l'],
  148. help: "Show a list of players hidden by 'hide' command.",
  149. run: function(args) {
  150. let hiddenArray = [];
  151. for(let pl in hiddenIndividual) hiddenArray.push(hiddenIndividual[pl].name);
  152. log(`Hidden Players: ${hiddenArray}`);
  153. }
  154. }
  155. }
  156. dispatch.hook('C_CHAT', 1, (event) => {
  157. if(!event.message.includes('!fps'))
  158. return;
  159. let command = format.stripTags(event.message).split(' ');
  160. if(command.length > 1) {
  161. command = command.splice(1, 1);
  162. for(let cmd in commands) {
  163. if(commands[cmd].alias.indexOf(command[0])) {
  164. commands[cmd].run(command);
  165. }
  166. }
  167. }
  168. return false;
  169. });
  170. function help(cmd) {
  171. }
  172. function log(msg) {
  173. if(debug) console.log('[fps-utils3] ' + msg);
  174. dispatch.toClient('S_CHAT', 1, {
  175. channel: 24,
  176. authorID: 0,
  177. unk1: 0,
  178. gm: 0,
  179. unk2: 0,
  180. authorName: '',
  181. message: ' (fps-utils3) ' + msg
  182. });
  183. }
  184. function save(callback) {
  185. fs.writeFile('./config.json', config, 'utf8', (err) => {
  186. if(!err) log("config file overwritten successfully");
  187. else callback(err);
  188. });
  189. }
  190. }