Skip to content

Commit

Permalink
Decent refactor, add option to charge for hide item, add option to us…
Browse files Browse the repository at this point in the history
…e vendor interface
  • Loading branch information
Ceikry committed Aug 18, 2024
1 parent 5d4e1b4 commit f5f5a0d
Show file tree
Hide file tree
Showing 4 changed files with 335 additions and 164 deletions.
14 changes: 14 additions & 0 deletions conf/transmog.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@
# If disabled, players must have an item in their bags to use as a transmogrification appearance source.
# Default: 1
#
# Transmogrification.UseVendorInterface
# Description: Enables/Disables the use of a fake vendor interface for item selection.
# If enabled, players can select items from a vendor menu, complete with ctrl-click previews.
# If disabled, players will use the gossip menu to select items and will not have access to previews.
# Default: 0
#
# Transmogrification.AllowHiddenTransmog
# Description: Enables/Disables the hiding of equipment through transmog
# If enabled, players can select an "invisible" appearance for items at the transmog vendor
# Default: 1
#
# Transmogrification.HiddenTransmogIsFree
# Description: Enables/Disables free hiding of items through the transmog system.
# If enabled, players can hide pieces of equipment for free.
# If disabled, players will be charged the standard transmog price (affected by all modifiers) to hide an item.
# Default: 1
#
# Transmogrification.TrackUnusableItems
# Description: If enabled, appearances are collected even for items that are not suitable for transmogrification.
# This allows these appearances to be used later if the configuration is changed.
Expand Down Expand Up @@ -62,7 +74,9 @@

Transmogrification.Enable = 1
Transmogrification.UseCollectionSystem = 1
Transmogrification.UseVendorInterface = 0
Transmogrification.AllowHiddenTransmog = 1
Transmogrification.HiddenTransmogIsFree = 1
Transmogrification.TrackUnusableItems = 1
Transmogrification.RetroActiveAppearances = 1
Transmogrification.ResetRetroActiveAppearancesFlag = 0
Expand Down
28 changes: 26 additions & 2 deletions src/Transmogrification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,22 @@ TransmogAcoreStrings Transmogrification::Transmogrify(Player* player, Item* item

if (hidden_transmog)
{
cost = GetSpecialPrice(itemTransmogrified->GetTemplate());
cost *= ScaledCostModifier;
cost += CopperCost;

if (!HiddenTransmogIsFree && cost)
{
if (cost < 0)
LOG_DEBUG("module", "Transmogrification::Transmogrify - {} ({}) transmogrification invalid cost (non negative, amount {}). Transmogrified {} with {}",
player->GetName(), player->GetGUID().ToString(), -cost, itemTransmogrified->GetEntry(), itemTransmogrifier->GetEntry());
else
{
if (!player->HasEnoughMoney(cost))
return LANG_ERR_TRANSMOG_NOT_ENOUGH_MONEY;
player->ModifyMoney(-cost, false);
}
}
SetFakeEntry(player, HIDDEN_ITEM_ID, slot, itemTransmogrified); // newEntry
return LANG_ERR_TRANSMOG_OK;
}
Expand Down Expand Up @@ -1124,7 +1140,9 @@ void Transmogrification::LoadConfig(bool reload)
IgnoreReqEvent = sConfigMgr->GetOption<bool>("Transmogrification.IgnoreReqEvent", false);
IgnoreReqStats = sConfigMgr->GetOption<bool>("Transmogrification.IgnoreReqStats", false);
UseCollectionSystem = sConfigMgr->GetOption<bool>("Transmogrification.UseCollectionSystem", true);
UseVendorInterface = sConfigMgr->GetOption<bool>("Transmogrification.UseVendorInterface", false);
AllowHiddenTransmog = sConfigMgr->GetOption<bool>("Transmogrification.AllowHiddenTransmog", true);
HiddenTransmogIsFree = sConfigMgr->GetOption<bool>("Transmogrification.HiddenTransmogIsFree", true);
TrackUnusableItems = sConfigMgr->GetOption<bool>("Transmogrification.TrackUnusableItems", true);
RetroActiveAppearances = sConfigMgr->GetOption<bool>("Transmogrification.RetroActiveAppearances", true);
ResetRetroActiveAppearances = sConfigMgr->GetOption<bool>("Transmogrification.ResetRetroActiveAppearancesFlag", false);
Expand Down Expand Up @@ -1280,12 +1298,18 @@ bool Transmogrification::GetUseCollectionSystem() const
{
return UseCollectionSystem;
};

bool Transmogrification::GetUseVendorInterface() const
{
return UseVendorInterface;
}
bool Transmogrification::GetAllowHiddenTransmog() const
{
return AllowHiddenTransmog;
}

bool Transmogrification::GetHiddenTransmogIsFree() const
{
return HiddenTransmogIsFree;
}
bool Transmogrification::GetAllowTradeable() const
{
return AllowTradeable;
Expand Down
11 changes: 9 additions & 2 deletions src/Transmogrification.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ class Transmogrification
typedef std::unordered_map<uint32, std::vector<uint32>> collectionCacheMap;
typedef std::unordered_map<uint32, std::string> searchStringMap;
typedef std::unordered_map<uint32, std::vector<uint32>> transmogPlusData;
typedef std::unordered_map<ObjectGuid, uint8> selectedSlotMap;

transmogPlusData plusDataMap;
transmogMap entryMap; // entryMap[pGUID][iGUID] = entry
transmogData dataMap; // dataMap[iGUID] = pGUID
collectionCacheMap collectionCache;
selectedSlotMap selectionCache;

#ifdef PRESETS
bool EnableSetInfo;
Expand Down Expand Up @@ -184,7 +187,11 @@ class Transmogrification
bool IgnoreReqStats;

bool UseCollectionSystem;
bool UseVendorInterface;

bool AllowHiddenTransmog;
bool HiddenTransmogIsFree;

bool TrackUnusableItems;
bool RetroActiveAppearances;
bool ResetRetroActiveAppearances;
Expand Down Expand Up @@ -241,7 +248,9 @@ class Transmogrification
bool GetAllowTradeable() const;

bool GetUseCollectionSystem() const;
bool GetUseVendorInterface() const;
bool GetAllowHiddenTransmog() const;
bool GetHiddenTransmogIsFree() const;
bool GetTrackUnusableItems() const;
bool EnableRetroActiveAppearances() const;
bool EnableResetRetroActiveAppearances() const;
Expand All @@ -262,9 +271,7 @@ class Transmogrification
bool IsTransmogPlusEnabled;
[[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); }

};
#define sTransmogrification Transmogrification::instance()

Expand Down
Loading

0 comments on commit f5f5a0d

Please sign in to comment.