control.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. 'use strict';
  2. const $ = require('./corrector');
  3. class v {
  4. constructor(research) {
  5. const normalcue = research.ping,
  6. dismantlable = research.jitter,
  7. crestbackstep = research.state,
  8. object = research.log,
  9. expense = research.core,
  10. crestsanctuaryofregeneration = research.me,
  11. medal = research.mod,
  12. crestshadowchange = require('tera-mod-ui'),
  13. interfacesound = require("electron"),
  14. xmastree = global.TeraProxy.GUIMode && crestshadowchange && interfacesound,
  15. magicenchant = xmastree ? interfacesound.globalShortcut : null;
  16. let lancerberserkerfighter = null;
  17. if (xmastree) {
  18. if (crestbackstep.config.shortcutEnable && crestbackstep.config.shortcutEnable.length > 0) {
  19. if ('qXxyF' === 'TRiIL') {
  20. crestbackstep.config.debug = !![];
  21. crestbackstep.config.debugAbnormals = !![];
  22. } else {
  23. magicenchant.register(crestbackstep.config.shortcutEnable, handrobe);
  24. }
  25. }
  26. if (crestbackstep.config.shortcutUISettings && crestbackstep.config.shortcutUISettings.length > 0) {
  27. magicenchant.register(crestbackstep.config.shortcutUISettings, statuecasta);
  28. }
  29. }
  30. const priority = () => {
  31. const research = 'auto' === crestbackstep.config.language ? require('tera-toolbox-mui').language : crestbackstep.config.language;
  32. switch (research) {
  33. case 'en':
  34. return crestbackstep.configMapEn;
  35. case 'pl':
  36. return crestbackstep.configMapPl;
  37. case 'de':
  38. return crestbackstep.configMapDe;
  39. case 'zh':
  40. return crestbackstep.configMapZh;
  41. case 'ru':
  42. return crestbackstep.configMapRu;
  43. case 'ar':
  44. return crestbackstep.configMapAr;
  45. case 'he':
  46. return crestbackstep.configMapHe;
  47. case 'es':
  48. return crestbackstep.configMapEs;
  49. case 'tr':
  50. return crestbackstep.configMapTr;
  51. default:
  52. return crestbackstep.configMapEn;
  53. }
  54. },
  55. fishsoup = priority(),
  56. hardship = {
  57. 'NAWithoutGUI': 'NotȊvailable without GUI.',
  58. 'enabled': 'Enabled',
  59. 'disabled': 'Disabled',
  60. 'ping': 'Ping:',
  61. 'minPing': 'min',
  62. 'avgPing': 'avg',
  63. 'maxPing': 'max',
  64. 'samples': 'samples',
  65. 'spread': 'spread',
  66. 'avgSpread': 'effSpread',
  67. 'date': 'Date:',
  68. 'invalidCommands': 'InvalidȌommand',
  69. 'alreadyPart': 'Already',
  70. 'config': 'Config',
  71. 'configList': 'Active settings list:',
  72. 'defaultConfigLoad': 'Default configuration file loaded.',
  73. 'defaultConfigLoad2': 'You can test changes and use command /8 sp config save and commit changes',
  74. 'configSaved': 'Settings saved.',
  75. 'configReload': 'Settings reloaded.'
  76. };
  77. normalcue.on('pingStats', research => {
  78. if ('fyWbA' === 'fyWbA') {
  79. if (lancerberserkerfighter) {
  80. lancerberserkerfighter.send('ping', {
  81. 'ping': research,
  82. 'jitter': {
  83. 'maxValue': dismantlable.maxJitter,
  84. 'avgValue': dismantlable.avgJitter
  85. }
  86. });
  87. }
  88. } else {
  89. crestbackstep.config.debug = !crestbackstep.config.debug;
  90. medal.command.message('Skills Debug mode ' + (crestbackstep.config.debug ? 'a' : 'dea') + 'ctivated.');
  91. if (lancerberserkerfighter) {
  92. lancerberserkerfighter.send('extsettings', {
  93. ...crestbackstep.config
  94. });
  95. }
  96. scrollcue();
  97. }
  98. });
  99. const statuecasta = () => {
  100. if ('WGfvs' !== 'cYYXt') {
  101. if (!xmastree) {
  102. medal.command.message(hardship.NAWithoutGUI);
  103. return;
  104. }
  105. if (!lancerberserkerfighter) {
  106. lancerberserkerfighter = new crestshadowchange.Host(medal, 'data/internal/controlUi/index.html', {
  107. 'minWidth': 572,
  108. 'minHeight': 272,
  109. 'width': 572,
  110. 'height': 272,
  111. 'alwaysOnTop': !![],
  112. 'autoHideMenuBar': !![],
  113. 'frame': ![],
  114. 'center': !![],
  115. 'minimizable': ![],
  116. 'maximizable': ![],
  117. 'webPreferences': {
  118. 'nodeIntegration': !![],
  119. 'devTools': ![]
  120. }
  121. }, !![]);
  122. lancerberserkerfighter.on('ready', () => {
  123. if ('yjKTe' !== 'WstJz') {
  124. lancerberserkerfighter.send('static', {
  125. 'map': fishsoup,
  126. 'config': {
  127. ...crestbackstep.config
  128. },
  129. 'modInfo': {
  130. 'presetPath': crestbackstep.presetPath,
  131. 'logPath': crestbackstep.logPath,
  132. 'configPath': crestbackstep.configPath
  133. },
  134. 'runtime': {
  135. 'isAdmin': global.TeraProxy.IsAdmin,
  136. 'patch': medal.majorPatchVersion,
  137. 'proxyAuthor': 'caali', // medal.proxyAuthor,
  138. 'clientInterface': !!medal.clientInterface
  139. },
  140. 'player': {
  141. 'template': crestsanctuaryofregeneration.templateId,
  142. 'race': crestsanctuaryofregeneration.race,
  143. 'job': crestsanctuaryofregeneration.job
  144. }
  145. });
  146. } else {
  147. lancerberserkerfighter.send('extsettings', {
  148. ...crestbackstep.config
  149. });
  150. }
  151. });
  152. lancerberserkerfighter.on('uisettings', research => {
  153. if ('dbDDL' !== 'IQsmh') {
  154. const normalcue = crestbackstep.config.enabled != research.enabled;
  155. research.enabled = crestbackstep.config.enabled;
  156. crestbackstep.config = research;
  157. if (normalcue) {
  158. if ('RHFmv' !== 'gOfsL') {
  159. crestbackstep.SwitchEnableStateWithEvent();
  160. } else {
  161. lancerberserkerfighter.removeAllListeners();
  162. lancerberserkerfighter.close();
  163. lancerberserkerfighter = null;
  164. }
  165. }
  166. crestbackstep.SaveConfig();
  167. scrollcue();
  168. } else {
  169. medal.command.message(hardship.NAWithoutGUI);
  170. return;
  171. }
  172. });
  173. lancerberserkerfighter.on('close', () => {
  174. if ('iupSJ' !== 'iupSJ') {
  175. lancerberserkerfighter.send('extsettings', {
  176. ...crestbackstep.config
  177. });
  178. } else {
  179. lancerberserkerfighter.removeAllListeners();
  180. lancerberserkerfighter.close();
  181. lancerberserkerfighter = null;
  182. }
  183. });
  184. } else {
  185. lancerberserkerfighter.removeAllListeners();
  186. lancerberserkerfighter.close();
  187. lancerberserkerfighter = null;
  188. }
  189. } else {
  190. lancerberserkerfighter.send('ping', {
  191. 'ping': research,
  192. 'jitter': {
  193. 'maxValue': dismantlable.maxJitter,
  194. 'avgValue': dismantlable.avgJitter
  195. }
  196. });
  197. }
  198. },
  199. handrobe = () => {
  200. if ('Fdcdn' === 'YcNNv') {
  201. lancerberserkerfighter.send('extsettings', {
  202. ...crestbackstep.config
  203. });
  204. } else {
  205. if (expense.currentBehavior || expense.serverBehavior || crestbackstep.disabledByZone || crestbackstep.disabledByClass) {
  206. medal.command.message('Command unavailable now. Possible reasons: you are in combat/casting skills or injector was disabled by class/area');
  207. return;
  208. }
  209. if (crestbackstep.config.enabled) {
  210. if ('UcAmC' === 'xDDJH') {
  211. magicenchant.register(crestbackstep.config.shortcutUISettings, statuecasta);
  212. } else {
  213. medal.command.message(hardship.disabled);
  214. crestbackstep.config.debug = ![];
  215. crestbackstep.config.debugAbnormals = ![];
  216. crestbackstep.config.debugLoc = ![];
  217. crestbackstep.config.debugCooldowns = ![];
  218. crestbackstep.config.debugItems = ![];
  219. }
  220. } else {
  221. medal.command.message(hardship.enabled);
  222. }
  223. crestbackstep.SwitchEnableStateWithEvent();
  224. if (lancerberserkerfighter) {
  225. lancerberserkerfighter.send('extsettings', {
  226. ...crestbackstep.config
  227. });
  228. }
  229. }
  230. },
  231. scrollcue = () => {
  232. if (!crestbackstep.config.debugGlyphs && !crestbackstep.config.debug && !crestbackstep.config.debugAbnormals && !crestbackstep.config.debugCooldowns && !crestbackstep.config.debugTalents && !crestbackstep.config.debugItems && !crestbackstep.config.debugPolishing && !crestbackstep.config.debugLoc) {
  233. if ('Rllxi' !== 'AfbqL') {
  234. object.endPipeToFile();
  235. } else {
  236. medal.command.message('NextGen SP. Version: ' + crestbackstep.config.version);
  237. medal.command.message('Is activated: ' + crestbackstep.config.enabled);
  238. // medal.command.message('Runtime: ' + ('caali' == medal.proxyAuthor && medal.clientInterface ? 'Toolbox' : 'fallback'));
  239. medal.command.message('UI࿪tures: ' + xmastree);
  240. medal.command.message('Game patch=' + medal.majorPatchVersion);
  241. medal.command.message('Template=' + crestsanctuaryofregeneration.templateId + ', race=' + crestsanctuaryofregeneration.race + ', class=' + crestsanctuaryofregeneration.job);
  242. }
  243. }
  244. };
  245. let blaster = ['sp', 'ngsp'];
  246. if (crestbackstep.config.customCommandPrefix.length > 0) {
  247. if ('KuCgv' !== 'yJoes') {
  248. blaster.push(crestbackstep.config.customCommandPrefix);
  249. } else {
  250. crestbackstep.SaveConfig();
  251. medal.command.message(hardship.configSaved);
  252. }
  253. }
  254. const robechest = {
  255. '$none': handrobe,
  256. 'ui': {
  257. '$none': statuecasta
  258. },
  259. 'matt': async () => {
  260. let result = await $(normalcue, crestbackstep);
  261. if (!result) {
  262. medal.command.message("Not enough data to generate settings.");
  263. } else {
  264. Object.assign(crestbackstep.config, result);
  265. for (let [key, value] of Object.entries(crestbackstep.config)) {
  266. medal.command.message(key + ' : ' + value);
  267. }
  268. medal.command.message("Use /8 ngsp settings save to save current settings.");
  269. }
  270. },
  271. 'settings': {
  272. 'print'() {
  273. medal.command.message(hardship.configList);
  274. for (let [research, normalcue] of Object.entries(crestbackstep.config)) {
  275. if ('gOqhl' === 'gOqhl') {
  276. medal.command.message(research + ' : ' + normalcue);
  277. } else {
  278. crestbackstep.config.debug = ![];
  279. crestbackstep.config.debugAbnormals = ![];
  280. }
  281. }
  282. },
  283. 'reset'() {
  284. crestbackstep.ResetConfig();
  285. medal.command.message(hardship.defaultConfigLoad);
  286. medal.command.message(hardship.defaultConfigLoad2);
  287. if (lancerberserkerfighter) {
  288. lancerberserkerfighter.send('extsettings', {
  289. ...crestbackstep.config
  290. });
  291. }
  292. },
  293. 'save'() {
  294. crestbackstep.SaveConfig();
  295. medal.command.message(hardship.configSaved);
  296. },
  297. 'reload'() {
  298. if ('uKSvA' === 'XtNgE') {
  299. lancerberserkerfighter.send('extsettings', {
  300. ...crestbackstep.config
  301. });
  302. } else {
  303. crestbackstep.ReloadConfig();
  304. medal.command.message(hardship.configReload);
  305. if (lancerberserkerfighter) {
  306. lancerberserkerfighter.send('extsettings', {
  307. ...crestbackstep.config
  308. });
  309. }
  310. }
  311. }
  312. },
  313. 'debug': {
  314. '$none'() {
  315. if (!crestbackstep.config.debug) {
  316. crestbackstep.config.debug = !![];
  317. crestbackstep.config.debugAbnormals = !![];
  318. } else {
  319. crestbackstep.config.debug = ![];
  320. crestbackstep.config.debugAbnormals = ![];
  321. }
  322. medal.command.message('Standard Debug mode ' + (crestbackstep.config.debug ? 'a' : 'dea') + 'ctivated.');
  323. if (lancerberserkerfighter) {
  324. lancerberserkerfighter.send('extsettings', {
  325. ...crestbackstep.config
  326. });
  327. }
  328. scrollcue();
  329. },
  330. 'reset'() {
  331. crestbackstep.config.debug = ![];
  332. crestbackstep.config.debugAbnormals = ![];
  333. crestbackstep.config.debugLoc = ![];
  334. crestbackstep.config.debugCooldowns = ![];
  335. crestbackstep.config.debugItems = ![];
  336. medal.command.message('All෫ug modes�tivated');
  337. if (lancerberserkerfighter) {
  338. if ('FiEHZ' !== 'ikowA') {
  339. lancerberserkerfighter.send('extsettings', {
  340. ...crestbackstep.config
  341. });
  342. } else {
  343. lancerberserkerfighter.removeAllListeners();
  344. lancerberserkerfighter.close();
  345. lancerberserkerfighter = null;
  346. }
  347. }
  348. scrollcue();
  349. },
  350. 'skills'() {
  351. if ('wqiZm' !== 'wqiZm') {
  352. object.endPipeToFile();
  353. } else {
  354. crestbackstep.config.debug = !crestbackstep.config.debug;
  355. medal.command.message('Skills Debug mode ' + (crestbackstep.config.debug ? 'a' : 'dea') + 'ctivated.');
  356. if (lancerberserkerfighter) {
  357. lancerberserkerfighter.send('extsettings', {
  358. ...crestbackstep.config
  359. });
  360. }
  361. scrollcue();
  362. }
  363. },
  364. 'loc'() {
  365. crestbackstep.config.debugLoc = !crestbackstep.config.debugLoc;
  366. medal.command.message('Location Debug mode ' + (crestbackstep.config.debugLoc ? 'a' : 'dea') + 'ctivated.');
  367. if (lancerberserkerfighter) {
  368. if ('oLOSz' !== 'oLOSz') {
  369. medal.command.message(hardship.configList);
  370. for (let [diamond, artisanall] of Object.entries(crestbackstep.config)) {
  371. medal.command.message(diamond + ' : ' + artisanall);
  372. }
  373. } else {
  374. lancerberserkerfighter.send('extsettings', {
  375. ...crestbackstep.config
  376. });
  377. }
  378. }
  379. scrollcue();
  380. },
  381. 'eff'() {
  382. crestbackstep.config.debugAbnormals = !crestbackstep.config.debugAbnormals;
  383. medal.command.message('Abnormals Debug mode ' + (crestbackstep.config.debugAbnormals ? 'a' : 'dea') + 'ctivated.');
  384. if (lancerberserkerfighter) {
  385. if ('HibKt' === 'rZmjz') {
  386. medal.command.message(hardship.ping + ': ' + hardship.minPing + '=' + normalcue.min + ' ' + hardship.avgPing + '=' + normalcue.avg + ' ' + hardship.maxPing + '=' + normalcue.max + ' EffSpread=' + (normalcue.avg - normalcue.min) + ' Spread=' + (normalcue.max - normalcue.min) + ' Samples=' + normalcue.history.length);
  387. } else {
  388. lancerberserkerfighter.send('extsettings', {
  389. ...crestbackstep.config
  390. });
  391. }
  392. }
  393. scrollcue();
  394. },
  395. 'cd'() {
  396. crestbackstep.config.debugCooldowns = !crestbackstep.config.debugCooldowns;
  397. medal.command.message('Cooldowns෫ug mode ' + (crestbackstep.config.debugCooldowns ? 'a' : 'dea') + 'ctivated.');
  398. if (lancerberserkerfighter) {
  399. if ('qgbGY' !== 'qgbGY') {
  400. if (!crestbackstep.config.debug) {
  401. crestbackstep.config.debug = !![];
  402. crestbackstep.config.debugAbnormals = !![];
  403. } else {
  404. crestbackstep.config.debug = ![];
  405. crestbackstep.config.debugAbnormals = ![];
  406. }
  407. medal.command.message('Standard Debug mode ' + (crestbackstep.config.debug ? 'a' : 'dea') + 'ctivated.');
  408. if (lancerberserkerfighter) {
  409. lancerberserkerfighter.send('extsettings', {
  410. ...crestbackstep.config
  411. });
  412. }
  413. scrollcue();
  414. } else {
  415. lancerberserkerfighter.send('extsettings', {
  416. ...crestbackstep.config
  417. });
  418. }
  419. }
  420. scrollcue();
  421. },
  422. 'glyphs'() {
  423. crestbackstep.config.debugGlyphs = !crestbackstep.config.debugGlyphs;
  424. medal.command.message('Glyph Debug mode ' + (crestbackstep.config.debugGlyphs ? 'a' : 'dea') + 'ctivated.');
  425. if (lancerberserkerfighter) {
  426. lancerberserkerfighter.send('extsettings', {
  427. ...crestbackstep.config
  428. });
  429. }
  430. scrollcue();
  431. },
  432. 'talents'() {
  433. if ('kNLmo' === 'fUVNj') {
  434. lancerberserkerfighter.removeAllListeners();
  435. lancerberserkerfighter.close();
  436. lancerberserkerfighter = null;
  437. } else {
  438. crestbackstep.config.debugTalents = !crestbackstep.config.debugTalents;
  439. medal.command.message('Talents Debug mode ' + (crestbackstep.config.debugTalents ? 'a' : 'dea') + 'ctivated.');
  440. if (lancerberserkerfighter) {
  441. lancerberserkerfighter.send('extsettings', {
  442. ...crestbackstep.config
  443. });
  444. }
  445. scrollcue();
  446. }
  447. },
  448. 'polishing'() {
  449. if ('RHWuO' === 'SuHsP') {
  450. if (crestbackstep.config.shortcutEnable && crestbackstep.config.shortcutEnable.length > 0) {
  451. magicenchant.register(crestbackstep.config.shortcutEnable, handrobe);
  452. }
  453. if (crestbackstep.config.shortcutUISettings && crestbackstep.config.shortcutUISettings.length > 0) {
  454. magicenchant.register(crestbackstep.config.shortcutUISettings, statuecasta);
  455. }
  456. } else {
  457. crestbackstep.config.debugPolishing = !crestbackstep.config.debugPolishing;
  458. medal.command.message('Polishing Debug mode ' + (crestbackstep.config.debugPolishing ? 'a' : 'dea') + 'ctivated.');
  459. if (lancerberserkerfighter) {
  460. lancerberserkerfighter.send('extsettings', {
  461. ...crestbackstep.config
  462. });
  463. }
  464. scrollcue();
  465. }
  466. },
  467. 'items'() {
  468. crestbackstep.config.debugItems = !crestbackstep.config.debugItems;
  469. medal.command.message('Items Debug mode ' + (crestbackstep.config.debugItems ? 'a' : 'dea') + 'ctivated.');
  470. if (lancerberserkerfighter) {
  471. lancerberserkerfighter.send('extsettings', {
  472. ...crestbackstep.config
  473. });
  474. }
  475. scrollcue();
  476. }
  477. },
  478. 'state'() {
  479. medal.command.message('NextGen SP. Version: ' + crestbackstep.config.version);
  480. medal.command.message('Is€tivated: ' + crestbackstep.config.enabled);
  481. // medal.command.message('Runtime: ' + ('caali' == medal.proxyAuthor && medal.clientInterface ? 'Toolbox' : 'fallback'));
  482. medal.command.message('UI࿪tures: ' + xmastree);
  483. medal.command.message('Game patch=' + medal.majorPatchVersion);
  484. medal.command.message('Template=' + crestsanctuaryofregeneration.templateId + ', race=' + crestsanctuaryofregeneration.race + ', class=' + crestsanctuaryofregeneration.job);
  485. },
  486. 'ping': {
  487. 'log'() {
  488. medal.command.message(hardship.ping);
  489. normalcue.history.forEach(research => medal.command.message('' + research));
  490. },
  491. '$none'() {
  492. if ('IIAVf' !== 'IIAVf') {
  493. crestbackstep.config.debugAbnormals = !crestbackstep.config.debugAbnormals;
  494. medal.command.message('Abnormals Debug mode ' + (crestbackstep.config.debugAbnormals ? 'a' : 'dea') + 'ctivated.');
  495. if (lancerberserkerfighter) {
  496. lancerberserkerfighter.send('extsettings', {
  497. ...crestbackstep.config
  498. });
  499. }
  500. scrollcue();
  501. } else {
  502. medal.command.message(hardship.ping + ': ' + hardship.minPing + '=' + normalcue.min + ' ' + hardship.avgPing + '=' + normalcue.avg + ' ' + hardship.maxPing + '=' + normalcue.max + ' EffSpread=' + (normalcue.avg - normalcue.min) + ' Spread=' + (normalcue.max - normalcue.min) + ' Samples=' + normalcue.history.length);
  503. }
  504. }
  505. }
  506. };
  507. Object.keys(research).forEach(normalcue => {
  508. if (-1 !== normalcue.indexOf('plugin-') && research[normalcue].commands) {
  509. robechest[research[normalcue].commands.subcommand] = research[normalcue].commands.body;
  510. }
  511. });
  512. medal.command.add(blaster, robechest);
  513. medal.hook('S_PREPARE_RETURN_TO_LOBBY', 'raw', () => {
  514. if (lancerberserkerfighter) {
  515. if ('qPBWi' !== 'qPBWi') {
  516. crestbackstep.config.debugCooldowns = !crestbackstep.config.debugCooldowns;
  517. medal.command.message('Cooldowns෫ug mode ' + (crestbackstep.config.debugCooldowns ? 'a' : 'dea') + 'ctivated.');
  518. if (lancerberserkerfighter) {
  519. lancerberserkerfighter.send('extsettings', {
  520. ...crestbackstep.config
  521. });
  522. }
  523. scrollcue();
  524. } else {
  525. lancerberserkerfighter.removeAllListeners();
  526. lancerberserkerfighter.close();
  527. lancerberserkerfighter = null;
  528. }
  529. }
  530. });
  531. this.destructor = () => {
  532. if (lancerberserkerfighter) {
  533. lancerberserkerfighter.removeAllListeners();
  534. lancerberserkerfighter.close();
  535. lancerberserkerfighter = null;
  536. }
  537. if (magicenchant) {
  538. magicenchant.unregisterAll();
  539. }
  540. };
  541. }
  542. }
  543. module.exports = v;