From 112d10e60c716720619dd6d2a3ac25f3883e9da1 Mon Sep 17 00:00:00 2001 From: Niam5 Date: Thu, 15 Jun 2023 18:48:58 -0700 Subject: [PATCH] Cata Preservation Project Changes Cata Preservation Project Changes --- ElunaCreatureAI.h | 8 ++- ElunaIncludes.h | 11 ++- ElunaUtility.cpp | 8 ++- GroupHooks.cpp | 11 +++ GuildHooks.cpp | 57 ++++++++++++++++ ItemHooks.cpp | 8 +++ LuaEngine.h | 13 ++++ PlayerHooks.cpp | 27 ++++++++ README.md | 2 + TrinityCore/BattleGroundMethods.h | 4 ++ TrinityCore/CreatureMethods.h | 10 +++ TrinityCore/GameObjectMethods.h | 6 ++ TrinityCore/GlobalMethods.h | 66 ++++++++++++++++++ TrinityCore/GuildMethods.h | 6 ++ TrinityCore/ItemMethods.h | 108 +++++++++++++++++++++++++++++- TrinityCore/MapMethods.h | 10 +++ TrinityCore/PlayerMethods.h | 101 ++++++++++++++++++++++++++++ TrinityCore/QuestMethods.h | 4 ++ TrinityCore/UnitMethods.h | 4 ++ TrinityCore/VehicleMethods.h | 4 ++ TrinityCore/WorldObjectMethods.h | 30 +++++++++ 21 files changed, 492 insertions(+), 6 deletions(-) diff --git a/ElunaCreatureAI.h b/ElunaCreatureAI.h index 24b1d43f61..413d0fc7e7 100644 --- a/ElunaCreatureAI.h +++ b/ElunaCreatureAI.h @@ -117,7 +117,9 @@ struct ElunaCreatureAI : CreatureAI // Called at any Damage from any attacker (before damage apply) #if defined AZEROTHCORE void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask) override -#elif defined(TRINITY) || CMANGOS +#elif ((defined (TRINITY) || CMANGOS) && !defined CATA) + void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override +#elif defined CATA && defined CMANGOS void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType damageType, SpellInfo const* spellInfo) override #else void DamageTaken(Unit* attacker, uint32& damage) override @@ -127,7 +129,7 @@ struct ElunaCreatureAI : CreatureAI { #if defined AZEROTHCORE ScriptedAI::DamageTaken(attacker, damage, damagetype, damageSchoolMask); -#elif defined TRINITY +#elif defined TRINITY && !defined CATA ScriptedAI::DamageTaken(attacker, damage, damageType, spellInfo); #elif defined CMANGOS CreatureAI::DamageTaken(attacker, damage, damageType, spellInfo); @@ -341,7 +343,7 @@ struct ElunaCreatureAI : CreatureAI #if defined TRINITY || AZEROTHCORE -#if defined TRINITY +#if defined TRINITY && !defined CATA // Called when the creature is summoned successfully by other creature void IsSummonedBy(WorldObject* summoner) override { diff --git a/ElunaIncludes.h b/ElunaIncludes.h index 53adcc4494..1f82c42455 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -16,6 +16,9 @@ #include "Chat.h" #include "Channel.h" #include "DBCStores.h" +#if defined CATA && defined TRINITY +#include "DB2Stores.h" +#endif #include "GameEventMgr.h" #include "GossipDef.h" #include "GridNotifiers.h" @@ -134,7 +137,10 @@ #endif #endif -#ifndef CLASSIC +#if (defined(TRINITY) && defined(CATA)) +typedef OpcodeServer OpcodesList; + +#elif !defined CLASSIC typedef Opcodes OpcodesList; #endif @@ -161,6 +167,9 @@ typedef Opcodes OpcodesList; #ifdef TRINITY #define CORE_NAME "TrinityCore" #define REGEN_TIME_FULL +#ifdef CATA +#define NUM_MSG_TYPES NUM_OPCODE_HANDLERS +#endif #endif #ifdef AZEROTHCORE diff --git a/ElunaUtility.cpp b/ElunaUtility.cpp index 8e8fcb4210..6d080dc829 100644 --- a/ElunaUtility.cpp +++ b/ElunaUtility.cpp @@ -97,7 +97,13 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u) { if (i_obj_fact) { -#if defined TRINITY || AZEROTHCORE || CMANGOS +#if ((defined TRINITY || AZEROTHCORE || CMANGOS) && !defined CATA) + if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1)) + return false; +#elif defined CATA && defined TRINITY + 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; #else diff --git a/GroupHooks.cpp b/GroupHooks.cpp index f674957ad7..fbc86ee9b4 100644 --- a/GroupHooks.cpp +++ b/GroupHooks.cpp @@ -61,6 +61,16 @@ void Eluna::OnDisband(Group* group) CallAllFunctions(GroupEventBindings, key); } +#if defined (TRINITY) && defined (CATA) +void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupFlags groupType) +{ + START_HOOK(GROUP_EVENT_ON_CREATE); + Push(group); + Push(leaderGuid); + Push(groupType); + CallAllFunctions(GroupEventBindings, key); +} +#else void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType) { START_HOOK(GROUP_EVENT_ON_CREATE); @@ -69,3 +79,4 @@ void Eluna::OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType) Push(groupType); CallAllFunctions(GroupEventBindings, key); } +#endif diff --git a/GuildHooks.cpp b/GuildHooks.cpp index 3662ef1f9a..3bf1b7260c 100644 --- a/GuildHooks.cpp +++ b/GuildHooks.cpp @@ -97,6 +97,35 @@ void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, b CleanUpStack(4); } +#ifdef CATA +void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair) +{ + START_HOOK(GUILD_EVENT_ON_MONEY_WITHDRAW); + Push(guild); + Push(player); + Push(amount); + Push(isRepair); // isRepair not a part of Mangos, implement? + int amountIndex = lua_gettop(L) - 1; + int n = SetupStack(GuildEventBindings, key, 4); + + while (n > 0) + { + int r = CallOneFunction(n--, 4, 1); + + if (lua_isnumber(L, r)) + { + amount = CHECKVAL(L, r); + // Update the stack for subsequent calls. + ReplaceArgument(amount, amountIndex); + } + + lua_pop(L, 1); + } + + CleanUpStack(4); +} +#endif + void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount) { START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT); @@ -123,6 +152,34 @@ void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount) CleanUpStack(3); } +#ifdef CATA +void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint64& amount) +{ + START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT); + Push(guild); + Push(player); + Push(amount); + int amountIndex = lua_gettop(L); + int n = SetupStack(GuildEventBindings, key, 3); + + while (n > 0) + { + int r = CallOneFunction(n--, 3, 1); + + if (lua_isnumber(L, r)) + { + amount = CHECKVAL(L, r); + // Update the stack for subsequent calls. + ReplaceArgument(amount, amountIndex); + } + + lua_pop(L, 1); + } + + CleanUpStack(3); +} +#endif + void Eluna::OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId, bool isDestBank, uint8 destContainer, uint8 destSlotId) { diff --git a/ItemHooks.cpp b/ItemHooks.cpp index ddd02233b9..1e5985ce89 100644 --- a/ItemHooks.cpp +++ b/ItemHooks.cpp @@ -118,9 +118,17 @@ bool Eluna::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targ bool Eluna::OnExpire(Player* pPlayer, ItemTemplate const* pProto) { +#if defined TRINITY && CATA + START_HOOK_WITH_RETVAL(ITEM_EVENT_ON_EXPIRE, pProto->BasicData->ID, false); +#else START_HOOK_WITH_RETVAL(ITEM_EVENT_ON_EXPIRE, pProto->ItemId, false); +#endif Push(pPlayer); +#if defined TRINITY && CATA + Push(pProto->BasicData->ID); +#else Push(pProto->ItemId); +#endif return CallAllFunctionsBool(ItemEventBindings, key); } diff --git a/LuaEngine.h b/LuaEngine.h index 43fcb47d68..b778aeee60 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -464,6 +464,9 @@ 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 + void OnMoneyChanged(Player* pPlayer, int64& amount); +#endif void OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim); void OnReputationChange(Player* pPlayer, uint32 factionID, int32& standing, bool incremental); void OnDuelRequest(Player* pTarget, Player* pChallenger); @@ -518,7 +521,13 @@ class ELUNA_GAME_API Eluna 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 + void OnMemberWitdrawMoney(Guild* guild, Player* player, uint64& amount, bool isRepair); +#endif void OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount); +#ifdef CATA + 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); void OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank); void OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId); @@ -529,7 +538,11 @@ class ELUNA_GAME_API Eluna void OnRemoveMember(Group* group, ObjectGuid guid, uint8 method); void OnChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid); void OnDisband(Group* group); +#if defined (TRINITY) && defined (CATA) + void OnCreate(Group* group, ObjectGuid leaderGuid, GroupFlags groupType); +#else void OnCreate(Group* group, ObjectGuid leaderGuid, GroupType groupType); +#endif /* Map */ void OnCreate(Map* map); diff --git a/PlayerHooks.cpp b/PlayerHooks.cpp index 0ef56f6d6b..a0aec36bcd 100644 --- a/PlayerHooks.cpp +++ b/PlayerHooks.cpp @@ -225,6 +225,33 @@ void Eluna::OnMoneyChanged(Player* pPlayer, int32& amount) CleanUpStack(2); } +#ifdef CATA +void Eluna::OnMoneyChanged(Player* pPlayer, int64& amount) +{ + START_HOOK(PLAYER_EVENT_ON_MONEY_CHANGE); + Push(pPlayer); + Push(amount); + int amountIndex = lua_gettop(L); + int n = SetupStack(PlayerEventBindings, key, 2); + + while (n > 0) + { + int r = CallOneFunction(n--, 2, 1); + + if (lua_isnumber(L, r)) + { + amount = CHECKVAL(L, r); + // Update the stack for subsequent calls. + ReplaceArgument(amount, amountIndex); + } + + lua_pop(L, 1); + } + + CleanUpStack(2); +} +#endif + void Eluna::OnGiveXP(Player* pPlayer, uint32& amount, Unit* pVictim) { START_HOOK(PLAYER_EVENT_ON_GIVE_XP); diff --git a/README.md b/README.md index 49ed49d017..8cd1a97a85 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ Core sources and forks with required modifications for Eluna: [AzerothCore Eluna Module](https://github.com/azerothcore/mod-eluna) +[Cataclysm Preservation Project](https://github.com/Niam5/ElunaCataPreservation) - maintained by [Niam5](https://github.com/Niam5) + ## Links * [MaNGOS](http://getmangos.eu/) diff --git a/TrinityCore/BattleGroundMethods.h b/TrinityCore/BattleGroundMethods.h index b01840162b..6ce153d821 100644 --- a/TrinityCore/BattleGroundMethods.h +++ b/TrinityCore/BattleGroundMethods.h @@ -82,7 +82,11 @@ namespace LuaBattleGround */ int GetEndTime(lua_State* L, BattleGround* bg) { +#ifdef CATA + Eluna::Push(L, bg->GetRemainingTime()); +#else Eluna::Push(L, bg->GetEndTime()); +#endif return 1; } diff --git a/TrinityCore/CreatureMethods.h b/TrinityCore/CreatureMethods.h index 73be40f6e1..0c1e5e80c8 100644 --- a/TrinityCore/CreatureMethods.h +++ b/TrinityCore/CreatureMethods.h @@ -22,7 +22,11 @@ namespace LuaCreature */ int IsRegeneratingHealth(lua_State* L, Creature* creature) { +#ifdef CATA + Eluna::Push(L, creature->isRegeneratingHealth()); +#else Eluna::Push(L, creature->CanRegenerateHealth()); +#endif return 1; } @@ -790,6 +794,7 @@ namespace LuaCreature return 1; } +#ifndef CATA /** * Returns the [Creature]'s shield block value. * @@ -800,6 +805,7 @@ namespace LuaCreature Eluna::Push(L, creature->GetShieldBlockValue()); return 1; } +#endif int GetLootMode(lua_State* L, Creature* creature) { @@ -1276,7 +1282,11 @@ namespace LuaCreature { "GetLootRecipientGroup", &LuaCreature::GetLootRecipientGroup }, { "GetNPCFlags", &LuaCreature::GetNPCFlags }, { "GetExtraFlags", &LuaCreature::GetExtraFlags }, +#ifndef CATA { "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue }, +#else + { "GetShieldBlockValue", nullptr }, +#endif { "GetDBTableGUIDLow", &LuaCreature::GetDBTableGUIDLow }, { "GetCreatureFamily", &LuaCreature::GetCreatureFamily }, diff --git a/TrinityCore/GameObjectMethods.h b/TrinityCore/GameObjectMethods.h index 62220f0b0a..2cf1b7a6ad 100644 --- a/TrinityCore/GameObjectMethods.h +++ b/TrinityCore/GameObjectMethods.h @@ -179,7 +179,13 @@ namespace LuaGameObject else if (state == 1) go->SetGoState(GO_STATE_READY); else if (state == 2) + { +#ifndef CATA go->SetGoState(GO_STATE_DESTROYED); +#else + go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE); +#endif + } return 0; } diff --git a/TrinityCore/GlobalMethods.h b/TrinityCore/GlobalMethods.h index 0058b016f5..e627130363 100644 --- a/TrinityCore/GlobalMethods.h +++ b/TrinityCore/GlobalMethods.h @@ -78,7 +78,11 @@ namespace LuaGlobalFunctions */ int GetCoreExpansion(lua_State* L) { +#ifdef WOTLK Eluna::Push(L, 2); +#elif CATA + Eluna::Push(L, 3); +#endif return 1; } @@ -362,12 +366,20 @@ namespace LuaGlobalFunctions if (!temp) return luaL_argerror(L, 1, "valid ItemEntry expected"); +#ifdef CATA + std::string name = temp->ExtendedData->Display->Str[locale]; +#else std::string name = temp->Name1; +#endif 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 << +#else oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec << +#endif "|Hitem:" << entry << ":0:" << "0:0:0:0:" << "0:0:0:0|h[" << name << "]|h|r"; @@ -1159,7 +1171,11 @@ namespace LuaGlobalFunctions { const char* command = Eluna::CHECKVAL(L, 1); // ignores output of the command +#ifdef CATA + eWorld->QueueCliCommand(new CliCommandHolder(nullptr, command, nullptr, [](void*, bool) {})); +#else eWorld->QueueCliCommand(new CliCommandHolder(nullptr, command, [](void*, std::string_view) {}, [](void*, bool) {})); +#endif return 0; } @@ -1448,14 +1464,22 @@ namespace LuaGlobalFunctions if (save) { Creature* creature = new Creature(); +#ifdef CATA + if (!creature->Create(map->GenerateLowGuid(), map, entry, pos)) +#else if (!creature->Create(map->GenerateLowGuid(), map, phase, entry, pos)) +#endif { delete creature; Eluna::Push(L); return 1; } +#ifdef CATA + creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); +#else creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); +#endif uint32 db_guid = creature->GetSpawnId(); @@ -1477,7 +1501,13 @@ namespace LuaGlobalFunctions } else { +#ifdef CATA + SummonCreatureExtraArgs extraArgs; + extraArgs.SummonDuration = durorresptime; + TempSummon* creature = map->SummonCreature(entry, pos, extraArgs); +#else TempSummon* creature = map->SummonCreature(entry, pos, NULL, durorresptime); +#endif if (!creature) { Eluna::Push(L); @@ -1513,7 +1543,11 @@ namespace LuaGlobalFunctions GameObject* object = new GameObject; uint32 guidLow = map->GenerateLowGuid(); 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)) +#else if (!object->Create(guidLow, objectInfo->entry, map, phase, Position(x, y, z, o), rot, 0, GO_STATE_READY)) +#endif { delete object; Eluna::Push(L); @@ -1526,7 +1560,11 @@ namespace LuaGlobalFunctions if (save) { // fill the gameobject data and save to the db +#ifdef CATA + object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode())); +#else object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), phase); +#endif guidLow = object->GetSpawnId(); // delete the old object and do a clean load from DB with a fresh new GameObject instance. @@ -1588,10 +1626,22 @@ namespace LuaGlobalFunctions uint32 incrtime = Eluna::CHECKVAL(L, 4); uint32 extendedcost = Eluna::CHECKVAL(L, 5); +#ifdef CATA + VendorItem vItem; + vItem.item = item; + vItem.maxcount = maxcount; + vItem.incrtime = incrtime; + vItem.ExtendedCost = extendedcost; + + if (!eObjectMgr->IsVendorItemValid(entry, vItem)) + return 0; + eObjectMgr->AddVendorItem(entry, vItem); +#else if (!eObjectMgr->IsVendorItemValid(entry, item, maxcount, incrtime, extendedcost)) return 0; eObjectMgr->AddVendorItem(entry, item, maxcount, incrtime, extendedcost); +#endif return 0; } @@ -1608,7 +1658,11 @@ namespace LuaGlobalFunctions if (!eObjectMgr->GetCreatureTemplate(entry)) return luaL_argerror(L, 1, "valid CreatureEntry expected"); +#ifdef CATA + eObjectMgr->RemoveVendorItem(entry, item, 1); +#else eObjectMgr->RemoveVendorItem(entry, item); +#endif return 0; } @@ -1628,8 +1682,12 @@ namespace LuaGlobalFunctions auto const itemlist = items->m_items; for (auto itr = itemlist.begin(); itr != itemlist.end(); ++itr) +#ifdef CATA + eObjectMgr->RemoveVendorItem(entry, itr->item, 1); +#else eObjectMgr->RemoveVendorItem(entry, itr->item); +#endif return 0; } @@ -1642,7 +1700,11 @@ namespace LuaGlobalFunctions { Player* player = Eluna::CHECKOBJ(L, 1); +#ifndef CATA player->GetSession()->KickPlayer("GlobalMethods::Kick Kick the player"); +#else + player->GetSession()->KickPlayer(); +#endif return 0; } @@ -1790,7 +1852,11 @@ namespace LuaGlobalFunctions luaL_error(L, "Item entry %d does not exist", entry); continue; } +#ifdef CATA + 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))) +#endif { luaL_error(L, "Item entry %d has invalid amount %d", entry, amount); continue; diff --git a/TrinityCore/GuildMethods.h b/TrinityCore/GuildMethods.h index af9fdfa7aa..63dd15bdf3 100644 --- a/TrinityCore/GuildMethods.h +++ b/TrinityCore/GuildMethods.h @@ -120,6 +120,7 @@ namespace LuaGuild return 1; } +#ifndef CATA /** * Sets the leader of this [Guild] * @@ -132,6 +133,7 @@ namespace LuaGuild guild->HandleSetLeader(player->GetSession(), player->GetName()); return 0; } +#endif /** * Sets the information of the bank tab specified @@ -255,7 +257,11 @@ namespace LuaGuild // Setters { "SetBankTabText", &LuaGuild::SetBankTabText }, { "SetMemberRank", &LuaGuild::SetMemberRank }, +#ifndef CATA { "SetLeader", &LuaGuild::SetLeader }, +#else + { "SetLeader", nullptr }, +#endif // Other { "SendPacket", &LuaGuild::SendPacket }, diff --git a/TrinityCore/ItemMethods.h b/TrinityCore/ItemMethods.h index 3f987132c9..46b0a2982b 100644 --- a/TrinityCore/ItemMethods.h +++ b/TrinityCore/ItemMethods.h @@ -185,6 +185,7 @@ namespace LuaItem return 1; } +#if defined(WOTLK) /** * Returns 'true' if the [Item] is a weapon vellum, 'false' otherwise * @@ -206,6 +207,7 @@ namespace LuaItem Eluna::Push(L, item->IsArmorVellum()); return 1; } +#endif /** * Returns 'true' if the [Item] is a conjured consumable, 'false' otherwise @@ -218,11 +220,13 @@ namespace LuaItem return 1; } +#ifndef CATA int IsRefundExpired(lua_State* L, Item* item) { Eluna::Push(L, item->IsRefundExpired()); return 1; } +#endif /** * Returns the chat link of the [Item] @@ -252,13 +256,22 @@ namespace LuaItem return luaL_argerror(L, 2, "valid LocaleConstant expected"); const ItemTemplate* temp = item->GetTemplate(); +#ifdef CATA + std::string name = temp->ExtendedData->Display1->Str[locale]; + if (ItemLocale const* il = eObjectMgr->GetItemLocale(temp->BasicData->ID)) +#else std::string name = temp->Name1; if (ItemLocale const* il = eObjectMgr->GetItemLocale(temp->ItemId)) +#endif ObjectMgr::GetLocaleString(il->Name, static_cast(locale), name); if (int32 itemRandPropId = item->GetItemRandomPropertyId()) { +#ifndef CATA std::array const* suffix = NULL; +#else + char* const* suffix = NULL; +#endif if (itemRandPropId < 0) { const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId()); @@ -274,13 +287,22 @@ namespace LuaItem if (suffix) { name += ' '; +#ifndef CATA name += (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)]; +#else + name += (*suffix)[(name != temp->ExtendedData->Display->Str[locale]) ? locale : uint8(DEFAULT_LOCALE)]; +#endif } } std::ostringstream oss; +#ifdef CATA + oss << "|c" << std::hex << ItemQualityColors[temp->ExtendedData->Quality] << std::dec << + "|Hitem:" << temp->BasicData->ID << ":" << +#else oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec << "|Hitem:" << temp->ItemId << ":" << +#endif item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT) << ":" << item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT) << ":" << item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_2) << ":" << @@ -383,7 +405,11 @@ namespace LuaItem if (index >= MAX_ITEM_PROTO_SPELLS) return luaL_argerror(L, 2, "valid SpellIndex expected"); +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->ExtendedData->SpellID[index]); +#else Eluna::Push(L, item->GetTemplate()->Spells[index].SpellId); +#endif return 1; } @@ -399,7 +425,11 @@ namespace LuaItem if (index >= MAX_ITEM_PROTO_SPELLS) return luaL_argerror(L, 2, "valid SpellIndex expected"); +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->ExtendedData->SpellTrigger[index]); +#else Eluna::Push(L, item->GetTemplate()->Spells[index].SpellTrigger); +#endif return 1; } @@ -410,7 +440,11 @@ namespace LuaItem */ int GetClass(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetClass()); +#else Eluna::Push(L, item->GetTemplate()->Class); +#endif return 1; } @@ -421,7 +455,11 @@ namespace LuaItem */ int GetSubClass(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetSubClass()); +#else Eluna::Push(L, item->GetTemplate()->SubClass); +#endif return 1; } @@ -432,7 +470,11 @@ namespace LuaItem */ int GetName(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetDefaultLocaleName()); +#else Eluna::Push(L, item->GetTemplate()->Name1); +#endif return 1; } @@ -443,7 +485,11 @@ namespace LuaItem */ int GetDisplayId(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetDisplayID()); +#else Eluna::Push(L, item->GetTemplate()->DisplayInfoID); +#endif return 1; } @@ -454,7 +500,11 @@ namespace LuaItem */ int GetQuality(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetQuality()); +#else Eluna::Push(L, item->GetTemplate()->Quality); +#endif return 1; } @@ -465,7 +515,11 @@ namespace LuaItem */ int GetBuyCount(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetBuyCount()); +#else Eluna::Push(L, item->GetTemplate()->BuyCount); +#endif return 1; } @@ -476,7 +530,11 @@ namespace LuaItem */ int GetBuyPrice(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetBuyPrice()); +#else Eluna::Push(L, item->GetTemplate()->BuyPrice); +#endif return 1; } @@ -487,7 +545,11 @@ namespace LuaItem */ int GetSellPrice(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetSellPrice()); +#else Eluna::Push(L, item->GetTemplate()->SellPrice); +#endif return 1; } @@ -498,7 +560,11 @@ namespace LuaItem */ int GetInventoryType(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetInventoryType()); +#else Eluna::Push(L, item->GetTemplate()->InventoryType); +#endif return 1; } @@ -509,7 +575,11 @@ namespace LuaItem */ int GetAllowableClass(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetAllowableClass()); +#else Eluna::Push(L, item->GetTemplate()->AllowableClass); +#endif return 1; } @@ -520,7 +590,11 @@ namespace LuaItem */ int GetAllowableRace(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetAllowableRace()); +#else Eluna::Push(L, item->GetTemplate()->AllowableRace); +#endif return 1; } @@ -531,7 +605,11 @@ namespace LuaItem */ int GetItemLevel(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetBaseItemLevel()); +#else Eluna::Push(L, item->GetTemplate()->ItemLevel); +#endif return 1; } @@ -542,15 +620,21 @@ namespace LuaItem */ int GetRequiredLevel(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetRequiredLevel()); +#else Eluna::Push(L, item->GetTemplate()->RequiredLevel); +#endif return 1; } +#ifdef WOTLK int GetStatsCount(lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->StatsCount); return 1; } +#endif /** * Returns the random property ID of this [Item] @@ -559,13 +643,21 @@ namespace LuaItem */ int GetRandomProperty(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetRandomProperty()); +#else Eluna::Push(L, item->GetTemplate()->RandomProperty); +#endif return 1; } int GetRandomSuffix(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetRandomSuffix()); +#else Eluna::Push(L, item->GetTemplate()->RandomSuffix); +#endif return 1; } @@ -576,7 +668,11 @@ namespace LuaItem */ int GetItemSet(lua_State* L, Item* item) { +#ifdef CATA + Eluna::Push(L, item->GetTemplate()->GetItemSet()); +#else Eluna::Push(L, item->GetTemplate()->ItemSet); +#endif return 1; } @@ -736,7 +832,11 @@ namespace LuaItem { "GetAllowableRace", &LuaItem::GetAllowableRace }, { "GetItemLevel", &LuaItem::GetItemLevel }, { "GetRequiredLevel", &LuaItem::GetRequiredLevel }, +#ifndef CATA { "GetStatsCount", &LuaItem::GetStatsCount }, +#else + { "GetStatsCount", nullptr }, +#endif { "GetRandomProperty", &LuaItem::GetRandomProperty }, { "GetRandomSuffix", &LuaItem::GetRandomSuffix }, { "GetItemSet", &LuaItem::GetItemSet }, @@ -763,10 +863,16 @@ namespace LuaItem { "IsEquipped", &LuaItem::IsEquipped }, { "HasQuest", &LuaItem::HasQuest }, { "IsPotion", &LuaItem::IsPotion }, +#ifndef CATA { "IsWeaponVellum", &LuaItem::IsWeaponVellum }, { "IsArmorVellum", &LuaItem::IsArmorVellum }, - { "IsConjuredConsumable", &LuaItem::IsConjuredConsumable }, { "IsRefundExpired", &LuaItem::IsRefundExpired }, +#else + { "IsWeaponVellum", nullptr }, + { "IsArmorVellum", nullptr }, + { "IsRefundExpired", nullptr }, +#endif + { "IsConjuredConsumable", &LuaItem::IsConjuredConsumable }, { "SetEnchantment", &LuaItem::SetEnchantment }, { "ClearEnchantment", &LuaItem::ClearEnchantment }, diff --git a/TrinityCore/MapMethods.h b/TrinityCore/MapMethods.h index 2ba9db67fe..4384cce751 100644 --- a/TrinityCore/MapMethods.h +++ b/TrinityCore/MapMethods.h @@ -107,9 +107,14 @@ namespace LuaMap { float x = Eluna::CHECKVAL(L, 2); float y = Eluna::CHECKVAL(L, 3); +#ifdef CATA + PhaseShift phase; + float z = map->GetHeight(phase, x, y, MAX_HEIGHT); +#else uint32 phasemask = Eluna::CHECKVAL(L, 4, 1); float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT); +#endif if (z != INVALID_HEIGHT) Eluna::Push(L, z); return 1; @@ -175,9 +180,14 @@ namespace LuaMap float x = Eluna::CHECKVAL(L, 2); float y = Eluna::CHECKVAL(L, 3); float z = Eluna::CHECKVAL(L, 4); +#ifdef CATA + PhaseShift phase; + Eluna::Push(L, map->GetAreaId(phase, x, y, z)); +#else float phasemask = Eluna::CHECKVAL(L, 5, PHASEMASK_NORMAL); Eluna::Push(L, map->GetAreaId(phasemask, x, y, z)); +#endif return 1; } diff --git a/TrinityCore/PlayerMethods.h b/TrinityCore/PlayerMethods.h index 5c93f515a5..3ee4be34ac 100644 --- a/TrinityCore/PlayerMethods.h +++ b/TrinityCore/PlayerMethods.h @@ -234,7 +234,11 @@ namespace LuaPlayer */ int CanSpeak(lua_State* L, Player* player) { +#ifndef CATA Eluna::Push(L, player->GetSession()->CanSpeak()); +#else + Eluna::Push(L, player->CanSpeak()); +#endif return 1; } @@ -620,7 +624,11 @@ namespace LuaPlayer int IsNeverVisible(lua_State* L, Player* player) { // Possibly add a bool var here +#ifdef CATA + Eluna::Push(L, player->IsNeverVisible()); +#else Eluna::Push(L, player->IsNeverVisible(true)); +#endif return 1; } @@ -667,6 +675,7 @@ namespace LuaPlayer return 1; } +#ifndef CATA /** * Returns the normal phase of the player instead of the actual phase possibly containing GM phase * @@ -710,6 +719,7 @@ namespace LuaPlayer Eluna::Push(L, player->GetShieldBlockValue()); return 1; } +#endif /** * Returns the [Player]s cooldown delay by specified [Spell] ID @@ -1011,7 +1021,11 @@ namespace LuaPlayer */ int GetGuildRank(lua_State* L, Player* player) // TODO: Move to Guild Methods { +#ifdef CATA + Eluna::Push(L, player->GetGuildRank()); +#else Eluna::Push(L, player->GetRank()); +#endif return 1; } @@ -1601,7 +1615,11 @@ namespace LuaPlayer if (!player->GetGuildId()) return 0; +#ifdef CATA + player->SetGuildRank(rank); +#else player->SetRank(rank); +#endif return 0; } @@ -1774,6 +1792,7 @@ namespace LuaPlayer return 0; } +#ifndef CATA /** * Sets the [Player]s Arena Points to the amount specified * @@ -1797,6 +1816,7 @@ namespace LuaPlayer player->SetHonorPoints(honorP); return 0; } +#endif /** * Sets the [Player]s amount of Lifetime Honorable Kills to the value specified @@ -1884,13 +1904,20 @@ namespace LuaPlayer bool apply = Eluna::CHECKVAL(L, 2, true); if(apply) +#ifdef CATA + player->SetByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP); + else + player->RemoveByteFlag(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_FFA_PVP); +#else player->SetPvpFlag(UNIT_BYTE2_FLAG_FFA_PVP); else player->RemovePvpFlag(UNIT_BYTE2_FLAG_FFA_PVP); +#endif return 0; } +#ifndef CATA int SetMovement(lua_State* L, Player* player) { int32 pType = Eluna::CHECKVAL(L, 2); @@ -1898,6 +1925,7 @@ namespace LuaPlayer player->SetMovement((PlayerMovementType)pType); return 0; } +#endif /** * Resets the [Player]s pets talent points @@ -1931,6 +1959,7 @@ namespace LuaPlayer return 0; } +#ifndef CATA /** * Adds or detracts from the [Player]s current Arena Points * @@ -1956,6 +1985,7 @@ namespace LuaPlayer player->ModifyHonorPoints(amount); return 0; } +#endif /** * Saves the [Player] to the database @@ -2108,7 +2138,11 @@ namespace LuaPlayer { Creature* obj = Eluna::CHECKOBJ(L, 2); +#ifdef CATA + player->GetSession()->SendTrainerList(obj, NULL); +#else player->GetSession()->SendTrainerList(obj); +#endif return 0; } @@ -2354,7 +2388,11 @@ namespace LuaPlayer */ int ResetTalentsCost(lua_State* L, Player* player) { +#ifdef CATA + Eluna::Push(L, player->GetNextResetTalentsCost()); +#else Eluna::Push(L, player->ResetTalentsCost()); +#endif return 1; } @@ -2601,6 +2639,7 @@ namespace LuaPlayer return 0; // check item starting quest (it can work incorrectly if added without item in inventory) +#ifndef CATA ItemTemplateContainer const& itc = sObjectMgr->GetItemTemplateStore(); auto itr = std::find_if(std::begin(itc), std::end(itc), [quest](ItemTemplateContainer::value_type const& value) { @@ -2610,6 +2649,13 @@ namespace LuaPlayer if (itr != std::end(itc)) return 0; +#elif CATA + ItemTemplateContainer const* itc = sObjectMgr->GetItemTemplateStore(); + ItemTemplateContainer::const_iterator result = std::find_if(itc->begin(), itc->end(), [quest](ItemTemplateContainer::value_type const& value) + { + return value.second.ExtendedData->StartQuest == quest->GetQuestId(); + }); +#endif // ok, normal (creature/GO starting) quest if (player->CanAddQuest(quest, true)) player->AddQuestAndCheckCompletion(quest, NULL); @@ -2887,6 +2933,7 @@ namespace LuaPlayer return 0; } +#ifndef CATA /** * Advances all of the [Player]s weapon skills to the maximum amount available */ @@ -2895,6 +2942,7 @@ namespace LuaPlayer player->UpdateWeaponsSkillsToMaxSkillsForLevel(); return 0; } +#endif /** * Advances all of the [Player]s skills to the amount specified @@ -2958,11 +3006,21 @@ namespace LuaPlayer float z = Eluna::CHECKVAL(L, 5); float o = Eluna::CHECKVAL(L, 6); +#ifdef CATA + if (player->IsInFlight()) + { + player->GetMotionMaster()->MovementExpired(); + player->m_taxi.ClearTaxiDestinations(); + } + else + player->SaveRecallPosition(); +#else if (player->IsInFlight()) player->FinishTaxiFlight(); else player->SaveRecallPosition(); +#endif Eluna::Push(L, player->TeleportTo(mapId, x, y, z, o)); return 1; } @@ -3188,7 +3246,11 @@ namespace LuaPlayer */ int KickPlayer(lua_State* /*L*/, Player* player) { +#ifndef CATA player->GetSession()->KickPlayer("PlayerMethods::KickPlayer Kick the player"); +#else + player->GetSession()->KickPlayer(); +#endif return 0; } @@ -3424,8 +3486,12 @@ namespace LuaPlayer if (!quest) return 0; +#ifdef CATA + player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GET_GUID(), activateAccept, true); +#else player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GET_GUID(), activateAccept); +#endif return 0; } @@ -3488,7 +3554,11 @@ namespace LuaPlayer if (success) { +#ifdef CATA + WorldPacket data(SMSG_PARTY_INVITE, 10); // guess size +#else WorldPacket data(SMSG_GROUP_INVITE, 10); // guess size +#endif data << uint8(1); // invited/already in group flag data << player->GetName(); // max len 48 data << uint32(0); // unk @@ -3672,8 +3742,13 @@ namespace LuaPlayer { "GetGuild", &LuaPlayer::GetGuild }, { "GetAccountId", &LuaPlayer::GetAccountId }, { "GetAccountName", &LuaPlayer::GetAccountName }, +#ifndef CATA { "GetArenaPoints", &LuaPlayer::GetArenaPoints }, { "GetHonorPoints", &LuaPlayer::GetHonorPoints }, +#else + { "GetArenaPoints", nullptr }, + { "GetHonorPoints", nullptr }, +#endif { "GetLifetimeKills", &LuaPlayer::GetLifetimeKills }, { "GetPlayerIP", &LuaPlayer::GetPlayerIP }, { "GetLevelPlayedTime", &LuaPlayer::GetLevelPlayedTime }, @@ -3687,7 +3762,11 @@ namespace LuaPlayer { "GetQuestLevel", &LuaPlayer::GetQuestLevel }, { "GetChatTag", &LuaPlayer::GetChatTag }, { "GetRestBonus", &LuaPlayer::GetRestBonus }, +#ifndef CATA { "GetPhaseMaskForSpawn", &LuaPlayer::GetPhaseMaskForSpawn }, +#else + { "GetPhaseMaskForSpawn", nullptr }, +#endif { "GetReqKillOrCastCurrentCount", &LuaPlayer::GetReqKillOrCastCurrentCount }, { "GetQuestStatus", &LuaPlayer::GetQuestStatus }, { "GetInGameTime", &LuaPlayer::GetInGameTime }, @@ -3727,10 +3806,18 @@ namespace LuaPlayer { "GetCorpse", &LuaPlayer::GetCorpse }, { "GetGossipTextId", &LuaPlayer::GetGossipTextId }, { "GetQuestRewardStatus", &LuaPlayer::GetQuestRewardStatus }, +#ifndef CATA { "GetShieldBlockValue", &LuaPlayer::GetShieldBlockValue }, +#else + { "GetShieldBlockValue", nullptr }, +#endif // Setters +#ifndef CATA { "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax }, +#else + { "AdvanceSkillsToMax", nullptr }, +#endif { "AdvanceSkill", &LuaPlayer::AdvanceSkill }, { "AdvanceAllSkills", &LuaPlayer::AdvanceAllSkills }, { "AddLifetimeKills", &LuaPlayer::AddLifetimeKills }, @@ -3738,8 +3825,13 @@ namespace LuaPlayer { "SetKnownTitle", &LuaPlayer::SetKnownTitle }, { "UnsetKnownTitle", &LuaPlayer::UnsetKnownTitle }, { "SetBindPoint", &LuaPlayer::SetBindPoint }, +#ifndef CATA { "SetArenaPoints", &LuaPlayer::SetArenaPoints }, { "SetHonorPoints", &LuaPlayer::SetHonorPoints }, +#else + { "SetArenaPoints", nullptr }, + { "SetHonorPoints", nullptr }, +#endif { "SetLifetimeKills", &LuaPlayer::SetLifetimeKills }, { "SetGameMaster", &LuaPlayer::SetGameMaster }, { "SetGMChat", &LuaPlayer::SetGMChat }, @@ -3752,7 +3844,11 @@ namespace LuaPlayer { "SetReputation", &LuaPlayer::SetReputation }, { "SetFreeTalentPoints", &LuaPlayer::SetFreeTalentPoints }, { "SetGuildRank", &LuaPlayer::SetGuildRank }, +#ifndef CATA { "SetMovement", &LuaPlayer::SetMovement }, +#else + { "SetMovement", nullptr }, +#endif { "SetSkill", &LuaPlayer::SetSkill }, { "SetFactionForRace", &LuaPlayer::SetFactionForRace }, { "SetDrunkValue", &LuaPlayer::SetDrunkValue }, @@ -3883,8 +3979,13 @@ namespace LuaPlayer { "DurabilityPointLossForEquipSlot", &LuaPlayer::DurabilityPointLossForEquipSlot }, { "DurabilityRepairAll", &LuaPlayer::DurabilityRepairAll }, { "DurabilityRepair", &LuaPlayer::DurabilityRepair }, +#ifndef CATA { "ModifyHonorPoints", &LuaPlayer::ModifyHonorPoints }, { "ModifyArenaPoints", &LuaPlayer::ModifyArenaPoints }, +#else + { "ModifyHonorPoints", nullptr }, + { "ModifyArenaPoints", nullptr }, +#endif { "LeaveBattleground", &LuaPlayer::LeaveBattleground }, { "BindToInstance", &LuaPlayer::BindToInstance }, { "UnbindInstance", &LuaPlayer::UnbindInstance }, diff --git a/TrinityCore/QuestMethods.h b/TrinityCore/QuestMethods.h index d625e501c2..dc425cd097 100644 --- a/TrinityCore/QuestMethods.h +++ b/TrinityCore/QuestMethods.h @@ -165,7 +165,11 @@ namespace LuaQuest */ int GetType(lua_State* L, Quest* quest) { +#ifdef CATA + Eluna::Push(L, quest->GetQuestType()); +#else Eluna::Push(L, quest->GetType()); +#endif return 1; } diff --git a/TrinityCore/UnitMethods.h b/TrinityCore/UnitMethods.h index 308dbb1b77..24183c81f7 100644 --- a/TrinityCore/UnitMethods.h +++ b/TrinityCore/UnitMethods.h @@ -1486,7 +1486,11 @@ namespace LuaUnit int SetNativeDisplayId(lua_State* L, Unit* unit) { uint32 model = Eluna::CHECKVAL(L, 2); +#ifndef CATA unit->SetNativeDisplayId(model); +#else + unit->SetDisplayId(model, true); +#endif return 0; } diff --git a/TrinityCore/VehicleMethods.h b/TrinityCore/VehicleMethods.h index 64343a16cf..57f8372e69 100644 --- a/TrinityCore/VehicleMethods.h +++ b/TrinityCore/VehicleMethods.h @@ -72,7 +72,11 @@ namespace LuaVehicle Unit* passenger = Eluna::CHECKOBJ(L, 2); int8 seatId = Eluna::CHECKVAL(L, 3); +#ifndef CATA vehicle->AddPassenger(passenger, seatId); +#else + vehicle->AddVehiclePassenger(passenger, seatId); +#endif return 0; } diff --git a/TrinityCore/WorldObjectMethods.h b/TrinityCore/WorldObjectMethods.h index 7665a3c064..03d9aa396c 100644 --- a/TrinityCore/WorldObjectMethods.h +++ b/TrinityCore/WorldObjectMethods.h @@ -41,7 +41,12 @@ namespace LuaWorldObject */ int GetPhaseMask(lua_State* L, WorldObject* obj) { +#ifdef CATA + EventMap event; + Eluna::Push(L, event.GetPhaseMask()); +#else Eluna::Push(L, obj->GetPhaseMask()); +#endif return 1; } @@ -54,8 +59,13 @@ namespace LuaWorldObject int SetPhaseMask(lua_State* L, WorldObject* obj) { uint32 phaseMask = Eluna::CHECKVAL(L, 2); +#ifdef CATA + EventMap event; + event.SetPhase(phaseMask); +#else bool update = Eluna::CHECKVAL(L, 3, true); obj->SetPhaseMask(phaseMask, update); +#endif return 0; } @@ -590,6 +600,7 @@ namespace LuaWorldObject int GetAngle(lua_State* L, WorldObject* obj) { WorldObject* target = Eluna::CHECKOBJ(L, 2, false); +#ifndef CATA if (target) Eluna::Push(L, obj->GetAbsoluteAngle(target)); else @@ -598,6 +609,16 @@ namespace LuaWorldObject float y = Eluna::CHECKVAL(L, 3); Eluna::Push(L, obj->GetAbsoluteAngle(x, y)); } +#else + if (target) + Eluna::Push(L, obj->GetAngle(target)); + else + { + float x = Eluna::CHECKVAL(L, 2); + float y = Eluna::CHECKVAL(L, 3); + Eluna::Push(L, obj->GetAngle(x, y)); + } +#endif return 1; } @@ -635,9 +656,14 @@ namespace LuaWorldObject float o = Eluna::CHECKVAL(L, 6); uint32 respawnDelay = Eluna::CHECKVAL(L, 7, 30); +#ifndef CATA QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); Eluna::Push(L, obj->SummonGameObject(entry, Position(x, y, z, o), rot, Seconds(respawnDelay))); +#else + QuaternionData rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); + Eluna::Push(L, obj->SummonGameObject(entry, x, y, z, o, rot, respawnDelay)); +#endif return 1; } @@ -708,7 +734,11 @@ namespace LuaWorldObject return luaL_argerror(L, 7, "valid SpawnType expected"); } +#ifndef CATA Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, Milliseconds(despawnTimer))); +#else + Eluna::Push(L, obj->SummonCreature(entry, x, y, z, o, type, despawnTimer)); +#endif return 1; }