mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 10:14:06 +00:00
Split out Level progression component (#671)
* Split out Level progression component from Character Component This is to get to the Player forced movement Comp in a sane way * move XML to component insted of abusing charComp * use overrides should probably make everything that calls that call it correctly * fix linking issue
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "Preconditions.h"
|
||||
#include "Preconditions.h"
|
||||
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "MissionComponent.h"
|
||||
#include "Character.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
@@ -128,7 +129,7 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
auto* destroyableComponent = player->GetComponent<DestroyableComponent>();
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
auto* levelComponent = player->GetComponent<LevelProgressionComponent>();
|
||||
auto* character = player->GetCharacter();
|
||||
|
||||
Mission* mission;
|
||||
@@ -207,7 +208,7 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value, bool evaluat
|
||||
case PreconditionType::NoInteraction:
|
||||
return false; // TODO
|
||||
case PreconditionType::HasLevel:
|
||||
return characterComponent->GetLevel() >= value;
|
||||
return levelComponent->GetLevel() >= value;
|
||||
default:
|
||||
return true; // There are a couple more unknown preconditions. Always return true in this case.
|
||||
}
|
||||
|
@@ -62,6 +62,7 @@
|
||||
#include "VanityUtilities.h"
|
||||
#include "GameConfig.h"
|
||||
#include "ScriptedActivityComponent.h"
|
||||
#include "LevelProgressionComponent.h"
|
||||
|
||||
void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr) {
|
||||
std::string chatCommand;
|
||||
@@ -1329,6 +1330,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
// query to set our uscore to the correct value for this level
|
||||
|
||||
auto characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
if (!characterComponent) return;
|
||||
auto levelComponent = entity->GetComponent<LevelProgressionComponent>();
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT requiredUScore from LevelProgressionLookup WHERE id = ?;");
|
||||
query.bind(1, (int)requestedLevel);
|
||||
auto result = query.execQuery();
|
||||
@@ -1336,18 +1339,18 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (result.eof()) return;
|
||||
|
||||
// Set the UScore first
|
||||
oldLevel = characterComponent->GetLevel();
|
||||
oldLevel = levelComponent->GetLevel();
|
||||
characterComponent->SetUScore(result.getIntField(0, characterComponent->GetUScore()));
|
||||
|
||||
// handle level up for each level we have passed if we set our level to be higher than the current one.
|
||||
if (oldLevel < requestedLevel) {
|
||||
while (oldLevel < requestedLevel) {
|
||||
oldLevel+=1;
|
||||
characterComponent->SetLevel(oldLevel);
|
||||
characterComponent->HandleLevelUp();
|
||||
levelComponent->SetLevel(oldLevel);
|
||||
levelComponent->HandleLevelUp();
|
||||
}
|
||||
} else {
|
||||
characterComponent->SetLevel(requestedLevel);
|
||||
levelComponent->SetLevel(requestedLevel);
|
||||
}
|
||||
|
||||
if (requestedPlayerToSetLevelOf != "") {
|
||||
|
Reference in New Issue
Block a user