И так, собственно написал скрипт еще полгода назад, который исправляет эту проблему, а также теперь будет атаковать цель пета (это дает возможность дк, контролировать свою гаргу через пета, используя /petattack)
Если сказать кратко, то реализовал Switch таргет у Горгульи.
Код:
class npc_ebon_gargoyle : public CreatureScript
{
public:
npc_ebon_gargoyle() : CreatureScript("npc_ebon_gargoyle") { }
struct npc_ebon_gargoyleAI : CasterAI
{
npc_ebon_gargoyleAI(Creature* creature) : CasterAI(creature) {}
uint32 despawnTimer;
uint32 switchTargetTimer;
void InitializeAI()
{
CasterAI::InitializeAI();
Unit * owner = me->GetOwner();
if (!owner)
return;
// Not needed to be despawned now
despawnTimer = 0;
switchTargetTimer = 1000;
// Find victim of Summon Gargoyle spell
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
me->VisitNearbyObject(30, searcher);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
if ((*iter)->GetAura(49206, owner->GetGUID()))
{
me->Attack((*iter), false);
break;
}
}
void JustDied(Unit* /*killer*/)
{
// Stop Feeding Gargoyle when it dies
if (Unit* owner = me->GetOwner())
owner->RemoveAurasDueToSpell(50514);
}
// Fly away when dismissed
void SpellHit(Unit* source, SpellInfo const* spell)
{
if (spell->Id != 50515 || !me->isAlive())
return;
Unit* owner = me->GetOwner();
if (!owner || owner != source)
return;
// Stop Fighting
me->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE, true);
// Sanctuary
me->CastSpell(me, 54661, true);
me->SetReactState(REACT_PASSIVE);
//! HACK: Creature's can't have MOVEMENTFLAG_FLYING
// Fly Away
me->AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY|MOVEMENTFLAG_ASCENDING|MOVEMENTFLAG_FLYING);
me->SetSpeed(MOVE_FLIGHT, 0.75f, true);
me->SetSpeed(MOVE_RUN, 0.75f, true);
float x = me->GetPositionX() + 20 * cos(me->GetOrientation());
float y = me->GetPositionY() + 20 * sin(me->GetOrientation());
float z = me->GetPositionZ() + 40;
me->GetMotionMaster()->Clear(false);
me->GetMotionMaster()->MovePoint(0, x, y, z);
// Despawn as soon as possible
despawnTimer = 4 * IN_MILLISECONDS;
}
void UpdateAI(const uint32 diff)
{
if (despawnTimer > 0)
{
if (despawnTimer > diff)
despawnTimer -= diff;
else
me->DespawnOrUnsummon();
return;
}
if (switchTargetTimer <= diff)
{
switchTargetTimer = 1000;
Unit * owner = me->GetOwner();
Unit * target = me->getVictim();
if (!owner)
return;
Player * player = owner->ToPlayer();
if (!player)
return;
uint64 GhoulGUID = NULL;
Unit * Ghoul=NULL;
for (Unit::ControlList::const_iterator itr = player->m_Controlled.begin(); itr != player->m_Controlled.end(); ++itr) //Find Ghoul
if ((*itr)->GetEntry() == 26125)
{
GhoulGUID = (*itr)->GetGUID();
Ghoul=(*itr);
break;
}
if (GhoulGUID && Ghoul)
{
if (target)
{
Unit * taget_ghoul = Ghoul->getVictim();
if (taget_ghoul && taget_ghoul != target)
me->Attack(taget_ghoul, false);
}
}
if (!target)
{
std::list<Unit*> targets;
Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(me, me, 30);
Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(me, targets, u_check);
me->VisitNearbyObject(30, searcher);
for (std::list<Unit*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
if ((*iter)->GetAura(49206, owner->GetGUID()))
{
me->Attack((*iter), false);
break;
}
}
} else switchTargetTimer -= diff;
CasterAI::UpdateAI(diff);
}
};
CreatureAI* GetAI(Creature* creature) const
{
return new npc_ebon_gargoyleAI(creature);
}
};