mirror of
https://github.com/azerothcore/mod-account-achievements
synced 2025-11-29 23:39:58 +08:00
Add Support for Excluding Specific Achievement IDs from Account-Wide Sync (#18)
* feature: config exclude achievement ids * set default excluded ids to 0 * update header * restore comments * restore default limitrace
This commit is contained in:
@@ -11,3 +11,7 @@ Account.Achievements.Enable = 1
|
|||||||
# Announce the module when the player logs in?
|
# Announce the module when the player logs in?
|
||||||
|
|
||||||
Account.Achievements.Announce = 1
|
Account.Achievements.Announce = 1
|
||||||
|
|
||||||
|
# List of achievement IDs to exclude (comma-separated)
|
||||||
|
|
||||||
|
Account.Achievements.Excluded = 0
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
- Comment: Tested and Works.
|
- Comment: Tested and Works.
|
||||||
- Orginial Creator: Lille Carl
|
- Orginial Creator: Lille Carl
|
||||||
- Edited: Render/Grim
|
- Edited: Render/Grim
|
||||||
|
- Edited: Blkht01(Qeme) Classic Plus - Added Exclusion
|
||||||
<--------------------------------------------------------------------------->
|
<--------------------------------------------------------------------------->
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -13,6 +14,8 @@
|
|||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
class AccountAchievements : public PlayerScript
|
class AccountAchievements : public PlayerScript
|
||||||
{
|
{
|
||||||
@@ -21,10 +24,28 @@ class AccountAchievements : public PlayerScript
|
|||||||
int minlevel = 80; // It's set to players of the level 60. Requires limitlevel to be set to true.
|
int minlevel = 80; // It's set to players of the level 60. Requires limitlevel to be set to true.
|
||||||
int setlevel = 1; // Dont Change
|
int setlevel = 1; // Dont Change
|
||||||
|
|
||||||
public:
|
std::unordered_set<uint32> excludedAchievements; // Store excluded achievement IDs
|
||||||
AccountAchievements() : PlayerScript("AccountAchievements") { }
|
|
||||||
|
|
||||||
void OnLogin(Player* pPlayer)
|
public:
|
||||||
|
AccountAchievements() : PlayerScript("AccountAchievements")
|
||||||
|
{
|
||||||
|
// Load excluded achievements from config
|
||||||
|
std::string excludeList = sConfigMgr->GetOption<std::string>("Account.Achievements.Excluded", "");
|
||||||
|
std::stringstream ss(excludeList);
|
||||||
|
std::string token;
|
||||||
|
|
||||||
|
while (std::getline(ss, token, ','))
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
uint32 id = std::stoul(token);
|
||||||
|
excludedAchievements.insert(id);
|
||||||
|
} catch (...) {
|
||||||
|
LOG_ERROR("module", "Invalid achievement ID in Account.Achievements.Excluded: {}", token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnLogin(Player* pPlayer) override
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetOption<bool>("Account.Achievements.Enable", true))
|
if (sConfigMgr->GetOption<bool>("Account.Achievements.Enable", true))
|
||||||
{
|
{
|
||||||
@@ -41,11 +62,10 @@ public:
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field* fields = result1->Fetch();
|
Field* fields = result1->Fetch();
|
||||||
|
|
||||||
uint32 race = fields[1].Get<uint8>();
|
uint32 race = fields[1].Get<uint8>();
|
||||||
|
|
||||||
if ((Player::TeamIdForRace(race) == Player::TeamIdForRace(pPlayer->getRace())) || !limitrace)
|
if ((Player::TeamIdForRace(race) == Player::TeamIdForRace(pPlayer->getRace())) || !limitrace)
|
||||||
Guids.push_back(result1->Fetch()[0].Get<uint32>());
|
Guids.push_back(fields[0].Get<uint32>());
|
||||||
|
|
||||||
} while (result1->NextRow());
|
} while (result1->NextRow());
|
||||||
|
|
||||||
@@ -59,17 +79,26 @@ public:
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Achievement.push_back(result2->Fetch()[0].Get<uint32>());
|
uint32 achievementID = result2->Fetch()[0].Get<uint32>();
|
||||||
|
// Only add if not in the exclusion list
|
||||||
|
if (excludedAchievements.find(achievementID) == excludedAchievements.end())
|
||||||
|
{
|
||||||
|
Achievement.push_back(achievementID);
|
||||||
|
}
|
||||||
|
|
||||||
} while (result2->NextRow());
|
} while (result2->NextRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& i : Achievement)
|
for (auto& i : Achievement)
|
||||||
{
|
{
|
||||||
auto sAchievement = sAchievementStore.LookupEntry(i);
|
auto sAchievement = sAchievementStore.LookupEntry(i);
|
||||||
|
if (sAchievement)
|
||||||
|
{
|
||||||
AddAchievements(pPlayer, sAchievement->ID);
|
AddAchievements(pPlayer, sAchievement->ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AddAchievements(Player* player, uint32 AchievementID)
|
void AddAchievements(Player* player, uint32 AchievementID)
|
||||||
{
|
{
|
||||||
@@ -79,9 +108,15 @@ public:
|
|||||||
setlevel = minlevel;
|
setlevel = minlevel;
|
||||||
|
|
||||||
if (player->GetLevel() >= setlevel)
|
if (player->GetLevel() >= setlevel)
|
||||||
|
{
|
||||||
|
// Check exclusion before granting achievement
|
||||||
|
if (excludedAchievements.find(AchievementID) == excludedAchievements.end())
|
||||||
|
{
|
||||||
player->CompletedAchievement(sAchievementStore.LookupEntry(AchievementID));
|
player->CompletedAchievement(sAchievementStore.LookupEntry(AchievementID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddAccountAchievementsScripts()
|
void AddAccountAchievementsScripts()
|
||||||
|
|||||||
Reference in New Issue
Block a user