Support for changing variants.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
637649c993
commit
c8314d6018
|
@ -25,6 +25,11 @@ export void CreatureLib_Creature_Destruct(const Creature* p) { delete p; }
|
||||||
|
|
||||||
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetSpecies, const CreatureLib::Library::CreatureSpecies*);
|
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetSpecies, const CreatureLib::Library::CreatureSpecies*);
|
||||||
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetVariant, const CreatureLib::Library::SpeciesVariant*);
|
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetVariant, const CreatureLib::Library::SpeciesVariant*);
|
||||||
|
|
||||||
|
export uint8_t CreatureLib_Creature_ChangeVariant(Creature* p, const CreatureLib::Library::SpeciesVariant* variant) {
|
||||||
|
Try(p->ChangeVariant(variant);)
|
||||||
|
}
|
||||||
|
|
||||||
SIMPLE_GET_FUNC(Creature, GetLevel, uint8_t);
|
SIMPLE_GET_FUNC(Creature, GetLevel, uint8_t);
|
||||||
SIMPLE_GET_FUNC(Creature, GetExperience, uint32_t);
|
SIMPLE_GET_FUNC(Creature, GetExperience, uint32_t);
|
||||||
SIMPLE_GET_FUNC(Creature, GetGender, CreatureLib::Library::Gender);
|
SIMPLE_GET_FUNC(Creature, GetGender, CreatureLib::Library::Gender);
|
||||||
|
|
|
@ -30,6 +30,33 @@ Battling::Creature::Creature(ArbUt::BorrowedPtr<const BattleLibrary> library,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Battling::Creature::ChangeVariant(ArbUt::BorrowedPtr<const Library::SpeciesVariant> variant) {
|
||||||
|
AssertNotNull(variant)
|
||||||
|
_variant = variant;
|
||||||
|
|
||||||
|
// Set the types to the new variant.
|
||||||
|
_types.clear();
|
||||||
|
for (auto t : variant->GetTypes()) {
|
||||||
|
_types.insert(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grab the new active talent.
|
||||||
|
_activeTalent =
|
||||||
|
std::unique_ptr<CreatureLib::Battling::Script>(_library->LoadScript(ScriptCategory::Talent, GetActiveTalent()));
|
||||||
|
|
||||||
|
// We modify the health of the creature by the change in its max health.
|
||||||
|
auto prevHealth = GetBoostedStat(CreatureLib::Library::Statistic::Health);
|
||||||
|
RecalculateFlatStats();
|
||||||
|
int32_t diffHealth = GetBoostedStat(CreatureLib::Library::Statistic::Health) - prevHealth;
|
||||||
|
if (_currentHealth < -diffHealth) {
|
||||||
|
_currentHealth = 0;
|
||||||
|
} else {
|
||||||
|
_currentHealth += diffHealth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: consider variant specific attacks?
|
||||||
|
}
|
||||||
|
|
||||||
void Battling::Creature::ChangeLevelBy(int8_t amount) {
|
void Battling::Creature::ChangeLevelBy(int8_t amount) {
|
||||||
auto level = _level + amount;
|
auto level = _level + amount;
|
||||||
if (level > _library->GetSettings()->GetMaximalLevel())
|
if (level > _library->GetSettings()->GetMaximalLevel())
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace CreatureLib::Battling {
|
||||||
return _species;
|
return _species;
|
||||||
}
|
}
|
||||||
inline const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& GetVariant() const noexcept { return _variant; }
|
inline const ArbUt::BorrowedPtr<const Library::SpeciesVariant>& GetVariant() const noexcept { return _variant; }
|
||||||
|
virtual void ChangeVariant(ArbUt::BorrowedPtr<const Library::SpeciesVariant> variant);
|
||||||
inline uint8_t GetLevel() const noexcept { return _level; }
|
inline uint8_t GetLevel() const noexcept { return _level; }
|
||||||
inline uint32_t GetExperience() const noexcept { return _experience; }
|
inline uint32_t GetExperience() const noexcept { return _experience; }
|
||||||
inline Library::Gender GetGender() const noexcept { return _gender; }
|
inline Library::Gender GetGender() const noexcept { return _gender; }
|
||||||
|
|
Loading…
Reference in New Issue