/
client_mods.cpp
1847 lines (1634 loc) · 36.8 KB
/
client_mods.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/rulesys.h"
#include "../common/spdat.h"
#include "client.h"
#include "mob.h"
#include <algorithm>
int32 Client::GetMaxStat(int32 aabonusAmount) const {
if((RuleI(Character, StatCap)) > 0)
return (RuleI(Character, StatCap));
if (GetLevel() <= 60)
return 255;
else
return 255 + (GetLevel() - 60) * 5 + aabonusAmount;
}
int32 Client::GetMaxResist() const
{
return 500;
}
int32 Client::GetMaxSTR() const {
return GetMaxStat(aabonuses.STRCapMod);
}
int32 Client::GetMaxSTA() const {
return GetMaxStat(aabonuses.STACapMod);
}
int32 Client::GetMaxDEX() const {
return GetMaxStat(aabonuses.DEXCapMod);
}
int32 Client::GetMaxAGI() const {
return GetMaxStat(aabonuses.AGICapMod);
}
int32 Client::GetMaxINT() const {
return GetMaxStat(aabonuses.INTCapMod);
}
int32 Client::GetMaxWIS() const {
return GetMaxStat(aabonuses.WISCapMod);
}
int32 Client::GetMaxCHA() const {
return GetMaxStat(aabonuses.CHACapMod);
}
int32 Client::GetMaxMR() const {
return GetMaxResist() + aabonuses.MRCapMod;
}
int32 Client::GetMaxPR() const {
return GetMaxResist() + aabonuses.PRCapMod;
}
int32 Client::GetMaxDR() const {
return GetMaxResist() + aabonuses.DRCapMod;
}
int32 Client::GetMaxCR() const {
return GetMaxResist() + aabonuses.CRCapMod;
}
int32 Client::GetMaxFR() const {
return GetMaxResist() + aabonuses.FRCapMod;
}
int32 Client::LevelRegen(int level, bool is_sitting, bool is_resting, bool is_feigned, bool is_famished, bool has_racial_regen_bonus)
{
// base regen is 1
int hp_regen_amount = 1;
// sitting adds 1
if (is_sitting)
{
hp_regen_amount += 1;
}
// feigning at 51+ adds 1 as if sitting
if (level > 50 && is_feigned)
{
hp_regen_amount += 1;
}
// being either hungry or thirsty negates the passive regen from standing/sitting/feigning but can still benefit from level bonuses and resting
if (is_famished) // the client checks to see if either food or water is 0 in pp
{
hp_regen_amount = 0;
}
// additional point of regen is gained at levels 51, 56, 60, 61, 63 and 65
if (level >= 51)
{
hp_regen_amount += 1;
}
if (level >= 56)
{
hp_regen_amount += 1;
}
if (level >= 60)
{
hp_regen_amount += 1;
}
if (level >= 61)
{
hp_regen_amount += 1;
}
if (level >= 63)
{
hp_regen_amount += 1;
}
if (level >= 65)
{
hp_regen_amount += 1;
}
// resting begins after sitting for 1 minute.
// 1 additional point of regen is gained at levels 20 and 50
if (is_sitting && is_resting)
{
if (level >= 20)
{
hp_regen_amount += 1;
}
if (level >= 50)
{
hp_regen_amount += 1;
}
}
// racial trait adds to then doubles regen bonuses
if (has_racial_regen_bonus)
{
if (level >= 51)
{
hp_regen_amount += 1;
}
if (level >= 56)
{
hp_regen_amount += 1;
}
hp_regen_amount *= 2;
}
return hp_regen_amount;
}
// based on client decompile
int32 Client::CalcHPRegen()
{
bool is_sitting = IsSitting() || (GetHorseId() != 0 && !auto_attack && !ClientMoving());
bool has_racial_regen_bonus = GetPlayerRaceBit(GetBaseRace()) & RuleI(Character, BaseHPRegenBonusRaces);
bool is_feigned = GetClass() == MONK && IsFeigned(); // only monks get this bonus
// naked regen
int32 hp_regen_amount = LevelRegen(GetLevel(), is_sitting, IsRested(), is_feigned, Famished(), has_racial_regen_bonus);
// add AA regen - this is here because of the check below needing to negate it so we can bleed out in sync with the client
hp_regen_amount += aabonuses.HPRegen;
// we're almost dead, our regeneration won't save us now but a heal could
if (GetHP() <= 0)
{
if (hp_regen_amount <= 0 || GetHP() < -5)
{
// bleed to death slowly
hp_regen_amount = -1;
}
}
// add spell and item regen
hp_regen_amount += itembonuses.HPRegen + spellbonuses.HPRegen;
// special case, if we're unconscious and our hp isn't changing, make it -1 so the character doesn't end up stuck in that state
// this only applies if the character ends up with between -5 and 0 hp, then once they reach -6 they will hit the normal bleeding logic
if (GetHP() <= 0 && hp_regen_amount == 0)
{
hp_regen_amount = -1;
}
return hp_regen_amount;
}
int32 Client::CalcHPRegenCap()
{
int base = 30;
if (level > 60)
base = level - 30;
return base;
}
int32 Client::CalcMaxHP(bool unbuffed) {
int32 val = (CalcBaseHP(unbuffed) + itembonuses.HP);
//The AA desc clearly says it only applies to base hp..
//but the actual effect sent on live causes the client
//to apply it to (basehp + itemhp).. I will oblige to the client's whims over
//the aa description
// Natural Durability and Physical Enhancement
double nd = 0.0;
int nd_level = GetAA(aaNaturalDurability);
if (nd_level != 0)
{
switch (nd_level)
{
case 1: nd = 2.0; break;
case 2: nd = 5.0; break;
case 3: nd = 10.0; break;
}
// Physical Enhancement only functions if you have at least 1 point in Natural Durability
int pe_level = GetAA(aaPhysicalEnhancement);
if (pe_level != 0)
{
nd += 2.0;
}
}
// Planar Durability - WAR PAL SHD ability
// Note that de-leveling below 60 after getting this ability causes you to lose hitpoints
int pd_level = GetAA(aaPlanarDurability);
if (pd_level != 0)
{
int levels_over_60 = GetLevel() - 60;
pd_level = pd_level > levels_over_60 ? levels_over_60 : pd_level;
if (GetClass() == WARRIOR)
{
nd += 1.5 * pd_level;
}
else if (GetClass() == PALADIN || GetClass() == SHADOWKNIGHT)
{
nd += 1.25 * pd_level;
}
}
// the results can end up being slightly off between the server, the mac client and the windows client due to floating point precision
// there are cases where the clients end up with different hp totals for the same character, but have only seen it off by 1 hp
val += (int32)(val * nd / 100.0);
val += aabonuses.HP + 5;
if (!unbuffed)
val += spellbonuses.HP;
// this MaxHPChange bonus is only used in AAs on TAKP, not in items or spells, so this line doesn't do anything
//val += val * ((spellbonuses.MaxHPChange + itembonuses.MaxHPChange) / 10000.0f);
if(val > 32767)
val = 32767;
if (!unbuffed)
{
if (cur_hp > val)
cur_hp = val;
max_hp = val;
}
return val;
}
uint32 Mob::GetClassLevelFactor(){
uint32 multiplier = 0;
uint8 mlevel=GetLevel();
switch(GetClass())
{
case WARRIOR:{
if (mlevel < 20)
multiplier = 220;
else if (mlevel < 30)
multiplier = 230;
else if (mlevel < 40)
multiplier = 250;
else if (mlevel < 53)
multiplier = 270;
else if (mlevel < 57)
multiplier = 280;
else if (mlevel < 60)
multiplier = 290;
else if (mlevel < 70)
multiplier = 300;
else
multiplier = 311;
break;
}
case DRUID:
case CLERIC:
case SHAMAN:{
if (mlevel < 70)
multiplier = 150;
else
multiplier = 157;
break;
}
case PALADIN:
case SHADOWKNIGHT:{
if (mlevel < 35)
multiplier = 210;
else if (mlevel < 45)
multiplier = 220;
else if (mlevel < 51)
multiplier = 230;
else if (mlevel < 56)
multiplier = 240;
else if (mlevel < 60)
multiplier = 250;
else if (mlevel < 68)
multiplier = 260;
else
multiplier = 270;
break;
}
case MONK:
case BARD:
case ROGUE:
case BEASTLORD:{
if (mlevel < 51)
multiplier = 180;
else if (mlevel < 58)
multiplier = 190;
else if (mlevel < 70)
multiplier = 200;
else
multiplier = 210;
break;
}
case RANGER:{
if (mlevel < 58)
multiplier = 200;
else if (mlevel < 70)
multiplier = 210;
else
multiplier = 220;
break;
}
case MAGICIAN:
case WIZARD:
case NECROMANCER:
case ENCHANTER:{
if (mlevel < 70)
multiplier = 120;
else
multiplier = 127;
break;
}
default:{
if (mlevel < 35)
multiplier = 210;
else if (mlevel < 45)
multiplier = 220;
else if (mlevel < 51)
multiplier = 230;
else if (mlevel < 56)
multiplier = 240;
else if (mlevel < 60)
multiplier = 250;
else
multiplier = 260;
break;
}
}
return multiplier;
}
int32 Client::CalcBaseHP(bool unbuffed)
{
int32 lm = GetClassLevelFactor() / 10;
int32 level_hp = GetLevel() * lm;
int32 sta_factor = GetSTA();
if (unbuffed) // web stats export uses this
{
sta_factor = CalcSTA(unbuffed);
}
if (sta_factor > 255)
{
sta_factor = (sta_factor - 255) / 2 + 255;
}
int32 val = level_hp * sta_factor / 300 + level_hp;
if (!unbuffed)
base_hp = val;
return val;
}
// This should return the combined AC of all the items the player is wearing.
int32 Client::GetRawItemAC() {
int32 Total = 0;
// this skips SlotAmmo..add an '=' conditional if that slot is required (original behavior)
for (int16 slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id < EQ::invslot::EQUIPMENT_END; slot_id++) {
const EQ::ItemInstance* inst = m_inv[slot_id];
if (inst && inst->IsType(EQ::item::ItemClassCommon)) {
Total += inst->GetItem()->AC;
}
}
return Total;
}
int32 Client::acmod() {
int agility = GetAGI();
int level = GetLevel();
if(agility < 1 || level < 1)
return(0);
if (agility <=74){
if (agility == 1)
return -24;
else if (agility <=3)
return -23;
else if (agility == 4)
return -22;
else if (agility <=6)
return -21;
else if (agility <=8)
return -20;
else if (agility == 9)
return -19;
else if (agility <=11)
return -18;
else if (agility == 12)
return -17;
else if (agility <=14)
return -16;
else if (agility <=16)
return -15;
else if (agility == 17)
return -14;
else if (agility <=19)
return -13;
else if (agility == 20)
return -12;
else if (agility <=22)
return -11;
else if (agility <=24)
return -10;
else if (agility == 25)
return -9;
else if (agility <=27)
return -8;
else if (agility == 28)
return -7;
else if (agility <=30)
return -6;
else if (agility <=32)
return -5;
else if (agility == 33)
return -4;
else if (agility <=35)
return -3;
else if (agility == 36)
return -2;
else if (agility <=38)
return -1;
else if (agility <=65)
return 0;
else if (agility <=70)
return 1;
else if (agility <=74)
return 5;
}
else if(agility <= 137) {
if (agility == 75){
if (level <= 6)
return 9;
else if (level <= 19)
return 23;
else if (level <= 39)
return 33;
else
return 39;
}
else if (agility >= 76 && agility <= 79){
if (level <= 6)
return 10;
else if (level <= 19)
return 23;
else if (level <= 39)
return 33;
else
return 40;
}
else if (agility == 80){
if (level <= 6)
return 11;
else if (level <= 19)
return 24;
else if (level <= 39)
return 34;
else
return 41;
}
else if (agility >= 81 && agility <= 85){
if (level <= 6)
return 12;
else if (level <= 19)
return 25;
else if (level <= 39)
return 35;
else
return 42;
}
else if (agility >= 86 && agility <= 90){
if (level <= 6)
return 12;
else if (level <= 19)
return 26;
else if (level <= 39)
return 36;
else
return 42;
}
else if (agility >= 91 && agility <= 95){
if (level <= 6)
return 13;
else if (level <= 19)
return 26;
else if (level <= 39)
return 36;
else
return 43;
}
else if (agility >= 96 && agility <= 99){
if (level <= 6)
return 14;
else if (level <= 19)
return 27;
else if (level <= 39)
return 37;
else
return 44;
}
else if (agility == 100 && level >= 7){
if (level <= 19)
return 28;
else if (level <= 39)
return 38;
else
return 45;
}
else if (level <= 6) {
return 15;
}
//level is >6
else if (agility >= 101 && agility <= 105){
if (level <= 19)
return 29;
else if (level <= 39)
return 39;// not verified
else
return 45;
}
else if (agility >= 106 && agility <= 110){
if (level <= 19)
return 29;
else if (level <= 39)
return 39;// not verified
else
return 46;
}
else if (agility >= 111 && agility <= 115){
if (level <= 19)
return 30;
else if (level <= 39)
return 40;// not verified
else
return 47;
}
else if (agility >= 116 && agility <= 119){
if (level <= 19)
return 31;
else if (level <= 39)
return 41;
else
return 47;
}
else if (level <= 19) {
return 32;
}
//level is > 19
else if (agility == 120){
if (level <= 39)
return 42;
else
return 48;
}
else if (agility <= 125){
if (level <= 39)
return 42;
else
return 49;
}
else if (agility <= 135){
if (level <= 39)
return 42;
else
return 50;
}
else {
if (level <= 39)
return 42;
else
return 51;
}
} else if(agility <= 300) {
if(level <= 6) {
if(agility <= 139)
return(21);
else if(agility == 140)
return(22);
else if(agility <= 145)
return(23);
else if(agility <= 150)
return(23);
else if(agility <= 155)
return(24);
else if(agility <= 159)
return(25);
else if(agility == 160)
return(26);
else if(agility <= 165)
return(26);
else if(agility <= 170)
return(27);
else if(agility <= 175)
return(28);
else if(agility <= 179)
return(28);
else if(agility == 180)
return(29);
else if(agility <= 185)
return(30);
else if(agility <= 190)
return(31);
else if(agility <= 195)
return(31);
else if(agility <= 199)
return(32);
else if(agility <= 219)
return(33);
else if(agility <= 239)
return(34);
else
return(35);
} else if(level <= 19) {
if(agility <= 139)
return(34);
else if(agility == 140)
return(35);
else if(agility <= 145)
return(36);
else if(agility <= 150)
return(37);
else if(agility <= 155)
return(37);
else if(agility <= 159)
return(38);
else if(agility == 160)
return(39);
else if(agility <= 165)
return(40);
else if(agility <= 170)
return(40);
else if(agility <= 175)
return(41);
else if(agility <= 179)
return(42);
else if(agility == 180)
return(43);
else if(agility <= 185)
return(43);
else if(agility <= 190)
return(44);
else if(agility <= 195)
return(45);
else if(agility <= 199)
return(45);
else if(agility <= 219)
return(46);
else if(agility <= 239)
return(47);
else
return(48);
} else if(level <= 39) {
if(agility <= 139)
return(44);
else if(agility == 140)
return(45);
else if(agility <= 145)
return(46);
else if(agility <= 150)
return(47);
else if(agility <= 155)
return(47);
else if(agility <= 159)
return(48);
else if(agility == 160)
return(49);
else if(agility <= 165)
return(50);
else if(agility <= 170)
return(50);
else if(agility <= 175)
return(51);
else if(agility <= 179)
return(52);
else if(agility == 180)
return(53);
else if(agility <= 185)
return(53);
else if(agility <= 190)
return(54);
else if(agility <= 195)
return(55);
else if(agility <= 199)
return(55);
else if(agility <= 219)
return(56);
else if(agility <= 239)
return(57);
else
return(58);
} else { //lvl >= 40
if(agility <= 139)
return(51);
else if(agility == 140)
return(52);
else if(agility <= 145)
return(53);
else if(agility <= 150)
return(53);
else if(agility <= 155)
return(54);
else if(agility <= 159)
return(55);
else if(agility == 160)
return(56);
else if(agility <= 165)
return(56);
else if(agility <= 170)
return(57);
else if(agility <= 175)
return(58);
else if(agility <= 179)
return(58);
else if(agility == 180)
return(59);
else if(agility <= 185)
return(60);
else if(agility <= 190)
return(61);
else if(agility <= 195)
return(61);
else if(agility <= 199)
return(62);
else if(agility <= 219)
return(63);
else if(agility <= 239)
return(64);
else
return(65);
}
}
else{
//seems about 21 agil per extra AC pt over 300...
return (65 + ((agility-300) / 21));
}
Log(Logs::Detail, Logs::Error, "Error in Client::acmod(): Agility: %i, Level: %i", agility, level);
return 0;
};
int32 Client::CalcAC()
{
// this is the value displayed in clients (it ignores the softcap) and is not used in combat calculations
AC = (GetAvoidance(true) + GetMitigation(true)) * 1000 / 847;
return AC;
}
int32 Client::CalcMaxMana()
{
switch(GetCasterClass())
{
case 'I':
case 'W': {
if ((GetClass() == RANGER || GetClass() == PALADIN || GetClass() == BEASTLORD) && GetLevel() < 9)
max_mana = 0;
else
max_mana = (CalcBaseMana() + itembonuses.Mana + spellbonuses.Mana);
break;
}
case 'N': {
max_mana = 0;
break;
}
default: {
Log(Logs::Detail, Logs::Spells, "Invalid Class '%c' in CalcMaxMana", GetCasterClass());
max_mana = 0;
break;
}
}
if (max_mana < 0) {
max_mana = 0;
}
if(max_mana > 32767)
max_mana = 32767;
if (cur_mana > max_mana) {
cur_mana = max_mana;
}
#if EQDEBUG >= 11
Log(Logs::Detail, Logs::Spells, "Client::CalcMaxMana() called for %s - returning %d", GetName(), max_mana);
#endif
return max_mana;
}
int32 Client::CalcBaseMana()
{
int WisInt = 0;
int MindLesserFactor, MindFactor;
int32 max_m = 0;
int wisint_mana = 0;
int base_mana = 0;
int ConvertedWisInt = 0;
switch(GetCasterClass())
{
case 'I':
WisInt = GetINT();
if((( WisInt - 199 ) / 2) > 0)
MindLesserFactor = ( WisInt - 199 ) / 2;
else
MindLesserFactor = 0;
MindFactor = WisInt - MindLesserFactor;
if(WisInt > 100)
max_m = (((5 * (MindFactor + 20)) / 2) * 3 * GetLevel() / 40);
else
max_m = (((5 * (MindFactor + 200)) / 2) * 3 * GetLevel() / 100);
break;
case 'W':
WisInt = GetWIS();
if((( WisInt - 199 ) / 2) > 0)
MindLesserFactor = ( WisInt - 199 ) / 2;
else
MindLesserFactor = 0;
MindFactor = WisInt - MindLesserFactor;
if(WisInt > 100)
max_m = (((5 * (MindFactor + 20)) / 2) * 3 * GetLevel() / 40);
else
max_m = (((5 * (MindFactor + 200)) / 2) * 3 * GetLevel() / 100);
break;
case 'N': {
max_m = 0;
break;
}
default: {
Log(Logs::General, Logs::Spells, "Invalid Class '%c' in CalcMaxMana", GetCasterClass());
max_m = 0;
break;
}
}
#if EQDEBUG >= 11
Log(Logs::General, Logs::Spells, "Client::CalcBaseMana() called for %s - returning %d", GetName(), max_m);
#endif
return max_m;
}
int32 Client::CalcManaRegen(bool meditate)
{
/*
- base regen
famished = 0
not famished, standing = 1
not famished, sitting/horse = 2
- meditate
non bard, sitting/horse, has meditate skill
skill <=1 = 3 (doesn't happen during normal play due to skills starting higher when trained)
skill >1 = 4 + skill / 15
- AA
mental clarity = add 0-3
body and mind rejuvenation = add 0-1
- level
level >61 = add 1
level >63 = add 1
- worn items
items = add 0-15
donal's buff = add 0-1
*/
if (CalcMaxMana() == 0)
return 0;
uint8 clevel = GetLevel();
int32 regen = 0;
bool new_medding_state = false;
// standing/sitting passive regen stops when famished
if (!Famished())
{
regen = 1; // passive standing regen when not famished
if (IsSitting() || (GetHorseId() != 0 && !auto_attack && !ClientMoving()))
{
regen = 2; // passive sitting regen when not famished
// bards cannot meditate even though they have the skill
if (GetClass() != BARD && HasSkill(EQ::skills::SkillMeditate))
{
// matches client logic for an edge case
// happens with skill level 0 or 1 but normally training the skill at level 4/8/12 will put it higher anyway
// except bards, they get only 1 point, but they can't meditate so they don't hit this condition either
regen = 3;
new_medding_state = true;
if (GetSkill(EQ::skills::SkillMeditate) > 1)
{
regen = 4 + GetSkill(EQ::skills::SkillMeditate) / 15; // meditate regen is 20 for characters with maximum skill
}
}
}
}
this->medding = new_medding_state; // turn off medding flag if it didn't get set above (famished or not sitting/mounted)
if (this->medding && meditate)
{
CheckIncreaseSkill(EQ::skills::SkillMeditate, nullptr, zone->skill_difficulty[EQ::skills::SkillMeditate].difficulty);
}
// level regen bonus applies even when famished
if (clevel > 61)
{
regen += 1;
}
if (clevel > 63)
{
regen += 1;
}
//AAs
regen += aabonuses.ManaRegen + spellbonuses.ManaRegen + itembonuses.ManaRegen;
// Donal's BP leaves a 7.5 min residual effect (extended by buff duration extension AAs) which provides 1 point of mana regen that is separate from spell bonuses and flowing thought
if (GetBuffSlotFromType(SE_CompleteHeal) >= 0)
{
regen += 1;
}
return regen;
}
int32 Client::CalcManaRegenCap()
{
if(GetCasterClass() == 'N')
return 0;
int32 cap = RuleI(Character, ItemManaRegenCap);
return cap;
}
uint32 Client::CalcCurrentWeight() {
const EQ::ItemInstance* ins = nullptr;
uint32 Total = 0;
int x;
for (x = EQ::invslot::slotCursor; x <= EQ::invslot::GENERAL_END; x++)
{
ins = GetInv().GetItem(x);
if (ins)
{
Total += ins->GetItem()->Weight;