This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathL2Vision.l2s
602 lines (500 loc) · 16.4 KB
/
L2Vision.l2s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
//======================================================================
//
// L2Vision v0.60
// by zdev, Stan12
//
// Code to report back to L2Vision server component. Note that by
// default even without using this script, the HP/CP/MP values will
// be reported by L2.Net to L2Vision server.
//
// By using this script, you can send more information to L2Vision
// server.
//
// [REQUIRED]
//
// L2Vision now requires DLIB scripts to be installed
// See http://insane-gamers.com/showthread.php/1214-DLIB-v3.4
//
// To use any of the optional components below, you must initialize
// L2Vision.l2s with the following script snippet:
//
// INCLUDE stdlib/Inventory.l2c
// INCLUDE stdlib/Player.l2c
// INCLUDE DLIB/Packets/Classes/Attack.l2c
// INCLUDE DLIB/Packets/Classes/MultiAttack.l2c
// INCLUDE DLIB/Packets/Classes/systemMessage.l2c
//
// CALL_EXTERN L2Vision.l2s L2V_init VOID 1 "#$aaa.bbb.ccc.ddd"
//
// For the "#$aaa.bbb.ccc.ddd" please provide the IP address where
// the L2Vision server component is running. If it's running on the
// same box as L2.Net, then you would provide: "#$127.0.0.1"
//
//
// [OPTIONAL: HILITE ITEMS IN LOOT LIST]
//
// Add to somewhere in your script (must be sent after L2Vision is up):
//
// CALL_EXTERN L2Vision.l2s L2V_send_hilite_item VOID 2 "#$Adena" <setting>
//
// where <setting> = #i0 (off) #i1 (on)
// Adena is an example, replace with another name but remember #$ in front
// call as many times as you want.
// This will make the item show up in white in the list.
//
// [OPTIONAL: MARK ITEMS AS CONSUMABLE]
//
// Add to somewhere in your script (must be sent after L2Vision is up):
//
// CALL_EXTERN L2V_send_consumable_item 2 "#$Soulshot: S-Grade" <setting>
//
// where <setting> = #i0 (off) #i1 (on)
// Soulshot is an example, replace with another name but remember #$ in front
// call as many times as you want
// This will show the item in the list no matter what and also show
// consumption rate next to it.
//
// CALL_EXTERN L2V_send_consumable_item_id 2 1061 <setting>
//
// 1061 is the id of the "Healing Potion", which is not an unique item name,
// so it's not correctly found if referred by name in previous function.
// Replace with another id for other items.
//
// [OPTIONAL: HILITE MOBS IN MOBS LIST]
//
// Add to somewhere in your script (must be sent after L2Vision is up):
//
// CALL_EXTERN L2Vision.l2s L2V_send_hilite_mob VOID 2 "#$Elpy" <setting>
//
// where <setting> = #i0 (off) #i1 (on)
// Elpy is an example, replace with another name but remember #$ in front
// call as many times as you want
// This will make the mob show up in white in the list.
//
// [OPTIONAL: ADD DAMAGE SKILL ID]
//
// Add to somewhere in your script (must be sent after L2Vision is up):
//
// CALL_EXTERN L2Vision.l2s L2V_add_damage_skill VOID 1 "#$Stun Shot"
//
// Stun Shot is an example, replace with another name but remember #$ in front
// call as many times as you want
// This will make the skill show up in damage statistics
//
// [OPTIONAL: ADD DAMAGE LIMITS]
//
// Add to somewhere in your script (must be sent after L2Vision is up):
//
// CALL_EXTERN L2Vision.l2s L2V_set_damage_limit VOID 2 <min> <max>
//
// Damage statistics show all damage that the character gives to mobs.
// Default values 0 and 1000000.
//
// However, it may be necessary to not count damage done by reflect buffs/items.
// Then set <min> number to something higher than your reflect damage but lower than
// hit damage.
//
// Also sometimes the normal damage to mobs is extraordinary high, for example
// average damage could be 1k but few hits of over 100k could appear from time time.
// Such hits skew the average statistics quite significantly: 99 hits of 1000 damage
// followed by a single 100000 hits = 2000 average damage.
// If you require to NOT count such hits, set <max> to something reasonable.
//
//======================================================================
//----------------------------------------------------------------------
FUNCTION L2V_send_char_info VOID
DEFINE BYTEBUFFER pkt 256
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i1
pkt.WRITE_UINT64 CHAR_XP
pkt.WRITE_UINT64 CHAR_SP
pkt.WRITE_UINT32 CHAR_MAX_CP
pkt.WRITE_UINT32 CHAR_CUR_CP
pkt.WRITE_UINT32 CHAR_MAX_HP
pkt.WRITE_UINT32 CHAR_CUR_HP
pkt.WRITE_UINT32 CHAR_MAX_MP
pkt.WRITE_UINT32 CHAR_CUR_MP
pkt.WRITE_INT32 CHAR_X
pkt.WRITE_INT32 CHAR_Y
pkt.WRITE_INT32 CHAR_Z
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_inventory_updated_item 2 item_id count
DEFINE BYTEBUFFER pkt 256
DEFINE STRING name 0
ITEM_GET_NAME name "<&item_id&>"
IF name == "#$-unknown item-"
DEFINE STRING name2 "<&name&> (id=<&item_id&>)"
ELSE
DEFINE STRING name2 "<&name&>"
ENDIF
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i2
pkt.WRITE_UINT64 item_id
pkt.WRITE_UINT64 count
pkt.WRITE_STRING name2
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_killed_mob 1 mob_id
DEFINE BYTEBUFFER pkt 256
DEFINE STRING name 0
IF mob_id > 1000000
mob_id = mob_id - 1000000
ENDIF
NPC_GET_NAME name "<&mob_id&>"
IF name == "#$-unknown npc-"
DEFINE STRING name2 "<&name&> (id=<&mob_id&>)"
ELSE
DEFINE STRING name2 "<&name&>"
ENDIF
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i3
pkt.WRITE_UINT64 mob_id
pkt.WRITE_STRING name2
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_hilite_item 2 name hilite
DEFINE BYTEBUFFER pkt 256
DEFINE INT item_id 0
ITEM_GET_ID item_id "<&name&>"
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i4
pkt.WRITE_UINT64 item_id
pkt.WRITE_UINT32 hilite
pkt.WRITE_STRING name
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_hilite_mob 2 name hilite
DEFINE BYTEBUFFER pkt 256
DEFINE INT mob_id 0
NPC_GET_ID mob_id "<&name&>"
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i5
pkt.WRITE_UINT64 mob_id
pkt.WRITE_UINT32 hilite
pkt.WRITE_STRING name
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_consumable_item 2 name consumable
DEFINE BYTEBUFFER pkt 256
DEFINE INT item_id 0
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i6
pkt.WRITE_UINT64 item_id
pkt.WRITE_UINT32 consumable
pkt.WRITE_STRING name
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_consumable_item_id 2 item_id consumable
DEFINE BYTEBUFFER pkt 256
DEFINE STRING name 0
ITEM_GET_NAME name "<&item_id&>"
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i6
pkt.WRITE_UINT64 item_id
pkt.WRITE_UINT32 consumable
pkt.WRITE_STRING name
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_inventory_added_item 2 item_id count
DEFINE BYTEBUFFER pkt 256
DEFINE STRING name ""
ITEM_GET_NAME name "<&item_id&>"
IF name == "#$-unknown item-"
DEFINE STRING name2 "<&name&> (id=<&item_id&>)"
ELSE
DEFINE STRING name2 "<&name&>"
ENDIF
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i7
pkt.WRITE_UINT64 item_id
pkt.WRITE_UINT64 count
pkt.WRITE_STRING name2
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_inventory_removed_item 2 item_id count
DEFINE BYTEBUFFER pkt 256
DEFINE STRING name ""
ITEM_GET_NAME name "<&item_id&>"
IF name == "#$-unknown item-"
DEFINE STRING name2 "<&name&> (id=<&item_id&>)"
ELSE
DEFINE STRING name2 "<&name&>"
ENDIF
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i8
pkt.WRITE_UINT64 item_id
pkt.WRITE_UINT64 count
pkt.WRITE_STRING name2
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_chat 3 type sender_name message
DEFINE BYTEBUFFER pkt 256
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i9
pkt.WRITE_UINT32 type
pkt.WRITE_STRING sender_name
pkt.WRITE_STRING message
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_visitor 1 name
DEFINE BYTEBUFFER pkt 256
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i10
pkt.WRITE_STRING name
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_visitor_info
DEFINE ARRAYLIST players 0
GET_PLAYERS players
FOREACH p Player players
L2V_send_visitor VOID 1 players.p.NAME
SLEEP 10
NEXTEACH
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_send_full_inventory VOID
DEFINE ARRAYLIST inv 0
GET_INVENTORY inv
FOREACH ii Inventory inv
L2V_send_inventory_updated_item VOID 2 inv.ii.ITEM_ID inv.ii.COUNT
SLEEP 10
NEXTEACH
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_inventory_packet_handler VOID
DEFINE INT pkt_type 0
DEFINE INT count 0
DEFINE INT i 0
DEFINE INT update_type 0
DEFINE INT item_type 0
DEFINE INT obj_id 0
DEFINE INT item_id 0
DEFINE INT ignore 0
DEFINE INT quantity 0
DEFINE INT item_type_2 0
PACKET.RESET_INDEX
PACKET.READ_BYTE pkt_type
PACKET.READ_UINT16 count
DO
PACKET.READ_UINT16 update_type
//PACKET.READ_UINT16 item_type
PACKET.READ_UINT32 obj_id
PACKET.READ_UINT32 item_id
PACKET.READ_UINT32 ignore
PACKET.READ_UINT64 quantity
PACKET.READ_UINT16 item_type_2
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT32 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT32 ignore
PACKET.READ_UINT32 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT32 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
PACKET.READ_UINT16 ignore
// ADDS
IF update_type == 1
L2V_send_inventory_added_item VOID 2 item_id quantity
ENDIF
// UPDATES
IF update_type == 2
L2V_send_inventory_updated_item VOID 2 item_id quantity
ENDIF
// REMOVES
IF update_type == 3
L2V_send_inventory_removed_item VOID 2 item_id quantity
ENDIF
i = i + 1
LOOP i < count
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_mob_death_handler VOID
L2V_send_killed_mob VOID 1 TARGET_TYPEID
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_chat_handler VOID
L2V_send_chat VOID 3 MESSAGETYPE SENDERNAME MESSAGE
RETURN VOID
//----------------------------------------------------------------------
function L2V_attack_packet_handler 0
define sortedlist attackSL 0
call_extern "DLIB\Packets\ReadAttack.l2s" DLIB::Packets::ReadAttack attackSL 1 PACKET
define int type 1
define int damage "<&attackSL.#$defender_damage&>"
if damage > L2V_max_damage
return void
endif
define int skill 0
define string skill_name "Normal attack"
define int flags 0
flags = #i128 & "attackSL.#$attacker_flags"
if flags == 128
type = 0
endif
define string source 0
char_get_name source "<&attackSL.#$attacker_id&>"
if source != CHAR_NAME
return void
endif
flags = #i32 & "attackSL.#$attacker_flags"
if flags == 32
type = 2
endif
DEFINE BYTEBUFFER pkt 256
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i11
pkt.WRITE_UINT32 damage
pkt.WRITE_UINT32 type
pkt.WRITE_UINT32 skill
pkt.WRITE_STRING skill_name
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
return void
//----------------------------------------------------------------------
FUNCTION L2V_add_damage_skill 1 name
DEFINE INT temp 0
SKILL_GET_ID temp "<&name&>"
L2V_skill_ids.add "<&temp&>" "<&temp&>"
RETURN VOID
//----------------------------------------------------------------------
FUNCTION L2V_set_damage_limit 2 min max
L2V_min_damage = min
L2V_max_damage = max
RETURN VOID
//----------------------------------------------------------------------
function L2V_sysmsg_packet_handler 0
define sortedlist msgSL 0
call_extern "DLIB\Packets\ReadSystemMessage.l2s" DLIB::Packets::ReadSystemMessage msgSL 1 PACKET
lock L2V_skill_mutex
if "<&msgSL.#$message_id&>" == 46
define int skill_id2 "<&msgSL.#$data.0.int_buffer0&>"
if "L2V_skill_ids.contains_key <&skill_id2&>" == true
L2V_skill_id = skill_id2
skill_get_name L2V_skill_name "<&msgSL.#$data.0.int_buffer0&>" "<&msgSL.#$data.0.int_buffer1&>"
endif
endif
if "<&msgSL.#$message_id&>" == 2266
if L2V_skill_id != 0
L2V_skill_crit = 1
endif
endif
if "<&msgSL.#$message_id&>" == 2261
if L2V_skill_id != 0
define int type 1
if L2V_skill_crit == 1
type = 2
endif
define int damage "<&msgSL.#$data.2.int_buffer0&>"
if (damage < L2V_min_damage) || (damage > L2V_max_damage)
unlock L2V_skill_mutex
return void
endif
DEFINE BYTEBUFFER pkt 256
pkt.RESET_INDEX
pkt.WRITE_UINT32 #i98765
pkt.WRITE_UINT32 #i11
pkt.WRITE_UINT32 damage
pkt.WRITE_UINT32 type
pkt.WRITE_UINT32 L2V_skill_id
pkt.WRITE_STRING L2V_skill_name
pkt.TRIM_TO_INDEX
pkt.RESET_INDEX
UDP_SENDBB pkt
endif
L2V_skill_id = 0
L2V_skill_crit = 0
endif
unlock L2V_skill_mutex
return void
//----------------------------------------------------------------------
FUNCTION L2V_reporter_thread VOID
DO
L2V_send_char_info
L2V_send_visitor_info
SLEEP 10000
LOOP ZERO == ZERO
RETURN VOID
//----------------------------------------------------------------------
// Listener Initialization
FUNCTION L2V_init 1 listener_ip
include Stdlib/Inventory.l2c
include Stdlib/Player.l2c
include DLIB/Modules/Classes/DlibModule.l2c
include DLIB/Packets/Classes/Attack.l2c
include DLIB/Packets/Classes/MultiAttack.l2c
include DLIB/Packets/Classes/systemMessage.l2c
DEFINE_GLOBAL STRING _listener_ip ""
_listener_ip = listener_ip
L2V_send_char_info
L2V_send_full_inventory
THREAD L2V_reporter_thread
SET_EVENT "<&SCRIPTEVENT_SERVERPACKET&>" "<&SYSTEM_CURRENTFILE&>" L2V_inventory_packet_handler 33
SET_EVENT "<&SCRIPTEVENT_CHAT&>" "<&SYSTEM_CURRENTFILE&>" L2V_chat_handler
SET_EVENT "<&SCRIPTEVENT_TARGETDIE&>" "<&SYSTEM_CURRENTFILE&>" L2V_mob_death_handler
set_event "<&SCRIPTEVENT_SERVERPACKET&>" "<&SYSTEM_CURRENTFILE&>" L2V_attack_packet_handler 51
define_global sortedlist L2V_skill_ids 0
define_global int L2V_skill_id 0
define_global string L2V_skill_name 0
define_global int L2V_skill_crit 0
define_global string L2V_skill_mutex "LOCK"
define_global int L2V_min_damage 0
define_global int L2V_max_damage 1000000
set_event "<&SCRIPTEVENT_SERVERPACKET&>" "<&SYSTEM_CURRENTFILE&>" L2V_sysmsg_packet_handler 98
RETURN VOID