31
31
using ClassicUO . Game . GameObjects ;
32
32
using ClassicUO . Game . Managers ;
33
33
using ClassicUO . Renderer ;
34
+ using ClassicUO . IO ;
34
35
using ClassicUO . IO . Resources ;
36
+ using ClassicUO . Utility ;
35
37
using ClassicUO . Utility . Collections ;
36
38
37
39
using Microsoft . Xna . Framework ;
@@ -239,5 +241,128 @@ public void OnCliloc(uint cliloc)
239
241
502637 , //You feel yourself resisting magical energy.
240
242
502638 //You feel yourself resisting magical energy.
241
243
} ;
244
+ //ON PLUGIN SEND
245
+ public void OnPluginSendLog ( Span < byte > buffer , int length )
246
+ {
247
+ if ( ! IsEnabled )
248
+ {
249
+ return ;
250
+ }
251
+
252
+ //NETCLIENT LOGPACKET
253
+ Span < char > span = stackalloc char [ 256 ] ;
254
+ ValueStringBuilder output = new ValueStringBuilder ( span ) ;
255
+ {
256
+ int off = sizeof ( ulong ) + 2 ;
257
+
258
+ output . Append ( ' ' , off ) ;
259
+ output . Append ( string . Format ( "Ticks: {0} | {1} | ID: {2:X2} Length: {3}\n " , Time . Ticks , ( "Assistant -> Server" ) , buffer [ 0 ] , length ) ) ;
260
+
261
+ output . Append ( ' ' , off ) ;
262
+ output . Append ( "0 1 2 3 4 5 6 7 8 9 A B C D E F\n " ) ;
263
+
264
+ output . Append ( ' ' , off ) ;
265
+ output . Append ( "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n " ) ;
266
+
267
+ ulong address = 0 ;
268
+
269
+ for ( int i = 0 ; i < length ; i += 16 , address += 16 )
270
+ {
271
+ output . Append ( $ "{ address : X8} ") ;
272
+
273
+ for ( int j = 0 ; j < 16 ; ++ j )
274
+ {
275
+ if ( ( j % 8 ) == 0 )
276
+ {
277
+ output . Append ( " " ) ;
278
+ }
279
+
280
+ if ( i + j < length )
281
+ {
282
+ output . Append ( $ " { buffer [ i + j ] : X2} ") ;
283
+ }
284
+ else
285
+ {
286
+ output . Append ( " " ) ;
287
+ }
288
+ }
289
+
290
+ output . Append ( " " ) ;
291
+
292
+ for ( int j = 0 ; j < 16 && i + j < length ; ++ j )
293
+ {
294
+ byte c = buffer [ i + j ] ;
295
+
296
+ if ( c >= 0x20 && c < 0x80 )
297
+ {
298
+ output . Append ( ( char ) c ) ;
299
+ }
300
+ else
301
+ {
302
+ output . Append ( '.' ) ;
303
+ }
304
+ }
305
+
306
+ output . Append ( '\n ' ) ;
307
+ }
308
+ output . Append ( '\n ' ) ;
309
+ output . Append ( '\n ' ) ;
310
+
311
+ Console . WriteLine ( output . ToString ( ) ) ;
312
+
313
+ output . Dispose ( ) ;
314
+ }
315
+ }
316
+ public void OnPluginSend ( byte [ ] data , int length )
317
+ {
318
+ if ( ! IsEnabled )
319
+ {
320
+ return ;
321
+ }
322
+
323
+ switch ( data [ 0 ] )
324
+ {
325
+ case 0x06 :
326
+
327
+ StackDataReader buffer = new StackDataReader ( data . AsSpan ( 0 , length ) ) ;
328
+
329
+ //skip first
330
+ //byte type = buffer.ReadUInt8();
331
+ int offset = 1 ;
332
+ buffer . Seek ( offset ) ;
333
+
334
+ //read serial
335
+ uint serial = buffer . ReadUInt32BE ( ) ;
336
+ //Console.WriteLine("serial: " + serial.ToHex());
337
+
338
+ if ( SerialHelper . IsItem ( serial ) )
339
+ {
340
+ Item item = World . Items . Get ( serial ) ;
341
+
342
+ //failsafe
343
+ if ( item == null )
344
+ {
345
+ break ;
346
+ }
347
+
348
+ //Console.WriteLine("item.Graphic" + item.Graphic);
349
+ //Console.WriteLine("item.Name" + item.Name);
350
+
351
+ //curepot = 0x0F07
352
+ //healpot = 0x0F0C
353
+ //refreshpot = 0xF0B
354
+ //str = 0xF09
355
+ //agi = 0xF08
356
+
357
+ if ( item . Graphic == 0x0F07 || item . Graphic == 0x0F0C || item . Graphic == 0xF0B || item . Graphic == 0xF09 || item . Graphic == 0xF08 )
358
+ {
359
+ TriggerByPotMacro ( item . Graphic ) ;
360
+ }
361
+ }
362
+
363
+ break ;
364
+ }
365
+ }
366
+
242
367
}
243
368
}
0 commit comments