diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 8c56d4c1..31b3af19 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -26,6 +26,7 @@ #include "MissionComponent.h" #include "CharacterComponent.h" +#include "dZoneManager.h" DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) { m_iArmor = 0; @@ -796,32 +797,34 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType } else { - auto* character = m_Parent->GetCharacter(); - - uint64_t coinsTotal = character->GetCoins(); - - if (coinsTotal > 0) + //Check if this zone allows coin drops + if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath()) { - uint64_t coinsToLoose = 1; + auto* character = m_Parent->GetCharacter(); + uint64_t coinsTotal = character->GetCoins(); - if (coinsTotal >= 200) + if (coinsTotal > 0) { - float hundreth = (coinsTotal / 100.0f); - coinsToLoose = static_cast(hundreth); - } + uint64_t coinsToLoose = 1; - if (coinsToLoose > 10000) - { - coinsToLoose = 10000; - } + if (coinsTotal >= 200) + { + float hundreth = (coinsTotal / 100.0f); + coinsToLoose = static_cast(hundreth); + } - coinsTotal -= coinsToLoose; - - LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose); + if (coinsToLoose > 10000) + { + coinsToLoose = 10000; + } + + coinsTotal -= coinsToLoose; + + LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose); + character->SetCoins(coinsTotal, LOOT_SOURCE_PICKUP); + } } - character->SetCoins(coinsTotal, LOOT_SOURCE_PICKUP); - Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity(); for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) { script->OnPlayerDied(zoneControl, m_Parent); diff --git a/dZoneManager/dZoneManager.cpp b/dZoneManager/dZoneManager.cpp index 6f11e8e4..687c93f9 100644 --- a/dZoneManager/dZoneManager.cpp +++ b/dZoneManager/dZoneManager.cpp @@ -26,19 +26,20 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) { LOT zoneControlTemplate = 2365; - std::stringstream query; - auto result = CDClientDatabase::ExecuteQuery("SELECT zoneControlTemplate, ghostdistance_min, ghostdistance FROM ZoneTable WHERE zoneID = " + std::to_string(zoneID.GetMapID())); + CDZoneTableTable* zoneTable = CDClientManager::Instance()->GetTable("ZoneTable"); + if (zoneTable != nullptr){ + const CDZoneTable* zone = zoneTable->Query(zoneID.GetMapID()); - if (!result.eof()) { - zoneControlTemplate = result.getIntField("zoneControlTemplate", 2365); - const auto min = result.getIntField("ghostdistance_min", 100); - const auto max = result.getIntField("ghostdistance", 100); - EntityManager::Instance()->SetGhostDistanceMax(max + min); - EntityManager::Instance()->SetGhostDistanceMin(max); + if (zone != nullptr) { + zoneControlTemplate = zone->zoneControlTemplate != -1 ? zone->zoneControlTemplate : 2365; + const auto min = zone->ghostdistance_min != -1.0f ? zone->ghostdistance_min : 100; + const auto max = zone->ghostdistance != -1.0f ? zone->ghostdistance : 100; + EntityManager::Instance()->SetGhostDistanceMax(max + min); + EntityManager::Instance()->SetGhostDistanceMin(min); + m_PlayerLoseCoinsOnDeath = zone->PlayerLoseCoinsOnDeath; + } } - result.finalize(); - Game::logger->Log("dZoneManager", "Creating zone control object %i\n", zoneControlTemplate); // Create ZoneControl object diff --git a/dZoneManager/dZoneManager.h b/dZoneManager/dZoneManager.h index 8eb04cca..3171c81f 100644 --- a/dZoneManager/dZoneManager.h +++ b/dZoneManager/dZoneManager.h @@ -42,6 +42,7 @@ public: std::vector GetSpawnersInGroup(std::string group); void Update(float deltaTime); Entity* GetZoneControlObject() { return m_ZoneControlObject; } + bool GetPlayerLoseCoinOnDeath() { return m_PlayerLoseCoinsOnDeath; } private: /** @@ -57,6 +58,7 @@ private: static dZoneManager* m_Address; //Singleton Zone* m_pZone; LWOZONEID m_ZoneID; + bool m_PlayerLoseCoinsOnDeath; //Do players drop coins in this zone when smashed std::map m_Spawners; Entity* m_ZoneControlObject;