Remove GetProperty macro, as it wasn't that intuitive, and caused issues later.
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:
@@ -10,20 +10,20 @@ Battling::Creature::Creature(const BattleLibrary* library, const Library::Creatu
|
||||
const Library::SpeciesVariant* variant, uint8_t level, uint32_t experience, uint32_t uid,
|
||||
Library::Gender gender, uint8_t coloring, const Library::Item* heldItem,
|
||||
std::string nickname, int8_t talent, std::vector<LearnedAttack*> attacks)
|
||||
: _library(library), __Species(species), __Variant(variant), __Level(level), __Experience(experience),
|
||||
__UniqueIdentifier(uid), __Gender(gender), __Coloring(coloring), __HeldItem(heldItem),
|
||||
_nickname(std::move(nickname)), _talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) {
|
||||
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
|
||||
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem), _nickname(std::move(nickname)),
|
||||
_talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) {
|
||||
_activeTalent = _library->LoadScript(ScriptResolver::ScriptCategory::Talent, GetActiveTalent());
|
||||
}
|
||||
|
||||
void Battling::Creature::ChangeLevel(int8_t amount) {
|
||||
this->__Level += amount;
|
||||
this->_level += amount;
|
||||
RecalculateFlatStats();
|
||||
}
|
||||
|
||||
const std::string& Battling::Creature::GetNickname() const {
|
||||
if (_nickname.empty())
|
||||
return __Species->GetName();
|
||||
return _species->GetName();
|
||||
return _nickname;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const std::string& Battling::Creature::GetActiveTalent() const {
|
||||
if (_hasOverridenTalent) {
|
||||
return _overridenTalentName;
|
||||
}
|
||||
return __Variant->GetTalent(_talentIndex);
|
||||
return _variant->GetTalent(_talentIndex);
|
||||
}
|
||||
|
||||
void Battling::Creature::SetBattleData(Battling::Battle* battle, Battling::BattleSide* side) {
|
||||
@@ -53,7 +53,7 @@ uint32_t Battling::Creature::GetFlatStat(Core::Statistic stat) const { return _f
|
||||
|
||||
uint32_t Battling::Creature::GetBoostedStat(Core::Statistic stat) const { return _boostedStats.GetStat(stat); }
|
||||
|
||||
uint32_t Battling::Creature::GetBaseStat(Core::Statistic stat) const { return __Variant->GetStatistic(stat); }
|
||||
uint32_t Battling::Creature::GetBaseStat(Core::Statistic stat) const { return _variant->GetStatistic(stat); }
|
||||
|
||||
int8_t Battling::Creature::GetStatBoost(Core::Statistic stat) const { return _statBoost.GetStat(stat); }
|
||||
|
||||
@@ -83,7 +83,7 @@ Battling::Battle* Battling::Creature::GetBattle() const { return _battle; }
|
||||
|
||||
Battling::BattleSide* Battling::Creature::GetBattleSide() const { return _side; }
|
||||
|
||||
bool Battling::Creature::IsFainted() const { return this->__CurrentHealth <= 0; }
|
||||
bool Battling::Creature::IsFainted() const { return this->_currentHealth <= 0; }
|
||||
|
||||
void Battling::Creature::OnFaint() {
|
||||
// HOOK: On Faint
|
||||
@@ -96,13 +96,13 @@ void Battling::Creature::OnFaint() {
|
||||
}
|
||||
|
||||
void Battling::Creature::Damage(uint32_t damage, Battling::DamageSource source) {
|
||||
if (damage > __CurrentHealth) {
|
||||
damage = __CurrentHealth;
|
||||
if (damage > _currentHealth) {
|
||||
damage = _currentHealth;
|
||||
}
|
||||
// HOOK: On Damage
|
||||
auto newHealth = __CurrentHealth - damage;
|
||||
this->GetBattle()->TriggerEventListener(new DamageEvent(this, source, __CurrentHealth, newHealth));
|
||||
__CurrentHealth = newHealth;
|
||||
auto newHealth = _currentHealth - damage;
|
||||
this->GetBattle()->TriggerEventListener(new DamageEvent(this, source, _currentHealth, newHealth));
|
||||
_currentHealth = newHealth;
|
||||
|
||||
if (IsFainted() && damage > 0) {
|
||||
OnFaint();
|
||||
@@ -117,7 +117,7 @@ void Battling::Creature::OverrideActiveTalent(const std::string& talent) {
|
||||
|
||||
const std::vector<uint8_t>& Battling::Creature::GetTypes() const {
|
||||
// HOOK: override types.
|
||||
return this->__Variant->GetTypes();
|
||||
return this->_variant->GetTypes();
|
||||
}
|
||||
|
||||
bool Battling::Creature::HasType(uint8_t type) const {
|
||||
@@ -134,24 +134,24 @@ void Battling::Creature::GetActiveScripts(std::vector<ScriptWrapper>& scripts) {
|
||||
void Battling::Creature::ClearVolatileScripts() { _volatile.Clear(); }
|
||||
void Battling::Creature::AddExperience(uint32_t amount) {
|
||||
auto maxLevel = _library->GetSettings().GetMaximalLevel();
|
||||
if (__Level >= maxLevel) {
|
||||
if (_level >= maxLevel) {
|
||||
return;
|
||||
}
|
||||
auto exp = __Experience + amount;
|
||||
auto exp = _experience + amount;
|
||||
auto level = _library->GetGrowthRateLibrary()->CalculateLevel(this->GetSpecies()->GetGrowthRate(), exp);
|
||||
if (level >= maxLevel) {
|
||||
exp = _library->GetGrowthRateLibrary()->CalculateExperience(this->GetSpecies()->GetGrowthRate(), maxLevel);
|
||||
}
|
||||
__Experience = exp;
|
||||
__Level = level;
|
||||
_experience = exp;
|
||||
_level = level;
|
||||
}
|
||||
const Library::CreatureSpecies* Battling::Creature::GetDisplaySpecies() {
|
||||
auto species = __Species;
|
||||
auto species = _species;
|
||||
HOOK(OverrideDisplaySpecies, this, this, &species);
|
||||
return species;
|
||||
}
|
||||
const Library::SpeciesVariant* Battling::Creature::GetDisplayVariant() {
|
||||
auto variant = __Variant;
|
||||
auto variant = _variant;
|
||||
HOOK(OverrideDisplayVariant, this, this, &variant);
|
||||
return variant;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user