From 2bd73bd4ef3c3df38572688cfa311813ec581368 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 30 Oct 2021 17:50:26 +0200 Subject: [PATCH] Reset weight/height when variant changes, when a creature is moved out of the battle. --- src/Battling/Models/Creature.cpp | 14 +++++++++++++- src/Battling/Models/Creature.hpp | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index c277cfe..9608d2a 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -61,6 +61,9 @@ namespace CreatureLib::Battling { _types.push_back(t); } + _weight = variant->GetWeight(); + _height = variant->GetHeight(); + // Grab the new active talent. _activeTalent = std::unique_ptr(_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent())); @@ -113,6 +116,15 @@ namespace CreatureLib::Battling { _height = _variant->GetHeight(); } + void Battling::Creature::SetOnBattleField(bool value) { + _battleData.OnBattleField = value; + if (!value) { + ResetActiveScripts(); + _weight = _variant->GetWeight(); + _height = _variant->GetHeight(); + } + } + bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) { bool changed = false; auto oldValue = this->_statBoost.GetStat(stat); @@ -410,4 +422,4 @@ Battling::Creature::~Creature() { if (_battleData.OnBattleField && _battleData.Side.HasValue()) { _battleData.Side.GetValue()->ForceClearCreature(_battleData.Index.GetCreatureIndex()); } -} +} \ No newline at end of file diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index eaec881..cd99b92 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -131,7 +131,7 @@ namespace CreatureLib::Battling { void ClearBattleData() noexcept; inline const ArbUt::OptionalBorrowedPtr& GetBattle() const { return _battleData.Battle; } inline const ArbUt::OptionalBorrowedPtr& GetBattleSide() const { return _battleData.Side; } - inline void SetOnBattleField(bool value) { _battleData.OnBattleField = value; } + inline void SetOnBattleField(bool value); inline void SetBattleIndex(const CreatureIndex& index) { _battleData.Index = index; } inline const CreatureIndex& GetBattleIndex() const noexcept { return _battleData.Index; } inline bool IsOnBattleField() const { return _battleData.OnBattleField; }