diff options
author | Bendegúz Nagy | 2016-07-13 17:49:49 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | b092e74be9c275db8adb04a98c5146a6923e4f43 (patch) | |
tree | 31f1d5bf05822b1646c38dbb984a07af0270ebbb /engines/dm | |
parent | 5602d07f966ed16c5c74d014fe596ef15bcf825d (diff) | |
download | scummvm-rg350-b092e74be9c275db8adb04a98c5146a6923e4f43.tar.gz scummvm-rg350-b092e74be9c275db8adb04a98c5146a6923e4f43.tar.bz2 scummvm-rg350-b092e74be9c275db8adb04a98c5146a6923e4f43.zip |
DM: Fix broken ChampionMan::f303_getSkillLevel
Diffstat (limited to 'engines/dm')
-rw-r--r-- | engines/dm/champion.cpp | 80 | ||||
-rw-r--r-- | engines/dm/champion.h | 2 |
2 files changed, 41 insertions, 41 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b9c286ac92..52be549f61 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1922,62 +1922,62 @@ void ChampionMan::f281_renameChampion(Champion* champ) { }
}
-uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, int16 skillIndex) {
- if (_g300_partyIsSleeping)
+uint16 ChampionMan::f303_getSkillLevel(int16 champIndex, uint16 skillIndex) {
+ if (_vm->_championMan->_g300_partyIsSleeping) {
return 1;
-
- bool ignoreTempExp = skillIndex & k0x8000_IgnoreTemporaryExperience;
- bool ignoreObjModifiers = skillIndex & k0x4000_IgnoreObjectModifiers;
- skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers));
- Champion *champ = &_gK71_champions[champIndex];
- Skill *skill = &champ->getSkill((ChampionSkill)skillIndex);
- int32 experience = skill->_experience;
-
- if (!ignoreTempExp)
- experience += skill->_temporaryExperience;
-
- if (skillIndex > k3_ChampionSkillWizard) { // hidden skill
- skill = &champ->getSkill((ChampionSkill)((skillIndex - k4_ChampionSkillSwing) / 4));
- experience += skill->_experience; // add exp to the base skill
- if (!ignoreTempExp)
- experience += skill->_temporaryExperience;
-
- experience /= 2; // halve the exp to get avarage of base skill + hidden skill exp
}
-
+ bool ignoreTmpExp = getFlag(skillIndex, k0x8000_IgnoreTemporaryExperience);
+ bool ignoreObjModifiers = getFlag(skillIndex, k0x4000_IgnoreObjectModifiers);
+ clearFlag(skillIndex, k0x8000_IgnoreTemporaryExperience | k0x4000_IgnoreObjectModifiers);
+ Champion *champ = &_vm->_championMan->_gK71_champions[champIndex];
+ Skill *skill = &champ->_skills[skillIndex];
+ int32 exp = skill->_experience;
+ if (!ignoreTmpExp) {
+ exp += skill->_temporaryExperience;
+ }
+ if (skillIndex > k3_ChampionSkillWizard) { /* Hidden skill */
+ skill = &champ->_skills[(skillIndex - k4_ChampionSkillSwing) >> 2];
+ exp += skill->_experience; /* Add experience in the base skill */
+ if (!ignoreTmpExp) {
+ exp += skill->_temporaryExperience;
+ }
+ exp >>= 1; /* Halve experience to get average of base skill + hidden skill experience */
+ }
int16 skillLevel = 1;
- while (experience >= 500) {
- experience /= 2;
+ while (exp >= 500) {
+ exp >>= 1;
skillLevel++;
}
-
if (!ignoreObjModifiers) {
- IconIndice actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k1_ChampionSlotActionHand));
- if (actionHandIconIndex == k27_IconIndiceWeaponTheFirestaff) {
+ int16 actionHandIconIndex;
+ if ((actionHandIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand])) == k27_IconIndiceWeaponTheFirestaff) {
skillLevel++;
- } else if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) {
- skillLevel += 2;
+ } else {
+ if (actionHandIconIndex == k28_IconIndiceWeaponTheFirestaffComplete) {
+ skillLevel += 2;
+ }
}
-
- IconIndice neckIconIndice = _vm->_objectMan->f33_getIconIndex(champ->getSlot(k10_ChampionSlotNeck));
+ int16 neckIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k10_ChampionSlotNeck]);
switch (skillIndex) {
case k3_ChampionSkillWizard:
- if (neckIconIndice == k124_IconIndiceJunkPendantFeral)
- skillLevel++;
+ if (neckIconIndex == k124_IconIndiceJunkPendantFeral) {
+ skillLevel += 1;
+ }
break;
case k15_ChampionSkillDefend:
- if (neckIconIndice == k121_IconIndiceJunkEkkhardCross)
- skillLevel++;
+ if (neckIconIndex == k121_IconIndiceJunkEkkhardCross) {
+ skillLevel += 1;
+ }
break;
case k13_ChampionSkillHeal:
- // these two are not cummulative
- if ((neckIconIndice == k120_IconIndiceJunkGemOfAges) || (neckIconIndice == k66_IconIndiceWeaponSceptreOfLyf))
- skillLevel++;
+ if ((neckIconIndex == k120_IconIndiceJunkGemOfAges) || (actionHandIconIndex == k66_IconIndiceWeaponSceptreOfLyf)) { /* The skill modifiers of these two objects are not cumulative */
+ skillLevel += 1;
+ }
break;
case k14_ChampionSkillInfluence:
- if (neckIconIndice == k122_IconIndiceJunkMoonstone)
- skillLevel++;
- break;
+ if (neckIconIndex == k122_IconIndiceJunkMoonstone) {
+ skillLevel += 1;
+ }
}
}
return skillLevel;
diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 2bae7c5947..5d98ecbd41 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -536,7 +536,7 @@ public: void f290_drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues void f291_drawSlot(uint16 champIndex, int16 slotIndex); // @ F0291_CHAMPION_DrawSlot void f281_renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename - uint16 f303_getSkillLevel(int16 champIndex, int16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel + uint16 f303_getSkillLevel(int16 champIndex, uint16 skillIndex);// @ F0303_CHAMPION_GetSkillLevel Common::String f288_getStringFromInteger(uint16 val, bool padding, uint16 paddingCharCount); // @ F0288_CHAMPION_GetStringFromInteger void f299_applyModifiersToStatistics(Champion *champ, int16 slotIndex, int16 iconIndex, int16 modifierFactor, Thing thing); // @ F0299_CHAMPION_ApplyObjectModifiersToStatistics |