Esempio n. 1
0
 void AttackStart(Unit* pWho) override
 {
     if (m_creature->Attack(pWho, true))
     {
         m_creature->AddThreat(pWho);
         m_creature->SetInCombatWith(pWho);
         pWho->SetInCombatWith(m_creature);
         HandleMovementOnAttackStart(pWho);
     }
 }
Esempio n. 2
0
/**
 * This function sets the TargetGuid for the creature if required
 * Also it will handle the combat movement (chase movement), depending on SetCombatMovement(bool)
 */
void ScriptedAI::AttackStart(Unit* pWho)
{
    if (pWho && m_creature->Attack(pWho, true))             // The Attack function also uses basic checks if pWho can be attacked
    {
        m_creature->AddThreat(pWho);
        m_creature->SetInCombatWith(pWho);
        pWho->SetInCombatWith(m_creature);

        HandleMovementOnAttackStart(pWho);
    }
}
Esempio n. 3
0
void UnitAI::AttackStart(Unit* who)
{
    if (!who || HasReactState(REACT_PASSIVE))
        return;

    if (m_unit->Attack(who, m_meleeEnabled))
    {
        m_unit->AddThreat(who);
        m_unit->SetInCombatWith(who);
        who->SetInCombatWith(m_unit);

        HandleMovementOnAttackStart(who);
    }
}
Esempio n. 4
0
void PetAI::AttackStart(Unit* u)
{
    if (!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET))
        return;

    if (m_creature->Attack(u, true))
    {
        // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
        // thus with the following clear the original TMG gets invalidated and crash, doh
        // hope it doesn't start to leak memory without this :-/
        // i_pet->Clear();
        HandleMovementOnAttackStart(u);
        inCombat = true;
    }
}
Esempio n. 5
0
void GuardAI::AttackStart(Unit* u)
{
    if (!u)
        return;

    if (m_creature->Attack(u, true))
    {
        i_victimGuid = u->GetObjectGuid();
        m_creature->AddThreat(u);
        m_creature->SetInCombatWith(u);
        u->SetInCombatWith(m_creature);

        HandleMovementOnAttackStart(u);
    }
}
Esempio n. 6
0
/**
 * This function sets the TargetGuid for the creature if required
 * Also it will handle the combat movement (chase movement), depending on SetCombatMovement(bool)
 */
void ScriptedAI::AttackStart(Unit* pWho)
{
#if defined (WOTLK)
    if (!m_creature->CanAttackByItself())
        return;
#endif    
    if (pWho && m_creature->Attack(pWho, true))             // The Attack function also uses basic checks if pWho can be attacked
    {
        m_creature->AddThreat(pWho);
        m_creature->SetInCombatWith(pWho);
        pWho->SetInCombatWith(m_creature);

        HandleMovementOnAttackStart(pWho);
    }
}
Esempio n. 7
0
void AggressorAI::AttackStart(Unit* u)
{
    if (!u || !m_creature->CanAttackByItself())
        return;

    if (m_creature->Attack(u, true))
    {
        i_victimGuid = u->GetObjectGuid();

        m_creature->AddThreat(u);
        m_creature->SetInCombatWith(u);
        u->SetInCombatWith(m_creature);

        HandleMovementOnAttackStart(u);
    }
}
Esempio n. 8
0
void
ReactorAI::AttackStart(Unit *p)
{
    if(!p)
        return;

    if(m_creature->Attack(p,true))
    {
        DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId());
        i_victimGuid = p->GetObjectGuid();
        m_creature->AddThreat(p);

        m_creature->SetInCombatWith(p);
        p->SetInCombatWith(m_creature);

        HandleMovementOnAttackStart(p);
    }
}
Esempio n. 9
0
void PetAI::AttackStart(Unit* u)
{
    Pet* pet = (m_unit->GetTypeId() == TYPEID_UNIT && static_cast<Creature*>(m_unit)->IsPet()) ? static_cast<Pet*>(m_unit) : nullptr;

    if (!u || (pet && pet->GetModeFlags() & PET_MODE_DISABLE_ACTIONS))
        return;

    if (m_unit->Attack(u, true))
    {
        // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
        // thus with the following clear the original TMG gets invalidated and crash, doh
        // hope it doesn't start to leak memory without this :-/
        // i_pet->Clear();
        HandleMovementOnAttackStart(u);

        inCombat = true;
    }
}
Esempio n. 10
0
void CreatureAI::AttackStart(Unit* who)
{
    if (!who || HasReactState(REACT_PASSIVE))
        return;

    if (m_creature->Attack(who, m_meleeEnabled))
    {
        m_creature->AddThreat(who);
        m_creature->SetInCombatWith(who);
        who->SetInCombatWith(m_unit);

        // Cast "Spawn Guard" to help Civilian
        if (m_creature->IsCivilian())
            m_creature->CastSpell(m_creature, 43783, TRIGGERED_OLD_TRIGGERED);

        HandleMovementOnAttackStart(who);
    }
}