mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 15:07:28 +00:00
Added logic to Convert UScore to Coins for Level 45 Characters (#348)
This commit is contained in:
parent
dac8ec621c
commit
13980c4133
@ -469,6 +469,9 @@ enum eRebuildState : uint32_t {
|
||||
REBUILD_INCOMPLETE
|
||||
};
|
||||
|
||||
/**
|
||||
* The loot source's type.
|
||||
*/
|
||||
enum eLootSourceType : int32_t {
|
||||
LOOT_SOURCE_NONE = 0,
|
||||
LOOT_SOURCE_CHEST,
|
||||
|
@ -558,7 +558,7 @@ void GameMessages::SendNotifyMissionTask(Entity* entity, const SystemAddress& sy
|
||||
SEND_PACKET
|
||||
}
|
||||
|
||||
void GameMessages::SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, int sourceType) {
|
||||
void GameMessages::SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType) {
|
||||
CBITSTREAM
|
||||
CMSGHEADER
|
||||
|
||||
@ -566,9 +566,8 @@ void GameMessages::SendModifyLEGOScore(Entity* entity, const SystemAddress& sysA
|
||||
bitStream.Write((uint16_t)GAME_MSG_MODIFY_LEGO_SCORE);
|
||||
bitStream.Write(score);
|
||||
|
||||
//Stuff stolen from the old codebase, no idea why this works. The proper implementation didn't for some reason.
|
||||
bitStream.Write((int32_t)129);
|
||||
bitStream.Write((unsigned char)0);
|
||||
bitStream.Write(sourceType != LOOT_SOURCE_NONE);
|
||||
if (sourceType != LOOT_SOURCE_NONE) bitStream.Write(sourceType);
|
||||
|
||||
SEND_PACKET
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ namespace GameMessages {
|
||||
void SendNotifyMission(Entity * entity, const SystemAddress& sysAddr, int missionID, int missionState, bool sendingRewards);
|
||||
void SendNotifyMissionTask(Entity * entity, const SystemAddress& sysAddr, int missionID, int taskMask, std::vector<float> updates);
|
||||
|
||||
void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, int sourceType);
|
||||
void SendModifyLEGOScore(Entity* entity, const SystemAddress& sysAddr, int64_t score, eLootSourceType sourceType);
|
||||
void SendUIMessageServerToSingleClient(Entity* entity, const SystemAddress& sysAddr, const std::string& message, NDGFxValue args);
|
||||
void SendUIMessageServerToAllClients(const std::string& message, NDGFxValue args);
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "dLocale.h"
|
||||
#include "dLogger.h"
|
||||
#include "dServer.h"
|
||||
#include "dZoneManager.h"
|
||||
|
||||
Mission::Mission(MissionComponent* missionComponent, const uint32_t missionId) {
|
||||
m_MissionComponent = missionComponent;
|
||||
@ -421,11 +422,15 @@ void Mission::YieldRewards() {
|
||||
}
|
||||
}
|
||||
|
||||
int32_t coinsToSend = 0;
|
||||
if (info->LegoScore > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT;
|
||||
if(characterComponent->GetLevel() >= dZoneManager::Instance()->GetMaxLevel()) {
|
||||
// Since the character is at the level cap we reward them with coins instead of UScore.
|
||||
coinsToSend += info->LegoScore * dZoneManager::Instance()->GetLevelCapCurrencyConversion();
|
||||
} else {
|
||||
characterComponent->SetUScore(characterComponent->GetUScore() + info->LegoScore);
|
||||
|
||||
if (info->isMission) {
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), info->LegoScore, 2);
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), info->LegoScore, lootSource);
|
||||
}
|
||||
}
|
||||
|
||||
@ -455,8 +460,9 @@ void Mission::YieldRewards() {
|
||||
inventoryComponent->AddItem(pair.first, count);
|
||||
}
|
||||
|
||||
if (info->reward_currency_repeatable > 0) {
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency_repeatable, LOOT_SOURCE_MISSION);
|
||||
if (info->reward_currency_repeatable > 0 || coinsToSend > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT;
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency_repeatable + coinsToSend, lootSource);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -487,9 +493,9 @@ void Mission::YieldRewards() {
|
||||
inventoryComponent->AddItem(pair.first, count);
|
||||
}
|
||||
|
||||
if (info->reward_currency > 0) {
|
||||
if (info->reward_currency > 0 || coinsToSend > 0) {
|
||||
eLootSourceType lootSource = info->isMission ? LOOT_SOURCE_MISSION : LOOT_SOURCE_ACHIEVEMENT;
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency, lootSource);
|
||||
character->SetCoins(character->GetCoins() + info->reward_currency + coinsToSend, lootSource);
|
||||
}
|
||||
|
||||
if (info->reward_maxinventory > 0) {
|
||||
|
@ -1304,8 +1304,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
CharacterComponent* character = entity->GetComponent<CharacterComponent>();
|
||||
if (character) character->SetUScore(character->GetUScore() + uscore);
|
||||
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, LOOTTYPE_NONE);
|
||||
// LOOT_SOURCE_MODERATION should work but it doesn't. Relog to see uscore changes
|
||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, LOOT_SOURCE_MODERATION);
|
||||
}
|
||||
|
||||
if (chatCommand == "pos" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
|
||||
|
@ -118,6 +118,24 @@ LWOZONEID dZoneManager::GetZoneID() const
|
||||
return m_ZoneID;
|
||||
}
|
||||
|
||||
uint32_t dZoneManager::GetMaxLevel() {
|
||||
if (m_MaxLevel == 0) {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT LevelCap FROM WorldConfig WHERE WorldConfigID = 1 LIMIT 1;");
|
||||
m_MaxLevel = tableData.getIntField(0, -1);
|
||||
tableData.finalize();
|
||||
}
|
||||
return m_MaxLevel;
|
||||
}
|
||||
|
||||
int32_t dZoneManager::GetLevelCapCurrencyConversion() {
|
||||
if (m_CurrencyConversionRate == 0) {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT LevelCapCurrencyConversion FROM WorldConfig WHERE WorldConfigID = 1 LIMIT 1;");
|
||||
m_CurrencyConversionRate = tableData.getIntField(0, -1);
|
||||
tableData.finalize();
|
||||
}
|
||||
return m_CurrencyConversionRate;
|
||||
}
|
||||
|
||||
void dZoneManager::Update(float deltaTime) {
|
||||
for (auto spawner : m_Spawners) {
|
||||
spawner.second->Update(deltaTime);
|
||||
|
@ -33,6 +33,8 @@ public:
|
||||
void NotifyZone(const dZoneNotifier& notifier, const LWOOBJID& objectID); //Notifies the zone of a certain event or command.
|
||||
void AddSpawner(LWOOBJID id, Spawner* spawner);
|
||||
LWOZONEID GetZoneID() const;
|
||||
uint32_t GetMaxLevel();
|
||||
int32_t GetLevelCapCurrencyConversion();
|
||||
LWOOBJID MakeSpawner(SpawnerInfo info);
|
||||
Spawner* GetSpawner(LWOOBJID id);
|
||||
void RemoveSpawner(LWOOBJID id);
|
||||
@ -42,6 +44,16 @@ public:
|
||||
Entity* GetZoneControlObject() { return m_ZoneControlObject; }
|
||||
|
||||
private:
|
||||
/**
|
||||
* The maximum level of the world.
|
||||
*/
|
||||
uint32_t m_MaxLevel = 0;
|
||||
|
||||
/**
|
||||
* The ratio of LEGO Score to currency when the character has hit the max level.
|
||||
*/
|
||||
int32_t m_CurrencyConversionRate = 0;
|
||||
|
||||
static dZoneManager* m_Address; //Singleton
|
||||
Zone* m_pZone;
|
||||
LWOZONEID m_ZoneID;
|
||||
|
Loading…
Reference in New Issue
Block a user