diff --git a/data/modules/scripts/blessings/blessings.lua b/data/modules/scripts/blessings/blessings.lua index 744f8046084..96e677d7319 100644 --- a/data/modules/scripts/blessings/blessings.lua +++ b/data/modules/scripts/blessings/blessings.lua @@ -21,7 +21,7 @@ Blessings.Credits = { Blessings.Config = { AdventurerBlessingLevel = configManager.getNumber(configKeys.ADVENTURERSBLESSING_LEVEL), -- Free full bless until level - HasToF = false, -- Enables/disables twist of fate + HasToF = true, -- Enables/disables twist of fate InquisitonBlessPriceMultiplier = 1.1, -- Bless price multiplied by henricus SkulledDeathLoseStoreItem = configManager.getBoolean(configKeys.SKULLED_DEATH_LOSE_STORE_ITEM), -- Destroy all items on store when dying with red/blackskull InventoryGlowOnFiveBless = configManager.getBoolean(configKeys.INVENTORY_GLOW), -- Glow in yellow inventory items when the player has 5 or more bless, diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 5032547e3f8..51ad0e4717e 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -635,20 +635,6 @@ phmap::flat_hash_map> Player::getAllSlotItems() c return itemMap; } -phmap::flat_hash_map Player::getBlessingNames() const { - static phmap::flat_hash_map blessingNames = { - { TWIST_OF_FATE, "Twist of Fate" }, - { WISDOM_OF_SOLITUDE, "The Wisdom of Solitude" }, - { SPARK_OF_THE_PHOENIX, "The Spark of the Phoenix" }, - { FIRE_OF_THE_SUNS, "The Fire of the Suns" }, - { SPIRITUAL_SHIELDING, "The Spiritual Shielding" }, - { EMBRACE_OF_TIBIA, "The Embrace of Tibia" }, - { BLOOD_OF_THE_MOUNTAIN, "Blood of the Mountain" }, - { HEARTH_OF_THE_MOUNTAIN, "Heart of the Mountain" }, - }; - return blessingNames; -} - void Player::setTraining(bool value) { for (const auto &[key, player] : g_game().getPlayers()) { if (!this->isInGhostMode() || player->isAccessPlayer()) { @@ -6628,7 +6614,7 @@ std::string Player::getBlessingsName() const { } }); - auto BlessingNames = getBlessingNames(); + auto BlessingNames = g_game().getBlessingNames(); std::ostringstream os; for (uint8_t i = 1; i <= 8; i++) { if (hasBlessing(i)) { diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index 62b66db6a03..edda885751c 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -2595,9 +2595,6 @@ class Player final : public Creature, public Cylinder, public Bankable { // This get all players slot items phmap::flat_hash_map> getAllSlotItems() const; - // This get all blessings - phmap::flat_hash_map getBlessingNames() const; - // Gets the equipped items with augment by type std::vector> getEquippedAugmentItemsByType(Augment_t augmentType) const; diff --git a/src/game/game.cpp b/src/game/game.cpp index 94cc30beb69..db7ab401eba 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -360,6 +360,17 @@ Game::Game() { HighscoreCategory("Magic Level", static_cast(HighscoreCategories_t::MAGIC_LEVEL)) }; + m_blessingNames = { + { static_cast(TWIST_OF_FATE), "Twist of Fate" }, + { static_cast(WISDOM_OF_SOLITUDE), "The Wisdom of Solitude" }, + { static_cast(SPARK_OF_THE_PHOENIX), "The Spark of the Phoenix" }, + { static_cast(FIRE_OF_THE_SUNS), "The Fire of the Suns" }, + { static_cast(SPIRITUAL_SHIELDING), "The Spiritual Shielding" }, + { static_cast(EMBRACE_OF_TIBIA), "The Embrace of Tibia" }, + { static_cast(BLOOD_OF_THE_MOUNTAIN), "Blood of the Mountain" }, + { static_cast(HEARTH_OF_THE_MOUNTAIN), "Heart of the Mountain" }, + }; + m_summaryCategories = { { static_cast(Summary_t::HOUSE_ITEMS), "house-items" }, { static_cast(Summary_t::BOOSTS), "xp-boosts" }, @@ -10668,6 +10679,10 @@ Title Game::getTitleByName(const std::string &name) { return {}; } +std::unordered_map Game::getBlessingNames() { + return m_blessingNames; +} + std::unordered_map Game::getHirelingSkills() { return m_hirelingSkills; } diff --git a/src/game/game.hpp b/src/game/game.hpp index 24b720c659e..584a652dc27 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -735,6 +735,7 @@ class Game { return m_summaryCategories[type]; } + std::unordered_map getBlessingNames(); std::unordered_map getHirelingSkills(); std::unordered_map getHirelingOutfits(); @@ -748,6 +749,8 @@ class Game { std::vector m_highscoreCategories; std::unordered_map m_highscoreCategoriesNames; + std::unordered_map m_blessingNames; + std::unordered_map m_summaryCategories; std::unordered_map m_hirelingSkills; std::unordered_map m_hirelingOutfits; diff --git a/src/game/game_definitions.hpp b/src/game/game_definitions.hpp index a6ce6e7eaa8..8b165bc725d 100644 --- a/src/game/game_definitions.hpp +++ b/src/game/game_definitions.hpp @@ -102,6 +102,17 @@ enum class HighscoreCategories_t : uint8_t { BOSS_POINTS = 14, }; +enum Blessings_t : uint8_t { + TWIST_OF_FATE = 1, + WISDOM_OF_SOLITUDE = 2, + SPARK_OF_THE_PHOENIX = 3, + FIRE_OF_THE_SUNS = 4, + SPIRITUAL_SHIELDING = 5, + EMBRACE_OF_TIBIA = 6, + BLOOD_OF_THE_MOUNTAIN = 7, + HEARTH_OF_THE_MOUNTAIN = 8, +}; + enum HighscoreType_t : uint8_t { HIGHSCORE_GETENTRIES = 0, HIGHSCORE_OURRANK = 1 diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 147b00b75c8..b929f024293 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -3976,30 +3976,14 @@ void ProtocolGame::sendCyclopediaCharacterStoreSummary() { auto cyclopediaSummary = player->cyclopedia()->getSummary(); // getBlessingsObtained - auto blessingNames = player->getBlessingNames(); + auto blessingNames = g_game().getBlessingNames(); std::vector> orderedBlessings; - for (const auto &bless : blessingNames) { - orderedBlessings.emplace_back(bless.first, bless.second); - } - std::sort(orderedBlessings.begin(), orderedBlessings.end(), [](const std::pair &a, const std::pair &b) { - return a.first < b.first; - }); - msg.addByte(static_cast(blessingNames.size())); - // auto blessingsObtained = player->cyclopedia()->getResult(static_cast(Summary_t::BLESSINGS)); - for (const auto &bless : orderedBlessings) { + for (const auto &bless : blessingNames) { g_logger().info("bless: {} - {}", bless.first, bless.second); msg.addString(bless.second, "ProtocolGame::sendCyclopediaCharacterStoreSummary - blessing.name"); uint8_t blessingIndex = bless.first - 1; msg.addByte((blessingIndex < player->blessings.size()) ? static_cast(player->blessings[blessingIndex]) : 0); - - // msg.addByte(static_cast(player->blessings[bless.first - 1])); - // msg.addByte(std::find(player->blessings.begin(), player->blessings.end(), )//player->getBlessingCount(bless.first)); - // uint16_t blessAmount = 0; - // auto it = std::find_if(blessingsObtained.begin(), blessingsObtained.end(), [&bName_it](const auto &b_it) { - // return b_it.first == bName_it.first; - // }); - // msg.addByte((it != blessingsObtained.end()) ? static_cast(it->second) : 0x00); } uint8_t preySlotsUnlocked = 0; @@ -4029,22 +4013,20 @@ void ProtocolGame::sendCyclopediaCharacterStoreSummary() { } msg.addByte(m_hSkills.size()); for (const auto &id : m_hSkills) { - msg.add(id - 1000); - // msg.addByte(id); - } - - // std::vector m_hOutfits; - // for (const auto &it : g_game().getHirelingOutfits()) { - // if (player->kv()->scoped("hireling-outfits")->get(it.second)) { - // m_hOutfits.emplace_back(it.first); - // g_logger().info("outfit id: {}, name: {}", it.first, it.second); - // } - // } - // msg.addByte(m_hOutfits.size()); - // for (const auto &id : m_hOutfits) { - // msg.add(id); - // // msg.addByte(id); - // } + msg.addByte(id - 1000); + } + + std::vector m_hOutfits; + for (const auto &it : g_game().getHirelingOutfits()) { + if (player->kv()->scoped("hireling-outfits")->get(it.second)) { + m_hOutfits.emplace_back(it.first); + g_logger().info("outfit id: {}, name: {}", it.first, it.second); + } + } + msg.addByte(m_hOutfits.size()); + for (const auto &id : m_hOutfits) { + msg.addByte(id - 2000); + } msg.addByte(0x00); auto houseItems = player->cyclopedia()->getResult(static_cast(Summary_t::HOUSE_ITEMS)); diff --git a/src/utils/utils_definitions.hpp b/src/utils/utils_definitions.hpp index af2c40ba533..7466c83a8f2 100644 --- a/src/utils/utils_definitions.hpp +++ b/src/utils/utils_definitions.hpp @@ -709,17 +709,6 @@ enum class PlayerFlags_t : uint8_t { FlagLast }; -enum Blessings_t : uint8_t { - TWIST_OF_FATE = 1, - WISDOM_OF_SOLITUDE = 2, - SPARK_OF_THE_PHOENIX = 3, - FIRE_OF_THE_SUNS = 4, - SPIRITUAL_SHIELDING = 5, - EMBRACE_OF_TIBIA = 6, - BLOOD_OF_THE_MOUNTAIN = 7, - HEARTH_OF_THE_MOUNTAIN = 8, -}; - enum BedItemPart_t : uint8_t { BED_NONE_PART, BED_PILLOW_PART,