-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
skill.c
executable file
·20496 lines (18610 loc) · 676 KB
/
skill.c
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
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#include "../common/cbasetypes.h"
#include "../common/timer.h"
#include "../common/nullpo.h"
#include "../common/malloc.h"
#include "../common/random.h"
#include "../common/showmsg.h"
#include "../common/strlib.h"
#include "../common/utils.h"
#include "../common/ers.h"
#include "map.h"
#include "path.h"
#include "clif.h"
#include "pc.h"
#include "status.h"
#include "skill.h"
#include "pet.h"
#include "homunculus.h"
#include "mercenary.h"
#include "elemental.h"
#include "mob.h"
#include "npc.h"
#include "battle.h"
#include "battleground.h"
#include "party.h"
#include "itemdb.h"
#include "script.h"
#include "intif.h"
#include "log.h"
#include "chrif.h"
#include "guild.h"
#include "date.h"
#include "unit.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#define SKILLUNITTIMER_INTERVAL 100
// ranges reserved for mapping skill ids to skilldb offsets
#define HM_SKILLRANGEMIN 700
#define HM_SKILLRANGEMAX HM_SKILLRANGEMIN + MAX_HOMUNSKILL
#define MC_SKILLRANGEMIN HM_SKILLRANGEMAX + 1
#define MC_SKILLRANGEMAX MC_SKILLRANGEMIN + MAX_MERCSKILL
#define EL_SKILLRANGEMIN MC_SKILLRANGEMAX + 1
#define EL_SKILLRANGEMAX EL_SKILLRANGEMIN + MAX_ELEMENTALSKILL
#define GD_SKILLRANGEMIN EL_SKILLRANGEMAX + 1
#define GD_SKILLRANGEMAX GD_SKILLRANGEMIN + MAX_GUILDSKILL
#if GD_SKILLRANGEMAX > 999
#error GD_SKILLRANGEMAX is greater than 999
#endif
static struct eri *skill_unit_ers = NULL; //For handling skill_unit's [Skotlex]
static struct eri *skill_timer_ers = NULL; //For handling skill_timerskills [Skotlex]
static DBMap* bowling_db = NULL; // int mob_id -> struct mob_data*
DBMap* skillunit_db = NULL; // int id -> struct skill_unit*
/**
* Skill Unit Persistency during endack routes (mostly for songs see bugreport:4574)
*/
DBMap* skillusave_db = NULL; // char_id -> struct skill_usave
struct skill_usave {
uint16 skill_id, skill_lv;
};
struct s_skill_db skill_db[MAX_SKILL_DB];
struct s_skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB];
static unsigned short skill_produce_count;
struct s_skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB];
static unsigned short skill_arrow_count;
struct s_skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB];
unsigned short skill_abra_count;
struct s_skill_improvise_db {
uint16 skill_id;
unsigned short per;//1-10000
};
struct s_skill_improvise_db skill_improvise_db[MAX_SKILL_IMPROVISE_DB];
static unsigned short skill_improvise_count;
#define MAX_SKILL_CHANGEMATERIAL_DB 75
#define MAX_SKILL_CHANGEMATERIAL_SET 3
struct s_skill_changematerial_db {
unsigned short nameid;
unsigned short rate;
unsigned short qty[MAX_SKILL_CHANGEMATERIAL_SET];
unsigned short qty_rate[MAX_SKILL_CHANGEMATERIAL_SET];
};
struct s_skill_changematerial_db skill_changematerial_db[MAX_SKILL_CHANGEMATERIAL_DB];
static unsigned short skill_changematerial_count;
//Warlock
struct s_skill_spellbook_db skill_spellbook_db[MAX_SKILL_SPELLBOOK_DB];
unsigned short skill_spellbook_count;
//Guillotine Cross
struct s_skill_magicmushroom_db skill_magicmushroom_db[MAX_SKILL_MAGICMUSHROOM_DB];
unsigned short skill_magicmushroom_count;
struct s_skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT];
int firewall_unit_pos;
int icewall_unit_pos;
int earthstrain_unit_pos;
int firerain_unit_pos;
int wallofthorn_unit_pos;
struct s_skill_nounit_layout skill_nounit_layout[MAX_SKILL_UNIT_LAYOUT2];
int overbrand_nounit_pos;
int overbrand_brandish_nounit_pos;
static char dir_ka = -1; // Holds temporary direction to the target for SR_KNUCKLEARROW
//early declaration
int skill_block_check(struct block_list *bl, enum sc_type type, uint16 skill_id);
static int skill_check_unit_range (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv);
static int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv, bool isNearNPC);
static int skill_destroy_trap( struct block_list *bl, va_list ap );
static int skill_check_condition_mob_master_sub (struct block_list *bl, va_list ap);
static bool skill_check_condition_sc_required(struct map_session_data *sd, unsigned short skill_id, struct skill_condition *require);
//Since only mob-casted splash skills can hit ice-walls
static inline int splash_target(struct block_list* bl) {
#ifndef RENEWAL
return ( bl->type == BL_MOB ) ? BL_SKILL|BL_CHAR : BL_CHAR;
#else // Some skills can now hit ground skills(traps, ice wall & etc.)
return BL_SKILL|BL_CHAR;
#endif
}
/// Returns the id of the skill, or 0 if not found.
int skill_name2id(const char* name) {
if( name == NULL )
return 0;
return strdb_iget(skilldb_name2id, name);
}
/// Maps skill ids to skill db offsets.
/// Returns the skill's array index, or 0 (Unknown Skill).
int skill_get_index( uint16 skill_id ) {
// avoid ranges reserved for mapping guild/homun/mercenary skills
if( (skill_id >= GD_SKILLRANGEMIN && skill_id <= GD_SKILLRANGEMAX)
|| (skill_id >= HM_SKILLRANGEMIN && skill_id <= HM_SKILLRANGEMAX)
|| (skill_id >= MC_SKILLRANGEMIN && skill_id <= MC_SKILLRANGEMAX)
|| (skill_id >= EL_SKILLRANGEMIN && skill_id <= EL_SKILLRANGEMAX) )
return 0;
// map skill id to skill db index
if( skill_id >= GD_SKILLBASE )
skill_id = GD_SKILLRANGEMIN + skill_id - GD_SKILLBASE;
else if( skill_id >= EL_SKILLBASE )
skill_id = EL_SKILLRANGEMIN + skill_id - EL_SKILLBASE;
else if( skill_id >= MC_SKILLBASE )
skill_id = MC_SKILLRANGEMIN + skill_id - MC_SKILLBASE;
else if( skill_id >= HM_SKILLBASE )
skill_id = HM_SKILLRANGEMIN + skill_id - HM_SKILLBASE;
// validate result
if( !skill_id || skill_id >= MAX_SKILL_DB )
return 0;
return skill_id;
}
const char* skill_get_name( uint16 skill_id ) {
return skill_db[skill_get_index(skill_id)].name;
}
const char* skill_get_desc( uint16 skill_id ) {
return skill_db[skill_get_index(skill_id)].desc;
}
/// out of bounds error checking [celest]
static void skill_chk(uint16 *skill_id) {
*skill_id = skill_get_index(*skill_id); // checks/adjusts id
}
// checks/adjusts level
static void skill_chk2(uint16 *skill_lv) {
*skill_lv = (*skill_lv < 1) ? 1 : (*skill_lv > MAX_SKILL_LEVEL) ? MAX_SKILL_LEVEL : *skill_lv;
}
// checks/adjusts index. make sure we don't use negative index
static void skill_chk3(int *idx) {
if (*idx < 0) *idx = 0;
}
#define skill_get(var,id) { skill_chk(&id); if(!id) return 0; return var; }
#define skill_get2(var,id,lv) { skill_chk(&id); if (!id) return 0; skill_chk2(&lv); return var; }
#define skill_get3(var,id,x) { skill_chk(&id); if (!id) return 0; skill_chk3(&x); return var; }
// Skill DB
int skill_get_hit( uint16 skill_id ) { skill_get (skill_db[skill_id].hit, skill_id); }
int skill_get_inf( uint16 skill_id ) { skill_get (skill_db[skill_id].inf, skill_id); }
int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill_db[skill_id].element[skill_lv-1], skill_id, skill_lv); }
int skill_get_nk( uint16 skill_id ) { skill_get (skill_db[skill_id].nk, skill_id); }
int skill_get_max( uint16 skill_id ) { skill_get (skill_db[skill_id].max, skill_id); }
int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill_db[skill_id].range[skill_lv-1], skill_id, skill_lv); }
int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill_db[skill_id].splash[skill_lv-1]>=0?skill_db[skill_id].splash[skill_lv-1]:AREA_SIZE), skill_id, skill_lv); }
int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].num[skill_lv-1], skill_id, skill_lv); }
int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cast[skill_lv-1], skill_id, skill_lv); }
int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].delay[skill_lv-1], skill_id, skill_lv); }
int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].walkdelay[skill_lv-1], skill_id, skill_lv); }
int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time[skill_lv-1], skill_id, skill_lv); }
int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].upkeep_time2[skill_lv-1], skill_id, skill_lv); }
int skill_get_castdef( uint16 skill_id ) { skill_get (skill_db[skill_id].cast_def_rate, skill_id); }
int skill_get_inf2( uint16 skill_id ) { skill_get (skill_db[skill_id].inf2, skill_id); }
int skill_get_inf3( uint16 skill_id ) { skill_get (skill_db[skill_id].inf3, skill_id); }
int skill_get_castcancel( uint16 skill_id ) { skill_get (skill_db[skill_id].castcancel, skill_id); }
int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].maxcount[skill_lv-1], skill_id, skill_lv); }
int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].blewcount[skill_lv-1], skill_id, skill_lv); }
int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].castnodex[skill_lv-1], skill_id, skill_lv); }
int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].delaynodex[skill_lv-1], skill_id, skill_lv); }
int skill_get_nocast ( uint16 skill_id ) { skill_get (skill_db[skill_id].nocast, skill_id); }
int skill_get_type( uint16 skill_id ) { skill_get (skill_db[skill_id].skill_type, skill_id); }
int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get3 (skill_db[skill_id].unit_id[flag], skill_id, flag); }
int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_interval, skill_id); }
int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ){ skill_get2 (skill_db[skill_id].unit_range[skill_lv-1], skill_id, skill_lv); }
int skill_get_unit_target( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_target&BCT_ALL, skill_id); }
int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_target&BL_ALL, skill_id); }
int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill_db[skill_id].unit_flag, skill_id); }
int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].unit_layout_type[skill_lv-1], skill_id, skill_lv); }
int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].cooldown[skill_lv-1], skill_id, skill_lv); }
#ifdef RENEWAL_CAST
int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill_db[skill_id].fixed_cast[skill_lv-1], skill_id, skill_lv); }
#endif
// Skill requirements
int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].require.hp[skill_lv-1], skill_id, skill_lv); }
int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].require.mhp[skill_lv-1], skill_id, skill_lv); }
int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].require.sp[skill_lv-1], skill_id, skill_lv); }
int skill_get_hp_rate( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].require.hp_rate[skill_lv-1], skill_id, skill_lv); }
int skill_get_sp_rate( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].require.sp_rate[skill_lv-1], skill_id, skill_lv); }
int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill_db[skill_id].require.zeny[skill_lv-1], skill_id, skill_lv); }
int skill_get_weapontype( uint16 skill_id ) { skill_get (skill_db[skill_id].require.weapon, skill_id); }
int skill_get_ammotype( uint16 skill_id ) { skill_get (skill_db[skill_id].require.ammo, skill_id); }
int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill_db[skill_id].require.ammo_qty[skill_lv-1], skill_id, skill_lv); }
int skill_get_state( uint16 skill_id ) { skill_get (skill_db[skill_id].require.state, skill_id); }
//int skill_get_status( uint16 skill_id, int idx ) { skill_get3 (skill_db[skill_id].require.status[idx], skill_id, idx); }
int skill_get_status_count( uint16 skill_id ) { skill_get (skill_db[skill_id].require.status_count, skill_id); }
int skill_get_spiritball( uint16 skill_id, uint16 skill_lv ){ skill_get2 (skill_db[skill_id].require.spiritball[skill_lv-1], skill_id, skill_lv); }
int skill_get_itemid( uint16 skill_id, int idx ) { skill_get3 (skill_db[skill_id].require.itemid[idx], skill_id, idx); }
int skill_get_itemqty( uint16 skill_id, int idx ) { skill_get3 (skill_db[skill_id].require.amount[idx], skill_id, idx); }
int skill_get_itemeq( uint16 skill_id, int idx ) { skill_get3 (skill_db[skill_id].require.eqItem[idx], skill_id, idx); }
int skill_tree_get_max(uint16 skill_id, int b_class)
{
int i;
b_class = pc_class2idx(b_class);
ARR_FIND( 0, MAX_SKILL_TREE, i, skill_tree[b_class][i].id == 0 || skill_tree[b_class][i].id == skill_id );
if( i < MAX_SKILL_TREE && skill_tree[b_class][i].id == skill_id )
return skill_tree[b_class][i].max;
else
return skill_get_max(skill_id);
}
int skill_frostjoke_scream(struct block_list *bl,va_list ap);
int skill_attack_area(struct block_list *bl,va_list ap);
struct skill_unit_group *skill_locate_element_field(struct block_list *bl); // [Skotlex]
int skill_graffitiremover(struct block_list *bl, va_list ap); // [Valaris]
int skill_greed(struct block_list *bl, va_list ap);
static void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id);
static int skill_cell_overlap(struct block_list *bl, va_list ap);
static int skill_trap_splash(struct block_list *bl, va_list ap);
struct skill_unit_group_tickset *skill_unitgrouptickset_search(struct block_list *bl,struct skill_unit_group *sg,int tick);
static int skill_unit_onplace(struct skill_unit *src,struct block_list *bl,unsigned int tick);
int skill_unit_onleft(uint16 skill_id, struct block_list *bl,unsigned int tick);
static int skill_unit_effect(struct block_list *bl,va_list ap);
static int skill_bind_trap(struct block_list *bl, va_list ap);
int skill_get_casttype (uint16 skill_id) {
int inf = skill_get_inf(skill_id);
if (inf&(INF_GROUND_SKILL))
return CAST_GROUND;
if (inf&INF_SUPPORT_SKILL)
return CAST_NODAMAGE;
if (inf&INF_SELF_SKILL) {
if(skill_get_inf2(skill_id)&INF2_NO_TARGET_SELF)
return CAST_DAMAGE; //Combo skill.
return CAST_NODAMAGE;
}
if (skill_get_nk(skill_id)&NK_NO_DAMAGE)
return CAST_NODAMAGE;
return CAST_DAMAGE;
}
//Returns actual skill range taking into account attack range and AC_OWL [Skotlex]
int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
int range, inf3=0;
if( bl->type == BL_MOB && battle_config.mob_ai&0x400 )
return 9; //Mobs have a range of 9 regardless of skill used.
range = skill_get_range(skill_id, skill_lv);
if( range < 0 ) {
if( battle_config.use_weapon_skill_range&bl->type )
return status_get_range(bl);
range *=-1;
}
inf3 = skill_get_inf3(skill_id);
if(inf3&(INF3_EFF_VULTURE|INF3_EFF_SNAKEEYE) ){
if( bl->type == BL_PC ) {
if(inf3&INF3_EFF_VULTURE) range += pc_checkskill((TBL_PC*)bl, AC_VULTURE);
// added to allow GS skills to be effected by the range of Snake Eyes [Reddozen]
if(inf3&INF3_EFF_SNAKEEYE) range += pc_checkskill((TBL_PC*)bl, GS_SNAKEEYE);
} else
range += 10; //Assume level 10?
}
if(inf3&(INF3_EFF_SHADOWJUMP|INF3_EFF_RADIUS|INF3_EFF_RESEARCHTRAP) ){
if( bl->type == BL_PC ) {
if(inf3&INF3_EFF_SHADOWJUMP) range = skill_get_range(NJ_SHADOWJUMP,pc_checkskill((TBL_PC*)bl,NJ_SHADOWJUMP));
if(inf3&INF3_EFF_RADIUS) range += pc_checkskill((TBL_PC*)bl, WL_RADIUS);
if(inf3&INF3_EFF_RESEARCHTRAP) range += (1 + pc_checkskill((TBL_PC*)bl, RA_RESEARCHTRAP))/2;
}
}
if( !range && bl->type != BL_PC )
return 9; // Enable non players to use self skills on others. [Skotlex]
return range;
}
/**
* Calculates heal value of skill's effect
* @param src
* @param target
* @param skill_id
* @param skill_lv
* @param heal
* @return modified heal value
*/
int skill_calc_heal(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, bool heal) {
int skill, hp = 0;
struct map_session_data *sd = BL_CAST(BL_PC, src);
struct map_session_data *tsd = BL_CAST(BL_PC, target);
struct status_change *sc, *tsc;
sc = status_get_sc(src);
tsc = status_get_sc(target);
switch( skill_id ) {
case BA_APPLEIDUN:
#ifdef RENEWAL
hp = 100+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery
#else
hp = 30+5*skill_lv+5*(status_get_vit(src)/10); // HP recovery
#endif
if( sd )
hp += 5*pc_checkskill(sd,BA_MUSICALLESSON);
break;
case PR_SANCTUARY:
hp = (skill_lv>6)?777:skill_lv*100;
break;
case NPC_EVILLAND:
hp = (skill_lv>6)?666:skill_lv*100;
break;
default:
if (skill_lv >= battle_config.max_heal_lv)
return battle_config.max_heal;
#ifdef RENEWAL
/**
* Renewal Heal Formula
* Formula: ( [(Base Level + INT) / 5] x 30 ) x (Heal Level / 10) x (Modifiers) + MATK
*/
hp = (status_get_lv(src) + status_get_int(src)) / 5 * 30 * (skill_id == AB_HIGHNESSHEAL ? ((sd) ? pc_checkskill(sd,AL_HEAL) : skill_get_max(AL_HEAL)) : skill_lv) / 10;
#else
hp = (status_get_lv(src) + status_get_int(src)) / 8 * (4 + ( (skill_id == AB_HIGHNESSHEAL ? ((sd) ? pc_checkskill(sd,AL_HEAL) : skill_get_max(AL_HEAL)) : skill_lv) * 8));
#endif
if (skill_id == AB_HIGHNESSHEAL)
hp = hp * ( 17 + 3 * skill_lv ) / 10;
if( sd && ((skill = pc_checkskill(sd, HP_MEDITATIO)) > 0) )
hp += hp * skill * 2 / 100;
else if( src->type == BL_HOM && (skill = hom_checkskill(((TBL_HOM*)src), HLIF_BRAIN)) > 0 )
hp += hp * skill * 2 / 100;
if( sd && tsd && sd->status.partner_id == tsd->status.char_id && sd->class_&JOBL_SUPER_NOVICE && sd->status.sex == 0 )
hp *= 2;
break;
}
if( (!heal || (target && target->type == BL_MER)) && skill_id != NPC_EVILLAND )
hp >>= 1;
if( sd && (skill = pc_skillheal_bonus(sd, skill_id)) )
hp += hp*skill/100;
if( tsd && (skill = pc_skillheal2_bonus(tsd, skill_id)) )
hp += hp*skill/100;
if( sc && sc->data[SC_OFFERTORIUM] && (skill_id == AB_HIGHNESSHEAL || skill_id == AB_CHEAL ||
skill_id == PR_SANCTUARY || skill_id == AL_HEAL) )
hp += hp * sc->data[SC_OFFERTORIUM]->val2 / 100;
if( tsc && tsc->count ) {
if( heal && tsc->data[SC_CRITICALWOUND] ) //Critical Wound has no effect on offensive heal. [Inkfish]
hp -= hp * tsc->data[SC_CRITICALWOUND]->val2 / 100;
if( heal && tsc->data[SC_DEATHHURT] )
hp -= hp * 20/100;
if( tsc->data[SC_INCHEALRATE] && skill_id != NPC_EVILLAND && skill_id != BA_APPLEIDUN )
hp += hp * tsc->data[SC_INCHEALRATE]->val1 / 100; //Only affects Heal, Sanctuary and PotionPitcher.(like bHealPower) [Inkfish]
if( tsc->data[SC_WATER_INSIGNIA] && tsc->data[SC_WATER_INSIGNIA]->val1 == 2)
hp += hp / 10;
}
#ifdef RENEWAL
// MATK part of the RE heal formula [malufett]
// Note: in this part matk bonuses from items or skills are not applied
switch( skill_id ) {
case BA_APPLEIDUN: case PR_SANCTUARY:
case NPC_EVILLAND: break;
default:
{
struct status_data *status = status_get_status_data(src);
int min, max;
min = max = status_base_matk(status, status_get_lv(src));
if( status->rhw.matk > 0 ){
int wMatk, variance;
wMatk = status->rhw.matk;
variance = wMatk * status->rhw.wlv / 10;
min += wMatk - variance;
max += wMatk + variance;
}
if( sc && sc->data[SC_RECOGNIZEDSPELL] )
min = max;
if( sd && sd->right_weapon.overrefine > 0 ){
min++;
max += sd->right_weapon.overrefine - 1;
}
if(max > min)
hp += min+rnd()%(max-min);
else
hp += min;
}
}
#endif
return hp;
}
/**
* Making Plagiarism and Reproduce check their own function
* Previous prevention for NPC skills, Wedding skills, and INF3_DIS_PLAGIA are removed since we use skill_copyable_db.txt [Cydh]
* @param sd: Player who will copy the skill
* @param skill_id: Target skill
* @return 0 - Cannot be copied; 1 - Can be copied by Plagiarism 2 - Can be copied by Reproduce
* @author Aru - for previous check; Jobbie for class restriction idea; Cydh expands the copyable skill
*/
static char skill_isCopyable(struct map_session_data *sd, uint16 skill_id) {
uint16 idx = skill_get_index(skill_id);
// Only copy skill that player doesn't have or the skill is old clone
if (sd->status.skill[idx].id != 0 && sd->status.skill[idx].flag != SKILL_FLAG_PLAGIARIZED)
return 0;
// Check if the skill is copyable by class
if (!pc_has_permission(sd,PC_PERM_ALL_SKILL)) {
uint16 job_allowed = skill_db[idx].copyable.joballowed;
while (1) {
if (job_allowed&0x01 && sd->status.class_ == JOB_ROGUE) break;
if (job_allowed&0x02 && sd->status.class_ == JOB_STALKER) break;
if (job_allowed&0x04 && sd->status.class_ == JOB_SHADOW_CHASER) break;
if (job_allowed&0x08 && sd->status.class_ == JOB_SHADOW_CHASER_T) break;
if (job_allowed&0x10 && sd->status.class_ == JOB_BABY_ROGUE) break;
if (job_allowed&0x20 && sd->status.class_ == JOB_BABY_CHASER) break;
return 0;
}
}
//Plagiarism only able to copy skill while SC_PRESERVE is not active and skill is copyable by Plagiarism
if (skill_db[idx].copyable.option&1 && pc_checkskill(sd,RG_PLAGIARISM) && !sd->sc.data[SC_PRESERVE])
return 1;
//Reproduce can copy skill if SC__REPRODUCE is active and the skill is copyable by Reproduce
if (skill_db[idx].copyable.option&2 && pc_checkskill(sd,SC_REPRODUCE) && &sd->sc && sd->sc.data[SC__REPRODUCE] && sd->sc.data[SC__REPRODUCE]->val1)
return 2;
return 0;
}
/**
* Check if the skill is ok to cast and when.
* Done before check_condition_begin, requirement
* @param skill_id: Skill ID that casted
* @param sd: Player who casted
* @return true: Skill cannot be used, false: otherwise
* @author [MouseJstr]
*/
bool skill_isNotOk(uint16 skill_id, struct map_session_data *sd)
{
int16 idx,m;
nullpo_retr(1,sd);
m = sd->bl.m;
idx = skill_get_index(skill_id);
if (idx == 0)
return true; // invalid skill id
if (pc_has_permission(sd,PC_PERM_SKILL_UNCONDITIONAL))
return false; // can do any damn thing they want
if (skill_id == AL_TELEPORT && sd->skillitem == skill_id && sd->skillitemlv > 2)
return false; // Teleport lv 3 bypasses this check.[Inkfish]
if (map[m].flag.noskill)
return true;
// Epoque:
// This code will compare the player's attack motion value which is influenced by ASPD before
// allowing a skill to be cast. This is to prevent no-delay ACT files from spamming skills such as
// AC_DOUBLE which do not have a skill delay and are not regarded in terms of attack motion.
if (!sd->state.autocast && sd->skillitem != skill_id && sd->canskill_tick &&
DIFF_TICK(gettick(),sd->canskill_tick) < (sd->battle_status.amotion * (battle_config.skill_amotion_leniency) / 100))
{// attempted to cast a skill before the attack motion has finished
return true;
}
if (skill_blockpc_get(sd, skill_id) != -1){
clif_skill_fail(sd,skill_id,USESKILL_FAIL_SKILLINTERVAL,0);
return true;
}
/**
* It has been confirmed on a official server (thanks to Yommy) that item-cast skills bypass all the restrictions above
* Also, without this check, an exploit where an item casting + healing (or any other kind buff) isn't deleted after used on a restricted map
*/
if( sd->skillitem == skill_id )
return false;
// Check skill restrictions [Celest]
if( (!map_flag_vs(m) && skill_get_nocast (skill_id) & 1) ||
(map[m].flag.pvp && skill_get_nocast (skill_id) & 2) ||
(map_flag_gvg(m) && skill_get_nocast (skill_id) & 4) ||
(map[m].flag.battleground && skill_get_nocast (skill_id) & 8) ||
(map[m].flag.restricted && map[m].zone && skill_get_nocast (skill_id) & (8*map[m].zone)) ){
clif_msg(sd, SKILL_CANT_USE_AREA); // This skill cannot be used within this area
return true;
}
if( &sd->sc && sd->sc.data[SC_ALL_RIDING] )
return true; //You can't use skills while in the new mounts (The client doesn't let you, this is to make cheat-safe)
switch (skill_id) {
case AL_WARP:
case RETURN_TO_ELDICASTES:
case ALL_GUARDIAN_RECALL:
case ECLAGE_RECALL:
if(map[m].flag.nowarp) {
clif_skill_teleportmessage(sd,0);
return true;
}
return false;
case AL_TELEPORT:
case SC_FATALMENACE:
case SC_DIMENSIONDOOR:
case ALL_ODINS_RECALL:
if(map[m].flag.noteleport) {
clif_skill_teleportmessage(sd,0);
return true;
}
return false; // gonna be checked in 'skill_castend_nodamage_id'
case WE_CALLPARTNER:
case WE_CALLPARENT:
case WE_CALLBABY:
if (map[m].flag.nomemo) {
clif_skill_teleportmessage(sd,1);
return true;
}
break;
case MC_VENDING:
case ALL_BUYING_STORE:
if( map[sd->bl.m].flag.novending ) {
clif_displaymessage (sd->fd, msg_txt(sd,276)); // "You can't open a shop on this map"
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return true;
}
if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) {
clif_displaymessage (sd->fd, msg_txt(sd,204)); // "You can't open a shop on this cell."
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return true;
}
if( npc_isnear(&sd->bl) ) {
// uncomment to send msg_txt.
//char output[150];
//sprintf(output, msg_txt(662), battle_config.min_npc_vendchat_distance);
//clif_displaymessage(sd->fd, output);
clif_skill_fail(sd,skill_id,USESKILL_FAIL_THERE_ARE_NPC_AROUND,0);
return true;
}
case MC_IDENTIFY:
return false; // always allowed
case WZ_ICEWALL:
// noicewall flag [Valaris]
if (map[m].flag.noicewall) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return true;
}
break;
case GC_DARKILLUSION:
if( map_flag_gvg(m) ) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return true;
}
break;
case GD_EMERGENCYCALL:
case GD_ITEMEMERGENCYCALL:
if (
!(battle_config.emergency_call&((agit_flag || agit2_flag)?2:1)) ||
!(battle_config.emergency_call&(map[m].flag.gvg || map[m].flag.gvg_castle?8:4)) ||
(battle_config.emergency_call&16 && map[m].flag.nowarpto && !map[m].flag.gvg_castle)
) {
clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return true;
}
break;
case WM_SIRCLEOFNATURE:
case WM_SOUND_OF_DESTRUCTION:
case WM_LULLABY_DEEPSLEEP:
case WM_SATURDAY_NIGHT_FEVER:
if( !map_flag_vs(m) ) {
clif_skill_teleportmessage(sd,2); // This skill uses this msg instead of skill fails.
return true;
}
break;
}
return false;
}
/**
* Check if the homunculus skill is ok to be processed
* After checking from Homunculus side, also check the master condition
* @param skill_id: Skill ID that casted
* @param hd: Homunculus who casted
* @return true: Skill cannot be used, false: otherwise
*/
bool skill_isNotOk_hom(uint16 skill_id, struct homun_data *hd)
{
uint16 idx = skill_get_index(skill_id);
nullpo_retr(1,hd);
if (idx == 0)
return true; // invalid skill id
if (hd->blockskill[idx] > 0)
return true;
switch(skill_id) {
case MH_LIGHT_OF_REGENE: //must be cordial
if (hom_get_intimacy_grade(hd) != 4) {
if (hd->master)
clif_skill_fail(hd->master, skill_id, USESKILL_FAIL_RELATIONGRADE, 0);
return true;
}
break;
case MH_GOLDENE_FERSE: //cant be used with angriff
if(&hd->sc && hd->sc.data[SC_ANGRIFFS_MODUS]) return true;
break;
case MH_ANGRIFFS_MODUS:
if(&hd->sc && hd->sc.data[SC_GOLDENE_FERSE]) return true;
break;
case MH_TINDER_BREAKER: //must be in grappling mode
if(!&hd->sc
|| !(hd->sc.data[SC_STYLE_CHANGE] && hd->sc.data[SC_STYLE_CHANGE]->val1 == MH_MD_GRAPPLING)
|| !hd->homunculus.spiritball) return true;
break;
case MH_SONIC_CRAW: //must be in fighting mode
if(!&hd->sc
|| !(hd->sc.data[SC_STYLE_CHANGE] && hd->sc.data[SC_STYLE_CHANGE]->val1 == MH_MD_FIGHTING)
|| !hd->homunculus.spiritball) return true;
break;
case MH_SILVERVEIN_RUSH:
if(!&hd->sc
|| !(hd->sc.data[SC_COMBO] && hd->sc.data[SC_COMBO]->val1 == MH_SONIC_CRAW)
|| hd->homunculus.spiritball < 2) return true;
break;
case MH_MIDNIGHT_FRENZY:
if(!&hd->sc
|| !(hd->sc.data[SC_COMBO] && hd->sc.data[SC_COMBO]->val1 == MH_SILVERVEIN_RUSH)
|| !hd->homunculus.spiritball) return true;
break;
case MH_CBC:
if(!&hd->sc
|| !(hd->sc.data[SC_COMBO] && hd->sc.data[SC_COMBO]->val1 == MH_TINDER_BREAKER)
|| hd->homunculus.spiritball < 2) return true;
break;
case MH_EQC:
if(!&hd->sc
|| !(hd->sc.data[SC_COMBO] && hd->sc.data[SC_COMBO]->val1 == MH_CBC)
|| hd->homunculus.spiritball < 3) return true;
break;
}
//Use master's criteria.
return skill_isNotOk(skill_id, hd->master);
}
/**
* Check if the mercenary skill is ok to be processed
* After checking from Homunculus side, also check the master condition
* @param skill_id: Skill ID that casted
* @param md: Mercenary who casted
* @return true: Skill cannot be used, false: otherwise
*/
bool skill_isNotOk_mercenary(uint16 skill_id, struct mercenary_data *md)
{
uint16 idx = skill_get_index(skill_id);
nullpo_retr(1, md);
if (!idx)
return true; // Invalid Skill ID
if (md->blockskill[idx] > 0)
return true;
return skill_isNotOk(skill_id, md->master);
}
/**
* Check if the skill can be casted near NPC or not
* @param src Object who casted
* @param skill_id Skill ID that casted
* @param skill_lv Skill Lv
* @param pos_x Position x of the target
* @param pos_y Position y of the target
* @return true: Skill cannot be used, false: otherwise
* @author [Cydh]
*/
bool skill_isNotOk_npcRange(struct block_list *src, uint16 skill_id, uint16 skill_lv, int pos_x, int pos_y) {
int inf;
if (!src || !skill_get_index(skill_id))
return false;
if (src->type == BL_PC && pc_has_permission(BL_CAST(BL_PC,src),PC_PERM_SKILL_UNCONDITIONAL))
return false;
inf = skill_get_inf(skill_id);
//if self skill
if (inf&INF_SELF_SKILL) {
pos_x = src->x;
pos_y = src->y;
}
if (pos_x <= 0) pos_x = src->x;
if (pos_y <= 0) pos_y = src->y;
return skill_check_unit_range2(src,pos_x,pos_y,skill_id,skill_lv,true);
}
struct s_skill_unit_layout *skill_get_unit_layout(uint16 skill_id, uint16 skill_lv, struct block_list* src, int x, int y)
{
int pos = skill_get_unit_layout_type(skill_id,skill_lv);
uint8 dir;
if (pos < -1 || pos >= MAX_SKILL_UNIT_LAYOUT) {
ShowError("skill_get_unit_layout: unsupported layout type %d for skill %d (level %d)\n", pos, skill_id, skill_lv);
pos = cap_value(pos, 0, MAX_SQUARE_LAYOUT); // cap to nearest square layout
}
if (pos != -1) // simple single-definition layout
return &skill_unit_layout[pos];
dir = (src->x == x && src->y == y) ? 6 : map_calc_dir(src,x,y); // 6 - default aegis direction
if (skill_id == MG_FIREWALL)
return &skill_unit_layout [firewall_unit_pos + dir];
else if (skill_id == WZ_ICEWALL)
return &skill_unit_layout [icewall_unit_pos + dir];
else if( skill_id == WL_EARTHSTRAIN )
return &skill_unit_layout [earthstrain_unit_pos + dir];
else if( skill_id == RL_FIRE_RAIN )
return &skill_unit_layout[firerain_unit_pos + dir];
else if( skill_id == GN_WALLOFTHORN )
return &skill_unit_layout[wallofthorn_unit_pos + dir];
ShowError("skill_get_unit_layout: unknown unit layout for skill %d (level %d)\n", skill_id, skill_lv);
return &skill_unit_layout[0]; // default 1x1 layout
}
struct s_skill_nounit_layout* skill_get_nounit_layout(uint16 skill_id, uint16 skill_lv, struct block_list* src, int x, int y, int dir)
{
if( skill_id == LG_OVERBRAND )
return &skill_nounit_layout[overbrand_nounit_pos + dir];
else if( skill_id == LG_OVERBRAND_BRANDISH )
return &skill_nounit_layout[overbrand_brandish_nounit_pos + dir];
ShowError("skill_get_nounit_layout: unknown no-unit layout for skill %d (level %d)\n", skill_id, skill_lv);
return &skill_nounit_layout[0];
}
/*==========================================
* Add effect to skill when hit succesfully target
*------------------------------------------*/
int skill_additional_effect(struct block_list* src, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int attack_type, int dmg_lv, unsigned int tick)
{
struct map_session_data *sd, *dstsd;
struct mob_data *md, *dstmd;
struct status_data *sstatus, *tstatus;
struct status_change *sc, *tsc;
enum sc_type status;
int skill;
int rate;
int chorusbonus = 0;
nullpo_ret(src);
nullpo_ret(bl);
if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! - celest
if( dmg_lv < ATK_BLOCK ) // Don't apply effect if miss.
return 0;
sd = BL_CAST(BL_PC, src);
md = BL_CAST(BL_MOB, src);
dstsd = BL_CAST(BL_PC, bl);
dstmd = BL_CAST(BL_MOB, bl);
sc = status_get_sc(src);
tsc = status_get_sc(bl);
sstatus = status_get_status_data(src);
tstatus = status_get_status_data(bl);
if (!tsc) //skill additional effect is about adding effects to the target...
//So if the target can't be inflicted with statuses, this is pointless.
return 0;
// Minstrel/Wanderer number check for chorus skills.
// Bonus remains 0 unless 3 or more Minstrels/Wanderers are in the party.
if( sd && sd->status.party_id ) {
chorusbonus = party_foreachsamemap(party_sub_count_class, sd, MAPID_THIRDMASK, MAPID_MINSTRELWANDERER);
if( chorusbonus > 7 )
chorusbonus = 5; // Maximum effect possible from 7 or more Minstrels/Wanderers
else if( chorusbonus > 2 )
chorusbonus = chorusbonus - 2; // Effect bonus from additional Minstrels/Wanderers if not above the max possible.
}
if( sd )
{ // These statuses would be applied anyway even if the damage was blocked by some skills. [Inkfish]
if( skill_id != WS_CARTTERMINATION && skill_id != AM_DEMONSTRATION && skill_id != CR_REFLECTSHIELD && skill_id != MS_REFLECTSHIELD && skill_id != ASC_BREAKER ) {
// Trigger status effects
enum sc_type type;
int i;
for( i = 0; i < ARRAYLENGTH(sd->addeff) && sd->addeff[i].flag; i++ ) {
rate = sd->addeff[i].rate;
if( attack_type&BF_LONG ) // Any ranged physical attack takes status arrows into account (Grimtooth...) [DracoRPG]
rate += sd->addeff[i].arrow_rate;
if( !rate ) continue;
if( (sd->addeff[i].flag&(ATF_WEAPON|ATF_MAGIC|ATF_MISC)) != (ATF_WEAPON|ATF_MAGIC|ATF_MISC) ) {
// Trigger has attack type consideration.
if( (sd->addeff[i].flag&ATF_WEAPON && attack_type&BF_WEAPON) ||
(sd->addeff[i].flag&ATF_MAGIC && attack_type&BF_MAGIC) ||
(sd->addeff[i].flag&ATF_MISC && attack_type&BF_MISC) ) ;
else
continue;
}
if( (sd->addeff[i].flag&(ATF_LONG|ATF_SHORT)) != (ATF_LONG|ATF_SHORT) ) {
// Trigger has range consideration.
if((sd->addeff[i].flag&ATF_LONG && !(attack_type&BF_LONG)) ||
(sd->addeff[i].flag&ATF_SHORT && !(attack_type&BF_SHORT)))
continue; //Range Failed.
}
type = sd->addeff[i].id;
skill = skill_get_time2(status_sc2skill(type),7);
if (sd->addeff[i].flag&ATF_TARGET)
status_change_start(src,bl,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,skill,SCSTART_NONE);
if (sd->addeff[i].flag&ATF_SELF)
status_change_start(src,src,type,rate,7,0,(type == SC_BURNING)?src->id:0,0,skill,SCSTART_NONE);
}
}
if( skill_id ) {
// Trigger status effects on skills
enum sc_type type;
int i;
for( i = 0; i < ARRAYLENGTH(sd->addeff3) && sd->addeff3[i].skill; i++ ) {
if( skill_id != sd->addeff3[i].skill || !sd->addeff3[i].rate )
continue;
type = sd->addeff3[i].id;
skill = skill_get_time2(status_sc2skill(type),7);
if( sd->addeff3[i].target&ATF_TARGET )
status_change_start(src,bl,type,sd->addeff3[i].rate,7,0,0,0,skill,SCSTART_NONE);
if( sd->addeff3[i].target&ATF_SELF )
status_change_start(src,src,type,sd->addeff3[i].rate,7,0,0,0,skill,SCSTART_NONE);
}
//"While the damage can be blocked by Pneuma, the chance to break armor remains", irowiki. [Cydh]
if (dmg_lv == ATK_BLOCK && skill_id == AM_ACIDTERROR) {
sc_start2(src,bl,SC_BLEEDING,(skill_lv*3),skill_lv,src->id,skill_get_time2(skill_id,skill_lv));
if (skill_break_equip(src,bl, EQP_ARMOR, 100*skill_get_time(skill_id,skill_lv), BCT_ENEMY))
clif_emotion(bl,E_OMG);
}
}
}
if( dmg_lv < ATK_DEF ) // no damage, return;
return 0;
switch(skill_id) {
case 0:
{ // Normal attacks (no skill used)
if( attack_type&BF_SKILL )
break; // If a normal attack is a skill, it's splash damage. [Inkfish]
if(sd) {
// Automatic trigger of Blitz Beat
if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (skill=pc_checkskill(sd,HT_BLITZBEAT))>0 &&
rnd()%1000 <= sstatus->luk*10/3+1 ) {
rate=(sd->status.job_level+9)/10;
skill_castend_damage_id(src,bl,HT_BLITZBEAT,(skill<rate)?skill:rate,tick,SD_LEVEL);
}
// Automatic trigger of Warg Strike [Jobbie]
if( pc_iswug(sd) && (sd->status.weapon == W_BOW || sd->status.weapon == W_FIST) && (skill=pc_checkskill(sd,RA_WUGSTRIKE)) > 0 && rnd()%1000 <= sstatus->luk*10/3+1 )
skill_castend_damage_id(src,bl,RA_WUGSTRIKE,skill,tick,0);
// Gank
if(dstmd && sd->status.weapon != W_BOW &&
(skill=pc_checkskill(sd,RG_SNATCHER)) > 0 &&
(skill*15 + 55) + pc_checkskill(sd,TF_STEAL)*10 > rnd()%1000) {
if(pc_steal_item(sd,bl,pc_checkskill(sd,TF_STEAL)))
clif_skill_nodamage(src,bl,TF_STEAL,skill,1);
else
clif_skill_fail(sd,RG_SNATCHER,USESKILL_FAIL_LEVEL,0);
}
// Chance to trigger Taekwon kicks [Dralnu]
if(sc && !sc->data[SC_COMBO]) {
if(sc->data[SC_READYSTORM] &&
sc_start4(src,src,SC_COMBO, 15, TK_STORMKICK,
bl->id, 2, 0,
(2000 - 4*sstatus->agi - 2*sstatus->dex)))
; //Stance triggered
else if(sc->data[SC_READYDOWN] &&
sc_start4(src,src,SC_COMBO, 15, TK_DOWNKICK,
bl->id, 2, 0,
(2000 - 4*sstatus->agi - 2*sstatus->dex)))
; //Stance triggered
else if(sc->data[SC_READYTURN] &&
sc_start4(src,src,SC_COMBO, 15, TK_TURNKICK,
bl->id, 2, 0,
(2000 - 4*sstatus->agi - 2*sstatus->dex)))
; //Stance triggered
else if (sc->data[SC_READYCOUNTER]) { //additional chance from SG_FRIEND [Komurka]
rate = 20;
if (sc->data[SC_SKILLRATE_UP] && sc->data[SC_SKILLRATE_UP]->val1 == TK_COUNTER) {
rate += rate*sc->data[SC_SKILLRATE_UP]->val2/100;
status_change_end(src, SC_SKILLRATE_UP, INVALID_TIMER);
}
sc_start4(src,src, SC_COMBO, rate, TK_COUNTER,
bl->id, 2, 0,
(2000 - 4*sstatus->agi - 2*sstatus->dex))
; //Stance triggered
}
}
if(sc && sc->data[SC_PYROCLASTIC] && ((rnd()%100)<=sc->data[SC_PYROCLASTIC]->val3) )
skill_castend_pos2(src, bl->x, bl->y, BS_HAMMERFALL,sc->data[SC_PYROCLASTIC]->val1, tick, 0);
}
if (sc) {
struct status_change_entry *sce;
// Enchant Poison gives a chance to poison attacked enemies
if((sce=sc->data[SC_ENCPOISON])) //Don't use sc_start since chance comes in 1/10000 rate.
status_change_start(src,bl,SC_POISON,sce->val2, sce->val1,src->id,0,0,
skill_get_time2(AS_ENCHANTPOISON,sce->val1),SCSTART_NONE);
// Enchant Deadly Poison gives a chance to deadly poison attacked enemies
if((sce=sc->data[SC_EDP]))
sc_start4(src,bl,SC_DPOISON,sce->val2, sce->val1,src->id,0,0,
skill_get_time2(ASC_EDP,sce->val1));
}
}
break;
case SM_BASH:
if( sd && skill_lv > 5 && pc_checkskill(sd,SM_FATALBLOW)>0 ){
//BaseChance gets multiplied with BaseLevel/50.0; 500/50 simplifies to 10 [Playtester]
status_change_start(src,bl,SC_STUN,(skill_lv-5)*sd->status.base_level*10,
skill_lv,0,0,0,skill_get_time2(SM_FATALBLOW,skill_lv),SCSTART_NONE);
}
break;
case MER_CRASH:
sc_start(src,bl,SC_STUN,(6*skill_lv),skill_lv,skill_get_time2(skill_id,skill_lv));
break;
case AS_VENOMKNIFE:
if (sd) //Poison chance must be that of Envenom. [Skotlex]
skill_lv = pc_checkskill(sd, TF_POISON);
case TF_POISON:
case AS_SPLASHER:
if(!sc_start2(src,bl,SC_POISON,(4*skill_lv+10),skill_lv,src->id,skill_get_time2(skill_id,skill_lv))
&& sd && skill_id==TF_POISON