jitter.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. 'use strict';
  2. class T {
  3. constructor(crestrejuvenation) {
  4. const pigling = crestrejuvenation.mod,
  5. amethyst = crestrejuvenation.me,
  6. petrifactionleaf = crestrejuvenation.defs,
  7. itemboxcue = crestrejuvenation.ping;
  8. this.__utils = crestrejuvenation.utils;
  9. this.__state = crestrejuvenation.state;
  10. this.jittercompEndTime = -1;
  11. this.startedSkillBase = -1;
  12. this.startedSkillTime = 0;
  13. this.awaitFirstStage = ![];
  14. this.lastEmulatedStageTime = 0;
  15. this.lastEmulatedStage = -1;
  16. this.lastEmulatedSkillId = -1;
  17. this.delayNext = 0;
  18. this.avgJitter = 0;
  19. this.maxJitter = 0;
  20. this.jitterHistory = [];
  21. this.jitterHistoryMax = 100;
  22. this.__state.on('stateChanged', () => {
  23. this.cleanup();
  24. });
  25. const ring = {
  26. 350100: !![]
  27. },
  28. optimizeoption = crestrejuvenation => {
  29. if (!this.__state.config.enabled || ring[crestrejuvenation.skill.id] || this.__state.sharedSkills[crestrejuvenation.skill.id]) {
  30. return;
  31. }
  32. if (this.__utils.getSkillBase(crestrejuvenation.skill.id) == this.startedSkillBase && this.awaitFirstStage) {
  33. return;
  34. }
  35. this.jittercompEndTime = -1;
  36. this.startedSkillBase = this.__utils.getSkillBase(crestrejuvenation.skill.id);
  37. this.awaitFirstStage = !![];
  38. this.startedSkillTime = Date.now();
  39. },
  40. fabrication = crestrejuvenation => {
  41. if ('nQcCd' === 'cKszI') {
  42. pigling = Math.round(pigling);
  43. this.jitterHistory.push(pigling);
  44. if (this.jitterHistory.length > this.jitterHistoryMax) {
  45. this.jitterHistory.shift();
  46. }
  47. this.delayNext += pigling;
  48. const bladeknife = this.__utils.getStatsFromArray(this.jitterHistory, 0.1);
  49. this.avgJitter = bladeknife.avgValue;
  50. this.maxJitter = bladeknife.maxValue;
  51. } else {
  52. if (!this.__state.config.enabled || !amethyst.isMe(crestrejuvenation.gameId)) {
  53. return;
  54. }
  55. this.lastEmulatedStageTime = Date.now();
  56. this.lastEmulatedStage = crestrejuvenation.stage;
  57. this.lastEmulatedSkillId = crestrejuvenation.skill.id;
  58. }
  59. },
  60. universaldart = crestrejuvenation => {
  61. if ('VVQPh' !== 'VVQPh') {
  62. if (!this.__state.config.enabled || !amethyst.isMe(crestrejuvenation.gameId)) {
  63. return;
  64. }
  65. this.lastEmulatedStageTime = Date.now();
  66. this.lastEmulatedStage = crestrejuvenation.stage;
  67. this.lastEmulatedSkillId = crestrejuvenation.skill.id;
  68. } else {
  69. if (!this.__state.config.enabled || !amethyst.isMe(crestrejuvenation.gameId)) {
  70. return;
  71. }
  72. let pigling = -1;
  73. if (this.awaitFirstStage && 0 == crestrejuvenation.stage && this.__utils.getSkillBase(crestrejuvenation.skill.id) == this.startedSkillBase) {
  74. this.awaitFirstStage = ![];
  75. pigling = Date.now() - this.startedSkillTime - itemboxcue.min;
  76. } else if (crestrejuvenation.stage == this.lastEmulatedStage && this.lastEmulatedSkillId == crestrejuvenation.skill.id) {
  77. if ('emDic' === 'gsERC') {
  78. if (!this.__state.config.enabled || !amethyst.isMe(crestrejuvenation.gameId)) {
  79. return;
  80. }
  81. if (99 == crestrejuvenation.type) {
  82. this.cleanup();
  83. } else if (0 == crestrejuvenation.type || 1 == crestrejuvenation.type || 10 == crestrejuvenation.type || 51 == crestrejuvenation.type) {
  84. this.jittercompEndTime = Date.now() + this.delayNext;
  85. }
  86. } else {
  87. pigling = Date.now() - this.lastEmulatedStageTime - itemboxcue.min;
  88. }
  89. } else {
  90. if ('mQnnB' === 'mQnnB') {
  91. this.cleanup();
  92. } else {
  93. this.cleanup();
  94. }
  95. }
  96. if (-1 != pigling) {
  97. if ('bAUoQ' === 'bAUoQ') {
  98. pigling = Math.round(pigling);
  99. this.jitterHistory.push(pigling);
  100. if (this.jitterHistory.length > this.jitterHistoryMax) {
  101. this.jitterHistory.shift();
  102. }
  103. this.delayNext += pigling;
  104. const crestrejuvenation = this.__utils.getStatsFromArray(this.jitterHistory, 0.1);
  105. this.avgJitter = crestrejuvenation.avgValue;
  106. this.maxJitter = crestrejuvenation.maxValue;
  107. } else {
  108. this.cleanup();
  109. }
  110. }
  111. }
  112. },
  113. fragment = crestrejuvenation => {
  114. if ('oJyAP' !== 'oJyAP') {
  115. if (!this.__state.config.enabled || ring[crestrejuvenation.skill.id] || this.__state.sharedSkills[crestrejuvenation.skill.id]) {
  116. return;
  117. }
  118. if (this.__utils.getSkillBase(crestrejuvenation.skill.id) == this.startedSkillBase && this.awaitFirstStage) {
  119. return;
  120. }
  121. this.jittercompEndTime = -1;
  122. this.startedSkillBase = this.__utils.getSkillBase(crestrejuvenation.skill.id);
  123. this.awaitFirstStage = !![];
  124. this.startedSkillTime = Date.now();
  125. } else {
  126. if (!this.__state.config.enabled || !amethyst.isMe(crestrejuvenation.gameId)) {
  127. return;
  128. }
  129. if (99 == crestrejuvenation.type) {
  130. this.cleanup();
  131. } else if (0 == crestrejuvenation.type || 1 == crestrejuvenation.type || 10 == crestrejuvenation.type || 51 == crestrejuvenation.type) {
  132. this.jittercompEndTime = Date.now() + this.delayNext;
  133. }
  134. }
  135. };
  136. for (let crestrejuvenation of ['C_START_SKILL', 'C_START_TARGETED_SKILL', 'C_START_COMBO_INSTANT_SKILL', 'C_START_INSTANCE_SKILL', 'C_START_INSTANCE_SKILL_EX', 'C_PRESS_SKILL']) {
  137. if ('Uvzxa' !== 'nZROE') {
  138. pigling.hook(...petrifactionleaf.getVersion(crestrejuvenation), this.__state.hookFakeNotFirst, optimizeoption);
  139. } else {
  140. this.delayNext = 0;
  141. this.jittercompEndTime = -1;
  142. this.lastEmulatedSkillId = -1;
  143. this.lastEmulatedStage = -1;
  144. this.awaitFirstStage = ![];
  145. }
  146. }
  147. pigling.hook(...petrifactionleaf.getVersion('S_ACTION_STAGE'), {
  148. 'order': -11,
  149. 'filter': {
  150. 'fake': !![]
  151. }
  152. }, fabrication);
  153. pigling.hook(...petrifactionleaf.getVersion('S_ACTION_STAGE'), {
  154. 'order': -11,
  155. 'filter': {
  156. 'fake': ![]
  157. }
  158. }, universaldart);
  159. pigling.hook(...petrifactionleaf.getVersion('S_ACTION_END'), {
  160. 'order': 11,
  161. 'filter': {
  162. 'fake': !![]
  163. }
  164. }, fragment);
  165. } ['cleanup']() {
  166. this.delayNext = 0;
  167. this.jittercompEndTime = -1;
  168. this.lastEmulatedSkillId = -1;
  169. this.lastEmulatedStage = -1;
  170. this.awaitFirstStage = ![];
  171. } ['consumeDelay']() {
  172. const revival = -1 != this.jittercompEndTime && Date.now() < this.jittercompEndTime ? Math.max(0, this.jittercompEndTime - Date.now()) : Math.max(0, this.delayNext);
  173. this.cleanup();
  174. return revival;
  175. } ['getState']() {
  176. return this.delayNext;
  177. } ['getMaxState']() {
  178. return this.maxJitter;
  179. }
  180. }
  181. module.exports = T;