mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Update CreatureMethods.h
This commit is contained in:
@@ -330,10 +330,12 @@ namespace LuaCreature
|
||||
uint32 targetType = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
bool playerOnly = Eluna::CHECKVAL<bool>(L, 3, false);
|
||||
uint32 position = Eluna::CHECKVAL<uint32>(L, 4, 0);
|
||||
float dist = Eluna::CHECKVAL<float>(L, 5, -1.0f);
|
||||
float dist = Eluna::CHECKVAL<float>(L, 5, 0.0f);
|
||||
int32 aura = Eluna::CHECKVAL<int32>(L, 6, 0);
|
||||
|
||||
ThreatList const& threatlist = creature->getThreatManager().getThreatList();
|
||||
if (threatlist.empty())
|
||||
return 1;
|
||||
if (position >= threatlist.size())
|
||||
return 1;
|
||||
|
||||
@@ -351,9 +353,13 @@ namespace LuaCreature
|
||||
continue;
|
||||
if (dist > 0.0f && !creature->IsWithinDist(target, dist))
|
||||
continue;
|
||||
else if (dist < 0.0f && creature->IsWithinDist(target, -dist))
|
||||
continue;
|
||||
targetList.push_back(target);
|
||||
}
|
||||
|
||||
if (targetList.empty())
|
||||
return 1;
|
||||
if (position >= targetList.size())
|
||||
return 1;
|
||||
|
||||
@@ -366,6 +372,7 @@ namespace LuaCreature
|
||||
case SELECT_TARGET_TOPAGGRO:
|
||||
{
|
||||
std::list<Unit*>::const_iterator itr = targetList.begin();
|
||||
if (position)
|
||||
std::advance(itr, position);
|
||||
Eluna::Push(L, *itr);
|
||||
}
|
||||
@@ -374,6 +381,7 @@ namespace LuaCreature
|
||||
case SELECT_TARGET_BOTTOMAGGRO:
|
||||
{
|
||||
std::list<Unit*>::reverse_iterator ritr = targetList.rbegin();
|
||||
if (position)
|
||||
std::advance(ritr, position);
|
||||
Eluna::Push(L, *ritr);
|
||||
}
|
||||
@@ -381,7 +389,8 @@ namespace LuaCreature
|
||||
case SELECT_TARGET_RANDOM:
|
||||
{
|
||||
std::list<Unit*>::const_iterator itr = targetList.begin();
|
||||
std::advance(itr, urand(position, targetList.size() - 1));
|
||||
if (position)
|
||||
std::advance(itr, urand(0, position));
|
||||
Eluna::Push(L, *itr);
|
||||
}
|
||||
break;
|
||||
@@ -400,8 +409,9 @@ namespace LuaCreature
|
||||
uint32 i = 0;
|
||||
|
||||
ThreatList const& threatList = creature->getThreatManager().getThreatList();
|
||||
ThreatList::const_iterator itr;
|
||||
for (itr = threatList.begin(); itr != threatList.end(); ++itr)
|
||||
if (threatList.empty())
|
||||
return 1;
|
||||
for (ThreatList::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
|
||||
{
|
||||
Unit* target = (*itr)->getTarget();
|
||||
if (!target)
|
||||
|
||||
Reference in New Issue
Block a user