diff --git a/ElunaCreatureAI.h b/ElunaCreatureAI.h index d4d4aff098..897709e3f5 100644 --- a/ElunaCreatureAI.h +++ b/ElunaCreatureAI.h @@ -82,7 +82,11 @@ struct ElunaCreatureAI : CreatureAI if (!me->GetEluna()->UpdateAI(me, diff)) { #if defined TRINITY || AZEROTHCORE || VMANGOS +#ifdef RETAIL + if (!me->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC)) +#else if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)) +#endif ScriptedAI::UpdateAI(diff); #elif defined CMANGOS if (!me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)) diff --git a/ElunaIncludes.h b/ElunaIncludes.h index b8eb057262..5723fa6795 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -15,8 +15,10 @@ #include "CellImpl.h" #include "Chat.h" #include "Channel.h" +#ifndef RETAIL #include "DBCStores.h" -#if defined CATA && defined TRINITY +#endif +#if (defined CATA || defined RETAIL) && defined TRINITY #include "DB2Stores.h" #endif #include "GameEventMgr.h" @@ -141,7 +143,7 @@ #endif #endif -#if (defined(TRINITY) && defined(CATA)) +#if (defined CATA || defined RETAIL) && defined TRINITY typedef OpcodeServer OpcodesList; #elif !defined CLASSIC diff --git a/ElunaInstanceAI.h b/ElunaInstanceAI.h index a9fa3faf5f..eb228d20ad 100644 --- a/ElunaInstanceAI.h +++ b/ElunaInstanceAI.h @@ -84,10 +84,18 @@ class ElunaInstanceAI : public InstanceData * These are responsible for serializing/deserializing the instance's * data table to/from the core. */ +#if defined(TRINITY) && defined(RETAIL) + void Load(const char* data); +#else void Load(const char* data) override; +#endif #if defined TRINITY || AZEROTHCORE // Simply calls Save, since the functions are a bit different in name and data types on different cores +#if defined(TRINITY) && defined(RETAIL) + std::string GetSaveData() +#else std::string GetSaveData() override +#endif { return Save(); } diff --git a/ElunaUtility.cpp b/ElunaUtility.cpp index 142c0c34f3..2bbae8d9d4 100644 --- a/ElunaUtility.cpp +++ b/ElunaUtility.cpp @@ -10,7 +10,11 @@ #include "Object.h" #include "Unit.h" #include "GameObject.h" +#ifdef RETAIL +#include "DB2Stores.h" +#else #include "DBCStores.h" +#endif #else #include "World/World.h" #include "Entities/Object.h" @@ -101,12 +105,12 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u) { if (i_obj_fact) { -#if ((defined TRINITY || AZEROTHCORE || CMANGOS || VMANGOS) && !defined CATA) - if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1)) - return false; -#elif defined CATA && defined TRINITY +#if ((defined CATA || RETAIL) && defined TRINITY) if ((i_obj_fact->IsHostileTo(target->GetFactionTemplateEntry())) != (i_hostile == 1)) return false; +#elif ((defined TRINITY || AZEROTHCORE || CMANGOS || VMANGOS) && !defined CATA) + if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1)) + return false; #elif defined CATA && defined CMANGOS if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1)) return false; diff --git a/ElunaUtility.h b/ElunaUtility.h index 3dbd5ba632..46ea16f4e8 100644 --- a/ElunaUtility.h +++ b/ElunaUtility.h @@ -57,22 +57,21 @@ typedef QueryResult ElunaQuery; #define GET_GUID GetGUID #define HIGHGUID_PLAYER HighGuid::Player -#define HIGHGUID_UNIT HighGuid::Unit +#define HIGHGUID_UNIT HighGuid::Creature #define HIGHGUID_ITEM HighGuid::Item #define HIGHGUID_GAMEOBJECT HighGuid::GameObject #define HIGHGUID_PET HighGuid::Pet #define HIGHGUID_TRANSPORT HighGuid::Transport #define HIGHGUID_VEHICLE HighGuid::Vehicle -#define HIGHGUID_CONTAINER HighGuid::Container +//#define HIGHGUID_CONTAINER HighGuid::Container #define HIGHGUID_DYNAMICOBJECT HighGuid::DynamicObject #define HIGHGUID_CORPSE HighGuid::Corpse -#define HIGHGUID_MO_TRANSPORT HighGuid::Mo_Transport +#define HIGHGUID_MO_TRANSPORT HighGuid::Transport #define HIGHGUID_INSTANCE HighGuid::Instance -#define HIGHGUID_GROUP HighGuid::Group +//#define HIGHGUID_GROUP HighGuid::Group #endif #ifdef TRINITY -#ifdef WOTLK #include "fmt/printf.h" #define ELUNA_LOG_TC_FMT(TC_LOG_MACRO, ...) \ try { \ @@ -84,11 +83,6 @@ typedef QueryResult ElunaQuery; #define ELUNA_LOG_INFO(...) ELUNA_LOG_TC_FMT(TC_LOG_INFO, __VA_ARGS__); #define ELUNA_LOG_ERROR(...) ELUNA_LOG_TC_FMT(TC_LOG_ERROR, __VA_ARGS__); #define ELUNA_LOG_DEBUG(...) ELUNA_LOG_TC_FMT(TC_LOG_DEBUG, __VA_ARGS__); -#else -#define ELUNA_LOG_INFO(...) TC_LOG_INFO("eluna", __VA_ARGS__); -#define ELUNA_LOG_ERROR(...) TC_LOG_ERROR("eluna", __VA_ARGS__); -#define ELUNA_LOG_DEBUG(...) TC_LOG_DEBUG("eluna", __VA_ARGS__); -#endif #elif defined(AZEROTHCORE) #define ELUNA_LOG_INFO(...) LOG_INFO("eluna", __VA_ARGS__); #define ELUNA_LOG_ERROR(...) LOG_ERROR("eluna", __VA_ARGS__); diff --git a/LuaEngine.cpp b/LuaEngine.cpp index 733a3400c5..81ea2dea1e 100644 --- a/LuaEngine.cpp +++ b/LuaEngine.cpp @@ -16,6 +16,7 @@ #include "ElunaUtility.h" #include "ElunaCreatureAI.h" #include "ElunaInstanceAI.h" +#include extern "C" { @@ -786,12 +787,12 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc case Hooks::REGTYPE_PACKET: if (event_id < Hooks::PACKET_EVENT_COUNT) { - if (entry >= NUM_MSG_TYPES) + /*if (entry >= NUM_MSG_TYPES) { luaL_unref(L, LUA_REGISTRYINDEX, functionRef); luaL_error(L, "Couldn't find a creature with (ID: %d)!", entry); return 0; // Stack: (empty) - } + }*/ auto key = EntryKey((Hooks::PacketEvents)event_id, entry); bindingID = PacketEventBindings->Insert(key, functionRef, shots); @@ -972,13 +973,13 @@ int Eluna::Register(uint8 regtype, uint32 entry, ObjectGuid guid, uint32 instanc void Eluna::UpdateEluna(uint32 diff) { if (reload) -#ifdef TRINITY +#if defined TRINITY && defined WOTLK if(!GetQueryProcessor().HasPendingCallbacks()) #endif _ReloadEluna(); eventMgr->globalProcessor->Update(diff); -#ifdef TRINITY +#if defined TRINITY && defined WOTLK GetQueryProcessor().ProcessReadyCallbacks(); #endif } diff --git a/LuaEngine.h b/LuaEngine.h index f3d2ac64a9..9fbe1a6eef 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -410,7 +410,11 @@ class ELUNA_GAME_API Eluna void OnResurrect(Player* pPlayer); void OnQuestAbandon(Player* pPlayer, uint32 questId); void OnQuestStatusChanged(Player* pPlayer, uint32 questId, uint8 status); +#ifdef RETAIL + void OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 spellid); +#else void OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid); +#endif void OnSkillChange(Player* pPlayer, uint32 skillId, uint32 skillValue); void OnLearnSpell(Player* pPlayer, uint32 spellid); InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry); @@ -506,7 +510,7 @@ class ELUNA_GAME_API Eluna void OnFreeTalentPointsChanged(Player* pPlayer, uint32 newPoints); void OnTalentsReset(Player* pPlayer, bool noCost); void OnMoneyChanged(Player* pPlayer, int32& amount); -#ifdef CATA +#if defined CATA || defined RETAIL void OnMoneyChanged(Player* pPlayer, int64& amount); #endif void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim); @@ -552,24 +556,29 @@ class ELUNA_GAME_API Eluna void OnChange(Weather* weather, uint32 zone, WeatherState state, float grade); /* Auction House */ - void OnAdd(AuctionHouseObject* ah, AuctionEntry* entry); - void OnRemove(AuctionHouseObject* ah, AuctionEntry* entry); - void OnSuccessful(AuctionHouseObject* ah, AuctionEntry* entry); - void OnExpire(AuctionHouseObject* ah, AuctionEntry* entry); + //void OnAdd(AuctionHouseObject* ah, AuctionEntry* entry); + //void OnAdd(AuctionHouseObject* ah, AuctionPosting* entry); + //void OnRemove(AuctionHouseObject* ah, AuctionEntry* entry); + //void OnSuccessful(AuctionHouseObject* ah, AuctionEntry* entry); + //void OnExpire(AuctionHouseObject* ah, AuctionEntry* entry); /* Guild */ void OnAddMember(Guild* guild, Player* player, uint32 plRank); +#ifdef RETAIL + void OnRemoveMember(Guild* guild, ObjectGuid guid, bool isDisbanding); +#else void OnRemoveMember(Guild* guild, Player* player, bool isDisbanding); +#endif void OnMOTDChanged(Guild* guild, const std::string& newMotd); void OnInfoChanged(Guild* guild, const std::string& newInfo); void OnCreate(Guild* guild, Player* leader, const std::string& name); void OnDisband(Guild* guild); void OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair); -#ifdef CATA +#if defined CATA || defined RETAIL void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair); #endif void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount); -#ifdef CATA +#if defined CATA || defined RETAIL void OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount); #endif void OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId); diff --git a/hooks/GossipHooks.cpp b/hooks/GossipHooks.cpp index e74609375f..49307734b3 100644 --- a/hooks/GossipHooks.cpp +++ b/hooks/GossipHooks.cpp @@ -142,7 +142,7 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, auto original_menu = *pPlayer->GetPlayerMenu(); pPlayer->GetPlayerMenu()->ClearMenus(); #else - auto original_menu = *pPlayer->PlayerTalkClass; + auto original_menu = pPlayer->PlayerTalkClass->GetGossipMenu().GetMenuId(); pPlayer->PlayerTalkClass->ClearMenus(); #endif HookPush(pPlayer); @@ -154,7 +154,7 @@ bool Eluna::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, #if defined CMANGOS && !defined(CATA) *pPlayer->GetPlayerMenu() = original_menu; #else - *pPlayer->PlayerTalkClass = original_menu; + pPlayer->PlayerTalkClass->GetGossipMenu().SetMenuId(original_menu); #endif } return preventDefault; @@ -167,7 +167,7 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 send auto original_menu = *pPlayer->GetPlayerMenu(); pPlayer->GetPlayerMenu()->ClearMenus(); #else - auto original_menu = *pPlayer->PlayerTalkClass; + auto original_menu = pPlayer->PlayerTalkClass->GetGossipMenu().GetMenuId(); pPlayer->PlayerTalkClass->ClearMenus(); #endif HookPush(pPlayer); @@ -180,7 +180,7 @@ bool Eluna::OnGossipSelectCode(Player* pPlayer, Creature* pCreature, uint32 send #if defined CMANGOS &&!defined(CATA) *pPlayer->GetPlayerMenu() = original_menu; #else - *pPlayer->PlayerTalkClass = original_menu; + pPlayer->PlayerTalkClass->GetGossipMenu().SetMenuId(original_menu); #endif } return preventDefault; diff --git a/hooks/GuildHooks.cpp b/hooks/GuildHooks.cpp index 97915bdcb9..b4fdcb9dea 100644 --- a/hooks/GuildHooks.cpp +++ b/hooks/GuildHooks.cpp @@ -26,6 +26,16 @@ void Eluna::OnAddMember(Guild* guild, Player* player, uint32 plRank) CallAllFunctions(GuildEventBindings, key); } +#ifdef RETAIL +void Eluna::OnRemoveMember(Guild* guild, ObjectGuid guid, bool isDisbanding) +{ + START_HOOK(GUILD_EVENT_ON_REMOVE_MEMBER); + HookPush(guild); + HookPush(guid); + HookPush(isDisbanding); + CallAllFunctions(GuildEventBindings, key); +} +#else void Eluna::OnRemoveMember(Guild* guild, Player* player, bool isDisbanding) { START_HOOK(GUILD_EVENT_ON_REMOVE_MEMBER); @@ -34,6 +44,7 @@ void Eluna::OnRemoveMember(Guild* guild, Player* player, bool isDisbanding) HookPush(isDisbanding); CallAllFunctions(GuildEventBindings, key); } +#endif void Eluna::OnMOTDChanged(Guild* guild, const std::string& newMotd) { @@ -94,7 +105,7 @@ void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, b CleanUpStack(4); } -#ifdef CATA +#if defined CATA || defined RETAIL void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair) { START_HOOK(GUILD_EVENT_ON_MONEY_WITHDRAW); @@ -149,7 +160,7 @@ void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount) CleanUpStack(3); } -#ifdef CATA +#if defined CATA || defined RETAIL void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount) { START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT); diff --git a/hooks/ItemHooks.cpp b/hooks/ItemHooks.cpp index 3b78c5823b..37cb249aff 100644 --- a/hooks/ItemHooks.cpp +++ b/hooks/ItemHooks.cpp @@ -66,7 +66,7 @@ bool Eluna::OnUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets) WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 18); data << uint8(59); // EQUIP_ERR_NONE / EQUIP_ERR_CANT_BE_DISENCHANTED data << guid; - data << ObjectGuid(uint64(0)); + data << uint64(0); data << uint8(0); #ifdef CMANGOS pPlayer->GetSession()->SendPacket(data); @@ -112,9 +112,17 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ bool Eluna::OnExpire(Player* pPlayer, ItemTemplate const* pProto) { +#if defined TRINITY && (defined CATA || defined RETAIL) + START_HOOK_WITH_RETVAL(ITEM_EVENT_ON_EXPIRE, pProto->BasicData->ID, false); +#else START_HOOK_WITH_RETVAL(ITEM_EVENT_ON_EXPIRE, pProto->ItemId, false); - HookPush(pPlayer); - HookPush(pProto->ItemId); +#endif + Push(pPlayer); +#if defined TRINITY && (defined CATA || defined RETAIL) + Push(pProto->BasicData->ID); +#else + Push(pProto->ItemId); +#endif return CallAllFunctionsBool(ItemEventBindings, key); } diff --git a/hooks/PlayerHooks.cpp b/hooks/PlayerHooks.cpp index 26841c8e5e..db2df7aca9 100644 --- a/hooks/PlayerHooks.cpp +++ b/hooks/PlayerHooks.cpp @@ -26,6 +26,16 @@ using namespace Hooks; if (!PlayerEventBindings->HasBindingsFor(key))\ return RETVAL; +#ifdef RETAIL +void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 spellid) +{ + START_HOOK(PLAYER_EVENT_ON_LEARN_TALENTS); + HookPush(pPlayer); + HookPush(talentId); + HookPush(spellid); + CallAllFunctions(PlayerEventBindings, key); +} +#else void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, uint32 spellid) { START_HOOK(PLAYER_EVENT_ON_LEARN_TALENTS); @@ -35,6 +45,7 @@ void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank, HookPush(spellid); CallAllFunctions(PlayerEventBindings, key); } +#endif void Eluna::OnSkillChange(Player* pPlayer, uint32 skillId, uint32 skillValue) { @@ -280,7 +291,7 @@ void Eluna::OnMoneyChanged(Player* pPlayer, int32& amount) CleanUpStack(2); } -#ifdef CATA +#if defined CATA || defined RETAIL void Eluna::OnMoneyChanged(Player* pPlayer, int64& amount) { START_HOOK(PLAYER_EVENT_ON_MONEY_CHANGE); diff --git a/hooks/ServerHooks.cpp b/hooks/ServerHooks.cpp index 2cb4c74404..435e8c323c 100644 --- a/hooks/ServerHooks.cpp +++ b/hooks/ServerHooks.cpp @@ -132,8 +132,44 @@ void Eluna::OnChange(Weather* /*weather*/, uint32 zone, WeatherState state, floa CallAllFunctions(ServerEventBindings, key); } +#ifndef RETAIL // Auction House -void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry) +void Eluna::OnAdd(AuctionHouseObject* ah, AuctionPosting* entry) +{ +#ifdef AZEROTHCORE + Player* owner = eObjectAccessor()FindPlayer(entry->owner); +#else + Player* owner = eObjectAccessor()FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); +#endif + +#ifdef TRINITY + Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); + uint32 expiretime = entry->expire_time; +#elif AZEROTHCORE + Item* item = eAuctionMgr->GetAItem(entry->item_guid); + uint32 expiretime = entry->expire_time; +#else + Item* item = eAuctionMgr->GetAItem(entry->itemGuidLow); + uint32 expiretime = entry->expireTime; +#endif + + if (!owner || !item) + return; + + START_HOOK(AUCTION_EVENT_ON_ADD); + Push(entry->Id); + Push(owner); + Push(item); + Push(expiretime); + Push(entry->buyout); + Push(entry->startbid); + Push(entry->bid); + Push(entry->bidder); + CallAllFunctions(ServerEventBindings, key); +} + +#ifndef RETAIL +void Eluna::OnAdd(AuctionHouseObject* , AuctionEntry* entry) { #ifdef AZEROTHCORE Player* owner = eObjectAccessor()FindPlayer(entry->owner); @@ -166,6 +202,7 @@ void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry) HookPush(entry->bidder); CallAllFunctions(ServerEventBindings, key); } +#endif void Eluna::OnRemove(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { @@ -271,6 +308,7 @@ void Eluna::OnExpire(AuctionHouseObject* /*ah*/, AuctionEntry* entry) HookPush(entry->bidder); CallAllFunctions(ServerEventBindings, key); } +#endif void Eluna::OnOpenStateChange(bool open) { diff --git a/methods/TrinityCore/BattleGroundMethods.h b/methods/TrinityCore/BattleGroundMethods.h index f386f47148..116e135b85 100644 --- a/methods/TrinityCore/BattleGroundMethods.h +++ b/methods/TrinityCore/BattleGroundMethods.h @@ -82,7 +82,7 @@ namespace LuaBattleGround */ int GetEndTime(Eluna* E, BattleGround* bg) { -#ifdef CATA +#if defined CATA || defined RETAIL E->Push(bg->GetRemainingTime()); #else E->Push(bg->GetEndTime()); diff --git a/methods/TrinityCore/CreatureMethods.h b/methods/TrinityCore/CreatureMethods.h index 4162d7cf9e..13e2d2a557 100644 --- a/methods/TrinityCore/CreatureMethods.h +++ b/methods/TrinityCore/CreatureMethods.h @@ -6,7 +6,6 @@ #ifndef CREATUREMETHODS_H #define CREATUREMETHODS_H - /*** * Non-[Player] controlled [Unit]s (i.e. NPCs). * @@ -142,6 +141,7 @@ namespace LuaCreature return 1; } +#ifndef RETAIL /** * Returns `true` if the [Creature] can start attacking nearby hostile [Unit]s, * and returns `false` otherwise. @@ -153,6 +153,7 @@ namespace LuaCreature E->Push(!creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)); return 1; } +#endif /** * Returns `true` if the [Creature] can move through deep water, @@ -166,6 +167,7 @@ namespace LuaCreature return 1; } +#ifndef RETAIL /** * Returns `true` if the [Creature] can move on land, * and returns `false` otherwise. @@ -177,6 +179,7 @@ namespace LuaCreature E->Push(creature->CanWalk()); return 1; } +#endif /** * Returns `true` if the [Creature] is returning to its spawn position from combat, @@ -198,7 +201,7 @@ namespace LuaCreature */ int IsElite(Eluna* E, Creature* creature) { - E->Push(creature->isElite()); + E->Push(creature->IsElite()); return 1; } @@ -274,7 +277,7 @@ namespace LuaCreature { uint32 spell = E->CHECKVAL(2); - if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE)) E->Push(info->GetCategory() && creature->GetSpellHistory()->HasCooldown(spell)); else E->Push(false); @@ -351,6 +354,7 @@ namespace LuaCreature return 1; } +#ifndef RETAIL /** * Returns true if the [Creature] is damaged enough for looting * @@ -361,6 +365,7 @@ namespace LuaCreature E->Push(creature->IsDamageEnoughForLootingAndReward()); return 1; } +#endif /** * Returns true if the [Creature] can start attacking specified target @@ -419,6 +424,7 @@ namespace LuaCreature return 1; } +#ifndef RETAIL /** * Returns the current waypoint path ID of the [Creature]. * @@ -429,6 +435,7 @@ namespace LuaCreature E->Push(creature->GetWaypointPath()); return 1; } +#endif /** * Returns the current waypoint ID of the [Creature]. @@ -483,7 +490,7 @@ namespace LuaCreature return 1; } - +#ifndef RETAIL /** * Returns the [Group] that can loot this [Creature]. * @@ -505,6 +512,7 @@ namespace LuaCreature E->Push(creature->GetLootRecipient()); return 1; } +#endif /** * Returns the [Creature]'s script name. @@ -560,8 +568,11 @@ namespace LuaCreature { uint32 spell = E->CHECKVAL(2); - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) - E->Push(creature->GetSpellHistory()->GetRemainingCooldown(spellInfo)); + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE)) + { + Milliseconds remainingCooldown = creature->GetSpellHistory()->GetRemainingCooldown(spellInfo); + E->Push(remainingCooldown.count()); + } else E->Push(0); @@ -794,7 +805,7 @@ namespace LuaCreature float threat = E->CHECKVAL(3, true); uint32 spell = E->CHECKVAL(4, 0); - creature->GetThreatManager().AddThreat(victim, threat, spell ? sSpellMgr->GetSpellInfo(spell) : NULL, true, true); + creature->GetThreatManager().AddThreat(victim, threat, spell ? sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE) : NULL, true, true); return 0; } @@ -865,6 +876,7 @@ namespace LuaCreature return 0; } +#ifndef RETAIL /** * Returns the [Creature]'s NPC flags. * @@ -878,6 +890,7 @@ namespace LuaCreature E->Push(creature->GetUInt32Value(UNIT_NPC_FLAGS)); return 1; } +#endif /** * Returns the [Creature]'s Extra flags. @@ -893,6 +906,7 @@ namespace LuaCreature return 1; } +#ifndef RETAIL /** * Returns the [Creature]'s rank as defined in the creature template. * @@ -903,8 +917,9 @@ namespace LuaCreature E->Push(creature->GetCreatureTemplate()->rank); return 1; } +#endif -#ifndef CATA +#ifdef WOTLK /** * Returns the [Creature]'s shield block value. * @@ -948,6 +963,7 @@ namespace LuaCreature return 1; } +#ifndef RETAIL /** * Sets the [Creature]'s NPC flags to `flags`. * @@ -960,6 +976,7 @@ namespace LuaCreature creature->SetUInt32Value(UNIT_NPC_FLAGS, flags); return 0; } +#endif /** * Sets the [Creature]'s ReactState to `state`. @@ -1035,6 +1052,7 @@ namespace LuaCreature return 0; } +#ifndef RETAIL /** * Equips given [Item]s to the [Unit]. Using 0 removes the equipped [Item] * @@ -1070,6 +1088,7 @@ namespace LuaCreature return 0; } +#endif /** * Sets whether the [Creature] gives reputation or not. @@ -1207,6 +1226,7 @@ namespace LuaCreature return 0; } +#ifndef RETAIL /** * Make the [Creature] start following its waypoint path. */ @@ -1215,6 +1235,7 @@ namespace LuaCreature creature->GetMotionMaster()->MovePath(creature->GetWaypointPath(), true); return 0; } +#endif /** * Make the [Creature] call for assistance in combat from other nearby [Creature]s. @@ -1433,15 +1454,15 @@ namespace LuaCreature { "GetRespawnDelay", &LuaCreature::GetRespawnDelay }, { "GetWanderRadius", &LuaCreature::GetWanderRadius }, { "GetCurrentWaypointId", &LuaCreature::GetCurrentWaypointId }, - { "GetWaypointPath", &LuaCreature::GetWaypointPath }, + //{ "GetWaypointPath", &LuaCreature::GetWaypointPath }, { "GetLootMode", &LuaCreature::GetLootMode }, - { "GetLootRecipient", &LuaCreature::GetLootRecipient }, - { "GetLootRecipientGroup", &LuaCreature::GetLootRecipientGroup }, - { "GetNPCFlags", &LuaCreature::GetNPCFlags }, + //{ "GetLootRecipient", &LuaCreature::GetLootRecipient }, + //{ "GetLootRecipientGroup", &LuaCreature::GetLootRecipientGroup }, + //{ "GetNPCFlags", &LuaCreature::GetNPCFlags }, { "GetExtraFlags", &LuaCreature::GetExtraFlags }, - { "GetRank", &LuaCreature::GetRank }, + //{ "GetRank", &LuaCreature::GetRank }, #ifndef CATA - { "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue }, + //{ "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue }, #endif { "GetDBTableGUIDLow", &LuaCreature::GetDBTableGUIDLow }, { "GetCreatureFamily", &LuaCreature::GetCreatureFamily }, @@ -1451,7 +1472,7 @@ namespace LuaCreature { "SetRegeneratingHealth", &LuaCreature::SetRegeneratingHealth }, { "SetHover", &LuaCreature::SetHover }, { "SetDisableGravity", &LuaCreature::SetDisableGravity }, - { "SetAggroEnabled", &LuaCreature::SetAggroEnabled }, + //{ "SetAggroEnabled", &LuaCreature::SetAggroEnabled }, { "SetNoCallAssistance", &LuaCreature::SetNoCallAssistance }, { "SetNoSearchAssistance", &LuaCreature::SetNoSearchAssistance }, { "SetDefaultMovementType", &LuaCreature::SetDefaultMovementType }, @@ -1460,12 +1481,12 @@ namespace LuaCreature { "SetInCombatWithZone", &LuaCreature::SetInCombatWithZone }, { "SetDisableReputationGain", &LuaCreature::SetDisableReputationGain }, { "SetLootMode", &LuaCreature::SetLootMode }, - { "SetNPCFlags", &LuaCreature::SetNPCFlags }, + //{ "SetNPCFlags", &LuaCreature::SetNPCFlags }, { "SetReactState", &LuaCreature::SetReactState }, { "SetDeathState", &LuaCreature::SetDeathState }, { "SetWalk", &LuaCreature::SetWalk }, { "SetHomePosition", &LuaCreature::SetHomePosition }, - { "SetEquipmentSlots", &LuaCreature::SetEquipmentSlots }, + //{ "SetEquipmentSlots", &LuaCreature::SetEquipmentSlots }, // Boolean { "IsRegeneratingHealth", &LuaCreature::IsRegeneratingHealth }, @@ -1478,9 +1499,9 @@ namespace LuaCreature { "IsElite", &LuaCreature::IsElite }, { "IsInEvadeMode", &LuaCreature::IsInEvadeMode }, { "HasCategoryCooldown", &LuaCreature::HasCategoryCooldown }, - { "CanWalk", &LuaCreature::CanWalk }, + //{ "CanWalk", &LuaCreature::CanWalk }, { "CanSwim", &LuaCreature::CanSwim }, - { "CanAggro", &LuaCreature::CanAggro }, + //{ "CanAggro", &LuaCreature::CanAggro }, { "CanStartAttack", &LuaCreature::CanStartAttack }, { "HasSearchedAssistance", &LuaCreature::HasSearchedAssistance }, { "IsTappedBy", &LuaCreature::IsTappedBy }, @@ -1489,7 +1510,7 @@ namespace LuaCreature { "IsTargetableForAttack", &LuaCreature::IsTargetableForAttack }, { "CanCompleteQuest", &LuaCreature::CanCompleteQuest }, { "IsReputationGainDisabled", &LuaCreature::IsReputationGainDisabled }, - { "IsDamageEnoughForLootingAndReward", &LuaCreature::IsDamageEnoughForLootingAndReward }, + //{ "IsDamageEnoughForLootingAndReward", &LuaCreature::IsDamageEnoughForLootingAndReward }, { "HasLootMode", &LuaCreature::HasLootMode }, { "HasSpell", &LuaCreature::HasSpell }, { "HasQuest", &LuaCreature::HasQuest }, @@ -1509,7 +1530,7 @@ namespace LuaCreature { "RemoveLootMode", &LuaCreature::RemoveLootMode }, { "SaveToDB", &LuaCreature::SaveToDB }, { "SelectVictim", &LuaCreature::SelectVictim }, - { "MoveWaypoint", &LuaCreature::MoveWaypoint }, + //{ "MoveWaypoint", &LuaCreature::MoveWaypoint }, { "UpdateEntry", &LuaCreature::UpdateEntry }, { "AddThreat", &LuaCreature::AddThreat }, { "ClearThreat", &LuaCreature::ClearThreat }, diff --git a/methods/TrinityCore/GameObjectMethods.h b/methods/TrinityCore/GameObjectMethods.h index 3e53ee767c..e0067519f1 100644 --- a/methods/TrinityCore/GameObjectMethods.h +++ b/methods/TrinityCore/GameObjectMethods.h @@ -124,6 +124,7 @@ namespace LuaGameObject return 1; } +#ifndef RETAIL /** * Returns the [Player] that can loot the [GameObject] * @@ -149,6 +150,7 @@ namespace LuaGameObject E->Push(go->GetLootRecipientGroup()); return 1; } +#endif /** * Returns the guid of the [GameObject] that is used as the ID in the database @@ -237,6 +239,7 @@ namespace LuaGameObject return 0; } +#ifndef RETAIL /** * Removes [GameObject] from the world * @@ -267,6 +270,7 @@ namespace LuaGameObject return 0; } +#endif /** * Activates a door or a button/lever @@ -322,8 +326,8 @@ namespace LuaGameObject { "GetDisplayId", &LuaGameObject::GetDisplayId }, { "GetGoState", &LuaGameObject::GetGoState }, { "GetLootState", &LuaGameObject::GetLootState }, - { "GetLootRecipient", &LuaGameObject::GetLootRecipient }, - { "GetLootRecipientGroup", &LuaGameObject::GetLootRecipientGroup }, + //{ "GetLootRecipient", &LuaGameObject::GetLootRecipient }, + //{ "GetLootRecipientGroup", &LuaGameObject::GetLootRecipientGroup }, { "GetDBTableGUIDLow", &LuaGameObject::GetDBTableGUIDLow }, // Setters @@ -339,7 +343,7 @@ namespace LuaGameObject { "IsSpawned", &LuaGameObject::IsSpawned }, // Other - { "RemoveFromWorld", &LuaGameObject::RemoveFromWorld }, + //{ "RemoveFromWorld", &LuaGameObject::RemoveFromWorld }, { "UseDoorOrButton", &LuaGameObject::UseDoorOrButton }, { "Despawn", &LuaGameObject::Despawn }, { "Respawn", &LuaGameObject::Respawn }, diff --git a/methods/TrinityCore/GlobalMethods.h b/methods/TrinityCore/GlobalMethods.h index ae89a50629..b8772ea835 100644 --- a/methods/TrinityCore/GlobalMethods.h +++ b/methods/TrinityCore/GlobalMethods.h @@ -8,6 +8,7 @@ #define GLOBALMETHODS_H #include "BindingMap.h" +#include /*** * These functions can be used anywhere at any time, including at start-up. @@ -72,7 +73,7 @@ namespace LuaGlobalFunctions /** * Returns emulator's supported expansion. * - * Expansion is 0 for pre-TBC, 1 for TBC, 2 for WotLK, and 3 for Cataclysm. + * Expansion is 0 for pre-TBC, 1 for TBC, 2 for WotLK, 3 for Cataclysm, 9 for Dragonflight. * * @return int32 expansion */ @@ -82,6 +83,8 @@ namespace LuaGlobalFunctions E->Push(2); #elif CATA E->Push(3); +#elif RETAIL + E->Push(9); #endif return 1; } @@ -341,7 +344,7 @@ namespace LuaGlobalFunctions int GetPlayerGUID(Eluna* E) { uint32 lowguid = E->CHECKVAL(1); - E->Push(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); + //E->Push(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); return 1; } @@ -357,7 +360,7 @@ namespace LuaGlobalFunctions int GetItemGUID(Eluna* E) { uint32 lowguid = E->CHECKVAL(1); - E->Push(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM)); + //E->Push(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_ITEM)); return 1; } @@ -376,7 +379,7 @@ namespace LuaGlobalFunctions { uint32 lowguid = E->CHECKVAL(1); uint32 entry = E->CHECKVAL(2); - E->Push(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); + //E->Push(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_GAMEOBJECT)); return 1; } @@ -395,7 +398,7 @@ namespace LuaGlobalFunctions { uint32 lowguid = E->CHECKVAL(1); uint32 entry = E->CHECKVAL(2); - E->Push(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT)); + //E->Push(MAKE_NEW_GUID(lowguid, entry, HIGHGUID_UNIT)); return 1; } @@ -446,6 +449,9 @@ namespace LuaGlobalFunctions * @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [Item] name in * @return string itemLink */ +#ifdef RETAIL + /* + #endif int GetItemLink(Eluna* E) { uint32 entry = E->CHECKVAL(1); @@ -457,17 +463,20 @@ namespace LuaGlobalFunctions if (!temp) return luaL_argerror(E->L, 1, "valid ItemEntry expected"); -#ifdef CATA +#if defined CATA std::string name = temp->ExtendedData->Display->Str[locale]; +#elif defined RETAIL + std::string name = temp->ExtendedData->Display.Str[locale]; #else std::string name = temp->Name1; #endif + if (ItemSparseEntry const* il = eObjectMgr->getitem) if (ItemLocale const* il = eObjectMgr->GetItemLocale(entry)) ObjectMgr::GetLocaleString(il->Name, static_cast(locale), name); std::ostringstream oss; -#ifdef CATA - oss << "|c" << std::hex << ItemQualityColors[temp->ExtendedData->Quality] << std::dec << +#if defined CATA || defined RETAIL + oss << "|c" << std::hex << ItemQualityColors[temp->ExtendedData->OverallQualityID] << std::dec << #else oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec << #endif @@ -478,6 +487,9 @@ namespace LuaGlobalFunctions E->Push(oss.str()); return 1; } +#ifdef RETAIL + */ +#endif /** * Returns the type ID from a GUID. @@ -511,6 +523,7 @@ namespace LuaGlobalFunctions return 1; } +#ifndef RETAIL /** * Returns the area or zone's name. * @@ -545,6 +558,7 @@ namespace LuaGlobalFunctions E->Push(areaEntry->AreaName[locale]); return 1; } +#endif /** * Returns the currently active game events. @@ -1697,7 +1711,7 @@ namespace LuaGlobalFunctions E->eventMgr->globalProcessor->SetStates(LUAEVENT_STATE_ABORT); return 0; } - +#ifndef RETAIL /** * Performs an in-game spawn and returns the [Creature] or [GameObject] spawned. * @@ -1748,8 +1762,8 @@ namespace LuaGlobalFunctions if (save) { Creature* creature = new Creature(); -#ifdef CATA - if (!creature->Create(map->GenerateLowGuid(), map, entry, pos)) +#if defined CATA || RETAIL + if (!creature->Create(map->GenerateLowGuid(), map, entry, pos, nullptr, NULL)) #else if (!creature->Create(map->GenerateLowGuid(), map, phase, entry, pos)) #endif @@ -1759,8 +1773,8 @@ namespace LuaGlobalFunctions return 1; } -#ifdef CATA - creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); +#if defined CATA || RETAIL + creature->SaveToDB(map->GetId(), { map->GetDifficultyID() }); #else creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); #endif @@ -1780,17 +1794,17 @@ namespace LuaGlobalFunctions return 1; } - eObjectMgr->AddCreatureToGrid(db_guid, eObjectMgr->GetCreatureData(db_guid)); + eObjectMgr->AddCreatureToGrid(eObjectMgr->GetCreatureData(db_guid)); E->Push(creature); } else { -#ifdef CATA +#if defined CATA SummonCreatureExtraArgs extraArgs; extraArgs.SummonDuration = durorresptime; TempSummon* creature = map->SummonCreature(entry, pos, extraArgs); #else - TempSummon* creature = map->SummonCreature(entry, pos, NULL, durorresptime); + TempSummon* creature = map->SummonCreature(entry, pos, NULL, Milliseconds(durorresptime)); #endif if (!creature) { @@ -1829,6 +1843,8 @@ namespace LuaGlobalFunctions QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); #ifdef CATA if (!object->Create(guidLow, objectInfo->entry, map, Position(x, y, z, o), rot, 0, GO_STATE_READY)) +#elif RETAIL + if (!object->CreateGameObject(guidLow, map, Position(x, y, z, o), rot, 0, GO_STATE_READY)) #else if (!object->Create(guidLow, objectInfo->entry, map, phase, Position(x, y, z, o), rot, 0, GO_STATE_READY)) #endif @@ -1847,7 +1863,7 @@ namespace LuaGlobalFunctions #ifdef CATA object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); #else - object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); + object->SaveToDB(map->GetId(), { map->GetDifficultyID() }); #endif guidLow = object->GetSpawnId(); @@ -1863,7 +1879,7 @@ namespace LuaGlobalFunctions E->Push(); return 1; } - eObjectMgr->AddGameobjectToGrid(guidLow, eObjectMgr->GetGameObjectData(guidLow)); + eObjectMgr->AddGameobjectToGrid(eObjectMgr->GetGameObjectData(guidLow)); } else map->AddToMap(object); @@ -1882,6 +1898,7 @@ namespace LuaGlobalFunctions * @param uint32 size : the size of the packet * @return [WorldPacket] packet */ + int CreatePacket(Eluna* E) { uint32 opcode = E->CHECKVAL(1); @@ -1893,6 +1910,8 @@ namespace LuaGlobalFunctions return 1; } +#endif + /** * Adds an [Item] to a vendor and updates the world database. * @@ -1910,7 +1929,7 @@ namespace LuaGlobalFunctions uint32 incrtime = E->CHECKVAL(4); uint32 extendedcost = E->CHECKVAL(5); -#ifdef CATA +#if defined CATA ||defined RETAIL VendorItem vItem; vItem.item = item; vItem.maxcount = maxcount; @@ -1942,7 +1961,7 @@ namespace LuaGlobalFunctions if (!eObjectMgr->GetCreatureTemplate(entry)) return luaL_argerror(E->L, 1, "valid CreatureEntry expected"); -#ifdef CATA +#if defined CATA || defined RETAIL eObjectMgr->RemoveVendorItem(entry, item, 1); #else eObjectMgr->RemoveVendorItem(entry, item); @@ -1966,7 +1985,7 @@ namespace LuaGlobalFunctions auto const itemlist = items->m_items; for (auto itr = itemlist.begin(); itr != itemlist.end(); ++itr) -#ifdef CATA +#if defined CATA || defined RETAIL eObjectMgr->RemoveVendorItem(entry, itr->item, 1); #else eObjectMgr->RemoveVendorItem(entry, itr->item); @@ -2073,6 +2092,7 @@ namespace LuaGlobalFunctions return 0; } +#ifndef RETAIL /** * Sends mail to a [Player]. * @@ -2136,7 +2156,7 @@ namespace LuaGlobalFunctions luaL_error(E->L, "Item entry %d does not exist", entry); continue; } -#ifdef CATA +#if defined CATA || defined RETAIL if (amount < 1 || (item_proto->ExtendedData->MaxCount > 0 && amount > uint32(item_proto->ExtendedData->MaxCount))) #else if (amount < 1 || (item_proto->MaxCount > 0 && amount > uint32(item_proto->MaxCount))) @@ -2160,6 +2180,7 @@ namespace LuaGlobalFunctions return addedItems; } +#endif /** * Performs a bitwise AND (a & b). @@ -2249,6 +2270,7 @@ namespace LuaGlobalFunctions return 1; } +#ifndef RETAIL /** * Adds a taxi path to a specified map, returns the used pathId. * @@ -2380,6 +2402,8 @@ namespace LuaGlobalFunctions E->Push(pathId); return 1; } +#endif + /** * Returns `true` if Eluna is in compatibility mode, `false` if in multistate. * @@ -2719,7 +2743,7 @@ namespace LuaGlobalFunctions } return 0; } - +#ifndef RETAIL /** * Unbinds event handlers for either all of a [Creature]'s events, or one type of event. * @@ -2757,6 +2781,7 @@ namespace LuaGlobalFunctions } return 0; } +#endif /** * Unbinds event handlers for either all of a [Creature]'s gossip events, or one type of event. @@ -3194,7 +3219,7 @@ namespace LuaGlobalFunctions { "ClearBattleGroundEvents", &LuaGlobalFunctions::ClearBattleGroundEvents }, { "ClearCreatureEvents", &LuaGlobalFunctions::ClearCreatureEvents }, - { "ClearUniqueCreatureEvents", &LuaGlobalFunctions::ClearUniqueCreatureEvents }, + //{ "ClearUniqueCreatureEvents", &LuaGlobalFunctions::ClearUniqueCreatureEvents }, { "ClearCreatureGossipEvents", &LuaGlobalFunctions::ClearCreatureGossipEvents }, { "ClearGameObjectEvents", &LuaGlobalFunctions::ClearGameObjectEvents }, { "ClearGameObjectGossipEvents", &LuaGlobalFunctions::ClearGameObjectGossipEvents }, @@ -3234,14 +3259,22 @@ namespace LuaGlobalFunctions { "GetGUIDLow", &LuaGlobalFunctions::GetGUIDLow }, { "GetGUIDType", &LuaGlobalFunctions::GetGUIDType }, { "GetGUIDEntry", &LuaGlobalFunctions::GetGUIDEntry }, +#ifndef RETAIL { "GetAreaName", &LuaGlobalFunctions::GetAreaName }, +#else + { "GetAreaName", nullptr, METHOD_REG_NONE }, +#endif { "bit_not", &LuaGlobalFunctions::bit_not }, { "bit_xor", &LuaGlobalFunctions::bit_xor }, { "bit_rshift", &LuaGlobalFunctions::bit_rshift }, { "bit_lshift", &LuaGlobalFunctions::bit_lshift }, { "bit_or", &LuaGlobalFunctions::bit_or }, { "bit_and", &LuaGlobalFunctions::bit_and }, +#ifndef RETAIL { "GetItemLink", &LuaGlobalFunctions::GetItemLink }, +#else + { "GetItemLink", nullptr, METHOD_REG_NONE }, +#endif { "GetMapById", &LuaGlobalFunctions::GetMapById, METHOD_REG_WORLD }, // World state method only in multistate { "GetCurrTime", &LuaGlobalFunctions::GetCurrTime }, { "GetTimeDiff", &LuaGlobalFunctions::GetTimeDiff }, @@ -3274,16 +3307,25 @@ namespace LuaGlobalFunctions { "CreateLuaEvent", &LuaGlobalFunctions::CreateLuaEvent }, { "RemoveEventById", &LuaGlobalFunctions::RemoveEventById }, { "RemoveEvents", &LuaGlobalFunctions::RemoveEvents }, - { "PerformIngameSpawn", &LuaGlobalFunctions::PerformIngameSpawn }, + //{ "PerformIngameSpawn", &LuaGlobalFunctions::PerformIngameSpawn }, +#ifndef RETAIL { "CreatePacket", &LuaGlobalFunctions::CreatePacket }, +#else + { "CreatePacket", nullptr, METHOD_REG_NONE }, +#endif { "AddVendorItem", &LuaGlobalFunctions::AddVendorItem }, { "VendorRemoveItem", &LuaGlobalFunctions::VendorRemoveItem }, { "VendorRemoveAllItems", &LuaGlobalFunctions::VendorRemoveAllItems }, { "Kick", &LuaGlobalFunctions::Kick }, { "Ban", &LuaGlobalFunctions::Ban }, { "SaveAllPlayers", &LuaGlobalFunctions::SaveAllPlayers }, +#ifndef RETAIL { "SendMail", &LuaGlobalFunctions::SendMail }, { "AddTaxiPath", &LuaGlobalFunctions::AddTaxiPath }, +#else + { "SendMail", nullptr, METHOD_REG_NONE }, + { "AddTaxiPath", nullptr, METHOD_REG_NONE }, +#endif { "CreateInt64", &LuaGlobalFunctions::CreateLongLong }, { "CreateUint64", &LuaGlobalFunctions::CreateULongLong }, { "StartGameEvent", &LuaGlobalFunctions::StartGameEvent }, diff --git a/methods/TrinityCore/GuildMethods.h b/methods/TrinityCore/GuildMethods.h index fcd941593f..1dfeff9279 100644 --- a/methods/TrinityCore/GuildMethods.h +++ b/methods/TrinityCore/GuildMethods.h @@ -52,7 +52,7 @@ namespace LuaGuild */ int GetMemberCount(Eluna* E, Guild* guild) { - E->Push(guild->GetMemberCount()); + E->Push(guild->GetMembersCount()); return 1; } @@ -124,7 +124,7 @@ namespace LuaGuild return 1; } -#ifndef CATA +#ifdef WOTLK /** * Sets the leader of this [Guild] * @@ -184,7 +184,7 @@ namespace LuaGuild WorldPacket* data = E->CHECKOBJ(2); uint8 ranked = E->CHECKVAL(3); - guild->BroadcastPacketToRank(data, ranked); + guild->BroadcastPacketToRank(data, GuildRankId(ranked)); return 0; } @@ -217,7 +217,7 @@ namespace LuaGuild CharacterDatabaseTransaction trans(nullptr); - guild->AddMember(trans, player->GET_GUID(), rankId); + guild->AddMember(trans, player->GET_GUID(), GuildRankId(rankId)); return 0; } @@ -255,7 +255,7 @@ namespace LuaGuild CharacterDatabaseTransaction trans(nullptr); - guild->ChangeMemberRank(trans, player->GET_GUID(), newRank); + guild->ChangeMemberRank(trans, player->GET_GUID(), GuildRankId(newRank)); return 0; } @@ -274,7 +274,7 @@ namespace LuaGuild // Setters { "SetBankTabText", &LuaGuild::SetBankTabText, METHOD_REG_WORLD }, // World state method only in multistate { "SetMemberRank", &LuaGuild::SetMemberRank, METHOD_REG_WORLD }, // World state method only in multistate -#ifndef CATA +#ifdef WOTLK { "SetLeader", &LuaGuild::SetLeader, METHOD_REG_WORLD }, // World state method only in multistate #endif diff --git a/methods/TrinityCore/ItemMethods.h b/methods/TrinityCore/ItemMethods.h index 60ababc544..08b6688faf 100644 --- a/methods/TrinityCore/ItemMethods.h +++ b/methods/TrinityCore/ItemMethods.h @@ -45,6 +45,7 @@ namespace LuaItem return 1; } +#ifndef RETAIL /** * Returns 'true' if the [Item] is not bound to the [Player] specified, 'false' otherwise * @@ -58,6 +59,7 @@ namespace LuaItem E->Push(item->IsBindedNotWith(player)); return 1; } +#endif /** * Returns 'true' if the [Item] is locked, 'false' otherwise @@ -233,6 +235,7 @@ namespace LuaItem } #endif +#ifndef RETAIL /** * Returns the chat link of the [Item] * @@ -261,7 +264,7 @@ namespace LuaItem return luaL_argerror(E->L, 2, "valid LocaleConstant expected"); const ItemTemplate* temp = item->GetTemplate(); -#ifdef CATA +#if defined CATA || RETAIL std::string name = temp->ExtendedData->Display1->Str[locale]; if (ItemLocale const* il = eObjectMgr->GetItemLocale(temp->BasicData->ID)) #else @@ -319,6 +322,7 @@ namespace LuaItem E->Push(oss.str()); return 1; } +#endif /** * Returns GUID of the [Player] who currently owns the [Item] @@ -403,6 +407,7 @@ namespace LuaItem return 1; } +#ifndef RETAIL /** * Returns the spell ID tied to the [Item] by spell index * @@ -412,7 +417,7 @@ namespace LuaItem int GetSpellId(Eluna* E, Item* item) { uint32 index = E->CHECKVAL(2); - if (index >= MAX_ITEM_PROTO_SPELLS) + if (index >= MAX_ITEM_PROTO_FLAGS) return luaL_argerror(E->L, 2, "valid SpellIndex expected"); #ifdef CATA @@ -442,6 +447,7 @@ namespace LuaItem #endif return 1; } +#endif /** * Returns class of the [Item] @@ -450,7 +456,7 @@ namespace LuaItem */ int GetClass(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetClass()); #else E->Push(item->GetTemplate()->Class); @@ -465,7 +471,7 @@ namespace LuaItem */ int GetSubClass(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetSubClass()); #else E->Push(item->GetTemplate()->SubClass); @@ -480,7 +486,7 @@ namespace LuaItem */ int GetItemId(Eluna* E, Item* item) { - E->Push(item->GetTemplate()->ItemId); + E->Push(item->GetTemplate()->BasicData->ID); return 1; } @@ -491,7 +497,7 @@ namespace LuaItem */ int GetName(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetDefaultLocaleName()); #else E->Push(item->GetTemplate()->Name1); @@ -499,6 +505,7 @@ namespace LuaItem return 1; } +#ifndef RETAIL /** * Returns the display ID of the [Item] * @@ -506,13 +513,14 @@ namespace LuaItem */ int GetDisplayId(Eluna* E, Item* item) { -#ifdef CATA - E->Push(item->GetTemplate()->GetDisplayID()); +#ifndef WOTLK + E->Push(item->GetTemplate()->displ); #else E->Push(item->GetTemplate()->DisplayInfoID); #endif return 1; } +#endif /** * Returns the quality of the [Item] @@ -521,7 +529,7 @@ namespace LuaItem */ int GetQuality(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetQuality()); #else E->Push(item->GetTemplate()->Quality); @@ -529,6 +537,7 @@ namespace LuaItem return 1; } +#ifndef RETAIL /** * Returns the flags of the [Item] * @@ -550,6 +559,7 @@ namespace LuaItem E->Push(item->GetTemplate()->Flags2); return 1; } +#endif /** * Returns the extraFlags of the [Item] @@ -569,7 +579,7 @@ namespace LuaItem */ int GetBuyCount(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetBuyCount()); #else E->Push(item->GetTemplate()->BuyCount); @@ -584,7 +594,7 @@ namespace LuaItem */ int GetBuyPrice(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetBuyPrice()); #else E->Push(item->GetTemplate()->BuyPrice); @@ -599,7 +609,7 @@ namespace LuaItem */ int GetSellPrice(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetSellPrice()); #else E->Push(item->GetTemplate()->SellPrice); @@ -614,7 +624,7 @@ namespace LuaItem */ int GetInventoryType(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetInventoryType()); #else E->Push(item->GetTemplate()->InventoryType); @@ -629,7 +639,7 @@ namespace LuaItem */ int GetAllowableClass(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetAllowableClass()); #else E->Push(item->GetTemplate()->AllowableClass); @@ -637,6 +647,7 @@ namespace LuaItem return 1; } +#ifndef RETAIL /** * Returns the [Player] races allowed to use this [Item] * @@ -644,13 +655,14 @@ namespace LuaItem */ int GetAllowableRace(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetAllowableRace()); #else E->Push(item->GetTemplate()->AllowableRace); #endif return 1; } +#endif /** * Returns the [Item]s level @@ -659,7 +671,7 @@ namespace LuaItem */ int GetItemLevel(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetBaseItemLevel()); #else E->Push(item->GetTemplate()->ItemLevel); @@ -676,6 +688,8 @@ namespace LuaItem { #ifdef CATA E->Push(item->GetTemplate()->GetRequiredLevel()); +#elif RETAIL + E->Push(item->GetTemplate()->GetBaseRequiredLevel()); #else E->Push(item->GetTemplate()->RequiredLevel); #endif @@ -695,6 +709,7 @@ namespace LuaItem } #endif +#ifndef RETAIL /** * Returns the random property ID of this [Item] * @@ -702,7 +717,7 @@ namespace LuaItem */ int GetRandomProperty(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetRandomProperty()); #else E->Push(item->GetTemplate()->RandomProperty); @@ -717,13 +732,14 @@ namespace LuaItem */ int GetRandomSuffix(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetRandomSuffix()); #else E->Push(item->GetTemplate()->RandomSuffix); #endif return 1; } +#endif /** * Returns the item set ID of this [Item] @@ -732,7 +748,7 @@ namespace LuaItem */ int GetItemSet(Eluna* E, Item* item) { -#ifdef CATA +#ifndef WOTLK E->Push(item->GetTemplate()->GetItemSet()); #else E->Push(item->GetTemplate()->ItemSet); @@ -880,31 +896,31 @@ namespace LuaItem { "GetSlot", &LuaItem::GetSlot }, { "GetBagSlot", &LuaItem::GetBagSlot }, { "GetEnchantmentId", &LuaItem::GetEnchantmentId }, - { "GetSpellId", &LuaItem::GetSpellId }, - { "GetSpellTrigger", &LuaItem::GetSpellTrigger }, - { "GetItemLink", &LuaItem::GetItemLink }, + //{ "GetSpellId", &LuaItem::GetSpellId }, + //{ "GetSpellTrigger", &LuaItem::GetSpellTrigger }, + //{ "GetItemLink", &LuaItem::GetItemLink }, { "GetClass", &LuaItem::GetClass }, { "GetSubClass", &LuaItem::GetSubClass }, { "GetItemId", &LuaItem::GetItemId }, { "GetName", &LuaItem::GetName }, - { "GetDisplayId", &LuaItem::GetDisplayId }, + //{ "GetDisplayId", &LuaItem::GetDisplayId }, { "GetQuality", &LuaItem::GetQuality }, - { "GetFlags", &LuaItem::GetFlags }, - { "GetFlags2", &LuaItem::GetFlags2 }, - { "GetExtraFlags", &LuaItem::GetExtraFlags }, + //{ "GetFlags", &LuaItem::GetFlags }, + //{ "GetFlags2", &LuaItem::GetFlags2 }, + { "GetExtraFlags", &LuaItem::GetExtraFlags }, { "GetBuyCount", &LuaItem::GetBuyCount }, { "GetBuyPrice", &LuaItem::GetBuyPrice }, { "GetSellPrice", &LuaItem::GetSellPrice }, { "GetInventoryType", &LuaItem::GetInventoryType }, { "GetAllowableClass", &LuaItem::GetAllowableClass }, - { "GetAllowableRace", &LuaItem::GetAllowableRace }, + //{ "GetAllowableRace", &LuaItem::GetAllowableRace }, { "GetItemLevel", &LuaItem::GetItemLevel }, { "GetRequiredLevel", &LuaItem::GetRequiredLevel }, #ifndef CATA - { "GetStatsCount", &LuaItem::GetStatsCount }, + //{ "GetStatsCount", &LuaItem::GetStatsCount }, #endif - { "GetRandomProperty", &LuaItem::GetRandomProperty }, - { "GetRandomSuffix", &LuaItem::GetRandomSuffix }, + //{ "GetRandomProperty", &LuaItem::GetRandomProperty }, + //{ "GetRandomSuffix", &LuaItem::GetRandomSuffix }, { "GetItemSet", &LuaItem::GetItemSet }, { "GetBagSize", &LuaItem::GetBagSize }, @@ -917,7 +933,7 @@ namespace LuaItem { "IsSoulBound", &LuaItem::IsSoulBound }, { "IsBoundAccountWide", &LuaItem::IsBoundAccountWide }, { "IsBoundByEnchant", &LuaItem::IsBoundByEnchant }, - { "IsNotBoundToPlayer", &LuaItem::IsNotBoundToPlayer }, + //{ "IsNotBoundToPlayer", &LuaItem::IsNotBoundToPlayer }, { "IsLocked", &LuaItem::IsLocked }, { "IsBag", &LuaItem::IsBag }, { "IsCurrencyToken", &LuaItem::IsCurrencyToken }, @@ -930,8 +946,8 @@ namespace LuaItem { "HasQuest", &LuaItem::HasQuest }, { "IsPotion", &LuaItem::IsPotion }, #ifndef CATA - { "IsWeaponVellum", &LuaItem::IsWeaponVellum }, - { "IsArmorVellum", &LuaItem::IsArmorVellum }, + //{ "IsWeaponVellum", &LuaItem::IsWeaponVellum }, + //{ "IsArmorVellum", &LuaItem::IsArmorVellum }, { "IsRefundExpired", &LuaItem::IsRefundExpired }, #endif { "IsConjuredConsumable", &LuaItem::IsConjuredConsumable }, diff --git a/methods/TrinityCore/MapMethods.h b/methods/TrinityCore/MapMethods.h index 7032e844d6..c60466a18d 100644 --- a/methods/TrinityCore/MapMethods.h +++ b/methods/TrinityCore/MapMethods.h @@ -95,6 +95,7 @@ namespace LuaMap return 1; } +#ifndef RETAIL /** * Returns the height of the [Map] at the given X and Y coordinates. * @@ -130,9 +131,10 @@ namespace LuaMap */ int GetDifficulty(Eluna* E, Map* map) { - E->Push(map->GetDifficulty()); + E->Push(map->GetMapDifficulty()); return 1; } +#endif /** * Returns the instance ID of the [Map]. @@ -167,6 +169,7 @@ namespace LuaMap return 1; } +#ifndef RETAIL /** * Returns the area ID of the [Map] at the specified X, Y, and Z coordinates. * @@ -191,6 +194,7 @@ namespace LuaMap #endif return 1; } +#endif /** * Returns a [WorldObject] by its GUID from the map if it is spawned. @@ -208,7 +212,7 @@ namespace LuaMap E->Push(eObjectAccessor()GetPlayer(map, guid)); break; case HIGHGUID_TRANSPORT: - case HIGHGUID_MO_TRANSPORT: + //case HIGHGUID_MO_TRANSPORT: case HIGHGUID_GAMEOBJECT: E->Push(map->GetGameObject(guid)); break; @@ -283,6 +287,7 @@ namespace LuaMap return 1; } +#ifndef RETAIL /** * Saves the [Map]'s instance data to the database. */ @@ -297,6 +302,7 @@ namespace LuaMap return 0; } +#endif /** * Returns a table with all the current [Player]s in the map @@ -367,14 +373,14 @@ namespace LuaMap { // Getters { "GetName", &LuaMap::GetName }, - { "GetDifficulty", &LuaMap::GetDifficulty }, + //{ "GetDifficulty", &LuaMap::GetDifficulty }, { "GetInstanceId", &LuaMap::GetInstanceId }, { "GetInstanceData", &LuaMap::GetInstanceData }, { "GetPlayerCount", &LuaMap::GetPlayerCount }, { "GetPlayers", &LuaMap::GetPlayers }, { "GetMapId", &LuaMap::GetMapId }, - { "GetAreaId", &LuaMap::GetAreaId }, - { "GetHeight", &LuaMap::GetHeight }, + //{ "GetAreaId", &LuaMap::GetAreaId }, + //{ "GetHeight", &LuaMap::GetHeight }, { "GetWorldObject", &LuaMap::GetWorldObject }, // Setters @@ -389,7 +395,7 @@ namespace LuaMap { "IsRaid", &LuaMap::IsRaid }, // Other - { "SaveInstanceData", &LuaMap::SaveInstanceData }, + //{ "SaveInstanceData", &LuaMap::SaveInstanceData }, { "Data", &LuaMap::Data }, { NULL, NULL, METHOD_REG_NONE } diff --git a/methods/TrinityCore/ObjectMethods.h b/methods/TrinityCore/ObjectMethods.h index b33e963045..7fb406a7d1 100644 --- a/methods/TrinityCore/ObjectMethods.h +++ b/methods/TrinityCore/ObjectMethods.h @@ -36,7 +36,7 @@ namespace LuaObject uint16 index = E->CHECKVAL(2); uint32 flag = E->CHECKVAL(3); - E->Push(obj->HasFlag(index, flag)); + E->Push(obj->HasDynamicFlag(flag)); return 1; } @@ -50,7 +50,7 @@ namespace LuaObject E->Push(obj->IsInWorld()); return 1; } - +#ifndef RETAIL /** * Returns the data at the specified index, casted to a signed 32-bit integer. * @@ -123,6 +123,7 @@ namespace LuaObject E->Push(obj->GetUInt16Value(index, offset)); return 1; } +#endif /** * Returns the scale/size of the [Object]. @@ -209,6 +210,7 @@ namespace LuaObject return 1; } +#ifndef RETAIL /** * Returns the data at the specified index, casted to an unsigned 64-bit integer. * @@ -221,6 +223,7 @@ namespace LuaObject E->Push(obj->GetUInt64Value(index)); return 1; } +#endif /** * Sets the specified flag in the data value at the specified index. @@ -237,10 +240,11 @@ namespace LuaObject uint16 index = E->CHECKVAL(2); uint32 flag = E->CHECKVAL(3); - obj->SetFlag(index, flag); + obj->SetDynamicFlag(flag); return 0; } +#ifndef RETAIL /** * Sets the data at the specified index to the given value, converted to a signed 32-bit integer. * @@ -346,19 +350,6 @@ namespace LuaObject return 0; } - /** - * Sets the [Object]'s scale/size to the given value. - * - * @param float scale - */ - int SetScale(Eluna* E, Object* obj) - { - float size = E->CHECKVAL(2); - - obj->SetObjectScale(size); - return 0; - } - /** * Sets the data at the specified index to the given value, converted to an unsigned 64-bit integer. * @@ -372,6 +363,19 @@ namespace LuaObject obj->SetUInt64Value(index, value); return 0; } +#endif + /** + * Sets the [Object]'s scale/size to the given value. + * + * @param float scale + */ + int SetScale(Eluna* E, Object* obj) + { + float size = E->CHECKVAL(2); + + obj->SetObjectScale(size); + return 0; + } /** * Removes a flag from the value at the specified index. @@ -384,7 +388,7 @@ namespace LuaObject uint16 index = E->CHECKVAL(2); uint32 flag = E->CHECKVAL(3); - obj->RemoveFlag(index, flag); + obj->RemoveDynamicFlag(flag); return 0; } @@ -459,16 +463,17 @@ namespace LuaObject { "GetEntry", &LuaObject::GetEntry }, { "GetGUID", &LuaObject::GetGUID }, { "GetGUIDLow", &LuaObject::GetGUIDLow }, - { "GetInt32Value", &LuaObject::GetInt32Value }, - { "GetUInt32Value", &LuaObject::GetUInt32Value }, - { "GetFloatValue", &LuaObject::GetFloatValue }, - { "GetByteValue", &LuaObject::GetByteValue }, - { "GetUInt16Value", &LuaObject::GetUInt16Value }, - { "GetUInt64Value", &LuaObject::GetUInt64Value }, + //{ "GetInt32Value", &LuaObject::GetInt32Value }, + //{ "GetUInt32Value", &LuaObject::GetUInt32Value }, + //{ "GetFloatValue", &LuaObject::GetFloatValue }, + //{ "GetByteValue", &LuaObject::GetByteValue }, + //{ "GetUInt16Value", &LuaObject::GetUInt16Value }, + //{ "GetUInt64Value", &LuaObject::GetUInt64Value }, { "GetScale", &LuaObject::GetScale }, { "GetTypeId", &LuaObject::GetTypeId }, // Setters +#ifndef RETAIL { "SetInt32Value", &LuaObject::SetInt32Value }, { "SetUInt32Value", &LuaObject::SetUInt32Value }, { "UpdateUInt32Value", &LuaObject::UpdateUInt32Value }, @@ -477,6 +482,16 @@ namespace LuaObject { "SetUInt16Value", &LuaObject::SetUInt16Value }, { "SetInt16Value", &LuaObject::SetInt16Value }, { "SetUInt64Value", &LuaObject::SetUInt64Value }, +#else + { "SetInt32Value", nullptr, METHOD_REG_NONE }, + { "SetUInt32Value", nullptr, METHOD_REG_NONE }, + { "UpdateUInt32Value", nullptr, METHOD_REG_NONE }, + { "SetFloatValue", nullptr, METHOD_REG_NONE }, + { "SetByteValue", nullptr, METHOD_REG_NONE }, + { "SetUInt16Value", nullptr, METHOD_REG_NONE }, + { "SetInt16Value", nullptr, METHOD_REG_NONE }, + { "SetUInt64Value", nullptr, METHOD_REG_NONE }, +#endif { "SetScale", &LuaObject::SetScale }, { "SetFlag", &LuaObject::SetFlag }, diff --git a/methods/TrinityCore/PlayerMethods.h b/methods/TrinityCore/PlayerMethods.h index 7efd583bc2..3411fc0a7a 100644 --- a/methods/TrinityCore/PlayerMethods.h +++ b/methods/TrinityCore/PlayerMethods.h @@ -38,7 +38,11 @@ namespace LuaPlayer int HasTalent(Eluna* E, Player* player) { uint32 spellId = E->CHECKVAL(2); +#ifndef RETAIL uint8 maxSpecs = MAX_TALENT_SPECS; +#else + uint8 maxSpecs = MAX_SPECIALIZATIONS; +#endif uint8 spec = E->CHECKVAL(3); if (spec >= maxSpecs) @@ -254,7 +258,7 @@ namespace LuaPlayer */ int CanUninviteFromGroup(Eluna* E, Player* player) { - E->Push(player->CanUninviteFromGroup() == ERR_PARTY_RESULT_OK); + E->Push(player->CanUninviteFromGroup(ObjectGuid::Empty, 0) == ERR_PARTY_RESULT_OK); return 1; } @@ -568,6 +572,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns 'true' if the [Player] is currently rested, 'false' otherwise. * @@ -578,6 +583,7 @@ namespace LuaPlayer E->Push(player->GetRestBonus() > 0.0f); return 1; } +#endif /** * Returns 'true' if the [Player] is currently in a [BattleGround] queue, 'false' otherwise. @@ -666,6 +672,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL int IsNeverVisible(Eluna* E, Player* player) { // Possibly add a bool var here @@ -676,6 +683,7 @@ namespace LuaPlayer #endif return 1; } +#endif /*int CanFlyInZone(Eluna* E, Player* player) { @@ -698,6 +706,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns the amount of available specs the [Player] currently has * @@ -719,8 +728,9 @@ namespace LuaPlayer E->Push(player->GetActiveSpec()); return 1; } +#endif -#ifndef CATA +#ifdef WOTLK /** * Returns the normal phase of the player instead of the actual phase possibly containing GM phase * @@ -739,7 +749,7 @@ namespace LuaPlayer */ int GetArenaPoints(Eluna* E, Player* player) { - E->Push(player->GetArenaPoints()); + E->Push(player->arena); return 1; } @@ -750,7 +760,7 @@ namespace LuaPlayer */ int GetHonorPoints(Eluna* E, Player* player) { - E->Push(player->GetHonorPoints()); + E->Push(player->GetHonorLevel()); return 1; } @@ -776,8 +786,11 @@ namespace LuaPlayer { uint32 spellId = E->CHECKVAL(2); - if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) - E->Push(player->GetSpellHistory()->GetRemainingCooldown(spellInfo)); + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE)) + { + Milliseconds remainingCooldown = player->GetSpellHistory()->GetRemainingCooldown(spellInfo); + E->Push(remainingCooldown.count()); + } else E->Push(0); @@ -864,6 +877,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns rested experience bonus * @@ -877,6 +891,7 @@ namespace LuaPlayer E->Push(player->GetXPRestBonus(xp)); return 1; } +#endif /** * Returns the [Player]s current [BattleGround] type ID @@ -1023,6 +1038,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns mana bonus from amount of intellect * @@ -1033,6 +1049,7 @@ namespace LuaPlayer E->Push(player->GetManaBonusFromIntellect()); return 1; } +#endif /** * Returns health bonus from amount of stamina @@ -1045,6 +1062,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns raid or dungeon difficulty * @@ -1058,6 +1076,7 @@ namespace LuaPlayer E->Push(player->GetDifficulty(isRaid)); return 1; } +#endif /** * Returns the [Player]s current guild rank @@ -1066,7 +1085,7 @@ namespace LuaPlayer */ int GetGuildRank(Eluna* E, Player* player) // TODO: Move to Guild Methods { -#ifdef CATA +#if defined CATA || defined RETAIL E->Push(player->GetGuildRank()); #else E->Push(player->GetRank()); @@ -1074,6 +1093,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns the [Player]s free talent point amount * @@ -1084,6 +1104,7 @@ namespace LuaPlayer E->Push(player->GetFreeTalentPoints()); return 1; } +#endif /** * Returns the name of the [Player]s current [Guild] @@ -1112,6 +1133,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns [Unit] target combo points are on * @@ -1133,6 +1155,7 @@ namespace LuaPlayer E->Push(player->GetComboPoints()); return 1; } +#endif /** * Returns the amount of time the [Player] has spent ingame @@ -1220,6 +1243,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns the [Player]s current resting bonus * @@ -1241,6 +1265,7 @@ namespace LuaPlayer E->Push(player->GetChatTag()); return 1; } +#endif /** * Returns an item in given bag on given slot. @@ -1405,6 +1430,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL /** * Returns the [Player]s lifetime Honorable Kills * @@ -1415,6 +1441,7 @@ namespace LuaPlayer E->Push(player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS)); return 1; } +#endif /** * Returns the [Player]s IP address @@ -1599,12 +1626,12 @@ namespace LuaPlayer if (apply) { - player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED); + //player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED); player->SetClientControl(player, 0); } else { - player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED); + //player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED | UNIT_FLAG_SILENCED); player->SetClientControl(player, 1); } return 0; @@ -1695,7 +1722,7 @@ namespace LuaPlayer if (!player->GetGuildId()) return 0; -#ifdef CATA +#if defined CATA || defined RETAIL player->SetGuildRank(rank); #else player->SetRank(rank); @@ -1703,6 +1730,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Sets the [Player]s free talent points to the amount specified for the current spec * @@ -1716,6 +1744,7 @@ namespace LuaPlayer player->SendTalentsInfoData(false); return 0; } +#endif /** * Sets the [Player]s reputation amount for the faction specified @@ -1750,6 +1779,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Sets the [Player]s rest bonus to the amount specified * @@ -1762,6 +1792,7 @@ namespace LuaPlayer player->SetRestBonus(bonus); return 0; } +#endif /** * Toggles whether the [Player] accepts whispers or not @@ -1866,12 +1897,17 @@ namespace LuaPlayer return luaL_argerror(E->L, 2, "valid Gender expected"); } +#ifdef RETAIL + player->SetGender(gender); +#else player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); player->SetByteValue(PLAYER_BYTES_3, 0, gender); +#endif player->InitDisplayIds(); return 0; } +#ifndef RETAIL #ifndef CATA /** * Sets the [Player]s Arena Points to the amount specified @@ -1909,6 +1945,7 @@ namespace LuaPlayer player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, val); return 0; } +#endif /** * Sets the [Player]s amount of money to copper specified @@ -1999,7 +2036,7 @@ namespace LuaPlayer } -#ifndef CATA +#ifdef WOTLK int SetMovement(Eluna* E, Player* player) { int32 pType = E->CHECKVAL(2); @@ -2009,6 +2046,7 @@ namespace LuaPlayer } #endif +#ifndef RETAIL /** * Resets the [Player]s pets talent points */ @@ -2018,6 +2056,7 @@ namespace LuaPlayer player->SendTalentsInfoData(true); return 0; } +#endif /** * Reset the [Player]s completed achievements @@ -2041,7 +2080,7 @@ namespace LuaPlayer return 0; } -#ifndef CATA +#ifdef WOTLK /** * Adds or detracts from the [Player]s current Arena Points * @@ -2128,10 +2167,11 @@ namespace LuaPlayer if (!quest || player->GetQuestStatus(entry) != QUEST_STATUS_COMPLETE) return 0; - player->RewardQuest(quest, 0, player); + player->RewardQuest(quest, LootItemType::Item, 0, player, false); return 0; } +#ifndef RETAIL /** * Sends an auction house window to the [Player] from the [Unit] specified * @@ -2144,6 +2184,7 @@ namespace LuaPlayer player->GetSession()->SendAuctionHello(unit->GET_GUID(), unit); return 0; } +#endif /** * Sends a flightmaster window to the [Player] from the [Creature] specified @@ -2176,7 +2217,7 @@ namespace LuaPlayer { WorldObject* obj = E->CHECKOBJ(2); - player->GetSession()->SendTabardVendorActivate(obj->GET_GUID()); + player->GetSession()->SendTabardVendorActivate(obj->GET_GUID(), TabardVendorType(0)); return 0; } @@ -2215,7 +2256,7 @@ namespace LuaPlayer { Creature* obj = E->CHECKOBJ(2); -#ifdef CATA +#if defined CATA || defined RETAIL player->GetSession()->SendTrainerList(obj, NULL); #else player->GetSession()->SendTrainerList(obj); @@ -2275,6 +2316,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Unbinds the [Player] from his instances except the one he currently is in. * @@ -2312,6 +2354,7 @@ namespace LuaPlayer } return 0; } +#endif /** * Forces the [Player] to leave a [BattleGround] @@ -2464,7 +2507,7 @@ namespace LuaPlayer */ int ResetTalentsCost(Eluna* E, Player* player) { -#ifdef CATA +#if defined CATA || defined RETAIL E->Push(player->GetNextResetTalentsCost()); #else E->Push(player->ResetTalentsCost()); @@ -2482,7 +2525,7 @@ namespace LuaPlayer bool no_cost = E->CHECKVAL(2, true); player->ResetTalents(no_cost); - player->SendTalentsInfoData(false); + player->SendTalentsInfoData(); return 0; } @@ -2499,6 +2542,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Clears the [Player]s combo points */ @@ -2522,6 +2566,7 @@ namespace LuaPlayer player->AddComboPoints(target, count); return 0; } +#endif /** * Gives [Quest] monster talked to credit @@ -2605,6 +2650,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Completes the given quest entry for the [Player] and tries to satisfy all quest requirements. * @@ -2699,7 +2745,9 @@ namespace LuaPlayer player->CompleteQuest(entry); return 0; } +#endif +#ifndef RETAIL /** * Tries to add the given quest entry for the [Player]. * @@ -2715,7 +2763,13 @@ namespace LuaPlayer return 0; // check item starting quest (it can work incorrectly if added without item in inventory) -#ifndef CATA +#ifdef RETAIL + ItemTemplateContainer const itc = sObjectMgr->GetItemTemplateStore(); + ItemTemplateContainer::const_iterator result = std::find_if(std::begin(itc), std::end(itc), [quest](ItemTemplateContainer::value_type const& value) + { + return value.second.ExtendedData->StartQuestID == quest->GetQuestId(); + }); +#elif WOTLK ItemTemplateContainer const& itc = sObjectMgr->GetItemTemplateStore(); auto itr = std::find_if(std::begin(itc), std::end(itc), [quest](ItemTemplateContainer::value_type const& value) { @@ -2724,8 +2778,7 @@ namespace LuaPlayer if (itr != std::end(itc)) return 0; - -#elif CATA +#else ItemTemplateContainer const* itc = sObjectMgr->GetItemTemplateStore(); ItemTemplateContainer::const_iterator result = std::find_if(itc->begin(), itc->end(), [quest](ItemTemplateContainer::value_type const& value) { @@ -2738,6 +2791,7 @@ namespace LuaPlayer return 0; } +#endif /** * Removes the given quest entry from the [Player]. @@ -2924,7 +2978,7 @@ namespace LuaPlayer if (!item) { uint32 entry = E->CHECKVAL(2); - item = Item::CreateItem(entry, 1, player); + item = Item::CreateItem(entry, 1, ItemContext::NONE, player); if (!item) return 1; @@ -2935,7 +2989,7 @@ namespace LuaPlayer return 1; } player->ItemAddedQuestCheck(entry, 1); - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, entry, 1); + //player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, entry, 1); } else { @@ -3009,7 +3063,7 @@ namespace LuaPlayer return 0; } -#ifndef CATA +#ifdef WOTLK /** * Advances all of the [Player]s weapon skills to the maximum amount available */ @@ -3020,6 +3074,7 @@ namespace LuaPlayer } #endif +#ifndef RETAIL /** * Advances all of the [Player]s skills to the amount specified * @@ -3064,6 +3119,7 @@ namespace LuaPlayer } return 0; } +#endif /** * Teleports a [Player] to the location specified @@ -3101,6 +3157,7 @@ namespace LuaPlayer return 1; } +#ifndef RETAIL int AddLifetimeKills(Eluna* E, Player* player) { uint32 val = E->CHECKVAL(2); @@ -3108,7 +3165,8 @@ namespace LuaPlayer player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val); return 0; } - +#endif + /** * Adds the given amount of the specified item entry to the player. * @@ -3130,7 +3188,7 @@ namespace LuaPlayer if (itemCount == 0 || dest.empty()) return 1; - Item* item = player->StoreNewItem(dest, itemId, true, GenerateItemRandomPropertyId(itemId)); + Item* item = player->StoreNewItem(dest, itemId, true, GenerateItemRandomBonusListId(itemId)); if (item) player->SendNewItem(item, itemCount, true, false); @@ -3164,6 +3222,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Removes specified amount of lifetime kills * @@ -3178,6 +3237,7 @@ namespace LuaPlayer player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills - val); return 0; } +#endif /** * Resets cooldown of the specified spell @@ -3208,7 +3268,7 @@ namespace LuaPlayer player->GetSpellHistory()->ResetCooldowns([category](SpellHistory::CooldownStorageType::iterator itr) -> bool { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itr->first, DIFFICULTY_NONE); return spellInfo && spellInfo->GetCategory() == category; }, update); @@ -3237,6 +3297,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Sends an Area Trigger Message to the [Player] * @@ -3249,6 +3310,7 @@ namespace LuaPlayer player->GetSession()->SendAreaTriggerMessage("%s", msg.c_str()); return 0; } +#endif /** * Sends a Notification to the [Player] @@ -3282,6 +3344,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Sends addon message to the [Player] receiver * @@ -3303,6 +3366,7 @@ namespace LuaPlayer receiver->GetSession()->SendPacket(&data); return 0; } +#endif /** * Kicks the [Player] from the server @@ -3345,6 +3409,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Learn the [Player] the talent specified by talent_id and talentRank * @@ -3357,9 +3422,10 @@ namespace LuaPlayer uint32 rank = E->CHECKVAL(3); player->LearnTalent(id, rank); - player->SendTalentsInfoData(false); + player->SendTalentsInfoData(); return 0; } +#endif /** * Remove cooldowns on spells that have less than 10 minutes of cooldown from the [Player], similarly to when you enter an arena. @@ -3385,6 +3451,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Adds a new item to the gossip menu shown to the [Player] on next call to [Player:GossipSendMenu]. * @@ -3413,9 +3480,11 @@ namespace LuaPlayer const char* _promptMsg = E->CHECKVAL(7, ""); uint32 _money = E->CHECKVAL(8, 0); + player->PlayerTalkClass->GetGossipMenu().AddMenuItem player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, GossipOptionIcon(_icon), msg, _sender, _intid, _promptMsg, _money, _code); return 0; } +#endif /** * Closes the [Player]s currently open Gossip Menu. @@ -3513,6 +3582,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL /** * Adds the gossip items to the [Player]'s gossip for the quests the given [WorldObject] can offer to the player. * @@ -3534,6 +3604,7 @@ namespace LuaPlayer } return 0; } +#endif /** * Shows a quest accepting window to the [Player] for the given quest. @@ -3550,7 +3621,7 @@ namespace LuaPlayer if (!quest) return 0; -#ifdef CATA +#if defined CATA || defined RETAIL player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GET_GUID(), activateAccept, true); #else player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GET_GUID(), activateAccept); @@ -3700,6 +3771,7 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL int BindToInstance(Eluna* /*E*/, Player* player) { player->BindToInstance(); @@ -3719,6 +3791,7 @@ namespace LuaPlayer return 1; } +#endif /*int GainSpellComboPoints(Eluna* E, Player* player) { @@ -3737,11 +3810,13 @@ namespace LuaPlayer return 0; } +#ifndef RETAIL int KilledPlayerCredit(Eluna* /*E*/, Player* player) { player->KilledPlayerCredit(); return 0; } +#endif int RemoveRewardedQuest(Eluna* E, Player* player) { @@ -3772,7 +3847,7 @@ namespace LuaPlayer if (petType >= MAX_PET_TYPE) return 0; - player->SummonPet(entry, x, y, z, o, (PetType)petType, despwtime); + player->SummonPet(entry, PetSaveMode(PET_SAVE_AS_CURRENT), x, y, z, o, despwtime); return 0; } @@ -3801,11 +3876,13 @@ namespace LuaPlayer { "GetGuild", &LuaPlayer::GetGuild }, { "GetAccountId", &LuaPlayer::GetAccountId }, { "GetAccountName", &LuaPlayer::GetAccountName }, -#ifndef CATA +#ifdef WOTLK { "GetArenaPoints", &LuaPlayer::GetArenaPoints }, { "GetHonorPoints", &LuaPlayer::GetHonorPoints }, #endif +#ifndef RETAIL { "GetLifetimeKills", &LuaPlayer::GetLifetimeKills }, +#endif { "GetPlayerIP", &LuaPlayer::GetPlayerIP }, { "GetLevelPlayedTime", &LuaPlayer::GetLevelPlayedTime }, { "GetTotalPlayedTime", &LuaPlayer::GetTotalPlayedTime }, @@ -3816,25 +3893,25 @@ namespace LuaPlayer { "GetReputation", &LuaPlayer::GetReputation }, { "GetEquippedItemBySlot", &LuaPlayer::GetEquippedItemBySlot }, { "GetQuestLevel", &LuaPlayer::GetQuestLevel }, - { "GetChatTag", &LuaPlayer::GetChatTag }, - { "GetRestBonus", &LuaPlayer::GetRestBonus }, + //{ "GetChatTag", &LuaPlayer::GetChatTag }, + //{ "GetRestBonus", &LuaPlayer::GetRestBonus }, #ifndef CATA - { "GetPhaseMaskForSpawn", &LuaPlayer::GetPhaseMaskForSpawn }, + //{ "GetPhaseMaskForSpawn", &LuaPlayer::GetPhaseMaskForSpawn }, #endif { "GetReqKillOrCastCurrentCount", &LuaPlayer::GetReqKillOrCastCurrentCount }, { "GetQuestStatus", &LuaPlayer::GetQuestStatus }, { "GetInGameTime", &LuaPlayer::GetInGameTime }, - { "GetComboPoints", &LuaPlayer::GetComboPoints }, - { "GetComboTarget", &LuaPlayer::GetComboTarget }, + //{ "GetComboPoints", &LuaPlayer::GetComboPoints }, + //{ "GetComboTarget", &LuaPlayer::GetComboTarget }, { "GetGuildName", &LuaPlayer::GetGuildName }, - { "GetFreeTalentPoints", &LuaPlayer::GetFreeTalentPoints }, - { "GetActiveSpec", &LuaPlayer::GetActiveSpec }, - { "GetSpecsCount", &LuaPlayer::GetSpecsCount }, + //{ "GetFreeTalentPoints", &LuaPlayer::GetFreeTalentPoints }, + //{ "GetActiveSpec", &LuaPlayer::GetActiveSpec }, + //{ "GetSpecsCount", &LuaPlayer::GetSpecsCount }, { "GetSpellCooldownDelay", &LuaPlayer::GetSpellCooldownDelay }, { "GetGuildRank", &LuaPlayer::GetGuildRank }, - { "GetDifficulty", &LuaPlayer::GetDifficulty }, + //{ "GetDifficulty", &LuaPlayer::GetDifficulty }, { "GetHealthBonusFromStamina", &LuaPlayer::GetHealthBonusFromStamina }, - { "GetManaBonusFromIntellect", &LuaPlayer::GetManaBonusFromIntellect }, + //{ "GetManaBonusFromIntellect", &LuaPlayer::GetManaBonusFromIntellect }, { "GetMaxSkillValue", &LuaPlayer::GetMaxSkillValue }, { "GetPureMaxSkillValue", &LuaPlayer::GetPureMaxSkillValue }, { "GetSkillValue", &LuaPlayer::GetSkillValue }, @@ -3846,7 +3923,7 @@ namespace LuaPlayer { "GetDrunkValue", &LuaPlayer::GetDrunkValue }, { "GetBattlegroundId", &LuaPlayer::GetBattlegroundId }, { "GetBattlegroundTypeId", &LuaPlayer::GetBattlegroundTypeId }, - { "GetXPRestBonus", &LuaPlayer::GetXPRestBonus }, + //{ "GetXPRestBonus", &LuaPlayer::GetXPRestBonus }, { "GetGroupInvite", &LuaPlayer::GetGroupInvite }, { "GetSubGroup", &LuaPlayer::GetSubGroup }, { "GetNextRandomRaidMember", &LuaPlayer::GetNextRandomRaidMember }, @@ -3861,7 +3938,7 @@ namespace LuaPlayer { "GetGossipTextId", &LuaPlayer::GetGossipTextId }, { "GetQuestRewardStatus", &LuaPlayer::GetQuestRewardStatus }, #ifndef CATA - { "GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue }, + //{ "GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue }, { "GetMailCount", &LuaPlayer::GetMailCount }, { "GetXP", &LuaPlayer::GetXP }, { "GetXPForNextLevel", &LuaPlayer::GetXPForNextLevel }, @@ -3869,33 +3946,33 @@ namespace LuaPlayer // Setters #ifndef CATA - { "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax }, + //{ "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax }, #endif - { "AdvanceSkill", &LuaPlayer::AdvanceSkill }, - { "AdvanceAllSkills", &LuaPlayer::AdvanceAllSkills }, - { "AddLifetimeKills", &LuaPlayer::AddLifetimeKills }, + //{ "AdvanceSkill", &LuaPlayer::AdvanceSkill }, + //{ "AdvanceAllSkills", &LuaPlayer::AdvanceAllSkills }, + //{ "AddLifetimeKills", &LuaPlayer::AddLifetimeKills }, { "SetCoinage", &LuaPlayer::SetCoinage }, { "SetKnownTitle", &LuaPlayer::SetKnownTitle }, { "UnsetKnownTitle", &LuaPlayer::UnsetKnownTitle }, { "SetBindPoint", &LuaPlayer::SetBindPoint }, #ifndef CATA - { "SetArenaPoints", &LuaPlayer::SetArenaPoints }, - { "SetHonorPoints", &LuaPlayer::SetHonorPoints }, + //{ "SetArenaPoints", &LuaPlayer::SetArenaPoints }, + //{ "SetHonorPoints", &LuaPlayer::SetHonorPoints }, #endif - { "SetLifetimeKills", &LuaPlayer::SetLifetimeKills }, + //{ "SetLifetimeKills", &LuaPlayer::SetLifetimeKills }, { "SetGameMaster", &LuaPlayer::SetGameMaster }, { "SetGMChat", &LuaPlayer::SetGMChat }, { "SetTaxiCheat", &LuaPlayer::SetTaxiCheat }, { "SetGMVisible", &LuaPlayer::SetGMVisible }, { "SetPvPDeath", &LuaPlayer::SetPvPDeath }, { "SetAcceptWhispers", &LuaPlayer::SetAcceptWhispers }, - { "SetRestBonus", &LuaPlayer::SetRestBonus }, + //{ "SetRestBonus", &LuaPlayer::SetRestBonus }, { "SetQuestStatus", &LuaPlayer::SetQuestStatus }, { "SetReputation", &LuaPlayer::SetReputation }, - { "SetFreeTalentPoints", &LuaPlayer::SetFreeTalentPoints }, + //{ "SetFreeTalentPoints", &LuaPlayer::SetFreeTalentPoints }, { "SetGuildRank", &LuaPlayer::SetGuildRank }, #ifndef CATA - { "SetMovement", &LuaPlayer::SetMovement }, + //{ "SetMovement", &LuaPlayer::SetMovement }, #endif { "SetSkill", &LuaPlayer::SetSkill }, { "SetFactionForRace", &LuaPlayer::SetFactionForRace }, @@ -3939,8 +4016,8 @@ namespace LuaPlayer { "HasAchieved", &LuaPlayer::HasAchieved }, { "SetAchievement", &LuaPlayer::SetAchievement }, { "CanUninviteFromGroup", &LuaPlayer::CanUninviteFromGroup }, - { "IsRested", &LuaPlayer::IsRested }, - { "IsNeverVisible", &LuaPlayer::IsNeverVisible }, + //{ "IsRested", &LuaPlayer::IsRested }, + //{ "IsNeverVisible", &LuaPlayer::IsNeverVisible }, { "IsVisibleForPlayer", &LuaPlayer::IsVisibleForPlayer }, { "IsUsingLfg", &LuaPlayer::IsUsingLfg }, { "HasQuestForItem", &LuaPlayer::HasQuestForItem }, @@ -3973,23 +4050,23 @@ namespace LuaPlayer #endif // Gossip - { "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem }, + //{ "GossipMenuAddItem", &LuaPlayer::GossipMenuAddItem }, { "GossipSendMenu", &LuaPlayer::GossipSendMenu }, { "GossipComplete", &LuaPlayer::GossipComplete }, { "GossipClearMenu", &LuaPlayer::GossipClearMenu }, // Other { "SendBroadcastMessage", &LuaPlayer::SendBroadcastMessage }, - { "SendAreaTriggerMessage", &LuaPlayer::SendAreaTriggerMessage }, + //{ "SendAreaTriggerMessage", &LuaPlayer::SendAreaTriggerMessage }, { "SendNotification", &LuaPlayer::SendNotification }, { "SendPacket", &LuaPlayer::SendPacket }, - { "SendAddonMessage", &LuaPlayer::SendAddonMessage }, + //{ "SendAddonMessage", &LuaPlayer::SendAddonMessage }, { "ModifyMoney", &LuaPlayer::ModifyMoney }, { "LearnSpell", &LuaPlayer::LearnSpell }, - { "LearnTalent", &LuaPlayer::LearnTalent }, + //{ "LearnTalent", &LuaPlayer::LearnTalent }, { "RemoveArenaSpellCooldowns", &LuaPlayer::RemoveArenaSpellCooldowns }, { "RemoveItem", &LuaPlayer::RemoveItem }, - { "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills }, + //{ "RemoveLifetimeKills", &LuaPlayer::RemoveLifetimeKills }, { "ResurrectPlayer", &LuaPlayer::ResurrectPlayer }, { "EquipItem", &LuaPlayer::EquipItem }, { "ResetSpellCooldown", &LuaPlayer::ResetSpellCooldown }, @@ -4002,26 +4079,26 @@ namespace LuaPlayer { "Yell", &LuaPlayer::Yell }, { "TextEmote", &LuaPlayer::TextEmote }, { "Whisper", &LuaPlayer::Whisper }, - { "CompleteQuest", &LuaPlayer::CompleteQuest }, + //{ "CompleteQuest", &LuaPlayer::CompleteQuest }, { "IncompleteQuest", &LuaPlayer::IncompleteQuest }, { "FailQuest", &LuaPlayer::FailQuest }, - { "AddQuest", &LuaPlayer::AddQuest }, + //{ "AddQuest", &LuaPlayer::AddQuest }, { "RemoveQuest", &LuaPlayer::RemoveQuest }, { "RemoveActiveQuest", &LuaPlayer::RemoveActiveQuest }, { "RemoveRewardedQuest", &LuaPlayer::RemoveRewardedQuest }, { "AreaExploredOrEventHappens", &LuaPlayer::AreaExploredOrEventHappens }, { "GroupEventHappens", &LuaPlayer::GroupEventHappens }, { "KilledMonsterCredit", &LuaPlayer::KilledMonsterCredit }, - { "KilledPlayerCredit", &LuaPlayer::KilledPlayerCredit }, + //{ "KilledPlayerCredit", &LuaPlayer::KilledPlayerCredit }, { "KillGOCredit", &LuaPlayer::KillGOCredit }, { "TalkedToCreature", &LuaPlayer::TalkedToCreature }, - { "ResetPetTalents", &LuaPlayer::ResetPetTalents }, - { "AddComboPoints", &LuaPlayer::AddComboPoints }, - { "ClearComboPoints", &LuaPlayer::ClearComboPoints }, + //{ "ResetPetTalents", &LuaPlayer::ResetPetTalents }, + //{ "AddComboPoints", &LuaPlayer::AddComboPoints }, + //{ "ClearComboPoints", &LuaPlayer::ClearComboPoints }, { "RemoveSpell", &LuaPlayer::RemoveSpell }, { "ResetTalents", &LuaPlayer::ResetTalents }, { "ResetTalentsCost", &LuaPlayer::ResetTalentsCost }, - { "AddTalent", &LuaPlayer::AddTalent }, + //{ "AddTalent", &LuaPlayer::AddTalent }, { "RemoveFromGroup", &LuaPlayer::RemoveFromGroup }, { "KillPlayer", &LuaPlayer::KillPlayer }, { "DurabilityLossAll", &LuaPlayer::DurabilityLossAll }, @@ -4032,13 +4109,13 @@ namespace LuaPlayer { "DurabilityRepairAll", &LuaPlayer::DurabilityRepairAll }, { "DurabilityRepair", &LuaPlayer::DurabilityRepair }, #ifndef CATA - { "ModifyHonorPoints", &LuaPlayer::ModifyHonorPoints }, - { "ModifyArenaPoints", &LuaPlayer::ModifyArenaPoints }, + //{ "ModifyHonorPoints", &LuaPlayer::ModifyHonorPoints }, + //{ "ModifyArenaPoints", &LuaPlayer::ModifyArenaPoints }, #endif { "LeaveBattleground", &LuaPlayer::LeaveBattleground }, - { "BindToInstance", &LuaPlayer::BindToInstance }, - { "UnbindInstance", &LuaPlayer::UnbindInstance }, - { "UnbindAllInstances", &LuaPlayer::UnbindAllInstances }, + //{ "BindToInstance", &LuaPlayer::BindToInstance }, + //{ "UnbindInstance", &LuaPlayer::UnbindInstance }, + //{ "UnbindAllInstances", &LuaPlayer::UnbindAllInstances }, { "RemoveFromBattlegroundRaid", &LuaPlayer::RemoveFromBattlegroundRaid }, { "ResetAchievements", &LuaPlayer::ResetAchievements }, { "KickPlayer", &LuaPlayer::KickPlayer }, @@ -4051,11 +4128,11 @@ namespace LuaPlayer { "SendTaxiMenu", &LuaPlayer::SendTaxiMenu }, { "SendUpdateWorldState", &LuaPlayer::SendUpdateWorldState }, { "RewardQuest", &LuaPlayer::RewardQuest }, - { "SendAuctionMenu", &LuaPlayer::SendAuctionMenu }, + //{ "SendAuctionMenu", &LuaPlayer::SendAuctionMenu }, { "SendShowMailBox", &LuaPlayer::SendShowMailBox }, { "StartTaxi", &LuaPlayer::StartTaxi }, { "GossipSendPOI", &LuaPlayer::GossipSendPOI }, - { "GossipAddQuests", &LuaPlayer::GossipAddQuests }, + //{ "GossipAddQuests", &LuaPlayer::GossipAddQuests }, { "SendQuestTemplate", &LuaPlayer::SendQuestTemplate }, { "SpawnBones", &LuaPlayer::SpawnBones }, { "RemovedInsignia", &LuaPlayer::RemovedInsignia }, diff --git a/methods/TrinityCore/QuestMethods.h b/methods/TrinityCore/QuestMethods.h index 0e2c24011e..a333cdf5b6 100644 --- a/methods/TrinityCore/QuestMethods.h +++ b/methods/TrinityCore/QuestMethods.h @@ -53,7 +53,7 @@ namespace LuaQuest { uint32 flag = E->CHECKVAL(2); - E->Push(quest->HasFlag(flag)); + E->Push(quest->HasFlag(QuestFlags(flag))); return 1; } @@ -90,6 +90,7 @@ namespace LuaQuest return 1; } +#ifndef RETAIL /** * Returns the [Quest]'s level. * @@ -111,6 +112,7 @@ namespace LuaQuest E->Push(quest->GetMinLevel()); return 1; } +#endif /** * Returns the next [Quest] entry ID. @@ -165,7 +167,7 @@ namespace LuaQuest */ int GetType(Eluna* E, Quest* quest) { -#ifdef CATA +#ifndef WOTLK E->Push(quest->GetQuestType()); #else E->Push(quest->GetType()); @@ -188,9 +190,9 @@ namespace LuaQuest { // Getters { "GetId", &LuaQuest::GetId }, - { "GetLevel", &LuaQuest::GetLevel }, + //{ "GetLevel", &LuaQuest::GetLevel }, { "GetMaxLevel", &LuaQuest::GetMaxLevel }, - { "GetMinLevel", &LuaQuest::GetMinLevel }, + //{ "GetMinLevel", &LuaQuest::GetMinLevel }, { "GetNextQuestId", &LuaQuest::GetNextQuestId }, { "GetPrevQuestId", &LuaQuest::GetPrevQuestId }, { "GetNextQuestInChain", &LuaQuest::GetNextQuestInChain }, diff --git a/methods/TrinityCore/SpellMethods.h b/methods/TrinityCore/SpellMethods.h index 30c4a89161..c23ffe55c1 100644 --- a/methods/TrinityCore/SpellMethods.h +++ b/methods/TrinityCore/SpellMethods.h @@ -58,6 +58,7 @@ namespace LuaSpell return 1; } +#ifndef RETAIL /** * Returns the power cost of the [Spell]. * @@ -68,6 +69,7 @@ namespace LuaSpell E->Push(spell->GetPowerCost()); return 1; } +#endif /** * Returns the spell duration of the [Spell]. @@ -177,7 +179,7 @@ namespace LuaSpell { "GetCastTime", &LuaSpell::GetCastTime }, { "GetEntry", &LuaSpell::GetEntry }, { "GetDuration", &LuaSpell::GetDuration }, - { "GetPowerCost", &LuaSpell::GetPowerCost }, + //{ "GetPowerCost", &LuaSpell::GetPowerCost }, { "GetTargetDest", &LuaSpell::GetTargetDest }, { "GetTarget", &LuaSpell::GetTarget }, diff --git a/methods/TrinityCore/UnitMethods.h b/methods/TrinityCore/UnitMethods.h index 0165b8eb03..57b6095346 100644 --- a/methods/TrinityCore/UnitMethods.h +++ b/methods/TrinityCore/UnitMethods.h @@ -58,7 +58,7 @@ namespace LuaUnit int32 immunity = E->CHECKVAL(2); bool apply = E->CHECKVAL(3, true); - unit->ApplySpellImmune(0, 5, immunity, apply); + unit->ApplySpellImmune(0, SpellImmunity(IMMUNITY_MECHANIC), immunity, apply); return 0; } /** @@ -117,7 +117,7 @@ namespace LuaUnit */ int IsRooted(Eluna* E, Unit* unit) { - E->Push(unit->IsRooted() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); + E->Push(unit->HasRootAura() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT)); return 1; } @@ -231,7 +231,7 @@ namespace LuaUnit */ int IsSpiritGuide(Eluna* E, Unit* unit) { - E->Push(unit->IsSpiritGuide()); + E->Push(unit->IsSpiritService()); return 1; } @@ -656,6 +656,7 @@ namespace LuaUnit return 1; } +#ifndef RETAIL /** * Returns the [Unit]'s base spell power * @@ -672,6 +673,7 @@ namespace LuaUnit E->Push(unit->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + spellschool)); return 1; } +#endif /** * Returns the [Unit]'s current victim target or nil. @@ -997,6 +999,7 @@ namespace LuaUnit return 1; } +#ifndef RETAIL /** * Returns the [Unit]'s class' name in given or default locale or nil. * @@ -1066,6 +1069,7 @@ namespace LuaUnit E->Push(entry->Name[locale]); return 1; } +#endif /** * Returns the [Unit]'s faction ID. @@ -1379,7 +1383,7 @@ namespace LuaUnit { player->GiveLevel(newlevel); player->InitTalentForLevel(); - player->SetUInt32Value(PLAYER_XP, 0); + // player->SetUInt32Value(PLAYER_XP, 0); } else unit->SetLevel(newlevel); @@ -1550,7 +1554,7 @@ namespace LuaUnit int SetNativeDisplayId(Eluna* E, Unit* unit) { uint32 model = E->CHECKVAL(2); -#ifndef CATA +#ifdef WOTLK unit->SetNativeDisplayId(model); #else unit->SetDisplayId(model, true); @@ -1646,6 +1650,7 @@ namespace LuaUnit return 0; } +#ifndef RETAIL /** * Sets the [Unit]'s FFA flag on or off. * @@ -1691,6 +1696,7 @@ namespace LuaUnit return 0; } +#endif int SetCritterGUID(Eluna* E, Unit* unit) { @@ -1801,6 +1807,7 @@ namespace LuaUnit return 0; } +#ifndef RETAIL /** * Makes the [Unit] perform the given emote continuously. * @@ -1813,6 +1820,7 @@ namespace LuaUnit unit->SetUInt32Value(UNIT_NPC_EMOTESTATE, emoteId); return 0; } +#endif /** * Returns calculated percentage from Health @@ -1836,6 +1844,7 @@ namespace LuaUnit return 1; } +#ifndef RETAIL /** * Sends chat message to [Player] * @@ -1862,6 +1871,7 @@ namespace LuaUnit target->GetSession()->SendPacket(&data); return 0; } +#endif /** * Stops the [Unit]'s movement @@ -1977,7 +1987,7 @@ namespace LuaUnit { Unit* target = E->CHECKOBJ(2); uint32 time = E->CHECKVAL(3, 0); - unit->GetMotionMaster()->MoveFleeing(target, time); + unit->GetMotionMaster()->MoveFleeing(target, Milliseconds(time)); return 0; } @@ -2124,7 +2134,7 @@ namespace LuaUnit uint32 spell = E->CHECKVAL(3); bool triggered = E->CHECKVAL(4, false); - SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell); + SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE); if (!spellEntry) return 0; @@ -2132,6 +2142,7 @@ namespace LuaUnit return 0; } +#ifndef RETAIL /** * Casts the [Spell] at target [Unit] with custom basepoints or casters. * See also [Unit:CastSpell]. @@ -2176,6 +2187,7 @@ namespace LuaUnit unit->CastSpell(target, spell, args); return 0; } +#endif /** * Makes the [Unit] cast the spell to the given coordinates, used for area effect spells. @@ -2269,7 +2281,7 @@ namespace LuaUnit uint32 spell = E->CHECKVAL(2); Unit* target = E->CHECKOBJ(3); - SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell); + SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE); if (!spellEntry) return 1; @@ -2354,6 +2366,7 @@ namespace LuaUnit return 0; } +#ifndef RETAIL /** * Makes the [Unit] damage the target [Unit] * @@ -2434,6 +2447,7 @@ namespace LuaUnit unit->DealSpellDamage(&dmgInfo, true); return 0; } +#endif /** * Makes the [Unit] heal the target [Unit] with given spell @@ -2450,7 +2464,7 @@ namespace LuaUnit uint32 amount = E->CHECKVAL(4); bool critical = E->CHECKVAL(5, false); - if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) + if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell, DIFFICULTY_NONE)) { HealInfo healInfo(unit, target, amount, info, info->GetSchoolMask()); unit->HealBySpell(healInfo, critical); @@ -2568,8 +2582,8 @@ namespace LuaUnit { "GetClass", &LuaUnit::GetClass }, { "GetRaceMask", &LuaUnit::GetRaceMask }, { "GetClassMask", &LuaUnit::GetClassMask }, - { "GetRaceAsString", &LuaUnit::GetRaceAsString }, - { "GetClassAsString", &LuaUnit::GetClassAsString }, + //{ "GetRaceAsString", &LuaUnit::GetRaceAsString }, + //{ "GetClassAsString", &LuaUnit::GetClassAsString }, { "GetAura", &LuaUnit::GetAura }, { "GetFaction", &LuaUnit::GetFaction }, { "GetCurrentSpell", &LuaUnit::GetCurrentSpell }, @@ -2591,7 +2605,7 @@ namespace LuaUnit { "GetVictim", &LuaUnit::GetVictim }, { "GetSpeed", &LuaUnit::GetSpeed }, { "GetStat", &LuaUnit::GetStat }, - { "GetBaseSpellPower", &LuaUnit::GetBaseSpellPower }, + //{ "GetBaseSpellPower", &LuaUnit::GetBaseSpellPower }, { "GetVehicleKit", &LuaUnit::GetVehicleKit }, { "GetVehicle", &LuaUnit::GetVehicle }, { "GetMovementType", &LuaUnit::GetMovementType }, @@ -2614,8 +2628,8 @@ namespace LuaUnit { "SetConfused", &LuaUnit::SetConfused }, { "SetFeared", &LuaUnit::SetFeared }, { "SetPvP", &LuaUnit::SetPvP }, - { "SetFFA", &LuaUnit::SetFFA }, - { "SetSanctuary", &LuaUnit::SetSanctuary }, + //{ "SetFFA", &LuaUnit::SetFFA }, + //{ "SetSanctuary", &LuaUnit::SetSanctuary }, { "SetCanFly", &LuaUnit::SetCanFly }, { "SetVisible", &LuaUnit::SetVisible }, { "SetOwnerGUID", &LuaUnit::SetOwnerGUID }, @@ -2687,14 +2701,14 @@ namespace LuaUnit { "SendUnitSay", &LuaUnit::SendUnitSay }, { "SendUnitYell", &LuaUnit::SendUnitYell }, { "CastSpell", &LuaUnit::CastSpell }, - { "CastCustomSpell", &LuaUnit::CastCustomSpell }, + //{ "CastCustomSpell", &LuaUnit::CastCustomSpell }, { "CastSpellAoF", &LuaUnit::CastSpellAoF }, { "Kill", &LuaUnit::Kill }, { "StopSpellCast", &LuaUnit::StopSpellCast }, { "InterruptSpell", &LuaUnit::InterruptSpell }, - { "SendChatMessageToPlayer", &LuaUnit::SendChatMessageToPlayer }, + //{ "SendChatMessageToPlayer", &LuaUnit::SendChatMessageToPlayer }, { "PerformEmote", &LuaUnit::PerformEmote }, - { "EmoteState", &LuaUnit::EmoteState }, + //{ "EmoteState", &LuaUnit::EmoteState }, { "CountPctFromCurHealth", &LuaUnit::CountPctFromCurHealth }, { "CountPctFromMaxHealth", &LuaUnit::CountPctFromMaxHealth }, { "Dismount", &LuaUnit::Dismount }, @@ -2719,7 +2733,7 @@ namespace LuaUnit { "MoveStop", &LuaUnit::MoveStop }, { "MoveExpire", &LuaUnit::MoveExpire }, { "MoveClear", &LuaUnit::MoveClear }, - { "DealDamage", &LuaUnit::DealDamage }, + //{ "DealDamage", &LuaUnit::DealDamage }, { "DealHeal", &LuaUnit::DealHeal }, // Not implemented methods diff --git a/methods/TrinityCore/VehicleMethods.h b/methods/TrinityCore/VehicleMethods.h index 1fdeb6d29b..3c26b7e45e 100644 --- a/methods/TrinityCore/VehicleMethods.h +++ b/methods/TrinityCore/VehicleMethods.h @@ -72,7 +72,7 @@ namespace LuaVehicle Unit* passenger = E->CHECKOBJ(2); int8 seatId = E->CHECKVAL(3); -#ifndef CATA +#ifdef WOTLK vehicle->AddPassenger(passenger, seatId); #else vehicle->AddVehiclePassenger(passenger, seatId); @@ -110,5 +110,4 @@ namespace LuaVehicle { NULL, NULL, METHOD_REG_NONE } }; } - #endif // VEHICLEMETHODS_H diff --git a/methods/TrinityCore/WorldObjectMethods.h b/methods/TrinityCore/WorldObjectMethods.h index 497064c742..dcda2c0d0d 100644 --- a/methods/TrinityCore/WorldObjectMethods.h +++ b/methods/TrinityCore/WorldObjectMethods.h @@ -8,7 +8,6 @@ #define WORLDOBJECTMETHODS_H #include "LuaValue.h" - /*** * Inherits all methods from: [Object] */ @@ -43,7 +42,7 @@ namespace LuaWorldObject */ int GetPhaseMask(Eluna* E, WorldObject* obj) { -#ifdef CATA +#if defined CATA || defined RETAIL EventMap event; E->Push(event.GetPhaseMask()); #else @@ -61,7 +60,7 @@ namespace LuaWorldObject int SetPhaseMask(Eluna* E, WorldObject* obj) { uint32 phaseMask = E->CHECKVAL(2); -#ifdef CATA +#if defined CATA || defined RETAIL EventMap event; event.SetPhase(phaseMask); #else @@ -1066,9 +1065,13 @@ namespace LuaWorldObject uint32 musicid = E->CHECKVAL(2); Player* player = E->CHECKOBJ(3, false); +#ifdef RETAIL + if (!sSoundKitStore.LookupEntry(musicid)) + musicid = 0; +#else if (!sSoundEntriesStore.LookupEntry(musicid)) musicid = 0; - +#endif WorldPackets::Misc::PlayMusic playMusic(musicid); const WorldPacket* data = playMusic.Write(); @@ -1095,7 +1098,11 @@ namespace LuaWorldObject { uint32 soundId = E->CHECKVAL(2); Player* player = E->CHECKOBJ(3, false); +#ifdef RETAIL + if (!sSoundKitStore.LookupEntry(soundId)) +#else if (!sSoundEntriesStore.LookupEntry(soundId)) +#endif return 0; if (player) @@ -1122,7 +1129,11 @@ namespace LuaWorldObject { uint32 soundId = E->CHECKVAL(2); Player* player = E->CHECKOBJ(3, false); +#ifdef RETAIL + if (!sSoundKitStore.LookupEntry(soundId)) +#else if (!sSoundEntriesStore.LookupEntry(soundId)) +#endif return 0; if (player) diff --git a/methods/TrinityCore/WorldPacketMethods.h b/methods/TrinityCore/WorldPacketMethods.h index 86d3bbdb3f..4cd8850a05 100644 --- a/methods/TrinityCore/WorldPacketMethods.h +++ b/methods/TrinityCore/WorldPacketMethods.h @@ -42,6 +42,7 @@ namespace LuaPacket return 1; } +#ifndef RETAIL /** * Sets the opcode of the [WorldPacket] to the specified opcode. * @@ -56,6 +57,7 @@ namespace LuaPacket packet->SetOpcode((OpcodesList)opcode); return 0; } +#endif /** * Reads and returns a signed 8-bit integer value from the [WorldPacket]. @@ -314,7 +316,7 @@ namespace LuaPacket { "GetSize", &LuaPacket::GetSize }, // Setters - { "SetOpcode", &LuaPacket::SetOpcode }, + //{ "SetOpcode", &LuaPacket::SetOpcode }, // Readers { "ReadByte", &LuaPacket::ReadByte },