Adds Creature specific weight and height, which can be modified dynamically during battles.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-10-30 17:07:13 +02:00
parent 2e2abfe122
commit a12972472b
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 26 additions and 1 deletions

View File

@ -17,7 +17,8 @@ namespace CreatureLib::Battling {
bool allowedExperienceGain) bool allowedExperienceGain)
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience), : _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem), _uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem),
_nickname(std::move(nickname)), _talentIndex(talent), _hasOverridenTalent(false), _attacks(attacks), _weight(variant->GetWeight()), _height(variant->GetHeight()), _nickname(std::move(nickname)),
_talentIndex(talent), _hasOverridenTalent(false), _attacks(attacks),
_allowedExperienceGain(allowedExperienceGain) { _allowedExperienceGain(allowedExperienceGain) {
_activeTalent = _activeTalent =
std::unique_ptr<BattleScript>(_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent())); std::unique_ptr<BattleScript>(_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent()));
@ -108,6 +109,8 @@ namespace CreatureLib::Battling {
_battleData = {}; _battleData = {};
_battleData.SeenOpponents = {}; _battleData.SeenOpponents = {};
ResetActiveScripts(); ResetActiveScripts();
_weight = _variant->GetWeight();
_height = _variant->GetHeight();
} }
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) { bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {

View File

@ -36,6 +36,9 @@ namespace CreatureLib::Battling {
ArbUt::OptionalBorrowedPtr<const Library::Item> _heldItem; ArbUt::OptionalBorrowedPtr<const Library::Item> _heldItem;
uint32_t _currentHealth = -1; uint32_t _currentHealth = -1;
f32 _weight;
f32 _height;
Library::ClampedStatisticSet<int8_t, -6, 6> _statBoost; Library::ClampedStatisticSet<int8_t, -6, 6> _statBoost;
Library::StatisticSet<uint32_t> _flatStats; Library::StatisticSet<uint32_t> _flatStats;
Library::StatisticSet<uint32_t> _boostedStats; Library::StatisticSet<uint32_t> _boostedStats;
@ -108,6 +111,22 @@ namespace CreatureLib::Battling {
inline uint32_t GetCurrentHealth() const noexcept { return _currentHealth; } inline uint32_t GetCurrentHealth() const noexcept { return _currentHealth; }
inline f32 GetWeight() const noexcept { return _weight; }
inline void SetWeight(f32 weight) noexcept {
if (weight < 0.1f) {
weight = 0.1f;
}
_weight = weight;
}
inline f32 GetHeight() const noexcept { return _height; }
inline void SetHeight(f32 height) noexcept {
if (height < 0.1f) {
height = 0.1f;
}
_height = height;
}
void SetBattleData(const ArbUt::BorrowedPtr<Battle>& battle, const ArbUt::BorrowedPtr<BattleSide>& side); void SetBattleData(const ArbUt::BorrowedPtr<Battle>& battle, const ArbUt::BorrowedPtr<BattleSide>& side);
void ClearBattleData() noexcept; void ClearBattleData() noexcept;
inline const ArbUt::OptionalBorrowedPtr<Battle>& GetBattle() const { return _battleData.Battle; } inline const ArbUt::OptionalBorrowedPtr<Battle>& GetBattle() const { return _battleData.Battle; }

View File

@ -25,4 +25,7 @@ using i16 = int16_t;
using i32 = int32_t; using i32 = int32_t;
using i64 = int64_t; using i64 = int64_t;
using f32 = float;
using f64 = double;
#endif // CREATURELIB_DEFINES_HPP #endif // CREATURELIB_DEFINES_HPP