Sup!
I'm currently developing my own server and I'm not releasing it before I've got my Karazhan and Gruul scripts close-to-blizzlike.
Now I'm stuck on my last boss, which is Netherspite.
If you don't know the fight:
There are 3 portals in the room which cast a beam on Netherspite.
If there is a player in between the Portal and Netherspite, then the beam is cast on the Player instead.
Now I've got it partially working, but it's far from perfect.
This is the script:
Code:
Unit* u_netherspite = netherspite[_unit->GetInstanceID()];
float PI = 3.14159265f;
float nethX = u_netherspite->GetPositionX();
float nethY = u_netherspite->GetPositionY();
float minAngle = _unit->calcAngle(_unit->GetPositionX(), _unit->GetPositionY(), nethX, nethY) - (PI/16);
float maxAngle = _unit->calcAngle(_unit->GetPositionX(), _unit->GetPositionY(), nethX, nethY) + (PI/16);
float distance = _unit->GetDistance2dSq(u_netherspite);
//Unit* target = u_netherspite;
Unit* target = NULL;
set<Object*>::iterator itr;
for(itr = _unit->GetInRangeSetBegin(); itr != _unit->GetInRangeSetEnd(); ++itr)
{
if ( (*itr)->GetTypeId() != TYPEID_UNIT && (*itr)->GetTypeId() != TYPEID_PLAYER )
continue;
float getAngle = _unit->calcAngle(_unit->GetPositionX(), _unit->GetPositionY(), (*itr)->GetPositionX(), (*itr)->GetPositionY());
if (getAngle > minAngle &&
getAngle < maxAngle &&
_unit->GetDistance2dSq((*itr)) < distance)
{
// needs more checks
distance = _unit->GetDistance2dSq((*itr));
target = static_cast<Unit*>((*itr));
break;
}
else
target = u_netherspite;
}
Now what happens is he will always cast it on Netherspite untill a player gets REALLY CLOSE to Netherspite, then it MIGHT target the player (moving an inch can change it back to Netherspite)
Now my question is: Anyone knows what I'm doing wrong or knows how to fix it?