Update CreatureMethods.h

This commit is contained in:
Rochet2
2014-06-14 12:35:01 +03:00
committed by Foereaper
parent 719707f8b0
commit 6e4e77f18d

View File

@@ -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();
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,7 +372,8 @@ namespace LuaCreature
case SELECT_TARGET_TOPAGGRO:
{
std::list<Unit*>::const_iterator itr = targetList.begin();
std::advance(itr, position);
if (position)
std::advance(itr, position);
Eluna::Push(L, *itr);
}
break;
@@ -374,14 +381,16 @@ namespace LuaCreature
case SELECT_TARGET_BOTTOMAGGRO:
{
std::list<Unit*>::reverse_iterator ritr = targetList.rbegin();
std::advance(ritr, position);
if (position)
std::advance(ritr, position);
Eluna::Push(L, *ritr);
}
break;
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)