Last active
December 1, 2018 22:08
-
-
Save bumbummen99/5cdd27c7122754c07b73d11732dd8a3f to your computer and use it in GitHub Desktop.
TrinityCore 3.3.5a AccountMounts. Kinda Blizzlike account mount sharing. Includes optional faction lock and riding skill sharing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Player.h" | |
class AccountMounts : public PlayerScript | |
{ | |
static const bool limitrace = true; //Disable share mounts between faction | |
static const bool limitlevel = true; //Disable share riding with level 1 characters | |
static const uint8 minRidingLevel = 20; //Minimum level for shared riding skill | |
public: | |
AccountMounts() : PlayerScript("AccountMounts") { } | |
void OnLogin(Player* pPlayer, bool firstLogin) | |
{ | |
learnAccountMounts(pPlayer); | |
} | |
void OnLevelChanged(Player* pPlayer, uint8 oldLevel) | |
{ | |
uint8 currentLevel = pPlayer->getLevel(); | |
if (currentLevel >= minRidingLevel) | |
learnAccountMounts(pPlayer); | |
} | |
void learnAccountMounts(Player* pPlayer) | |
{ | |
std::vector<uint32> Guids; | |
QueryResult result1 = CharacterDatabase.PQuery("SELECT guid, race FROM characters WHERE account = %u", pPlayer->GetSession()->GetAccountId()); | |
if (!result1) | |
return; | |
do | |
{ | |
Field* fields = result1->Fetch(); | |
uint32 guid = fields[0].GetUInt32(); | |
uint32 race = fields[1].GetUInt8(); | |
if ((Player::TeamForRace(race) == Player::TeamForRace(pPlayer->getRace())) || !limitrace) | |
Guids.push_back(result1->Fetch()[0].GetUInt32()); | |
} while (result1->NextRow()); | |
std::vector<uint32> Spells; | |
for (auto& i : Guids) | |
{ | |
QueryResult result2 = CharacterDatabase.PQuery("SELECT spell FROM character_spell WHERE guid = %u", i); | |
if (!result2) | |
continue; | |
do { | |
Spells.push_back(result2->Fetch()[0].GetUInt32()); | |
} while (result2->NextRow()); | |
} | |
for (auto& i : Spells) | |
{ | |
auto sSpell = sSpellStore.LookupEntry(i); | |
if (sSpell->Effect[0] == SPELL_EFFECT_APPLY_AURA && sSpell->EffectApplyAuraName[0] == SPELL_AURA_MOUNTED) | |
{ | |
if (limitlevel) { | |
QueryResult result3 = WorldDatabase.PQuery("SELECT RequiredLevel FROM item_template WHERE class = 15 AND subclass = 5 AND spellid_2 = %u", i); | |
if (!result3) | |
continue; | |
/* Required Level for the item granting the spell */ | |
uint8 requiredLevel = result3->Fetch()[0].GetUInt8(); | |
if (pPlayer->getLevel() < requiredLevel) | |
continue; | |
} | |
pPlayer->LearnSpell(sSpell->Id, false); | |
} | |
} | |
} | |
}; | |
void Add_AccontMounts() | |
{ | |
new AccountMounts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment