26 lines
916 B
C++
26 lines
916 B
C++
#include "ExperienceLibrary.hpp"
|
|
#include "../PkmnScriptHook.hpp"
|
|
#include "../Pokemon/Pokemon.hpp"
|
|
|
|
void PkmnLib::Battling::ExperienceLibrary::HandleExperienceGain(
|
|
CreatureLib::Battling::Creature* faintedMon,
|
|
const std::unordered_set<CreatureLib::Battling::Creature*>& opponents) const {
|
|
|
|
auto fainted = dynamic_cast<Pokemon*>(faintedMon);
|
|
auto expGain = fainted->GetForme()->GetBaseExperience();
|
|
auto level = fainted->GetLevel();
|
|
// TODO exp share
|
|
|
|
auto v1 = (expGain * level) / 5;
|
|
|
|
for (auto op : opponents) {
|
|
if (!op->AllowedExperienceGain())
|
|
continue;
|
|
auto v2 = pow(2 * level + 10, 2.5) / pow(level + op->GetLevel() + 10, 2.5);
|
|
uint32_t experienceGain = v1 * v2 + 1;
|
|
// TODO: Check owner and international
|
|
PKMN_HOOK(ModifyExperienceGain, op, faintedMon, op, experienceGain);
|
|
op->AddExperience(experienceGain);
|
|
}
|
|
}
|