From a12972472b4a326e6a9ed76b8ddccf6e4a4040f1 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 30 Oct 2021 17:07:13 +0200 Subject: [PATCH] Adds Creature specific weight and height, which can be modified dynamically during battles. --- src/Battling/Models/Creature.cpp | 5 ++++- src/Battling/Models/Creature.hpp | 19 +++++++++++++++++++ src/Defines.hpp | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 769f7b0..c277cfe 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -17,7 +17,8 @@ namespace CreatureLib::Battling { bool allowedExperienceGain) : _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(attacks), + _weight(variant->GetWeight()), _height(variant->GetHeight()), _nickname(std::move(nickname)), + _talentIndex(talent), _hasOverridenTalent(false), _attacks(attacks), _allowedExperienceGain(allowedExperienceGain) { _activeTalent = std::unique_ptr(_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent())); @@ -108,6 +109,8 @@ namespace CreatureLib::Battling { _battleData = {}; _battleData.SeenOpponents = {}; ResetActiveScripts(); + _weight = _variant->GetWeight(); + _height = _variant->GetHeight(); } bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) { diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index f1d2999..eaec881 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -36,6 +36,9 @@ namespace CreatureLib::Battling { ArbUt::OptionalBorrowedPtr _heldItem; uint32_t _currentHealth = -1; + f32 _weight; + f32 _height; + Library::ClampedStatisticSet _statBoost; Library::StatisticSet _flatStats; Library::StatisticSet _boostedStats; @@ -108,6 +111,22 @@ namespace CreatureLib::Battling { 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, const ArbUt::BorrowedPtr& side); void ClearBattleData() noexcept; inline const ArbUt::OptionalBorrowedPtr& GetBattle() const { return _battleData.Battle; } diff --git a/src/Defines.hpp b/src/Defines.hpp index d4ae49f..2bdd0ff 100644 --- a/src/Defines.hpp +++ b/src/Defines.hpp @@ -25,4 +25,7 @@ using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; +using f32 = float; +using f64 = double; + #endif // CREATURELIB_DEFINES_HPP