mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Merge pull request #935 from EmosewaMC/WorldConfig
Eliminate WorldConfig Based Magic Numbers
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "PossessorComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "WorldConfig.h"
|
||||
|
||||
DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) {
|
||||
m_iArmor = 0;
|
||||
@@ -763,22 +764,17 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath()) {
|
||||
auto* character = m_Parent->GetCharacter();
|
||||
uint64_t coinsTotal = character->GetCoins();
|
||||
const uint64_t minCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMin;
|
||||
if (coinsTotal >= minCoinsToLose) {
|
||||
const uint64_t maxCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMax;
|
||||
const float coinPercentageToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathPercent;
|
||||
|
||||
if (coinsTotal > 0) {
|
||||
uint64_t coinsToLoose = 1;
|
||||
uint64_t coinsToLose = std::max(static_cast<uint64_t>(coinsTotal * coinPercentageToLose), minCoinsToLose);
|
||||
coinsToLose = std::min(maxCoinsToLose, coinsToLose);
|
||||
|
||||
if (coinsTotal >= 200) {
|
||||
float hundreth = (coinsTotal / 100.0f);
|
||||
coinsToLoose = static_cast<int>(hundreth);
|
||||
}
|
||||
coinsTotal -= coinsToLose;
|
||||
|
||||
if (coinsToLoose > 10000) {
|
||||
coinsToLoose = 10000;
|
||||
}
|
||||
|
||||
coinsTotal -= coinsToLoose;
|
||||
|
||||
LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose);
|
||||
LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLose, coinsToLose);
|
||||
character->SetCoins(coinsTotal, eLootSourceType::LOOT_SOURCE_PICKUP);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "dZoneManager.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "Database.h"
|
||||
#include "WorldConfig.h"
|
||||
|
||||
Mission::Mission(MissionComponent* missionComponent, const uint32_t missionId) {
|
||||
m_MissionComponent = missionComponent;
|
||||
@@ -435,9 +436,9 @@ void Mission::YieldRewards() {
|
||||
int32_t coinsToSend = 0;
|
||||
if (info->LegoScore > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? eLootSourceType::LOOT_SOURCE_MISSION : eLootSourceType::LOOT_SOURCE_ACHIEVEMENT;
|
||||
if (levelComponent->GetLevel() >= dZoneManager::Instance()->GetMaxLevel()) {
|
||||
if (levelComponent->GetLevel() >= dZoneManager::Instance()->GetWorldConfig()->levelCap) {
|
||||
// Since the character is at the level cap we reward them with coins instead of UScore.
|
||||
coinsToSend += info->LegoScore * dZoneManager::Instance()->GetLevelCapCurrencyConversion();
|
||||
coinsToSend += info->LegoScore * dZoneManager::Instance()->GetWorldConfig()->levelCapCurrencyConversion;
|
||||
} else {
|
||||
characterComponent->SetUScore(characterComponent->GetUScore() + info->LegoScore);
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), info->LegoScore, lootSource);
|
||||
|
@@ -22,6 +22,8 @@
|
||||
#include "MissionComponent.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "Character.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "WorldConfig.h"
|
||||
|
||||
void Mail::SendMail(const Entity* recipient, const std::string& subject, const std::string& body, const LOT attachment,
|
||||
const uint16_t attachmentCount) {
|
||||
@@ -191,7 +193,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
|
||||
uint32_t itemID = static_cast<uint32_t>(attachmentID);
|
||||
LOT itemLOT = 0;
|
||||
//Inventory::InventoryType itemType;
|
||||
int mailCost = 25;
|
||||
int mailCost = dZoneManager::Instance()->GetWorldConfig()->mailBaseFee;
|
||||
int stackSize = 0;
|
||||
auto inv = static_cast<InventoryComponent*>(entity->GetComponent(COMPONENT_TYPE_INVENTORY));
|
||||
Item* item = nullptr;
|
||||
@@ -199,7 +201,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
|
||||
if (itemID > 0 && attachmentCount > 0 && inv) {
|
||||
item = inv->FindItemById(attachmentID);
|
||||
if (item) {
|
||||
mailCost += (item->GetInfo().baseValue * 0.1f);
|
||||
mailCost += (item->GetInfo().baseValue * dZoneManager::Instance()->GetWorldConfig()->mailPercentAttachmentFee);
|
||||
stackSize = item->GetCount();
|
||||
itemLOT = item->GetLot();
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user