mirror of
https://github.com/azerothcore/mod-transmog
synced 2025-11-29 22:48:30 +08:00
feat: transmog plus pet (#141)
* feat: transmog plus pet * chore: update code style based on standard, restore sql values * refactor: improve code quality, remove unnecessary sql query
This commit is contained in:
@@ -270,13 +270,19 @@ Transmogrification.SetCopperCost = 0
|
|||||||
#
|
#
|
||||||
# Transmogrification.MembershipLevelsLegendary
|
# Transmogrification.MembershipLevelsLegendary
|
||||||
# Description: Membership levels ID from acore_cms_subscriptions that define the eligibility for legendary items
|
# Description: Membership levels ID from acore_cms_subscriptions that define the eligibility for legendary items
|
||||||
# Example: Transmogrification.MembershipLevels = "1,2,3"
|
# Example: Transmogrification.MembershipLevelsLegendary = "1,2,3"
|
||||||
|
# Default: ""
|
||||||
|
#
|
||||||
|
# Transmogrification.MembershipLevelsPet
|
||||||
|
# Description: Membership levels ID from acore_cms_subscriptions that define the eligibility for transmog pet
|
||||||
|
# Example: Transmogrification.MembershipLevelsPet = "1,2,3"
|
||||||
# Default: ""
|
# Default: ""
|
||||||
#
|
#
|
||||||
|
|
||||||
Transmogrification.EnablePlus = 0
|
Transmogrification.EnablePlus = 0
|
||||||
Transmogrification.MembershipLevels = ""
|
Transmogrification.MembershipLevels = ""
|
||||||
Transmogrification.MembershipLevelsLegendary = ""
|
Transmogrification.MembershipLevelsLegendary = ""
|
||||||
|
Transmogrification.MembershipLevelsPet = ""
|
||||||
|
|
||||||
#
|
#
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
|
|||||||
@@ -722,7 +722,7 @@ bool Transmogrification::SuitableForTransmogrification(Player* player, ItemTempl
|
|||||||
if (IsAllowed(proto->ItemId))
|
if (IsAllowed(proto->ItemId))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!IsItemTransmogrifiable(proto, player->GetGUID().GetCounter()))
|
if (!IsItemTransmogrifiable(proto, player->GetGUID()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//[AZTH] Yehonal
|
//[AZTH] Yehonal
|
||||||
@@ -782,10 +782,10 @@ bool Transmogrification::SuitableForTransmogrification(ObjectGuid guid, ItemTemp
|
|||||||
if (IsAllowed(proto->ItemId))
|
if (IsAllowed(proto->ItemId))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
auto playerGuid = guid.GetCounter();
|
if (!IsItemTransmogrifiable(proto, guid))
|
||||||
if (!IsItemTransmogrifiable(proto, playerGuid))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto playerGuid = guid.GetCounter();
|
||||||
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(guid);
|
||||||
if (!playerData)
|
if (!playerData)
|
||||||
return false;
|
return false;
|
||||||
@@ -855,7 +855,7 @@ bool Transmogrification::SuitableForTransmogrification(ObjectGuid guid, ItemTemp
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transmogrification::IsItemTransmogrifiable(ItemTemplate const* proto, ObjectGuid::LowType playerGuid) const
|
bool Transmogrification::IsItemTransmogrifiable(ItemTemplate const* proto, ObjectGuid const &playerGuid) const
|
||||||
{
|
{
|
||||||
if (!proto)
|
if (!proto)
|
||||||
return false;
|
return false;
|
||||||
@@ -919,7 +919,7 @@ bool Transmogrification::IsNotAllowed(uint32 entry) const
|
|||||||
return NotAllowed.find(entry) != NotAllowed.end();
|
return NotAllowed.find(entry) != NotAllowed.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transmogrification::IsAllowedQuality(uint32 quality, ObjectGuid::LowType playerGuid) const
|
bool Transmogrification::IsAllowedQuality(uint32 quality, ObjectGuid const &playerGuid) const
|
||||||
{
|
{
|
||||||
switch (quality)
|
switch (quality)
|
||||||
{
|
{
|
||||||
@@ -1053,6 +1053,11 @@ void Transmogrification::LoadConfig(bool reload)
|
|||||||
for (auto& itr : Acore::Tokenize(stringMembershipIds, ',', false)) {
|
for (auto& itr : Acore::Tokenize(stringMembershipIds, ',', false)) {
|
||||||
MembershipIdsLegendary.push_back(Acore::StringTo<uint32>(itr).value());
|
MembershipIdsLegendary.push_back(Acore::StringTo<uint32>(itr).value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stringMembershipIds = sConfigMgr->GetOption<std::string>("Transmogrification.MembershipLevelsPet", "");
|
||||||
|
for (auto& itr : Acore::Tokenize(stringMembershipIds, ',', false)) {
|
||||||
|
MembershipIdsPet.push_back(Acore::StringTo<uint32>(itr).value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, CharacterDatabaseTransaction* trans /*= nullptr*/)
|
void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, CharacterDatabaseTransaction* trans /*= nullptr*/)
|
||||||
@@ -1071,68 +1076,77 @@ void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, Chara
|
|||||||
CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE GUID = {}", itemGUID.GetCounter());
|
CharacterDatabase.Execute("DELETE FROM custom_transmogrification WHERE GUID = {}", itemGUID.GetCounter());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transmogrification::isPlusWhiteGreyEligible(ObjectGuid::LowType playerGuid) const {
|
uint32 Transmogrification::getPlayerMembershipLevel(ObjectGuid const & playerGuid) const {
|
||||||
if (!IsTransmogPlusEnabled) {
|
CharacterCacheEntry const* playerData = sCharacterCache->GetCharacterCacheByGuid(playerGuid);
|
||||||
return false;
|
if (!playerData)
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
if (MembershipIds.size() == 0) {
|
uint32 accountId = playerData->AccountId;
|
||||||
|
QueryResult resultAcc = LoginDatabase.Query("SELECT `membership_level` FROM `acore_cms_subscriptions` WHERE `account_name` COLLATE utf8mb4_general_ci = (SELECT `username` FROM `account` WHERE `id` = {})", accountId);
|
||||||
|
|
||||||
|
if (resultAcc)
|
||||||
|
return (*resultAcc)[0].Get<uint32>();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Transmogrification::isPlusWhiteGreyEligible(ObjectGuid const &playerGuid) const {
|
||||||
|
if (!IsTransmogPlusEnabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (MembershipIds.size() == 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
const auto membershipLevel = getPlayerMembershipLevel(playerGuid);
|
const auto membershipLevel = getPlayerMembershipLevel(playerGuid);
|
||||||
if (membershipLevel == 0) {
|
if (membershipLevel == 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& itr : MembershipIds)
|
for (const auto& itr : MembershipIds)
|
||||||
{
|
{
|
||||||
if (itr == membershipLevel) {
|
if (itr == membershipLevel)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Transmogrification::isPlusLegendaryEligible(ObjectGuid::LowType playerGuid) const {
|
bool Transmogrification::isPlusLegendaryEligible(ObjectGuid const & playerGuid) const {
|
||||||
if (!IsTransmogPlusEnabled) {
|
if (!IsTransmogPlusEnabled)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (MembershipIdsLegendary.size() == 0) {
|
if (MembershipIdsLegendary.size() == 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
const auto membershipLevel = getPlayerMembershipLevel(playerGuid);
|
const auto membershipLevel = getPlayerMembershipLevel(playerGuid);
|
||||||
if (membershipLevel == 0) {
|
if (membershipLevel == 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& itr : MembershipIdsLegendary)
|
for (const auto& itr : MembershipIdsLegendary)
|
||||||
{
|
{
|
||||||
if (itr == membershipLevel) {
|
if (itr == membershipLevel)
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Transmogrification::getPlayerMembershipLevel(ObjectGuid::LowType playerGuid) const {
|
|
||||||
QueryResult result = CharacterDatabase.Query("SELECT `account` FROM `characters` WHERE `guid` = {}", playerGuid);
|
|
||||||
|
|
||||||
if (result) {
|
bool Transmogrification::isTransmogPlusPetEligible(ObjectGuid const & playerGuid) const {
|
||||||
uint32 accountId = (*result)[0].Get<uint32>();
|
if (MembershipIdsPet.size() == 0)
|
||||||
QueryResult resultAcc = LoginDatabase.Query("SELECT `membership_level` FROM `acore_cms_subscriptions` WHERE `account_name` COLLATE utf8mb4_general_ci = (SELECT `username` FROM `account` WHERE `id` = {})", accountId);
|
return false;
|
||||||
|
|
||||||
if (resultAcc) {
|
const auto membershipLevel = getPlayerMembershipLevel(playerGuid);
|
||||||
return (*resultAcc)[0].Get<uint32>();
|
if (membershipLevel == 0)
|
||||||
}
|
return false;
|
||||||
|
|
||||||
|
for (const auto& itr : MembershipIdsPet)
|
||||||
|
{
|
||||||
|
if (itr == membershipLevel)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transmogrification::GetEnableTransmogInfo() const
|
bool Transmogrification::GetEnableTransmogInfo() const
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ public:
|
|||||||
|
|
||||||
bool IsAllowed(uint32 entry) const;
|
bool IsAllowed(uint32 entry) const;
|
||||||
bool IsNotAllowed(uint32 entry) const;
|
bool IsNotAllowed(uint32 entry) const;
|
||||||
bool IsAllowedQuality(uint32 quality, ObjectGuid::LowType playerGuid) const;
|
bool IsAllowedQuality(uint32 quality, ObjectGuid const & playerGuid) const;
|
||||||
bool IsRangedWeapon(uint32 Class, uint32 SubClass) const;
|
bool IsRangedWeapon(uint32 Class, uint32 SubClass) const;
|
||||||
bool CanNeverTransmog(ItemTemplate const* itemTemplate);
|
bool CanNeverTransmog(ItemTemplate const* itemTemplate);
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ public:
|
|||||||
bool CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* destination, ItemTemplate const* source) const;
|
bool CanTransmogrifyItemWithItem(Player* player, ItemTemplate const* destination, ItemTemplate const* source) const;
|
||||||
bool SuitableForTransmogrification(Player* player, ItemTemplate const* proto) const;
|
bool SuitableForTransmogrification(Player* player, ItemTemplate const* proto) const;
|
||||||
bool SuitableForTransmogrification(ObjectGuid guid, ItemTemplate const* proto) const;
|
bool SuitableForTransmogrification(ObjectGuid guid, ItemTemplate const* proto) const;
|
||||||
bool IsItemTransmogrifiable(ItemTemplate const* proto, ObjectGuid::LowType playerGuid) const;
|
bool IsItemTransmogrifiable(ItemTemplate const* proto, ObjectGuid const &playerGuid) const;
|
||||||
uint32 GetSpecialPrice(ItemTemplate const* proto) const;
|
uint32 GetSpecialPrice(ItemTemplate const* proto) const;
|
||||||
|
|
||||||
void DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, CharacterDatabaseTransaction* trans = nullptr);
|
void DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, CharacterDatabaseTransaction* trans = nullptr);
|
||||||
@@ -216,9 +216,12 @@ public:
|
|||||||
bool IsTransmogPlusEnabled;
|
bool IsTransmogPlusEnabled;
|
||||||
std::vector<uint32> MembershipIds;
|
std::vector<uint32> MembershipIds;
|
||||||
std::vector<uint32> MembershipIdsLegendary;
|
std::vector<uint32> MembershipIdsLegendary;
|
||||||
bool isPlusWhiteGreyEligible(ObjectGuid::LowType playerGuid) const;
|
std::vector<uint32> MembershipIdsPet;
|
||||||
bool isPlusLegendaryEligible(ObjectGuid::LowType playerGuid) const;
|
|
||||||
uint32 getPlayerMembershipLevel(ObjectGuid::LowType playerGuid) const;
|
uint32 getPlayerMembershipLevel(ObjectGuid const & playerGuid) const;
|
||||||
|
bool isPlusWhiteGreyEligible(ObjectGuid const & playerGuid) const;
|
||||||
|
bool isPlusLegendaryEligible(ObjectGuid const & playerGuid) const;
|
||||||
|
bool isTransmogPlusPetEligible(ObjectGuid const & playerGuid) const;
|
||||||
};
|
};
|
||||||
#define sTransmogrification Transmogrification::instance()
|
#define sTransmogrification Transmogrification::instance()
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
{ "add", addCollectionTable },
|
{ "add", addCollectionTable },
|
||||||
{ "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No },
|
{ "", HandleDisableTransMogVisual, SEC_PLAYER, Console::No },
|
||||||
{ "sync", HandleSyncTransMogCommand, SEC_PLAYER, Console::No },
|
{ "sync", HandleSyncTransMogCommand, SEC_PLAYER, Console::No },
|
||||||
{ "portable", HandleTransmogPortableCommand, SEC_MODERATOR, Console::No },
|
{ "portable", HandleTransmogPortableCommand, SEC_PLAYER, Console::No },
|
||||||
};
|
};
|
||||||
|
|
||||||
static ChatCommandTable commandTable =
|
static ChatCommandTable commandTable =
|
||||||
@@ -304,8 +304,21 @@ public:
|
|||||||
|
|
||||||
if (Player* player = PlayerIdentifier::FromSelf(handler)->GetConnectedPlayer())
|
if (Player* player = PlayerIdentifier::FromSelf(handler)->GetConnectedPlayer())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (sTransmogrification->IsTransmogPlusEnabled) {
|
||||||
|
if (sTransmogrification->isTransmogPlusPetEligible(player->GetGUID())) {
|
||||||
|
player->CastSpell((Unit*)nullptr, SPELL_SUMMON_ETHEREAL_WARPWEAVER, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player->GetSession()->GetSecurity() < SEC_MODERATOR) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
player->CastSpell((Unit*)nullptr, SPELL_SUMMON_ETHEREAL_WARPWEAVER, true);
|
player->CastSpell((Unit*)nullptr, SPELL_SUMMON_ETHEREAL_WARPWEAVER, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user