Example #1
0
    void UpdateAI(const uint32 diff)
    {
        if (RefreshTimer <= diff)
            RefreshTimer = 0;
        else RefreshTimer -= diff;

        if (TargetSelected && TargetGUID)
        {
            Unit *pTarget = Unit::GetUnit((*me), TargetGUID);
            if (pTarget && pTarget->isAlive())
            {
                pTarget->CastSpell(pTarget, SPELL_DOOMFIRE_DAMAGE, true);
                TargetGUID = 0;
                TargetSelected = false;
            }
        }

        if (CheckTimer <= diff)
        {
            if (ArchimondeGUID)
            {
                Unit* Archimonde = Unit::GetUnit((*me), ArchimondeGUID);
                if (!Archimonde || !Archimonde->isAlive())
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                CheckTimer = 5000;
            }
            else me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
        } else CheckTimer -= diff;
    }
    void removeAdds()
    {
        for (std::vector<uint64>::iterator itr = adds.begin(); itr != adds.end(); ++itr)
        {
            Unit* temp = Unit::GetUnit((*me),*itr);
            if (temp && temp->isAlive())
            {
                (*temp).GetMotionMaster()->Clear(true);
                me->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                CAST_CRE(temp)->RemoveCorpse();
            }
        }
        adds.clear();

        for (std::vector<uint64>::iterator itr = assassins.begin(); itr != assassins.end(); ++itr)
        {
            Unit* temp = Unit::GetUnit((*me),*itr);
            if (temp && temp->isAlive())
            {
                (*temp).GetMotionMaster()->Clear(true);
                me->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                CAST_CRE(temp)->RemoveCorpse();
            }
        }
        assassins.clear();
    }
        void IsSummonedBy(Unit * summoner)
        {
            me->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);

            ThreatContainer::StorageType const& m_threatList = summoner->getThreatManager().getThreatList();
            if (m_threatList.empty())
                return;

            for(ThreatContainer::StorageType::const_iterator itr = m_threatList.begin(); itr != m_threatList.end(); ++itr)
            {
                Unit * unit = me->GetUnit(*me, (*itr)->getUnitGuid());
                if(unit && unit->isAlive() && unit->GetTypeId() == TYPEID_PLAYER)
                    targetGUIDs.push_back((*itr)->getUnitGuid());
            }

            if(!targetGUIDs.empty())
            {
                Unit * target = me->GetUnit(*me, targetGUIDs.front());
                if(target && target->isAlive())
                {
                    currentTarget = targetGUIDs.front();
                    me->GetMotionMaster()->Clear();
                    me->GetMotionMaster()->MoveFollow(target, 0.0f, 0.0f);
                }
            }
        }
Example #4
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (DefenderTimer < diff)
        {
            Unit *defender = DoSpawnCreature(CR_FERAL_DEFENDER, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
            Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
            if(defender && target && target->isAlive())
                defender->AddThreat(target, 1.0f);
            DefenderTimer = 45000;
        }
        else DefenderTimer -= diff;

        if (ScreechTimer < diff)
        {
            DoCast(m_creature, Regular ? SP_SONIC_SCREECH : H_SP_SONIC_SCREECH);
            ScreechTimer = 25000 + rand()%15000;
        }
        else ScreechTimer -= diff;

        if (SwarmTimer < diff)
        {
            Unit *target = SelectUnit(SELECT_TARGET_RANDOM, 0);
            if(target && target->isAlive())
            {
                DoCast(target, SP_GUARDIAN_SWARM);
                /*Creature *add = NULL;
                for(int i=0; i<16; i++)
                {
                    add = DoSpawnCreature(CR_SWARMING_GUARDIAN, 
                        target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0,
                        TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
                    if(add) add->AddThreat(target, 1.0f);
                }*/
            }

            SwarmTimer = 20000 + rand()%20000;
        }
        else SwarmTimer -= diff;

        if (TerrifyTimer < diff)
        {
            DoCast(m_creature->getVictim(), SP_TERRIFY);
            TerrifyTimer = 30000 + rand()%15000;
        }
        else TerrifyTimer -= diff;

        if (EnrageTimer < diff)
        {
            DoCast(m_creature, SP_BERSERK);
            EnrageTimer = 20000 + rand()%20000;
        }
        else EnrageTimer -= diff;

        DoMeleeAttackIfReady();
    }
Example #5
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if (SummonTimer <= diff)
        {
            if (ArchimondeGUID)
            {
                Unit* Archimonde = Unit::GetUnit((*me), ArchimondeGUID);
                if (Archimonde && Archimonde->isAlive())
                {
                    Creature* Doomfire = DoSpawnCreature(CREATURE_DOOMFIRE, 0, 0, 2, 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
                    if (Doomfire)
                    {
                        Doomfire->CastSpell(Doomfire, SPELL_DOOMFIRE_VISUAL, true);
                        ((mob_doomfireAI*)Doomfire->AI())->ArchimondeGUID = ArchimondeGUID;
                        Doomfire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    }
                    SummonTimer = 500;
                }
                else
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }
            else
                me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
        } else SummonTimer -= diff;

        if (ChangeTargetTimer <= diff)
        {
            Unit *pTarget = NULL;
            switch(rand()%2)
            {
                case 0:                                     // stalk player
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
                    if (pTarget && pTarget->isAlive())
                    {
                        me->AddThreat(pTarget, DoGetThreat(me->getVictim()));
                        me->GetMotionMaster()->MoveChase(pTarget);
                    }
                    break;

                case 1:                                     // random location
                    Position pos;
                    me->GetRandomNearPosition(pos, 40);
                    me->GetMotionMaster()->MovePoint(0, pos.m_positionX, pos.m_positionY, pos.m_positionZ);
                    break;
            }

            ChangeTargetTimer = 5000;
        } else ChangeTargetTimer -= diff;
    }
Example #6
0
void WorldSession::HandlePetAction(WorldPacket& recv_data)
{
    ObjectGuid petGuid;
    uint32 data;
    ObjectGuid targetGuid;
    float x, y, z;
    recv_data >> petGuid;
    recv_data >> data;
    recv_data >> targetGuid;
    recv_data >> x >> y >> z;

    uint32 spellid = UNIT_ACTION_BUTTON_ACTION(data);
    uint8 flag = UNIT_ACTION_BUTTON_TYPE(data);             // delete = 0x07 CastSpell = C1

    DETAIL_LOG("HandlePetAction: %s flag is %u, spellid is %u, target %s.", petGuid.GetString().c_str(), uint32(flag), spellid, targetGuid.GetString().c_str());

    // used also for charmed creature/player
    Unit* pet = GetPlayer()->GetMap()->GetUnit(petGuid);
    if (!pet)
    {
        sLog.outError("HandlePetAction: %s not exist.", petGuid.GetString().c_str());
        return;
    }

    if (GetPlayer()->GetObjectGuid() != pet->GetCharmerOrOwnerGuid())
    {
        sLog.outError("HandlePetAction: %s isn't controlled by %s.", petGuid.GetString().c_str(), GetPlayer()->GetGuidStr().c_str());
        return;
    }


    CharmInfo* charmInfo = pet->GetCharmInfo();
    if (!charmInfo)
    {
        sLog.outError("WorldSession::HandlePetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
        return;
    }

    if (!pet->isAlive())
    {
        pet->SendPetActionFeedback(FEEDBACK_PET_DEAD);
        return;
    }

    if (pet->GetTypeId() == TYPEID_PLAYER)
    {
        // controller player can only do melee attack
        if (!(flag == ACT_COMMAND && spellid == COMMAND_ATTACK))
            return;
    }
    else if (((Creature*)pet)->IsPet())
    {
        // pet can have action bar disabled
        if (charmInfo->HasState(CHARM_STATE_ACTION,ACTIONS_DISABLE))
            return;
    }

    if (((Creature*)pet)->IsPet() || pet->isCharmed())
        GetPlayer()->CallForAllControlledUnits(DoPetActionWithHelper(GetPlayer(), flag, spellid, petGuid, targetGuid), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM);
}
void netherspite_infernalAI::Cleanup()
{
    Unit *pMalchezaar = Unit::GetUnit(*me, malchezaar);

    if (pMalchezaar && pMalchezaar->isAlive())
        CAST_AI(boss_malchezaarAI, CAST_CRE(pMalchezaar)->AI())->Cleanup(me, point);
}
Example #8
0
void WorldSession::HandlePetStopAttack(WorldPacket& recv_data)
{
    DEBUG_LOG("WORLD: Received CMSG_PET_STOP_ATTACK");

    ObjectGuid petGuid;
    recv_data >> petGuid;

    Unit* pet = GetPlayer()->GetMap()->GetUnit(petGuid);    // pet or controlled creature/player
    if (!pet)
    {
        sLog.outError("%s doesn't exist.", petGuid.GetString().c_str());
        return;
    }

    if (GetPlayer()->GetObjectGuid() != pet->GetCharmerOrOwnerGuid())
    {
        sLog.outError("HandlePetStopAttack: %s isn't charm/pet of %s.", petGuid.GetString().c_str(), GetPlayer()->GetGuidStr().c_str());
        return;
    }

    if (!pet->isAlive())
        return;

    pet->AttackStop();
}
Example #9
0
    bool CanUseFingerOfDeath()
    {
        // First we check if our current victim is in melee range or not.
        Unit* victim = me->getVictim();
        if (victim && me->IsWithinDistInMap(victim, me->GetAttackDistance(victim)))
            return false;

        std::list<HostileReference*>& m_threatlist = me->getThreatManager().getThreatList();
        if (m_threatlist.empty())
            return false;

        std::list<Unit*> targets;
        std::list<HostileReference*>::iterator itr = m_threatlist.begin();
        for (; itr != m_threatlist.end(); ++itr)
        {
            Unit* pUnit = Unit::GetUnit((*me), (*itr)->getUnitGuid());
            if (pUnit && pUnit->isAlive())
                targets.push_back(pUnit);
        }

        if (targets.empty())
            return false;

        targets.sort(Oregon::ObjectDistanceOrderPred(me));
        Unit *pTarget = targets.front();
        if (pTarget)
        {
            if (!me->IsWithinDistInMap(pTarget, me->GetAttackDistance(pTarget)))
                return true;                                // Cast Finger of Death
            else                                            // This target is closest, he is our new tank
                me->AddThreat(pTarget, DoGetThreat(me->getVictim()));
        }

        return false;
    }
Example #10
0
    void Reset()
    {
        FrostBolt_Timer = (rand()%60)*1000;                 //It won't be more than a minute without cast it
        FrostBoltNova_Timer = 15000;                        //Cast every 15 seconds
        ChainsOfKelthuzad_Timer = (rand()%30+30)*1000;      //Cast no sooner than once every 30 seconds
        ManaDetonation_Timer = 20000;                       //Seems to cast about every 20 seconds
        ShadowFisure_Timer = 25000;                         //25 seconds
        FrostBlast_Timer = (rand()%30+30)*1000;             //Random time between 30-60 seconds
        GuardiansOfIcecrown_Timer = 5000;                   //5 seconds for summoning each Guardian of Icecrown in phase 3

        for (int i=0; i<5; i++)
        {
            if (GuardiansOfIcecrown[i])
        {
            //delete creature
            Unit* pUnit = Unit::GetUnit((*me), GuardiansOfIcecrown[i]);
            if (pUnit && pUnit->isAlive())
                pUnit->DealDamage(pUnit, pUnit->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            GuardiansOfIcecrown[i] = 0;
        }
        }

        Phase1_Timer = 310000;                              //Phase 1 lasts 5 minutes and 10 seconds
        Phase2 = false;
        Phase3 = false;
    }
Example #11
0
void WorldSession::HandlePetStopAttack(WorldPacket &recv_data)
{
    uint64 guid;
    recv_data >> guid;

    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PET_STOP_ATTACK for GUID " UI64FMTD "", guid);

    Unit* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);

    if (!pet)
    {
        sLog->outError("HandlePetStopAttack: Pet %u does not exist", uint32(GUID_LOPART(guid)));
        return;
    }

    if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm())
    {
        sLog->outError("HandlePetStopAttack: Pet GUID %u isn't a pet or charmed creature of player %s", uint32(GUID_LOPART(guid)), GetPlayer()->GetName());
        return;
    }

    if (!pet->isAlive())
        return;

    pet->AttackStop();
}
Example #12
0
bool ArcScriptCreatureAI::IsValidUnitTarget(Object* pObject, TargetFilter pFilter)
{
	//Make sure its a valid unit
	if( !pObject->IsUnit() ) return false;
	if( pObject->GetInstanceID() != _unit->GetInstanceID() ) return false;
	Unit* UnitTarget = static_cast<Unit*>(pObject);

	//Skip dead, feign death or invisible targets
	if( !UnitTarget->isAlive() ) return false;
	if( UnitTarget->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FEIGN_DEATH) ) return false;
	if( UnitTarget->m_invisible ) return false;

	//Skip units not on threat list
	if( _unit->GetAIInterface()->getThreatByPtr(UnitTarget) == 0 ) return false;

	//Check if we apply target filtering
	if( pFilter != TargetFilter_None )
	{
		//Skip current attacking target if requested
		if( (pFilter & TargetFilter_NotCurrent) && UnitTarget == _unit->GetAIInterface()->GetNextTarget() ) return false;

		//Keep only wounded targets if requested
		if( (pFilter & TargetFilter_Wounded) && UnitTarget->GetHealthPct() >= 99 ) return false;

		//Handle hostile/friendly
		if( pFilter & TargetFilter_Friendly ) 
		{
			if( !UnitTarget->CombatStatus.IsInCombat() ) return false; //Skip not-in-combat targets if friendly
			if( isHostile(_unit, UnitTarget) || _unit->GetAIInterface()->getThreatByPtr(UnitTarget) > 0 ) return false;
		}
	}

	return true; //This is a valid unit target
}
Example #13
0
        void StartEvent(Unit* target)
        {
            if (!instance)
                return;

            if (target && target->isAlive())
            {
                Council[0] = instance->GetData64(DATA_GATHIOSTHESHATTERER);
                Council[1] = instance->GetData64(DATA_HIGHNETHERMANCERZEREVOR);
                Council[2] = instance->GetData64(DATA_LADYMALANDE);
                Council[3] = instance->GetData64(DATA_VERASDARKSHADOW);

                // Start the event for the Voice Trigger
                if (Creature* VoiceTrigger = (Unit::GetCreature(*me, instance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE))))
                {
                    CAST_AI(mob_blood_elf_council_voice_trigger::mob_blood_elf_council_voice_triggerAI, VoiceTrigger->AI())->LoadCouncilGUIDs();
                    CAST_AI(mob_blood_elf_council_voice_trigger::mob_blood_elf_council_voice_triggerAI, VoiceTrigger->AI())->EventStarted = true;
                }

                for (uint8 i = 0; i < 4; ++i)
                {
                    if (Council[i])
                    {
                        Unit* member = Unit::GetUnit(*me, Council[i]);
                        if (member && member->isAlive())
                            CAST_CRE(member)->AI()->AttackStart(target);
                    }
                }

                instance->SetData(DATA_ILLIDARICOUNCILEVENT, IN_PROGRESS);

                EventBegun = true;
            }
        }
        void FlameWreathEffect()
        {
            std::vector<Unit*> targets;
            std::list<HostileReference*> t_list = me->getThreatManager().getThreatList();

            if (t_list.empty())
                return;

            //store the threat list in a different container
            for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                Unit* target = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                //only on alive players
                if (target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER)
                    targets.push_back(target);
            }

            //cut down to size if we have more than 3 targets
            while (targets.size() > 3)
                targets.erase(targets.begin()+rand()%targets.size());

            uint32 i = 0;
            for (std::vector<Unit*>::const_iterator itr = targets.begin(); itr!= targets.end(); ++itr)
            {
                if (*itr)
                {
                    FlameWreathTarget[i] = (*itr)->GetGUID();
                    FWTargPosX[i] = (*itr)->GetPositionX();
                    FWTargPosY[i] = (*itr)->GetPositionY();
                    DoCast((*itr), SPELL_FLAME_WREATH, true);
                    ++i;
                }
            }
        }
Example #15
0
void AssistanceMovementGenerator::Finalize(Unit &unit)
{
    ((Creature*)&unit)->SetNoCallAssistance(false);
    ((Creature*)&unit)->CallAssistance();
    if (unit.isAlive())
        unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY));
}
Example #16
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            events.Update(diff);

            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                    case EVENT_HATEFUL:
                    {
                        //Cast Hateful strike on the player with the highest
                        //amount of HP within melee distance
                        uint32 MostHP = 0;
                        Unit* pMostHPTarget = NULL;

                        std::list<HostileReference*>::const_iterator i = me->getThreatManager().getThreatList().begin();
                        int targetCounter = RAID_MODE(2, 3); // Picks 2 (3) highest threat targets as Hateful Strike candidates
                        for (; i != me->getThreatManager().getThreatList().end() && targetCounter > 0; ++i, --targetCounter)
                        {
                            Unit *pTarget = (*i)->getTarget();
                            if (pTarget->isAlive() && pTarget != me->getVictim() && pTarget->GetHealth() > MostHP && me->IsWithinMeleeRange(pTarget))
                            {
                                MostHP = pTarget->GetHealth();
                                pMostHPTarget = pTarget;
                            }
                        }

                        if (!pMostHPTarget)
                            pMostHPTarget = me->getVictim();

                        DoCast(pMostHPTarget, RAID_MODE(SPELL_HATEFUL_STRIKE, H_SPELL_HATEFUL_STRIKE), true);

                        events.ScheduleEvent(EVENT_HATEFUL, 1200);
                        break;
                    }
                    case EVENT_BERSERK:
                        DoCast(me, SPELL_BERSERK, true);
                        DoScriptText(EMOTE_BERSERK, me);
                        events.ScheduleEvent(EVENT_SLIME, 2000);
                        break;
                    case EVENT_SLIME:
                        DoCast(me->getVictim(), SPELL_SLIME_BOLT);
                        events.ScheduleEvent(EVENT_SLIME, 2000);
                        break;
                }
            }

            if (!Enraged && HealthBelowPct(5))
            {
                DoCast(me, SPELL_FRENZY, true);
                DoScriptText(EMOTE_ENRAGE, me);
                Enraged = true;
            }

            DoMeleeAttackIfReady();
        }
 void WaypointReached(uint32 waypointId)
 {
     if (waypointId == 7 && instance)
     {
         Unit* target = Unit::GetUnit(*me, instance->GetData64(DATA_JAINAPROUDMOORE));
         if (target && target->isAlive())
             me->AddThreat(target, 0.0f);
     }
 }
void AssistanceMovementGenerator::Finalize(Unit& unit)
{
    unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE);

    ((Creature*)&unit)->SetNoCallAssistance(false);
    ((Creature*)&unit)->CallAssistance();
    if (unit.isAlive())
        unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY));
}
Example #19
0
	void WaypointReached(uint32 i) {
		pos = i;
		if (i == 7 && pInstance) {
			Unit *pTarget = Unit::GetUnit((*me),
					pInstance->GetData64(DATA_THRALL));
			if (pTarget && pTarget->isAlive())
				me->AddThreat(pTarget, 0.0f);
		}
	}
 void AxesCleanup()
 {
     for (uint8 i = 0; i < 2; ++i)
     {
         Unit *axe = Unit::GetUnit(*me, axes[i]);
         if (axe && axe->isAlive())
             axe->Kill(axe);
         axes[i] = 0;
     }
 }
Example #21
0
    void ActivateMinion (uint64 guid, bool flag)
    {
        Unit *minion = Unit::GetUnit(*m_creature, guid);

        if (minion && minion->isAlive())
        {
            DoCast (minion, SPELL_AWAKEN_VAULT_WALKER, flag);
            minion->CastSpell(minion, SPELL_ARCHAEDAS_AWAKEN,true);
        }
    }
Example #22
0
 void WaypointReached(uint32 i)
 {
     pos = i;
     if (i == 7 && pInstance)
     {
         Unit* target = Unit::GetUnit((*me), pInstance->GetData64(DATA_JAINAPROUDMOORE));
         if (target && target->isAlive())
             me->AddThreat(target, 0.0f);
     }
 }
Example #23
0
 void WaypointReached(uint32 i)
 {
     pos = i;
     if (i == 7 && pInstance)
     {
         Unit* target = Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_THRALL));
         if (target && target->isAlive())
             m_creature->AddThreat(target,0.0);
     }
 }
    void DoCastWebWrap()
    {
        std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
        std::vector<Unit *> targets;

        //This spell doesn't work if we only have 1 player on threat list
        if (t_list.size() < 2)
            return;

        //begin + 1 , so we don't target the one with the highest threat
        std::list<HostileReference *>::iterator itr = t_list.begin();
        std::advance(itr, 1);
        for (; itr != t_list.end(); ++itr)                   //store the threat list in a different container
        {
            Unit *pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                                                            //only on alive players
            if (pTarget && pTarget->isAlive() && pTarget->GetTypeId() == TYPEID_PLAYER)
                targets.push_back(pTarget);
        }

        while (targets.size() > 3)
                                                            //cut down to size if we have more than 3 targets
            targets.erase(targets.begin()+rand()%targets.size());

        int i = 0;
        for (std::vector<Unit *>::iterator itr = targets.begin(); itr != targets.end(); ++itr, ++i)
        {
            // Teleport the 3 targets to a location on the wall and summon a Web Wrap on them
            Unit *pTarget = *itr;
            Creature* Wrap = NULL;
            if (pTarget)
            {
                switch(i)
                {
                    case 0:
                        DoTeleportPlayer(pTarget, LOC_X1, LOC_Y1, LOC_Z1, pTarget->GetOrientation());
                        Wrap = me->SummonCreature(16486, LOC_X1, LOC_Y1, LOC_Z1, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                        break;
                    case 1:
                        DoTeleportPlayer(pTarget, LOC_X2, LOC_Y2, LOC_Z2, pTarget->GetOrientation());
                        Wrap = me->SummonCreature(16486, LOC_X2, LOC_Y2, LOC_Z2, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                        break;
                    case 2:
                        DoTeleportPlayer(pTarget, LOC_X3, LOC_Y3, LOC_Z3, pTarget->GetOrientation());
                        Wrap = me->SummonCreature(16486, LOC_X3, LOC_Y3, LOC_Z3, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                        break;
                }
                if (Wrap)
                {
                    Wrap->setFaction(me->getFaction());
                    ((mob_webwrapAI*)Wrap->AI())->SetVictim(pTarget);
                }
            }
        }
    }
Example #25
0
bool SoulShatter(uint32 i, Spell* s)
{
    Unit* unitTarget = s->GetUnitTarget();

    if (!s->u_caster || !s->u_caster->isAlive() || !unitTarget || !unitTarget->isAlive())
        return false;

    s->u_caster->CastSpell(unitTarget, 32835, false);

    return true;
}
Example #26
0
bool Poultryizer(uint32 i, Spell* s)
{
	Unit* unitTarget = s->GetUnitTarget();

	if(!unitTarget || !unitTarget->isAlive())
		return false;

	s->u_caster->CastSpell(unitTarget->GetGUID(), 30501, true);

	return true;
}
 void EnfeebleResetHealth()
 {
     for (uint8 i = 0; i < 5; ++i)
     {
         Unit *pTarget = Unit::GetUnit(*me, enfeeble_targets[i]);
         if (pTarget && pTarget->isAlive())
             pTarget->SetHealth(enfeeble_health[i]);
         enfeeble_targets[i] = 0;
         enfeeble_health[i] = 0;
     }
 }
Example #28
0
        void UpdateAI(const uint32 diff)
        {
            if (!UpdateVictim())
                return;

            if (ShadowboltTimer <= diff)
            {
                Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0);
                if (target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER)
                    me->CastSpell(target, DUNGEON_MODE(SPELL_SHADOWBOLT, SPELL_SHADOWBOLT_HEROIC), true);
                ShadowboltTimer = 10000;
            } else ShadowboltTimer -= diff;

            if (!Skeletons)
            {
                if ((SummonSkeletonsTimer <= diff))
                {
                    Creature* Skeleton;
                    DoScriptText(SAY_SKELETONS, me);
                    for (uint8 i = 0; i < 5; ++i)
                    {
                        Skeleton = me->SummonCreature(CREATURE_SKELETON, SkeletonSpawnPoint[i][0], SkeletonSpawnPoint[i][1] , SKELETONSPAWN_Z, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                        if (Skeleton)
                        {
                            Skeleton->RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
                            Skeleton->GetMotionMaster()->MovePoint(0, me->GetPositionX(), me->GetPositionY() , me->GetPositionZ());
                            Skeleton->AddThreat(me->getVictim(), 0.0f);
                            DoZoneInCombat(Skeleton);
                        }
                    }
                    Skeletons = true;
                } else SummonSkeletonsTimer -= diff;
            }

            if (FrostTombTimer <= diff)
            {
                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                    if (target->isAlive())
                    {
                        //DoCast(target, SPELL_FROST_TOMB_SUMMON, true);
                        if (Creature* pChains = me->SummonCreature(CREATURE_FROSTTOMB, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 20000))
                        {
                            CAST_AI(mob_frost_tomb::mob_frost_tombAI, pChains->AI())->SetPrisoner(target);
                            pChains->CastSpell(target, SPELL_FROST_TOMB, true);

                            DoScriptText(SAY_FROST_TOMB, me);
                        }
                    }
                FrostTombTimer = 15000;
            } else FrostTombTimer -= diff;

            DoMeleeAttackIfReady();
        }
Example #29
0
    Unit* SelectGuestTarget()
    {
        uint64 TempGUID = GuestGUID[rand()%4];
        if (TempGUID)
        {
            Unit* unit = Unit::GetUnit((*me), TempGUID);
            if (unit && unit->isAlive())
                return unit;
        }

        return me;
    }
void TimedFleeingMovementGenerator::Finalize(Unit& owner)
{
    owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_FLEEING_MOVE);
    if (Unit* victim = owner.getVictim())
    {
        if (owner.isAlive())
        {
            owner.AttackStop(true);
            ((Creature*)&owner)->AI()->AttackStart(victim);
        }
    }
}