Example #1
0
    void UpdateAI(const uint32 diff)
    {
        if (!m_creature->SelectHostilTarget() && !m_creature->getVictim())
            return;

        if(StormCount)
        {
            Unit* target = Unit::GetUnit(*m_creature, CloudGUID);
            if(!target || !target->isAlive())
            {
                EnterEvadeMode();
                return;
            }
            else if(Unit* Cyclone = Unit::GetUnit(*m_creature, CycloneGUID))
                Cyclone->CastSpell(target, 25160, true); // keep casting or...

            if(StormSequenceTimer < diff) {
                HandleStormSequence(target);
            }else StormSequenceTimer -= diff;
            return;
        }

        if (Enrage_Timer < diff) {
            DoYell(SAY_ONENRAGE, LANG_UNIVERSAL, NULL);
            DoPlaySoundToSet(m_creature, SOUND_ONENRAGE);
            m_creature->CastSpell(m_creature, SPELL_BERSERK, true);
            Enrage_Timer = 600000;
        }else Enrage_Timer -= diff;

        if (StaticDisruption_Timer < diff) {
            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
            if(!target) target = m_creature->getVictim();
            TargetGUID = target->GetGUID();
            m_creature->CastSpell(target, SPELL_STATIC_DISRUPTION, false);
            m_creature->SetInFront(m_creature->getVictim());
            StaticDisruption_Timer = (10+rand()%8)*1000; // < 20s

            float dist = m_creature->GetDistance(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ());
            if (dist < 5.0f) dist = 5.0f;
            SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);
        }else StaticDisruption_Timer -= diff;

        if (SDisruptAOEVisual_Timer < diff) {
            Unit* SDVictim = Unit::GetUnit((*m_creature), TargetGUID);
            if(SDVictim && SDVictim->isAlive())
                SDVictim->CastSpell(SDVictim, SPELL_STATIC_VISUAL, true);
            SDisruptAOEVisual_Timer = 99999;
            TargetGUID = 0;
        }else SDisruptAOEVisual_Timer -= diff;

        if (GustOfWind_Timer < diff) {
            Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 1);
            if(!target) target = m_creature->getVictim();
            DoCast(target, SPELL_GUST_OF_WIND);
            GustOfWind_Timer = (20+rand()%10)*1000; //20 to 30 seconds(bosskillers)
        } else GustOfWind_Timer -= diff;

        if (CallLighting_Timer < diff) {
            DoCast(m_creature->getVictim(), SPELL_CALL_LIGHTNING);
            CallLighting_Timer = (12 + rand()%5)*1000; //totaly random timer. can't find any info on this
        } else CallLighting_Timer -= diff;

        if (!isRaining && ElectricalStorm_Timer < 8000 + rand()%5000) {
            SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f);
            isRaining = true;
        }

        if (ElectricalStorm_Timer < diff) {
            Unit* target = SelectRandomPlayer(50);
            if(!target) target = m_creature->getVictim();
            float x, y, z;
            target->GetPosition(x, y, z);
            Creature *Cloud = m_creature->SummonCreature(MOB_TEMP_TRIGGER, x, y, m_creature->GetPositionZ() + 10, 0, TEMPSUMMON_TIMED_DESPAWN, 15000);
            if(Cloud)
            {
                CloudGUID = Cloud->GetGUID();
                Cloud->AddMonsterMoveFlag(MONSTER_MOVE_LEVITATING);
                Cloud->StopMoving();
                Cloud->SetFloatValue(OBJECT_FIELD_SCALE_X, 3.0f);
                Cloud->setFaction(35);
                Cloud->SetMaxHealth(9999999);
                Cloud->SetHealth(9999999);
                Cloud->CastSpell(Cloud, 45213, true); // cloud visual
                m_creature->StopMoving();
                Cloud->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                m_creature->CastSpell(Cloud, 43501, false); // siphon soul
            }
            Unit *Cyclone = m_creature->SummonCreature(MOB_TEMP_TRIGGER, x, y, z, 0, TEMPSUMMON_TIMED_DESPAWN, 15000);
            if(Cyclone)
            {
                Cyclone->CastSpell(Cyclone, 25160, true); // wind visual
                CycloneGUID = Cyclone->GetGUID();
            }
            ElectricalStorm_Timer = 60000; //60 seconds(bosskillers)
            StormCount = 1;
            StormSequenceTimer = 0;
        } else ElectricalStorm_Timer -= diff;

        if (SummonEagles_Timer < diff) 
        {
            DoYell(SAY_ONSUMMON, LANG_UNIVERSAL, NULL);
            DoPlaySoundToSet(m_creature, SOUND_ONSUMMON);

            float x, y, z;
            m_creature->GetPosition(x, y, z);
            for (uint8 i = 0; i < 6 + rand()%3; i++) 
            {
                if(Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0))
                {
                    x = target->GetPositionX() + 10 - rand()%20;
                    y = target->GetPositionY() + 10 - rand()%20;
                    z = target->GetPositionZ() + 6 + rand()%5 + 10;
                    if(z > 95) z = 95 - rand()%5;
                }

                Creature *pCreature = m_creature->SummonCreature(MOB_SOARING_EAGLE, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                if (pCreature)
                {
                    pCreature->AddThreat(m_creature->getVictim(), 1.0f);
                    pCreature->AI()->AttackStart(m_creature->getVictim());
                }
            }
            SummonEagles_Timer = 999999;
        } else SummonEagles_Timer -= diff;

        DoMeleeAttackIfReady();
    }
Example #2
0
    void GossipSelectOption(Object* pObject, Player * plr, uint32 Id, uint32 IntId, const char * Code)
    {
		GossipMenu *Menu;
		Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL;
		if(pObject->GetTypeId()!=TYPEID_UNIT)
			return;
		
		switch(IntId)
		{
		case 1:		// Question 1 (Initial question, always the same)
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60027, plr);

            Menu->AddItem(0, "I slay the man on the spot as my liege would expect me to do, as he is nothing more than a thief and a liar.", 10);
			Menu->AddItem(0, "I turn over the man to my liege for punishment, as he has broken the law of the land and it is my sworn duty to enforce it.", 11);
			Menu->AddItem(0, "I confiscate the corn he has stolen, warn him that stealing is a path towards doom and destruction, but I let him go to return to his family.", 12);
			Menu->AddItem(0, "I allow the man to take enough corn to feed his family for a couple of days, encouraging him to leave the land.", 13);
            
            Menu->SendTo(plr);
		break;

        case 10:	// Question 2 (First Answer = 1)
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60028, plr);

            Menu->AddItem(0, "I execute him as per my liege's instructions, and do it in such a manner that he suffers painfully before he dies a retribution for his crimes against my people.", 14);
			Menu->AddItem(0, "I execute him as per my liege's instructions, but doing so in as painless of a way as possible. Justice must be served, but I can show some compassion.", 15);
			Menu->AddItem(0, "I risk my own life and free him so that he may prove his innocence. If I can, I'll help him in any way.", 16);
			            
            Menu->SendTo(plr);
		break;

		case 11:     // Question 2 (First Answer = 2)
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60029, plr);

            Menu->AddItem(0, "I confront the ruler on his malicious behavior, upholding my liege's honor at risk of any future diplomacy.", 17);
			Menu->AddItem(0, "I not-so-quietly ignore the insult, hoping to instill a fear in the ruler that he may have gaffed. I then inform my liege of the insult when I return.", 18);
			Menu->AddItem(0, "I quietly ignore the insult. I will not tell my liege, as I am to secure peace at all costs. It's only an insult - not a declaration of war.", 19);
			            
            Menu->SendTo(plr);
		break;

		case 12:     // Question 2 (First Answer = 3)
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60030, plr);

            Menu->AddItem(0, "I would speak against my brother joining the order, rushing a permanent breech in our relationship. He would be a danger to himself and those around him, and that is too great a risk hoping he would improve over time.", 20);
			Menu->AddItem(0, "I would speak for my brother joining the order, potentially risking the safety of the order. I could help him with the order's regimens, and I'd have faith in his ability to adapt and learn.", 21);
			Menu->AddItem(0, "I would create some surreptitious means to keep my brother out of the order. I can keep him out without him being any bit wiser, thereby saving our familial bonds.", 22);
			            
            Menu->SendTo(plr);
		break;

		case 13:     // Question 2 (First Answer = 4)
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60031, plr);

            Menu->AddItem(0, "I would show my liege the beast's ear and claim the beast's death as my own, taking the reward for my own use. It is wrong to claim a deed as your own that someone else in fact did.", 23);
			Menu->AddItem(0, "I would show my liege the beast's ear and claim the beast's death as my own - after all, I did slay it. I would then offer some of the reward to the destitute knight to help his family.", 24);
			Menu->AddItem(0, "I would remain silent about the kill and allow the knight to claim the reward to aid his family.", 25);
			            
            Menu->SendTo(plr);
		break;

		// Answers 1-#
		case 14:     // Answers: 1-1
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);

			pCreature->CastSpell(plr, 23768, true);
		break;

		case 15:     // Answers: 1-2
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23769, true);
		break;

		case 16:     // Answers: 1-3
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23767, true);
		break;

		// Answers 2-#
        case 17:     // Answers: 2-1
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23738, true);
		break;

		case 18:     // Answers: 2-2
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23766, true);	
		break;

		case 19:     // Answers: 2-3
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23769, true);
		break;

		// Answers 3-#
        case 20:     // Answers: 3-1
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23737, true);	
		break;

		case 21:     // Answers: 3-2
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23735, true);	
		break;

		case 22:     // Answers: 3-3
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23736, true);
		break;

		// Answers 4-#
        case 23:     // Answers: 4-1
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23766, true);		
		break;

		case 24:     // Answers: 4-2
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23738, true);
		break;

		case 25:     // Answers: 4-3
            objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60032, plr);

            Menu->AddItem(0, "I'd love to get one of those written fortunes you mentioned! I've got the space in my inventory for it.", 30);        
            Menu->SendTo(plr);
					
			pCreature->CastSpell(plr, 23737, true);	
		break;

		case 30:
			objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 60033, plr);
			Menu->SendTo(plr);

			// Cast the fortune into the player's inventory - Not working?
			pCreature->CastSpell(plr, 23765, true);

			// TEMP fix for spell not adding item to  player's inventory.
			if (plr->GetItemInterface()->CalculateFreeSlots(ItemPrototypeStorage.LookupEntry(19422)))			
			{				
				plr->GetItemInterface()->AddItemToFreeSlot(objmgr.CreateItem(19422, plr)); //Darkmoon Faire Fortune				
			} else	{				
				sChatHandler.SystemMessage(plr->GetSession(), "You do not have enough free slots for your fortune!");			
			}
		break;
		}
    }
        void UpdateAI(const uint32 diff)
        {
            if (EventInProgress) {
                Player* pWarrior = NULL;

                if (PlayerGUID)
                    pWarrior = Unit::GetPlayer(*me, PlayerGUID);

                if (!pWarrior)
                    return;

                if (!pWarrior->isAlive() && pWarrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) {
                    Talk(SAY_TWIGGY_FLATHEAD_DOWN);
                    pWarrior->FailQuest(1719);

                    for (uint8 i = 0; i < 6; ++i) // unsummon challengers
                    {
                        if (AffrayChallenger[i])
                        {
                            Creature* creature = Unit::GetCreature((*me), AffrayChallenger[i]);
                            if (creature && creature->isAlive())
                                creature->DisappearAndDie();
                        }
                    }

                    if (BigWill) // unsummon bigWill
                    {
                        Creature* creature = Unit::GetCreature((*me), BigWill);
                        if (creature && creature->isAlive())
                            creature->DisappearAndDie();
                    }
                    Reset();
                }

                if (!EventGrate && EventInProgress)
                {
                    float x, y, z;
                    pWarrior->GetPosition(x, y, z);

                    if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324) {
                        pWarrior->AreaExploredOrEventHappens(1719);
                        Talk(SAY_TWIGGY_FLATHEAD_BEGIN, pWarrior->GetGUID());

                        for (uint8 i = 0; i < 6; ++i)
                        {
                            Creature* creature = me->SummonCreature(NPC_AFFRAY_CHALLENGER, AffrayChallengerLoc[i], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            if (!creature)
                                continue;
                            creature->setFaction(35);
                            creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            creature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
                            AffrayChallenger[i] = creature->GetGUID();
                        }
                        WaveTimer = 5000;
                        ChallengerChecker = 1000;
                        EventGrate = true;
                    }
                }
                else if (EventInProgress)
                {
                    if (ChallengerChecker <= diff)
                    {
                        for (uint8 i = 0; i < 6; ++i)
                        {
                            if (AffrayChallenger[i])
                            {
                                Creature* creature = Unit::GetCreature((*me), AffrayChallenger[i]);
                                if ((!creature || (!creature->isAlive())) && !ChallengerDown[i])
                                {
                                    Talk(SAY_TWIGGY_FLATHEAD_DOWN);
                                    ChallengerDown[i] = true;
                                }
                            }
                        }
                        ChallengerChecker = 1000;
                    } else ChallengerChecker -= diff;

                    if (WaveTimer <= diff)
                    {
                        if (Wave < 6 && AffrayChallenger[Wave] && !EventBigWill)
                        {
                            Talk(SAY_TWIGGY_FLATHEAD_FRAY);
                            Creature* creature = Unit::GetCreature((*me), AffrayChallenger[Wave]);
                            if (creature && (creature->isAlive()))
                            {
                                creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                                creature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
                                creature->setFaction(14);
                                creature->AI()->AttackStart(pWarrior);
                                ++Wave;
                                WaveTimer = 20000;
                            }
                        }
                        else if (Wave >= 6 && !EventBigWill) {
                            if (Creature* creature = me->SummonCreature(NPC_BIG_WILL, -1722, -4341, 6.12f, 6.26f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 480000))
                            {
                                BigWill = creature->GetGUID();
                                //creature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32f);
                                //creature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78f);
                                creature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79f);
                                creature->HandleEmoteCommand(EMOTE_STATE_READY_UNARMED);
                                EventBigWill = true;
                                WaveTimer = 1000;
                            }
                        }
                        else if (Wave >= 6 && EventBigWill && BigWill)
                        {
                            Creature* creature = Unit::GetCreature((*me), BigWill);
                            if (!creature || !creature->isAlive())
                            {
                                Talk(SAY_TWIGGY_FLATHEAD_OVER);
                                Reset();
                            }
                        }
                    } else WaveTimer -= diff;
                }
            }
        }
Example #4
0
 void WaypointReached(uint32 i)
 {
     Player* pPlayer = GetPlayerForEscort();
     if (!pPlayer)
         return;
     Creature* Godfrey = me->FindNearestCreature(NPC_GODFREY, 50, true);
     if (!Godfrey)
         return;  
     switch (i)
     {
         case 1:                
             DoScriptText(SAY_WP_1, me, Godfrey);
             me->SetUInt64Value(UNIT_FIELD_TARGET, Godfrey->GetGUID());
             me->HandleEmoteCommand(5);
             me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
             me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);                
             break;
         case 2:
             Godfrey->HandleEmoteCommand(434);
             DoScriptText(SAY_WP_2, me, Godfrey);
             me->HandleEmoteCommand(15);
             break;
         case 3:                
             DoScriptText(SAY_WP_3, me, Godfrey);
             me->HandleEmoteCommand(1);
             break;
         case 4:
             DoScriptText(SAY_WP_4, Godfrey);
             break;
         case 5:
             DoScriptText(SAY_WP_5, Godfrey);
             break;
         case 6:
             DoScriptText(SAY_WP_6, Godfrey);
             break;
         case 7:
             DoScriptText(SAY_WP_7, me, Godfrey);
             me->HandleEmoteCommand(1);
             break;
         case 8:
             DoScriptText(SAY_WP_8, me, Godfrey);
             me->HandleEmoteCommand(16);
             break;
         case 9:
             DoScriptText(SAY_WP_9, me, Godfrey);                
             me->HandleEmoteCommand(5);
             break;
         case 10:
             DoScriptText(SAY_WP_10, me, Godfrey);
             DoCast(Godfrey, SPELL_HOLY_FIRE);
             break;
         case 11:
             Godfrey->HandleEmoteCommand(434);
             DoScriptText(SAY_WP_11, Godfrey);
             break;
         case 12:
             DoScriptText(SAY_WP_12, me, Godfrey);
             DoCast(Godfrey, SPELL_HOLY_FIRE);
             break;
         case 13:
             DoScriptText(SAY_WP_13, me, Godfrey);
             DoCast(Godfrey, SPELL_HOLY_FIRE);
             break;
         case 14:
             Godfrey->HandleEmoteCommand(434);
             DoScriptText(SAY_WP_14, Godfrey);
             break;
         case 15:
             DoScriptText(SAY_WP_15, me, Godfrey);
             DoCast(Godfrey, SPELL_HOLY_FIRE);
             break;
         case 16:
             DoScriptText(SAY_WP_16, me, Godfrey);
             break;
         case 17:
             DoScriptText(SAY_WP_17, me, Godfrey);
             break;
         case 18:
             DoScriptText(SAY_WP_18, Godfrey);
             break;
         case 19:
             DoScriptText(SAY_WP_19, me, Godfrey);
             break;
         case 20:
             DoScriptText(SAY_WP_20, Godfrey);
             break;
         case 21:
             DoScriptText(SAY_WP_21, Godfrey);
             break;
         case 22:
             DoScriptText(SAY_WP_22, me, Godfrey);
             break;
         case 23:
             DoScriptText(SAY_WP_23, Godfrey);
             break;
         case 24:
             DoScriptText(SAY_WP_24, Godfrey);
             break;
         case 25:
             DoScriptText(SAY_WP_25, me, Godfrey);
             break;
         case 26:
             DoScriptText(SAY_WP_26, me);
             me->SetUInt64Value(UNIT_FIELD_TARGET, pPlayer->GetGUID());
             break;
         case 27:
             DoScriptText(SAY_WP_27, me, Godfrey);
             me->SetUInt64Value(UNIT_FIELD_TARGET, Godfrey->GetGUID());
             Completed = true;                
             if (pPlayer)
                 pPlayer->GroupEventHappens(QUEST_A_RIGHTEOUS_SERMON, me);
             break;                          
     }
 }
Example #5
0
Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const* data)
{
    Map* map = GetMap();

    Creature* creature = Creature::CreateCreatureFromDB(guid, map, false);
    if (!creature)
        return nullptr;

    ASSERT(data);

    float x = data->posX;
    float y = data->posY;
    float z = data->posZ;
    float o = data->orientation;

    creature->SetTransport(this);
    creature->m_movementInfo.transport.guid = GetGUID();
    creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
    creature->m_movementInfo.transport.seat = -1;
    CalculatePassengerPosition(x, y, z, &o);
    creature->Relocate(x, y, z, o);
    creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
    creature->SetTransportHomePosition(creature->m_movementInfo.transport.pos);

    /// @HACK - transport models are not added to map's dynamic LoS calculations
    ///         because the current GameObjectModel cannot be moved without recreating
    creature->AddUnitState(UNIT_STATE_IGNORE_PATHFINDING);

    if (!creature->IsPositionValid())
    {
        TC_LOG_ERROR("entities.transport", "Passenger %s not created. Suggested coordinates aren't valid (X: %f Y: %f)", creature->GetGUID().ToString().c_str(), creature->GetPositionX(), creature->GetPositionY());
        delete creature;
        return nullptr;
    }

    PhasingHandler::InitDbPhaseShift(creature->GetPhaseShift(), data->phaseUseFlags, data->phaseId, data->phaseGroup);
    PhasingHandler::InitDbVisibleMapId(creature->GetPhaseShift(), data->terrainSwapMap);

    if (!map->AddToMap(creature))
    {
        delete creature;
        return nullptr;
    }

    _staticPassengers.insert(creature);
    sScriptMgr->OnAddCreaturePassenger(this, creature);
    return creature;
}
    void UpdateAI(const uint32 diff)
    {
        if (!CanAttack && Intro)
        {
            if (AggroTimer <= diff)
            {
                CanAttack = true;
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                AggroTimer=19000;
            } else
            {
                AggroTimer-=diff;
                return;
            }
        }
        //to prevent abuses during phase 2
        if (Phase == 2 && !me->getVictim() && me->isInCombat())
        {
            EnterEvadeMode();
            return;
        }
        //Return since we have no target
        if (!UpdateVictim())
            return;

        if (Phase == 1 || Phase == 3)
        {
            //ShockBlast_Timer
            if (ShockBlast_Timer <= diff)
            {
                //Shock Burst
                //Randomly used in Phases 1 and 3 on Vashj's target, it's a Shock spell doing 8325-9675 nature damage and stunning the target for 5 seconds, during which she will not attack her target but switch to the next person on the aggro list.
                DoCast(me->getVictim(), SPELL_SHOCK_BLAST);
                me->TauntApply(me->getVictim());

                ShockBlast_Timer = 1000+rand()%14000;       //random cooldown
            } else ShockBlast_Timer -= diff;

            //StaticCharge_Timer
            if (StaticCharge_Timer <= diff)
            {
                //Static Charge
                //Used on random people (only 1 person at any given time) in Phases 1 and 3, it's a debuff doing 2775 to 3225 Nature damage to the target and everybody in about 5 yards around it, every 1 seconds for 30 seconds. It can be removed by Cloak of Shadows, Iceblock, Divine Shield, etc, but not by Cleanse or Dispel Magic.
                Unit *pTarget = NULL;
                pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 200, true);

                if (pTarget && !pTarget->HasAura(SPELL_STATIC_CHARGE_TRIGGER, 0))
                                                            //cast Static Charge every 2 seconds for 20 seconds
                        DoCast(pTarget, SPELL_STATIC_CHARGE_TRIGGER);

                StaticCharge_Timer = 10000+rand()%20000;    //blizzlike
            } else StaticCharge_Timer -= diff;

            //Entangle_Timer
            if (Entangle_Timer <= diff)
            {
                if (!Entangle)
                {
                    //Entangle
                    //Used in Phases 1 and 3, it casts Entangling Roots on everybody in a 15 yard radius of Vashj, immobilzing them for 10 seconds and dealing 500 damage every 2 seconds. It's not a magic effect so it cannot be dispelled, but is removed by various buffs such as Cloak of Shadows or Blessing of Freedom.
                    DoCast(me->getVictim(), SPELL_ENTANGLE);
                    Entangle = true;
                    Entangle_Timer = 10000;
                }
                else
                {
                    CastShootOrMultishot();
                    Entangle = false;
                    Entangle_Timer = 20000+rand()%5000;
                }
            } else Entangle_Timer -= diff;

            //Phase 1
            if (Phase == 1)
            {
                //Start phase 2
                if ((me->GetHealth()*100 / me->GetMaxHealth()) < 70)
                {
                    //Phase 2 begins when Vashj hits 70%. She will run to the middle of her platform and surround herself in a shield making her invulerable.
                    Phase = 2;

                    me->GetMotionMaster()->Clear();
                    DoTeleportTo(MIDDLE_X, MIDDLE_Y, MIDDLE_Z);

                    Creature *pCreature;
                    for (uint8 i = 0; i < 4; ++i)
                    {
                        pCreature = me->SummonCreature(SHIED_GENERATOR_CHANNEL, ShieldGeneratorChannelPos[i][0],  ShieldGeneratorChannelPos[i][1],  ShieldGeneratorChannelPos[i][2],  ShieldGeneratorChannelPos[i][3], TEMPSUMMON_CORPSE_DESPAWN, 0);
                        if (pCreature)
                            ShieldGeneratorChannel[i] = pCreature->GetGUID();
                    }
                    DoScriptText(SAY_PHASE2, me);
                }
            }
            //Phase 3
            else
            {
                //SummonSporebat_Timer
                if (SummonSporebat_Timer <= diff)
                {
                    Creature *Sporebat = NULL;
                    Sporebat = me->SummonCreature(TOXIC_SPOREBAT, SPOREBAT_X, SPOREBAT_Y, SPOREBAT_Z, SPOREBAT_O, TEMPSUMMON_CORPSE_DESPAWN, 0);

                    if (Sporebat)
                    {
                        Unit *pTarget = NULL;
                        pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                        if (pTarget)
                            Sporebat->AI()->AttackStart(pTarget);
                    }

                    //summon sporebats faster and faster
                    if (SummonSporebat_StaticTimer > 1000)
                        SummonSporebat_StaticTimer -= 1000;

                    SummonSporebat_Timer = SummonSporebat_StaticTimer;

                    if (SummonSporebat_Timer < 5000)
                        SummonSporebat_Timer = 5000;

                } else SummonSporebat_Timer -= diff;
            }

            //Melee attack
            DoMeleeAttackIfReady();

            //Check_Timer - used to check if somebody is in melee range
            if (Check_Timer <= diff)
            {
                bool InMeleeRange = false;
                Unit *pTarget;
                std::list<HostileReference *> t_list = me->getThreatManager().getThreatList();
                for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                {
                    pTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                                                            //if in melee range
                    if (pTarget && pTarget->IsWithinDistInMap(me, 5))
                    {
                        InMeleeRange = true;
                        break;
                    }
                }

                //if nobody is in melee range
                if (!InMeleeRange)
                    CastShootOrMultishot();

                Check_Timer = 5000;
            } else Check_Timer -= diff;
        }
        //Phase 2
        else
        {
            //ForkedLightning_Timer
            if (ForkedLightning_Timer <= diff)
            {
                //Forked Lightning
                //Used constantly in Phase 2, it shoots out completely randomly targeted bolts of lightning which hit everybody in a roughtly 60 degree cone in front of Vashj for 2313-2687 nature damage.
                Unit *pTarget = NULL;
                pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);

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

                DoCast(pTarget, SPELL_FORKED_LIGHTNING);

                ForkedLightning_Timer = 2000+rand()%6000;   //blizzlike
            } else ForkedLightning_Timer -= diff;

            //EnchantedElemental_Timer
            if (EnchantedElemental_Timer <= diff)
            {
                me->SummonCreature(ENCHANTED_ELEMENTAL, ElementPos[EnchantedElemental_Pos][0], ElementPos[EnchantedElemental_Pos][1], ElementPos[EnchantedElemental_Pos][2], ElementPos[EnchantedElemental_Pos][3], TEMPSUMMON_CORPSE_DESPAWN, 0);

                if (EnchantedElemental_Pos == 7)
                    EnchantedElemental_Pos = 0;
                else
                    ++EnchantedElemental_Pos;

                EnchantedElemental_Timer = 10000+rand()%5000;
            } else EnchantedElemental_Timer -= diff;

            //TaintedElemental_Timer
            if (TaintedElemental_Timer <= diff)
            {
                uint32 pos = rand()%8;
                me->SummonCreature(TAINTED_ELEMENTAL, ElementPos[pos][0], ElementPos[pos][1], ElementPos[pos][2], ElementPos[pos][3], TEMPSUMMON_DEAD_DESPAWN, 0);

                TaintedElemental_Timer = 120000;
            } else TaintedElemental_Timer -= diff;

            //CoilfangElite_Timer
            if (CoilfangElite_Timer <= diff)
            {
                uint32 pos = rand()%3;
                Creature* CoilfangElite = NULL;
                CoilfangElite = me->SummonCreature(COILFANG_ELITE, CoilfangElitePos[pos][0], CoilfangElitePos[pos][1], CoilfangElitePos[pos][2], CoilfangElitePos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                if (CoilfangElite)
                {
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget)
                        CoilfangElite->AI()->AttackStart(pTarget);
                    else if (me->getVictim())
                        CoilfangElite->AI()->AttackStart(me->getVictim());
                }
                CoilfangElite_Timer = 45000+rand()%5000;
            } else CoilfangElite_Timer -= diff;

            //CoilfangStrider_Timer
            if (CoilfangStrider_Timer <= diff)
            {
                uint32 pos = rand()%3;
                Creature* CoilfangStrider = NULL;
                CoilfangStrider = me->SummonCreature(COILFANG_STRIDER, CoilfangStriderPos[pos][0], CoilfangStriderPos[pos][1], CoilfangStriderPos[pos][2], CoilfangStriderPos[pos][3], TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                 if (CoilfangStrider)
                {
                    Unit *pTarget = NULL;
                    pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget)
                        CoilfangStrider->AI()->AttackStart(pTarget);
                    else if (me->getVictim())
                        CoilfangStrider->AI()->AttackStart(me->getVictim());
                }
                CoilfangStrider_Timer = 60000+rand()%10000;
            } else CoilfangStrider_Timer -= diff;

            //Check_Timer
            if (Check_Timer <= diff)
            {
                //Start Phase 3
                if (pInstance && pInstance->GetData(DATA_CANSTARTPHASE3))
                {
                    //set life 50%
                    me->SetHealth(me->GetMaxHealth()/2);

                    me->RemoveAurasDueToSpell(SPELL_MAGIC_BARRIER);

                    DoScriptText(SAY_PHASE3, me);

                    Phase = 3;

                    //return to the tank
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                }
                Check_Timer = 1000;
            } else Check_Timer -= diff;
        }
    }
Example #7
0
        void UpdateAI(uint32 diff)
        {
            if (!me->IsInCombat())
            {
                if (instance)
                {
                    // Do not let the raid skip straight to Archimonde. Visible and hostile ONLY if Azagalor is finished.
                    if ((instance->GetData(DATA_AZGALOREVENT) < DONE) && (me->IsVisible() || (me->getFaction() != 35)))
                    {
                        me->SetVisible(false);
                        me->setFaction(35);
                    }
                    else if ((instance->GetData(DATA_AZGALOREVENT) >= DONE) && (!me->IsVisible() || (me->getFaction() == 35)))
                    {
                        me->setFaction(1720);
                        me->SetVisible(true);
                    }
                }

                if (DrainNordrassilTimer <= diff)
                {
                    if (!IsChanneling)
                    {
                        Creature* temp = me->SummonCreature(CREATURE_CHANNEL_TARGET, NordrassilLoc, TEMPSUMMON_TIMED_DESPAWN, 1200000);

                        if (temp)
                            WorldTreeGUID = temp->GetGUID();

                        if (Unit* Nordrassil = Unit::GetUnit(*me, WorldTreeGUID))
                        {
                            Nordrassil->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            Nordrassil->SetDisplayId(11686);
                            DoCast(Nordrassil, SPELL_DRAIN_WORLD_TREE);
                            IsChanneling = true;
                        }
                    }

                    if (Unit* Nordrassil = Unit::GetUnit(*me, WorldTreeGUID))
                    {
                        Nordrassil->CastSpell(me, SPELL_DRAIN_WORLD_TREE_2, true);
                        DrainNordrassilTimer = 1000;
                    }
                } else DrainNordrassilTimer -= diff;
            }

            if (!UpdateVictim())
                return;

            if (me->HealthBelowPct(10) && !BelowTenPercent && !Enraged)
                BelowTenPercent = true;

            if (!Enraged)
            {
                if (EnrageTimer <= diff)
                {
                    if (HealthAbovePct(10))
                    {
                        me->GetMotionMaster()->Clear(false);
                        me->GetMotionMaster()->MoveIdle();
                        Enraged = true;
                        Talk(SAY_ENRAGE);
                    }
                } else EnrageTimer -= diff;

                if (CheckDistanceTimer <= diff)
                {
                    // To simplify the check, we simply summon a Creature in the location and then check how far we are from the creature
                    Creature* Check = me->SummonCreature(CREATURE_CHANNEL_TARGET, NordrassilLoc, TEMPSUMMON_TIMED_DESPAWN, 2000);
                    if (Check)
                    {
                        Check->SetVisible(false);

                        if (me->IsWithinDistInMap(Check, 75))
                        {
                            me->GetMotionMaster()->Clear(false);
                            me->GetMotionMaster()->MoveIdle();
                            Enraged = true;
                            Talk(SAY_ENRAGE);
                        }
                    }
                    CheckDistanceTimer = 5000;
                } else CheckDistanceTimer -= diff;
            }

            if (BelowTenPercent)
            {
                if (!HasProtected)
                {
                    me->GetMotionMaster()->Clear(false);
                    me->GetMotionMaster()->MoveIdle();

                    //all members of raid must get this buff
                    DoCastVictim(SPELL_PROTECTION_OF_ELUNE, true);
                    HasProtected = true;
                    Enraged = true;
                }

                if (SummonWispTimer <= diff)
                {
                    DoSpawnCreature(CREATURE_ANCIENT_WISP, float(rand()%40), float(rand()%40), 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                    SummonWispTimer = 1500;
                    ++WispCount;
                } else SummonWispTimer -= diff;

                if (WispCount >= 30)
                    me->DealDamage(me, me->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }

            if (Enraged)
            {
                if (HandOfDeathTimer <= diff)
                {
                    DoCastVictim(SPELL_HAND_OF_DEATH);
                    HandOfDeathTimer = 2000;
                } else HandOfDeathTimer -= diff;
                return;                                         // Don't do anything after this point.
            }

            if (SoulChargeCount)
            {
                if (SoulChargeTimer <= diff)
                    UnleashSoulCharge();
                else SoulChargeTimer -= diff;
            }

            if (GripOfTheLegionTimer <= diff)
            {
                DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_GRIP_OF_THE_LEGION);
                GripOfTheLegionTimer = urand(5000, 25000);
            } else GripOfTheLegionTimer -= diff;

            if (AirBurstTimer <= diff)
            {
                Talk(SAY_AIR_BURST);
                DoCast(SelectTarget(SELECT_TARGET_RANDOM, 1), SPELL_AIR_BURST);//not on tank
                AirBurstTimer = urand(25000, 40000);
            } else AirBurstTimer -= diff;

            if (FearTimer <= diff)
            {
                DoCastVictim(SPELL_FEAR);
                FearTimer = 42000;
            } else FearTimer -= diff;

            if (DoomfireTimer <= diff)
            {
                Talk(SAY_DOOMFIRE);
                Unit* temp = SelectTarget(SELECT_TARGET_RANDOM, 1);
                if (!temp)
                    temp = me->GetVictim();

                //replace with spell cast 31903 once implicitTarget 73 implemented
                SummonDoomfire(temp);

                //supposedly three doomfire can be up at the same time
                DoomfireTimer = 20000;
            } else DoomfireTimer -= diff;

            if (MeleeRangeCheckTimer <= diff)
            {
                if (CanUseFingerOfDeath())
                {
                    DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_FINGER_OF_DEATH);
                    MeleeRangeCheckTimer = 1000;
                }

                MeleeRangeCheckTimer = 5000;
            } else MeleeRangeCheckTimer -= diff;

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

                if (StormCount)
                {
                    Unit *pTarget = Unit::GetUnit(*me, CloudGUID);
                    if (!pTarget || !pTarget->isAlive())
                    {
                        EnterEvadeMode();
                        return;
                    }
                    else if (Unit* Cyclone = Unit::GetUnit(*me, CycloneGUID))
                        Cyclone->CastSpell(pTarget, 25160, true); // keep casting or...

                    if (StormSequenceTimer <= diff)
                        HandleStormSequence(pTarget);
                    else
                        StormSequenceTimer -= diff;

                    return;
                }

                if (Enrage_Timer <= diff)
                {
                    me->MonsterYell(SAY_ONENRAGE, LANG_UNIVERSAL, NULL);
                    DoPlaySoundToSet(me, SOUND_ONENRAGE);
                    DoCast(me, SPELL_BERSERK, true);
                    Enrage_Timer = 600000;
                } else Enrage_Timer -= diff;

                if (StaticDisruption_Timer <= diff)
                {
                    Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1);
                    if (!pTarget) pTarget = me->getVictim();
                    TargetGUID = pTarget->GetGUID();
                    DoCast(pTarget, SPELL_STATIC_DISRUPTION, false);
                    me->SetInFront(me->getVictim());
                    StaticDisruption_Timer = (10+rand()%8)*1000; // < 20s

                    /*if (float dist = me->IsWithinDist3d(pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 5.0f) dist = 5.0f;
                    SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/
                } else StaticDisruption_Timer -= diff;

                if (GustOfWind_Timer <= diff)
                {
                    Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1);
                    if (!pTarget) pTarget = me->getVictim();
                    DoCast(pTarget, SPELL_GUST_OF_WIND);
                    GustOfWind_Timer = (20+rand()%10)*1000; //20 to 30 seconds(bosskillers)
                } else GustOfWind_Timer -= diff;

                if (CallLighting_Timer <= diff)
                {
                    DoCast(me->getVictim(), SPELL_CALL_LIGHTNING);
                    CallLighting_Timer = (12 + rand()%5)*1000; //totaly random timer. can't find any info on this
                } else CallLighting_Timer -= diff;

                if (!isRaining && ElectricalStorm_Timer < uint32(8000 + rand() % 5000))
                {
                    SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f);
                    isRaining = true;
                }

                if (ElectricalStorm_Timer <= diff) {
                    Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true);
                    if (!pTarget)
                    {
                        EnterEvadeMode();
                        return;
                    }
                    pTarget->CastSpell(pTarget, 44007, true);//cloud visual
                    DoCast(pTarget, SPELL_ELECTRICAL_STORM, false);//storm cyclon + visual
                    float x,y,z;
                    pTarget->GetPosition(x,y,z);
                    if (pTarget)
                    {
                        pTarget->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
                        pTarget->SendMonsterMove(x,y,me->GetPositionZ()+15,0);
                    }
                    Unit *Cloud = me->SummonTrigger(x, y, me->GetPositionZ()+16, 0, 15000);
                    if (Cloud)
                    {
                        CloudGUID = Cloud->GetGUID();
                        Cloud->SetUnitMovementFlags(MOVEMENTFLAG_LEVITATING);
                        Cloud->StopMoving();
                        Cloud->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
                        Cloud->setFaction(35);
                        Cloud->SetMaxHealth(9999999);
                        Cloud->SetHealth(9999999);
                        Cloud->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    }
                    ElectricalStorm_Timer = 60000; //60 seconds(bosskillers)
                    StormCount = 1;
                    StormSequenceTimer = 0;
                } else ElectricalStorm_Timer -= diff;

                if (SummonEagles_Timer <= diff)
                {
                    me->MonsterYell(SAY_ONSUMMON, LANG_UNIVERSAL, NULL);
                    DoPlaySoundToSet(me, SOUND_ONSUMMON);

                    float x, y, z;
                    me->GetPosition(x, y, z);

                    for (uint8 i = 0; i < 8; ++i)
                    {
                        Unit* bird = Unit::GetUnit(*me,BirdGUIDs[i]);
                        if (!bird) //they despawned on die
                        {
                            if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0))
                            {
                                x = pTarget->GetPositionX() + irand(-10,10);
                                y = pTarget->GetPositionY() + irand(-10,10);
                                z = pTarget->GetPositionZ() + urand(16,20);
                                if (z > 95)
                                    z = 95.0f - urand(0,5);
                            }
                            Creature *pCreature = me->SummonCreature(MOB_SOARING_EAGLE, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                            if (pCreature)
                            {
                                pCreature->AddThreat(me->getVictim(), 1.0f);
                                pCreature->AI()->AttackStart(me->getVictim());
                                BirdGUIDs[i] = pCreature->GetGUID();
                            }
                        }
                    }
                    SummonEagles_Timer = 999999;
                } else SummonEagles_Timer -= diff;

                DoMeleeAttackIfReady();
            }
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        //If some worshipers are dead cast spell
        for(uint8 i=0; i<4; ++i)
        {
            Unit* pGuard = Unit::GetUnit(*m_creature, m_uiGuardGUID[i]);
            if(pGuard && !pGuard->isAlive())
            {
                m_creature->CastSpell(m_creature, SPELL_SELF_SPAWN_10, true);
                m_uiGuardGUID[i] = 0;
            }
        }

        // Impale
        if (m_uiImpaleTimer < uiDiff)
        {
            //Cast Impale on a random target
            //Do NOT cast it when we are afflicted by locust swarm
            if (!m_creature->HasAura(SPELL_LOCUSTSWARM) || !m_creature->HasAura(SPELL_LOCUSTSWARM_H))
            {
                if (Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    DoCastSpellIfCan(target, m_bIsRegularMode ? SPELL_IMPALE : SPELL_IMPALE_H);
            }

            m_uiImpaleTimer = 15000;
        }
        else
            m_uiImpaleTimer -= uiDiff;

        // Locust Swarm
        if (m_uiLocustSwarmTimer < uiDiff)
        {
            if(m_creature)
                DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_LOCUSTSWARM : SPELL_LOCUSTSWARM_H);
            m_uiLocustSwarmTimer = 90000;

            Creature* Guard = m_creature->SummonCreature(NPC_CRYPT_GUARD, m_creature->GetPositionX(), m_creature->GetPositionY()+10, m_creature->GetPositionZ(), m_creature->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000);
            if(Guard)
            {
                m_uiGuardGUID[3] = Guard->GetGUID();
                if(Unit* pPlayer = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    Guard->AI()->AttackStart(pPlayer);
            }

            m_uiLocustSwarmTimer = 90000;
        }
        else
            m_uiLocustSwarmTimer -= uiDiff;

        // Summon
        /*if (m_uiSummonTimer < uiDiff)
        {
            DoCastSpellIfCan(m_creature, SPELL_SUMMONGUARD);
            Summon_Timer = 45000;
        }
        else
            m_uiSummonTimer -= uiDiff;*/

        DoMeleeAttackIfReady();
    }
Example #10
0
        void DoWork()
        {
            switch (m_phase)
            {
            case 0:
            {
                Creature* oger = me->FindNearestCreature(NPC_OGER, 10.0f);
                Creature* kobold = me->FindNearestCreature(NPC_KOBOLD, 10.0f);
                Creature* defias = me->FindNearestCreature(NPC_DEFIAS, 10.0f);
                if (Creature* bunny = me->FindNearestCreature(NPC_TARGET_BUNNY, 125.0f))
                    if (Player* player = me->FindNearestPlayer(125.0f, true))
                    {
                        m_PlayerGUID = player->GetGUID();
                        m_BunnyGUID = bunny->GetGUID();
                        Creature* worker = NULL;
                        if (oger && kobold)
                            worker = RAND(oger, kobold);
                        else if (oger)
                            worker = oger;
                        else if (kobold)
                            worker = kobold;
                        else if(defias)
                            worker = defias;

                        if (worker)
                        {
                            m_WorkerGUID = worker->GetGUID();
                            m_WorkCounter = 0;
                            worker->HandleEmote(EMOTE_STATE_WORK);
                            m_phase = 1;
                            m_timer = 5000;
                            return;
                        }
                    }

                if (m_WorkCounter < 2)
                {
                    m_WorkCounter++;
                    if (oger)
                        oger->HandleEmoteState(EMOTE_ONESHOT_NONE);
                    if (kobold)
                    {
                        kobold->HandleEmoteCommand(EMOTE_ONESHOT_NONE);
                        kobold->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
                    }
                    if (defias)
                        defias->HandleEmoteState(EMOTE_ONESHOT_NONE);
                }
                break;
            }
            case 1:
            {
				if (Player* player = ObjectAccessor::GetPlayer(*me, m_PlayerGUID))
					if (Creature* bunny = ObjectAccessor::GetCreature(*me, m_BunnyGUID))
						if (Creature* worker = ObjectAccessor::GetCreature(*me, m_WorkerGUID))
                        {
                            float dist = bunny->GetDistance2d(player);
                            if (dist < 10.0f)
                            {
                                m_TargetTyp = 1;
                                me->CastSpell(player, SPELL_CANNON_A, true);
                                worker->HandleEmoteState(EMOTE_ONESHOT_NONE);
                                m_phase = 2;
                                return;
                            }
                            else
                            {
                                m_TargetTyp = 2;
                                me->CastSpell(bunny, SPELL_CANNON_A, true);
                                worker->HandleEmoteState(EMOTE_ONESHOT_NONE);
                                m_phase = 2;
                                return;
                            }
                        }

                m_phase = 0;
                break;
            }
            case 2:
				if (Player* player = ObjectAccessor::GetPlayer(*me, m_PlayerGUID))
					if (Creature* bunny = ObjectAccessor::GetCreature(*me, m_BunnyGUID))
						if (Creature* worker = ObjectAccessor::GetCreature(*me, m_WorkerGUID))
                            if (m_TargetTyp == 1)
                            {
                                me->CastSpell(player, SPELL_CANNON_B, true);
                                worker->HandleEmoteState(EMOTE_ONESHOT_NONE);
                            }
                            else if (m_TargetTyp == 2)
                            {
                                me->CastSpell(bunny, SPELL_CANNON_B, true);
                                worker->HandleEmoteCommand(EMOTE_ONESHOT_NONE);
                                worker->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
                            }

                m_TargetTyp = 0;
                m_phase = 0;
                m_timer = urand(11000, 16000);
                break;
            }
        }
Example #11
0
bool EffectAuraDummy_spell_aura_dummy_npc(const Aura* pAura, bool bApply)
{
    switch(pAura->GetId())
    {
        case SPELL_BLESSING_OF_PEACE:
        {
            Creature* pCreature = (Creature*)pAura->GetTarget();

            if (!pCreature || pCreature->GetEntry() != NPC_FALLEN_HERO_SPIRIT)
                return true;

            if (pAura->GetEffIndex() != EFFECT_INDEX_0)
                return true;

            if (bApply)
            {
                switch(urand(0, 4))
                {
                    case 0: DoScriptText(SAY_BLESS_1, pCreature); break;
                    case 1: DoScriptText(SAY_BLESS_2, pCreature); break;
                    case 2: DoScriptText(SAY_BLESS_3, pCreature); break;
                    case 3: DoScriptText(SAY_BLESS_4, pCreature); break;
                    case 4: DoScriptText(SAY_BLESS_5, pCreature); break;
                }
            }
            else
            {
                if (Player* pPlayer = (Player*)pAura->GetCaster())
                {
                    pPlayer->KilledMonsterCredit(NPC_FALLEN_HERO_SPIRIT_PROXY, pCreature->GetGUID());
                    pCreature->ForcedDespawn();
                }
            }

            return true;
        }
        case SPELL_HEALING_SALVE:
        {
            if (pAura->GetEffIndex() != EFFECT_INDEX_0)
                return true;

            if (bApply)
            {
                if (Unit* pCaster = pAura->GetCaster())
                    pCaster->CastSpell(pAura->GetTarget(), SPELL_HEALING_SALVE_DUMMY, true);
            }

            return true;
        }
        case SPELL_HEALING_SALVE_DUMMY:
        {
            if (pAura->GetEffIndex() != EFFECT_INDEX_0)
                return true;

            if (!bApply)
            {
                Creature* pCreature = (Creature*)pAura->GetTarget();

                pCreature->UpdateEntry(NPC_MAGHAR_GRUNT);

                if (pCreature->getStandState() == UNIT_STAND_STATE_KNEEL)
                    pCreature->SetStandState(UNIT_STAND_STATE_STAND);

                pCreature->ForcedDespawn(60*IN_MILLISECONDS);
            }

            return true;
        }
        case SPELL_RECHARGING_BATTERY:
        {
            if (pAura->GetEffIndex() != EFFECT_INDEX_0)
                return true;

            if (!bApply)
            {
                if (pAura->GetTarget()->HasAuraState(AURA_STATE_HEALTHLESS_20_PERCENT))
                    ((Creature*)pAura->GetTarget())->UpdateEntry(NPC_DRAINED_PHASE_HUNTER);
            }

            return true;
        }
        case SPELL_TAG_MURLOC:
        {
            Creature* pCreature = (Creature*)pAura->GetTarget();

            if (pAura->GetEffIndex() != EFFECT_INDEX_0)
                return true;

            if (bApply)
            {
                if (pCreature->GetEntry() == NPC_BLACKSILT_MURLOC)
                {
                    if (Unit* pCaster = pAura->GetCaster())
                        pCaster->CastSpell(pCreature, SPELL_TAG_MURLOC_PROC, true);
                }
            }
            else
            {
                if (pCreature->GetEntry() == NPC_TAGGED_MURLOC)
                    pCreature->ForcedDespawn();
            }

            return true;
        }
        case SPELL_RAELORASZ_FIREBALL:
        {
            if (pAura->GetEffIndex() != EFFECT_INDEX_0)
                return true;
            
            if (Unit* pCaster = pAura->GetCaster())
                DoScriptText(SAY_SPECIMEN, pCaster);

            Unit* pTarget = pAura->GetTarget();
            if (pTarget->GetTypeId() == TYPEID_UNIT)
            {
                Creature* pCreature = (Creature*)pTarget;

                if (pCreature->GetEntry() == NPC_NEXUS_DRAKE_HATCHLING)
                {
                    pCreature->SetStandState(UNIT_STAND_STATE_SLEEP);
                    pCreature->ForcedDespawn(3000);
                }
            }
            return true;
        }
        case SPELL_ENRAGE:
        {
            if (pAura->GetTarget()->GetTypeId() != TYPEID_UNIT || !bApply)
                return false;

            if (Creature* pCreature = GetClosestCreatureWithEntry(pAura->GetTarget(), NPC_DARKSPINE_MYRMIDON, 25.0f))
            {
                dynamic_cast<Creature*>(pAura->GetTarget())->AI()->AttackStart(pCreature);
                return true;
            }

            if (Creature* pCreature = GetClosestCreatureWithEntry(pAura->GetTarget(), NPC_DARKSPINE_SIREN, 25.0f))
            {
                dynamic_cast<Creature*>(pAura->GetTarget())->AI()->AttackStart(pCreature);
                return true;
            }

            return false;
        }
    }

    return false;
}
Example #12
0
        void UpdateAI(const uint32 diff)
        {
            if (EventInProgress) {
                Player* pWarrior = NULL;

                if (PlayerGUID)
                    pWarrior = Unit::GetPlayer(*me, PlayerGUID);

                if (!pWarrior)
                    return;

                if (!pWarrior->isAlive() && pWarrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) {
                    EventInProgress = false;
                    DoScriptText(SAY_TWIGGY_FLATHEAD_DOWN, me);
                    pWarrior->FailQuest(1719);

                    for (uint8 i = 0; i < 6; ++i)
                    {
                        if (AffrayChallenger[i])
                        {
                            Creature* pCreature = Unit::GetCreature((*me), AffrayChallenger[i]);
                            if (pCreature) {
                                if (pCreature->isAlive())
                                {
                                    pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
                                    pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                    pCreature->setDeathState(JUST_DIED);
                                }
                            }
                        }
                        AffrayChallenger[i] = 0;
                        Challenger_down[i] = false;
                    }

                    if (BigWill)
                    {
                        Creature* pCreature = Unit::GetCreature((*me), BigWill);
                        if (pCreature) {
                            if (pCreature->isAlive()) {
                                pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
                                pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pCreature->setDeathState(JUST_DIED);
                            }
                        }
                    }
                    BigWill = 0;
                }

                if (!EventGrate && EventInProgress)
                {
                    float x, y, z;
                    pWarrior->GetPosition(x, y, z);

                    if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324) {
                        pWarrior->AreaExploredOrEventHappens(1719);
                        DoScriptText(SAY_TWIGGY_FLATHEAD_BEGIN, me);

                        for (uint8 i = 0; i < 6; ++i)
                        {
                            Creature* pCreature = me->SummonCreature(NPC_AFFRAY_CHALLENGER, AffrayChallengerLoc[i][0], AffrayChallengerLoc[i][1], AffrayChallengerLoc[i][2], AffrayChallengerLoc[i][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            if (!pCreature)
                                continue;
                            pCreature->setFaction(35);
                            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            pCreature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
                            AffrayChallenger[i] = pCreature->GetGUID();
                        }
                        Wave_Timer = 5000;
                        Challenger_checker = 1000;
                        EventGrate = true;
                    }
                }
                else if (EventInProgress)
                {
                    if (Challenger_checker <= diff)
                    {
                        for (uint8 i = 0; i < 6; ++i)
                        {
                            if (AffrayChallenger[i])
                            {
                                Creature* pCreature = Unit::GetCreature((*me), AffrayChallenger[i]);
                                if ((!pCreature || (!pCreature->isAlive())) && !Challenger_down[i])
                                {
                                    DoScriptText(SAY_TWIGGY_FLATHEAD_DOWN, me);
                                    Challenger_down[i] = true;
                                }
                            }
                        }
                        Challenger_checker = 1000;
                    } else Challenger_checker -= diff;

                    if (Wave_Timer <= diff)
                    {
                        if (AffrayChallenger[Wave] && Wave < 6 && !EventBigWill)
                        {
                            DoScriptText(SAY_TWIGGY_FLATHEAD_FRAY, me);
                            Creature* pCreature = Unit::GetCreature((*me), AffrayChallenger[Wave]);
                            if (pCreature && (pCreature->isAlive()))
                            {
                                pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                                pCreature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
                                pCreature->setFaction(14);
                                pCreature->AI()->AttackStart(pWarrior);
                                ++Wave;
                                Wave_Timer = 20000;
                            }
                        }
                        else if (Wave >= 6 && !EventBigWill) {
                            if (Creature* pCreature = me->SummonCreature(NPC_BIG_WILL, -1722, -4341, 6.12f, 6.26f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 480000))
                            {
                                BigWill = pCreature->GetGUID();
                                //pCreature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32f);
                                //pCreature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78f);
                                pCreature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79f);
                                pCreature->HandleEmoteCommand(EMOTE_STATE_READYUNARMED);
                                EventBigWill = true;
                                Wave_Timer = 1000;
                            }
                        }
                        else if (Wave >= 6 && EventBigWill && BigWill)
                        {
                            Creature* pCreature = Unit::GetCreature((*me), BigWill);
                            if (!pCreature || !pCreature->isAlive())
                            {
                                DoScriptText(SAY_TWIGGY_FLATHEAD_OVER, me);
                                EventInProgress = false;
                                EventBigWill = false;
                                EventGrate = false;
                                PlayerGUID = 0;
                                Wave = 0;
                            }
                        }
                    } else Wave_Timer -= diff;
                }
            }
        }
void npc_reginald_windsorAI::UpdateAI(const uint32 uiDiff)
{
    // in case of idle / afk players
    if (m_uiDespawnTimer < uiDiff)
    {
        PokeRowe();
        m_creature->ForcedDespawn();
    }
    else
        m_uiDespawnTimer -= uiDiff;

    for (int i = 0; i < 6; i++)
    {
        if (GardeNeed[i] == true)
        {
            if (GardeTimer[i] < uiDiff)
            {
                if (Creature* pGarde = GetGuard(i))
                {
                    int Var = i + 7;
                    pGarde->SetFacingTo(WindsorEventMove[Var].o);
                    pGarde->SetStandState(UNIT_STAND_STATE_KNEEL);
                    GardeNeed[i] = false;
                }
            }
            else
                GardeTimer[i] -= uiDiff;
        }
    }
    if (Begin)
    {
        if (m_creature->GetDistance2d(WindsorDeplacement[0].x, WindsorDeplacement[0].y) < 2.0f)
        {
            Begin = false;
            m_creature->Unmount();
            m_creature->CastSpell(m_creature, SPELL_WINDSOR_DISMISS_HORSE, true);
            m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);

            if (Creature* pMercutio = m_creature->FindNearestCreature(NPC_MERCUTIO, 10.0f))
            {
                pMercutio->SetSpeedRate(MOVE_WALK, 2.5f, true);
                pMercutio->setFaction(m_creature->getFaction());
                pMercutio->GetMotionMaster()->MovePoint(0, -9148.395508f, 371.322174f, 90.543655f);
                pMercutio->ForcedDespawn(12000);
                m_creature->SetFacingToObject(pMercutio);
                m_creature->MonsterSay("Yawww!");
                m_creature->HandleEmote(EMOTE_ONESHOT_ATTACKUNARMED);
            }

            m_creature->SetWalk(true);
            m_creature->SetSpeedRate(MOVE_WALK, 1.0f, true);
            GreetPlayer = true;
        }
    }

    if (!BeginQuest)
    {
        if (GreetPlayer)
        {
            if (Timer <= uiDiff)
            {
                Player* pPlayer = GetPlayer();
                if (pPlayer)
                {
                    m_creature->SetFacingToObject(pPlayer);
                    char sMessage[200];
                    sprintf(sMessage, "I knew you would come, %s. It is good to see you again, friend.", pPlayer->GetName());
                    m_creature->MonsterSay(sMessage);
                    m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
                }
                Timer = 5000;
                GreetPlayer = false;
            }
            else
                Timer -= uiDiff;
        }
        return;
    }

    if (Timer < uiDiff)
    {
        std::list<Creature*> DragListe;
        float X = 0.0f;
        float Y = 0.0f;
        uint32 eventGardId = 6;
        switch (Tick)
        {
        case 0:
            m_uiDespawnTimer = 20 * MINUTE*IN_MILLISECONDS;
            m_creature->SetFacingTo(0.659f);
            m_creature->MonsterYellToZone(NOST_TEXT(235));
            m_creature->HandleEmote(EMOTE_ONESHOT_SHOUT);
            Timer = 5000;
            break;
        case 1:
            for (int i = 0; i < 6; i++)
            {
                int Var = i + 1;
                Creature* pSummon = m_creature->SummonCreature(NPC_STORMWIND_CITY_GUARD,
                    WindsorEventMove[Var].x,
                    WindsorEventMove[Var].y,
                    WindsorEventMove[Var].z,
                    WindsorEventMove[Var].o, TEMPSUMMON_TIMED_DESPAWN, 240 * IN_MILLISECONDS);
                if (pSummon)
                {
                    GardesGUIDs[i] = pSummon->GetGUID();
                    pSummon->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                }
            }
            if (Creature* Onyxia = m_creature->SummonCreature(NPC_KATRANA_PRESTOR, -9075.6f, 466.11f, 120.383f, 6.27f, TEMPSUMMON_TIMED_DESPAWN, 10 * IN_MILLISECONDS))
            {
                Onyxia->SetDisplayId(11686);
                Onyxia->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                Onyxia->MonsterYellToZone(NOST_TEXT(WindsorTalk[IDSpeech]));
                IDSpeech++;
            }
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->GetMotionMaster()->MovePoint(0, WindsorEventMove[0].x, WindsorEventMove[0].y, WindsorEventMove[0].z);
                General->Unmount();
            }
            m_creature->GetMotionMaster()->MovePoint(0, WindsorDeplacement[1].x, WindsorDeplacement[1].y, WindsorDeplacement[1].z);
            X = m_creature->GetPositionX() - WindsorDeplacement[1].x;
            Y = m_creature->GetPositionY() - WindsorDeplacement[1].y;
            Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            break;
        case 2:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                DoTalk(General, false);
                General->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            Timer = 10000;
            break;
        case 3:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 4:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 5:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                DoTalk(General, false);
                General->HandleEmote(EMOTE_ONESHOT_TALK);
                General->MonsterTextEmote("General Marcus Jonathan appears lost in contemplation.", nullptr);
            }
            Timer = 10000;
            break;
        case 6:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                DoTalk(General, false);
                General->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            Timer = 10000;
            break;
        case 7:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 8:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 9:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                if (Creature* pGarde = GetGuard(0))
                    General->SetFacingToObject(pGarde);
                General->HandleEmote(EMOTE_ONESHOT_EXCLAMATION);
                DoTalk(General, false);
            }
            Timer = 4000;
            break;
        case 10:
            eventGardId = 0;
            break;
        case 11:
            eventGardId = 1;
            break;
        case 12:
            eventGardId = 2;
            break;
        case 13:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                if (Creature* pGarde = GetGuard(3))
                    General->SetFacingToObject(pGarde);
                General->HandleEmote(EMOTE_ONESHOT_EXCLAMATION);
                DoTalk(General, false);
            }
            Timer = 4000;
            break;
        case 14:
            eventGardId = 3;
            break;
        case 15:
            eventGardId = 4;
            break;
        case 16:
            eventGardId = 5;
            break;
        case 17:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->SetFacingToObject(m_creature);
                DoTalk(General, true);
                General->HandleEmote(EMOTE_ONESHOT_SHOUT);
            }
            Timer = 5000;
            break;
        case 18:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
                General->HandleEmote(EMOTE_ONESHOT_SALUTE);
            Timer = 5000;
            break;
        case 19:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
                DoTalk(General, false);
            Timer = 10000;
            break;
        case 20:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->GetMotionMaster()->MovePoint(0, WindsorEventMove[13].x, WindsorEventMove[13].y, WindsorEventMove[13].z);
                X = General->GetPositionX() - WindsorEventMove[13].x;
                Y = General->GetPositionY() - WindsorEventMove[13].y;
                Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            }
            else Timer = 1000;
            break;
        case 21:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->HandleEmote(EMOTE_STATE_KNEEL);
                General->SetFacingTo(WindsorEventMove[13].o);
                m_creature->SetFacingToObject(General);
                DoTalk(m_creature, false);
            }
            Timer = 10000;
            break;
        case 22:
            if (Creature* pGarde = GetGuard(0))
                m_creature->SetFacingToObject(pGarde);
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_POINT);
            Timer = 5000;
            break;
        case 25:
            NeedCheck = true;
            break;
        case 26:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->ForcedDespawn();
                General->Respawn();
            }
            break;
        case 40:
            m_uiDespawnTimer = 10 * MINUTE*IN_MILLISECONDS;
            BeginQuest = false;
            m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 1);
            DoTalk(m_creature, false);
            break;
        case 47:
            DoTalk(m_creature, false);
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                Bolvar->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP);
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                Onyxia->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP);
            Timer = 10000;
            break;
        case 48:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                DoTalk(Bolvar, false);
            Timer = 500;
            break;
        case 49:
            if (Creature* Anduin = m_creature->FindNearestCreature(NPC_ANDUIN_WRYNN, 150.0f))
                Anduin->GetMotionMaster()->MovePoint(0, WindsorEventMove[14].x, WindsorEventMove[14].y, WindsorEventMove[14].z);
            Timer = 5000;
            break;
        case 50:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                m_creature->SetFacingToObject(Onyxia);
                DoTalk(m_creature, false);
                m_creature->HandleEmote(EMOTE_ONESHOT_POINT);
            }
            Timer = 10000;
            break;
        case 51:
        case 52:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                DoTalk(Onyxia, false);
                Onyxia->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            Timer = 10000;
            break;
        case 53:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 7000;
            break;
        case 54:
            m_creature->MonsterTextEmote("Reginald Windsor reaches into his pack and pulls out the encoded tablets.");
            Timer = 4000;
            break;
        case 55:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 6000;
            break;
        case 56:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 4000;
            break;
        case 57:
            m_creature->MonsterTextEmote("Reginald Windsor reads from the tablets. Unknown, unheard sounds flow through your consciousness.");
            Timer = 2000;
            break;
        case 58:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                m_creature->CastSpell(Onyxia, SPELL_WINSOR_READ_TABLETS, false);
            Timer = 10000;
            break;
        case 59:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->CastSpell(Onyxia, SPELL_ONYXIA_TRANS, true);
                Onyxia->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
            }
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                Bolvar->MonsterTextEmote("Highlord Bolvar Fordragon gasps.");
            Timer = 2000;
            break;
        case 60:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                Bolvar->GetMotionMaster()->MovePoint(0, WindsorEventMove[15].x, WindsorEventMove[15].y, WindsorEventMove[15].z);
                X = Bolvar->GetPositionX() - WindsorEventMove[15].x;
                Y = Bolvar->GetPositionY() - WindsorEventMove[15].y;
                Timer = 1000 + sqrt((X * X) + (Y * Y)) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            }
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                DoTalk(Onyxia, false);
                Onyxia->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            else Timer = 5000;
            break;
        case 61:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                    Bolvar->SetFacingToObject(Onyxia);
                DoTalk(Bolvar, true);
            }
            Timer = 1000;
            break;
        case 62:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                Onyxia->MonsterTextEmote("Lady Onyxia laughs.");
            Timer = 2000;
            break;
        case 63:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->MonsterSay("Yesss... Guards, come to your lord's aid!");
                int Var = 0;
                GetCreatureListWithEntryInGrid(DragListe, Onyxia, NPC_STORMWIND_ROYAL_GUARD, 25.0f);
                for (auto itr = DragListe.begin(); itr != DragListe.end(); ++itr)
                {
                    DragsGUIDs[Var] = (*itr)->GetGUID();
                    (*itr)->UpdateEntry(NPC_ONYXIA_ELITE_GUARD);
                    (*itr)->AIM_Initialize();
                    (*itr)->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    if (!urand(0, 2))
                        (*itr)->MonsterTextEmote("Onyxia's Elite Guard hisses.");
                    Var++;
                }
            }
            Timer = 4000;
            break;
        case 64:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                Onyxia->CastSpell(m_creature, SPELL_WINDSOR_DEATH, false);
            Timer = 1500;
            break;
        case 65:
            DoTalk(m_creature, false);
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->MonsterSay("Was this fated, Windsor? If it was death that you came for then the prophecy has been fulfilled. May your consciousness rot in the Twisting Nether. Finish the rest of these meddlesome insects, children. Bolvar, you have been a pleasurable puppet.");
                Onyxia->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PASSIVE);
                if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                {
                    int Var = 0;
                    while (DragsGUIDs[Var] && Var < 9)
                    {
                        Creature* crea = me->GetMap()->GetCreature(DragsGUIDs[Var]);
                        crea->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                        crea->getThreatManager().addThreatDirectly(Bolvar, 5000.0f);
                        crea->SetTargetGuid(Bolvar->GetGUID());
                        Bolvar->AddThreat(crea);
                        Bolvar->SetInCombatWith(crea);
                        crea->SetInCombatWith(Bolvar);
                        Var++;
                    }
                }
            }
            Timer = 5000;
            break;
        case 66:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->MonsterYell("You have failed him, mortalsss... Farewell!");
                Onyxia->CastSpell(Onyxia, SPELL_PRESTOR_DESPAWNS, true);
            }
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                Bolvar->MonsterTextEmote("Highlord Bolvar Fordragon's medallion shatters.");
            Timer = 1000;
            PhaseFinale = true;
            break;
        case 67:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP);
                Onyxia->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
                Onyxia->ForcedDespawn();
                Onyxia->SetRespawnDelay(7 * MINUTE);
                Onyxia->SetRespawnTime(7 * MINUTE);
            }
            Tick = 100; // come back when combat is done
            break;
        case 68:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                DoTalk(Bolvar, false);
                DoTalk(m_creature, false);
                Bolvar->HandleEmote(EMOTE_ONESHOT_KNEEL);
            }
            Timer = 4500;
            break;
        case 69:
            SituationFinale();
            BeginQuest = false;
            m_creature->MonsterTextEmote("Reginald Windsor dies.");
            m_creature->CastSpell(m_creature, 5, true);
            break;
        }
        if (eventGardId < 6)
        {
            if (Creature* pGarde = GetGuard(eventGardId))
            {
                int Var = eventGardId + 7;
                pGarde->GetMotionMaster()->MovePoint(0, WindsorEventMove[Var].x, WindsorEventMove[Var].y, WindsorEventMove[Var].z);
                X = pGarde->GetPositionX() - WindsorEventMove[Var].x;
                Y = pGarde->GetPositionY() - WindsorEventMove[Var].y;
            }
            GardeTimer[eventGardId] = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            GardeNeed[eventGardId] = true;
            Timer = 1000;
        }
        if (Tick > 23 && Tick < 40)
        {
            int Var = Tick - 21;
            m_creature->GetMotionMaster()->MovePoint(0, WindsorDeplacement[Var].x, WindsorDeplacement[Var].y, WindsorDeplacement[Var].z);
            X = m_creature->GetPositionX() - WindsorDeplacement[Var].x;
            Y = m_creature->GetPositionY() - WindsorDeplacement[Var].y;
            Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
        }
        else if (Tick > 41 && Tick < 46)
        {
            int Var = Tick - 22;
            m_creature->GetMotionMaster()->MovePoint(0, WindsorDeplacement[Var].x, WindsorDeplacement[Var].y, WindsorDeplacement[Var].z);
            X = m_creature->GetPositionX() - WindsorDeplacement[Var].x;
            Y = m_creature->GetPositionY() - WindsorDeplacement[Var].y;
            Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
        }
        else if (PhaseFinale == true)
        {
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                if (!Bolvar->isInCombat())
                {
                    if (!CombatJustEnded)
                    {
                        Bolvar->SetWalk(true);
                        Bolvar->GetMotionMaster()->MovePoint(0, -8447.39f, 335.35f, 121.747f, 1.29f);
                        CombatJustEnded = true;
                        Timer = 5000;
                        Tick = 68;
                        return;
                    }
                }
            }
        }
        Tick++;
    }
    else
        Timer -= uiDiff;
}
Example #14
0
void hyjalAI::SummonCreature(uint32 entry, float Base[4][3])
{
    uint32 random = rand()%4;
    float SpawnLoc[3];

    for (uint8 i = 0; i < 3; ++i)
    {
        SpawnLoc[i] = Base[random][i];
    }
    Creature* creature = NULL;
    switch (entry)
    {
            case 17906:    //GARGOYLE

                if (!FirstBossDead && (WaveCount == 1 || WaveCount == 3))
                {//summon at tower
                    creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][1]+irand(-20, 20), SpawnPointSpecial[SPAWN_NEAR_TOWER][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                    if (creature)
                        CAST_AI(hyjal_trashAI, creature->AI())->useFlyPath = true;
                }
                else
                {//summon at gate
                    creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_GARG_GATE][0]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][1]+irand(-10, 10), SpawnPointSpecial[SPAWN_GARG_GATE][2]+irand(-10, 10), 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                }
                break;
            case 17907:    //FROST_WYRM,
                if (FirstBossDead && WaveCount == 1) //summon at gate
                    creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_WYRM_GATE][0], SpawnPointSpecial[SPAWN_WYRM_GATE][1], SpawnPointSpecial[SPAWN_WYRM_GATE][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                else
                {
                    creature = me->SummonCreature(entry, SpawnPointSpecial[SPAWN_NEAR_TOWER][0], SpawnPointSpecial[SPAWN_NEAR_TOWER][1], SpawnPointSpecial[SPAWN_NEAR_TOWER][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                    if (creature)
                        CAST_AI(hyjal_trashAI, creature->AI())->useFlyPath = true;
                }
                break;
            case 17908:    //GIANT_INFERNAL
                ++InfernalCount;
                if (InfernalCount > 7)
                    InfernalCount = 0;
                creature = me->SummonCreature(entry, InfernalPos[InfernalCount][0], InfernalPos[InfernalCount][1], InfernalPos[InfernalCount][2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                break;
            default:
                creature = me->SummonCreature(entry, SpawnLoc[0], SpawnLoc[1], SpawnLoc[2], 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120000);
                break;

    }

    if (creature)
    {
        // Increment Enemy Count to be used in World States and instance script
        ++EnemyCount;

        creature->SetWalk(false);
        creature->setActive(true);
        switch (entry)
        {
            case NECROMANCER:
            case ABOMINATION:
            case GHOUL:
            case BANSHEE:
            case CRYPT_FIEND:
            case GARGOYLE:
            case FROST_WYRM:
            case GIANT_INFERNAL:
            case FEL_STALKER:
            case RAGE_WINTERCHILL:
            case ANETHERON:
            case KAZROGAL:
            case AZGALOR:
                CAST_AI(hyjal_trashAI, creature->AI())->IsEvent = true;
                break;
        }
        if (instance)
        {
            if (instance->GetData(DATA_RAIDDAMAGE) < MINRAIDDAMAGE)
                creature->SetDisableReputationGain(true);//no repu for solo farming
        }
        // Check if Creature is a boss.
        if (creature->isWorldBoss())
        {
            if (!FirstBossDead)  BossGUID[0] = creature->GetGUID();
            else                BossGUID[1] = creature->GetGUID();
            CheckTimer = 5000;
        }
    }
}
Example #15
0
void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
{
    CHECK_PACKET_SIZE(recv_data, 8+4+2+2);

    sLog.outDetail( "HandlePetSetAction. CMSG_PET_SET_ACTION" );

    uint64 petguid;
    uint32 position;
    uint16 spell_id;
    uint16 act_state;
    uint8  count;

    recv_data >> petguid;

    // FIXME: charmed case
    //Pet* pet = ObjectAccessor::Instance().GetPet(petguid);
    if(ObjectAccessor::FindPlayer(petguid))
        return;

    Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, petguid);

    if(!pet || (pet != _player->GetPet() && pet != _player->GetCharm()))
    {
        sLog.outError( "HandlePetSetAction: Unknown pet or pet owner." );
        return;
    }

    CharmInfo *charmInfo = pet->GetCharmInfo();
    if(!charmInfo)
    {
        sLog.outError("WorldSession::HandlePetSetAction: object "I64FMTD" is considered pet-like but doesn't have a charminfo!", pet->GetGUID());
        return;
    }

    count = (recv_data.size() == 24) ? 2 : 1;
    for(uint8 i = 0; i < count; ++i)
    {
        recv_data >> position;
        recv_data >> spell_id;
        recv_data >> act_state;

        sLog.outDetail( "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X", _player->GetName(), position, spell_id, act_state);

        //if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
        if(!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
        {
            //sign for autocast
            if(act_state == ACT_ENABLED && spell_id)
            {
                if(pet->isCharmed())
                    charmInfo->ToggleCreatureAutocast(spell_id, true);
                else
                    ((Pet*)pet)->ToggleAutocast(spell_id, true);
            }
            //sign for no/turn off autocast
            else if(act_state == ACT_DISABLED && spell_id)
            {
                if(pet->isCharmed())
                    charmInfo->ToggleCreatureAutocast(spell_id, false);
                else
                    ((Pet*)pet)->ToggleAutocast(spell_id, false);
            }

            charmInfo->GetActionBarEntry(position)->Type = act_state;
            charmInfo->GetActionBarEntry(position)->SpellOrAction = spell_id;
        }
    }
}
Example #16
0
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        if (EnfeebleResetTimer && EnfeebleResetTimer <= diff) // Let's not forget to reset that
        {
            EnfeebleResetHealth();
            EnfeebleResetTimer = 0;
        } else EnfeebleResetTimer -= diff;

        if (me->hasUnitState(UNIT_STAT_STUNNED))      // While shifting to phase 2 malchezaar stuns himself
            return;

        if (me->GetUInt64Value(UNIT_FIELD_TARGET) != me->getVictim()->GetGUID())
            me->SetUInt64Value(UNIT_FIELD_TARGET, me->getVictim()->GetGUID());

        if (phase == 1)
        {
            if ((me->GetHealth()*100) / me->GetMaxHealth() < 60)
            {
                me->InterruptNonMeleeSpells(false);

                phase = 2;

                //animation
                DoCast(me, SPELL_EQUIP_AXES);

                //text
                DoScriptText(SAY_AXE_TOSS1, me);

                //passive thrash aura
                DoCast(me, SPELL_THRASH_AURA, true);

                //models
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO);

                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY+1, AXE_EQUIP_MODEL);
                me->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO+2, AXE_EQUIP_INFO);

                //damage
                const CreatureTemplate *cinfo = me->GetCreatureTemplate();
                me->SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, 2*cinfo->mindmg);
                me->SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, 2*cinfo->maxdmg);
                me->UpdateDamagePhysical(BASE_ATTACK);

                me->SetBaseWeaponDamage(OFF_ATTACK, MINDAMAGE, cinfo->mindmg);
                me->SetBaseWeaponDamage(OFF_ATTACK, MAXDAMAGE, cinfo->maxdmg);
                //Sigh, updating only works on main attack, do it manually ....
                me->SetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, cinfo->mindmg);
                me->SetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, cinfo->maxdmg);

                me->SetAttackTime(OFF_ATTACK, (me->GetAttackTime(BASE_ATTACK)*150)/100);
            }
        }
        else if (phase == 2)
        {
            if ((me->GetHealth()*100) / me->GetMaxHealth() < 30)
            {
                InfernalTimer = 15000;

                phase = 3;

                ClearWeapons();

                //remove thrash
                me->RemoveAurasDueToSpell(SPELL_THRASH_AURA);

                DoScriptText(SAY_AXE_TOSS2, me);

                Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                for (uint8 i = 0; i < 2; ++i)
                {
                    Creature *axe = me->SummonCreature(MALCHEZARS_AXE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
                    if (axe)
                    {
                        axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, AXE_EQUIP_MODEL);
                        axe->SetUInt32Value(UNIT_VIRTUAL_ITEM_INFO, AXE_EQUIP_INFO);

                        axe->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        axe->setFaction(me->getFaction());
                        axes[i] = axe->GetGUID();
                        if (pTarget)
                        {
                            axe->AI()->AttackStart(pTarget);
                            //axe->getThreatManager().tauntApply(pTarget); //Taunt Apply and fade out does not work properly
                                                            // So we'll use a hack to add a lot of threat to our target
                            axe->AddThreat(pTarget, 10000000.0f);
                        }
                    }
                }

                if (ShadowNovaTimer > 35000)
                    ShadowNovaTimer = EnfeebleTimer + 5000;

                return;
            }

            if (SunderArmorTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_SUNDER_ARMOR);
                SunderArmorTimer = urand(10000, 18000);
            } else SunderArmorTimer -= diff;

            if (Cleave_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_CLEAVE);
                Cleave_Timer = urand(6000, 12000);
            } else Cleave_Timer -= diff;
        }
        else
        {
            if (AxesTargetSwitchTimer <= diff)
            {
                AxesTargetSwitchTimer = urand(7500, 20000);

                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                {
                    for (uint8 i = 0; i < 2; ++i)
                    {
                        if (Unit *axe = Unit::GetUnit(*me, axes[i]))
                        {
                            if (axe->getVictim())
                                DoModifyThreatPercent(axe->getVictim(), -100);
                            if (pTarget)
                                axe->AddThreat(pTarget, 1000000.0f);
                            //axe->getThreatManager().tauntFadeOut(axe->getVictim());
                            //axe->getThreatManager().tauntApply(pTarget);
                        }
                    }
                }
            } else AxesTargetSwitchTimer -= diff;

            if (AmplifyDamageTimer <= diff)
            {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                    DoCast(pTarget, SPELL_AMPLIFY_DAMAGE);
                AmplifyDamageTimer = urand(20000, 30000);
            } else AmplifyDamageTimer -= diff;
        }

        //Time for global and double timers
        if (InfernalTimer <= diff)
        {
            SummonInfernal(diff);
            InfernalTimer = phase == 3 ? 14500 : 44500;    // 15 secs in phase 3, 45 otherwise
        } else InfernalTimer -= diff;

        if (ShadowNovaTimer <= diff)
        {
            DoCast(me->getVictim(), SPELL_SHADOWNOVA);
            ShadowNovaTimer = phase == 3 ? 31000 : uint32(-1);
        } else ShadowNovaTimer -= diff;

        if (phase != 2)
        {
            if (SWPainTimer <= diff)
            {
                Unit *pTarget = NULL;
                if (phase == 1)
                    pTarget = me->getVictim();        // the tank
                else                                          // anyone but the tank
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);

                if (pTarget)
                    DoCast(pTarget, SPELL_SW_PAIN);

                SWPainTimer = 20000;
            } else SWPainTimer -= diff;
        }

        if (phase != 3)
        {
            if (EnfeebleTimer <= diff)
            {
                EnfeebleHealthEffect();
                EnfeebleTimer = 30000;
                ShadowNovaTimer = 5000;
                EnfeebleResetTimer = 9000;
            } else EnfeebleTimer -= diff;
        }

        if (phase == 2)
            DoMeleeAttacksIfReady();
        else
            DoMeleeAttackIfReady();
    }
bool GossipHelloAction::Execute(Event event)
{
    ObjectGuid guid;

    WorldPacket &p = event.getPacket();
    if (p.empty())
    {
        Player* master = GetMaster();
        if (master && master->GetSelectedUnit())
            guid = master->GetSelectedUnit()->GetGUID();
    }
    else
    {
        p.rpos(0);
        p >> guid;
    }

    if (!guid)
        return false;

    Creature *pCreature = bot->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
    if (!pCreature)
    {
        sLog->outMessage("playerbot", LOG_LEVEL_DEBUG, "[PlayerbotMgr]: HandleMasterIncomingPacket - Received  CMSG_GOSSIP_HELLO %d not found or you can't interact with him.", guid.GetRawValue());
        return false;
    }

    GossipMenuItemsMapBounds pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBounds(pCreature->GetCreatureTemplate()->GossipMenuId);
    if (pMenuItemBounds.first == pMenuItemBounds.second)
        return false;

    WorldPacket p1;
    p1 << guid;
    bot->GetSession()->HandleGossipHelloOpcode(p1);
    bot->SetFacingToObject(pCreature);

    ostringstream out; out << "--- " << pCreature->GetName() << " ---";
    ai->TellMasterNoFacing(out.str());

    GossipMenu& menu = bot->PlayerTalkClass->GetGossipMenu();
    int i = 0, loops = 0;
    set<uint32> alreadyTalked;
    while (i < menu.GetMenuItemCount() && loops++ < 100)
    {
        GossipMenuItem const* item = menu.GetItem(i);
        ai->TellMasterNoFacing(item->Message);

        if (item->OptionType < 1000 && item->OptionType != GOSSIP_OPTION_GOSSIP)
        {
            i++;
            continue;
        }

        WorldPacket p1;
        std::string code;
        p1 << guid << menu.GetMenuId() << i << code;
        bot->GetSession()->HandleGossipSelectOptionOpcode(p1);

        i = 0;
    }

    bot->TalkedToCreature(pCreature->GetEntry(), pCreature->GetGUID());
    return true;
}
Example #18
0
void WorldSession::SendListInventory(ObjectGuid vendorGuid)
{
    Creature* vendor = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR);
    if (!vendor)
    {
        TC_LOG_DEBUG("network", "WORLD: SendListInventory - %s not found or you can not interact with him.", vendorGuid.ToString().c_str());
        _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, ObjectGuid::Empty);
        return;
    }

    // remove fake death
    if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

    // Stop the npc if moving
    if (vendor->HasUnitState(UNIT_STATE_MOVING))
        vendor->StopMoving();

    VendorItemData const* vendorItems = vendor->GetVendorItems();
    uint32 rawItemCount = vendorItems ? vendorItems->GetItemCount() : 0;

    WorldPackets::NPC::VendorInventory packet;
    packet.Vendor = vendor->GetGUID();

    packet.Items.resize(rawItemCount);

    const float discountMod = _player->GetReputationPriceDiscount(vendor);
    uint8 count = 0;
    for (uint32 slot = 0; slot < rawItemCount; ++slot)
    {
        VendorItem const* vendorItem = vendorItems->GetItem(slot);
        if (!vendorItem)
            continue;

        WorldPackets::NPC::VendorItem& item = packet.Items[count];

        if (vendorItem->Type == ITEM_VENDOR_TYPE_ITEM)
        {
            ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(vendorItem->item);
            if (!itemTemplate)
                continue;

            int32 leftInStock = !vendorItem->maxcount ? -1 : vendor->GetVendorItemCurrentCount(vendorItem);
            if (!_player->IsGameMaster()) // ignore conditions if GM on
            {
                // Respect allowed class
                if (!(itemTemplate->GetAllowableClass() & _player->getClassMask()) && itemTemplate->GetBonding() == BIND_ON_ACQUIRE)
                    continue;

                // Only display items in vendor lists for the team the player is on
                if ((itemTemplate->GetFlags2() & ITEM_FLAG2_FACTION_HORDE && _player->GetTeam() == ALLIANCE) ||
                    (itemTemplate->GetFlags2() & ITEM_FLAG2_FACTION_ALLIANCE && _player->GetTeam() == HORDE))
                    continue;

                // Items sold out are not displayed in list
                if (leftInStock == 0)
                    continue;
            }

            if (!sConditionMgr->IsObjectMeetingVendorItemConditions(vendor->GetEntry(), vendorItem->item, _player, vendor))
            {
                TC_LOG_DEBUG("condition", "SendListInventory: conditions not met for creature entry %u item %u", vendor->GetEntry(), vendorItem->item);
                continue;
            }

            int32 price = vendorItem->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->GetBuyPrice() * discountMod)) : 0;

            if (int32 priceMod = _player->GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES))
                price -= CalculatePct(price, priceMod);

            item.MuID = slot + 1; // client expects counting to start at 1
            item.Durability = itemTemplate->MaxDurability;
            item.ExtendedCostID = vendorItem->ExtendedCost;
            item.Type = vendorItem->Type;
            item.Quantity = leftInStock;
            item.StackCount = itemTemplate->GetBuyCount();
            item.Price = price;

            item.Item.ItemID = vendorItem->item;
        }
        else if (vendorItem->Type == ITEM_VENDOR_TYPE_CURRENCY)
        {
            CurrencyTypesEntry const* currencyTemplate = sCurrencyTypesStore.LookupEntry(vendorItem->item);
            if (!currencyTemplate)
                continue;

            if (!vendorItem->ExtendedCost)
                continue; // there's no price defined for currencies, only extendedcost is used

            item.MuID = slot + 1; // client expects counting to start at 1
            item.ExtendedCostID = vendorItem->ExtendedCost;
            item.Item.ItemID = vendorItem->item;
            item.Type = vendorItem->Type;
            item.StackCount = vendorItem->maxcount;
        }
        else
            continue;

        if (++count >= MAX_VENDOR_ITEMS)
            break;
    }

    // Resize vector to real size (some items can be skipped due to checks)
    packet.Items.resize(count);

    SendPacket(packet.Write());
}
void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_LOOT_MONEY");

    Player* player = GetPlayer();
    uint64 guid = player->GetLootGUID();
    if (!guid)
        return;

    Loot* masterLoot = NULL;
    std::list<Loot*> linkedLoots;
    bool shareMoney = true;

    switch (GUID_HIPART(guid))
    {
        case HIGHGUID_GAMEOBJECT:
        {
            GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid);

            // do not check distance for GO if player is the owner of it (ex. fishing bobber)
            if (go && ((go->GetOwnerGUID() == player->GetGUID() || go->IsWithinDistInMap(player, INTERACTION_DISTANCE))))
                masterLoot = &go->loot;

            break;
        }
        case HIGHGUID_CORPSE:                               // remove insignia ONLY in BG
        {
            Corpse* bones = ObjectAccessor::GetCorpse(*player, guid);

            if (bones && bones->IsWithinDistInMap(player, INTERACTION_DISTANCE))
            {
                masterLoot = &bones->loot;
                shareMoney = false;
            }

            break;
        }
        case HIGHGUID_ITEM:
        {
            if (Item* item = player->GetItemByGuid(guid))
            {
                masterLoot = &item->loot;
                shareMoney = false;
            }
            break;
        }
        case HIGHGUID_UNIT:
        case HIGHGUID_VEHICLE:
        {
            Creature* creature = player->GetMap()->GetCreature(guid);
            bool lootAllowed = creature && creature->isAlive() == (player->getClass() == CLASS_ROGUE && creature->lootForPickPocketed);
            if (lootAllowed && creature->IsWithinDistInMap(player, INTERACTION_DISTANCE))
            {
                masterLoot = &creature->loot;
                if (creature->isAlive())
                    shareMoney = false;
                // Check creature around for radius loot
                else
                {
                    std::list<Creature*> linkedLootCreatures;
                    CellCoord p(WoWSource::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
                    Cell cell(p);
                    cell.SetNoCreate();

                    WoWSource::AllDeadCreaturesInRange check(player, 25.0f, creature->GetGUID());
                    WoWSource::CreatureListSearcher<WoWSource::AllDeadCreaturesInRange> searcher(player, linkedLootCreatures, check);
                    TypeContainerVisitor<WoWSource::CreatureListSearcher<WoWSource::AllDeadCreaturesInRange>, GridTypeMapContainer> cSearcher(searcher);
                    cell.Visit(p, cSearcher, *(player->GetMap()), *player,  25.0f);

                    for (auto itr : linkedLootCreatures)
                    {
                        Player* recipient = itr->GetLootRecipient();
                        if (!recipient)
                            continue;

                        if (itr->loot.HasLooter(player->GetGUID()))
                            linkedLoots.push_back(&itr->loot);
                    }
                }
            }
            break;
        }
        default:
            return;                                         // unlootable type
    }

    if (masterLoot)
        linkedLoots.push_back(masterLoot);

    for (auto loot : linkedLoots)
    {
        if (shareMoney && player->GetGroup())      //item, pickpocket and players can be looted only single player
        {
            Group* group = player->GetGroup();

            std::vector<Player*> playersNear;
            for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
            {
                Player* member = itr->getSource();
                if (!member)
                    continue;

                if (player->IsWithinDistInMap(member, sWorld->getFloatConfig(CONFIG_GROUP_XP_DISTANCE), false))
                    playersNear.push_back(member);
            }
             /*@todo: check me for 5.0.5*/
            uint32 goldPerPlayer = uint32((loot->gold) / (playersNear.size()));
            
            loot->NotifyMoneyRemoved(goldPerPlayer);
            for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
            {
                (*i)->ModifyMoney(goldPerPlayer);
                (*i)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, goldPerPlayer);

                if ((*i)->HasAuraType(SPELL_AURA_DEPOSIT_BONUS_MONEY_IN_GUILD_BANK_ON_LOOT))
                {
                    if (Guild* guild = sGuildMgr->GetGuildById((*i)->GetGuildId()))
                    {
                        uint64 guildGold = (uint64)CalculatePct(goldPerPlayer, (*i)->GetTotalAuraModifier(SPELL_AURA_DEPOSIT_BONUS_MONEY_IN_GUILD_BANK_ON_LOOT));
                        if (guildGold > MAX_MONEY_AMOUNT)
                            guildGold = MAX_MONEY_AMOUNT;

                        uint64 amount = guild->GetBankMoney();
                        uint64 after = amount + guildGold;
                        if (after > MAX_MONEY_AMOUNT)
                            guildGold = uint64(MAX_MONEY_AMOUNT) - amount; // do not cast MAX_MONEY_AMOUNT to uint since MAX_MONEY_AMOUNT is 9.999 billions, that more that uint32 max

                        if (guildGold > 0)
                            guild->DepositMoney(guildGold);
                    }
                }

                WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1);
                data << uint32(goldPerPlayer);
                data.WriteBit(playersNear.size() <= 1); // Controls the text displayed in chat. 0 is "Your share is..." and 1 is "You loot..."
                data.FlushBits();
                (*i)->GetSession()->SendPacket(&data);
            }
        }
        else
        {
            player->ModifyMoney(loot->gold);
            player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, loot->gold);

            if (player->HasAuraType(SPELL_AURA_DEPOSIT_BONUS_MONEY_IN_GUILD_BANK_ON_LOOT))
            {
                if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()))
                {
                    uint64 guildGold = (uint64)CalculatePct(loot->gold, player->GetTotalAuraModifier(SPELL_AURA_DEPOSIT_BONUS_MONEY_IN_GUILD_BANK_ON_LOOT));
                    if (guildGold > MAX_MONEY_AMOUNT)
                        guildGold = MAX_MONEY_AMOUNT;

                    uint64 amount = guild->GetBankMoney();
                    uint64 after = amount + guildGold;
                    if (after > MAX_MONEY_AMOUNT)
                        guildGold = uint64(MAX_MONEY_AMOUNT) - amount; // do not cast MAX_MONEY_AMOUNT to uint since MAX_MONEY_AMOUNT is 9.999 billions, that more that uint32 max

                    if (guildGold > 0)
                        guild->DepositMoney(guildGold);
                }
            }

            loot->NotifyMoneyRemoved(loot->gold);
            WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1);
            data << uint32(loot->gold);
            data.WriteBit(1);   // "You loot..."
            data.FlushBits();
            SendPacket(&data);
        }

        loot->gold = 0;
    }
}
        void UpdateAI(const uint32 diff)
        {
            //Return since we have no target
            if(me->HasAura(AURA_BANISH) || !UpdateVictim())
            {
                if(BanishTimer <= diff)
                {
                    CheckBanish();//no need to check every update tick
                    BanishTimer = 1000;
                } else BanishTimer -= diff;
                return;
            }
            if(me->HasAura(SPELL_WHIRLWIND))
            {
                if(Whirlwind_Timer <= diff)
                {
                    Unit* newTarget = SelectTarget(SELECT_TARGET_RANDOM, 0);
                    if(newTarget)
                    {
                        DoResetThreat();
                        me->GetMotionMaster()->Clear();
                        me->GetMotionMaster()->MovePoint(0, newTarget->GetPositionX(), newTarget->GetPositionY(), newTarget->GetPositionZ());
                    }
                    Whirlwind_Timer = 2000;
                } else Whirlwind_Timer -= diff;
            }

            // reseting after changing forms and after ending whirlwind
            if(NeedThreatReset && !me->HasAura(SPELL_WHIRLWIND))
            {
                // when changing forms seting timers (or when ending whirlwind - to avoid adding new variable i use Whirlwind_Timer to countdown 2s while whirlwinding)
                if(DemonForm)
                    InnerDemons_Timer = 30000;
                else
                    Whirlwind_Timer =  15000;

                NeedThreatReset = false;
                DoResetThreat();
                me->GetMotionMaster()->Clear();
                me->GetMotionMaster()->MoveChase(me->getVictim());
            }

            //Enrage_Timer (10 min)
            if(Berserk_Timer < diff && !EnrageUsed)
            {
                me->InterruptNonMeleeSpells(false);
                DoCast(me, SPELL_BERSERK);
                EnrageUsed = true;
            } else Berserk_Timer -= diff;

            if(!DemonForm)
            {
                //Whirldind Timer
                if(!me->HasAura(SPELL_WHIRLWIND))
                {
                    if(Whirlwind_Timer <= diff)
                    {
                        DoCast(me, SPELL_WHIRLWIND);
                        // while whirlwinding this variable is used to countdown target's change
                        Whirlwind_Timer = 2000;
                        NeedThreatReset = true;
                    } else Whirlwind_Timer -= diff;
                }
                //Switch_Timer

                if(!IsFinalForm)
                {
                    if(SwitchToDemon_Timer <= diff)
                    {
                        //switch to demon form
                        me->RemoveAurasDueToSpell(SPELL_WHIRLWIND, 0);
                        me->SetDisplayId(MODEL_DEMON);
                        DoScriptText(SAY_SWITCH_TO_DEMON, me);
                        me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID , 0);
                        me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID+1, 0);
                        DemonForm = true;
                        NeedThreatReset = true;
                        SwitchToDemon_Timer = 45000;
                    } else SwitchToDemon_Timer -= diff;
                }
                DoMeleeAttackIfReady();
            }
            else
            {
                //ChaosBlast_Timer
                if(!me->getVictim())
                    return;
                if(me->IsWithinDist(me->getVictim(), 30))
                    me->StopMoving();
                if(ChaosBlast_Timer <= diff)
                {
                    // will cast only when in range of spell
                    if(me->IsWithinDist(me->getVictim(), 30))
                    {
                        //DoCast(me->getVictim(), SPELL_CHAOS_BLAST, true);
                        int damage = 100;
                        me->CastCustomSpell(me->getVictim(), SPELL_CHAOS_BLAST, &damage, NULL, NULL, false, NULL, NULL, me->GetGUID());
                    }
                    ChaosBlast_Timer = 3000;
                } else ChaosBlast_Timer -= diff;
                //Summon Inner Demon
                if(InnerDemons_Timer <= diff)
                {
                    std::list<HostileReference *>& ThreatList = me->getThreatManager().getThreatList();
                    std::vector<Unit* > TargetList;
                    for(std::list<HostileReference *>::const_iterator itr = ThreatList.begin(); itr != ThreatList.end(); ++itr)
                    {
                        Unit* tempTarget = Unit::GetUnit(*me, (*itr)->getUnitGuid());
                        if(tempTarget && tempTarget->GetTypeId() == TYPEID_PLAYER && tempTarget->GetGUID() != me->getVictim()->GetGUID() && TargetList.size()<5)
                            TargetList.push_back(tempTarget);
                    }

                    for(std::vector<Unit* >::const_iterator itr = TargetList.begin(); itr != TargetList.end(); ++itr)
                    {
                        if((*itr) && (*itr)->isAlive())
                        {
                            Creature* demon = me->SummonCreature(INNER_DEMON_ID, (*itr)->GetPositionX()+10, (*itr)->GetPositionY()+10, (*itr)->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                            if(demon)
                            {
                                demon->AI()->AttackStart((*itr));
                                CAST_AI(mob_inner_demon::mob_inner_demonAI, demon->AI())->victimGUID = (*itr)->GetGUID();

                                (*itr)->AddAura(SPELL_INSIDIOUS_WHISPER, *itr);

                                if(InnerDemon_Count > 4)
                                    InnerDemon_Count = 0;

                                //Safe storing of creatures
                                InnderDemon[InnerDemon_Count] = demon->GetGUID();

                                //Update demon count
                                ++InnerDemon_Count;
                            }
                        }
                    }
                    DoScriptText(SAY_INNER_DEMONS, me);

                    InnerDemons_Timer = 999999;
                } else InnerDemons_Timer -= diff;

                //Switch_Timer
                if(SwitchToHuman_Timer <= diff)
                {
                    //switch to nightelf form
                    me->SetDisplayId(MODEL_NIGHTELF);
                    me->LoadEquipment(me->GetEquipmentId());

                    CastConsumingMadness();
                    DespawnDemon();

                    DemonForm = false;
                    NeedThreatReset = true;

                    SwitchToHuman_Timer = 60000;
                } else SwitchToHuman_Timer -= diff;
            }

            if(!IsFinalForm && HealthBelowPct(15))
            {
                //at this point he divides himself in two parts
                CastConsumingMadness();
                DespawnDemon();
                Creature* Copy = NULL;
                Copy = DoSpawnCreature(DEMON_FORM, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 6000);
                if(Copy)
                 {
                     Demon = Copy->GetGUID();
                    if(me->getVictim())
                        Copy->AI()->AttackStart(me->getVictim());
                }
                //set nightelf final form
                IsFinalForm = true;
                DemonForm = false;

                DoScriptText(SAY_FINAL_FORM, me);
                me->SetDisplayId(MODEL_NIGHTELF);
                me->LoadEquipment(me->GetEquipmentId());
            }
        }
        void UpdateAI(const uint32 diff)
        {
            if (!EventBegun)
                return;

            if (HealthBelowPct(15) && !HasYelledOnce)
            {
                DoScriptText(SAY_LOW_HEALTH, me);
                HasYelledOnce = true;
            }

            if (ShadeGUID && !StartCombat)
            {
                Creature* Shade = (Unit::GetCreature((*me), ShadeGUID));
                if (Shade && Shade->isAlive())
                {
                    if (CAST_AI(boss_shade_of_akama::boss_shade_of_akamaAI, Shade->AI())->IsBanished)
                    {
                        if (CastSoulRetrieveTimer <= diff)
                        {
                            DoCast(Shade, SPELL_AKAMA_SOUL_CHANNEL);
                            CastSoulRetrieveTimer = 500;
                        } else CastSoulRetrieveTimer -= diff;
                    }
                    else
                    {
                        me->InterruptNonMeleeSpells(false);
                        StartCombat = true;
                    }
                }
            }

            if (ShadeHasDied && (WayPointId == 1))
            {
                if (pInstance)
                    pInstance->SetData(DATA_SHADEOFAKAMAEVENT, DONE);
                me->GetMotionMaster()->MovePoint(WayPointId, AkamaWP[1].x, AkamaWP[1].y, AkamaWP[1].z);
                ++WayPointId;
            }

            if (!ShadeHasDied && StartCombat)
            {
                if (CheckTimer <= diff)
                {
                    if (ShadeGUID)
                    {
                        Creature* Shade = Unit::GetCreature((*me), ShadeGUID);
                        if (Shade && !Shade->isAlive())
                        {
                            ShadeHasDied = true;
                            WayPointId = 0;
                            me->AddUnitMovementFlag(MOVEMENTFLAG_WALKING);
                            me->GetMotionMaster()->MovePoint(WayPointId, AkamaWP[0].x, AkamaWP[0].y, AkamaWP[0].z);
                        }
                        if (Shade && Shade->isAlive())
                        {
                            if (Shade->getThreatManager().getThreatList().size() < 2)
                                Shade->AI()->EnterEvadeMode();
                        }
                    }
                    CheckTimer = 5000;
                } else CheckTimer -= diff;
            }

            if (SummonBrokenTimer && BrokenSummonIndex < 4)
            {
                if (SummonBrokenTimer <= diff)
                {
                    for (uint8 i = 0; i < 4; ++i)
                    {
                        float x = BrokenCoords[BrokenSummonIndex].x + (i*5);
                        float y = BrokenCoords[BrokenSummonIndex].y + (1*5);
                        float z = BrokenCoords[BrokenSummonIndex].z;
                        float o = BrokenCoords[BrokenSummonIndex].o;
                        Creature* Broken = me->SummonCreature(CREATURE_BROKEN, x, y, z, o, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 360000);
                        if (Broken)
                        {
                            float wx = BrokenWP[BrokenSummonIndex].x + (i*5);
                            float wy = BrokenWP[BrokenSummonIndex].y + (i*5);
                            float wz = BrokenWP[BrokenSummonIndex].z;
                            Broken->GetMotionMaster()->MovePoint(0, wx, wy, wz);
                            Broken->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            BrokenList.push_back(Broken->GetGUID());
                        }
                    }
                    ++BrokenSummonIndex;
                    SummonBrokenTimer = 1000;
                } else SummonBrokenTimer -= diff;
            }

            if (SoulRetrieveTimer)
            {
                if (SoulRetrieveTimer <= diff)
                {
                    switch (EndingTalkCount)
                    {
                    case 0:
                        me->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
                        ++EndingTalkCount;
                        SoulRetrieveTimer = 2000;
                        SummonBrokenTimer = 1;
                        break;
                    case 1:
                        DoScriptText(SAY_FREE, me);
                        ++EndingTalkCount;
                        SoulRetrieveTimer = 25000;
                        break;
                    case 2:
                        if (!BrokenList.empty())
                        {
                            bool Yelled = false;
                            for (std::list<uint64>::const_iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
                                if (Creature* pUnit = Unit::GetCreature(*me, *itr))
                                {
                                    if (!Yelled)
                                    {
                                        DoScriptText(SAY_BROKEN_FREE_01, pUnit);
                                        Yelled = true;
                                    }
                                    pUnit->HandleEmoteCommand(EMOTE_ONESHOT_KNEEL);
                                }
                        }
                        ++EndingTalkCount;
                        SoulRetrieveTimer = 1500;
                        break;
                    case 3:
                        if (!BrokenList.empty())
                        {
                            for (std::list<uint64>::const_iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
                                if (Creature* pUnit = Unit::GetCreature(*me, *itr))
                                    // This is the incorrect spell, but can't seem to find the right one.
                                    pUnit->CastSpell(pUnit, 39656, true);
                        }
                        ++EndingTalkCount;
                        SoulRetrieveTimer = 5000;
                        break;
                    case 4:
                        if (!BrokenList.empty())
                        {
                            for (std::list<uint64>::const_iterator itr = BrokenList.begin(); itr != BrokenList.end(); ++itr)
                                if (Creature* pUnit = Unit::GetCreature((*me), *itr))
                                    pUnit->MonsterYell(SAY_BROKEN_FREE_02, LANG_UNIVERSAL, 0);
                        }
                        SoulRetrieveTimer = 0;
                        break;
                    }
                } else SoulRetrieveTimer -= diff;
            }

            if (!UpdateVictim())
                return;

            if (DestructivePoisonTimer <= diff)
            {
                Creature* Shade = Unit::GetCreature((*me), ShadeGUID);
                if (Shade && Shade->isAlive())
                    DoCast(Shade, SPELL_DESTRUCTIVE_POISON);
                DestructivePoisonTimer = 15000;
            } else DestructivePoisonTimer -= diff;

            if (LightningBoltTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_LIGHTNING_BOLT);
                LightningBoltTimer = 10000;
            } else LightningBoltTimer -= diff;

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

                if (target)
                {
                    AttackStart(target);
                }
            }

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

            //someone evaded!
            if (instance && !instance->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* target = SelectTarget(SELECT_TARGET_RANDOM, 0);
                if (Pet && target)
                {
                    Pet->AI()->AttackStart(target);
                    SummonedPet = Pet->GetGUID();
                }
            } else Pet_Timer -= diff;

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

                events.Update(diff);

                while (uint32 eventId = events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_STATIC_DISRUPTION:
                            {
                            Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
                            if (!target)
                                target = me->GetVictim();
                            if (target)
                            {
                                TargetGUID = target->GetGUID();
                                DoCast(target, SPELL_STATIC_DISRUPTION, false);
                                me->SetInFront(me->GetVictim());
                            }
                            /*if (float dist = me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f) dist = 5.0f;
                            SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/
                            events.ScheduleEvent(EVENT_STATIC_DISRUPTION, urand(10000, 18000));
                            break;
                            }
                        case EVENT_GUST_OF_WIND:
                            {
                                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
                                if (!target)
                                    target = me->GetVictim();
                                if (target)
                                    DoCast(target, SPELL_GUST_OF_WIND);
                                events.ScheduleEvent(EVENT_GUST_OF_WIND, urand(20000, 30000));
                                break;
                            }
                        case EVENT_CALL_LIGHTNING:
                            DoCastVictim(SPELL_CALL_LIGHTNING);
                            events.ScheduleEvent(EVENT_CALL_LIGHTNING, urand(12000, 17000)); // totaly random timer. can't find any info on this
                            break;
                        case EVENT_ELECTRICAL_STORM:
                            {
                                Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true);
                                if (!target)
                                {
                                    EnterEvadeMode();
                                    return;
                                }
                                target->CastSpell(target, 44007, true); // cloud visual
                                DoCast(target, SPELL_ELECTRICAL_STORM, false); // storm cyclon + visual
                                float x, y, z;
                                target->GetPosition(x, y, z);
                                /// @todo: fix it in correct way, that causes player to can fly until logout
                                /*
                                if (target)
                                {
                                    target->SetDisableGravity(true);
                                    target->MonsterMoveWithSpeed(x, y, me->GetPositionZ()+15, 0);
                                }
                                */

                                Unit* Cloud = me->SummonTrigger(x, y, me->GetPositionZ()+16, 0, 15000);
                                if (Cloud)
                                    {
                                        CloudGUID = Cloud->GetGUID();
                                        Cloud->SetDisableGravity(true);
                                        Cloud->StopMoving();
                                        Cloud->SetObjectScale(1.0f);
                                        Cloud->setFaction(35);
                                        Cloud->SetMaxHealth(9999999);
                                        Cloud->SetHealth(9999999);
                                        Cloud->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                    }
                                StormCount = 1;
                                events.ScheduleEvent(EVENT_ELECTRICAL_STORM, 60000); // 60 seconds(bosskillers)
                                events.ScheduleEvent(EVENT_RAIN, urand(47000, 52000));
                                break;
                            }
                        case EVENT_RAIN:
                            if (!isRaining)
                            {
                                SetWeather(WEATHER_STATE_HEAVY_RAIN, 0.9999f);
                                isRaining = true;
                            }
                            else
                                events.ScheduleEvent(EVENT_RAIN, 1000);
                            break;
                        case EVENT_STORM_SEQUENCE:
                            {
                                Unit* target = ObjectAccessor::GetUnit(*me, CloudGUID);
                                if (!target || !target->IsAlive())
                                {
                                    EnterEvadeMode();
                                    return;
                                }
                                else if (Unit* Cyclone = ObjectAccessor::GetUnit(*me, CycloneGUID))
                                    Cyclone->CastSpell(target, SPELL_SAND_STORM, true); // keep casting or...
                                HandleStormSequence(target);
                                break;
                            }
                        case EVENT_SUMMON_EAGLES:
                            Talk(SAY_SUMMON);

                            float x, y, z;
                            me->GetPosition(x, y, z);

                            for (uint8 i = 0; i < 8; ++i)
                            {
                                Unit* bird = ObjectAccessor::GetUnit(*me, BirdGUIDs[i]);
                                if (!bird) //they despawned on die
                                {
                                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                                    {
                                        x = target->GetPositionX() + irand(-10, 10);
                                        y = target->GetPositionY() + irand(-10, 10);
                                        z = target->GetPositionZ() + urand(16, 20);
                                        if (z > 95)
                                            z = 95.0f - urand(0, 5);
                                    }
                                    Creature* creature = me->SummonCreature(NPC_SOARING_EAGLE, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0);
                                    if (creature)
                                    {
                                        creature->AddThreat(me->GetVictim(), 1.0f);
                                        creature->AI()->AttackStart(me->GetVictim());
                                        BirdGUIDs[i] = creature->GetGUID();
                                    }
                                }
                            }
                            break;
                        case EVENT_ENRAGE:
                             Talk(SAY_ENRAGE);
                             DoCast(me, SPELL_BERSERK, true);
                            events.ScheduleEvent(EVENT_ENRAGE, 600000);
                            break;
                        default:
                            break;
                    }
                }

                DoMeleeAttackIfReady();
            }
        void UpdateAI(uint32 diff) override
        {
            if (!UpdateVictim())
                return;

            if (EnfeebleResetTimer && EnfeebleResetTimer <= diff) // Let's not forget to reset that
            {
                EnfeebleResetHealth();
                EnfeebleResetTimer = 0;
            } else EnfeebleResetTimer -= diff;

            if (me->HasUnitState(UNIT_STATE_STUNNED))      // While shifting to phase 2 malchezaar stuns himself
                return;

            if (me->GetVictim() && me->GetTarget() != me->EnsureVictim()->GetGUID())
                me->SetTarget(me->EnsureVictim()->GetGUID());

            if (phase == 1)
            {
                if (HealthBelowPct(60))
                {
                    me->InterruptNonMeleeSpells(false);

                    phase = 2;

                    //animation
                    DoCast(me, SPELL_EQUIP_AXES);

                    //text
                    Talk(SAY_AXE_TOSS1);

                    //passive thrash aura
                    DoCast(me, SPELL_THRASH_AURA, true);

                    //models
                    SetEquipmentSlots(false, EQUIP_ID_AXE, EQUIP_ID_AXE, EQUIP_NO_CHANGE);

                    me->SetAttackTime(OFF_ATTACK, (me->GetAttackTime(BASE_ATTACK)*150)/100);
                    me->SetCanDualWield(true);
                }
            }
            else if (phase == 2)
            {
                if (HealthBelowPct(30))
                {
                    InfernalTimer = 15000;

                    phase = 3;

                    ClearWeapons();

                    //remove thrash
                    me->RemoveAurasDueToSpell(SPELL_THRASH_AURA);

                    Talk(SAY_AXE_TOSS2);

                    Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                    for (uint8 i = 0; i < 2; ++i)
                    {
                        Creature* axe = me->SummonCreature(MALCHEZARS_AXE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 1000);
                        if (axe)
                        {
                            axe->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            axe->setFaction(me->getFaction());
                            axes[i] = axe->GetGUID();
                            if (target)
                            {
                                axe->AI()->AttackStart(target);
                                //axe->getThreatManager().tauntApply(target); //Taunt Apply and fade out does not work properly
                                                                // So we'll use a hack to add a lot of threat to our target
                                axe->AddThreat(target, 10000000.0f);
                            }
                        }
                    }

                    if (ShadowNovaTimer > 35000)
                        ShadowNovaTimer = EnfeebleTimer + 5000;

                    return;
                }

                if (SunderArmorTimer <= diff)
                {
                    DoCastVictim(SPELL_SUNDER_ARMOR);
                    SunderArmorTimer = urand(10000, 18000);
                } else SunderArmorTimer -= diff;

                if (Cleave_Timer <= diff)
                {
                    DoCastVictim(SPELL_CLEAVE);
                    Cleave_Timer = urand(6000, 12000);
                } else Cleave_Timer -= diff;
            }
            else
            {
                if (AxesTargetSwitchTimer <= diff)
                {
                    AxesTargetSwitchTimer = urand(7500, 20000);

                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                    {
                        for (uint8 i = 0; i < 2; ++i)
                        {
                            if (Unit* axe = ObjectAccessor::GetUnit(*me, axes[i]))
                            {
                                if (axe->GetVictim())
                                    DoModifyThreatPercent(axe->GetVictim(), -100);
                                if (target)
                                    axe->AddThreat(target, 1000000.0f);
                                //axe->getThreatManager().tauntFadeOut(axe->GetVictim());
                                //axe->getThreatManager().tauntApply(target);
                            }
                        }
                    }
                } else AxesTargetSwitchTimer -= diff;

                if (AmplifyDamageTimer <= diff)
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                        DoCast(target, SPELL_AMPLIFY_DAMAGE);
                    AmplifyDamageTimer = urand(20000, 30000);
                } else AmplifyDamageTimer -= diff;
            }

            //Time for global and double timers
            if (InfernalTimer <= diff)
            {
                SummonInfernal(diff);
                InfernalTimer = phase == 3 ? 14500 : 44500;    // 15 secs in phase 3, 45 otherwise
            } else InfernalTimer -= diff;

            if (ShadowNovaTimer <= diff)
            {
                DoCastVictim(SPELL_SHADOWNOVA);
                ShadowNovaTimer = phase == 3 ? 31000 : uint32(-1);
            } else ShadowNovaTimer -= diff;

            if (phase != 2)
            {
                if (SWPainTimer <= diff)
                {
                    Unit* target = NULL;
                    if (phase == 1)
                        target = me->GetVictim();        // the tank
                    else                                          // anyone but the tank
                        target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);

                    if (target)
                        DoCast(target, SPELL_SW_PAIN);

                    SWPainTimer = 20000;
                } else SWPainTimer -= diff;
            }

            if (phase != 3)
            {
                if (EnfeebleTimer <= diff)
                {
                    EnfeebleHealthEffect();
                    EnfeebleTimer = 30000;
                    ShadowNovaTimer = 5000;
                    EnfeebleResetTimer = 9000;
                } else EnfeebleTimer -= diff;
            }

            if (phase == 2)
                DoMeleeAttacksIfReady();
            else
                DoMeleeAttackIfReady();
        }
Example #25
0
        void DoIntro()
        {
            Creature* Madrigosa = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_MADRIGOSA) : 0);
            if (!Madrigosa)
                return;

            switch (IntroPhase)
            {
            case 0:
                Madrigosa->AI()->Talk(YELL_MADR_ICE_BARRIER);
                IntroPhaseTimer = 7000;
                ++IntroPhase;
                break;
            case 1:
                me->SetInFront(Madrigosa);
                Madrigosa->SetInFront(me);
                Madrigosa->AI()->Talk(YELL_MADR_INTRO, me->GetGUID());
                IntroPhaseTimer = 9000;
                ++IntroPhase;
                break;
            case 2:
                Talk(YELL_INTRO, Madrigosa->GetGUID());
                IntroPhaseTimer = 13000;
                ++IntroPhase;
                break;
            case 3:
                DoCast(me, SPELL_INTRO_FROST_BLAST);
                Madrigosa->SetDisableGravity(true);
                me->AttackStop();
                Madrigosa->AttackStop();
                IntroFrostBoltTimer = 3000;
                IntroPhaseTimer = 28000;
                ++IntroPhase;
                break;
            case 4:
                Talk(YELL_INTRO_BREAK_ICE);
                IntroPhaseTimer = 6000;
                ++IntroPhase;
                break;
            case 5:
                Madrigosa->CastSpell(me, SPELL_INTRO_ENCAPSULATE_CHANELLING, false);
                Madrigosa->AI()->Talk(YELL_MADR_TRAP);
                DoCast(me, SPELL_INTRO_ENCAPSULATE);
                IntroPhaseTimer = 11000;
                ++IntroPhase;
                break;
            case 6:
                Talk(YELL_INTRO_CHARGE);
                IntroPhaseTimer = 5000;
                ++IntroPhase;
                break;
            case 7:
                me->Kill(Madrigosa);
                Madrigosa->AI()->Talk(YELL_MADR_DEATH);
                me->SetFullHealth();
                me->AttackStop();
                IntroPhaseTimer = 4000;
                ++IntroPhase;
                break;
            case 8:
                Talk(YELL_INTRO_KILL_MADRIGOSA);
                me->SetOrientation(0.14f);
                me->StopMoving();
                Madrigosa->setDeathState(CORPSE);
                IntroPhaseTimer = 8000;
                ++IntroPhase;
                break;
            case 9:
                Talk(YELL_INTRO_TAUNT);
                IntroPhaseTimer = 5000;
                ++IntroPhase;
                break;
            case 10:
                EndIntro();
                break;
            }
        }
Example #26
0
void WorldSession::HandleGossipHelloOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GOSSIP_HELLO");

    uint64 guid;
    recvData >> guid;

    //Bot
    if (guid == _player->GetGUID())
    {
        if (!_player->GetBotHelper())
        {
            TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Player (GUID: %u) do not have a helper on gossip hello.", uint32(GUID_LOPART(guid)));
            return;
        }
        _player->GetBotHelper()->OnGossipHello(_player);
        return;
    }
    //end Bot

    Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
    if (!unit)
    {
        TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipHelloOpcode - Unit (GUID: %u) not found or you can not interact with him.", uint32(GUID_LOPART(guid)));
        return;
    }

    // set faction visible if needed
    if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction()))
        _player->GetReputationMgr().SetVisible(factionTemplateEntry);

    GetPlayer()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK);
    // remove fake death
    //if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
    //    GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

    if (unit->IsArmorer() || unit->IsCivilian() || unit->IsQuestGiver() || unit->IsServiceProvider() || unit->IsGuard())
    {
        unit->StopMoving();
    }

    // If spiritguide, no need for gossip menu, just put player into resurrect queue
    if (unit->IsSpiritGuide())
    {
        Battleground* bg = _player->GetBattleground();
        if (bg)
        {
            bg->AddPlayerToResurrectQueue(unit->GetGUID(), _player->GetGUID());
            sBattlegroundMgr->SendAreaSpiritHealerQueryOpcode(_player, bg, unit->GetGUID());
            return;
        }
    }

    if (!sScriptMgr->OnGossipHello(_player, unit))
    {
//        _player->TalkedToCreature(unit->GetEntry(), unit->GetGUID());
        _player->PrepareGossipMenu(unit, unit->GetCreatureTemplate()->GossipMenuId, true);
        _player->SendPreparedGossip(unit);
    }
    unit->AI()->sGossipHello(_player);
}
    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
            return;

        //Only do this if we haven't spawned nef yet
        if (SpawnedAdds < 42)
        {
            //ShadowBoltTimer
            if (ShadowBoltTimer <= diff)
            {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                    DoCast(pTarget, SPELL_SHADOWBOLT);

                ShadowBoltTimer = urand(3000,10000);
            } else ShadowBoltTimer -= diff;

            //FearTimer
            if (FearTimer <= diff)
            {
                if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
                    DoCast(pTarget, SPELL_FEAR);

                FearTimer = 10000 + (rand()%10000);
            } else FearTimer -= diff;

            //Add spawning mechanism
            if (AddSpawnTimer <= diff)
            {
                //Spawn 2 random types of creatures at the 2 locations
                uint32 CreatureID;
                Creature* Spawned = NULL;
                Unit *pTarget = NULL;

                //1 in 3 chance it will be a chromatic
                if (urand(0,2) == 0)
                    CreatureID = CREATURE_CHROMATIC_DRAKANOID;
                else
                    CreatureID = DrakType1;

                ++SpawnedAdds;

                //Spawn Creature and force it to start attacking a random target
                Spawned = me->SummonCreature(CreatureID,ADD_X1,ADD_Y1,ADD_Z1,5.000,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000);
                pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                if (pTarget && Spawned)
                {
                    Spawned->AI()->AttackStart(pTarget);
                    Spawned->setFaction(103);
                }

                //1 in 3 chance it will be a chromatic
                if (urand(0,2) == 0)
                    CreatureID = CREATURE_CHROMATIC_DRAKANOID;
                else
                    CreatureID = DrakType2;

                ++SpawnedAdds;

                Spawned = me->SummonCreature(CreatureID,ADD_X2,ADD_Y2,ADD_Z2,5.000,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,5000);
                pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                if (pTarget && Spawned)
                {
                    Spawned->AI()->AttackStart(pTarget);
                    Spawned->setFaction(103);
                }

                //Begin phase 2 by spawning Nefarian and what not
                if (SpawnedAdds >= 42)
                {
                    //Teleport Victor Nefarius way out of the map
                    //MapManager::Instance().GetMap(me->GetMapId(), me)->CreatureRelocation(me,0,0,-5000,0);

                    //Inturrupt any spell casting
                    me->InterruptNonMeleeSpells(false);

                    //Root self
                    DoCast(me, 33356);

                    //Make super invis
                    DoCast(me, 8149);

                    //Teleport self to a hiding spot (this causes errors in the Trinity log but no real issues)
                    DoTeleportTo(HIDE_X,HIDE_Y,HIDE_Z);
                    me->addUnitState(UNIT_STAT_FLEEING);

                    //Spawn nef and have him attack a random target
                    Creature* Nefarian = me->SummonCreature(CREATURE_NEFARIAN,NEF_X,NEF_Y,NEF_Z,0,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT,120000);
                    pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true);
                    if (pTarget && Nefarian)
                    {
                        Nefarian->AI()->AttackStart(pTarget);
                        Nefarian->setFaction(103);
                        NefarianGUID = Nefarian->GetGUID();
                    }
                    else error_log("TSCR: Blackwing Lair: Unable to spawn nefarian properly.");
                }

                AddSpawnTimer = 4000;
            } else AddSpawnTimer -= diff;
        }
        else if (NefarianGUID)
        {
            if (NefCheckTime <= diff)
            {
                Unit* Nefarian = Unit::GetCreature((*me),NefarianGUID);

                //If nef is dead then we die to so the players get out of combat
                //and cannot repeat the event
                if (!Nefarian || !Nefarian->isAlive())
                {
                    NefarianGUID = 0;
                    me->ForcedDespawn();
                }

                NefCheckTime = 2000;
            } else NefCheckTime -= diff;
        }
    }
Example #28
0
void WaypointMovementGenerator<Creature>::OnArrived(Creature& creature)
{
    if (!i_path || i_path->empty())
        return;
    if (m_isArrivalDone)
        return;

    creature.ClearUnitState(UNIT_STATE_ROAMING_MOVE);
    m_isArrivalDone = true;

    if (i_path->at(i_currentNode)->event_id && urand(0, 99) < i_path->at(i_currentNode)->event_chance)
    {
        sLog->outDebug(LOG_FILTER_MAPSCRIPTS, "Creature movement start script %u at point %u for "UI64FMTD".", i_path->at(i_currentNode)->event_id, i_currentNode, creature.GetGUID());
        creature.GetMap()->ScriptsStart(sWaypointScripts, i_path->at(i_currentNode)->event_id, &creature, NULL);
    }

    // Inform script
    MovementInform(creature);
    creature.UpdateWaypointID(i_currentNode);
    Stop(i_path->at(i_currentNode)->delay);
}
            void UpdateAI(uint32 diff) override
            {
                if (_phase != PHASE_OUTRO)
                    return;

                _events.Update(diff);

                while (uint32 eventId = _events.ExecuteEvent())
                {
                    switch (eventId)
                    {
                        case EVENT_OUTRO_1:
                        {
                            if (Creature* temp = ObjectAccessor::GetCreature(*me, _instanceScript->GetGuidData(DATA_JAINA_SYLVANAS_1)))
                                temp->DespawnOrUnsummon();

                            Creature* jainaOrSylvanas = nullptr;
                            if (_instanceScript->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
                                jainaOrSylvanas = me->SummonCreature(NPC_JAINA_PART1, outroPos[2], TEMPSUMMON_MANUAL_DESPAWN);
                            else
                                jainaOrSylvanas = me->SummonCreature(NPC_SYLVANAS_PART1, outroPos[2], TEMPSUMMON_MANUAL_DESPAWN);

                            if (jainaOrSylvanas)
                            {
                                jainaOrSylvanas->GetMotionMaster()->MovePoint(0, outroPos[3]);
                                _outroNpcGUID = jainaOrSylvanas->GetGUID();
                            }
                            _events.ScheduleEvent(EVENT_OUTRO_2, 6000);
                            break;
                        }
                        case EVENT_OUTRO_2:
                            if (Creature* jainaOrSylvanas = ObjectAccessor::GetCreature(*me, _outroNpcGUID))
                            {
                                jainaOrSylvanas->SetFacingToObject(me);
                                me->SetFacingToObject(jainaOrSylvanas);
                                if (_instanceScript->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
                                    jainaOrSylvanas->AI()->Talk(SAY_JAYNA_OUTRO_2);
                                else
                                    jainaOrSylvanas->AI()->Talk(SAY_SYLVANAS_OUTRO_2);
                            }
                            _events.ScheduleEvent(EVENT_OUTRO_3, 5000);
                            break;
                        case EVENT_OUTRO_3:
                            Talk(SAY_KRICK_OUTRO_3);
                            _events.ScheduleEvent(EVENT_OUTRO_4, 18000);
                            break;
                        case EVENT_OUTRO_4:
                            if (Creature* jainaOrSylvanas = ObjectAccessor::GetCreature(*me, _outroNpcGUID))
                            {
                                if (_instanceScript->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
                                    jainaOrSylvanas->AI()->Talk(SAY_JAYNA_OUTRO_4);
                                else
                                    jainaOrSylvanas->AI()->Talk(SAY_SYLVANAS_OUTRO_4);
                            }
                            _events.ScheduleEvent(EVENT_OUTRO_5, 5000);
                            break;
                        case EVENT_OUTRO_5:
                            Talk(SAY_KRICK_OUTRO_5);
                            _events.ScheduleEvent(EVENT_OUTRO_6, 1000);
                            break;
                        case EVENT_OUTRO_6:
                            if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _instanceScript->GetGuidData(DATA_TYRANNUS_EVENT)))
                            {
                                tyrannus->SetSpeedRate(MOVE_FLIGHT, 3.5f);
                                tyrannus->GetMotionMaster()->MovePoint(1, outroPos[4]);
                                _tyrannusGUID = tyrannus->GetGUID();
                            }
                            _events.ScheduleEvent(EVENT_OUTRO_7, 5000);
                            break;
                        case EVENT_OUTRO_7:
                            if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _tyrannusGUID))
                                tyrannus->AI()->Talk(SAY_TYRANNUS_OUTRO_7);
                            _events.ScheduleEvent(EVENT_OUTRO_8, 5000);
                            break;
                        case EVENT_OUTRO_8:
                            //! HACK: Creature's can't have MOVEMENTFLAG_FLYING
                            me->AddUnitMovementFlag(MOVEMENTFLAG_FLYING);
                            me->GetMotionMaster()->MovePoint(0, outroPos[5]);
                            DoCast(me, SPELL_STRANGULATING);
                            _events.ScheduleEvent(EVENT_OUTRO_9, 2000);
                            break;
                        case EVENT_OUTRO_9:
                            Talk(SAY_KRICK_OUTRO_8);
                            /// @todo Tyrannus starts killing Krick.
                            // there shall be some visual spell effect
                            if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _tyrannusGUID))
                                tyrannus->CastSpell(me, SPELL_NECROMANTIC_POWER, true);  //not sure if it's the right spell :/
                            _events.ScheduleEvent(EVENT_OUTRO_10, 1000);
                            break;
                        case EVENT_OUTRO_10:
                            //! HACK: Creature's can't have MOVEMENTFLAG_FLYING
                            me->RemoveUnitMovementFlag(MOVEMENTFLAG_FLYING);
                            me->AddUnitMovementFlag(MOVEMENTFLAG_FALLING_FAR);
                            me->GetMotionMaster()->MovePoint(0, outroPos[6]);
                            _events.ScheduleEvent(EVENT_OUTRO_11, 2000);
                            break;
                        case EVENT_OUTRO_11:
                            DoCast(me, SPELL_KRICK_KILL_CREDIT); // don't really know if we need it
                            me->SetStandState(UNIT_STAND_STATE_DEAD);
                            me->SetHealth(0);
                            _events.ScheduleEvent(EVENT_OUTRO_12, 3000);
                            break;
                        case EVENT_OUTRO_12:
                            if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _tyrannusGUID))
                                tyrannus->AI()->Talk(SAY_TYRANNUS_OUTRO_9);
                            _events.ScheduleEvent(EVENT_OUTRO_13, 2000);
                            break;
                        case EVENT_OUTRO_13:
                            if (Creature* jainaOrSylvanas = ObjectAccessor::GetCreature(*me, _outroNpcGUID))
                            {
                                if (_instanceScript->GetData(DATA_TEAM_IN_INSTANCE) == ALLIANCE)
                                    jainaOrSylvanas->AI()->Talk(SAY_JAYNA_OUTRO_10);
                                else
                                    jainaOrSylvanas->AI()->Talk(SAY_SYLVANAS_OUTRO_10);
                            }
                            // End of OUTRO. for now...
                            _events.ScheduleEvent(EVENT_OUTRO_END, 3s);
                            if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _tyrannusGUID))
                                tyrannus->GetMotionMaster()->MovePoint(0, outroPos[7]);
                            break;
                        case EVENT_OUTRO_END:
                            if (Creature* tyrannus = ObjectAccessor::GetCreature(*me, _tyrannusGUID))
                                tyrannus->DespawnOrUnsummon();

                            me->DisappearAndDie();
                            break;
                        default:
                            break;
                    }
                }
            }
Example #30
0
void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvPacket)
{
	if(!_player->IsInWorld()) return;
	uint64 Guid;
	uint32 TeachingSpellID;

	recvPacket >> Guid >> TeachingSpellID;
	Creature *pCreature = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(Guid));
	if(pCreature == 0) return;

	Trainer *pTrainer = pCreature->GetTrainer();
	if(pTrainer == 0 || !CanTrainAt(_player, pTrainer)) return;

	TrainerSpell * pSpell=NULL;
	for(vector<TrainerSpell>::iterator itr = pTrainer->Spells.begin(); itr != pTrainer->Spells.end(); ++itr)
	{
		if( ( itr->pCastRealSpell && itr->pCastRealSpell->Id == TeachingSpellID ) ||
			( itr->pLearnSpell && itr->pLearnSpell->Id == TeachingSpellID ) )
		{
			pSpell = &(*itr);
		}
	}
	
	if(pSpell == NULL)
		return;

	if(TrainerGetSpellStatus(pSpell) > 0) return;
	
	_player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)pSpell->Cost);

	if( pSpell->pCastSpell)
	{
		// Cast teaching spell on player
		pCreature->CastSpell(_player, pSpell->pCastSpell, true);
	}

	if( pSpell->pLearnSpell )
	{
		packetSMSG_PLAY_SPELL_VISUAL pck;
		pck.guid = pCreature->GetGUID();
		pck.visualid = 0x5b3;
		_player->OutPacketToSet( SMSG_PLAY_SPELL_VISUAL, sizeof(packetSMSG_PLAY_SPELL_VISUAL), &pck, true );

		pck.guid = _player->GetGUID();
		pck.visualid = 0x16a;
		_player->OutPacketToSet( 0x1F7, sizeof(packetSMSG_PLAY_SPELL_VISUAL), &pck, true );

		// add the spell
		_player->addSpell( pSpell->pLearnSpell->Id );

		uint32 i;
		for( i = 0; i < 3; ++i)
		{
			if(pSpell->pLearnSpell->Effect[i] == SPELL_EFFECT_PROFICIENCY || pSpell->pLearnSpell->Effect[i] == SPELL_EFFECT_LEARN_SPELL ||
				pSpell->pLearnSpell->Effect[i] == SPELL_EFFECT_WEAPON)
			{
				_player->CastSpell(_player, pSpell->pLearnSpell, true);
				break;
			}
		}

		for( i = 0; i < 3; ++i)
		{
			if( pSpell->pLearnSpell->Effect[i] == SPELL_EFFECT_SKILL )
			{
				uint32 skill = pSpell->pLearnSpell->EffectMiscValue[i];
				uint32 val = (pSpell->pLearnSpell->EffectBasePoints[i]+1) * 75;
				if( val > 350 )
					val = 350;

				if( _player->_GetSkillLineMax(skill) >= val )
					return;

				if( skill == SKILL_RIDING )
					_player->_AddSkillLine( skill, val, val );
				else
				{
					if( _player->_HasSkillLine(skill) )
						_player->_ModifySkillMaximum(skill, val);
					else
						_player->_AddSkillLine( skill, 1, val);
				}
			}
		}
	}

	if(pSpell->DeleteSpell)
	{
		// Remove old spell.
		if( pSpell->pLearnSpell )
			_player->removeSpell(pSpell->DeleteSpell, true, true, pSpell->pLearnSpell->Id);
		else if(pSpell->pCastSpell)
			_player->removeSpell(pSpell->DeleteSpell, true, true, pSpell->pCastRealSpell->Id);
		else
			_player->removeSpell(pSpell->DeleteSpell,true,false,0);
	}
}