-
Notifications
You must be signed in to change notification settings - Fork 98
/
effects.cpp
1242 lines (1080 loc) · 36.7 KB
/
effects.cpp
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
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/global_define.h"
#include "../common/eqemu_logsys.h"
#include "../common/spdat.h"
#include "../common/zone_store.h"
#include "../common/misc_functions.h"
#include "client.h"
#include "entity.h"
#include "mob.h"
#include "beacon.h"
#include "string_ids.h"
#include "worldserver.h"
#include "zonedb.h"
#include "position.h"
float Client::GetActSpellRange(uint16 spell_id, float range, std::string& item)
{
std::string item_name;
float extrange = GetFocusEffect(focusRange, spell_id, item_name) + 100;
item = item_name;
casting_spell_focus_range = extrange;
return (range * extrange) / 100;
}
float Client::GetSpellRange(uint16 spell_id, float range)
{
if (casting_spell_focus_range > 100)
{
return (range * casting_spell_focus_range) / 100;
}
return range;
}
// This also handles NPC cast DoTs.
int32 NPC::GetActSpellDamage(uint16 spell_id, int32 value, Mob* target) {
//Quest scale all NPC spell damage via $npc->SetSpellFocusDMG(value)
//DoT Damage - Mob::DoBuffTic [spell_effects.cpp] / Direct Damage Mob::SpellEffect [spell_effects.cpp]
int32 dmg = value;
value += dmg*GetSpellFocusDMG()/100;
if (AI_HasSpellsEffects()){
int16 chance = 0;
int ratio = 0;
if (spells[spell_id].buffduration == 0) {
if (chance && zone->random.Roll(chance)) {
value += (value*ratio)/100;
entity_list.MessageClose_StringID(this, true, 100, Chat::SpellCrit, StringID::OTHER_CRIT_BLAST, GetCleanName(), itoa(-value));
}
}
else {
chance += spellbonuses.CriticalDoTChance;
if (chance && zone->random.Roll(chance)) {
value += (value*ratio)/100;
}
}
}
return value;
}
// maxHit set to 0 ignores the check; it's just used for manaburn. need it here because otherwise crits would multiply it
// damage should be negative
int32 Client::TryWizardInnateCrit(uint16 spell_id, int32 damage, int32 focusDmg, int32 maxHit)
{
if (GetClass() == Class::Wizard && GetLevel() >= RuleI(Spells, WizCritLevel))
{
double wizCritChance = (((std::min(GetINT(), 255) + std::min(GetDEX(), 255)) / 2.0) + 32.0) / 10000.0;
bool critSuccess = zone->random.Roll(wizCritChance);
if (critSuccess)
{
int32 mult = zone->random.Int(1, 50);
damage += damage * mult / 100 + focusDmg;
if (maxHit && damage < maxHit)
damage = maxHit;
entity_list.MessageClose_StringID(this, true, 100, Chat::SpellCrit,
StringID::OTHER_CRIT_BLAST, GetName(), itoa(-damage));
Message_StringID(Chat::SpellCrit, StringID::YOU_CRIT_BLAST, itoa(-damage));
}
else
damage += focusDmg;
}
return damage;
}
// handle crits and apply AA and disc bonuses/modifers to spell damage cast by clients. dmg should be negative
int32 Client::GetActSpellDamage(uint16 spell_id, int32 dmg, Mob* target)
{
if (spells[spell_id].targettype == ST_Self)
return dmg;
if (spell_id == SPELL_IMP_HARM_TOUCH) // Improved Harm Touch AA skill
dmg -= GetAA(aaUnholyTouch) * 450; // Unholy Touch AA
if ((spell_id == SPELL_HARM_TOUCH || spell_id == SPELL_HARM_TOUCH2 || spell_id == SPELL_IMP_HARM_TOUCH) && HasInstantDisc(spell_id)) // Unholy Aura disc; 50% dmg is guaranteed
dmg = dmg * 150 / 100;
std::string item_name;
int32 focusDmg = 0;
focusDmg = dmg * GetFocusEffect(focusImprovedDamage, spell_id, item_name) / 100;
if (focusDmg)
Log(Logs::General, Logs::Focus, "focusImprovedDamage improved damage from %d to %d", dmg, focusDmg + dmg);
// SK AA Soul Abrasion; only SKs get something with focusSpellDamageMult
if (GetClass() == Class::ShadowKnight)
{
dmg += dmg * GetFocusEffect(focusSpellDamageMult, spell_id, item_name) / 100; // the AA bonus only applies to spells with spellgroup 99, so don't need spell ID check here
}
bool critical = false;
int critChanceAA = itembonuses.CriticalSpellChance + spellbonuses.CriticalSpellChance + aabonuses.CriticalSpellChance;
if (critChanceAA && zone->random.Roll(critChanceAA))
critical = true;
// Improved Harm Touch is a guaranteed crit if you have at least one level of SCF.
if (spell_id == SPELL_IMP_HARM_TOUCH && (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0))
critical = true;
if (critical)
{
int mult = 100;
if (GetAA(aaSpellCastingFury) == 1) // lower ranks do not do double damage
mult = 33;
else if (GetAA(aaSpellCastingFury) == 2)
mult = 66;
dmg += dmg * mult / 100 + focusDmg; // focused damage is not multiplied by crit
entity_list.MessageClose_StringID(this, false, 100, Chat::SpellCrit,
StringID::OTHER_CRIT_BLAST, GetName(), itoa(-dmg));
Message_StringID(Chat::SpellCrit, StringID::YOU_CRIT_BLAST, itoa(-dmg));
}
else if (GetClass() == Class::Wizard)
dmg = TryWizardInnateCrit(spell_id, dmg, focusDmg);
else
dmg += focusDmg;
return dmg;
}
int32 Client::GetActDoTDamage(uint16 spell_id, int32 value, Mob* target) {
if (target == nullptr)
return value;
int32 value_BaseEffect = value;
int16 chance = 0;
chance += itembonuses.CriticalDoTChance + spellbonuses.CriticalDoTChance + aabonuses.CriticalDoTChance;
std::string item_name;
if (chance > 0 && (zone->random.Roll(chance))) {
int32 ratio = 200;
value = value_BaseEffect*ratio/100;
int32 tmp_val = value;
value += int(value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id, item_name, true)/100)*ratio/100;
if (tmp_val != value)
Log(Logs::General, Logs::Focus, "focusImprovedDamage improved DOT damage from %d to %d", tmp_val, value);
return value;
}
value = value_BaseEffect;
value += value_BaseEffect*GetFocusEffect(focusImprovedDamage, spell_id, item_name, true)/100;
return value;
}
int32 Mob::GetExtraSpellAmt(uint16 spell_id, int32 extra_spell_amt, int32 base_spell_dmg)
{
int total_cast_time = 0;
if (spells[spell_id].recast_time >= spells[spell_id].recovery_time)
total_cast_time = spells[spell_id].recast_time + spells[spell_id].cast_time;
else
total_cast_time = spells[spell_id].recovery_time + spells[spell_id].cast_time;
if (total_cast_time > 0 && total_cast_time <= 2500)
extra_spell_amt = extra_spell_amt*25/100;
else if (total_cast_time > 2500 && total_cast_time < 7000)
extra_spell_amt = extra_spell_amt*(167*((total_cast_time - 1000)/1000)) / 1000;
else
extra_spell_amt = extra_spell_amt * total_cast_time / 7000;
if(extra_spell_amt*2 < base_spell_dmg)
return 0;
return extra_spell_amt;
}
int32 NPC::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target, bool hot) {
//Scale all NPC spell healing via SetSpellFocusHeal(value)
value += value*GetSpellFocusHeal()/100;
if (target) {
value += value*target->GetHealRate(spell_id, this)/100;
}
//Allow for critical heal chance if NPC is loading spell effect bonuses.
if (AI_HasSpellsEffects()){
if(spells[spell_id].buffduration < 1) {
if(spellbonuses.CriticalHealChance && (zone->random.Roll(spellbonuses.CriticalHealChance))) {
value = value*2;
entity_list.MessageClose_StringID(this, true, 100, Chat::SpellCrit, StringID::OTHER_CRIT_HEAL, GetCleanName(), itoa(value));
}
}
}
return value;
}
int32 Client::GetActSpellHealing(uint16 spell_id, int32 value, Mob* target, bool hot) {
if (target == nullptr)
target = this;
int32 value_BaseEffect = value;
int16 chance = 0;
int8 modifier = 1;
bool Critical = false;
if (!hot)
{
std::string item_name;
value += int(value_BaseEffect*GetFocusEffect(focusImprovedHeal, spell_id, item_name) / 100);
if (value_BaseEffect != value)
{
int32 tmp_val = GetHP() + value > GetMaxHP() ? GetMaxHP() : value;
Log(Logs::General, Logs::Focus, "focusImprovedHeal improved heal from %d to %d", value_BaseEffect, tmp_val);
}
}
// Instant Heals
if(spells[spell_id].buffduration < 1) {
chance += itembonuses.CriticalHealChance + spellbonuses.CriticalHealChance + aabonuses.CriticalHealChance;
if (IsPercentalHealSpell(spell_id)) // these don't crit - Tunare's Renewal, Kragg's Mending, Karana's Renewal
{
chance = 0;
}
if(chance && (zone->random.Roll(chance))) {
Critical = true;
modifier = 2; //At present time no critical heal amount modifier SPA exists.
}
value *= modifier;
value += value*target->GetHealRate(spell_id, this)/100;
if (Critical) {
entity_list.MessageClose_StringID(this, false, 100, Chat::SpellCrit,
StringID::OTHER_CRIT_HEAL, GetName(), itoa(value));
Message_StringID(Chat::SpellCrit, StringID::YOU_CRIT_HEAL, itoa(value));
}
return value;
}
return value;
}
int32 Client::GetActSpellCost(uint16 spell_id, int32 cost)
{
// This formula was derived from the following resource:
// http://www.eqsummoners.com/eq1/specialization-library.html
// WildcardX
float PercentManaReduction = 0.0f;
float SpecializeSkill = GetSpecializeSkillValue(spell_id);
if (SpecializeSkill > 0.0f)
{
PercentManaReduction = 1 + SpecializeSkill / 20.0f;
switch(GetAA(aaSpellCastingMastery))
{
case 1:
PercentManaReduction += 2.5f;
break;
case 2:
PercentManaReduction += 5.0f;
break;
case 3:
PercentManaReduction += 10.0f;
break;
}
}
cost -= (cost * (PercentManaReduction / 100));
if(cost < 0)
cost = 0;
return cost;
}
int32 Client::GetActSpellDuration(uint16 spell_id, int32 duration)
{
int increase = 100;
int tic_inc = 0;
return (((duration * increase) / 100) + tic_inc);
}
int32 Client::GetActSpellCasttime(uint16 spell_id, int32 casttime)
{
std::string item_name; // not used
int32 aa_casting_time_mod = GetAACastingTimeModifier(spell_id, casttime);
int32 item_casting_time_mod = 0;
int32 buff_casting_time_mod = 0;
if (FindBuff(SPELL_EPOCH_CONVICTION))
{
// custom behavior for TAKP Quarm. this desyncs the client and is incorrect but it was broken for a long time on TAKP
item_casting_time_mod = casttime * (100 - GetFocusEffect(focusSpellHaste, spell_id, item_name, false, -1, true, false, false)) / 100 - casttime;
buff_casting_time_mod = casttime * (100 - GetFocusEffect(focusSpellHaste, spell_id, item_name, false, -1, false, true, false)) / 100 - casttime;
}
else
{
// intentional sign bug reproduced here, this is how sony did it on AK
item_casting_time_mod = -(casttime * GetFocusEffect(focusSpellHaste, spell_id, item_name, false, -1, true, false, false) / 100u);
buff_casting_time_mod = -(casttime * GetFocusEffect(focusSpellHaste, spell_id, item_name, false, -1, false, true, false) / 100u);
}
int32 modified_cast_time = casttime + aa_casting_time_mod + item_casting_time_mod + buff_casting_time_mod;
modified_cast_time = modified_cast_time < casttime / 2 ? casttime / 2 : modified_cast_time;
if(modified_cast_time != casttime)
Log(Logs::General, Logs::Focus, "Spell %d casttime %d modified %d aa_mod %d item_mod %d buff_mod %d", spell_id, casttime, modified_cast_time, aa_casting_time_mod, item_casting_time_mod, buff_casting_time_mod);
return modified_cast_time;
}
int32 Client::GetAACastingTimeModifier(uint16 spell_id, int32 casttime)
{
// this function is based on a client decompile
const struct SPDat_Spell_Struct *spell = &spells[spell_id];
int32 modified_cast_time = casttime;
// Spell Casting Deftness and Quick Buff
if (spell->goodEffect != 0 && casttime > 3999 && spell->buffduration)
{
uint32 SpellCastingDeftness_AA_Level = GetAA(aaSpellCastingDeftness);
if (SpellCastingDeftness_AA_Level > 0)
{
int32 percent_mod = 100;
switch (SpellCastingDeftness_AA_Level)
{
case 1: percent_mod = 95; break; // Spell Casting Deftness 1 - 5% cast time reduction
case 2: percent_mod = 85; break; // Spell Casting Deftness 2 - 15% cast time reduction
case 3: percent_mod = 75; break; // Spell Casting Deftness 3 - 25% cast time reduction
}
modified_cast_time = modified_cast_time * percent_mod / 100;
}
uint32 QuickBuff_AA_Level = GetAA(aaQuickBuff);
if (QuickBuff_AA_Level > 0)
{
int32 percent_mod = 100;
switch (QuickBuff_AA_Level)
{
case 1: percent_mod = 90; break; // Quick Buff 1 - 10% cast time reduction
case 2: percent_mod = 75; break; // Quick Buff 2 - 25% cast time reduction
case 3: percent_mod = 50; break; // Quick Buff 3 - 50% cast time reduction
}
modified_cast_time = modified_cast_time * percent_mod / 100;
}
}
// Quick Damage
if (spell->goodEffect == 0 && casttime > 3999 && spell->buffduration == 0 && IsEffectInSpell(spell_id, SE_CurrentHP) && GetAA(aaSpellCastingFury) == 3)
{
uint32 QuickDamage_AA_Level = GetAA(aaQuickDamage);
if (QuickDamage_AA_Level > 0)
{
int32 percent_mod = 100;
switch (QuickDamage_AA_Level)
{
case 1: percent_mod = 98; break; // Quick Damage 1 - 2% cast time reduction
case 2: percent_mod = 95; break; // Quick Damage 2 - 5% cast time reduction
case 3: percent_mod = 90; break; // Quick Damage 3 - 10% cast time reduction
}
modified_cast_time = modified_cast_time * percent_mod / 100;
}
}
// Quick Evacuation
if (IsEffectInSpell(spell_id, SE_Succor))
{
uint32 QuickEvacuation_AA_Level = GetAA(aaQuickEvacuation);
if (QuickEvacuation_AA_Level > 0)
{
int32 percent_mod = 100;
switch (QuickEvacuation_AA_Level)
{
case 1: percent_mod = 90; break; // Quick Evacuation 1 - 10% cast time reduction
case 2: percent_mod = 75; break; // Quick Evacuation 2 - 25% cast time reduction
case 3: percent_mod = 50; break; // Quick Evacuation 3 - 50% cast time reduction
}
modified_cast_time = modified_cast_time * percent_mod / 100;
}
}
// Quick Summoning
if (GetClass() == Class::Magician)
{
if (IsEffectInSpell(spell_id, SE_SummonItem) || IsEffectInSpell(spell_id, SE_SummonPet) || spell_id == SPELL_MANIFEST_ELEMENTS || spell_id == SPELL_CALL_OF_THE_HERO)
{
uint32 QuickSummoning_AA_Level = GetAA(aaQuickSummoning);
if (QuickSummoning_AA_Level > 0)
{
int32 percent_mod = 100;
switch (QuickSummoning_AA_Level)
{
case 1: percent_mod = 90; break; // Quick Summoning 1 - 10% cast time reduction
case 2: percent_mod = 75; break; // Quick Summoning 2 - 25% cast time reduction
case 3: percent_mod = 50; break; // Quick Summoning 3 - 50% cast time reduction
}
modified_cast_time = modified_cast_time * percent_mod / 100;
}
}
}
return modified_cast_time - casttime;
}
bool Client::UseDiscipline(uint8 disc_id)
{
// Dont let client waste a reuse timer if they can't use the disc
if (IsFeared() || IsMezzed() || IsAmnesiad() || IsPet())
{
return(false);
}
//Check the disc timer
uint32 remain = CheckDiscTimer(pTimerDisciplineReuseStart + GetDiscTimerID(disc_id));
if(remain > 0 && !GetGM())
{
char val1[20]={0};
char val2[20]={0};
Message_StringID(Chat::Disciplines, StringID::DISCIPLINE_CANUSEIN, ConvertArray((remain)/60,val1), ConvertArray(remain%60,val2));
return(false);
}
bool active = disc_ability_timer.Enabled();
if(active)
{
Message(Chat::Disciplines, "You must wait before using this discipline."); //find correct message
return(false);
}
//can we use the disc? the client checks this for us, but we should also confirm server side.
uint8 level_to_use = DisciplineUseLevel(disc_id);
if(level_to_use > GetLevel() || level_to_use == 0)
{
Message_StringID(Chat::Disciplines, StringID::DISC_LEVEL_USE_ERROR);
return(false);
}
// Disciplines with no ability timer (ashenhand, silentfist, thunderkick, and unholyaura) will remain on the player until they either
// use the skill the disc affects successfully, camp/zone, or attempt to use another disc. If we're here, clear that disc so they can
// cast a new one.
if(GetActiveDisc() != 0)
{
Log(Logs::General, Logs::Discs, "Clearing disc %d so that disc %d can be cast.", GetActiveDisc(), disc_id);
FadeDisc();
}
//cast the disc
if(CastDiscipline(disc_id, level_to_use))
return(true);
else
return(false);
}
uint8 Client::DisciplineUseLevel(uint8 disc_id)
{
switch(disc_id)
{
case disc_aggressive:
if(GetClass() == Class::Warrior)
return 60;
else
return 0;
break;
case disc_precision:
if(GetClass() == Class::Warrior)
return 57;
else
return 0;
break;
case disc_defensive:
if(GetClass() == Class::Warrior)
return 55;
else
return 0;
break;
case disc_evasive:
if(GetClass() == Class::Warrior)
return 52;
else
return 0;
break;
case disc_ashenhand:
if(GetClass() == Class::Monk)
return 60;
else
return 0;
break;
case disc_furious:
if(GetClass() == Class::Warrior)
return 56;
else if(GetClass() == Class::Monk || GetClass() == Class::Rogue)
return 53;
else
return 0;
break;
case disc_stonestance:
if(GetClass() == Class::Monk)
return 51;
else if(GetClass() == Class::Beastlord)
return 55;
else
return 0;
break;
case disc_thunderkick:
if(GetClass() == Class::Monk)
return 52;
else
return 0;
break;
case disc_fortitude:
if(GetClass() == Class::Warrior)
return 59;
else if(GetClass() == Class::Monk)
return 54;
else
return 0;
break;
case disc_fellstrike:
if(GetClass() == Class::Warrior)
return 58;
else if(GetClass() == Class::Monk)
return 56;
else if(GetClass() == Class::Beastlord)
return 60;
else if(GetClass() == Class::Rogue)
return 59;
else
return 0;
break;
case disc_hundredfist:
if(GetClass() == Class::Monk)
return 57;
else if(GetClass() == Class::Rogue)
return 58;
else
return 0;
break;
case disc_charge:
if(GetClass() == Class::Warrior)
return 53;
else if(GetClass() == Class::Rogue)
return 54;
else
return 0;
break;
case disc_mightystrike:
if(GetClass() == Class::Warrior)
return 54;
else
return 0;
break;
case disc_nimble:
if(GetClass() == Class::Rogue)
return 55;
else
return 0;
break;
case disc_silentfist:
if(GetClass() == Class::Monk)
return 59;
else
return 0;
break;
case disc_kinesthetics:
if(GetClass() == Class::Rogue)
return 57;
else
return 0;
break;
case disc_holyforge:
if(GetClass() == Class::Paladin)
return 55;
else
return 0;
break;
case disc_sanctification:
if(GetClass() == Class::Paladin)
return 60;
else
return 0;
break;
case disc_trueshot:
if(GetClass() == Class::Ranger)
return 55;
else
return 0;
break;
case disc_weaponshield:
if(GetClass() == Class::Ranger)
return 60;
else
return 0;
break;
case disc_unholyaura:
if(GetClass() == Class::ShadowKnight)
return 55;
else
return 0;
break;
case disc_leechcurse:
if(GetClass() == Class::ShadowKnight)
return 60;
else
return 0;
break;
case disc_deftdance:
if(GetClass() == Class::Bard)
return 55;
else
return 0;
break;
case disc_puretone:
if(GetClass() == Class::Bard)
return 60;
else
return 0;
break;
case disc_resistant:
if(GetClass() == Class::Warrior || GetClass() == Class::Monk || GetClass() == Class::Rogue)
return 30;
else if(GetClass() == Class::Paladin || GetClass() == Class::Ranger || GetClass() == Class::ShadowKnight || GetClass() == Class::Bard || GetClass() == Class::Beastlord)
return 51;
else
return 0;
break;
case disc_fearless:
if(GetClass() == Class::Warrior || GetClass() == Class::Monk || GetClass() == Class::Rogue)
return 40;
else if(GetClass() == Class::Paladin || GetClass() == Class::Ranger || GetClass() == Class::ShadowKnight || GetClass() == Class::Bard || GetClass() == Class::Beastlord)
return 54;
else
return 0;
break;
default:
return 0;
break;
}
}
bool Client::CastDiscipline(uint8 disc_id, uint8 level_to_use)
{
uint8 current_level = GetLevel();
if(level_to_use > current_level || level_to_use == 0)
return false;
// reuse_timer is in seconds, ability_timer is in milliseconds.
int32 reuse_timer = 0, ability_timer = 0, string = 0;
int16 spellid = 0;
switch(disc_id)
{
case disc_aggressive:
reuse_timer = 1620;
ability_timer = 180000;
spellid = 4498;
string = StringID::DISCIPLINE_AGRESSIVE;
break;
case disc_precision:
reuse_timer = 1800;
ability_timer = 180000;
spellid = 4501;
string = StringID::DISCIPLINE_PRECISION;
break;
case disc_defensive:
reuse_timer = 900;
ability_timer = 180000;
spellid = 4499;
string = StringID::DISCIPLINE_DEFENSIVE;
break;
case disc_evasive:
reuse_timer = 900;
ability_timer = 180000;
spellid = 4503;
string = StringID::DISCIPLINE_EVASIVE;
break;
case disc_ashenhand:
reuse_timer = 4320;
spellid = 4508;
string = StringID::DISCIPLINE_ASHENHAND;
break;
case disc_furious: // furious (WAR), whirlwind (MNK), counterattack (ROG)
reuse_timer = 3600;
ability_timer = 9000;
if(GetBaseClass() == Class::Warrior)
spellid = 4674;
else if(GetBaseClass() == Class::Monk)
spellid = 4509;
else if(GetBaseClass() == Class::Rogue)
spellid = 4673;
string = StringID::DISCIPLINE_FURIOUS;
break;
case disc_stonestance: // stonestance (MNK), protectivespirit (BST)
reuse_timer = 720;
ability_timer = 12000;
if(GetBaseClass() == Class::Monk)
spellid = 4510;
else if(GetBaseClass() == Class::Beastlord)
spellid = 4671;
string = StringID::DISCIPLINE_STONESTANCE;
break;
case disc_thunderkick:
reuse_timer = 540;
spellid = 4511;
string = StringID::DISCIPLINE_THUNDERKICK;
break;
case disc_fortitude: // fortitude (WAR), voiddance (MNK)
reuse_timer = 3600;
ability_timer = 8000;
if(GetBaseClass() == Class::Warrior)
spellid = 4670;
else if(GetBaseClass() == Class::Monk)
spellid = 4502;
string = StringID::DISCIPLINE_FORTITUDE;
break;
case disc_fellstrike: // fellstrike (WAR), bestialrage (BST), innerflame (MNK), duelist (ROG)
reuse_timer = 1800;
ability_timer = 12000;
if(GetBaseClass() == Class::Warrior)
spellid = 4675;
else if(GetBaseClass() == Class::Monk)
spellid = 4512;
else if(GetBaseClass() == Class::Rogue)
spellid = 4676;
else if(GetBaseClass() == Class::Beastlord)
spellid = 4678;
string = StringID::DISCIPLINE_FELLSTRIKE;
break;
case disc_hundredfist: // hundredfist (MNK), blindingspeed (ROG)
reuse_timer = 1800;
ability_timer = 15000;
if(GetBaseClass() == Class::Monk)
spellid = 4513;
else if(GetBaseClass() == Class::Rogue)
spellid = 4677;
string = StringID::DISCIPLINE_HUNDREDFIST;
break;
case disc_charge: // charge (WAR), deadeye (ROG)
reuse_timer = 1800;
ability_timer = 14000;
if(GetBaseClass() == Class::Warrior)
spellid = 4672;
else if(GetBaseClass() == Class::Rogue)
spellid = 4505;
string = StringID::DISCIPLINE_CHARGE;
break;
case disc_mightystrike:
reuse_timer = 3600;
ability_timer = 10000;
spellid = 4514;
string = StringID::DISCIPLINE_MIGHTYSTRIKE;
break;
case disc_nimble:
reuse_timer = 1800;
ability_timer = 12000;
spellid = 4515;
string = StringID::DISCIPLINE_NIMBLE;
break;
case disc_silentfist:
reuse_timer = 594;
spellid = 4507;
if(GetRace() == Race::Iksar)
string = StringID::DISCIPLINE_SILENTFIST_IKSAR;
else
string = StringID::DISCIPLINE_SILENTFIST;
break;
case disc_kinesthetics:
reuse_timer = 1800;
ability_timer = 18000;
spellid = 4517;
string = StringID::DISCIPLINE_KINESTHETICS;
break;
case disc_holyforge:
reuse_timer = 4320;
ability_timer = 300000;
spellid = 4500;
string = StringID::DISCIPLINE_HOLYFORGE;
break;
case disc_sanctification:
reuse_timer = 4320;
ability_timer = 15000;
spellid = 4518;
string = StringID::DISCIPLINE_SANCTIFICATION;
break;
case disc_trueshot:
reuse_timer = 4320;
ability_timer = 120000;
spellid = 4506;
string = StringID::DISCIPLINE_TRUESHOT;
break;
case disc_weaponshield:
reuse_timer = 4320;
ability_timer = 20000;
spellid = 4519;
if(GetGender() == Gender::Male)
string = StringID::DISCIPLINE_WPNSLD_MALE;
else if(GetGender() == Gender::Female)
string = StringID::DISCIPLINE_WPNSLD_FEMALE;
else
string = StringID::DISCIPLINE_WPNSLD_MONSTER;
break;
case disc_unholyaura:
reuse_timer = 4320;
spellid = 4520;
string = StringID::DISCIPLINE_UNHOLYAURA;
break;
case disc_leechcurse:
reuse_timer = 4320;
ability_timer = 20000;
spellid = 4504;
string = StringID::DISCIPLINE_LEECHCURSE;
break;
case disc_deftdance:
reuse_timer = 4320;
ability_timer = 15000;
spellid = 4516;
string = StringID::DISCIPLINE_DEFTDANCE;
break;
case disc_puretone:
reuse_timer = 4320;
ability_timer = 240000;
spellid = 4586;
string = StringID::DISCIPLINE_PURETONE;
break;
case disc_resistant:
reuse_timer = 3600;
ability_timer = 300000;
spellid = 4585;
string = StringID::DISCIPLINE_RESISTANT;
break;
case disc_fearless:
reuse_timer = 3600;
ability_timer = 11000;
spellid = 4587;
string = StringID::DISCIPLINE_FEARLESS;
break;
default:
Log(Logs::General, Logs::Discs, "Invalid disc id %d was passed to CastDiscipline.", disc_id);
return false;
}
if(string > 0 && IsValidSpell(spellid) && IsDisc(spellid))
{
entity_list.MessageClose_StringID(this, true, 50, Chat::Disciplines, string, GetName());
if (reuse_timer < 1620 && current_level > 60)
current_level = 60;
int32 reuse_timer_mod = 0 - ((current_level - level_to_use) * 54);
reuse_timer += reuse_timer_mod;
if (reuse_timer > 4320)
reuse_timer = 4320; // 72:00 maximum reuse time
if (reuse_timer < 234)
reuse_timer = 234; // 3:54 minimum reuse time
p_timers.Start(pTimerDisciplineReuseStart + GetDiscTimerID(disc_id), reuse_timer);
if(ability_timer > 0)
{
disc_ability_timer.Start(ability_timer);
}
else
{
Log(Logs::General, Logs::Discs, "Disc %d is an instant effect", disc_id);
}
SetActiveDisc(disc_id, spellid);
SpellFinished(spellid, this);
}
else
{
Log(Logs::General, Logs::Discs, "Disc: %d Invalid stringid or spellid specified.", disc_id);
return false;
}
auto outapp = new EQApplicationPacket(OP_DisciplineChange, sizeof(ClientDiscipline_Struct));
ClientDiscipline_Struct *d = (ClientDiscipline_Struct*)outapp->pBuffer;
d->disc_id = disc_id;
QueuePacket(outapp);
safe_delete(outapp);
// warrior /shield doesn't work with discs
EndShield();
return true;
}
void EntityList::AETaunt(Client* taunter, float range)
{
// Note: This AA was changed to a spell in May 2004; comments after that date are not applicable.
// In our era it had no LoS check and would aggro mobs on other floors or behind walls, so the reach
// was limited which made it very unreliable on large NPCs. (AoW and Fennin for example)
if (range <= 0.0f)
range = 25.0f;
range = range * range;
auto it = npc_list.begin();
while (it != npc_list.end())
{
NPC *them = it->second;
float zdiff = std::abs(taunter->GetZ() - them->GetZ());
if (zdiff < 25.0f // our Z offets are much lower than Sony's, which could go up over 25 units. Ours maxes ~12
&& taunter->IsAttackAllowed(them)
&& DistanceSquaredNoZ(taunter->GetPosition(), them->GetPosition()) <= range
) {
//if (taunter->CheckLosFN(them))
//{
taunter->Taunt(them, true, 100);
taunter->Message_StringID(Chat::Skills, StringID::TAUNT_SUCCESS, them->GetCleanName());
//}
}
++it;
}
}
// causes caster to hit every mob within dist range of center with spell_id.
// NPC spells will only affect other NPCs with compatible faction
// resisted determines if the spell landed on the original target or not, so we know whether to count them towards the limit