void JustDied(Unit* killer)
    {
        if (ScriptedInstance* pInstance = (ScriptedInstance*)m_creature->GetInstanceData())
        {
            Creature* pSelin = pInstance->GetSingleCreatureFromStorage(NPC_SELIN_FIREHEART);

            if (pSelin && pSelin->isAlive())
            {
                boss_selin_fireheartAI* pSelinAI = dynamic_cast<boss_selin_fireheartAI*>(pSelin->AI());

                if (pSelinAI && pSelinAI->m_crystalGuid == m_creature->GetObjectGuid())
                {
                    // Set this to false if we are the creature that Selin is draining so his AI flows properly
                    pSelinAI->m_bDrainingCrystal = false;
                    pSelinAI->m_bIsDraining = false;
                    pSelinAI->m_uiEmpowerTimer = 10000;

                    if (pSelin->getVictim())
                    {
                        pSelin->AI()->AttackStart(pSelin->getVictim());
                        pSelin->GetMotionMaster()->MoveChase(pSelin->getVictim());
                    }
                }
            }
        }
    }
Example #2
0
    void JustDidDialogueStep(int32 iEntry) override
    {
        if (!m_pInstance)
            return;

        switch (iEntry)
        {
            case NPC_HUMMEL:
            {
                if (Creature* pHummel = m_pInstance->GetSingleCreatureFromStorage(NPC_HUMMEL))
                {
                    // WARNING: workaround -> faction should be set on event start
                    pHummel->SetFactionTemporary(FACTION_HOSTILE, TEMPFACTION_RESTORE_REACH_HOME | TEMPFACTION_RESTORE_RESPAWN);
                    pHummel->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE | UNIT_FLAG_NON_ATTACKABLE);

                    if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_EventStarterGuid))
                        pHummel->AI()->AttackStart(pPlayer);
                }

                m_pInstance->SetData(TYPE_APOTHECARY, IN_PROGRESS);
                break;
            }
            case NPC_BAXTER:
            {
                Creature* pHummel = m_pInstance->GetSingleCreatureFromStorage(NPC_HUMMEL);
                if (!pHummel)
                    return;

                if (Creature* pBaxter = m_pInstance->GetSingleCreatureFromStorage(NPC_BAXTER))
                {
                    DoScriptText(SAY_CALL_BAXTER, pHummel);

                    // WARNING: workaround -> faction should be set on event start
                    pBaxter->SetFactionTemporary(FACTION_HOSTILE, TEMPFACTION_RESTORE_REACH_HOME | TEMPFACTION_RESTORE_RESPAWN);
                    pBaxter->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE | UNIT_FLAG_NON_ATTACKABLE);
                    if (pHummel->getVictim())
                        pBaxter->AI()->AttackStart(pHummel->getVictim());
                }
                break;
            }
            case NPC_FRYE:
            {
                Creature* pHummel = m_pInstance->GetSingleCreatureFromStorage(NPC_HUMMEL);
                if (!pHummel)
                    return;

                if (Creature* pFrye = m_pInstance->GetSingleCreatureFromStorage(NPC_FRYE))
                {
                    DoScriptText(SAY_CALL_FRYE, pHummel);

                    // WARNING: workaround -> faction should be set on event start
                    pFrye->SetFactionTemporary(FACTION_HOSTILE, TEMPFACTION_RESTORE_REACH_HOME | TEMPFACTION_RESTORE_RESPAWN);
                    pFrye->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE | UNIT_FLAG_NON_ATTACKABLE);
                    if (pHummel->getVictim())
                        pFrye->AI()->AttackStart(pHummel->getVictim());
                }
                break;
            }
        }
    }
Example #3
0
    void AttackStart(Unit* pWho)
    {
        if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE) || m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
            return;

        if (m_creature->Attack(pWho, true))
        {
            m_creature->AddThreat(pWho, 0.0f);
            m_creature->SetInCombatWith(pWho);
            pWho->SetInCombatWith(m_creature);
            DoStartMovement(pWho);

            if (pInstance)
            {
                if (pGuard1)
                {
                    pGuard1->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                    if (!pGuard1->getVictim() && pGuard1->AI())
                        pGuard1->AI()->AttackStart(pWho);
                }
     
                if (pGuard2)
                {
                    pGuard2->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                    if (!pGuard2->getVictim() && pGuard2->AI())
                        pGuard2->AI()->AttackStart(pWho);
                }
            }
        }
    }
void FleeingMovementGenerator<Creature>::Finalize(Creature &owner)
{
    owner.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
    owner.ClearUnitState(UNIT_STATE_FLEEING|UNIT_STATE_FLEEING_MOVE);
    if (owner.getVictim())
        owner.SetTarget(owner.getVictim()->GetGUID());
}
void ConfusedMovementGenerator<Creature>::Finalize(Creature &unit)
{
    unit.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
    unit.ClearUnitState(UNIT_STATE_CONFUSED|UNIT_STATE_CONFUSED_MOVE);
    if (unit.getVictim())
        unit.SetTarget(unit.getVictim()->GetGUID());
}
void ChaseMovementGenerator<Creature>::Initialize(Creature &owner)
{
    owner.SetWalk(false);
    owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE);
    _setTargetLocation(owner);

    if (owner.getVictim() && !owner.hasUnitState(UNIT_STAT_MELEE_ATTACKING))
        owner.Attack(owner.getVictim(), !owner.IsNonMeleeSpellCasted(true));
}
Example #7
0
 void UpdateAI(const uint32 diff)
 {
     switch (phase)
     {
     case 0: // circle around the platform
         return;
         break;
     case 1: // go to the middle and begin the fight
         if (check <= diff)
         {
             if (!me->IsWithinDist3d(VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2], 5))
             {
                 me->GetMotionMaster()->Clear();
                 me->GetMotionMaster()->MovePoint(0, VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2]);
                 check = 1000;
             }
             else
             {
                 SummonAdds();
                 phase = 2;
                 return;
             }
         }
         else
             check -= diff;
         break;
     default: // adds do the job now
         if (check <= diff)
         {
             Creature* Nazan = Unit::GetCreature(*me, NazanGUID);
             Creature* Vazruden = Unit::GetCreature(*me, VazrudenGUID);
             if ((Nazan && Nazan->isAlive()) || (Vazruden && Vazruden->isAlive()))
             {
                 if ((Nazan && Nazan->getVictim()) || (Vazruden && Vazruden->getVictim()))
                     return;
                 else
                 {
                     UnsummonAdds();
                     EnterEvadeMode();
                     return;
                 }
             }
             else if (!lootSpawned)
             {
                 me->SummonGameObject(DUNGEON_MODE(ENTRY_REINFORCED_FEL_IRON_CHEST, ENTRY_REINFORCED_FEL_IRON_CHEST_H), VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2], 0, 0, 0, 0, 0, 0);
                 me->SetLootRecipient(NULL); // don't think this is necessary..
                 //me->Kill(me);
                 lootSpawned = true;
             }
             check = 2000;
         }
         else
             check -= diff;
         break;
     }
 }
 void UpdateAI(const uint32 diff)
 {
     switch (phase)
     {
     case 0: // circle around the platform
         return;
         break;
     case 1: // go to the middle and begin the fight
         if (check <= diff)
         {
             if (me->GetDistance(VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2]) > 5)
             {
                 me->GetMotionMaster()->Clear();
                 me->GetMotionMaster()->MovePoint(0, VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2]);
                 check = 1000;
             }
             else
             {
                 SummonAdds();
                 phase = 2;
                 return;
             }
         }
         else check -= diff;
         break;
     default: // adds do the job now
         if (check <= diff)
         {
             Creature* Nazan = Unit::GetCreature(*me, NazanGUID);
             Creature* Vazruden = Unit::GetCreature(*me, VazrudenGUID);
             if ((Nazan && Nazan->IsAlive()) || (Vazruden && Vazruden->IsAlive()))
             {
                 if ((Nazan && Nazan->getVictim()) || (Vazruden && Vazruden->getVictim()))
                     return;
                 else
                 {
                     Reset();
                     EnterEvadeMode();
                     return;
                 }
             }
             else
             {
                 me->SummonGameObject(ENTRY_REINFORCED_FEL_IRON_CHEST, VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2], 0, 0, 0, 0, 0, 0);
                 me->SetLootRecipient(NULL);
                 me->DealDamage(me, me->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                 if (pInstance)
                     pInstance->SetData(DATA_VAZRUDEN, DONE);
             }
             check = 2000;
         }
         else check -= diff;
         break;
     }
 }
Example #9
0
 void EnterCombat(Unit* /*who*/)
 {
     DoScriptText(SAY_ROMULO_AGGRO, me);
     if (JulianneGUID)
     {
         Creature* Julianne = (Unit::GetCreature((*me), JulianneGUID));
         if (Julianne && Julianne->getVictim())
         {
             me->AddThreat(Julianne->getVictim(), 1.0f);
             AttackStart(Julianne->getVictim());
         }
     }
 }
Example #10
0
    bool EffectDummy(Unit* pCaster, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Object* pTarget, ObjectGuid /*originalCasterGuid*/) override
    {
        Creature *pCreatureTarget = pTarget->ToCreature();
        if (!pCreatureTarget)
            return true;

        if (uiSpellId == SPELL_THROW_GORDAWG_BOULDER && uiEffIndex == EFFECT_INDEX_0)
        {
            for (int i = 0; i < 3; ++i)
            {
                if (irand(i, 2))                        // 2-3 summons
                {
                    pCreatureTarget->SummonCreature(NPC_MINION_OF_GUROK, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_CORPSE_DESPAWN, 5000);
                }
            }

            if (pCreatureTarget->getVictim())
            {
                pCaster->DealDamage(pCreatureTarget, pCreatureTarget->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                return true;
            }

            // If not in combat, no xp or loot
            pCreatureTarget->SetDeathState(JUST_DIED);
            pCreatureTarget->SetHealth(0);
            return true;
        }
        return true;
    }
void CreatureFormation::MemberAttackStart(Creature* member, Unit* target)
{
    uint8 formationAI = CreatureFormationMap[m_formationID]->formationAI;

    if (!formationAI)
        return;

    if (formationAI == 1 && member != m_leader)
        return;

    for (CreatureFormationMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        Creature* pCreature = itr->first;

        if (m_leader) // avoid crash if leader was killed and reset.
            sLog.outDebug("CreatureFormation::MemberAttackStart: formation instance id %u calls member instid %u", m_leader->GetInstanceId(), member->GetInstanceId());

        //Skip one check
        if (pCreature == member)
            continue;

        if (!pCreature->isAlive())
            continue;

        if (pCreature->getVictim())
            continue;

        if (pCreature->IsAIEnabled)
            if (pCreature->canAttack(target))
                pCreature->AI()->AttackStart(target);
    }
}
Example #12
0
void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
{
    uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetDBTableGUIDLow()]->groupAI;
    if (!groupAI)
        return;

    if (groupAI == 1 && member != m_leader)
        return;

    for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        if (m_leader) // avoid crash if leader was killed and reset.
            sLog->outDebug(LOG_FILTER_UNITS, "GROUP ATTACK: group instance id %u calls member instid %u", m_leader->GetInstanceId(), member->GetInstanceId());

        Creature* first = itr->first;
        //Skip one check
        if (first == member)
            continue;

        if (!first->isAlive())
            continue;

        if (first->getVictim())
            continue;

        if (first->IsValidAttackTarget(target) && first->AI())
            first->AI()->AttackStart(target);
    }
}
Example #13
0
    void Sinister(Player* victim,uint8 i,uint8 k)
    {
        uint32 spell;

        switch(victim->getClass())
        {
            case CLASS_PRIEST:  spell = SPELL_PRIEST; break;
            case CLASS_PALADIN: spell = SPELL_PALADIN; break;
            case CLASS_WARLOCK: spell = SPELL_WARLOCK; break;
            case CLASS_MAGE:    spell = SPELL_MAGE; break;
            case CLASS_ROGUE:   spell = SPELL_ROGUE; break;
            case CLASS_WARRIOR: spell = SPELL_WARRIOR; break;
            case CLASS_DRUID:   spell = SPELL_DRUID; break;
            case CLASS_SHAMAN:  spell = SPELL_SHAMAN; break;
            case CLASS_HUNTER:  spell = SPELL_HUNTER; break;
        }

        for(i=0; i<k; ++i)
        {
            Creature* Sinister = me->SummonCreature(ID_SINISTER, victim->GetPositionX()+rand()%3, victim->GetPositionY()+rand()%3, me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
            if(Sinister)
            {
                Sinister->AI()->AttackStart(Sinister->getVictim());
                SinisterGUID[i][0] = Sinister->GetGUID();
                SinisterGUID[i][1] = spell;
            }
        }
    }
Example #14
0
void CreatureGroup::LeaderMoveTo(float x, float y, float z)
{
    if (!m_leader)
        return;

    float pathangle    = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x);

    for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        Creature* member = itr->first;
        if (member == m_leader || !member->isAlive() || member->getVictim())
            continue;

        float angle = itr->second->follow_angle;
        float dist = itr->second->follow_dist;

        float dx = x + cos(angle + pathangle) * dist;
        float dy = y + sin(angle + pathangle) * dist;
        float dz = z;

        Trinity::NormalizeMapCoord(dx);
        Trinity::NormalizeMapCoord(dy);

        member->UpdateGroundPositionZ(dx, dy, dz);

        if (member->IsWithinDist(m_leader, dist + MAX_DESYNC))
            member->SetUnitMovementFlags(m_leader->GetUnitMovementFlags());
        else
            member->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);

        member->GetMotionMaster()->MovePoint(0, dx, dy, dz);
        member->SetHomePosition(dx, dy, dz, pathangle);
    }
}
void ChaseMovementGenerator<Creature>::initialize(Creature& owner)
{
    owner.SetWalk(false, false);                            // Chase movement is running
    owner.addUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE);

    Unit* pVictim = owner.getVictim();
    if (pVictim && !owner.hasUnitState(UNIT_STAT_MELEE_ATTACKING))
        owner.Attack(pVictim, !owner.IsNonMeleeSpellCasted(true));
}
Example #16
0
    void UpdateAI(const uint32 uiDiff)
    {
        // OOC
        if (m_uiCheckoutTimer <= uiDiff)
        {
            for (int i = 0; i < MAX_WEAVERS; ++i)
            {
                if (WeaverGUID[i] == 0)
                    continue;

                Creature* pWeaver = m_creature->GetMap()->GetCreature(WeaverGUID[i]);
                // return weavers to orginal spawn point
                if (pWeaver && pWeaver->isAlive())
                {
                    if (!pWeaver->SelectHostileTarget() || !pWeaver->getVictim())
                    {
                        if ((m_creature->GetDistance(pWeaver) > (SPAWN_DISTANCE + 1.5)) || (m_creature->GetDistance(pWeaver) < (SPAWN_DISTANCE - 1.5)))
                        {
                            pWeaver->GetMotionMaster()->Clear();
                            pWeaver->GetMotionMaster()->MovePoint(0, WeaverPOSITION[i][0], WeaverPOSITION[i][1], WeaverPOSITION[i][2]);
                        }
                        else if (!pWeaver->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
                            pWeaver->CastSpell(m_creature, SPELL_WEAVING_OOC, false);
                    }
                    else if (pWeaver->HasAura(SPELL_WEAVING_OOC)) 
                        pWeaver->InterruptSpell(CURRENT_CHANNELED_SPELL);
                }
            }
            m_uiCheckoutTimer = 1000;
        } m_uiCheckoutTimer -= uiDiff;

        // in combat
        if(!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiEventTimer <= uiDiff)
        {
            if (Unit* pVictim = m_creature->getVictim())
            {
                switch(m_creature->GetEntry())
                {
                    case NPC_DURVAL: DoCastSpellIfCan(pVictim, SPELL_RUNE_OF_DESTRUCTION);  break;
                    case NPC_LOCHLI: DoCastSpellIfCan(pVictim, SPELL_THUNDERSTORM);         break;
                    case NPC_KORGAN:
                        if (m_creature->GetHealthPercent() < 80.0f)
                            DoCastSpellIfCan(m_creature, SPELL_SPELL_REVITALIZING_RUNE);
                        else DoCastSpellIfCan(pVictim, SPELL_CALL_LIGHTNING);
                        break;
                    default: break;
                }
            }
            m_uiEventTimer = 30000;
        } else m_uiEventTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }                 
 void AddJustAggroed(Unit* pWho)
 {
     // Let all adds attack
     for (GuidVector::const_iterator itr = m_vAddGuids.begin(); itr != m_vAddGuids.end(); ++itr)
     {
         Creature* pAdd = m_creature->GetMap()->GetCreature(*itr);
         if (pAdd && !pAdd->getVictim())
             pAdd->AI()->AttackStart(pWho);
     }
 }
Example #18
0
    void FetchDragons()
    {
        Creature* pTene = m_pInstance->GetSingleCreatureFromStorage(NPC_TENEBRON);
        Creature* pShad = m_pInstance->GetSingleCreatureFromStorage(NPC_SHADRON);
        Creature* pVesp = m_pInstance->GetSingleCreatureFromStorage(NPC_VESPERON);

        // if at least one of the dragons are alive and are being called
        uint8 uiCountFetchableDragons = 0;

        if (pTene && pTene->IsAlive() && !pTene->getVictim())
        {
            ++uiCountFetchableDragons;
            pTene->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aTene[0].m_fX, m_aTene[0].m_fY, m_aTene[0].m_fZ);

            if (!pTene->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
                pTene->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
        }

        if (pShad && pShad->IsAlive() && !pShad->getVictim())
        {
            ++uiCountFetchableDragons;
            pShad->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aShad[0].m_fX, m_aShad[0].m_fY, m_aShad[0].m_fZ);

            if (!pShad->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
                pShad->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
        }

        if (pVesp && pVesp->IsAlive() && !pVesp->getVictim())
        {
            ++uiCountFetchableDragons;
            pVesp->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aVesp[0].m_fX, m_aVesp[0].m_fY, m_aVesp[0].m_fZ);

            if (!pVesp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
                pVesp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
        }

        if (uiCountFetchableDragons)
            DoCastSpellIfCan(m_creature, SPELL_WILL_OF_SARTHARION);

        m_pInstance->SetData(TYPE_ALIVE_DRAGONS, uiCountFetchableDragons);
    }
    void Aggro(Unit* pWho)
    {
        if (!m_pInstance)
        {
            ERROR_INST_DATA(m_creature);
            return;
        }

        Creature* pTerestian = ((Creature*)Unit::GetUnit(*m_creature, m_pInstance->GetData64(DATA_TERESTIAN)));
        if (pTerestian && (!pTerestian->SelectHostileTarget() && !pTerestian->getVictim()))
            pTerestian->AddThreat(pWho);
    }
Example #20
0
    void Aggro(Unit *who)
    {
        if(!pInstance)
        {
            ERROR_INST_DATA(m_creature);
            return;
        }

        Creature* Terestian = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_TERESTIAN)));
        if(Terestian && (!Terestian->SelectHostilTarget() && !Terestian->getVictim()))
            Terestian->AddThreat(who, 1.0f);
    }
    void EnterCombat(Unit *who)
    {
        if (!pInstance)
        {
            ERROR_INST_DATA(m_creature);
            return;
        }

        Creature* Terestian = (Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_TERESTIAN)));
        if (Terestian && !Terestian->getVictim())
            Terestian->AddThreat(who, 1.0f);
    }
Example #22
0
    static bool HandleCastTargetCommad(ChatHandler* handler, char const* args)
    {
        Creature* caster = handler->getSelectedCreature();
        if (!caster)
        {
            handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
            handler->SetSentErrorMessage(true);
            return false;
        }

        if (!caster->getVictim())
        {
            handler->SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM);
            handler->SetSentErrorMessage(true);
            return false;
        }

        // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
        uint32 spellId = handler->extractSpellIdFromLink((char*)args);
        if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
        {
            handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
            handler->SetSentErrorMessage(true);
            return false;
        }

        char* triggeredStr = strtok(NULL, " ");
        if (triggeredStr)
        {
            int l = strlen(triggeredStr);
            if (strncmp(triggeredStr, "triggered", l) != 0)
                return false;
        }

        bool triggered = (triggeredStr != NULL);

        caster->CastSpell(caster->getVictim(), spellId, triggered);

        return true;
    }
Example #23
0
void CreatureGroup::LeaderMoveTo(float x, float y, float z)
{
    m_movingUnits = 0;
    if (!m_leader)
        return;

    float pathangle = atan2(m_leader->GetPositionY() - y, m_leader->GetPositionX() - x);

    for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        Creature *member = m_leader->GetMap()->GetCreature(itr->first);
        if (!member || member == m_leader || !member->isAlive() || member->getVictim())
            continue;

        float angle = itr->second->follow_angle;
        float dist = itr->second->follow_dist;

        // if follow distance is 0 then don't follow leader
        if (!dist)
            continue;

        float dx = x + cos(angle + pathangle) * dist;
        float dy = y + sin(angle + pathangle) * dist;
        float dz = z;

        Hellground::NormalizeMapCoord(dx);
        Hellground::NormalizeMapCoord(dy);

        member->UpdateGroundPositionZ(dx, dy, dz);

        if (member->IsWithinDistInMap(m_leader, dist + MAX_DESYNC))
        {
            uint32 moveFlags = m_leader->GetUnitMovementFlags();
            if (!member->m_movementInfo.HasMovementFlag(MOVEFLAG_SPLINE_ENABLED))
                moveFlags &= ~MOVEFLAG_SPLINE_ENABLED;

            member->SetUnitMovementFlags(moveFlags);
        }
        else
        {
            // jak sie za bardzo rozjada xO
            if (!member->IsWithinDistInMap(m_leader, 40.0f))
                member->NearTeleportTo(m_leader->GetPositionX(), m_leader->GetPositionY(), m_leader->GetPositionZ(), 0.0f);
            else
                member->SetWalk(false);
        }

        member->GetMotionMaster()->MovePoint(0, dx, dy, dz, true, true, UNIT_ACTION_HOME);
        member->SetHomePosition(m_leader->GetPositionX(), m_leader->GetPositionY(), m_leader->GetPositionZ(), pathangle);
        m_movingUnits++;
    }
}
Example #24
0
 void Aggro(Unit* pWho)
 {
     if (m_pInstance)
     {
         Creature* pEmalon = (Creature*)Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_EMALON));
         if (pEmalon && !pEmalon->getVictim())
             pEmalon->AI()->AttackStart(pWho);
         Creature* pMinion = NULL;
         pMinion = (Creature*)Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_TEMPEST_MINION_1));
         if (pMinion && !pMinion->getVictim())
             pMinion->AI()->AttackStart(pWho);
         pMinion = (Creature*)Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_TEMPEST_MINION_2));
         if (pMinion && !pMinion->getVictim())
             pMinion->AI()->AttackStart(pWho);
         pMinion = (Creature*)Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_TEMPEST_MINION_3));
         if (pMinion && pMinion->isAlive() && !pMinion->getVictim())
             pMinion->AI()->AttackStart(pWho);
         pMinion = (Creature*)Unit::GetUnit((*m_creature), m_pInstance->GetData64(DATA_TEMPEST_MINION_4));
         if (pMinion && !pMinion->getVictim())
             pMinion->AI()->AttackStart(pWho);
     }
 }
 void JustDied(Unit* killer)
 {
     if (ScriptedInstance* pInstance = ((ScriptedInstance*)m_creature->GetInstanceData()))
     {
         Creature* Selin = ((Creature*)Unit::GetUnit(*m_creature, pInstance->GetData64(DATA_SELIN)));
         if (Selin && Selin->isAlive())
         {
             if (((boss_selin_fireheartAI*)Selin->AI())->CrystalGUID == m_creature->GetGUID())
             {
                 // Set this to false if we are the creature that Selin is draining so his AI flows properly
                 ((boss_selin_fireheartAI*)Selin->AI())->DrainingCrystal = false;
                 ((boss_selin_fireheartAI*)Selin->AI())->IsDraining = false;
                 ((boss_selin_fireheartAI*)Selin->AI())->EmpowerTimer = 10000;
                 if (Selin->getVictim())
                 {
                     Selin->AI()->AttackStart(Selin->getVictim());
                     Selin->GetMotionMaster()->MoveChase(Selin->getVictim());
                 }
             }
         }
     }else error_log(ERROR_INST_DATA);
 }
void world_map_ebon_hold::OnCreatureDeath(Creature* pCreature)
{
    if (GetData(TYPE_BATTLE) != IN_PROGRESS)
        return;

    switch (pCreature->GetEntry())
    {
            // resummon the behemots or abominations if they die
        case NPC_FLESH_BEHEMOTH:
        case NPC_RAMPAGING_ABOMINATION:
            m_lArmyGuids.remove(pCreature->GetObjectGuid());// if remove respawning on reset won't work! (are there any spawned by default?) ?? - unclear related to ResetBattle()
            if (Creature* pTemp = pCreature->SummonCreature(pCreature->GetEntry(), pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ(), pCreature->GetOrientation(), TEMPSUMMON_CORPSE_DESPAWN, 0))
            {
                // the new summoned mob should attack
                Creature* pDarion = GetSingleCreatureFromStorage(NPC_HIGHLORD_DARION_MOGRAINE);
                if (pDarion && pDarion->getVictim())
                    pTemp->AI()->AttackStart(pDarion->getVictim());
            }
            pCreature->ForcedDespawn(1000);
            break;
    }
}
 void JustDied(Unit* /*killer*/)
 {
     if (InstanceScript* instance = me->GetInstanceScript())
     {
         Creature* Selin = (Unit::GetCreature(*me, instance->GetData64(DATA_SELIN)));
         if (Selin && Selin->isAlive())
         {
             if (CAST_AI(boss_selin_fireheart::boss_selin_fireheartAI, Selin->AI())->CrystalGUID == me->GetGUID())
             {
                 // Set this to false if we are the Creature that Selin is draining so his AI flows properly
                 CAST_AI(boss_selin_fireheart::boss_selin_fireheartAI, Selin->AI())->DrainingCrystal = false;
                 CAST_AI(boss_selin_fireheart::boss_selin_fireheartAI, Selin->AI())->IsDraining = false;
                 CAST_AI(boss_selin_fireheart::boss_selin_fireheartAI, Selin->AI())->EmpowerTimer = 10000;
                 if (Selin->getVictim())
                 {
                     Selin->AI()->AttackStart(Selin->getVictim());
                     Selin->GetMotionMaster()->MoveChase(Selin->getVictim());
                 }
             }
         }
     } else sLog->outError(ERROR_INST_DATA);
 }
Example #28
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            events.Update(diff);

            if (me->HasUnitState(UNIT_STATE_CASTING))
                return;

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch (eventId)
                {
                case EVENT_WHIRLWIND:
                {
                    DoCastVictim(SPELL_WHIRLWIND);
                    events.ScheduleEvent(EVENT_WHIRLWIND, urand(10000, 15000));
                }
                break;
                case EVENT_HEROIC_LEAP:
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_FARTHEST, 0, 25.0f, true))
                    {
                        me->GetMotionMaster()->MoveJump(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), SPEED_CHARGE, SPEED_CHARGE, 1);
                        DoCast(target, SPELL_HEROIC_LEAP);
                    }
                    events.ScheduleEvent(EVENT_HEROIC_LEAP, urand(40000, 50000));
                }
                break;
                case EVENT_SUMMON_GUARDS:
                {
                    // this feels a bit custom, but sources say he summons guards...so lets summon guards!
                    uint32 guardCount = urand(1,2);
                    for (uint32 iter = 0; iter < guardCount; ++iter)
                    {
                        Creature* summon = me->SummonCreature(NPC_GUARD, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 45.0f, true))
                        {
                            summon->Attack(target, true);
                            summon->GetMotionMaster()->MoveChase(summon->getVictim());
                        }
                    }
                    events.ScheduleEvent(EVENT_SUMMON_GUARDS, urand(30000, 45000));
                }
                break;
                }
            }

            DoMeleeAttackIfReady();
        }
    void EnterCombat(Unit* who)
    {
        DoScriptText(SAY_AGGRO, me);

        if(pInstance)
        {
            // Put Kil'rek in combat against our target so players don't skip him
            Creature* Kilrek = (Unit::GetCreature(*me, pInstance->GetData64(DATA_KILREK)));
            if(Kilrek && !Kilrek->getVictim())
                Kilrek->AddThreat(who, 1.0f);

            pInstance->SetData(DATA_TERESTIAN, IN_PROGRESS);
        }else ERROR_INST_DATA(me);
    }
 void JustDied(Unit* killer)
 {
     me->RemoveAurasDueToSpell(SPELL_MANA_RAGE);
     if (ScriptedInstance* pInstance = (me->GetInstanceData()))
     {
         Creature* Selin = (Unit::GetCreature(*me, pInstance->GetData64(DATA_SELIN)));
         if (Selin && Selin->isAlive())
         {
             if (((boss_selin_fireheartAI*)Selin->AI())->CrystalGUID == me->GetGUID())
             {
                 // Set this to false if we are the creature that Selin is draining so his AI flows properly
                 ((boss_selin_fireheartAI*)Selin->AI())->DrainingCrystal = false;
                 ((boss_selin_fireheartAI*)Selin->AI())->IsDraining = false;
                 Selin->RemoveAurasDueToSpell(SPELL_MANA_RAGE);
                 if (Selin->getVictim())
                 {
                     Selin->AI()->AttackStart(Selin->getVictim());
                     Selin->GetMotionMaster()->MoveChase(Selin->getVictim());
                 }
             }
         }
     } else error_log(ERROR_INST_DATA);
 }