diff --git a/CreatureMethods.h b/CreatureMethods.h index 83a5c5b..b3db467 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -37,7 +37,7 @@ namespace LuaCreature { uint32 quest_id = Eluna::CHECKVAL(L, 2); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->hasInvolvedQuest(quest_id)); #else Eluna::Push(L, creature->HasInvolvedQuest(quest_id)); @@ -105,7 +105,7 @@ namespace LuaCreature { Player* player = Eluna::CHECKOBJ(L, 2); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->isTappedBy(player)); #else Eluna::Push(L, creature->IsTappedBy(player)); @@ -121,7 +121,7 @@ namespace LuaCreature */ int HasLootRecipient(lua_State* L, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->hasLootRecipient()); #else Eluna::Push(L, creature->HasLootRecipient()); @@ -137,7 +137,7 @@ namespace LuaCreature */ int CanAggro(lua_State* L, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, !creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC)); #else // Eluna::Push(L, creature->CanInitiateAttack()); @@ -190,7 +190,7 @@ namespace LuaCreature */ int IsElite(lua_State* L, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->isElite()); #else Eluna::Push(L, creature->IsElite()); @@ -242,7 +242,7 @@ namespace LuaCreature */ int IsWorldBoss(lua_State* L, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->isWorldBoss()); #else Eluna::Push(L, creature->IsWorldBoss()); @@ -261,12 +261,12 @@ namespace LuaCreature { uint32 spell = Eluna::CHECKVAL(L, 2); -#if defined TRINITY +#if defined(TRINITY) if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, info->GetCategory() && creature->GetSpellHistory()->HasCooldown(spell)); else Eluna::Push(L, false); -#elif AZEROTHCORE +#elif defined(AZEROTHCORE) if (const SpellInfo* info = sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, info->GetCategory() && creature->HasSpellCooldown(spell)); else @@ -303,7 +303,7 @@ namespace LuaCreature { uint32 questId = Eluna::CHECKVAL(L, 2); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->hasQuest(questId)); #else Eluna::Push(L, creature->HasQuest(questId)); @@ -322,7 +322,7 @@ namespace LuaCreature { uint32 spellId = Eluna::CHECKVAL(L, 2); -#ifdef TRINITY +#if defined(TRINITY) Eluna::Push(L, creature->GetSpellHistory()->HasCooldown(spellId)); #else Eluna::Push(L, creature->HasSpellCooldown(spellId)); @@ -342,7 +342,7 @@ namespace LuaCreature return 1; } -#if defined(TRINITY) || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) /** * Returns `true` if the [Creature] is an invisible trigger, * and returns `false` otherwise. @@ -423,7 +423,7 @@ namespace LuaCreature */ int GetWanderRadius(lua_State* L, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetWanderDistance()); #else Eluna::Push(L, creature->GetRespawnRadius()); @@ -431,7 +431,7 @@ namespace LuaCreature return 1; } -#if defined(TRINITY) || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) /** * Returns the current waypoint path ID of the [Creature]. * @@ -451,9 +451,9 @@ namespace LuaCreature */ int GetCurrentWaypointId(lua_State* L, Creature* creature) { -#ifdef TRINITY +#if defined(TRINITY) Eluna::Push(L, creature->GetCurrentWaypointInfo().first); -#elif AZEROTHCORE +#elif defined(AZEROTHCORE) Eluna::Push(L, creature->GetCurrentWaypointID()); #else Eluna::Push(L, creature->GetMotionMaster()->getLastReachedWaypoint()); @@ -482,7 +482,7 @@ namespace LuaCreature { Unit* target = Eluna::CHECKOBJ(L, 2); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetAggroRange(target)); #else float AttackDist = creature->GetAttackDistance(target); @@ -518,7 +518,7 @@ namespace LuaCreature */ int GetLootRecipientGroup(lua_State* L, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->GetLootRecipientGroup()); #else Eluna::Push(L, creature->GetGroupLootRecipient()); @@ -591,12 +591,12 @@ namespace LuaCreature { uint32 spell = Eluna::CHECKVAL(L, 2); -#ifdef TRINITY +#if defined(TRINITY) if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, creature->GetSpellHistory()->GetRemainingCooldown(spellInfo)); else Eluna::Push(L, 0); -#elif AZEROTHCORE +#elif defined(AZEROTHCORE) if (sSpellMgr->GetSpellInfo(spell)) Eluna::Push(L, creature->GetSpellCooldown(spell)); else @@ -630,7 +630,7 @@ namespace LuaCreature int GetHomePosition(lua_State* L, Creature* creature) { float x, y, z, o; -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->GetHomePosition(x, y, z, o); #else creature->GetRespawnCoord(x, y, z, &o); @@ -659,7 +659,7 @@ namespace LuaCreature float z = Eluna::CHECKVAL(L, 4); float o = Eluna::CHECKVAL(L, 5); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->SetHomePosition(x, y, z, o); #else creature->SetRespawnCoord(x, y, z, o); @@ -711,13 +711,13 @@ namespace LuaCreature float dist = Eluna::CHECKVAL(L, 5, 0.0f); int32 aura = Eluna::CHECKVAL(L, 6, 0); -#ifdef CMANGOS +#if defined(CMANGOS) ThreatList const& threatlist = creature->getThreatManager().getThreatList(); -#elif MANGOS +#elif defined(MANGOS) ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); -#elif TRINITY +#elif defined(TRINITY) auto const& threatlist = creature->GetThreatManager().GetSortedThreatList(); -#elif AZEROTHCORE +#elif defined(AZEROTHCORE) auto const& threatlist = creature->getThreatManager().getThreatList(); #endif #ifndef TRINITY @@ -727,13 +727,13 @@ namespace LuaCreature return 1; #endif std::list targetList; -#ifdef TRINITY +#if defined(TRINITY) for (ThreatReference const* itr : threatlist) #else for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr) #endif { -#ifdef TRINITY +#if defined(TRINITY) Unit* target = itr->GetVictim(); #else Unit* target = (*itr)->getTarget(); @@ -806,9 +806,9 @@ namespace LuaCreature */ int GetAITargets(lua_State* L, Creature* creature) { -#ifdef TRINITY +#if defined(TRINITY) auto const& threatlist = creature->GetThreatManager().GetThreatenedByMeList(); -#elif defined AZEROTHCORE +#elif defined(AZEROTHCORE) auto const& threatlist = creature->getThreatManager().getThreatList(); #else ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); @@ -818,7 +818,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); uint32 i = 0; for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr) { -#ifdef TRINITY +#if defined(TRINITY) Unit* target = itr->second->GetOwner(); #else Unit* target = (*itr)->getTarget(); @@ -840,9 +840,9 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); */ int GetAITargetsCount(lua_State* L, Creature* creature) { -#ifdef TRINITY +#if defined(TRINITY) Eluna::Push(L, creature->GetThreatManager().GetThreatenedByMeList().size()); -#elif AZEROTHCORE +#elif defined(AZEROTHCORE) Eluna::Push(L, creature->getThreatManager().getThreatList().size()); #else Eluna::Push(L, creature->GetThreatManager().getThreatList().size()); @@ -877,7 +877,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); } #endif -#if defined(TRINITY) || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) int GetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { Eluna::Push(L, creature->GetLootMode()); @@ -892,7 +892,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); */ int GetDBTableGUIDLow(lua_State* L, Creature* creature) { -#ifdef TRINITY +#if defined(TRINITY) Eluna::Push(L, creature->GetSpawnId()); #else // on mangos based this is same as lowguid @@ -924,7 +924,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { bool disable = Eluna::CHECKVAL(L, 2); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->SetDisableGravity(disable); #else creature->SetLevitate(disable); @@ -932,7 +932,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); return 0; } -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) int SetLootMode(lua_State* L, Creature* creature) // TODO: Implement LootMode features { uint16 lootMode = Eluna::CHECKVAL(L, 2); @@ -951,7 +951,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { int32 state = Eluna::CHECKVAL(L, 2); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->setDeathState((DeathState)state); #else creature->SetDeathState((DeathState)state); @@ -985,7 +985,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); uint32 off_hand = Eluna::CHECKVAL(L, 3); uint32 ranged = Eluna::CHECKVAL(L, 4); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, main_hand); creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, off_hand); creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, ranged); @@ -1006,7 +1006,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { bool allow = Eluna::CHECKVAL(L, 2, true); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) if (allow) creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); else @@ -1042,10 +1042,10 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); */ int SetInCombatWithZone(lua_State* /*L*/, Creature* creature) { -#if defined AZEROTHCORE +#if defined(AZEROTHCORE) if (creature->IsAIEnabled) creature->AI()->DoZoneInCombat(); -#elif defined TRINITY +#elif defined(TRINITY) if (creature->IsAIEnabled()) creature->AI()->DoZoneInCombat(); #else @@ -1063,7 +1063,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { float dist = Eluna::CHECKVAL(L, 2); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->SetWanderDistance(dist); #else creature->SetRespawnRadius(dist); @@ -1132,7 +1132,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { bool enable = Eluna::CHECKVAL(L, 2, true); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->SetHover(enable); #else // Copy paste from Aura::HandleAuraHover @@ -1144,7 +1144,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); data.Initialize(SMSG_MOVE_UNSET_HOVER, 8 + 4); data << creature->GetPackGUID(); data << uint32(0); -#ifdef CMANGOS +#if defined(CMANGOS) creature->SendMessageToSet(data, true); #else creature->SendMessageToSet(&data, true); @@ -1162,9 +1162,9 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { uint32 msTimeToDespawn = Eluna::CHECKVAL(L, 2, 0); -#if defined TRINITY +#if defined(TRINITY) creature->DespawnOrUnsummon(Milliseconds(msTimeToDespawn)); -#elif defined AZEROTHCORE +#elif defined(AZEROTHCORE) creature->DespawnOrUnsummon(msTimeToDespawn); #else creature->ForcedDespawn(msTimeToDespawn); @@ -1195,7 +1195,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); */ int MoveWaypoint(lua_State* /*L*/, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->GetMotionMaster()->MovePath(creature->GetWaypointPath(), true); #else creature->GetMotionMaster()->MoveWaypoint(); @@ -1263,7 +1263,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); */ int SelectVictim(lua_State* L, Creature* creature) { -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) Eluna::Push(L, creature->SelectVictim()); #else Eluna::Push(L, creature->SelectHostileTarget()); @@ -1282,7 +1282,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); uint32 entry = Eluna::CHECKVAL(L, 2); uint32 dataGuidLow = Eluna::CHECKVAL(L, 3, 0); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) creature->UpdateEntry(entry, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL); #else creature->UpdateEntry(entry, ALLIANCE, dataGuidLow ? eObjectMgr->GetCreatureData(dataGuidLow) : NULL); @@ -1290,7 +1290,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); return 0; } -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) /** * Resets [Creature]'s loot mode to default */ @@ -1385,7 +1385,7 @@ auto const& threatlist = creature->getThreatManager().getThreatList(); { uint32 entry = creature->GetEntry(); -#if defined TRINITY || AZEROTHCORE +#if defined(TRINITY) || defined(AZEROTHCORE) CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry); if (cInfo) Eluna::Push(L, cInfo->family); diff --git a/GlobalMethods.h b/GlobalMethods.h index 8ac9702..332dbb8 100644 --- a/GlobalMethods.h +++ b/GlobalMethods.h @@ -62,7 +62,7 @@ namespace LuaGlobalFunctions int GetRealmID(lua_State* L) { #ifdef MANGOS - Eluna::Push(L, eWorld->GetRealmID()); + Eluna::Push(L, realmID); #else Eluna::Push(L, sConfigMgr->GetIntDefault("RealmID", 1)); #endif @@ -495,7 +495,11 @@ namespace LuaGlobalFunctions if (!areaEntry) return luaL_argerror(L, 1, "valid Area or Zone ID expected"); +#if defined(TRINITY) Eluna::Push(L, areaEntry->AreaName[locale]); +#else + Eluna::Push(L, areaEntry->area_name[locale]); +#endif return 1; } diff --git a/ItemMethods.h b/ItemMethods.h index 719eb60..2dafc3b 100644 --- a/ItemMethods.h +++ b/ItemMethods.h @@ -276,7 +276,7 @@ namespace LuaItem #else #ifdef TRINITY std::array const* suffix = NULL; -#elif +#else char* const* suffix = NULL; #endif #endif diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index ea2618b..d5448c9 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -601,7 +601,9 @@ ElunaRegister PlayerMethods[] = // {"HasPendingBind", &LuaPlayer::HasPendingBind}, // :HasPendingBind() - UNDOCUMENTED - Returns true if the player has a pending instance bind #if (!defined(TBC) && !defined(CLASSIC)) { "HasAchieved", &LuaPlayer::HasAchieved }, +#if defined(TRINITY) || defined(AZEROTHCORE) { "SetAchievement", &LuaPlayer::SetAchievement }, +#endif #endif { "CanUninviteFromGroup", &LuaPlayer::CanUninviteFromGroup }, { "IsRested", &LuaPlayer::IsRested }, diff --git a/PlayerMethods.h b/PlayerMethods.h index e04b784..b581727 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -2059,6 +2059,7 @@ namespace LuaPlayer } +#if defined(TRINITY) || defined(AZEROTHCORE) /** * Adds the specified achievement to the [Player]s * @@ -2072,6 +2073,7 @@ namespace LuaPlayer player->CompletedAchievement(t); return 0; } +#endif #endif