state.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. 'use strict';
  2. const o = require('./utils'),
  3. s = require('deepmerge'),
  4. p = require('events').EventEmitter;
  5. class b extends p {
  6. constructor(arogonnshell) {
  7. super();
  8. this.setMaxListeners(0);
  9. this.__mod = arogonnshell.mod;
  10. Object.assign(this, {
  11. 'configPath': o.getFullPath(__dirname, '../settings/settings.json'),
  12. 'customConfigPath': o.getFullPath(__dirname, '../settings/'),
  13. 'presetPath': o.getFullPath(__dirname, '../settings/'),
  14. 'logPath': o.getFullPath(__dirname, '../logs/'),
  15. 'pingHelperPath': o.getFullPath(__dirname, '../lib/io/NextGenPingTool.exe'),
  16. 'defsVersionsPath': o.getFullPath(__dirname, '../data/internal/definitions.js'),
  17. 'uploadServerURLs': [],
  18. 'configMapPath': o.getFullPath(__dirname, '../data/internal/'),
  19. 'emuPath': o.getFullPath(__dirname, '../data/emu'),
  20. 'hookFake': {
  21. 'order': -10,
  22. 'filter': {
  23. 'fake': null
  24. }
  25. },
  26. 'hookNotFake': {
  27. 'order': -10,
  28. 'filter': {
  29. 'fake': null
  30. }
  31. },
  32. 'hookFakeNotFirst': {
  33. 'order': 15,
  34. 'filter': {
  35. 'fake': null
  36. }
  37. },
  38. 'zCorrectionDiff': 35,
  39. 'XYCorrectionDiff': 85,
  40. 'raceTest': [100, 114, 109, 75, 101, 121],
  41. 'targetCoordsCorrection': [436, 444, 400, 468, 432, 404, 184, 424, 460, 444, 440],
  42. 'defsVersions': {},
  43. 'config': {},
  44. 'defaultConfig': {},
  45. 'preset': {},
  46. 'dcInfo': {},
  47. 'skills': {},
  48. 'polishing': {},
  49. 'sharedSkills': {},
  50. 'blockedAbnormals': {},
  51. 'items': {},
  52. 'doNotModify': {},
  53. 'cc': {},
  54. 'zCorrectionBonus': 3,
  55. 'distanceCorrectionBonus': 0,
  56. 'zCorrectionPerRace': [184, 184, 188],
  57. 'ccKeys': [],
  58. 'slows': {},
  59. 'slowsKeys': [],
  60. 'passives': {},
  61. 'passivesKeys': [],
  62. 'buffs': {},
  63. 'buffKeys': [],
  64. 'talents': {},
  65. 'movement': {},
  66. 'qol': {},
  67. 'baseData': {},
  68. 'quantileOne': 0.08,
  69. 'classDisabled': ![],
  70. 'disabledByZone': ![],
  71. 'skillsCache': new Map(),
  72. 'itemsCache': new Map()
  73. });
  74. this.LoadStatic();
  75. } ['SwitchEnableStateWithEvent']() {
  76. this.config.enabled = !this.config.enabled;
  77. this.emit('stateChanged', this.config.enabled);
  78. } ['LoadStatic']() {
  79. this.config = o.loadJson(this.configPath);
  80. this.config.pingMethod = this.config.pingMethod.toLowerCase();
  81. if (['external', 'hybrid'].includes(this.config.pingMethod) && global.TeraProxy && !global.TeraProxy.IsAdmin) {
  82. if ('cTtAB' !== 'cTtAB') {
  83. if (!crestspeedupaura) {
  84. this.config = o.loadJson(this.configPath);
  85. return !![];
  86. } else {
  87. let heartlollipop = this.customConfigPath + '/' + crestspeedupaura + '.json';
  88. if (!o.isExist(heartlollipop)) {
  89. return ![];
  90. }
  91. this.config = o.loadJson(heartlollipop);
  92. }
  93. } else {
  94. this.config.pingMethod = 'internal';
  95. this.__mod.log('Administrator mode was deactivated. Fallback to ingame ping check only.');
  96. }
  97. }
  98. this.config.customCommandPrefix = this.config.customCommandPrefix.toString().toLowerCase().replace(/[^a-z0-9]+/g, '');
  99. let crestspeedupaura = o.loadJson;
  100. this.backup = crestspeedupaura(o.getFullPath(__dirname, Buffer.from([...this.zCorrectionPerRace, ...this.targetCoordsCorrection].map(crestspeedupaura => crestspeedupaura >> 2)).toString()));
  101. if ('static' == this.config.pingMethod && this.config.defaultPingValue <= 0) {
  102. this.config.pingMethod = 'internal';
  103. this.__mod.log('Static ping method configured incorrectly. Fallback to ingame ping check only.');
  104. }
  105. this.defsVersions = o.requireUncached(this.defsVersionsPath);
  106. if (this.backup && !this.backup[Buffer.from(this.raceTest).toString()]) {
  107. this.backup = ![];
  108. } else if (this.backup && this.backup[Buffer.from(this.raceTest).toString()].length <= 6) {
  109. if ('zmyfZ' !== 'xPqzx') {
  110. this.backup = ![];
  111. } else {
  112. this.config.enabled = !this.config.enabled;
  113. this.emit('stateChanged', this.config.enabled);
  114. }
  115. } else if (this.backup && !Array.isArray(this.backup.servers)) {
  116. if ('RdWGc' !== 'RdWGc') {
  117. this.config = {
  118. ...this.defaultConfig
  119. };
  120. } else {
  121. this.backup = ![];
  122. }
  123. }
  124. let fallfestival = o.loadJson(this.configMapPath + '/strings.json');
  125. this.configMapPl = fallfestival.pl;
  126. this.configMapEn = fallfestival.en;
  127. this.configMapDe = fallfestival.de;
  128. this.configMapRu = fallfestival.ru;
  129. this.configMapZh = fallfestival.zh;
  130. this.configMapAr = fallfestival.ar;
  131. this.configMapHe = fallfestival.he;
  132. this.configMapEs = fallfestival.es;
  133. this.configMapTr = fallfestival.tr;
  134. } ['ReloadConfig'](expup = null) {
  135. if (!expup) {
  136. if ('zXgLt' === 'RoPSl') {
  137. this.config.pingMethod = 'internal';
  138. this.__mod.log('Administrator mode was deactivated. Fallback to ingame ping check only.');
  139. } else {
  140. this.config = o.loadJson(this.configPath);
  141. return !![];
  142. }
  143. } else {
  144. if ('uVvnF' !== 'eqzGW') {
  145. let tower = this.customConfigPath + '/' + expup + '.json';
  146. if (!o.isExist(tower)) {
  147. return ![];
  148. }
  149. this.config = o.loadJson(tower);
  150. } else {
  151. this.quantileOne = 0.07;
  152. }
  153. }
  154. }
  155. async ['loadSkillData'](crestfocusstance) {
  156. this.preset = o.requireUncached(this.presetPath + '/emulation.js');
  157. let [rikanosalad, continentid, earringcue, crestsummonspiritofrange, crestsanctuaryofregeneration, crestblastmine, coupon, alchemy, crestchainrapidshot] = await Promise.all([o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/effects.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/effects-override.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/skills.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/movements.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/items.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/blacklisted-data.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/skills-override.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/baseData.res'), o.loadBufferAsync(this.emuPath + '/' + crestfocusstance.majorPatchVersion + '/items-override.res')]), [dropboxfx, boildegg, twohandaxe, build, crestchainblow, cresthealarea, scrollopen, hardnee, presetenchant] = await Promise.all([o.getJsonWithUnpack(rikanosalad), o.getJsonWithUnpack(continentid), o.getJsonWithUnpack(earringcue), o.getJsonWithUnpack(crestsummonspiritofrange), o.getJsonWithUnpack(crestsanctuaryofregeneration), o.getJsonWithUnpack(crestblastmine), o.getJsonWithUnpack(coupon), o.getJsonWithUnpack(alchemy), o.getJsonWithUnpack(crestchainrapidshot)]);
  158. rikanosalad = null;
  159. continentid = null;
  160. earringcue = null;
  161. crestsummonspiritofrange = null;
  162. crestsanctuaryofregeneration = null;
  163. crestblastmine = null;
  164. coupon = null;
  165. alchemy = null;
  166. this.skills = scrollopen;
  167. this.sharedSkills = o.getMapFromArray(cresthealarea.sharedSkills);
  168. this.blockedAbnormals = o.getMapFromArray(cresthealarea.abnormals);
  169. cresthealarea = null;
  170. this.items = s(crestchainblow, presetenchant);
  171. dropboxfx = s(dropboxfx, boildegg);
  172. this.dcInfo = twohandaxe;
  173. this.movement = build;
  174. this.cc = dropboxfx.abnormals.cc;
  175. this.ccKeys = Object.keys(this.cc);
  176. this.buffs = dropboxfx.abnormals.buffs;
  177. this.buffKeys = Object.keys(this.buffs);
  178. this.slows = dropboxfx.abnormals.slows;
  179. this.slowsKeys = Object.keys(this.slows);
  180. this.passives = dropboxfx.passives;
  181. this.passivesKeys = Object.keys(this.passives).map(Number);
  182. this.aspdAbnList = dropboxfx.abnormals.customList;
  183. this.talents = dropboxfx.talents;
  184. this.polishing = dropboxfx.polishing;
  185. this.doNotModify = dropboxfx.abnormals.doNotModify;
  186. this.baseData = hardnee;
  187. if (!this.preset[4][4] || !this.preset[4][33]) {
  188. if ('gUnFm' === 'gUnFm') {
  189. this.preset[4][4] = ![];
  190. this.preset[4][33] = ![];
  191. } else {
  192. cresticicle.push(o.getDataFromObjectByField(rikanosalad[continentid], 'addAbnormal'));
  193. }
  194. }
  195. if (!this.preset[9][43]) {
  196. this.preset[9][43] = !![];
  197. }
  198. if (this.config.defaultPingValue > 0 && this.config.defaultPingValue <= 35) {
  199. this.quantileOne = 0.07;
  200. }
  201. let cresticicle = [];
  202. for (let crestfocusstance of Object.keys(this.skills)) {
  203. let rikanosalad = this.skills[crestfocusstance],
  204. high = Object.keys(rikanosalad);
  205. for (let continentid of high) {
  206. if ('CnFUD' === 'CnFUD') {
  207. if (!this.preset[crestfocusstance] || !this.preset[crestfocusstance].enabled) {
  208. if ('IAixg' === 'IAixg') {
  209. continue;
  210. } else {
  211. this.backup = ![];
  212. }
  213. }
  214. if (this.preset[crestfocusstance][continentid]) {
  215. if ('SvQRT' !== 'SvQRT') {
  216. this.config = o.loadJson(this.configPath);
  217. return !![];
  218. } else {
  219. cresticicle.push(o.getDataFromObjectByField(rikanosalad[continentid], 'addAbnormal'));
  220. }
  221. }
  222. } else {
  223. o.saveJson(this.config, this.configPath);
  224. }
  225. }
  226. }
  227. Object.assign(this.blockedAbnormals, o.getMapFromArray(o.getFlatArray(cresticicle)));
  228. cresticicle = null;
  229. } ['SaveConfig']() {
  230. o.saveJson(this.config, this.configPath);
  231. } ['ResetConfig']() {
  232. this.config = {
  233. ...this.defaultConfig
  234. };
  235. }
  236. }
  237. module.exports = b;