mirror of
https://github.com/azerothcore/mod-transmog
synced 2025-11-29 22:48:30 +08:00
feat: Implement optional transmogs (#62)
* feat: Implement optional transmogs * logic * Enable disabling transmog * Update transmog.conf.dist * Hide the npc if transmog is off
This commit is contained in:
@@ -665,6 +665,8 @@ void Transmogrification::LoadConfig(bool reload)
|
||||
IgnoreReqEvent = sConfigMgr->GetOption<bool>("Transmogrification.IgnoreReqEvent", false);
|
||||
IgnoreReqStats = sConfigMgr->GetOption<bool>("Transmogrification.IgnoreReqStats", false);
|
||||
|
||||
IsTransmogEnabled = sConfigMgr->GetOption<bool>("Transmogrification.Enable", true);
|
||||
|
||||
if (!sObjectMgr->GetItemTemplate(TokenEntry))
|
||||
{
|
||||
//sLog->outError(LOG_FILTER_SERVER_LOADING, "Transmogrification.TokenEntry (%u) does not exist. Using default.", TokenEntry);
|
||||
@@ -732,3 +734,8 @@ bool Transmogrification::GetAllowMixedWeaponTypes() const
|
||||
{
|
||||
return AllowMixedWeaponTypes;
|
||||
};
|
||||
|
||||
bool Transmogrification::IsEnabled() const
|
||||
{
|
||||
return IsTransmogEnabled;
|
||||
};
|
||||
|
||||
@@ -17,6 +17,11 @@ class Player;
|
||||
class WorldSession;
|
||||
struct ItemTemplate;
|
||||
|
||||
enum TransmogSettings
|
||||
{
|
||||
SETTING_HIDE_TRANSMOG = 0,
|
||||
};
|
||||
|
||||
enum TransmogAcoreStrings // Language.h might have same entries, appears when executing SQL, change if needed
|
||||
{
|
||||
LANG_ERR_TRANSMOG_OK = 11100, // change this
|
||||
@@ -34,6 +39,8 @@ enum TransmogAcoreStrings // Language.h might have same entries, appears when ex
|
||||
#ifdef PRESETS
|
||||
LANG_PRESET_ERR_INVALID_NAME,
|
||||
#endif
|
||||
LANG_CMD_TRANSMOG_SHOW = 11111,
|
||||
LANG_CMD_TRANSMOG_HIDE = 11112,
|
||||
};
|
||||
|
||||
class Transmogrification
|
||||
@@ -111,6 +118,8 @@ public:
|
||||
bool IgnoreReqEvent;
|
||||
bool IgnoreReqStats;
|
||||
|
||||
bool IsTransmogEnabled;
|
||||
|
||||
bool IsAllowed(uint32 entry) const;
|
||||
bool IsNotAllowed(uint32 entry) const;
|
||||
bool IsAllowedQuality(uint32 quality) const;
|
||||
@@ -151,6 +160,8 @@ public:
|
||||
uint32 GetTransmogNpcText() const;
|
||||
bool GetEnableSetInfo() const;
|
||||
uint32 GetSetNpcText() const;
|
||||
|
||||
[[nodiscard]] bool IsEnabled() const;
|
||||
};
|
||||
#define sTransmogrification Transmogrification::instance()
|
||||
|
||||
|
||||
64
src/cs_transmog.cpp
Normal file
64
src/cs_transmog.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by the
|
||||
* Free Software Foundation; either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Chat.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Transmogrification.h"
|
||||
|
||||
using namespace Acore::ChatCommands;
|
||||
|
||||
class transmog_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
transmog_commandscript() : CommandScript("transmog_commandscript") { }
|
||||
|
||||
ChatCommandTable GetCommands() const override
|
||||
{
|
||||
static ChatCommandTable commandTable =
|
||||
{
|
||||
{ "transmog", HandleDisableTransMogVisual, SEC_PLAYER, Console::No },
|
||||
};
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleDisableTransMogVisual(ChatHandler* handler, bool hide)
|
||||
{
|
||||
Player* player = handler->GetPlayer();
|
||||
|
||||
if (hide)
|
||||
{
|
||||
player->UpdatePlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG, 0);
|
||||
handler->SendSysMessage(LANG_CMD_TRANSMOG_SHOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
player->UpdatePlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG, 1);
|
||||
handler->SendSysMessage(LANG_CMD_TRANSMOG_HIDE);
|
||||
}
|
||||
|
||||
player->UpdateObjectVisibility();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_transmog_commandscript()
|
||||
{
|
||||
new transmog_commandscript();
|
||||
}
|
||||
@@ -5,9 +5,11 @@
|
||||
|
||||
// From SC
|
||||
void AddSC_Transmog();
|
||||
void AddSC_transmog_commandscript();
|
||||
|
||||
// Add all
|
||||
void Addmod_transmogScripts()
|
||||
{
|
||||
AddSC_Transmog();
|
||||
AddSC_transmog_commandscript();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ Cant transmogrify rediculus items // Foereaper: would be fun to stab people with
|
||||
*/
|
||||
|
||||
#include "Transmogrification.h"
|
||||
#include "ScriptedCreature.h"
|
||||
|
||||
#define sT sTransmogrification
|
||||
#define GTS session->GetAcoreString // dropped translation support, no one using?
|
||||
|
||||
@@ -29,6 +31,22 @@ class npc_transmogrifier : public CreatureScript
|
||||
public:
|
||||
npc_transmogrifier() : CreatureScript("npc_transmogrifier") { }
|
||||
|
||||
struct npc_transmogrifierAI : ScriptedAI
|
||||
{
|
||||
npc_transmogrifierAI(Creature* creature) : ScriptedAI(creature) { };
|
||||
|
||||
bool CanBeSeen(Player const* player) override
|
||||
{
|
||||
Player* target = ObjectAccessor::FindConnectedPlayer(player->GetGUID());
|
||||
return !sTransmogrification->IsEnabled() && !target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value;
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new npc_transmogrifierAI(creature);
|
||||
}
|
||||
|
||||
bool OnGossipHello(Player* player, Creature* creature)
|
||||
{
|
||||
WorldSession* session = player->GetSession();
|
||||
@@ -373,7 +391,9 @@ public:
|
||||
return;
|
||||
|
||||
if (uint32 entry = sT->GetFakeEntry(item->GetGUID()))
|
||||
{
|
||||
player->SetUInt32Value(PLAYER_VISIBLE_ITEM_1_ENTRYID + (slot * 2), entry);
|
||||
}
|
||||
}
|
||||
|
||||
void OnAfterMoveItemFromInventory(Player* /*player*/, Item* it, uint8 /*bag*/, uint8 /*slot*/, bool /*update*/)
|
||||
@@ -472,9 +492,33 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class unit_transmog_script : public UnitScript
|
||||
{
|
||||
public:
|
||||
unit_transmog_script() : UnitScript("unit_transmog_script") { }
|
||||
|
||||
bool OnBuildValuesUpdate(Unit const* unit, uint8 /*updateType*/, ByteBuffer& fieldBuffer, Player* target, uint16 index) override
|
||||
{
|
||||
if (unit->IsPlayer() && index >= PLAYER_VISIBLE_ITEM_1_ENTRYID && index <= PLAYER_VISIBLE_ITEM_19_ENTRYID && (index & 1))
|
||||
{
|
||||
if (Item* item = unit->ToPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, ((index - PLAYER_VISIBLE_ITEM_1_ENTRYID) / 2U)))
|
||||
{
|
||||
if (!sTransmogrification->IsEnabled() || target->GetPlayerSetting("mod-transmog", SETTING_HIDE_TRANSMOG).value)
|
||||
{
|
||||
fieldBuffer << item->GetEntry();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_Transmog()
|
||||
{
|
||||
new global_transmog_script();
|
||||
new unit_transmog_script();
|
||||
new npc_transmogrifier();
|
||||
new PS_Transmogrification();
|
||||
new WS_Transmogrification();
|
||||
|
||||
Reference in New Issue
Block a user