Smart pointers for most library and battle classes.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -3,20 +3,21 @@
|
||||
#include "../PkmnScriptHook.hpp"
|
||||
#include "../Pokemon/Pokemon.hpp"
|
||||
|
||||
static inline uint32_t CalculateDynamicExperience(uint8_t level, float v1, CreatureLib::Battling::Creature* op,
|
||||
CreatureLib::Battling::Creature* faintedMon) {
|
||||
static inline uint32_t CalculateDynamicExperience(uint8_t level, float v1,
|
||||
ArbUt::BorrowedPtr<CreatureLib::Battling::Creature> op,
|
||||
ArbUt::BorrowedPtr<CreatureLib::Battling::Creature> faintedMon) {
|
||||
float a = 2 * level + 10;
|
||||
float b = level + op->GetLevel() + 10;
|
||||
float v2 = (a * a * sqrt(a)) / (b * b * sqrt(b));
|
||||
uint32_t experienceGain = v1 * v2 + 1;
|
||||
// TODO: Check owner and international
|
||||
PKMN_HOOK(ModifyExperienceGain, op, faintedMon, op, &experienceGain);
|
||||
PKMN_HOOK(ModifyExperienceGain, op, faintedMon.GetRaw(), op.GetRaw(), &experienceGain);
|
||||
return experienceGain;
|
||||
}
|
||||
|
||||
void PkmnLib::Battling::ExperienceLibrary::HandleExperienceGain(
|
||||
CreatureLib::Battling::Creature* faintedMon,
|
||||
const std::unordered_set<CreatureLib::Battling::Creature*>& opponents) const {
|
||||
const std::unordered_set<ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>>& opponents) const {
|
||||
|
||||
auto fainted = dynamic_cast<Pokemon*>(faintedMon);
|
||||
auto expGain = fainted->GetForme()->GetBaseExperience();
|
||||
|
||||
Reference in New Issue
Block a user