Example #1
0
int Game_Actor::GetBaseMaxSp(bool mod) const {
	int n = 0;
	if (GetLevel() > 0) {
		n = GetData().class_id > 0
			? *ReaderUtil::GetElement(GetClass()->parameters.maxsp, GetLevel())
			: *ReaderUtil::GetElement(GetActor().parameters.maxsp, GetLevel());
	}

	if (mod)
		n += GetData().sp_mod;

	return Utils::Clamp(n, 0, MaxStatBaseValue());
}
int Game_Battler::GetAgi() const {
	int base_agi = GetBaseAgi();
	int n = Utils::Clamp(base_agi, 1, MaxStatBaseValue());

	for (int16_t i : GetInflictedStates()) {
		// States are guaranteed to be valid
		const RPG::State& state = *ReaderUtil::GetElement(Data::states, i);
		if (state.affect_agility) {
			n = AffectParameter(state.affect_type, base_agi);
			break;
		}
	}

	n += agi_modifier;

	n = Utils::Clamp(n, 1, MaxStatBattleValue());

	return n;
}
Example #3
0
int Game_Actor::GetBaseAgi(bool mod, bool equip) const {
	int n = 0;
	if (GetLevel() > 0) {
		n = GetData().class_id > 0
			? *ReaderUtil::GetElement(GetClass()->parameters.agility, GetLevel())
			: *ReaderUtil::GetElement(GetActor().parameters.agility, GetLevel());
	}

	if (mod) {
		n += GetData().agility_mod;
	}

	if (equip) {
		for (std::vector<int16_t>::const_iterator it = GetData().equipped.begin(); it != GetData().equipped.end(); ++it) {
			if (*it > 0 && *it <= (int)Data::items.size()) {
				// Invalid equipment was removed
				n += ReaderUtil::GetElement(Data::items, *it)->agi_points1;
			}
		}
	}

	return Utils::Clamp(n, 1, MaxStatBaseValue());
}