Implement CDZoneTable PlayerLoseCoinsOnDeath (#251)

* Implement ZoneTable PlayerLoseCoinsOnDeath

- Adds a check on death if the character should drop coins in the current zone

* Refactored PlayerLoseCoinOnDeath into dZoneManager

* Coin death drops use LootGenerator

* Refactored again with use of CDZoneTableTable

* Remove duplicate CDZone call during initialization
This commit is contained in:
cooltrain7
2022-02-05 12:27:24 +00:00
committed by GitHub
parent f7009b499b
commit 579cf590b4
3 changed files with 35 additions and 29 deletions

View File

@@ -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<CDZoneTableTable>("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