Skip to content

Commit

Permalink
fix: Fix the transmog pet not working with the new vendor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyeriah committed Aug 26, 2024
1 parent af09880 commit ae7ead1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Transmogrification.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Transmogrification.h"
#include "ItemTemplate.h"
#include "DatabaseEnv.h"
#include "SpellMgr.h"
#include "Tokenize.h"

Transmogrification* Transmogrification::instance()
Expand Down Expand Up @@ -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*/)
Expand Down
8 changes: 6 additions & 2 deletions src/Transmogrification.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ enum PlusFeatures
PLUS_FEATURE_SKIP_LEVEL_REQ
};

const uint32 TMOG_VENDOR_CREATURE_ID = 190010;

class Transmogrification
{
public:
Expand Down Expand Up @@ -134,8 +136,6 @@ class Transmogrification
float SetCostModifier;
int32 SetCopperCost;

uint32 PetSpellId;

bool GetEnableSets() const;
uint8 GetMaxSets() const;
float GetSetCostModifier() const;
Expand Down Expand Up @@ -272,6 +272,10 @@ class Transmogrification
[[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()

Expand Down
9 changes: 6 additions & 3 deletions src/transmog_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1165,8 +1164,12 @@ class PS_Transmogrification : public PlayerScript
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)
Expand Down

0 comments on commit ae7ead1

Please sign in to comment.