/
champion.cpp
2607 lines (2303 loc) · 99.5 KB
/
champion.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
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* Based on the Reverse Engineering work of Christophe Fontanel,
* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/)
*/
#include "dm/champion.h"
#include "dm/dungeonman.h"
#include "dm/eventman.h"
#include "dm/menus.h"
#include "dm/inventory.h"
#include "dm/objectman.h"
#include "dm/text.h"
#include "dm/timeline.h"
#include "dm/projexpl.h"
#include "dm/group.h"
#include "dm/movesens.h"
#include "dm/sounds.h"
namespace DM {
void Champion::resetToZero() {
for (int16 i = 0; i < 30; ++i)
_slots[i] = Thing::_none;
for (int16 i = 0; i < 20; ++i)
_skills[i].resetToZero();
_attributes = _wounds = 0;
memset(_statistics, 0, 7 * 3);
memset(_name, '\0', 8);
memset(_title, '\0', 20);
_dir = kDMDirNorth;
_cell = k0_ViewCellFronLeft;
_actionIndex = kDMActionN;
_symbolStep = 0;
memset(_symbols, '\0', 5);
_directionMaximumDamageReceived = _maximumDamageReceived = _poisonEventCount = _enableActionEventIndex = 0;
_hideDamageReceivedIndex = _currHealth = _maxHealth = _currStamina = _maxStamina = _currMana = _maxMana = 0;
_actionDefense = _food = _water = _load = _shieldDefense = 0;
memset(_portrait, 0, 464);
}
void Champion::setWoundsFlag(ChampionWound flag, bool value) {
if (value)
_wounds |= flag;
else
_wounds &= ~flag;
}
void Champion::setAttributeFlag(ChampionAttribute flag, bool value) {
if (value)
_attributes |= flag;
else
_attributes &= ~flag;
}
void ChampionMan::initConstants() {
static const char *g417_baseSkillName_EN_ANY[4] = {"FIGHTER", "NINJA", "PRIEST", "WIZARD"};
static const char *g417_baseSkillName_DE_DEU[4] = {"KAEMPFER", "NINJA", "PRIESTER", "MAGIER"};
static const char *g417_baseSkillName_FR_FRA[4] = {"GUERRIER", "NINJA", "PRETRE", "SORCIER"};
static Box boxChampionIcons[4] = {
Box(281, 299, 0, 13),
Box(301, 319, 0, 13),
Box(301, 319, 15, 28),
Box(281, 299, 15, 28)
};
static Color championColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};
int16 lightPowerToLightAmount[16] = {0, 5, 12, 24, 33, 40, 46, 51, 59, 68, 76, 82, 89, 94, 97, 100};
uint16 slotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks
/* 30 for champion inventory, 8 for chest */
0xFFFF, /* Ready Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Action Hand Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0x0002, /* Head Head */
0x0008, /* Torso Torso */
0x0010, /* Legs Legs */
0x0020, /* Feet Feet */
0x0100, /* Pouch 2 Pouch */
0x0080, /* Quiver Line2 1 Quiver 2 */
0x0080, /* Quiver Line1 2 Quiver 2 */
0x0080, /* Quiver Line2 2 Quiver 2 */
0x0004, /* Neck Neck */
0x0100, /* Pouch 1 Pouch */
0x0040, /* Quiver Line1 1 Quiver 1 */
0xFFFF, /* Backpack Line1 1 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line2 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 2 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 3 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 4 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 5 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 6 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 7 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 8 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0xFFFF, /* Backpack Line1 9 Mouth/Head/Neck/Torso/Legs/Feet/Quiver 1/Quiver 2/Pouch/Hands/Chest */
0x0400, /* Chest 1 Chest */
0x0400, /* Chest 2 Chest */
0x0400, /* Chest 3 Chest */
0x0400, /* Chest 4 Chest */
0x0400, /* Chest 5 Chest */
0x0400, /* Chest 6 Chest */
0x0400, /* Chest 7 Chest */
0x0400 /* Chest 8 Chest */
};
_boxChampionPortrait = Box(0, 31, 0, 28); // @ G0047_s_Graphic562_Box_ChampionPortrait
const char **baseSkillName;
switch (_vm->getGameLanguage()) { // localized
case Common::EN_ANY:
baseSkillName = g417_baseSkillName_EN_ANY;
break;
case Common::DE_DEU:
baseSkillName = g417_baseSkillName_DE_DEU;
break;
case Common::FR_FRA:
baseSkillName = g417_baseSkillName_FR_FRA;
break;
default:
error("Unexpected language used");
}
for (int i = 0; i < 4; ++i) {
_baseSkillName[i] = baseSkillName[i];
_championColor[i] = championColor[i];
_boxChampionIcons[i] = boxChampionIcons[i];
}
for (int i = 0; i < 16; i++)
_lightPowerToLightAmount[i] = lightPowerToLightAmount[i];
for (int i = 0; i < 38; i++)
_slotMasks[i] = slotMasks[i];
}
ChampionMan::ChampionMan(DMEngine *vm) : _vm(vm) {
for (uint16 i = 0; i < 4; ++i) {
_championPendingDamage[i] = 0;
_championPendingWounds[i] = 0;
_champions[i].resetToZero();
}
_partyChampionCount = 0;
_partyDead = false;
_leaderHandObject = Thing(0);
_leaderIndex = kDMChampionNone;
_candidateChampionOrdinal = 0;
_partyIsSleeping = false;
_actingChampionOrdinal = 0;
_leaderHandObjectIconIndex = (IconIndice)0;
_leaderEmptyHanded = false;
_party.resetToZero();
_magicCasterChampionIndex = kDMChampionNone;
_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
initConstants();
}
bool ChampionMan::isLeaderHandObjectThrown(int16 side) {
if (_leaderIndex == kDMChampionNone)
return false;
return isObjectThrown(_leaderIndex, kDMSlotLeaderHand, side);
}
bool ChampionMan::isObjectThrown(uint16 champIndex, int16 slotIndex, int16 side) {
bool throwingLeaderHandObjectFl = false;
Thing curThing;
Champion *curChampion = nullptr;
Thing actionHandThing;
if (slotIndex < 0) { /* Throw object in leader hand, which is temporarily placed in action hand */
if (_leaderEmptyHanded)
return false;
curThing = getObjectRemovedFromLeaderHand();
curChampion = &_champions[champIndex];
actionHandThing = curChampion->getSlot(kDMSlotActionHand);
curChampion->setSlot(kDMSlotActionHand, curThing);
slotIndex = kDMSlotActionHand;
throwingLeaderHandObjectFl = true;
}
int16 kineticEnergy = getStrength(champIndex, slotIndex);
if (throwingLeaderHandObjectFl) {
// In this case, curChampion and actionHandThing are set.
curChampion->setSlot((ChampionSlot)slotIndex, actionHandThing);
} else {
curThing = getObjectRemovedFromSlot(champIndex, slotIndex);
if (curThing == Thing::_none)
return false;
}
_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
decrementStamina(champIndex, getThrowingStaminaCost(curThing));
disableAction(champIndex, 4);
int16 experience = 8;
int16 weaponKineticEnergy = 1;
if (curThing.getType() == kDMThingTypeWeapon) {
experience += 4;
WeaponInfo *curWeapon = _vm->_dungeonMan->getWeaponInfo(curThing);
if (curWeapon->_class <= k12_WeaponClassPoisinDart) {
weaponKineticEnergy = curWeapon->_kineticEnergy;
experience += weaponKineticEnergy >> 2;
}
}
addSkillExperience(champIndex, kDMSkillThrow, experience);
kineticEnergy += weaponKineticEnergy;
int16 skillLevel = getSkillLevel((ChampionIndex)champIndex, kDMSkillThrow);
kineticEnergy += _vm->getRandomNumber(16) + (kineticEnergy >> 1) + skillLevel;
int16 attack = CLIP<int16>(40, ((skillLevel << 3) + _vm->getRandomNumber(32)), 200);
int16 stepEnergy = MAX(5, 11 - skillLevel);
_vm->_projexpl->createProjectile(curThing, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY,
_vm->normalizeModulo4(_vm->_dungeonMan->_partyDir + side),
_vm->_dungeonMan->_partyDir, kineticEnergy, attack, stepEnergy);
_vm->_projectileDisableMovementTicks = 4;
_vm->_lastProjectileDisabledMovementDirection = _vm->_dungeonMan->_partyDir;
drawChampionState((ChampionIndex)champIndex);
return true;
}
uint16 ChampionMan::getChampionPortraitX(uint16 index) {
return ((index) & 0x7) << 5;
}
uint16 ChampionMan::getChampionPortraitY(uint16 index) {
return ((index) >> 3) * 29;
}
int16 ChampionMan::getDecodedValue(char *string, uint16 characterCount) {
int val = 0;
for (uint16 i = 0; i < characterCount; ++i) {
val = (val << 4) + (string[i] - 'A');
}
return val;
}
void ChampionMan::drawHealthOrStaminaOrManaValue(int16 posY, int16 currVal, int16 maxVal) {
Common::String tmp = getStringFromInteger(currVal, true, 3);
_vm->_textMan->printToViewport(55, posY, k13_ColorLightestGray, tmp.c_str());
_vm->_textMan->printToViewport(73, posY, k13_ColorLightestGray, "/");
tmp = getStringFromInteger(maxVal, true, 3);
_vm->_textMan->printToViewport(79, posY, k13_ColorLightestGray, tmp.c_str());
}
uint16 ChampionMan::getHandSlotIndex(uint16 slotBoxIndex) {
return slotBoxIndex & 0x1;
}
Common::String ChampionMan::getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount) {
Common::String valToStr = Common::String::format("%d", val);
Common::String result;
if (padding) {
for (int16 i = 0, end = paddingCharCount - valToStr.size(); i < end; ++i)
result += ' ';
}
return result += valToStr;
}
void ChampionMan::applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing) {
int16 statIndex = kDMStatLuck;
int16 modifier = 0;
ThingType thingType = thing.getType();
bool cursed = false;
if (((thingType == kDMThingTypeWeapon) || (thingType == kDMThingTypeArmour))
&& (slotIndex >= kDMSlotReadyHand) && (slotIndex <= kDMSlotQuiverLine1_1)) {
if (thingType == kDMThingTypeWeapon) {
Weapon *weapon = (Weapon *)_vm->_dungeonMan->getThingData(thing);
cursed = weapon->getCursed();
} else {
// k6_ArmourThingType
Armour *armour = (Armour *)_vm->_dungeonMan->getThingData(thing);
cursed = armour->getCursed();
}
if (cursed) {
statIndex = kDMStatLuck;
modifier = -3;
}
}
if (!cursed) {
statIndex = (ChampionStatType)thingType; // variable sharing
if ((iconIndex == kDMIconIndiceJunkRabbitsFoot) && (slotIndex < kDMSlotChest1)) {
statIndex = kDMStatLuck;
modifier = 10;
} else if (slotIndex == kDMSlotActionHand) {
if (iconIndex == kDMIconIndiceWeaponMaceOfOrder) {
statIndex = kDMStatStrength;
modifier = 5;
} else {
statIndex = kDMStatMana;
if ((iconIndex >= kDMIconIndiceWeaponStaffOfClawsEmpty) && (iconIndex <= kDMIconIndiceWeaponStaffOfClawsFull)) {
modifier = 4;
} else {
switch (iconIndex) {
case kDMIconIndiceWeaponDeltaSideSplitter:
modifier = 1;
break;
case kDMIconIndiceWeaponTheInquisitorDragonFang:
modifier = 2;
break;
case kDMIconIndiceWeaponVorpalBlade:
modifier = 4;
break;
case kDMIconIndiceWeaponStaff:
modifier = 2;
break;
case kDMIconIndiceWeaponWand:
modifier = 1;
break;
case kDMIconIndiceWeaponTeowand:
modifier = 6;
break;
case kDMIconIndiceWeaponYewStaff:
modifier = 4;
break;
case kDMIconIndiceWeaponStaffOfManarStaffOfIrra:
modifier = 10;
break;
case kDMIconIndiceWeaponSnakeStaffCrossOfNeta:
modifier = 8;
break;
case kDMIconIndiceWeaponTheConduitSerpentStaff:
modifier = 16;
break;
case kDMIconIndiceWeaponDragonSpit:
modifier = 7;
break;
case kDMIconIndiceWeaponSceptreOfLyf:
modifier = 5;
break;
default:
break;
}
}
}
} else if (slotIndex == kDMSlotLegs) {
if (iconIndex == kDMIconIndiceArmourPowertowers) {
statIndex = kDMStatStrength;
modifier = 10;
}
} else if (slotIndex == kDMSlotHead) {
switch (iconIndex) {
case kDMIconIndiceArmourCrownOfNerra:
statIndex = kDMStatWisdom;
modifier = 10;
break;
case kDMIconIndiceArmourDexhelm:
statIndex = kDMStatDexterity;
modifier = 10;
break;
default:
break;
}
} else if (slotIndex == kDMSlotTorso) {
switch (iconIndex) {
case kDMIconIndiceArmourFlamebain:
statIndex = kDMStatAntifire;
modifier = 12;
break;
case kDMIconIndiceArmourCloakOfNight:
statIndex = kDMStatDexterity;
modifier = 8;
break;
default:
break;
}
} else if (slotIndex == kDMSlotNeck) {
switch (iconIndex) {
case kDMIconIndiceJunkJewelSymalUnequipped:
case kDMIconIndiceJunkJewelSymalEquipped:
statIndex = kDMStatAntimagic;
modifier = 15;
break;
case kDMIconIndiceArmourCloakOfNight:
statIndex = kDMStatDexterity;
modifier = 8;
break;
case kDMIconIndiceJunkMoonstone:
statIndex = kDMStatMana;
modifier = 3;
break;
default:
break;
}
}
}
if (modifier) {
modifier *= modifierFactor;
//statIndex is set when modifier is set
if (statIndex == kDMStatMana) {
champ->_maxMana += modifier;
} else if (statIndex < kDMStatAntifire + 1) {
for (uint16 statValIndex = kDMStatMaximum; statValIndex <= kDMStatMinimum; ++statValIndex) {
champ->getStatistic((ChampionStatType)statIndex, (ChampionStatValue)statValIndex) += modifier;
}
}
}
}
bool ChampionMan::hasObjectIconInSlotBoxChanged(int16 slotBoxIndex, Thing thing) {
ObjectMan &objMan = *_vm->_objectMan;
IconIndice currIconIndex = objMan.getIconIndexInSlotBox(slotBoxIndex);
if (((currIconIndex < kDMIconIndiceWeaponDagger) && (currIconIndex >= kDMIconIndiceJunkCompassNorth))
|| ((currIconIndex >= kDMIconIndicePotionMaPotionMonPotion) && (currIconIndex <= kDMIconIndicePotionWaterFlask))
|| (currIconIndex == kDMIconIndicePotionEmptyFlask)) {
IconIndice newIconIndex = objMan.getIconIndex(thing);
if (newIconIndex != currIconIndex) {
if ((slotBoxIndex < k8_SlotBoxInventoryFirstSlot) && !_mousePointerHiddenToDrawChangedObjIconOnScreen) {
_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
_vm->_eventMan->hideMouse();
}
objMan.drawIconInSlotBox(slotBoxIndex, newIconIndex);
return true;
}
}
return false;
}
void ChampionMan::drawChangedObjectIcons() {
InventoryMan &invMan = *_vm->_inventoryMan;
ObjectMan &objMan = *_vm->_objectMan;
MenuMan &menuMan = *_vm->_menuMan;
uint16 invChampOrdinal = invMan._inventoryChampionOrdinal;
if (_candidateChampionOrdinal && !invChampOrdinal)
return;
_mousePointerHiddenToDrawChangedObjIconOnScreen = false;
IconIndice leaderHandObjIconIndex = _leaderHandObjectIconIndex;
if (((leaderHandObjIconIndex < kDMIconIndiceWeaponDagger) && (leaderHandObjIconIndex >= kDMIconIndiceJunkCompassNorth)) // < instead of <= is correct
|| ((leaderHandObjIconIndex >= kDMIconIndicePotionMaPotionMonPotion) && (leaderHandObjIconIndex <= kDMIconIndicePotionWaterFlask))
|| (leaderHandObjIconIndex == kDMIconIndicePotionEmptyFlask)) {
IconIndice iconIndex = objMan.getIconIndex(_leaderHandObject);
if (iconIndex != leaderHandObjIconIndex) {
_mousePointerHiddenToDrawChangedObjIconOnScreen = true;
_vm->_eventMan->hideMouse();
objMan.extractIconFromBitmap(iconIndex, objMan._objectIconForMousePointer);
_vm->_eventMan->setPointerToObject(_vm->_objectMan->_objectIconForMousePointer);
_leaderHandObjectIconIndex = iconIndex;
objMan.drawLeaderObjectName(_leaderHandObject);
}
}
for (uint16 slotBoxIndex = 0; slotBoxIndex < (_partyChampionCount * 2); ++slotBoxIndex) {
int16 champIndex = slotBoxIndex >> 1;
if (invChampOrdinal == _vm->indexToOrdinal(champIndex))
continue;
if (hasObjectIconInSlotBoxChanged(slotBoxIndex, _champions[champIndex].getSlot((ChampionSlot)getHandSlotIndex(slotBoxIndex)))
&& (getHandSlotIndex(slotBoxIndex) == kDMSlotActionHand)) {
menuMan.drawActionIcon((ChampionIndex)champIndex);
}
}
if (invChampOrdinal) {
Champion *champ = &_champions[_vm->ordinalToIndex(invChampOrdinal)];
Thing *thing = &champ->getSlot(kDMSlotReadyHand);
uint16 drawViewport = 0;
for (uint16 slotIndex = kDMSlotReadyHand; slotIndex < kDMSlotChest1; slotIndex++, thing++) {
uint16 objIconChanged = hasObjectIconInSlotBoxChanged(slotIndex + k8_SlotBoxInventoryFirstSlot, *thing) ? 1 : 0;
drawViewport |= objIconChanged;
if (objIconChanged && (slotIndex == kDMSlotActionHand)) {
menuMan.drawActionIcon((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
}
}
if (invMan._panelContent == k4_PanelContentChest) {
thing = invMan._chestSlots;
for (int16 slotIndex = 0; slotIndex < 8; ++slotIndex, thing++) {
drawViewport |= (hasObjectIconInSlotBoxChanged(slotIndex + k38_SlotBoxChestFirstSlot, *thing) ? 1 : 0);
}
}
if (drawViewport) {
champ->setAttributeFlag(kDMAttributeViewport, true);
drawChampionState((ChampionIndex)_vm->ordinalToIndex(invChampOrdinal));
}
}
if (_mousePointerHiddenToDrawChangedObjIconOnScreen)
_vm->_eventMan->showMouse();
}
void ChampionMan::addObjectInSlot(ChampionIndex champIndex, Thing thing, ChampionSlot slotIndex) {
InventoryMan &invMan = *_vm->_inventoryMan;
DungeonMan &dunMan = *_vm->_dungeonMan;
ObjectMan &objMan = *_vm->_objectMan;
MenuMan &menuMan = *_vm->_menuMan;
if (thing == Thing::_none)
return;
Champion *champ = &_champions[champIndex];
if (slotIndex >= kDMSlotChest1) {
invMan._chestSlots[slotIndex - kDMSlotChest1] = thing;
} else {
champ->setSlot(slotIndex, thing);
}
champ->_load += dunMan.getObjectWeight(thing);
champ->setAttributeFlag(kDMAttributeLoad, true);
IconIndice iconIndex = objMan.getIconIndex(thing);
bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == invMan._inventoryChampionOrdinal);
applyModifiersToStatistics(champ, slotIndex, iconIndex, 1, thing);
uint16 *rawObjPtr = dunMan.getThingData(thing);
if (slotIndex < kDMSlotHead) {
if (slotIndex == kDMSlotActionHand) {
champ->setAttributeFlag(kDMAttributeActionHand, true);
if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
menuMan.clearActingChampion();
if ((iconIndex >= kDMIconIndiceScrollOpen) && (iconIndex <= kDMIconIndiceScrollClosed)) {
((Scroll *)rawObjPtr)->setClosed(false);
drawChangedObjectIcons();
}
}
if (iconIndex == kDMIconIndiceWeaponTorchUnlit) {
((Weapon *)rawObjPtr)->setLit(true);
_vm->_inventoryMan->setDungeonViewPalette();
drawChangedObjectIcons();
} else if (isInventoryChampion && (slotIndex == kDMSlotActionHand) &&
((iconIndex == kDMIconIndiceContainerChestClosed) || ((iconIndex >= kDMIconIndiceScrollOpen) && (iconIndex <= kDMIconIndiceScrollClosed)))) {
champ->setAttributeFlag(kDMAttributePanel, true);
}
} else if (slotIndex == kDMSlotNeck) {
if ((iconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (iconIndex <= kDMIconIndiceJunkIllumuletEquipped)) {
((Junk *)rawObjPtr)->setChargeCount(1);
_party._magicalLightAmount += _lightPowerToLightAmount[2];
_vm->_inventoryMan->setDungeonViewPalette();
iconIndex = (IconIndice)(iconIndex + 1);
} else if ((iconIndex >= kDMIconIndiceJunkJewelSymalUnequipped) && (iconIndex <= kDMIconIndiceJunkJewelSymalEquipped)) {
((Junk *)rawObjPtr)->setChargeCount(1);
iconIndex = (IconIndice)(iconIndex + 1);
}
}
drawSlot(champIndex, slotIndex);
if (isInventoryChampion)
champ->setAttributeFlag(kDMAttributeViewport, true);
}
int16 ChampionMan::getScentOrdinal(int16 mapX, int16 mapY) {
int16 scentIndex = _party._scentCount;
if (scentIndex) {
Scent searchedScent;
searchedScent.setMapX(mapX);
searchedScent.setMapY(mapY);
searchedScent.setMapIndex(_vm->_dungeonMan->_currMapIndex);
uint16 searchedScentRedEagle = searchedScent.toUint16();
Scent *scent = &_party._scents[scentIndex--];
do {
if ((*(--scent)).toUint16() == searchedScentRedEagle) {
return _vm->indexToOrdinal(scentIndex);
}
} while (scentIndex--);
}
return 0;
}
Thing ChampionMan::getObjectRemovedFromLeaderHand() {
_leaderEmptyHanded = true;
Thing leaderHandObject = _leaderHandObject;
if (leaderHandObject != Thing::_none) {
_leaderHandObject = Thing::_none;
_leaderHandObjectIconIndex = kDMIconIndiceNone;
_vm->_eventMan->showMouse();
_vm->_objectMan->clearLeaderObjectName();
_vm->_eventMan->setMousePointer();
_vm->_eventMan->hideMouse();
if (_leaderIndex != kDMChampionNone) {
_champions[_leaderIndex]._load -= _vm->_dungeonMan->getObjectWeight(leaderHandObject);
setFlag(_champions[_leaderIndex]._attributes, kDMAttributeLoad);
drawChampionState(_leaderIndex);
}
}
return leaderHandObject;
}
uint16 ChampionMan::getStrength(int16 champIndex, int16 slotIndex) {
Champion *curChampion = &_champions[champIndex];
int16 strength = _vm->getRandomNumber(16) + curChampion->_statistics[kDMStatStrength][kDMStatCurrent];
Thing curThing = curChampion->_slots[slotIndex];
uint16 objectWeight = _vm->_dungeonMan->getObjectWeight(curThing);
uint16 oneSixteenthMaximumLoad = getMaximumLoad(curChampion) >> 4;
if (objectWeight <= oneSixteenthMaximumLoad) {
strength += objectWeight - 12;
} else {
int16 loadThreshold = oneSixteenthMaximumLoad + ((oneSixteenthMaximumLoad - 12) >> 1);
if (objectWeight <= loadThreshold) {
strength += (objectWeight - oneSixteenthMaximumLoad) >> 1;
} else {
strength -= (objectWeight - loadThreshold) << 1;
}
}
if (curThing.getType() == kDMThingTypeWeapon) {
WeaponInfo *weaponInfo = _vm->_dungeonMan->getWeaponInfo(curThing);
strength += weaponInfo->_strength;
uint16 skillLevel = 0;
uint16 weaponClass = weaponInfo->_class;
if ((weaponClass == k0_WeaponClassSwingWeapon) || (weaponClass == k2_WeaponClassDaggerAndAxes)) {
skillLevel = getSkillLevel(champIndex, kDMSkillSwing);
}
if ((weaponClass != k0_WeaponClassSwingWeapon) && (weaponClass < k16_WeaponClassFirstBow)) {
skillLevel += getSkillLevel(champIndex, kDMSkillThrow);
}
if ((weaponClass >= k16_WeaponClassFirstBow) && (weaponClass < k112_WeaponClassFirstMagicWeapon)) {
skillLevel += getSkillLevel(champIndex, kDMSkillShoot);
}
strength += skillLevel << 1;
}
strength = getStaminaAdjustedValue(curChampion, strength);
if (getFlag(curChampion->_wounds, (slotIndex == kDMSlotReadyHand) ? kDMWoundReadHand : kDMWoundActionHand)) {
strength >>= 1;
}
return CLIP(0, strength >> 1, 100);
}
Thing ChampionMan::getObjectRemovedFromSlot(uint16 champIndex, uint16 slotIndex) {
Champion *curChampion = &_champions[champIndex];
Thing curThing;
if (slotIndex >= kDMSlotChest1) {
curThing = _vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1];
_vm->_inventoryMan->_chestSlots[slotIndex - kDMSlotChest1] = Thing::_none;
} else {
curThing = curChampion->_slots[slotIndex];
curChampion->_slots[slotIndex] = Thing::_none;
}
if (curThing == Thing::_none)
return Thing::_none;
bool isInventoryChampion = (_vm->indexToOrdinal(champIndex) == _vm->_inventoryMan->_inventoryChampionOrdinal);
int16 curIconIndex = _vm->_objectMan->getIconIndex(curThing);
// Remove object modifiers
applyModifiersToStatistics(curChampion, slotIndex, curIconIndex, -1, curThing);
Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(curThing);
if (slotIndex == kDMSlotNeck) {
if ((curIconIndex >= kDMIconIndiceJunkIllumuletUnequipped) && (curIconIndex <= kDMIconIndiceJunkIllumuletEquipped)) {
((Junk *)curWeapon)->setChargeCount(0);
_party._magicalLightAmount -= _lightPowerToLightAmount[2];
_vm->_inventoryMan->setDungeonViewPalette();
} else if ((curIconIndex >= kDMIconIndiceJunkJewelSymalUnequipped) && (curIconIndex <= kDMIconIndiceJunkJewelSymalEquipped)) {
((Junk *)curWeapon)->setChargeCount(0);
}
}
drawSlot(champIndex, slotIndex);
if (isInventoryChampion)
setFlag(curChampion->_attributes, kDMAttributeViewport);
if (slotIndex < kDMSlotHead) {
if (slotIndex == kDMSlotActionHand) {
setFlag(curChampion->_attributes, kDMAttributeActionHand);
if (_actingChampionOrdinal == _vm->indexToOrdinal(champIndex))
_vm->_menuMan->clearActingChampion();
if ((curIconIndex >= kDMIconIndiceScrollOpen) && (curIconIndex <= kDMIconIndiceScrollClosed)) {
((Scroll *)curWeapon)->setClosed(true);
drawChangedObjectIcons();
}
}
if ((curIconIndex >= kDMIconIndiceWeaponTorchUnlit) && (curIconIndex <= kDMIconIndiceWeaponTorchLit)) {
curWeapon->setLit(false);
_vm->_inventoryMan->setDungeonViewPalette();
drawChangedObjectIcons();
}
if (isInventoryChampion && (slotIndex == kDMSlotActionHand)) {
switch (curIconIndex) {
case kDMIconIndiceContainerChestClosed:
_vm->_inventoryMan->closeChest();
// No break on purpose
case kDMIconIndiceScrollOpen:
case kDMIconIndiceScrollClosed:
setFlag(curChampion->_attributes, kDMAttributePanel);
break;
default:
break;
}
}
}
curChampion->_load -= _vm->_dungeonMan->getObjectWeight(curThing);
setFlag(curChampion->_attributes, kDMAttributeLoad);
return curThing;
}
void ChampionMan::decrementStamina(int16 championIndex, int16 decrement) {
if (championIndex == kDMChampionNone)
return;
Champion *curChampion = &_champions[championIndex];
curChampion->_currStamina -= decrement;
int16 stamina = curChampion->_currStamina;
if (stamina <= 0) {
curChampion->_currStamina = 0;
addPendingDamageAndWounds_getDamage(championIndex, (-stamina) >> 1, kDMWoundNone, kDMAttackTypeNormal);
} else if (stamina > curChampion->_maxStamina) {
curChampion->_currStamina = curChampion->_maxStamina;
}
setFlag(curChampion->_attributes, kDMAttributeLoad | kDMAttributeStatistics);
}
int16 ChampionMan::addPendingDamageAndWounds_getDamage(int16 champIndex, int16 attack, int16 allowedWounds, uint16 attackType) {
if (attack <= 0)
return 0;
Champion *curChampion = &_champions[champIndex];
if (!curChampion->_currHealth)
return 0;
if (attackType != kDMAttackTypeNormal) {
uint16 defense = 0;
uint16 woundCount = 0;
for (int16 woundIndex = kDMSlotReadyHand; woundIndex <= kDMSlotFeet; woundIndex++) {
if (allowedWounds & (1 << woundIndex)) {
woundCount++;
defense += getWoundDefense(champIndex, woundIndex | ((attackType == kDMAttackTypeSharp) ? kDMMaskSharpDefense : kDMMaskNoSharpDefense));
}
}
if (woundCount)
defense /= woundCount;
bool skipScaling = false;
switch (attackType) {
case kDMAttackTypePsychic:
{
int16 wisdomFactor = 115 - curChampion->_statistics[kDMStatWisdom][kDMStatCurrent];
if (wisdomFactor <= 0) {
attack = 0;
} else {
attack = _vm->getScaledProduct(attack, 6, wisdomFactor);
}
skipScaling = true;
}
break;
case kDMAttackTypeMagic:
attack = getStatisticAdjustedAttack(curChampion, kDMStatAntimagic, attack);
attack -= _party._spellShieldDefense;
skipScaling = true;
break;
case kDMAttackTypeFire:
attack = getStatisticAdjustedAttack(curChampion, kDMStatAntifire, attack);
attack -= _party._fireShieldDefense;
break;
case kDMAttackTypeSelf:
defense >>= 1;
break;
default:
break;
}
if (!skipScaling) {
if (attack <= 0)
return 0;
attack = _vm->getScaledProduct(attack, 6, 130 - defense);
}
/* BUG0_44
A champion may take much more damage than expected after a Black Flame attack or an impact
with a Fireball projectile. If the party has a fire shield defense value higher than the fire
attack value then the resulting intermediary attack value is negative and damage should be 0.
However, the negative value is still used for further computations and the result may be a very
high positive attack value which may kill a champion. This can occur only for k1_attackType_FIRE
and if attack is negative before calling F0030_MAIN_GetScaledProduct
*/
if (attack <= 0)
return 0;
int16 adjustedAttack = getStatisticAdjustedAttack(curChampion, kDMStatVitality, _vm->getRandomNumber(128) + 10);
if (attack > adjustedAttack) {
/* BUG0_45
This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the
probability of being wounded. However if it was fixed, the behavior would be the opposite
of what it should: the higher the vitality of a champion, the lower the result of
F0307_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get
wounded (because of more iterations in the loop below)
*/
do {
setFlag(*(uint16 *)&_championPendingWounds[champIndex], (1 << _vm->getRandomNumber(8)) & allowedWounds);
} while ((attack > (adjustedAttack <<= 1)) && adjustedAttack);
}
if (_partyIsSleeping)
wakeUp();
}
_championPendingDamage[champIndex] += attack;
return attack;
}
int16 ChampionMan::getWoundDefense(int16 champIndex, uint16 woundIndex) {
static const byte woundDefenseFactor[6] = {5, 5, 4, 6, 3, 1}; // @ G0050_auc_Graphic562_WoundDefenseFactor
Champion *curChampion = &_champions[champIndex];
bool useSharpDefense = getFlag(woundIndex, kDMMaskSharpDefense);
if (useSharpDefense)
clearFlag(woundIndex, kDMMaskSharpDefense);
uint16 armorShieldDefense = 0;
for (int16 slotIndex = kDMSlotReadyHand; slotIndex <= kDMSlotActionHand; slotIndex++) {
Thing curThing = curChampion->_slots[slotIndex];
if (curThing.getType() == kDMThingTypeArmour) {
ArmourInfo *armorInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
armorInfo = &_vm->_dungeonMan->_armourInfos[((Armour *)armorInfo)->getType()];
if (getFlag(armorInfo->_attributes, k0x0080_ArmourAttributeIsAShield))
armorShieldDefense += ((getStrength(champIndex, slotIndex) + _vm->_dungeonMan->getArmourDefense(armorInfo, useSharpDefense)) * woundDefenseFactor[woundIndex]) >> ((slotIndex == woundIndex) ? 4 : 5);
}
}
int16 woundDefense = _vm->getRandomNumber((curChampion->_statistics[kDMStatVitality][kDMStatCurrent] >> 3) + 1);
if (useSharpDefense)
woundDefense >>= 1;
woundDefense += curChampion->_actionDefense + curChampion->_shieldDefense + _party._shieldDefense + armorShieldDefense;
if (woundIndex > kDMSlotActionHand) {
Thing curThing = curChampion->_slots[woundIndex];
if (curThing.getType() == kDMThingTypeArmour) {
ArmourInfo *armourInfo = (ArmourInfo *)_vm->_dungeonMan->getThingData(curThing);
woundDefense += _vm->_dungeonMan->getArmourDefense(&_vm->_dungeonMan->_armourInfos[((Armour *)armourInfo)->getType()], useSharpDefense);
}
}
if (getFlag(curChampion->_wounds, 1 << woundIndex))
woundDefense -= 8 + _vm->getRandomNumber(4);
if (_partyIsSleeping)
woundDefense >>= 1;
return CLIP(0, woundDefense >> 1, 100);
}
uint16 ChampionMan::getStatisticAdjustedAttack(Champion *champ, uint16 statIndex, uint16 attack) {
int16 factor = 170 - champ->_statistics[statIndex][kDMStatCurrent];
/* BUG0_41
The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored
against poison and to determine the probability of being wounded. Vitality is still used normally
to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C
compiler produces wrong machine code for this statement. It always returns 0 for the current statistic
value so that factor = 170 in all cases
*/
if (factor < 16)
return attack >> 3;
return _vm->getScaledProduct(attack, 7, factor);
}
void ChampionMan::wakeUp() {
_vm->_stopWaitingForPlayerInput = true;
_partyIsSleeping = false;
_vm->_waitForInputMaxVerticalBlankCount = 10;
_vm->delay(10);
_vm->_displayMan->drawFloorAndCeiling();
_vm->_eventMan->_primaryMouseInput = _vm->_eventMan->_primaryMouseInputInterface;
_vm->_eventMan->_secondaryMouseInput = _vm->_eventMan->_secondaryMouseInputMovement;
_vm->_eventMan->_primaryKeyboardInput = _vm->_eventMan->_primaryKeyboardInputInterface;
_vm->_eventMan->_secondaryKeyboardInput = _vm->_eventMan->_secondaryKeyboardInputMovement;
_vm->_eventMan->discardAllInput();
_vm->_menuMan->drawEnabledMenus();
}
int16 ChampionMan::getThrowingStaminaCost(Thing thing) {
int16 weight = _vm->_dungeonMan->getObjectWeight(thing) >> 1;
int16 staminaCost = CLIP<int16>(1, weight, 10);
while ((weight -= 10) > 0)
staminaCost += weight >> 1;
return staminaCost;
}
void ChampionMan::disableAction(uint16 champIndex, uint16 ticks) {
Champion *curChampion = &_champions[champIndex];
int32 updatedEnableActionEventTime = _vm->_gameTime + ticks;
TimelineEvent curEvent;
curEvent._type = k11_TMEventTypeEnableChampionAction;
curEvent._priority = champIndex;
curEvent._Bu._slotOrdinal = 0;
int16 eventIndex = curChampion->_enableActionEventIndex;
if (eventIndex >= 0) {
int32 currentEnableActionEventTime = _vm->filterTime(_vm->_timeline->_events[eventIndex]._mapTime);
if (updatedEnableActionEventTime >= currentEnableActionEventTime) {
updatedEnableActionEventTime += (currentEnableActionEventTime - _vm->_gameTime) >> 1;
} else {
updatedEnableActionEventTime = currentEnableActionEventTime + (ticks >> 1);
}
_vm->_timeline->deleteEvent(eventIndex);
} else {
setFlag(curChampion->_attributes, kDMAttributeActionHand | kDMAttributeDisableAction);
drawChampionState((ChampionIndex)champIndex);
}
_vm->setMapAndTime(curEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, updatedEnableActionEventTime);
curChampion->_enableActionEventIndex = _vm->_timeline->addEventGetEventIndex(&curEvent);
}
void ChampionMan::addSkillExperience(uint16 champIndex, uint16 skillIndex, uint16 exp) {
if ((skillIndex >= kDMSkillSwing) && (skillIndex <= kDMSkillShoot) && (_vm->_projexpl->_lastCreatureAttackTime < _vm->_gameTime - 150))
exp >>= 1;
if (exp) {
if (_vm->_dungeonMan->_currMap->_difficulty)
exp *= _vm->_dungeonMan->_currMap->_difficulty;
Champion *curChampion = &_champions[champIndex];
uint16 baseSkillIndex;
if (skillIndex >= kDMSkillSwing)
baseSkillIndex = (skillIndex - kDMSkillSwing) >> 2;
else
baseSkillIndex = skillIndex;
uint16 skillLevelBefore = getSkillLevel(champIndex, baseSkillIndex | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience));
if ((skillIndex >= kDMSkillSwing) && (_vm->_projexpl->_lastCreatureAttackTime > _vm->_gameTime - 25))
exp <<= 1;
Skill *curSkill = &curChampion->_skills[skillIndex];
curSkill->_experience += exp;
if (curSkill->_temporaryExperience < 32000)
curSkill->_temporaryExperience += CLIP(1, exp >> 3, 100);
curSkill = &curChampion->_skills[baseSkillIndex];
if (skillIndex >= kDMSkillSwing)
curSkill->_experience += exp;
uint16 skillLevelAfter = getSkillLevel(champIndex, baseSkillIndex | (kDMIgnoreObjectModifiers | kDMIgnoreTemporaryExperience));
if (skillLevelAfter > skillLevelBefore) {
int16 newBaseSkillLevel = skillLevelAfter;
int16 minorStatIncrease = _vm->getRandomNumber(2);
int16 majorStatIncrease = 1 + _vm->getRandomNumber(2);
uint16 vitalityAmount = _vm->getRandomNumber(2); /* For Priest skill, the amount is 0 or 1 for all skill levels */
if (baseSkillIndex != kDMSkillPriest) {
vitalityAmount &= skillLevelAfter; /* For non Priest skills the amount is 0 for even skill levels. The amount is 0 or 1 for odd skill levels */
}
curChampion->_statistics[kDMStatVitality][kDMStatMaximum] += vitalityAmount;
uint16 staminaAmount = curChampion->_maxStamina;
curChampion->_statistics[kDMStatAntifire][kDMStatMaximum] += _vm->getRandomNumber(2) & ~skillLevelAfter; /* The amount is 0 for odd skill levels. The amount is 0 or 1 for even skill levels */
bool increaseManaFl = false;
switch (baseSkillIndex) {
case kDMSkillFighter:
staminaAmount >>= 4;
skillLevelAfter *= 3;
curChampion->_statistics[kDMStatStrength][kDMStatMaximum] += majorStatIncrease;
curChampion->_statistics[kDMStatDexterity][kDMStatMaximum] += minorStatIncrease;
break;
case kDMSkillNinja:
staminaAmount /= 21;
skillLevelAfter <<= 1;