diff --git a/CreatureMethods.h b/CreatureMethods.h index bc48b43..7bd33c0 100644 --- a/CreatureMethods.h +++ b/CreatureMethods.h @@ -692,8 +692,12 @@ namespace LuaCreature #ifdef CMANGOS ThreatList const& threatlist = creature->getThreatManager().getThreatList(); -#else +#endif +#ifdef MANGOS ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); +#endif +#ifdef TRINITY + auto const& threatlist = creature->GetThreatManager().GetThreatenedByMeList(); #endif if (threatlist.empty()) return 1; @@ -701,9 +705,13 @@ namespace LuaCreature return 1; std::list targetList; - for (ThreatList::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr) { +#ifdef TRINITY + Unit* target = itr->second->GetOwner(); +#else Unit* target = (*itr)->getTarget(); +#endif if (!target) continue; if (playerOnly && target->GetTypeId() != TYPEID_PLAYER) @@ -772,13 +780,21 @@ namespace LuaCreature */ int GetAITargets(lua_State* L, Creature* creature) { +#ifdef TRINITY + auto const& threatlist = creature->GetThreatManager().GetThreatenedByMeList(); +#else ThreatList const& threatlist = creature->GetThreatManager().getThreatList(); +#endif lua_createtable(L, threatlist.size(), 0); int tbl = lua_gettop(L); uint32 i = 0; - for (ThreatList::const_iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) + for (auto itr = threatlist.begin(); itr != threatlist.end(); ++itr) { +#ifdef TRINITY + Unit* target = itr->second->GetOwner(); +#else Unit* target = (*itr)->getTarget(); +#endif if (!target) continue; Eluna::Push(L, target); @@ -796,7 +812,11 @@ namespace LuaCreature */ int GetAITargetsCount(lua_State* L, Creature* creature) { +#ifdef TRINITY + Eluna::Push(L, creature->GetThreatManager().GetThreatenedByMeList().size()); +#else Eluna::Push(L, creature->GetThreatManager().getThreatList().size()); +#endif return 1; } diff --git a/ElunaIncludes.h b/ElunaIncludes.h index 231713e..773dfef 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -103,7 +103,6 @@ typedef Opcodes OpcodesList; #define eAuctionMgr (sAuctionMgr) #define eObjectAccessor() ObjectAccessor:: #define REGEN_TIME_FULL -typedef ThreatContainer::StorageType ThreatList; #ifdef CATA #define NUM_MSG_TYPES NUM_OPCODE_HANDLERS diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index f50bf25..2316332 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -270,7 +270,6 @@ ElunaRegister UnitMethods[] = { "GetRaceAsString", &LuaUnit::GetRaceAsString }, { "GetClassAsString", &LuaUnit::GetClassAsString }, { "GetAura", &LuaUnit::GetAura }, - { "GetCombatTime", &LuaUnit::GetCombatTime }, { "GetFaction", &LuaUnit::GetFaction }, { "GetCurrentSpell", &LuaUnit::GetCurrentSpell }, { "GetCreatureType", &LuaUnit::GetCreatureType }, diff --git a/UnitMethods.h b/UnitMethods.h index d5bb26d..d14c5d3 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -1177,17 +1177,6 @@ namespace LuaUnit return 1; } - /** - * Returns the [Unit]'s combat timer - * - * @return uint32 combatTimer - */ - int GetCombatTime(lua_State* L, Unit* unit) - { - Eluna::Push(L, unit->GetCombatTimer()); - return 1; - } - /** * Returns a table containing friendly [Unit]'s within given range of the [Unit]. * @@ -1928,7 +1917,11 @@ namespace LuaUnit */ int ClearThreatList(lua_State* /*L*/, Unit* unit) { +#ifdef TRINITY + unit->GetThreatManager().ClearAllThreat(); +#else unit->GetThreatManager().clearReferences(); +#endif return 0; }