Support Pokemon style experience gain.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <CreatureLib/Battling/Library/BattleLibrary.hpp>
|
||||
#include "../../Library/PokemonLibrary.hpp"
|
||||
#include "DamageLibrary.hpp"
|
||||
#include "ExperienceLibrary.hpp"
|
||||
#include "MiscLibrary.hpp"
|
||||
#include "StatCalculator.hpp"
|
||||
|
||||
@@ -11,7 +12,7 @@ namespace PkmnLib::Battling {
|
||||
class BattleLibrary : public CreatureLib::Battling::BattleLibrary {
|
||||
public:
|
||||
BattleLibrary(Library::PokemonLibrary* staticLib, StatCalculator* statCalculator, DamageLibrary* damageLibrary,
|
||||
CreatureLib::Battling::ExperienceLibrary* experienceLibrary,
|
||||
PkmnLib::Battling::ExperienceLibrary* experienceLibrary,
|
||||
CreatureLib::Battling::ScriptResolver* scriptResolver,
|
||||
PkmnLib::Battling::MiscLibrary* miscLibrary)
|
||||
: CreatureLib::Battling::BattleLibrary(staticLib, statCalculator, damageLibrary, experienceLibrary,
|
||||
|
||||
23
src/Battling/Library/ExperienceLibrary.cpp
Normal file
23
src/Battling/Library/ExperienceLibrary.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#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->GetPokemonSpecies()->GetExperienceGains();
|
||||
auto level = fainted->GetLevel();
|
||||
// TODO exp share
|
||||
|
||||
auto v1 = (expGain * level) / 5;
|
||||
|
||||
for (auto op : opponents) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
13
src/Battling/Library/ExperienceLibrary.hpp
Normal file
13
src/Battling/Library/ExperienceLibrary.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef PKMNLIB_EXPERIENCELIBRARY_HPP
|
||||
#define PKMNLIB_EXPERIENCELIBRARY_HPP
|
||||
|
||||
#include <CreatureLib/Battling/Library/ExperienceLibrary.hpp>
|
||||
namespace PkmnLib::Battling {
|
||||
class ExperienceLibrary : public CreatureLib::Battling::ExperienceLibrary {
|
||||
public:
|
||||
void HandleExperienceGain(CreatureLib::Battling::Creature* faintedMon,
|
||||
const std::unordered_set<CreatureLib::Battling::Creature*>& opponents) const override;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PKMNLIB_EXPERIENCELIBRARY_HPP
|
||||
Reference in New Issue
Block a user