From 2a0616d0e9a9f25ce6d0244bbe199cafdec6e85d Mon Sep 17 00:00:00 2001
From: EmosewaMC <39972741+EmosewaMC@users.noreply.github.com>
Date: Sat, 18 Jun 2022 00:14:24 -0700
Subject: [PATCH] Dont take imagination on initial tame

---
 dGame/dComponents/PetComponent.cpp | 14 +++++++-------
 dGame/dComponents/PetComponent.h   |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp
index 891f0d1d..23dcf5e6 100644
--- a/dGame/dComponents/PetComponent.cpp
+++ b/dGame/dComponents/PetComponent.cpp
@@ -651,7 +651,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
 
     inventoryComponent->SetDatabasePet(petSubKey, databasePet);
 
-    Activate(item, false);
+    Activate(item, false, true);
 
     m_Timer = 0;
 
@@ -912,9 +912,9 @@ void PetComponent::Wander()
 	m_Timer += (m_MovementAI->GetCurrentPosition().x - destination.x) / info.wanderSpeed;
 }
 
-void PetComponent::Activate(Item* item, bool registerPet) 
+void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) 
 {
-    AddDrainImaginationTimer(item);
+    AddDrainImaginationTimer(item, fromTaming);
 
     m_ItemId = item->GetId();
     m_DatabaseId = item->GetSubKey();
@@ -985,9 +985,9 @@ void PetComponent::Activate(Item* item, bool registerPet)
     GameMessages::SendShowPetActionButton(m_Owner, 3, true, owner->GetSystemAddress());
 }
 
-void PetComponent::AddDrainImaginationTimer(Item* item) {
+void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
     if (Game::config->GetValue("pets_imagination") != "1") return;
-    
+
     auto playerInventory = item->GetInventory();
     if (!playerInventory) return;
 
@@ -1000,8 +1000,8 @@ void PetComponent::AddDrainImaginationTimer(Item* item) {
     auto playerDestroyableComponent = playerEntity->GetComponent<DestroyableComponent>();
     if (!playerDestroyableComponent) return;
 
-    // Drain by 1 when you summon pet or when this method is called
-    playerDestroyableComponent->Imagine(-1);
+    // Drain by 1 when you summon pet or when this method is called, but not when we have just tamed this pet.
+    if (!fromTaming) playerDestroyableComponent->Imagine(-1);
 
     // Set this to a variable so when this is called back from the player the timer doesn't fire off.
     m_Parent->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item](){
diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h
index 9139575a..913cbc56 100644
--- a/dGame/dComponents/PetComponent.h
+++ b/dGame/dComponents/PetComponent.h
@@ -82,7 +82,7 @@ public:
      * @param item the item to create the pet from
      * @param registerPet notifies the client that the pet was spawned, not necessary if this pet is being tamed
      */
-    void Activate(Item* item, bool registerPet = true);
+    void Activate(Item* item, bool registerPet = true, bool fromTaming = false);
 
     /**
      * Despawns the pet
@@ -209,7 +209,7 @@ public:
      * 
      * @param item The item that represents this pet in the inventory.
      */
-    void AddDrainImaginationTimer(Item* item);
+    void AddDrainImaginationTimer(Item* item, bool fromTaming = false);
 
 private: