mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
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:
@@ -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<int>(hundreth);
|
||||
}
|
||||
uint64_t coinsToLoose = 1;
|
||||
|
||||
if (coinsToLoose > 10000)
|
||||
{
|
||||
coinsToLoose = 10000;
|
||||
}
|
||||
if (coinsTotal >= 200)
|
||||
{
|
||||
float hundreth = (coinsTotal / 100.0f);
|
||||
coinsToLoose = static_cast<int>(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);
|
||||
|
Reference in New Issue
Block a user