-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathABAllCreatureScript.cpp
More file actions
1622 lines (1420 loc) · 72.7 KB
/
ABAllCreatureScript.cpp
File metadata and controls
1622 lines (1420 loc) · 72.7 KB
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
#include "ABAllCreatureScript.h"
#include "ABConfig.h"
#include "ABCreatureInfo.h"
#include "ABMapInfo.h"
#include "ABScriptMgr.h"
#include "ABUtils.h"
#include "AutoBalance.h"
#include "MapMgr.h"
void AutoBalance_AllCreatureScript::OnBeforeCreatureSelectLevel(const CreatureTemplate* /*creatureTemplate*/, Creature* creature, uint8& level)
{
Map* creatureMap = creature->GetMap();
if (creatureMap && creatureMap->IsDungeon())
{
LOG_DEBUG("module.AutoBalance", "AutoBalance:: ------------------------------------------------");
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnBeforeCreatureSelectLevel: Creature {} ({}) | Entry ID: ({}) | Spawn ID: ({})",
creature->GetName(),
level,
creature->GetEntry(),
creature->GetSpawnId()
);
// Create the new creature's AB info
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
// mark this creature as brand new so that only the level will be modified before creation
creatureABInfo->isBrandNew = true;
// if the creature already has a selectedLevel on it, we have already processed it and can re-use that value
if (creatureABInfo->selectedLevel)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnBeforeCreatureSelectLevel: Creature {} ({}) | has already been processed, using level {}.",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
creatureABInfo->selectedLevel
);
level = creatureABInfo->selectedLevel;
return;
}
// Update the map's data if it is out of date (just before changing the map's creature list)
UpdateMapDataIfNeeded(creature->GetMap());
Map* creatureMap = creature->GetMap();
InstanceMap* instanceMap = creatureMap->ToInstanceMap();
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnBeforeCreatureSelectLevel: Creature {} ({}) | is in map {} ({}{}{}{})",
creature->GetName(),
level,
creatureMap->GetMapName(),
creatureMap->GetId(),
instanceMap ? "-" + std::to_string(instanceMap->GetInstanceId()) : "",
instanceMap ? ", " + std::to_string(instanceMap->GetMaxPlayers()) + "-player" : "",
instanceMap ? instanceMap->IsHeroic() ? " Heroic" : " Normal" : ""
);
// Set level originally intended for the creature
creatureABInfo->UnmodifiedLevel = level;
// add the creature to the map's tracking list
AddCreatureToMapCreatureList(creature);
// Update the map's data if it is out of date (just after changing the map's creature list)
UpdateMapDataIfNeeded(creature->GetMap());
// do an initial modification run of the creature, but don't update the level yet
ModifyCreatureAttributes(creature);
if (isCreatureRelevant(creature))
{
// set the new creature level
level = creatureABInfo->selectedLevel;
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnBeforeCreatureSelectLevel: Creature {} ({}) | will spawn in as level ({}).",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
creatureABInfo->selectedLevel
);
}
else
{
// don't change level value
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnBeforeCreatureSelectLevel: Creature {} ({}) | will spawn in at its original level ({}).",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
creatureABInfo->selectedLevel
);
}
}
}
void AutoBalance_AllCreatureScript::OnCreatureSelectLevel(const CreatureTemplate* /* cinfo */, Creature* creature)
{
// ensure we're in a dungeon with a creature
if (
!creature ||
!creature->GetMap() ||
!creature->GetMap()->IsDungeon() ||
!creature->GetMap()->GetInstanceId()
)
{
return;
}
// get the creature's info
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
// If the creature is brand new, it needs more processing
if (creatureABInfo->isBrandNew)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance:: ------------------------------------------------");
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureSelectLevel: Creature {} ({}) | Entry ID: ({}) | Spawn ID: ({})",
creature->GetName(),
creature->GetLevel(),
creature->GetEntry(),
creature->GetSpawnId()
);
if (creatureABInfo->isBrandNew)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureSelectLevel: Creature {} ({}) | is no longer brand new.",
creature->GetName(),
creature->GetLevel()
);
creatureABInfo->isBrandNew = false;
}
// Update the map's data if it is out of date
UpdateMapDataIfNeeded(creature->GetMap());
ModifyCreatureAttributes(creature);
// store the creature's max health value for validation in `OnCreatureAddWorld`
creatureABInfo->initialMaxHealth = creature->GetMaxHealth();
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
if (creature->GetLevel() != creatureABInfo->selectedLevel && isCreatureRelevant(creature))
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureSelectLevel: Creature {} ({}) | is set to level ({}).",
creature->GetName(),
creature->GetLevel(),
creatureABInfo->selectedLevel
);
creature->SetLevel(creatureABInfo->selectedLevel);
}
}
else
{
LOG_ERROR("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureSelectLevel: Creature {} ({}) | is new to the instance but wasn't flagged as brand new. Please open an issue.",
creature->GetName(),
creature->GetLevel()
);
}
}
void AutoBalance_AllCreatureScript::OnCreatureAddWorld(Creature* creature)
{
if (creature->GetMap()->IsDungeon())
{
Map* creatureMap = creature->GetMap();
InstanceMap* instanceMap = creatureMap->ToInstanceMap();
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
// final checks on the creature before spawning
if (isCreatureRelevant(creature))
{
// level check
if (creature->GetLevel() != creatureABInfo->selectedLevel && !creature->IsSummon())
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureAddWorld: Creature {} ({}) | is set to level ({}) just after being added to the world.",
creature->GetName(),
creature->GetLevel(),
creatureABInfo->selectedLevel
);
creature->SetLevel(creatureABInfo->selectedLevel);
}
// max health check
if (creature->GetMaxHealth() != creatureABInfo->initialMaxHealth)
{
float oldMaxHealth = creature->GetMaxHealth();
float healthPct = creature->GetHealthPct();
creature->SetMaxHealth(creatureABInfo->initialMaxHealth);
creature->SetHealth(creature->GetMaxHealth() * (healthPct / 100));
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureAddWorld: Creature {} ({}) | had its max health changed from ({})->({}) just after being added to the world.",
creature->GetName(),
creature->GetLevel(),
oldMaxHealth,
creatureABInfo->initialMaxHealth
);
}
}
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureAddWorld: Creature {} ({}) | added to map {} ({}{}{}{})",
creature->GetName(),
creature->GetLevel(),
creatureMap->GetMapName(),
creatureMap->GetId(),
instanceMap ? "-" + std::to_string(instanceMap->GetInstanceId()) : "",
instanceMap ? ", " + std::to_string(instanceMap->GetMaxPlayers()) + "-player" : "",
instanceMap ? instanceMap->IsHeroic() ? " Heroic" : " Normal" : ""
);
}
}
void AutoBalance_AllCreatureScript::OnCreatureRemoveWorld(Creature* creature)
{
if (creature->GetMap()->IsDungeon())
{
LOG_DEBUG("module.AutoBalance", "AutoBalance:: ------------------------------------------------");
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureRemoveWorld: Creature {} ({}) | Entry ID: ({}) | Spawn ID: ({})",
creature->GetName(),
creature->GetLevel(),
creature->GetEntry(),
creature->GetSpawnId()
);
InstanceMap* instanceMap = creature->GetMap()->ToInstanceMap();
Map* map = sMapMgr->FindBaseMap(creature->GetMapId());
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnCreatureRemoveWorld: Creature {} ({}) | removed from map {} ({}{}{}{})",
creature->GetName(),
creature->GetLevel(),
map->GetMapName(),
map->GetId(),
instanceMap ? "-" + std::to_string(instanceMap->GetInstanceId()) : "",
instanceMap ? ", " + std::to_string(instanceMap->GetMaxPlayers()) + "-player" : "",
instanceMap ? instanceMap->IsHeroic() ? " Heroic" : " Normal" : ""
);
// remove the creature from the map's tracking list, if present
RemoveCreatureFromMapData(creature);
}
}
void AutoBalance_AllCreatureScript::OnAllCreatureUpdate(Creature* creature, uint32 /*diff*/)
{
// ensure we're in a dungeon with a creature
if (
!creature ||
!creature->GetMap() ||
!creature->GetMap()->IsDungeon() ||
!creature->GetMap()->GetInstanceId()
)
{
return;
}
// update map data before making creature changes
UpdateMapDataIfNeeded(creature->GetMap());
// If the config is out of date and the creature was reset, run modify against it
if (ResetCreatureIfNeeded(creature))
{
LOG_DEBUG("module.AutoBalance", "AutoBalance:: ------------------------------------------------");
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnAllCreatureUpdate: Creature {} ({}) | Entry ID: ({}) | Spawn ID: ({})",
creature->GetName(),
creature->GetLevel(),
creature->GetEntry(),
creature->GetSpawnId()
);
// Update the map's data if it is out of date
UpdateMapDataIfNeeded(creature->GetMap());
ModifyCreatureAttributes(creature);
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
if (creature->GetLevel() != creatureABInfo->selectedLevel && isCreatureRelevant(creature))
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::OnAllCreatureUpdate: Creature {} ({}) | is set to level ({}).",
creature->GetName(),
creature->GetLevel(),
creatureABInfo->selectedLevel
);
creature->SetLevel(creatureABInfo->selectedLevel);
}
}
}
// Reset the passed creature to stock if the config has changed
bool AutoBalance_AllCreatureScript::ResetCreatureIfNeeded(Creature* creature)
{
// make sure we have a creature
if (!creature || !isCreatureRelevant(creature))
return false;
// get (or create) map and creature info
AutoBalanceMapInfo* mapABInfo = GetMapInfo(creature->GetMap());
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
// if creature is dead and mapConfigTime is 0, skip for now
if (creature->isDead() && creatureABInfo->mapConfigTime == 1)
return false;
// if the creature is dead but mapConfigTime is NOT 0, we set it to 0 so that it will be recalculated if revived
// also remember that this creature was once alive but is now dead
else if (creature->isDead())
{
LOG_DEBUG("module.AutoBalance", "AutoBalance:: ------------------------------------------------");
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ResetCreatureIfNeeded: Creature {} ({}) | is dead and mapConfigTime is not 0 - prime for reset if revived.", creature->GetName(), creature->GetLevel());
creatureABInfo->mapConfigTime = 1;
creatureABInfo->wasAliveNowDead = true;
return false;
}
// if the config is outdated, reset the creature
if (creatureABInfo->mapConfigTime < mapABInfo->mapConfigTime)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance:: ------------------------------------------------");
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ResetCreatureIfNeeded: Creature {} ({}) | Entry ID: ({}) | Spawn ID: ({})",
creature->GetName(),
creature->GetLevel(),
creature->GetEntry(),
creature->GetSpawnId()
);
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ResetCreatureIfNeeded: Creature {} ({}) | Map config time is out of date ({} < {}). Resetting creature before modify.",
creature->GetName(),
creature->GetLevel(),
creatureABInfo->mapConfigTime,
mapABInfo->mapConfigTime
);
// retain some values
uint8 unmodifiedLevel = creatureABInfo->UnmodifiedLevel;
bool isActive = creatureABInfo->isActive;
bool wasAliveNowDead = creatureABInfo->wasAliveNowDead;
bool isInCreatureList = creatureABInfo->isInCreatureList;
// reset AutoBalance modifiers
creature->CustomData.Erase("AutoBalanceCreatureInfo");
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
// grab the creature's template and the original creature's stats
CreatureTemplate const* creatureTemplate = creature->GetCreatureTemplate();
// set the creature's level
if (creature->GetLevel() != unmodifiedLevel)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ResetCreatureIfNeeded: Creature {} ({}) | is set to level ({}).",
creature->GetName(),
creature->GetLevel(),
unmodifiedLevel
);
creature->SetLevel(unmodifiedLevel);
creature->UpdateAllStats();
}
else
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ResetCreatureIfNeeded: Creature {} ({}) | is already set to level ({}).",
creature->GetName(),
creature->GetLevel(),
unmodifiedLevel
);
}
// get the creature's base stats
CreatureBaseStats const* origCreatureBaseStats = sObjectMgr->GetCreatureBaseStats(unmodifiedLevel, creatureTemplate->unit_class);
// health
float currentHealthPercent = (float)creature->GetHealth() / (float)creature->GetMaxHealth();
creature->SetMaxHealth(origCreatureBaseStats->GenerateHealth(creatureTemplate));
creature->SetHealth((float)origCreatureBaseStats->GenerateHealth(creatureTemplate) * currentHealthPercent);
// mana
if (creature->getPowerType() == POWER_MANA && creature->GetPower(POWER_MANA) >= 0 && creature->GetMaxPower(POWER_MANA) > 0)
{
float currentManaPercent = creature->GetPower(POWER_MANA) / creature->GetMaxPower(POWER_MANA);
creature->SetMaxPower(POWER_MANA, origCreatureBaseStats->GenerateMana(creatureTemplate));
creature->SetPower(POWER_MANA, creature->GetMaxPower(POWER_MANA) * currentManaPercent);
}
// armor
creature->SetArmor(origCreatureBaseStats->GenerateArmor(creatureTemplate));
// restore the saved data
creatureABInfo->UnmodifiedLevel = unmodifiedLevel;
creatureABInfo->isActive = isActive;
creatureABInfo->wasAliveNowDead = wasAliveNowDead;
creatureABInfo->isInCreatureList = isInCreatureList;
// damage and ccduration are handled using AutoBalanceCreatureInfo data only
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ResetCreatureIfNeeded: Creature {} ({}) is reset to its original stats.",
creature->GetName(),
creature->GetLevel()
);
// return true to indicate that the creature was reset
return true;
}
// creature was not reset, return false
return false;
}
void AutoBalance_AllCreatureScript::ModifyCreatureAttributes(Creature* creature)
{
// make sure we have a creature
if (!creature)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: creature is null.");
return;
}
// grab creature and map data
AutoBalanceCreatureInfo* creatureABInfo = creature->CustomData.GetDefault<AutoBalanceCreatureInfo>("AutoBalanceCreatureInfo");
Map* map = creature->GetMap();
InstanceMap* instanceMap = map->ToInstanceMap();
AutoBalanceMapInfo* mapABInfo = GetMapInfo(instanceMap);
// mark the creature as updated using the current settings if needed
// if this creature is brand new, do not update this so that it will be re-processed next OnCreatureUpdate
if (creatureABInfo->mapConfigTime < mapABInfo->mapConfigTime && !creatureABInfo->isBrandNew)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | Map config time set to ({}).",
creature->GetName(),
creature->GetLevel(),
mapABInfo->mapConfigTime
);
creatureABInfo->mapConfigTime = mapABInfo->mapConfigTime;
}
// check to make sure that the creature's map is enabled for scaling
if (!mapABInfo->enabled)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is in map {} ({}{}{}{}) that is not enabled, not changed.",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
map->GetMapName(),
map->GetId(),
instanceMap ? "-" + std::to_string(instanceMap->GetInstanceId()) : "",
instanceMap ? ", " + std::to_string(instanceMap->GetMaxPlayers()) + "-player" : "",
instanceMap ? instanceMap->IsHeroic() ? " Heroic" : " Normal" : ""
);
// return the creature back to their original level, if it's not already
creatureABInfo->selectedLevel = creatureABInfo->UnmodifiedLevel;
return;
}
// if the creature isn't relevant, don't modify it
if (!isCreatureRelevant(creature))
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is not relevant, not changed.",
creature->GetName(),
creatureABInfo->UnmodifiedLevel
);
// return the creature back to their original level, if it's not already
creatureABInfo->selectedLevel = creatureABInfo->UnmodifiedLevel;
return;
}
// if this creature is below 85% of the minimum LFG level for the map, make no changes
// if this creature is above 115% of the maximum LFG level for the map, make no changes
// if this is a critter that is substantial enough to be considered a real enemy, still modify it
// if this is a trigger, still modify it
if (
(
(creatureABInfo->UnmodifiedLevel < (uint8)(((float)mapABInfo->lfgMinLevel * .85f) + 0.5f)) ||
(creatureABInfo->UnmodifiedLevel > (uint8)(((float)mapABInfo->lfgMaxLevel * 1.15f) + 0.5f))
) &&
(
!(creature->IsCritter() && creatureABInfo->UnmodifiedLevel >= 5 && creature->GetMaxHealth() > 100) &&
!creature->IsTrigger()
)
)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is a {} outside of the expected NPC level range for the map ({} to {}), not modified.",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
creature->IsCritter() ? "critter" : "creature",
(uint8)(((float)mapABInfo->lfgMinLevel * .85f) + 0.5f),
(uint8)(((float)mapABInfo->lfgMaxLevel * 1.15f) + 0.5f)
);
creatureABInfo->selectedLevel = creatureABInfo->UnmodifiedLevel;
return;
}
// if the creature was dead (but this function is being called because they are being revived), reset it and allow modifications
if (creatureABInfo->wasAliveNowDead)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | was dead but appears to be alive now, reset wasAliveNowDead flag.", creature->GetName(), creatureABInfo->UnmodifiedLevel);
// if the creature was dead, reset it
creatureABInfo->wasAliveNowDead = false;
}
// if the creature is dead and wasn't marked as dead by this script, simply skip
else if (creature->isDead())
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is dead, do not modify.", creature->GetName(), creatureABInfo->UnmodifiedLevel);
return;
}
CreatureTemplate const* creatureTemplate = creature->GetCreatureTemplate();
// check to see if the creature is in the forced num players list
uint32 forcedNumPlayers = GetForcedNumPlayers(creatureTemplate->Entry);
if (forcedNumPlayers == 0)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is in the forced num players list with a value of 0, not changed.", creature->GetName(), creatureABInfo->UnmodifiedLevel);
return; // forcedNumPlayers 0 means that the creature is contained in DisabledID -> no scaling
}
// start with the map's adjusted player count
uint32 adjustedPlayerCount = mapABInfo->adjustedPlayerCount;
// if the forced value is set and the adjusted player count is above the forced value, change it to match
if (forcedNumPlayers > 0 && adjustedPlayerCount > forcedNumPlayers)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is in the forced num players list with a value of {}, adjusting adjustedPlayerCount to match.", creature->GetName(), creatureABInfo->UnmodifiedLevel, forcedNumPlayers);
adjustedPlayerCount = forcedNumPlayers;
}
// store the current player count in the creature and map's data
creatureABInfo->instancePlayerCount = adjustedPlayerCount;
if (!creatureABInfo->instancePlayerCount) // no players in map, do not modify attributes
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is on a map with no players, not changed.", creature->GetName(), creatureABInfo->UnmodifiedLevel);
return;
}
if (!sABScriptMgr->OnBeforeModifyAttributes(creature, creatureABInfo->instancePlayerCount))
return;
// only scale levels if level scaling is enabled and the instance's average creature level is not within the skip range
if
(
LevelScaling &&
(
(mapABInfo->avgCreatureLevel > mapABInfo->highestPlayerLevel + mapABInfo->levelScalingSkipHigherLevels || mapABInfo->levelScalingSkipHigherLevels == 0) ||
(mapABInfo->avgCreatureLevel < mapABInfo->highestPlayerLevel - mapABInfo->levelScalingSkipLowerLevels || mapABInfo->levelScalingSkipLowerLevels == 0)
) &&
!creatureABInfo->neverLevelScale
)
{
uint8 selectedLevel;
// handle "special" creatures
// note that these already passed a more complex check above
if (
(creature->IsTotem() && creature->IsSummon() && creatureABInfo->summoner && creatureABInfo->summoner->IsPlayer()) ||
(
creature->IsCritter() && creatureABInfo->UnmodifiedLevel <= 5 && creature->GetMaxHealth() <= 100
)
)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is a {} that will not be level scaled, but will have modifiers set.",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
creature->IsTotem() ? "totem" : "critter"
);
selectedLevel = creatureABInfo->UnmodifiedLevel;
}
// if we're using dynamic scaling, calculate the creature's level based relative to the highest player level in the map
else if (LevelScalingMethod == AUTOBALANCE_SCALING_DYNAMIC)
{
// calculate the creature's new level
selectedLevel = (mapABInfo->highestPlayerLevel + mapABInfo->levelScalingDynamicCeiling) - (mapABInfo->highestCreatureLevel - creatureABInfo->UnmodifiedLevel);
// check to be sure that the creature's new level is at least the dynamic scaling floor
if (selectedLevel < (mapABInfo->highestPlayerLevel - mapABInfo->levelScalingDynamicFloor))
selectedLevel = mapABInfo->highestPlayerLevel - mapABInfo->levelScalingDynamicFloor;
// check to be sure that the creature's new level is no higher than the dynamic scaling ceiling
if (selectedLevel > (mapABInfo->highestPlayerLevel + mapABInfo->levelScalingDynamicCeiling))
selectedLevel = mapABInfo->highestPlayerLevel + mapABInfo->levelScalingDynamicCeiling;
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | scaled to level ({}) via dynamic scaling.",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
selectedLevel
);
}
// otherwise we're using "fixed" scaling and should use the highest player level in the map
else
{
selectedLevel = mapABInfo->highestPlayerLevel;
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | scaled to level ({}) via fixed scaling.", creature->GetName(), creatureABInfo->UnmodifiedLevel, selectedLevel);
}
creatureABInfo->selectedLevel = selectedLevel;
if (creature->GetLevel() != selectedLevel)
{
if (!creatureABInfo->isBrandNew)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is set to new selectedLevel ({}).",
creature->GetName(),
creatureABInfo->UnmodifiedLevel,
selectedLevel
);
creature->SetLevel(selectedLevel);
}
}
}
else if (!LevelScaling)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | not level scaled due to level scaling being disabled.", creature->GetName(), creatureABInfo->UnmodifiedLevel);
creatureABInfo->selectedLevel = creatureABInfo->UnmodifiedLevel;
}
else if (creatureABInfo->neverLevelScale)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | not level scaled due to being marked as multipliers only.", creature->GetName(), creatureABInfo->UnmodifiedLevel);
creatureABInfo->selectedLevel = creatureABInfo->UnmodifiedLevel;
}
else
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | not level scaled due the instance's average creature level being inside the skip range.", creature->GetName(), creatureABInfo->UnmodifiedLevel);
creatureABInfo->selectedLevel = creatureABInfo->UnmodifiedLevel;
}
if (creatureABInfo->isBrandNew)
{
LOG_DEBUG("module.AutoBalance", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | is brand new, do not modify level or stats yet.",
creature->GetName(),
creatureABInfo->UnmodifiedLevel
);
return;
}
CreatureBaseStats const* origCreatureBaseStats = sObjectMgr->GetCreatureBaseStats(creatureABInfo->UnmodifiedLevel, creatureTemplate->unit_class);
CreatureBaseStats const* newCreatureBaseStats = sObjectMgr->GetCreatureBaseStats(creatureABInfo->selectedLevel, creatureTemplate->unit_class);
// Inflection Point
AutoBalanceInflectionPointSettings inflectionPointSettings = getInflectionPointSettings(instanceMap, isBossOrBossSummon(creature));
// Generate the default multiplier
float defaultMultiplier = getDefaultMultiplier(instanceMap, inflectionPointSettings);
if (!sABScriptMgr->OnAfterDefaultMultiplier(creature, defaultMultiplier))
return;
// Stat Modifiers
AutoBalanceStatModifiers statModifiers = getStatModifiers(map, creature);
float statMod_global = statModifiers.global;
float statMod_health = statModifiers.health;
float statMod_mana = statModifiers.mana;
float statMod_armor = statModifiers.armor;
float statMod_damage = statModifiers.damage;
float statMod_ccDuration = statModifiers.ccduration;
// Storage for the final values applied to the creature
uint32 newFinalHealth = 0;
uint32 newFinalMana = 0;
uint32 newFinalArmor = 0;
//
// Health Scaling
//
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | ---------- HEALTH MULTIPLIER ----------",
creature->GetName(),
creatureABInfo->selectedLevel
);
float healthMultiplier = defaultMultiplier * statMod_global * statMod_health;
float scaledHealthMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | HealthMultiplier: ({}) = defaultMultiplier ({}) * statMod_global ({}) * statMod_health ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
healthMultiplier,
defaultMultiplier,
statMod_global,
statMod_health
);
// Can't be less than MinHPModifier
if (healthMultiplier <= MinHPModifier)
{
healthMultiplier = MinHPModifier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | HealthMultiplier: ({}) - capped to MinHPModifier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
healthMultiplier,
MinHPModifier
);
}
// set the non-level-scaled health multiplier on the creature's AB info
creatureABInfo->HealthMultiplier = healthMultiplier;
// only level scale health if level scaling is enabled and the creature level has been altered
if (LevelScaling && creatureABInfo->selectedLevel != creatureABInfo->UnmodifiedLevel)
{
// the max health that the creature had before we did anything with it
float origHealth = origCreatureBaseStats->GenerateHealth(creatureTemplate);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | origHealth ({}) = origCreatureBaseStats->GenerateHealth(creatureTemplate)",
creature->GetName(),
creatureABInfo->selectedLevel,
origHealth
);
// the base health of the new creature level for this creature's class
// uses a custom smoothing formula to smooth transitions between expansions
float newBaseHealth = getBaseExpansionValueForLevel(newCreatureBaseStats->BaseHealth, mapABInfo->highestPlayerLevel);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newBaseHealth ({}) = getBaseExpansionValueForLevel(newCreatureBaseStats->BaseHealth, mapABInfo->highestPlayerLevel ({}))",
creature->GetName(),
creatureABInfo->selectedLevel,
newBaseHealth,
mapABInfo->highestPlayerLevel
);
// the health of the creature at its new level (before per-player scaling)
float newHealth = newBaseHealth * creatureTemplate->ModHealth;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newHealth ({}) = newBaseHealth ({}) * creature ModHealth ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newHealth,
newBaseHealth,
creatureTemplate->ModHealth
);
// the multiplier that would need to be applied to the creature's original health to get the new level's health (before per-player scaling)
float newHealthMultiplier = newHealth / origHealth;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newHealthMultiplier ({}) = newHealth ({}) / origHealth ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newHealthMultiplier,
newHealth,
origHealth
);
// the multiplier that would need to be applied to the creature's original health to get the new level's health (after per-player scaling)
scaledHealthMultiplier = healthMultiplier * newHealthMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | scaledHealthMultiplier ({}) = healthMultiplier ({}) * newHealthMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
scaledHealthMultiplier,
healthMultiplier,
newHealthMultiplier
);
// the actual health value to be applied to the level-scaled and player-scaled creature
newFinalHealth = round(origHealth * scaledHealthMultiplier);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newFinalHealth ({}) = origHealth ({}) * scaledHealthMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newFinalHealth,
origHealth,
scaledHealthMultiplier
);
}
else
{
// the non-level-scaled health multiplier is the same as the level-scaled health multiplier
scaledHealthMultiplier = healthMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | scaledHealthMultiplier ({}) = healthMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
scaledHealthMultiplier,
healthMultiplier
);
// the original health of the creature
uint32 origHealth = origCreatureBaseStats->GenerateHealth(creatureTemplate);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | origHealth ({}) = origCreatureBaseStats->GenerateHealth(creatureTemplate)",
creature->GetName(),
creatureABInfo->selectedLevel,
origHealth
);
// the actual health value to be applied to the player-scaled creature
newFinalHealth = round(origHealth * creatureABInfo->HealthMultiplier);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newFinalHealth ({}) = origHealth ({}) * HealthMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newFinalHealth,
origHealth,
creatureABInfo->HealthMultiplier
);
}
//
// Mana Scaling
//
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | ---------- MANA MULTIPLIER ----------",
creature->GetName(),
creatureABInfo->selectedLevel
);
float manaMultiplier = defaultMultiplier * statMod_global * statMod_mana;
float scaledManaMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | ManaMultiplier: ({}) = defaultMultiplier ({}) * statMod_global ({}) * statMod_mana ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
manaMultiplier,
defaultMultiplier,
statMod_global,
statMod_mana
);
// Can't be less than MinManaModifier
if (manaMultiplier <= MinManaModifier)
{
manaMultiplier = MinManaModifier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | ManaMultiplier: ({}) - capped to MinManaModifier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
manaMultiplier,
MinManaModifier
);
}
// if the creature doesn't have mana, set the multiplier to 0.0
if (!origCreatureBaseStats->GenerateMana(creatureTemplate))
{
manaMultiplier = 0.0f;
creatureABInfo->ManaMultiplier = 0.0f;
scaledManaMultiplier = 0.0f;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | Creature doesn't have mana, multiplier set to ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
creatureABInfo->ManaMultiplier
);
}
// if the creature has mana, continue calculations
else
{
// set the non-level-scaled mana multiplier on the creature's AB info
creatureABInfo->ManaMultiplier = manaMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | ManaMultiplier: ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
creatureABInfo->ManaMultiplier
);
// only level scale mana if level scaling is enabled and the creature level has been altered
if (LevelScaling && creatureABInfo->selectedLevel != creatureABInfo->UnmodifiedLevel)
{
// the max mana that the creature had before we did anything with it
uint32 origMana = origCreatureBaseStats->GenerateMana(creatureTemplate);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | origMana ({}) = origCreatureBaseStats->GenerateMana(creatureTemplate)",
creature->GetName(),
creatureABInfo->selectedLevel,
origMana
);
// the max mana that the creature would have at its new level
// there is no per-expansion adjustment for mana
uint32 newMana = newCreatureBaseStats->GenerateMana(creatureTemplate);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newMana ({}) = newCreatureBaseStats->GenerateMana(creatureTemplate)",
creature->GetName(),
creatureABInfo->selectedLevel,
newMana
);
// the multiplier that would need to be applied to the creature's original mana to get the new level's mana (before per-player scaling)
float newManaMultiplier = (float)newMana / (float)origMana;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newManaMultiplier ({}) = newMana ({}) / origMana ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newManaMultiplier,
newMana,
origMana
);
// the multiplier that would need to be applied to the creature's original mana to get the new level's mana (after per-player scaling)
scaledManaMultiplier = manaMultiplier * newManaMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | scaledManaMultiplier ({}) = manaMultiplier ({}) * newManaMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
scaledManaMultiplier,
manaMultiplier,
newManaMultiplier
);
// the actual mana value to be applied to the level-scaled and player-scaled creature
newFinalMana = round(origMana * scaledManaMultiplier);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newFinalMana ({}) = origMana ({}) * scaledManaMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newFinalMana,
origMana,
scaledManaMultiplier
);
}
else
{
// scaled mana multiplier is the same as the non-level-scaled mana multiplier
scaledManaMultiplier = manaMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | scaledManaMultiplier ({}) = manaMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
scaledManaMultiplier,
manaMultiplier
);
// the original mana of the creature
uint32 origMana = origCreatureBaseStats->GenerateMana(creatureTemplate);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | origMana ({}) = origCreatureBaseStats->GenerateMana(creatureTemplate)",
creature->GetName(),
creatureABInfo->selectedLevel,
origMana
);
// the actual mana value to be applied to the player-scaled creature
newFinalMana = round(origMana * creatureABInfo->ManaMultiplier);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newFinalMana ({}) = origMana ({}) * creatureABInfo->ManaMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newFinalMana,
origMana,
creatureABInfo->ManaMultiplier
);
}
}
//
// Armor Scaling
//
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | ---------- ARMOR MULTIPLIER ----------",
creature->GetName(),
creatureABInfo->selectedLevel
);
float armorMultiplier = defaultMultiplier * statMod_global * statMod_armor;
float scaledArmorMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | armorMultiplier: ({}) = defaultMultiplier ({}) * statMod_global ({}) * statMod_armor ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
armorMultiplier,
defaultMultiplier,
statMod_global,
statMod_armor
);
// set the non-level-scaled armor multiplier on the creature's AB info
creatureABInfo->ArmorMultiplier = armorMultiplier;
// only level scale armor if level scaling is enabled and the creature level has been altered
if (LevelScaling && creatureABInfo->selectedLevel != creatureABInfo->UnmodifiedLevel)
{
// the armor that the creature had before we did anything with it
uint32 origArmor = origCreatureBaseStats->GenerateArmor(creatureTemplate);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | origArmor ({}) = origCreatureBaseStats->GenerateArmor(creatureTemplate)",
creature->GetName(),
creatureABInfo->selectedLevel,
origArmor
);
// the armor that the creature would have at its new level
// there is no per-expansion adjustment for armor
uint32 newArmor = newCreatureBaseStats->GenerateArmor(creatureTemplate);
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newArmor ({}) = newCreatureBaseStats->GenerateArmor(creatureTemplate)",
creature->GetName(),
creatureABInfo->selectedLevel,
newArmor
);
// the multiplier that would need to be applied to the creature's original armor to get the new level's armor (before per-player scaling)
float newArmorMultiplier = (float)newArmor / (float)origArmor;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | newArmorMultiplier ({}) = newArmor ({}) / origArmor ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
newArmorMultiplier,
newArmor,
origArmor
);
// the multiplier that would need to be applied to the creature's original armor to get the new level's armor (after per-player scaling)
scaledArmorMultiplier = armorMultiplier * newArmorMultiplier;
LOG_DEBUG("module.AutoBalance_StatGeneration", "AutoBalance_AllCreatureScript::ModifyCreatureAttributes: Creature {} ({}) | scaledArmorMultiplier ({}) = armorMultiplier ({}) * newArmorMultiplier ({})",
creature->GetName(),
creatureABInfo->selectedLevel,
scaledArmorMultiplier,
armorMultiplier,
newArmorMultiplier
);
// the actual armor value to be applied to the level-scaled and player-scaled creature
newFinalArmor = round(origArmor * scaledArmorMultiplier);