fix: Fix the transmog pet not working with the new vendor interface (#169)

This commit is contained in:
Andrew
2024-08-26 00:52:50 -03:00
committed by GitHub
parent af0988099f
commit 190aed53bf
3 changed files with 16 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
#include "Transmogrification.h"
#include "ItemTemplate.h"
#include "DatabaseEnv.h"
#include "SpellMgr.h"
#include "Tokenize.h"
Transmogrification* Transmogrification::instance()
@@ -1188,6 +1189,9 @@ void Transmogrification::LoadConfig(bool reload)
}
PetSpellId = sConfigMgr->GetOption<uint32>("Transmogrification.PetSpellId", 2000100);
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(PetSpellId))
PetEntry = spellInfo->Effects[EFFECT_0].MiscValue;
}
void Transmogrification::DeleteFakeFromDB(ObjectGuid::LowType itemLowGuid, CharacterDatabaseTransaction* trans /*= nullptr*/)

View File

@@ -95,6 +95,8 @@ enum PlusFeatures
PLUS_FEATURE_SKIP_LEVEL_REQ
};
const uint32 TMOG_VENDOR_CREATURE_ID = 190010;
class Transmogrification
{
public:
@@ -134,8 +136,6 @@ public:
float SetCostModifier;
int32 SetCopperCost;
uint32 PetSpellId;
bool GetEnableSets() const;
uint8 GetMaxSets() const;
float GetSetCostModifier() const;
@@ -272,6 +272,10 @@ public:
[[nodiscard]] bool IsPlusFeatureEligible(ObjectGuid const& playerGuid, uint32 feature) const;
uint32 getPlayerMembershipLevel(ObjectGuid const & playerGuid) const;
[[nodiscard]] bool IgnoreLevelRequirement(ObjectGuid const& playerGuid) const { return IgnoreReqLevel || IsPlusFeatureEligible(playerGuid, PLUS_FEATURE_SKIP_LEVEL_REQ); }
uint32 PetSpellId;
uint32 PetEntry;
[[nodiscard]] bool IsTransmogVendor(uint32 entry) const { return entry == TMOG_VENDOR_CREATURE_ID || entry == PetEntry; };
};
#define sTransmogrification Transmogrification::instance()

View File

@@ -337,7 +337,6 @@ const uint32 FALLBACK_HIDE_ITEM_VENDOR_ID = 9172; //Invisibility potion
const uint32 FALLBACK_REMOVE_TMOG_VENDOR_ID = 1049; //Tablet of Purge
const uint32 CUSTOM_HIDE_ITEM_VENDOR_ID = 57575;//Custom Hide Item item
const uint32 CUSTOM_REMOVE_TMOG_VENDOR_ID = 57576;//Custom Remove Transmog item
const uint32 TMOG_VENDOR_CREATURE_ID = 190010;
std::string GetLocaleText(LocaleConstant locale, const std::string& titleType) {
auto textMapIt = textMaps.find(titleType);
@@ -1165,8 +1164,12 @@ public:
void OnBeforeBuyItemFromVendor(Player* player, ObjectGuid vendorguid, uint32 /*vendorslot*/, uint32& itemEntry, uint8 /*count*/, uint8 /*bag*/, uint8 /*slot*/) override
{
Creature* vendor = player->GetMap()->GetCreature(vendorguid);
if (!vendor) return;
if (vendor->GetEntry() != TMOG_VENDOR_CREATURE_ID) return;
if (!vendor)
return;
if (!sT->IsTransmogVendor(vendor->GetEntry()))
return;
uint8 slot = sT->selectionCache[player->GetGUID()];
if (itemEntry == CUSTOM_HIDE_ITEM_VENDOR_ID || itemEntry == FALLBACK_HIDE_ITEM_VENDOR_ID)