diff options
| author | Bendegúz Nagy | 2016-06-28 01:50:02 +0200 | 
|---|---|---|
| committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 | 
| commit | d6af931ad7d921e3a6e947634c4efcffef6545d0 (patch) | |
| tree | 7cab83a19db8ae647728fe033141d1a01c92be9b | |
| parent | ebdcac50734b4a1e297e40af6d096c52b183e4d9 (diff) | |
| download | scummvm-rg350-d6af931ad7d921e3a6e947634c4efcffef6545d0.tar.gz scummvm-rg350-d6af931ad7d921e3a6e947634c4efcffef6545d0.tar.bz2 scummvm-rg350-d6af931ad7d921e3a6e947634c4efcffef6545d0.zip | |
DM: Add  F0303_CHAMPION_GetSkillLevel
| -rw-r--r-- | engines/dm/champion.cpp | 62 | ||||
| -rw-r--r-- | engines/dm/champion.h | 6 | 
2 files changed, 67 insertions, 1 deletions
| diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b8676c803e..c974a71d59 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -717,6 +717,68 @@ void ChampionMan::renameChampion(Champion* champ) {  		dispMan.updateScreen();
  	}
  }
 +
 +uint16 ChampionMan::getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex) {
 +	if (_partyIsSleeping)
 +		return 1;
 +
 +	bool ignoreTempExp = skillIndex & kIgnoreTemporaryExperience;
 +	bool ignoreObjModifiers = skillIndex & kIgnoreObjectModifiers;
 +	skillIndex = (ChampionSkill)(skillIndex & ~(ignoreTempExp | ignoreObjModifiers));
 +	Champion *champ = &_champions[champIndex];
 +	Skill *skill = &champ->getSkill(skillIndex);
 +	int32 experience = skill->_experience;
 +
 +	if (!ignoreTempExp)
 +		experience += skill->_temporaryExperience;
 +
 +	if (skillIndex > kChampionSkillWizard) { // hidden skill
 +		skill = &champ->getSkill((ChampionSkill)((skillIndex - kChampionSkillSwing) / 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
 +	}
 +
 +	int16 skillLevel = 1;
 +	while (experience >= 500) {
 +		experience /= 2;
 +		skillLevel++;
 +	}
 +
 +	if (!ignoreObjModifiers) {
 +		IconIndice actionHandIconIndex = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotActionHand));
 +		if (actionHandIconIndex == kIconIndiceWeaponTheFirestaff) {
 +			skillLevel++;
 +		} else if (actionHandIconIndex == kIconIndiceWeaponTheFirestaffComplete) {
 +			skillLevel += 2;
 +		}
 +
 +		IconIndice neckIconIndice = _vm->_objectMan->getIconIndex(champ->getSlot(kChampionSlotNeck));
 +		switch (skillIndex) {
 +		case kChampionSkillWizard:
 +			if (neckIconIndice == kIconIndiceJunkPendantFeral)
 +				skillLevel++;
 +			break;
 +		case kChampionSkillDefend:
 +			if (neckIconIndice == kIconIndiceJunkEkkhardCross)
 +				skillLevel++;
 +			break;
 +		case kChampionSkillHeal:
 +			// these two are not cummulative
 +			if ((neckIconIndice == kIconIndiceJunkGemOfAges) || (neckIconIndice == kIconIndiceWeaponSceptreOfLyf))
 +				skillLevel++;
 +			break;
 +		case kChampionSkillInfluence:
 +			if (neckIconIndice == kIconIndiceJunkMoonstone)
 +				skillLevel++;
 +			break;
 +		}
 +	}
 +	return skillLevel;
 +}
 +
  }
 diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 3e72be3850..86425b48c7 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -35,6 +35,9 @@  namespace DM { +#define kIgnoreObjectModifiers 0x4000 // @ MASK0x4000_IGNORE_OBJECT_MODIFIERS      +#define kIgnoreTemporaryExperience 0x8000 // @ MASK0x8000_IGNORE_TEMPORARY_EXPERIENCE  +  extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons  extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor @@ -365,7 +368,7 @@ public:  	Thing getSlot(ChampionSlot slot) { return _slots[slot]; }  	void setSlot(ChampionSlot slot, Thing val) { _slots[slot] = val; } -	Skill getSkill(ChampionSkill skill) { return _skills[skill]; } +	Skill &getSkill(ChampionSkill skill) { return _skills[skill]; }  	void setSkillExp(ChampionSkill skill,  int32 val) { _skills[skill]._experience = val; }  	void setSkillTempExp(ChampionSkill skill,  int16 val) { _skills[skill]._temporaryExperience= val; } @@ -453,6 +456,7 @@ public:  	void drawHealthStaminaManaValues(Champion *champ); // @ F0290_CHAMPION_DrawHealthStaminaManaValues  	void drawSlot(uint16 champIndex, ChampionSlot slotIndex); // @ F0291_CHAMPION_DrawSlot  	void renameChampion(Champion* champ); // @ F0281_CHAMPION_Rename +	uint16 getSkillLevel(ChampionIndex champIndex, ChampionSkill skillIndex);// @ F0303_CHAMPION_GetSkillLevel  }; | 
