@@ -62,217 +62,12 @@ module.exports = function PingCompensationCore(dispatch) {
62
62
enabled = false
63
63
return
64
64
}
65
- < << << << HEAD
66
65
// debug
67
66
if ( option . toLowerCase ( ) == 'debug' ) {
68
67
config . debug = ! config . debug
69
68
command . message ( `Ping Compensation debug ${ config . debug ? 'enabled.' : 'disabled.' } ` )
70
69
return
71
70
}
72
- = === ===
73
- }
74
-
75
- if ( info . type == 'charging' ) {
76
- opts . stage += 1 ;
77
- stageEnd = sendActionStage . bind ( null , opts ) ;
78
- stageEndTime = Date . now ( ) + length ;
79
- stageEndTimeout = setTimeout ( stageEnd , length ) ;
80
- return
81
- }
82
-
83
- stageEnd = sendActionEnd . bind ( null , info . type == 'dash' ? 39 : 0 , opts . distance * opts . distanceMult ) ;
84
- stageEndTime = Date . now ( ) + length ;
85
- stageEndTimeout = setTimeout ( stageEnd , length )
86
- }
87
-
88
- function getServerTimeout ( ) {
89
- return ( ping . min * 2 ) + ( ping . max > 300 ? 125 : ping . max / 2 ) + ( config . skillRetryCount * config . skillRetryMs ) + config . serverTimeout
90
- }
91
-
92
- function clearStage ( ) {
93
- clearTimeout ( serverTimeout ) ;
94
- clearTimeout ( stageEndTimeout )
95
- }
96
-
97
- function refreshStageEnd ( ) {
98
- clearTimeout ( stageEndTimeout ) ;
99
- stageEndTimeout = setTimeout ( stageEnd , stageEndTime - Date . now ( ) )
100
- }
101
-
102
- function grantCharge ( skill , info , stage ) {
103
- let levels = info . chargeLevels ;
104
- dispatch . toClient ( 'S_GRANT_SKILL' , 1 , {
105
- skill : modifyChain ( skill , levels ? levels [ stage ] : 10 + stage )
106
- } )
107
- }
108
-
109
- function sendInstantDash ( location ) {
110
- dispatch . toClient ( 'S_INSTANT_DASH' , 1 , {
111
- source : myChar ( ) ,
112
- unk1 : 0 ,
113
- unk2 : 0 ,
114
- unk3 : 0 ,
115
- x : location . x ,
116
- y : location . y ,
117
- z : location . z ,
118
- w : currentLocation . w
119
- } )
120
- }
121
-
122
- function sendInstantMove ( location ) {
123
- if ( location ) currentLocation = location ;
124
-
125
- dispatch . toClient ( 'S_INSTANT_MOVE' , 1 , {
126
- id : myChar ( ) ,
127
- x : currentLocation . x ,
128
- y : currentLocation . y ,
129
- z : currentLocation . z ,
130
- w : currentLocation . w
131
- } )
132
- }
133
-
134
- function sendActionEnd ( type , distance ) {
135
- clearStage ( ) ;
136
-
137
- if ( ! currentAction ) return ;
138
-
139
- if ( config . debug ) debug ( [ '<* S_ACTION_END' , skillId ( currentAction . skill ) , type || 0 , currentLocation . w + '\xb0' , ( distance || 0 ) + 'u' ] . join ( ' ' ) ) ;
140
-
141
- if ( oopsLocation && ( config . forceClipStrict || ! currentLocation . inAction ) ) sendInstantMove ( oopsLocation ) ;
142
- else movePlayer ( distance ) ;
143
-
144
- if ( canChainVB ) { // In case VB didn't get used on line 670
145
- switchVB = false ;
146
- canChainVB = false ;
147
- if ( config . debug ) debug ( '[Skill Prediction] Chained VB disabled' ) ;
148
- }
149
-
150
- dispatch . toClient ( 'S_ACTION_END' , 2 , {
151
- gameId : myChar ( ) ,
152
- x : currentLocation . x ,
153
- y : currentLocation . y ,
154
- z : currentLocation . z ,
155
- w : currentLocation . w ,
156
- templateId,
157
- skill : currentAction . skill ,
158
- type : type || 0 ,
159
- id : currentAction . id
160
- } ) ;
161
-
162
- if ( currentAction . id == actionNumber ) {
163
- let info = skillInfo ( currentAction . skill ) ;
164
- if ( info ) {
165
- if ( info . consumeAbnormalEnd )
166
- if ( Array . isArray ( info . consumeAbnormalEnd ) )
167
- for ( let id of info . consumeAbnormalEnd )
168
- abnormality . remove ( id )
169
- else
170
- abnormality . remove ( info . consumeAbnormalEnd ) ;
171
-
172
- if ( info . triggerAbnormalEnd )
173
- for ( let id in info . triggerAbnormalEnd ) {
174
- let abnormal = info . triggerAbnormalEnd [ id ] ;
175
-
176
- if ( Array . isArray ( abnormal ) )
177
- abnormality . add ( id , abnormal [ 0 ] , abnormal [ 1 ] ) ;
178
- else
179
- abnormality . add ( id , abnormal , 1 )
180
- }
181
-
182
- if ( info . type == 'dash' ) lastEndLocation = currentLocation
183
- }
184
- } else lastEndedId = currentAction . id ;
185
-
186
- actionNumber ++ ;
187
- if ( actionNumber > 0xffffffff ) actionNumber = 0x80000000 ;
188
-
189
- oopsLocation = currentAction = null ;
190
-
191
- lastEndedTime = Date . now ( )
192
- }
193
-
194
- function sendCannotStartSkill ( skill ) {
195
- dispatch . toClient ( 'S_CANNOT_START_SKILL' , 1 , {
196
- skill
197
- } )
198
- }
199
-
200
- function sendSystemMessage ( type , vars ) {
201
- let message = '@' + sysmsg . maps . get ( dispatch . base . protocolVersion ) . name . get ( type ) ;
202
-
203
- for ( let key in vars ) message += '\v' + key + '\v' + vars [ key ]
204
-
205
- dispatch . toClient ( 'S_SYSTEM_MESSAGE' , 1 , {
206
- message
207
- } )
208
- }
209
-
210
- function updateLocation ( event , inAction , special ) {
211
- event = event || currentAction ;
212
-
213
- currentLocation = special ? {
214
- x : event . x ,
215
- y : event . y ,
216
- z : event . z ,
217
- w : event . w || currentLocation . w , // Should be a skill flag maybe?
218
- inAction
219
- } : {
220
- x : event . x ,
221
- y : event . y ,
222
- z : event . z ,
223
- w : event . w ,
224
- inAction
225
- }
226
- }
227
-
228
- function retry ( cb , count = 1 ) {
229
- if ( count > config . skillRetryCount ) return ;
230
-
231
- setTimeout ( ( ) => {
232
- if ( cb ( ) ) retry ( cb , count + 1 )
233
- } , config . skillRetryMs )
234
- }
235
-
236
- function movePlayer ( distance ) {
237
- if ( distance && ! currentLocation . inAction ) applyDistance ( currentLocation , distance )
238
- }
239
-
240
- function calcDistance ( loc1 , loc2 ) {
241
- return Math . sqrt ( Math . pow ( loc2 . x - loc1 . x , 2 ) + Math . pow ( loc2 . y - loc1 . y , 2 ) )
242
- }
243
-
244
- function applyDistance ( loc , distance ) {
245
- let r = ( loc . w / 0x8000 ) * Math . PI ;
246
-
247
- loc . x += Math . cos ( r ) * distance ;
248
- loc . y += Math . sin ( r ) * distance ;
249
- return loc
250
- }
251
-
252
- // Modifies the chain part (last 2 digits) of a skill ID, preserving flags
253
- function modifyChain ( id , chain ) {
254
- return id - ( ( id & 0x3ffffff ) % 100 ) + chain
255
- }
256
-
257
- function skillId ( id , flagAs ) {
258
- id |= flagAs ;
259
-
260
- let skillFlags = [ 'P' , 'C' , '[?3]' , '[?4]' , '[?5]' , '[?6]' ] ,
261
- flags = '' ;
262
-
263
- for ( let i = 0 , x = id >>> 26 ; x ; i ++ , x >>>= 1 )
264
- if ( x & 1 ) flags += skillFlags [ i ] ;
265
-
266
- id = ( id & 0x3ffffff ) . toString ( ) ;
267
-
268
- switch ( flags ) {
269
- case 'P' :
270
- id = [ id . slice ( 0 , - 4 ) , id . slice ( - 4 , - 2 ) , id . slice ( - 2 ) ] . join ( '-' ) ;
271
- break ;
272
- case 'C' :
273
- id = [ id . slice ( 0 , - 2 ) , id . slice ( - 2 ) ] . join ( '-' ) ;
274
- break
275
- > >>> >>> salty / master
276
71
}
277
72
command . message ( 'Ping Compensation command input missing. Input options are "ping", "on", "off", or "debug".' )
278
73
} )
0 commit comments