Loading...   


		// Returns the base mana for a level / class combination.
		int getBaseMana() const {
			// BaseData.txt
			return Services::getBaseData()->mEntries[mLevel - 1][mClass - 1].mMana;
		}

		// Returns the amount of mana added by standard stats.
		static int getManaFromStat(const int pManaStat, const double pModifier) {
			int result = pManaStat;

			if (pManaStat > 100) {
				int x = pManaStat;
				if (pManaStat > 200)
					x = (pManaStat - 200) / -2 + pManaStat;
				result = (3 * x - 300) / 2 + x;
			}

			return (int)(pModifier * (double)result);
		}

		// Returns the amount of mana added by heroic stats.
		static int getManaFromHeroic(const int pManaStat) { return 10 * pManaStat; }

		// Returns the functional stat used for calculating max mana.
		int getManaStat() const {
			if (Class::isWisSpellCaster(getClass())) return getFunctionalWisdom();
			if (Class::isIntSpellCaster(getClass())) return getFunctionalIntelligence();
			return 0;
		}

		// Returns the heroic stat used for calculating max mana.
		int getHeroicManaStat() const {
			if (Class::isWisSpellCaster(getClass())) return getHeroicWisdom();
			if (Class::isIntSpellCaster(getClass())) return getHeroicIntelligence();
			return 0;
		}

		int calculateMaxMana() const {
			if (Class::isMelee(getClass())) return 0;

			auto e = Services::getBaseData()->mEntries[mLevel - 1][mClass - 1];
			int total = 0;

			int base = getBaseMana();
			int stat = getManaFromStat(getManaStat(), e.mManaMod);
			int heroic = getManaFromHeroic(getHeroicManaStat());
			int leadership = mLeadership.getMaxMana();
			int spells = mSpells.getMaxMana();
			int aas = mAAs.getMaxMana();
			int items = mAAs.getMaxMana();

			total = base + stat + heroic + leadership + spells + aas + items;

			return (total < 0 ? 0 : total) + heroic;
		}

Raw Paste Data