Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor Interface and Code Cleanup #166

Merged
merged 3 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions conf/transmog.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@
# 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.
# There are (optional) custom items available for Hide Item and Remove Transmog if data/sql/db-world/tasm_world_VendorItems.sql is imported.
# 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 +75,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
30 changes: 30 additions & 0 deletions data/sql/db-world/trasm_world_VendorItems.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
SET
@HideEntry = 57575,
@RemoveEntry = 57576,
@HideName = "Hide Equipped",
@RemoveName = "Clear Transmog";

DELETE FROM `item_template` WHERE `entry` = @HideEntry OR `entry` = @RemoveEntry;

INSERT INTO `item_template` (`entry`, `class`, `subclass`, `name`, `displayid`, `InventoryType`, `description`) VALUES
(@HideEntry, 15, 0, @HideName, 55112, 0, "Hide the item in this slot."),
(@RemoveEntry, 15, 0, @RemoveName, 8931, 0, "Remove active transmog for this item.");

DELETE FROM `item_template_locale` WHERE `ID` = @HideEntry OR `ID` = @RemoveEntry;
INSERT INTO `item_template_locale` (`ID`, `locale`, `Name`, `Description`) VALUES
(@HideEntry, "koKR", "장착된 아이템 숨기기", "이 슬롯의 아이템을 숨깁니다."),
(@RemoveEntry,"koKR", "변형 지우기", "이 아이템의 활성화된 변형을 제거합니다."),
(@HideEntry, "frFR", "Masquer l'équipement", "Masquer l'objet dans cet emplacement."),
(@RemoveEntry,"frFR", "Effacer transmog", "Supprimer la transmog active."),
(@HideEntry, "deDE", "Ausgerüstet verbergen", "Item in diesem Slot verbergen."),
(@RemoveEntry,"deDE", "Transmog zurücksetzen", "Aktive Transmogrifikation entfernen."),
(@HideEntry, "zhCN", "隐藏已装备", "隐藏此物品。"),
(@RemoveEntry,"zhCN", "清除幻化", "移除激活的幻化。"),
(@HideEntry, "zhTW", "隱藏已裝備", "隱藏此物品。"),
(@RemoveEntry,"zhTW", "清除幻化", "移除啟用的幻化。"),
(@HideEntry, "esES", "Ocultar equipado", "Ocultar el objeto en esta ranura."),
(@RemoveEntry,"esES", "Borrar transmog", "Eliminar la transmog activa."),
(@HideEntry, "esMX", "Ocultar equipado", "Ocultar el objeto en este espacio."),
(@RemoveEntry,"esMX", "Borrar transmog", "Eliminar la transmog activa."),
(@HideEntry, "ruRU", "Скрыть экипированное", "Скрыть предмет в слоте."),
(@RemoveEntry,"ruRU", "Очистить трансмог", "Удалить активный трансмог.");
33 changes: 30 additions & 3 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 @@ -680,6 +696,8 @@ bool Transmogrification::IsSubclassMismatchAllowed(Player *player, const ItemTem
{
return true;
}
if (sourceSub == ITEM_SUBCLASS_WEAPON_MISC)
return sourceType == targetType;
}
else if (targetClass == ITEM_CLASS_ARMOR)
{
Expand Down Expand Up @@ -764,7 +782,8 @@ bool Transmogrification::SuitableForTransmogrification(Player* player, ItemTempl
return false;

//[AZTH] Yehonal
if (proto->SubClass > 0 && player->GetSkillValue(proto->GetSkill()) == 0)
uint32 subclassSkill = proto->GetSkill();
if (proto->SubClass > 0 && subclassSkill && player->GetSkillValue(proto->GetSkill()) == 0)
{
if (proto->Class == ITEM_CLASS_ARMOR && !AllowMixedArmorTypes)
{
Expand Down Expand Up @@ -1124,7 +1143,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 +1301,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