Skip to content

Commit

Permalink
Sync things between characters on same account
Browse files Browse the repository at this point in the history
  • Loading branch information
conan513 committed Oct 5, 2024
1 parent 9150fed commit 563267b
Show file tree
Hide file tree
Showing 28 changed files with 2,602 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/mod-account-achievements/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
1 change: 1 addition & 0 deletions modules/mod-account-achievements/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reset.sh
650 changes: 650 additions & 0 deletions modules/mod-account-achievements/LICENSE.md

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions modules/mod-account-achievements/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore
## mod-account-achievements
- Latest build status with azerothcore: [![Build Status](https://github.com/azerothcore/mod-account-achievements/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-account-achievements)

# Account Achievements module for AzerothCore.

Share your characters achievements to all on your account.

# Original script:
http://www.ac-web.org/forums/showthread.php?223586-Account-Bound-Achievements
13 changes: 13 additions & 0 deletions modules/mod-account-achievements/conf/mod_achievements.conf.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[worldserver]

###################################################################################################
# Account Achievements module
###################################################################################################

# Enable the module? (1: true | 0: false)

Account.Achievements.Enable = 1

# Announce the module when the player logs in?

Account.Achievements.Announce = 1
Empty file.
6 changes: 6 additions & 0 deletions modules/mod-account-achievements/src/achievements_loader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void AddAccountAchievementsScripts();

void Addmod_account_achievementsScripts()
{
AddAccountAchievementsScripts();
}
90 changes: 90 additions & 0 deletions modules/mod-account-achievements/src/mod_achievements.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
<--------------------------------------------------------------------------->
- Developer(s): Lille Carl, Grim/Render
- Complete: %100
- ScriptName: 'AccountAchievements'
- Comment: Tested and Works.
- Orginial Creator: Lille Carl
- Edited: Render/Grim
<--------------------------------------------------------------------------->
*/

#include "Config.h"
#include "ScriptMgr.h"
#include "Chat.h"
#include "Player.h"

class AccountAchievements : public PlayerScript
{
static const bool limitrace = true; // This set to true will only achievements from chars on the same team, do what you want. NOT RECOMMANDED TO BE CHANGED!!!
static const bool limitlevel = false; // This checks the player's level and will only add achievements to players of that level.
int minlevel = 80; // It's set to players of the level 60. Requires limitlevel to be set to true.
int setlevel = 1; // Dont Change

public:
AccountAchievements() : PlayerScript("AccountAchievements") { }

void OnLogin(Player* pPlayer)
{
if (sConfigMgr->GetOption<bool>("Account.Achievements.Enable", true))
{
if (sConfigMgr->GetOption<bool>("Account.Achievements.Announce", true))
{
ChatHandler(pPlayer->GetSession()).SendSysMessage("This server is running the |cff4CFF00AccountAchievements |rmodule.");
}

std::vector<uint32> Guids;
QueryResult result1 = CharacterDatabase.Query("SELECT guid, race FROM characters WHERE account = {}", pPlayer->GetSession()->GetAccountId());
if (!result1)
return;

do
{
Field* fields = result1->Fetch();

uint32 race = fields[1].Get<uint8>();

if ((Player::TeamIdForRace(race) == Player::TeamIdForRace(pPlayer->getRace())) || !limitrace)
Guids.push_back(result1->Fetch()[0].Get<uint32>());

} while (result1->NextRow());

std::vector<uint32> Achievement;

for (auto& i : Guids)
{
QueryResult result2 = CharacterDatabase.Query("SELECT achievement FROM character_achievement WHERE guid = {}", i);
if (!result2)
continue;

do
{
Achievement.push_back(result2->Fetch()[0].Get<uint32>());
} while (result2->NextRow());
}

for (auto& i : Achievement)
{
auto sAchievement = sAchievementStore.LookupEntry(i);
AddAchievements(pPlayer, sAchievement->ID);
}
}
}

void AddAchievements(Player* player, uint32 AchievementID)
{
if (sConfigMgr->GetOption<bool>("Account.Achievements.Enable", true))
{
if (limitlevel)
setlevel = minlevel;

if (player->GetLevel() >= setlevel)
player->CompletedAchievement(sAchievementStore.LookupEntry(AchievementID));
}
}
};

void AddAccountAchievementsScripts()
{
new AccountAchievements;
}
Loading

0 comments on commit 563267b

Please sign in to comment.