void instance_arcatraz::JustDidDialogueStep(int32 iEntry)
{
    Creature* pMellichar = GetSingleCreatureFromStorage(NPC_MELLICHAR);
    if (!pMellichar)
        return;

    switch (iEntry)
    {
        case SPELL_TARGET_ALPHA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_ALPHA, TRIGGERED_NONE);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_APHPA_POD))
                pMellichar->SetFacingToObject(pTarget);
            SetData(TYPE_WARDEN_1, IN_PROGRESS);
            break;
        case YELL_MELLICHAR_RELEASE1:
            pMellichar->SummonCreature(urand(0, 1) ? NPC_BLAZING_TRICKSTER : NPC_PHASE_HUNTER, aSummonPosition[0].m_fX, aSummonPosition[0].m_fY, aSummonPosition[0].m_fZ, aSummonPosition[0].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            break;
        case YELL_MELLICHAR_RELEASE2:
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_BETA_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case SPELL_TARGET_BETA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_BETA, TRIGGERED_NONE);
            SetData(TYPE_WARDEN_2, IN_PROGRESS);
            break;
        case TYPE_WARDEN_2:
            pMellichar->SummonCreature(NPC_MILLHOUSE, aSummonPosition[1].m_fX, aSummonPosition[1].m_fY, aSummonPosition[1].m_fZ, aSummonPosition[1].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            break;
        case SPELL_TARGET_DELTA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_DELTA, TRIGGERED_NONE);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_DELTA_POD))
                pMellichar->SetFacingToObject(pTarget);
            SetData(TYPE_WARDEN_3, IN_PROGRESS);
            break;
        case TYPE_WARDEN_3:
            pMellichar->SummonCreature(urand(0, 1) ? NPC_AKKIRIS : NPC_SULFURON, aSummonPosition[2].m_fX, aSummonPosition[2].m_fY, aSummonPosition[2].m_fZ, aSummonPosition[2].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_OMEGA, TRIGGERED_NONE);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_BOSS_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case YELL_MELLICHAR_RELEASE4:
            pMellichar->InterruptNonMeleeSpells(false);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_GAMMA_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case SPELL_TARGET_GAMMA:
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_GAMMA, TRIGGERED_NONE);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_GAMMA_POD))
                pMellichar->SetFacingToObject(pTarget);
            SetData(TYPE_WARDEN_4, IN_PROGRESS);
            break;
        case TYPE_WARDEN_4:
            pMellichar->SummonCreature(urand(0, 1) ? NPC_TW_DRAKONAAR : NPC_BL_DRAKONAAR, aSummonPosition[3].m_fX, aSummonPosition[3].m_fY, aSummonPosition[3].m_fZ, aSummonPosition[3].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0);
            pMellichar->CastSpell(pMellichar, SPELL_TARGET_OMEGA, TRIGGERED_NONE);
            if (Creature* pTarget = GetSingleCreatureFromStorage(NPC_PRISON_BOSS_POD))
                pMellichar->SetFacingToObject(pTarget);
            break;
        case YELL_MELLICHAR_RELEASE5:
            pMellichar->InterruptNonMeleeSpells(false);
            SetData(TYPE_WARDEN_5, IN_PROGRESS);
            break;
        case TYPE_WARDEN_5:
            if (Creature* pSkyriss = pMellichar->SummonCreature(NPC_SKYRISS, aSummonPosition[4].m_fX, aSummonPosition[4].m_fY, aSummonPosition[4].m_fZ, aSummonPosition[4].m_fO, TEMPSUMMON_DEAD_DESPAWN, 0))
                pSkyriss->CastSpell(pSkyriss, SPELL_SIMPLE_TELEPORT, TRIGGERED_NONE);
            break;
        case YELL_MELLICAR_WELCOME:
            if (Creature* pSkyriss = GetSingleCreatureFromStorage(NPC_SKYRISS))
                pSkyriss->CastSpell(pSkyriss, SPELL_MIND_REND, TRIGGERED_NONE);
            break;
        case SAY_SKYRISS_AGGRO:
            // Kill Mellichar and start combat
            if (Creature* pSkyriss = GetSingleCreatureFromStorage(NPC_SKYRISS))
            {
                pSkyriss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
                pMellichar->DealDamage(pMellichar, pMellichar->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }
            DoUseDoorOrButton(GO_SEAL_SPHERE);
            break;
    }
}
    void UpdateAI(const uint32 uiDiff) override
    {
        if (m_uiNextBeastTimer)
        {
            if (m_uiNextBeastTimer <= uiDiff)
            {
                if (m_uiPhase == PHASE_GORMOK)
                    DoSummonNextBeast(NPC_DREADSCALE);
                else if (m_uiPhase == PHASE_WORMS)
                    DoSummonNextBeast(NPC_ICEHOWL);

                m_uiNextBeastTimer = 0;
            }
            else
                m_uiNextBeastTimer -= uiDiff;
        }

        if (m_uiAttackDelayTimer)
        {
            if (m_uiAttackDelayTimer <= uiDiff)
            {
                // for worm phase, summon brother on aggro
                if (m_uiPhase == PHASE_WORMS)
                {
                    m_creature->SummonCreature(NPC_ACIDMAW, aSpawnPositions[3][0], aSpawnPositions[3][1], aSpawnPositions[3][2], aSpawnPositions[3][3], TEMPSPAWN_DEAD_DESPAWN, 0);
                    m_uiWormPhaseTimer = 45000;
                }

                // start combat
                if (Creature* pBeast = m_creature->GetMap()->GetCreature(m_aSummonedBossGuid[m_uiPhase]))
                {
                    pBeast->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PLAYER);

                    // first boss doesn't automatically attack
                    if (pBeast->GetEntry() != NPC_GORMOK)
                        pBeast->SetInCombatWithZone();
                }

                m_uiAttackDelayTimer = 0;
            }
            else
                m_uiAttackDelayTimer -= uiDiff;
        }

        if (m_uiBerserkTimer)
        {
            if (m_uiBerserkTimer < uiDiff)
            {
                for (auto i : m_aSummonedBossGuid)
                {
                    Creature* pBoss = m_creature->GetMap()->GetCreature(i);
                    if (pBoss && pBoss->isAlive())
                        pBoss->CastSpell(pBoss, SPELL_BERSERK, TRIGGERED_OLD_TRIGGERED);
                }
            }
            else
                m_uiBerserkTimer -= uiDiff;
        }

        // jormungars phase switch control
        if (m_uiWormPhaseTimer)
        {
            if (m_uiWormPhaseTimer <= uiDiff)
            {
                if (!m_pInstance)
                    return;

                ++m_uiWormPhaseStage;

                switch (m_uiWormPhaseStage)
                {
                    // submerge worms
                    case 1:
                        if (Creature* pWorm = m_pInstance->GetSingleCreatureFromStorage(NPC_ACIDMAW))
                        {
                            if (pWorm->isAlive())
                                SendAIEvent(AI_EVENT_CUSTOM_A, m_creature, pWorm);
                        }
                        if (Creature* pWorm = m_pInstance->GetSingleCreatureFromStorage(NPC_DREADSCALE))
                        {
                            if (pWorm->isAlive())
                                SendAIEvent(AI_EVENT_CUSTOM_A, m_creature, pWorm);
                        }

                        m_uiWormPhaseTimer = 4000;
                        break;

                    // change places
                    case 2:
                        float fX, fY, fZ;
                        if (Creature* pWorm = m_pInstance->GetSingleCreatureFromStorage(NPC_ACIDMAW))
                        {
                            if (pWorm->isAlive())
                            {
                                m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 45.0f, fX, fY, fZ);
                                pWorm->MonsterMoveWithSpeed(fX, fY, fZ, 7.7f);
                            }
                        }
                        if (Creature* pWorm = m_pInstance->GetSingleCreatureFromStorage(NPC_DREADSCALE))
                        {
                            if (pWorm->isAlive())
                            {
                                m_creature->GetRandomPoint(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), 45.0f, fX, fY, fZ);
                                pWorm->MonsterMoveWithSpeed(fX, fY, fZ, 7.7f);
                            }
                        }

                        m_uiWormPhaseTimer = 6000;
                        break;

                    // emerge and change phase
                    case 3:
                        if (Creature* pWorm = m_pInstance->GetSingleCreatureFromStorage(NPC_ACIDMAW))
                        {
                            if (pWorm->isAlive())
                                SendAIEvent(AI_EVENT_CUSTOM_B, m_creature, pWorm);
                        }
                        if (Creature* pWorm = m_pInstance->GetSingleCreatureFromStorage(NPC_DREADSCALE))
                        {
                            if (pWorm->isAlive())
                                SendAIEvent(AI_EVENT_CUSTOM_B, m_creature, pWorm);
                        }

                        m_uiWormPhaseStage = 0;
                        m_uiWormPhaseTimer = 45000;
                        break;
                }
            }
            else
                m_uiWormPhaseTimer -= uiDiff;
        }

        // jormungars achiev timer
        if (m_uiWormAchievTimer)
        {
            if (m_uiWormAchievTimer <= uiDiff)
                m_uiWormAchievTimer = 0;
            else
                m_uiWormAchievTimer -= uiDiff;
        }

        m_creature->SelectHostileTarget();
    }
예제 #3
0
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            //always decrease BerserkTimer
            if (BerserkTimer <= diff)
            {
                //if evocate, then break evocate
                if (Evocating)
                {
                    if (me->HasAura(SPELL_EVOCATION))
                        me->RemoveAurasDueToSpell(SPELL_EVOCATION);

                    Evocating = false;
                }

                //may not be correct SAY (generic hard enrage)
                Talk(SAY_ENRAGE);

                me->InterruptNonMeleeSpells(true);
                DoCast(me, SPELL_BERSERK);

                //don't know if he's supposed to do summon/evocate after hard enrage (probably not)
                Enraged = true;
            } else BerserkTimer -= diff;

            if (Evocating)
            {
                //not supposed to do anything while evocate
                if (me->HasAura(SPELL_EVOCATION))
                    return;
                else
                    Evocating = false;
            }

            if (!Enraged)
            {
                if (AddTimer <= diff)
                {
                    //Summon Astral Flare
                    Creature* AstralFlare = DoSpawnCreature(17096, float(rand()%37), float(rand()%37), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                    Unit* target = NULL;
                    target = SelectTarget(SELECT_TARGET_RANDOM, 0);

                    if (AstralFlare && target)
                    {
                        AstralFlare->CastSpell(AstralFlare, SPELL_ASTRAL_FLARE_PASSIVE, false);
                        AstralFlare->AI()->AttackStart(target);
                    }

                    //Reduce Mana by 10% of max health
                    if (int32 mana = me->GetMaxPower(POWER_MANA))
                    {
                        mana /= 10;
                        me->ModifyPower(POWER_MANA, -mana);

                        //if this get's us below 10%, then we evocate (the 10th should be summoned now)
                        if (me->GetPower(POWER_MANA)*100 / me->GetMaxPower(POWER_MANA) < 10)
                        {
                            Talk(SAY_EVOCATE);
                            me->InterruptNonMeleeSpells(false);
                            DoCast(me, SPELL_EVOCATION);
                            Evocating = true;
                            //no AddTimer cooldown, this will make first flare appear instantly after evocate end, like expected
                            return;
                        }
                        else
                        {
                            if (urand(0, 1) == 0)
                            {
                                Talk(SAY_SUMMON);
                            }
                        }
                    }

                    AddTimer = 10000;
                } else AddTimer -= diff;

                if (!HealthAbovePct(15))
                {
                    Enraged = true;
                    DoCast(me, SPELL_ENRAGE);
                    Talk(SAY_ENRAGE);
                }
            }

            if (HatefulBoltTimer <= diff)
            {
                if (Enraged)
                    HatefulBoltTimer = 7000;
                else
                    HatefulBoltTimer = 15000;

                if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1))
                    DoCast(target, SPELL_HATEFUL_BOLT);
            } else HatefulBoltTimer -= diff;

            DoMeleeAttackIfReady();
        }
예제 #4
0
void InnkeeperGossip::OnSelectOption(Object* pObject, Player* Plr, uint32 Id, const char* Code)
{
	Creature* pCreature = (pObject->IsCreature()) ? (TO_CREATURE(pObject)) : NULL;
	if(pCreature == NULL)
		return;

	switch(Id)
	{
		case 1:     // VENDOR
			Plr->GetSession()->SendInventoryList(pCreature);
			break;
		case 2:     // BINDER
			Plr->GetSession()->SendInnkeeperBind(pCreature);
			break;
		case 3:     // WHAT CAN I DO ?
			// Prepare second menu
			Arcemu::Gossip::Menu::SendQuickMenu(pCreature->GetGUID(), 1853, Plr, 2, Arcemu::Gossip::ICON_CHAT, Plr->GetSession()->LocalizedWorldSrv(Arcemu::Gossip::INNKEEPER));
			break;
		case 4:     // EVENT OF HALLOWEEN
			if(!Plr->HasAura(SPELL_TRICK_OR_TREATED))
			{
				pCreature->CastSpell(Plr, SPELL_TRICK_OR_TREATED, true);

				// either trick or treat, 50% chance
				if(rand() % 2)
				{
					Plr->CastSpell(Plr, SPELL_TREAT, true);
				}
				else
				{
					int32 trickspell = 0;
					switch(rand() % 9)
					{
						case 0:
							trickspell = 24753;                     // cannot cast, random 30sec
							break;
						case 1:
							trickspell = 24713;                     // lepper gnome costume
							break;
						case 2:
							if(Plr->getGender() == 0)
							{
								trickspell = 24735;                 // male ghost costume
							}
							else
							{
								trickspell = 24736;                 // female ghostcostume
							}
							break;
						case 3:
							if(Plr->getGender() == 0)
							{
								trickspell = 24711;                 // male ninja costume
							}
							else
							{
								trickspell = 24710;                 // female ninja costume
							}
							break;
						case 4:
							if(Plr->getGender() == 0)
							{
								trickspell = 24708;                 // male pirate costume
							}
							else
							{
								trickspell = 24709;                 // female pirate costume
							}
							break;
						case 5:
							trickspell = 24723;                     // skeleton costume
							break;
					}
					pCreature->CastSpell(Plr, trickspell, true);
				}
			}
			Arcemu::Gossip::Menu::Complete(Plr);
			break;
	}
}
예제 #5
0
    void DoIntro()
    {
        Creature* Madrigosa = Unit::GetCreature(*me, pInstance ? pInstance->GetData64(DATA_MADRIGOSA) : 0);
        if (!Madrigosa)
            return;

        switch (IntroPhase)
        {
            case 0:
                DoScriptText(YELL_MADR_ICE_BARRIER, Madrigosa);
                IntroPhaseTimer = 7000;
                ++IntroPhase;
                break;
            case 1:
                me->SetInFront(Madrigosa);
                Madrigosa->SetInFront(me);
                DoScriptText(YELL_MADR_INTRO, Madrigosa, me);
                IntroPhaseTimer = 9000;
                ++IntroPhase;
                break;
            case 2:
                DoScriptText(YELL_INTRO, me, Madrigosa);
                IntroPhaseTimer = 13000;
                ++IntroPhase;
                break;
            case 3:
                DoCast(me, SPELL_INTRO_FROST_BLAST);
                Madrigosa->AddUnitMovementFlag(MOVEFLAG_ONTRANSPORT | MOVEFLAG_LEVITATING);
                me->AttackStop();
                Madrigosa->AttackStop();
                IntroFrostBoltTimer = 3000;
                IntroPhaseTimer = 28000;
                ++IntroPhase;
                break;
            case 4:
                DoScriptText(YELL_INTRO_BREAK_ICE, me);
                IntroPhaseTimer = 6000;
                ++IntroPhase;
                break;
            case 5:
                Madrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE_CHANELLING, false);
                DoScriptText(YELL_MADR_TRAP, Madrigosa);
                DoCast(me, SPELL_INTRO_ENCAPSULATE);
                IntroPhaseTimer = 11000;
                ++IntroPhase;
                break;
            case 6:
                DoScriptText(YELL_INTRO_CHARGE, me);
                IntroPhaseTimer = 5000;
                ++IntroPhase;
                break;
            case 7:
                me->Kill(Madrigosa);
                DoScriptText(YELL_MADR_DEATH, Madrigosa);
                me->SetHealth(me->GetMaxHealth());
                me->AttackStop();
                IntroPhaseTimer = 4000;
                ++IntroPhase;
                break;
            case 8:
                DoScriptText(YELL_INTRO_KILL_MADRIGOSA, me);
                me->SetOrientation(0.14f);
                me->StopMoving();
                Madrigosa->setDeathState(CORPSE);
                IntroPhaseTimer = 8000;
                ++IntroPhase;
                break;
            case 9:
                DoScriptText(YELL_INTRO_TAUNT, me);
                IntroPhaseTimer = 5000;
                ++IntroPhase;
                break;
            case 10:
                EndIntro();
                break;
        }
    }
void instance_gundrak::DoAltarVisualEffect(uint8 uiType)
{
    // Sort the lists if not yet done
    if (!m_luiStalkerGUIDs.empty())
    {
        float fHeight = 10.0f;                              // A bit higher than the altar is needed
        if (GameObject* pCollusAltar = instance->GetGameObject(m_uiAltarOfColossusGUID))
            fHeight += pCollusAltar->GetPositionZ();

        std::list<Creature*> lStalkerTargets, lStalkerCasters;
        for (std::list<uint64>::const_iterator itr = m_luiStalkerGUIDs.begin(); itr != m_luiStalkerGUIDs.end(); ++itr)
        {
            if (Creature* pStalker = instance->GetCreature(*itr))
            {
                if (pStalker->GetPositionZ() > fHeight)
                    lStalkerTargets.push_back(pStalker);
                else
                    lStalkerCasters.push_back(pStalker);
            }
        }
        m_luiStalkerGUIDs.clear();

        lStalkerTargets.sort(sortFromEastToWest);
        lStalkerCasters.sort(sortFromEastToWest);

        for (std::list<Creature*>::const_iterator itr = lStalkerTargets.begin(); itr != lStalkerTargets.end(); ++itr)
            m_luiStalkerTargetGUIDs.push_back((*itr)->GetGUID());
        for (std::list<Creature*>::const_iterator itr = lStalkerCasters.begin(); itr != lStalkerCasters.end(); ++itr)
            m_luiStalkerCasterGUIDs.push_back((*itr)->GetGUID());
    }

    // Verify that the DB has enough trigger spawned
    if (m_luiStalkerTargetGUIDs.size() < 3 || m_luiStalkerCasterGUIDs.size() < 3)
        return;

    // Get the Index from the bosses
    uint8 uiIndex = 0;
    switch (uiType)
    {
        case TYPE_SLADRAN:  uiIndex = 0; break;
        case TYPE_COLOSSUS: uiIndex = 1; break;
        case TYPE_MOORABI:  uiIndex = 2; break;
        default:
            return;
    }

    std::list<uint64>::iterator targetItr = m_luiStalkerTargetGUIDs.begin();
    std::list<uint64>::iterator casterItr = m_luiStalkerCasterGUIDs.begin();

    advance(targetItr, uiIndex);
    advance(casterItr, uiIndex);

    Creature* pTarget = instance->GetCreature(*targetItr);
    Creature* pCaster = instance->GetCreature(*casterItr);

    if (!pTarget || !pCaster)
        return;

    uint32 auiFireBeamSpells[3] = {SPELL_BEAM_SNAKE, SPELL_BEAM_ELEMENTAL, SPELL_BEAM_MAMMOTH};

    // Cast from Caster to Target
    pCaster->CastSpell(pTarget, auiFireBeamSpells[uiIndex], true);
}
예제 #7
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::UpgradeGuard(uint64 guid)
{
    if(!guid)
        return;
    Player* player = GetPlayer();
    if(!player)
        return;

    Creature* creature = player->GetMap()->GetCreature(guid);
    if(!creature)
        return;
    uint32 currentLevel = 0;
    uint32 entry = GUID_ENPART(guid);
    if (Guards.find(guid) != Guards.end())
    {
        GuardInfo* guard = Guards[guid];
        currentLevel = guard->Level;
        uint32 newLevel = currentLevel +1;
        if(QueryResult queryResult = CharacterDatabase.PQuery("SELECT creatureName, creatureEntry, creatureCost FROM custom_td_base_stats WHERE creatureEntry = '%u'", entry))
        {   
            uint32 UpgradeCost = guard->GetUpgradeCost();
            switch(GetEventMode())
            {
            case TD_EVENT_MODE_HARD:
                UpgradeCost = UpgradeCost + (UpgradeCost/4);
                break;
            case TD_EVENT_MODE_EXTREME:
                UpgradeCost = UpgradeCost + (UpgradeCost/2);
                break;
            }
            if(GetResources() < UpgradeCost){
                SendMessageToPlayer(TD_SYSTEM_MSG_MORE_RESOURCES_UPG, UpgradeCost - GetResources());
                return;
            }
            if(QueryResult queryResult = CharacterDatabase.PQuery("SELECT * FROM custom_td_base_levels WHERE creatureEntry = '%u' AND creatureLevel = '%u'", entry, newLevel))
            {
                creature->CastSpell(creature, GetSpellIdByUniqueId(4),true); // upgrade level visual
                guard->SetLevel(newLevel);
                UpdateResources(TD_EVENT_DEC,UpgradeCost); // remove resource cost from player
                creature->RemoveAllAuras(); // remove all auras to apply new ones.
                SendMessageToPlayer(TD_SYSTEM_MSG_UPGRADED_TOWER_FOR, creature->GetName(),UpgradeCost);

                Field* Fields = queryResult->Fetch();

                uint32 newDefaultSpell = Fields[4].GetUInt32();
                if(newDefaultSpell)
                    guard->SetDefSpell(newDefaultSpell);

                uint32 newAttackSpeed = Fields[9].GetUInt32();
                if (newAttackSpeed)
                    guard->SetAttSpeed(newAttackSpeed);

                float newAttackDistance = Fields[8].GetFloat();
                if(newAttackDistance)
                    guard->SetAttackDistance(newAttackDistance);

                uint32 newAura = Fields[7].GetUInt32();
                if(newAura)
                    creature->CastSpell(creature,newAura,true);

                uint32 newDisplay = Fields[6].GetUInt32();
                if(newDisplay)
                    creature->SetDisplayId(newDisplay);

                float  newScale = Fields[5].GetFloat();
                if(newScale)
                    creature->SetObjectScale(newScale);

                uint32 newDamage = Fields[10].GetUInt32();
                if (newDamage)
                    guard->SetDamage(newDamage);

                uint32 newIsAntiAir = Fields[11].GetBool();
                if (newIsAntiAir)
                    guard->SetIsAntiAir(newIsAntiAir);

                uint32 newIsAntiGround = Fields[12].GetBool();
                if (newIsAntiGround)
                    guard->SetIsAntiGround(newIsAntiGround);
            }
        }
    } 
}
        void HandleDummy(SpellEffIndex /*effIndex*/)
        {
            uint32 roll = urand(1, 100);

            uint8 ev;
            if (roll <= 50)
                ev = EVENT_MISS;
            else if (roll <= 83)
                ev = EVENT_HIT;
            else
                ev = EVENT_MISS_BIRD;

            Unit* shooter = GetCaster();
            Creature* wilhelm = GetHitUnit()->ToCreature();
            Creature* apple = shooter->FindNearestCreature(NPC_APPLE, 30);
            Creature* drostan = shooter->FindNearestCreature(NPC_DROSTAN, 30);

            if (!wilhelm || !apple || !drostan)
                return;

            switch (ev)
            {
                case EVENT_MISS_BIRD:
                {
                    Creature* crunchy = shooter->FindNearestCreature(NPC_CRUNCHY, 30);
                    Creature* bird = shooter->FindNearestCreature(NPC_THICKBIRD, 30);

                    if (!bird || !crunchy)
                        ; // fall to EVENT_MISS
                    else
                    {
                        shooter->CastSpell(bird, SPELL_MISS_BIRD_APPLE);
                        bird->CastSpell(bird, SPELL_BIRD_FALL);
                        wilhelm->AI()->Talk(SAY_WILHELM_MISS);
                        drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);

                        bird->Kill(bird);
                        crunchy->GetMotionMaster()->MovePoint(0, bird->GetPositionX(), bird->GetPositionY(),
                            bird->GetMap()->GetWaterOrGroundLevel(bird->GetPositionX(), bird->GetPositionY(), bird->GetPositionZ()));
                        /// @todo Make crunchy perform emote eat when he reaches the bird

                        break;
                    }
                }
                case EVENT_MISS:
                {
                    shooter->CastSpell(wilhelm, SPELL_MISS_APPLE);
                    wilhelm->AI()->Talk(SAY_WILHELM_MISS);
                    drostan->AI()->Talk(SAY_DROSTAN_REPLY_MISS);
                    break;
                }
                case EVENT_HIT:
                {
                    shooter->CastSpell(apple, SPELL_HIT_APPLE);
                    apple->CastSpell(apple, SPELL_APPLE_FALL);
                    wilhelm->AI()->Talk(SAY_WILHELM_HIT);
                    if (Player* player = shooter->ToPlayer())
                        player->KilledMonsterCredit(NPC_APPLE);
                    apple->DespawnOrUnsummon();

                    break;
                }
            }
        }
예제 #9
0
void BattlegroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point)
{
    if (GetStatus() != STATUS_IN_PROGRESS)
        return;

    uint32 Team = Source->GetTeam();

    SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType, RESPAWN_ONE_DAY);
    SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, RESPAWN_ONE_DAY);
    SpawnBGObject(m_CapturingPointTypes[Point].DespawnNeutralObjectType + 2, RESPAWN_ONE_DAY);

    if (Team == ALLIANCE)
    {
        m_TeamPointsCount[BG_TEAM_ALLIANCE]++;
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, RESPAWN_IMMEDIATELY);
    }
    else
    {
        m_TeamPointsCount[BG_TEAM_HORDE]++;
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY);
        SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY);
    }

    //buff isn't respawned

    m_PointOwnedByTeam[Point] = Team;
    m_PointState[Point] = EY_POINT_UNDER_CONTROL;

    if (Team == ALLIANCE)
        SendMessageToAll(m_CapturingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
    else
        SendMessageToAll(m_CapturingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source);

    if (m_BgCreatures[Point])
        DelCreature(Point);

    WorldSafeLocsEntry const *sg = NULL;
    sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveYardId);
    if (!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, Team))
        sLog.outError("BatteGroundEY: Failed to spawn spirit guide! point: %u, team: %u, graveyard_id: %u",
            Point, Team, m_CapturingPointTypes[Point].GraveYardId);

//    SpawnBGCreature(Point,RESPAWN_IMMEDIATELY);

    UpdatePointsIcons(Team, Point);
    UpdatePointsCount(Team);

    if (Point >= EY_POINTS_MAX)
        return;

    Creature* trigger = GetBGCreature(Point + 6);//0-5 spirit guides
    if (!trigger)
       trigger = AddCreature(WORLD_TRIGGER,Point+6,Team,BG_EY_TriggerPositions[Point][0],BG_EY_TriggerPositions[Point][1],BG_EY_TriggerPositions[Point][2],BG_EY_TriggerPositions[Point][3]);

    //add bonus honor aura trigger creature when node is accupied
    //cast bonus aura (+50% honor in 25yards)
    //aura should only apply to players who have accupied the node, set correct faction for trigger
    if (trigger)
    {
        trigger->setFaction(Team == ALLIANCE ? 84 : 83);
        trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false);
    }
}
        void UpdateAI(const uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->isInCombat() && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT))
            {
                Unit *pTarget = Unit::GetUnit((*me), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER));

                if (pTarget)
                {
                    AttackStart(pTarget);
                }
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT))
            {
                EnterEvadeMode();
                return;
            }

            //WaterBoltVolley_Timer
            if (WaterBoltVolley_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_WATER_BOLT_VOLLEY);
                WaterBoltVolley_Timer = 30000;
            } else WaterBoltVolley_Timer -= diff;

            //TidalSurge_Timer
            if (TidalSurge_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_TIDAL_SURGE);
                // Hacky way to do it - won't trigger elseways
                me->getVictim()->CastSpell(me->getVictim(), SPELL_TIDAL_SURGE_FREEZE, true);
                TidalSurge_Timer = 15000+rand()%5000;
            } else TidalSurge_Timer -= diff;

            //Cyclone_Timer
            if (Cyclone_Timer <= diff)
            {
                //DoCast(me, SPELL_SUMMON_CYCLONE); // Doesn't work
                Cyclone_Timer = 30000+rand()%10000;
                Creature *Cyclone = me->SummonCreature(CREATURE_CYCLONE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand()%5), TEMPSUMMON_TIMED_DESPAWN, 15000);
                if (Cyclone)
                {
                    CAST_CRE(Cyclone)->SetFloatValue(OBJECT_FIELD_SCALE_X, 3.0f);
                    Cyclone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    Cyclone->setFaction(me->getFaction());
                    Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_CYCLONE, true);
                    Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget)
                    {
                        Cyclone->AI()->AttackStart(pTarget);
                    }
                }
            } else Cyclone_Timer -= diff;

            //Heal_Timer
            if (Heal_Timer <= diff)
            {
                // It can be cast on any of the mobs
                Unit *pUnit = NULL;

                while (pUnit == NULL || !pUnit->isAlive())
                {
                    pUnit = selectAdvisorUnit();
                }

                if (pUnit && pUnit->isAlive())
                    DoCast(pUnit, SPELL_HEAL);
                Heal_Timer = 60000;
            } else Heal_Timer -= diff;

            DoMeleeAttackIfReady();
        }
        void UpdateAI(const uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->isInCombat() && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT))
            {
                Unit *pTarget = Unit::GetUnit((*me), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER));

                if (pTarget)
                {
                    AttackStart(pTarget);
                }
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT))
            {
                EnterEvadeMode();
                return;
            }

            //LeechingThrow_Timer
            if (LeechingThrow_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_LEECHING_THROW);
                LeechingThrow_Timer = 20000;
            } else LeechingThrow_Timer -= diff;

            //Multishot_Timer
            if (Multishot_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_MULTISHOT);
                Multishot_Timer = 20000;
            } else Multishot_Timer -= diff;

            //TheBeastWithin_Timer
            if (TheBeastWithin_Timer <= diff)
            {
                DoCast(me, SPELL_THE_BEAST_WITHIN);
                Creature *Pet = Unit::GetCreature(*me, SummonedPet);
                if (Pet && Pet->isAlive())
                {
                    Pet->CastSpell(Pet, SPELL_PET_ENRAGE, true);
                }
                TheBeastWithin_Timer = 30000;
            } else TheBeastWithin_Timer -= diff;

            //Pet_Timer
            if (Pet_Timer < diff && pet == false)
            {
                pet = true;
                //uint32 spell_id;
                uint32 pet_id;
                if (!urand(0,1))
                {
                    //spell_id = SPELL_SUMMON_FATHOM_LURKER;
                    pet_id = CREATURE_FATHOM_LURKER;
                }
                else
                {
                    //spell_id = SPELL_SUMMON_FATHOM_SPOREBAT;
                    pet_id = CREATURE_FATHOM_SPOREBAT;
                }
                //DoCast(me, spell_id, true);
                Creature *Pet = DoSpawnCreature(pet_id,0,0,0,0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM,0);
                if (Pet && pTarget)
                {
                    Pet->AI()->AttackStart(pTarget);
                    SummonedPet = Pet->GetGUID();
                }
            } else Pet_Timer -= diff;

            DoMeleeAttackIfReady();
        }
예제 #12
0
            void UpdateAI(uint32 diff) override
            {
                if (!me->IsInCombat()) // sometimes IsInCombat but !incombat, faction bug?
                    return;

                if (Berserk_Timer <= diff)
                {
                    DoCast(me, SPELL_BERSERK, true);
                    Berserk_Timer = 60000;
                }
                else
                    Berserk_Timer -= diff;

                if (ForceMove)
                {
                    if (ForceTimer <= diff)
                    {
                        me->GetMotionMaster()->MovePoint(0, waypoint[cur_wp][0], waypoint[cur_wp][1], waypoint[cur_wp][2]);
                        ForceTimer = 5000;
                    }
                    else
                        ForceTimer -= diff;

                }
                if (WaitEvent)
                {
                    if (WaitTimer)
                    {
                        if (WaitTimer <= diff)
                        {
                            if (AfterMoving)
                            {
                                me->GetMotionMaster()->MoveIdle();
                                AfterMoving = false;
                            }

                            switch (WaitEvent)
                            {
                            case WE_PLATFORM:
                                Platforms_Move_Timer = 30000 + rand32() % 5000;
                                break;
                            case WE_QUILL:
                                DoCast(me, SPELL_FLAME_QUILLS, true);
                                Platforms_Move_Timer = 1;
                                WaitTimer = 10000;
                                WaitEvent = WE_DUMMY;
                                return;
                            case WE_DIE:
                                ForceMove = false;
                                me->SetStandState(UNIT_STAND_STATE_DEAD);
                                WaitTimer = 5000;
                                WaitEvent = WE_REVIVE;
                                return;
                            case WE_REVIVE:
                                me->SetStandState(UNIT_STAND_STATE_STAND);
                                me->SetFullHealth();
                                me->SetSpeedRate(MOVE_RUN, DefaultMoveSpeedRate);
                                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                                DoZoneInCombat();
                                DoCast(me, SPELL_REBIRTH, true);
                                MeltArmor_Timer = 60000;
                                Charge_Timer = 7000;
                                DiveBomb_Timer = 40000 + rand32() % 5000;
                                FlamePatch_Timer = 30000;
                                Phase1 = false;
                                break;
                            case WE_METEOR:
                                me->ApplySpellImmune(0, IMMUNITY_SCHOOL, SPELL_SCHOOL_MASK_FIRE, false);
                                DoCast(me, SPELL_DIVE_BOMB_VISUAL, false);
                                WaitEvent = WE_DIVE;
                                WaitTimer = 4000;
                                return;
                            case WE_DIVE:
                                if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                                {
                                    me->RemoveAurasDueToSpell(SPELL_DIVE_BOMB_VISUAL);
                                    DoCast(target, SPELL_DIVE_BOMB, true);
                                    float dist = 3.0f;
                                    if (me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f))
                                        dist = 5.0f;
                                    WaitTimer = 1000 + uint32(floor(dist / 80 * 1000.0f));
                                    me->SetPosition(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0.0f);
                                    me->StopMoving();
                                    WaitEvent = WE_LAND;
                                    return;
                                }
                                else
                                {
                                    EnterEvadeMode();
                                    return;
                                }
                            case WE_LAND:
                                WaitEvent = WE_SUMMON;
                                WaitTimer = 2000;
                                return;
                            case WE_SUMMON:
                                for (uint8 i = 0; i < 2; ++i)
                                    DoSpawnCreature(CREATURE_EMBER_OF_ALAR, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                                me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 10);
                                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                me->SetDisplayId(me->GetNativeDisplayId());
                                DoCast(me, SPELL_REBIRTH_2, true);
                                break;
                            case WE_DUMMY:
                            default:
                                break;
                            }

                            WaitEvent = WE_NONE;
                            WaitTimer = 0;
                        }
                        else
                            WaitTimer -= diff;
                    }
                    return;
                }

                if (Phase1)
                {
                    if (me->getThreatManager().getThreatList().empty())
                    {
                        EnterEvadeMode();
                        return;
                    }

                    if (Platforms_Move_Timer <= diff)
                    {
                        if (cur_wp == 4)
                        {
                            cur_wp = 0;
                            WaitEvent = WE_PLATFORM;
                        }
                        else
                        {
                            if (urand(0, 4)) // next platform
                            {
                                DoSpawnCreature(CREATURE_EMBER_OF_ALAR, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                                if (cur_wp == 3)
                                    cur_wp = 0;
                                else
                                    ++cur_wp;
                                WaitEvent = WE_PLATFORM;
                            }
                            else // flame quill
                            {
                                cur_wp = 4;
                                WaitEvent = WE_QUILL;
                            }
                        }
                        ForceMove = true;
                        ForceTimer = 5000;
                        me->GetMotionMaster()->MovePoint(0, waypoint[cur_wp][0], waypoint[cur_wp][1], waypoint[cur_wp][2]);
                        WaitTimer = 0;
                        return;
                    }
                    else
                        Platforms_Move_Timer -= diff;
                }
                else
                {
                    if (Charge_Timer <= diff)
                    {
                        Unit* target= SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
                        if (target)
                            DoCast(target, SPELL_CHARGE);
                        Charge_Timer = 30000;
                    }
                    else
                        Charge_Timer -= diff;

                    if (MeltArmor_Timer <= diff)
                    {
                        DoCastVictim(SPELL_MELT_ARMOR);
                        MeltArmor_Timer = 60000;
                    }
                    else
                        MeltArmor_Timer -= diff;

                    if (DiveBomb_Timer <= diff)
                    {
                        me->AttackStop();
                        me->GetMotionMaster()->MovePoint(6, waypoint[4][0], waypoint[4][1], waypoint[4][2]);
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        me->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 50);
                        WaitEvent = WE_METEOR;
                        WaitTimer = 0;
                        DiveBomb_Timer = 40000 + rand32() % 5000;
                        return;
                    }
                    else
                        DiveBomb_Timer -= diff;

                    if (FlamePatch_Timer <= diff)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            Creature* Summoned = me->SummonCreature(CREATURE_FLAME_PATCH_ALAR, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 120000);
                            if (Summoned)
                            {
                                Summoned->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                Summoned->SetObjectScale(Summoned->GetObjectScale() * 2.5f);
                                Summoned->SetDisplayId(11686);
                                Summoned->setFaction(me->getFaction());
                                Summoned->SetLevel(me->getLevel());
                                Summoned->CastSpell(Summoned, SPELL_FLAME_PATCH, false);
                            }
                        }
                        FlamePatch_Timer = 30000;
                    }
                    else
                        FlamePatch_Timer -= diff;
                }

                DoMeleeAttackIfReady();
            }
        void Update(uint32 diff)
        {
            if (!instance->HavePlayers())
                return;

            // portals should spawn if other portal is dead and doors are closed
            if (bActive && uiMainEventPhase == IN_PROGRESS)
            {
                if (uiActivationTimer < diff)
                {
                    AddWave();
                    bActive = false;
                    uiActivationTimer = 5000;
                } else uiActivationTimer -= diff;
            }

            // if main event is in progress and players have wiped then reset instance
            if ( uiMainEventPhase == IN_PROGRESS && CheckWipe())
            {
                SetData(DATA_REMOVE_NPC, 1);
                StartBossEncounter(uiFirstBoss, false);
                StartBossEncounter(uiSecondBoss, false);

                SetData(DATA_MAIN_DOOR,GO_STATE_ACTIVE);
                SetData(DATA_WAVE_COUNT, 0);
                uiMainEventPhase = NOT_STARTED;

                if (Creature* pSinclari = instance->GetCreature(uiSinclari))
                {
                    pSinclari->SetVisible(true);

                    std::list<Creature*> GuardList;
                    pSinclari->GetCreatureListWithEntryInGrid(GuardList, NPC_VIOLET_HOLD_GUARD, 40.0f);
                    if (!GuardList.empty())
                    {
                        for (std::list<Creature*>::const_iterator itr = GuardList.begin(); itr != GuardList.end(); ++itr)
                        {
                            if (Creature* pGuard = *itr)
                            {
                                pGuard->SetVisible(true);
                                pGuard->SetReactState(REACT_AGGRESSIVE);
                                pGuard->GetMotionMaster()->MovePoint(1,pGuard->GetHomePosition());
                            }
                        }
                    }
                    pSinclari->GetMotionMaster()->MovePoint(1,pSinclari->GetHomePosition());
                    pSinclari->RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_NOT_SELECTABLE);
                }
            }

            // Cyanigosa is spawned but not tranformed, prefight event
            Creature* pCyanigosa = instance->GetCreature(uiCyanigosa);
            if (pCyanigosa && !pCyanigosa->HasAura(CYANIGOSA_SPELL_TRANSFORM))
            {
                if (uiCyanigosaEventTimer <= diff)
                {
                    switch(uiCyanigosaEventPhase)
                    {
                        case 1:
                            pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false);
                            DoScriptText(CYANIGOSA_SAY_SPAWN, pCyanigosa);
                            uiCyanigosaEventTimer = 7*IN_MILLISECONDS;
                            ++uiCyanigosaEventPhase;
                            break;
                        case 2:
                            pCyanigosa->GetMotionMaster()->MoveJump(MiddleRoomLocation.GetPositionX(), MiddleRoomLocation.GetPositionY(), MiddleRoomLocation.GetPositionZ(), 10.0f, 20.0f);
                            pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_BLUE_AURA, false);
                            uiCyanigosaEventTimer = 7*IN_MILLISECONDS;
                            ++uiCyanigosaEventPhase;
                            break;
                        case 3:
                            pCyanigosa->RemoveAurasDueToSpell(CYANIGOSA_BLUE_AURA);
                            pCyanigosa->CastSpell(pCyanigosa, CYANIGOSA_SPELL_TRANSFORM, 0);
                            pCyanigosa->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                            pCyanigosa->SetReactState(REACT_AGGRESSIVE);
                            uiCyanigosaEventTimer = 2*IN_MILLISECONDS;
                            ++uiCyanigosaEventPhase;
                            break;
                        case 4:
                            uiCyanigosaEventPhase = 0;
                            break;
                    }
                } else uiCyanigosaEventTimer -= diff;
            }

            // if there are NPCs in front of the prison door, which are casting the door seal spell and doors are active
            if (GetData(DATA_NPC_PRESENCE_AT_DOOR) && uiMainEventPhase == IN_PROGRESS)
            {
                // if door integrity is > 0 then decrase it's integrity state
                if(GetData(DATA_DOOR_INTEGRITY))
                {
                    if(uiDoorSpellTimer < diff)
                    {
                        SetData(DATA_DOOR_INTEGRITY,GetData(DATA_DOOR_INTEGRITY)-1);
                        uiDoorSpellTimer =2000;
                    } else uiDoorSpellTimer -= diff;
                }
                // else set door state to active (means door will open and group have failed to sustain mob invasion on the door)
                else
                {
                    SetData(DATA_MAIN_DOOR,GO_STATE_ACTIVE);
                    uiMainEventPhase = FAIL;
                    DespawnInvadersInVioletHold(instance->GetCreature(uiSinclari));
                }
            }
        }