From e56732184fcad14f0b6fb0b9217465479d5c810b Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 24 Apr 2022 17:25:45 -0700 Subject: [PATCH 1/2] commit --- dGame/dComponents/DestroyableComponent.cpp | 26 +++++++++++----------- dGame/dMission/Mission.cpp | 4 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 31b3af19..c0cad3ba 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -215,6 +215,8 @@ void DestroyableComponent::SetHealth(int32_t value) { void DestroyableComponent::SetMaxHealth(float value, bool playAnim) { m_DirtyHealth = true; + // Used for playAnim if opted in for. + int32_t difference = static_cast(std::abs(m_fMaxHealth - value)); m_fMaxHealth = value; if (m_iHealth > m_fMaxHealth) { @@ -225,22 +227,21 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) { // Now update the player bar if (!m_Parent->GetParentUser()) return; AMFStringValue* amount = new AMFStringValue(); - amount->SetStringValue(std::to_string(value)); + amount->SetStringValue(std::to_string(difference)); AMFStringValue* type = new AMFStringValue(); type->SetStringValue("health"); AMFArrayValue args; args.InsertValue("amount", amount); args.InsertValue("type", type); - + Game::logger->Log("DestComp", "Setting max health diff %i\n", difference); GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args); delete amount; delete type; } - else { - EntityManager::Instance()->SerializeEntity(m_Parent); - } + + EntityManager::Instance()->SerializeEntity(m_Parent); } void DestroyableComponent::SetArmor(int32_t value) { @@ -287,9 +288,8 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) { delete amount; delete type; } - else { - EntityManager::Instance()->SerializeEntity(m_Parent); - } + + EntityManager::Instance()->SerializeEntity(m_Parent); } void DestroyableComponent::SetImagination(int32_t value) { @@ -310,6 +310,8 @@ void DestroyableComponent::SetImagination(int32_t value) { void DestroyableComponent::SetMaxImagination(float value, bool playAnim) { m_DirtyHealth = true; + // Used for playAnim if opted in for. + int32_t difference = static_cast(std::abs(m_fMaxImagination - value)); m_fMaxImagination = value; if (m_iImagination > m_fMaxImagination) { @@ -320,22 +322,20 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) { // Now update the player bar if (!m_Parent->GetParentUser()) return; AMFStringValue* amount = new AMFStringValue(); - amount->SetStringValue(std::to_string(value)); + amount->SetStringValue(std::to_string(difference)); AMFStringValue* type = new AMFStringValue(); type->SetStringValue("imagination"); AMFArrayValue args; args.InsertValue("amount", amount); args.InsertValue("type", type); - + Game::logger->Log("DestComp", "Setting max imagiantion diff %i\n", difference); GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args); delete amount; delete type; } - else { - EntityManager::Instance()->SerializeEntity(m_Parent); - } + EntityManager::Instance()->SerializeEntity(m_Parent); } void DestroyableComponent::SetDamageToAbsorb(int32_t value) diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 14fc5a24..a7d67c50 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -528,11 +528,11 @@ void Mission::YieldRewards() { } if (info->reward_maxhealth > 0) { - destroyableComponent->SetMaxHealth(destroyableComponent->GetMaxHealth() + static_cast(info->reward_maxhealth)); + destroyableComponent->SetMaxHealth(destroyableComponent->GetMaxHealth() + static_cast(info->reward_maxhealth), true); } if (info->reward_maximagination > 0) { - destroyableComponent->SetMaxImagination(destroyableComponent->GetMaxImagination() + static_cast(info->reward_maximagination)); + destroyableComponent->SetMaxImagination(destroyableComponent->GetMaxImagination() + static_cast(info->reward_maximagination), true); } EntityManager::Instance()->SerializeEntity(entity); From 2e29dce77c262fb3dae26ff421db6c357785f27c Mon Sep 17 00:00:00 2001 From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com> Date: Sun, 24 Apr 2022 17:27:25 -0700 Subject: [PATCH 2/2] removed logs --- dGame/dComponents/DestroyableComponent.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index c0cad3ba..0e348182 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -234,7 +234,6 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) { AMFArrayValue args; args.InsertValue("amount", amount); args.InsertValue("type", type); - Game::logger->Log("DestComp", "Setting max health diff %i\n", difference); GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args); delete amount; @@ -329,7 +328,6 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) { AMFArrayValue args; args.InsertValue("amount", amount); args.InsertValue("type", type); - Game::logger->Log("DestComp", "Setting max imagiantion diff %i\n", difference); GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args); delete amount;