void SetRuffies(uint64 guid, bool bAttack, bool bReset)
    {
        Creature* pCreature = m_creature->GetMap()->GetCreature(guid);

        if (!pCreature)
            return;

        if (bReset)
        {
            if (!pCreature->IsInEvadeMode() && pCreature->isAlive())
                pCreature->AI()->EnterEvadeMode();

            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);
        }
        else
        {
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE);

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

            pCreature->SetStandState(UNIT_STAND_STATE_STAND);

            if (bAttack)
            {
                if (Player* pPlayer = m_creature->GetMap()->GetPlayer(m_uiPlayerGUID))
                {
                    if (pPlayer->isAlive())
                        pCreature->AI()->AttackStart(pPlayer);
                }
            }
        }
    }
Example #2
0
 void UpdateAI(const uint32 diff)
 {
     switch (phase)
     {
     case 0: // circle around the platform
         return;
         break;
     case 1: // go to the middle and begin the fight
         if (check <= diff)
         {
             if (!me->IsWithinDist3d(VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2], 5))
             {
                 me->GetMotionMaster()->Clear();
                 me->GetMotionMaster()->MovePoint(0, VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2]);
                 check = 1000;
             }
             else
             {
                 SummonAdds();
                 phase = 2;
                 return;
             }
         }
         else
             check -= diff;
         break;
     default: // adds do the job now
         if (check <= diff)
         {
             Creature* Nazan = Unit::GetCreature(*me, NazanGUID);
             Creature* Vazruden = Unit::GetCreature(*me, VazrudenGUID);
             if ((Nazan && Nazan->isAlive()) || (Vazruden && Vazruden->isAlive()))
             {
                 if ((Nazan && Nazan->getVictim()) || (Vazruden && Vazruden->getVictim()))
                     return;
                 else
                 {
                     UnsummonAdds();
                     EnterEvadeMode();
                     return;
                 }
             }
             else if (!lootSpawned)
             {
                 me->SummonGameObject(DUNGEON_MODE(ENTRY_REINFORCED_FEL_IRON_CHEST, ENTRY_REINFORCED_FEL_IRON_CHEST_H), VazrudenMiddle[0], VazrudenMiddle[1], VazrudenMiddle[2], 0, 0, 0, 0, 0, 0);
                 me->SetLootRecipient(NULL); // don't think this is necessary..
                 //me->Kill(me);
                 lootSpawned = true;
             }
             check = 2000;
         }
         else
             check -= diff;
         break;
     }
 }
        void DoSpeech()
        {
            Creature* ada = instance->GetCreature(AdaGUID);
            Creature* ash = instance->GetCreature(AshGUID);

            if (ada && ada->isAlive() && ash && ash->isAlive())
            {
                DoScriptText(SAY_BOSS_DIE_AD, ada);
                DoScriptText(SAY_BOSS_DIE_AS, ash);
            }
        }
Example #4
0
        void DoSpeech()
        {
            Creature* pAda = instance->GetCreature(uiAdaGUID);
            Creature* pAsh = instance->GetCreature(uiAshGUID);

            if (pAda && pAda->isAlive() && pAsh && pAsh->isAlive())
            {
                DoScriptText(SAY_BOSS_DIE_AD, pAda);
                DoScriptText(SAY_BOSS_DIE_AS, pAsh);
            }
        }
/** Worker function to check if a spawning condition is met
 *
 *  This function is used directly from above function, and for recursive use
 *   in case of recursive use it is used only on _map with information of lowGuid.
 *
 *  @param lowGuid (only relevant in case of recursive uses) -- db-guid of the npc that is checked
 *  @param _map Map on which things are checked
 *  @param pInfo (only shipped in case of initial use) -- used as marker of first use, also in first use filled directly
 *  @param sx, sy (spawn position of the checked npc with initial use)
 */
bool CreatureLinkingHolder::CanSpawn(uint32 lowGuid, Map* _map, CreatureLinkingInfo const*  pInfo, float sx, float sy) const
{
    if (!pInfo)                                             // Prepare data for recursive use
    {
        CreatureData const* data = sObjectMgr.GetCreatureData(lowGuid);
        if (!data)
            return true;
        pInfo = sCreatureLinkingMgr.GetLinkedTriggerInformation(data->id, lowGuid, data->mapid);
        if (!pInfo)
            return true;
        // Has lowGuid npc actually spawning linked?
        if (!sCreatureLinkingMgr.IsSpawnedByLinkedMob(pInfo))
            return true;

        sx = data->posX;                                    // Fill position data
        sy = data->posY;
    }

    if (pInfo->searchRange == 0)                            // Map wide case
    {
        if (!pInfo->masterDBGuid)
            return false;                                   // This should never happen

        if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_DEAD)
            return IsRespawnReady(pInfo->masterDBGuid, _map);
        else if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_ALIVE)
            return !IsRespawnReady(pInfo->masterDBGuid, _map);
        else
            return true;
    }

    // Search for nearby master
    BossGuidMapBounds finds = m_masterGuid.equal_range(pInfo->masterId);
    for (BossGuidMap::const_iterator itr = finds.first; itr != finds.second; ++itr)
    {
        Creature* pMaster = _map->GetCreature(itr->second);
        if (pMaster && IsSlaveInRangeOfBoss(pMaster, sx, sy, pInfo->searchRange))
        {
            if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_DEAD)
                return pMaster->isAlive();
            else if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_ALIVE)
                return !pMaster->isAlive();
            else
                return true;
        }
    }

    return true;                                            // local boss does not exist - spawn
}
Example #6
0
        void Reset()
        {
            CheckTimer    = 2000;
            EndEventTimer = 0;

            DeathCount = 0;

            Creature* pMember = NULL;
            for (uint8 i = 0; i < 4; ++i)
            {
                pMember = Unit::GetCreature((*me), Council[i]);
                if (!pMember)
                    continue;

                if (!pMember->isAlive())
                {
                    pMember->RemoveCorpse();
                    pMember->Respawn();
                }
                pMember->AI()->EnterEvadeMode();
            }

            if (instance)
            {
                instance->SetData(DATA_ILLIDARICOUNCILEVENT, NOT_STARTED);
                if (Creature* VoiceTrigger = (Unit::GetCreature(*me, instance->GetData64(DATA_BLOOD_ELF_COUNCIL_VOICE))))
                    VoiceTrigger->AI()->EnterEvadeMode();
            }

            EventBegun = false;

            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
            me->SetDisplayId(11686);
        }
        void UpdateAI(const uint32 diff)
        {
            if (CheckTeronTimer <= diff)
            {
                if (TeronGUID)
                {
                    DoZoneInCombat();

                    Creature* Teron = (Unit::GetCreature((*me), TeronGUID));
                    if ((Teron) && (!Teron->isAlive() || Teron->IsInEvadeMode()))
                        Despawn();
                }
                else
                    Despawn();

                CheckTeronTimer = 5000;
            } else CheckTeronTimer -= diff;

            if (ShadowBoltTimer < diff && me->isInCombat())
            {
                DoCast(SelectTarget(SELECT_TARGET_RANDOM, 0), SPELL_SHADOWBOLT);
                ShadowBoltTimer = 10000;
            } else ShadowBoltTimer -= diff;
            return;
        }
        void Reset()
        {
            ArcingSmash_Timer = 10000;
            MightyBlow_Timer = 40000;
            Whirlwind_Timer = 30000;
            Charging_Timer = 0;
            Roar_Timer = 0;

            DoCast(me, SPELL_DUAL_WIELD, false);

            Phase2 = false;

            Creature* creature = NULL;
            for (uint8 i = 0; i < 4; ++i)
            {
                if (Council[i])
                {
                    creature = (Unit::GetCreature((*me), Council[i]));
                    if (creature && !creature->isAlive())
                    {
                        creature->Respawn();
                        creature->AI()->EnterEvadeMode();
                    }
                }
            }

            //reset encounter
            if (instance)
                instance->SetData(DATA_MAULGAREVENT, NOT_STARTED);
        }
Example #9
0
bool ProcessEventId_event_spell_summon_nightbane(uint32 /*uiEventId*/, Object* pSource, Object* /*pTarget*/, bool bIsStart)
{
    if (bIsStart && pSource->GetTypeId() == TYPEID_PLAYER)
    {
        ScriptedInstance* pInstance = (ScriptedInstance*)((Player*)pSource)->GetInstanceData();
        if (!pInstance)
            return false;

        if (pInstance->GetData(TYPE_NIGHTBANE) == NOT_STARTED || pInstance->GetData(TYPE_NIGHTBANE) == FAIL)
        {
            Creature* nightbane = pInstance->GetSingleCreatureFromStorage(NPC_NIGHTBANE);
            if (nightbane && nightbane->isAlive())
            {
                DoScriptText(EMOTE_AWAKEN, ((Player*)pSource));
                pInstance->SetData(TYPE_NIGHTBANE, IN_PROGRESS);

                // Sort of a hack, it is unclear how this really work but the values appear to be valid (see Onyxia, too)
                nightbane->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                nightbane->SetStandState(UNIT_STAND_STATE_STAND);
                nightbane->SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_FLY_ANIM);
                nightbane->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND);
                nightbane->SetLevitate(true);

                // Switch to waypoint movement
                if (boss_nightbaneAI* nightbaneAI = dynamic_cast<boss_nightbaneAI*>(nightbane->AI()))
                    nightbaneAI->Start(true);
            }
        }
    }

    return true;
}
Example #10
0
 uint64 GetData64(uint32 identifier)
 {
     switch(identifier)
     {
         case DATA_ELDER_NADOX:                return Elder_Nadox;
         case DATA_PRINCE_TALDARAM:            return Prince_Taldaram;
         case DATA_JEDOGA_SHADOWSEEKER:        return Jedoga_Shadowseeker;
         case DATA_HERALD_VOLAZJ:              return Herald_Volazj;
         case DATA_AMANITAR:                   return Amanitar;
         case DATA_SPHERE1:                    return Prince_TaldaramSpheres[0];
         case DATA_SPHERE2:                    return Prince_TaldaramSpheres[1];
         case DATA_PRINCE_TALDARAM_PLATFORM:   return Prince_TaldaramPlatform;
         case DATA_ADD_JEDOGA_INITIAND:
         {
             std::vector<uint64> vInitiands;
             vInitiands.clear();
             for (std::set<uint64>::const_iterator itr = InitiandGUIDs.begin(); itr != InitiandGUIDs.end(); ++itr)
             {
                 Creature* cr = instance->GetCreature(*itr);
                 if (cr && cr->isAlive())
                     vInitiands.push_back(*itr);
             }
             if (vInitiands.empty())
                 return 0;
             uint8 j = urand(0,vInitiands.size() -1);
             return vInitiands[j];
         }
         case DATA_ADD_JEDOGA_OPFER: return JedogaSacrifices;
         case DATA_PL_JEDOGA_TARGET: return JedogaTarget;
     }
     return 0;
 }
void mob_ashtongue_sorcererAI::JustDied(Unit* /*killer*/)
{
    Creature* Shade = (Unit::GetCreature((*me), ShadeGUID));
    if (Shade && Shade->isAlive())
        CAST_AI(boss_shade_of_akamaAI, Shade->AI())->IncrementDeathCount(me->GetGUID());
    else error_log("BSCR ERROR: Sorcerer dead but unable to increment DeathCount for Shade of Akama.");
}
    void MoveInLineOfSight(Unit* /*who*/)
    {
        if (!GridSearcherSucceeded)
        {
            FindChannelers();

            if (!Channelers.empty())
            {
                for (std::list<uint64>::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr)
                {
                    Creature* Channeler = (Unit::GetCreature(*me, *itr));
                    if (Channeler)
                    {
                        if (Channeler->isDead())
                        {
                            Channeler->RemoveCorpse();
                            Channeler->Respawn();
                            Channeler->InterruptNonMeleeSpells(true);
                            Channeler->RemoveAurasDueToSpell(SPELL_SHADE_SOUL_CHANNEL);
                        }

                        if (Channeler->isAlive())
                        {
                            Channeler->CastSpell(me, SPELL_SHADE_SOUL_CHANNEL, true);
                            Channeler->CastSpell(me, SPELL_SHADE_SOUL_CHANNEL_2, true);
                            Channeler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            GridSearcherSucceeded = true;
                        }
                    }
                }
            } else error_log("BSCR ERROR: No Channelers are stored in the list. This encounter will not work properly");
        }
    }
    void UpdateAI(const uint32 diff)
    {
        if (CheckTeronTimer < diff)
        {
            if (TeronGUID)
            {
                m_creature->SetInCombatWithZone();

                Creature* Teron = ((Creature*)Unit::GetUnit((*m_creature), TeronGUID));
                if ((Teron) && (!Teron->isAlive() || Teron->IsInEvadeMode()))
                    m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }
            else
                m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);

            CheckTeronTimer = 5000;
        }else CheckTeronTimer -= diff;

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

        if (ShadowBoltTimer < diff)
        {
            DoCast(SelectUnit(SELECT_TARGET_RANDOM, 0), SPELL_SHADOWBOLT);
            ShadowBoltTimer = 10000;
        }else ShadowBoltTimer -= diff;
    }
Example #14
0
		void UpdateAI(const uint32 diff) {
			if (currentPhase != PHASE_GORTOK_PALEHOOF)
				return;

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

			Creature* pTemp = Unit::GetCreature((*me),
					instance ? instance->GetData64(DATA_MOB_ORB) : 0);
			if (pTemp && pTemp->isAlive())
				pTemp->DisappearAndDie();

			if (uiArcingSmashTimer <= diff) {
				DoCast(me, SPELL_ARCING_SMASH);
				uiArcingSmashTimer = urand(13000, 17000);
			} else
				uiArcingSmashTimer -= diff;

			if (uiImpaleTimer <= diff) {
				if (Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
					DoCast(pTarget, SPELL_IMPALE);
				uiImpaleTimer = urand(8000, 12000);
			} else
				uiImpaleTimer -= diff;

			if (uiWhiteringRoarTimer <= diff) {
				DoCast(me, SPELL_WITHERING_ROAR);
				uiWhiteringRoarTimer = urand(8000, 12000);
			} else
				uiWhiteringRoarTimer -= diff;

			DoMeleeAttackIfReady();
		}
Example #15
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (m_uiCheckTeronTimer < uiDiff)
        {
            if (m_teronGuid)
            {
                m_creature->SetInCombatWithZone();

                Creature* pTeron = m_creature->GetMap()->GetCreature(m_teronGuid);
                if (pTeron && (!pTeron->isAlive() || pTeron->IsInEvadeMode()))
                    m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
            }
            else
                m_creature->DealDamage(m_creature, m_creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);

            m_uiCheckTeronTimer = 5000;
        }
        else
            m_uiCheckTeronTimer -= uiDiff;

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

        if (m_uiShadowBoltTimer < uiDiff)
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
                DoCastSpellIfCan(pTarget, SPELL_SHADOWBOLT);

            m_uiShadowBoltTimer = 10000;
        }
        else
            m_uiShadowBoltTimer -= uiDiff;
    }
    void JustDied(Unit* /*killer*/)
    {
        if (!pInstance)
            return;

        Creature* pDelrissa = Unit::GetCreature(*me, pInstance->GetData64(DATA_DELRISSA));
        uint32 uiLackeyDeathCount = pInstance->GetData(DATA_DELRISSA_DEATH_COUNT);

        if (!pDelrissa)
            return;

        //should delrissa really yell if dead?
        DoScriptText(LackeyDeath[uiLackeyDeathCount].id, pDelrissa);

        pInstance->SetData(DATA_DELRISSA_DEATH_COUNT, SPECIAL);

        //increase local var, since we now may have four dead
        ++uiLackeyDeathCount;

        if (uiLackeyDeathCount == MAX_ACTIVE_LACKEY)
        {
            //time to make her lootable and complete event if she died before lackeys
            if (!pDelrissa->isAlive())
            {
                if (!pDelrissa->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE))
                    pDelrissa->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);

                pInstance->SetData(DATA_DELRISSA_EVENT, DONE);
            }
        }
    }
    bool OnGossipHello(Player* /*player*/, GameObject* go)
    {
        InstanceScript* instance = go->GetInstanceScript();
        if (!instance)
            return true;

        Creature* pPrinceTaldaram = Unit::GetCreature(*go, instance->GetData64(DATA_PRINCE_TALDARAM));
        if (pPrinceTaldaram && pPrinceTaldaram->isAlive())
        {
            // maybe these are hacks :(
            go->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NOT_SELECTABLE);
            go->SetGoState(GO_STATE_ACTIVE);

            switch (go->GetEntry())
            {
                case GO_SPHERE1:
                    instance->SetData(DATA_SPHERE1_EVENT, IN_PROGRESS);
                    pPrinceTaldaram->AI()->Talk(SAY_1);
                    break;

                case GO_SPHERE2:
                    instance->SetData(DATA_SPHERE2_EVENT, IN_PROGRESS);
                    pPrinceTaldaram->AI()->Talk(SAY_1);
                    break;
            }

            CAST_AI(boss_taldaram::boss_taldaramAI, pPrinceTaldaram->AI())->CheckSpheres();
        }
        return true;
    }
Example #18
0
    void UpdateAI(const uint32 diff)
    {
        if(CheckTimer < diff)
        {
            if(pInstance)
            {
                Creature *pAnetheron = pInstance->GetCreature(pInstance->GetData64(DATA_ANETHERON));
                if(!pAnetheron || !pAnetheron->isAlive())
                {
                    m_creature->setDeathState(JUST_DIED);
                    m_creature->RemoveCorpse();
                    return;
                }
            }
            CheckTimer = 2000;
        }
        else
            CheckTimer -= diff;

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

        if(WaitTimer > diff)
        {
            WaitTimer -= diff;
            return;
        }

        DoMeleeAttackIfReady();
    }
    bool OnGossipHello(Player* /*pPlayer*/, GameObject *pGO)
    {
        InstanceScript *pInstance = pGO->GetInstanceScript();

        Creature *pPrinceTaldaram = Unit::GetCreature(*pGO, pInstance ? pInstance->GetData64(DATA_PRINCE_TALDARAM) : 0);
        if (pPrinceTaldaram && pPrinceTaldaram->isAlive())
        {
            // maybe these are hacks :(
            pGO->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_UNK1);
            pGO->SetGoState(GO_STATE_ACTIVE);

            switch(pGO->GetEntry())
            {
            case GO_SPHERE1:
                pInstance->SetData(DATA_SPHERE1_EVENT, IN_PROGRESS);
                break;
            case GO_SPHERE2:
                pInstance->SetData(DATA_SPHERE2_EVENT, IN_PROGRESS);
                break;
            }

            CAST_AI(boss_taldaram::boss_taldaramAI, pPrinceTaldaram->AI())->CheckSpheres();
        }
        return true;
    }
        void Reset()
        {
            LightningCloud_Timer = 15000;
            LungBurst_Timer = 7000;
            EnvelopingWinds_Timer = 9000;

            if (instance)
                instance->SetData(TYPE_HYDROMANCER_THESPIA, NOT_STARTED);

            if(me->isAlive())
            {
                DoScriptText(SAY_SUMMON, me);
                std::list<Creature*> list;
                GetCreatureListWithEntryInGrid(list,me,MOB_WATER_ELEMENTAL,150.0f);

                for (std::list<Creature*>::iterator iter = list.begin(); iter != list.end(); ++iter)
                {
                    Creature *c = *iter;
                    if (c)
                    {
                        if(c->isAlive())
                            c->AI()->EnterEvadeMode();
                        else
                            c->Respawn(true);
                    }
                }
            }
        }
Example #21
0
	uint32 GetData(uint32 type) {
		switch (type) {
		case DATA_ELDER_NADOX_EVENT:
			return m_auiEncounter[0];
		case DATA_PRINCE_TALDARAM_EVENT:
			return m_auiEncounter[1];
		case DATA_JEDOGA_SHADOWSEEKER_EVENT:
			return m_auiEncounter[2];
		case DATA_HERALD_VOLAZJ:
			return m_auiEncounter[3];
		case DATA_AMANITAR_EVENT:
			return m_auiEncounter[4];
		case DATA_SPHERE1_EVENT:
			return spheres[0];
		case DATA_SPHERE2_EVENT:
			return spheres[1];
		case DATA_ALL_INITIAND_DEAD:
			for (std::set<uint64>::const_iterator itr =
					InitiandGUIDs.begin(); itr != InitiandGUIDs.end();
					++itr) {
				Creature* cr = instance->GetCreature(*itr);
				if (!cr || (cr && cr->isAlive()))
					return 0;
			}
			return 1;
		case DATA_JEDOGA_TRIGGER_SWITCH:
			return switchtrigger;
		case DATA_INITIAND_KILLED:
			return initiandkilled;
		}
		return 0;
	}
Example #22
0
void CreatureGroup::LeaderMoveTo(float x, float y, float z)
{
    if(!m_leader)
        return;

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

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

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

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

        CW::NormalizeMapCoord(dx);
        CW::NormalizeMapCoord(dy);

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

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

        member->GetMotionMaster()->MovePoint(0, dx, dy, dz);
        member->SetHomePosition(dx, dy, dz, pathangle);
    }
}
Example #23
0
        void Update(uint32 diff)
        {
            if (CageTimer)
            {
                if (CageTimer <= diff)
                {
                    Creature *Magtheridon = instance->GetCreature(MagtheridonGUID);
                    if (Magtheridon && Magtheridon->isAlive())
                    {
                        Magtheridon->ClearUnitState(UNIT_STAT_STUNNED);
                        Magtheridon->AI()->AttackStart(Magtheridon->SelectNearestTarget(999));
                    }
                    CageTimer = 0;
                } else CageTimer -= diff;
            }

            if (RespawnTimer)
            {
                if (RespawnTimer <= diff)
                {
                    for (std::set<uint64>::const_iterator i = ChannelerGUID.begin(); i != ChannelerGUID.end(); ++i)
                    {
                        if (Creature *Channeler = instance->GetCreature(*i))
                        {
                            if (Channeler->isAlive())
                                Channeler->AI()->EnterEvadeMode();
                            else
                                Channeler->Respawn();
                        }
                    }
                    RespawnTimer = 0;
                } else RespawnTimer -= diff;
            }
        }
Example #24
0
    bool OnGossipHello(Player* player, GameObject* pGO)
    {
        if (player->GetQuestStatus(QUEST_PRISONERS_OF_WYRMSKULL) != QUEST_STATUS_INCOMPLETE)
            return true;

        Creature* pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PRIEST, 2.0f);
        if (!pPrisoner)
        {
            pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_MAGE, 2.0f);
            if (!pPrisoner)
            {
                pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_WARRIOR, 2.0f);
                if (!pPrisoner)
                    pPrisoner = pGO->FindNearestCreature(NPC_PRISONER_PALADIN, 2.0f);
            }
        }

        if (!pPrisoner || !pPrisoner->isAlive())
            return true;

        Quest const* qInfo = sObjectMgr->GetQuestTemplate(QUEST_PRISONERS_OF_WYRMSKULL);
        if (qInfo)
        {
            //TODO: prisoner should help player for a short period of time
            player->KilledMonsterCredit(qInfo->ReqCreatureOrGOId[0], 0);
            pPrisoner->DisappearAndDie();
        }
        return true;
    }
        void Reset()
        {
            CataclysmicBolt_Timer = 10000;
            Enrage_Timer = 600000;                              //10 minutes
            SearNova_Timer = 20000+rand()%40000; // 20 - 60 seconds

            BlessingOfTides = false;

            if (instance)
            {
                uint64 RAdvisors[MAX_ADVISORS];
                RAdvisors[0] = instance->GetData64(DATA_SHARKKIS);
                RAdvisors[1] = instance->GetData64(DATA_TIDALVESS);
                RAdvisors[2] = instance->GetData64(DATA_CARIBDIS);
                //Respawn of the 3 Advisors
                Creature* pAdvisor = NULL;
                for (int i=0; i<MAX_ADVISORS; ++i)
                    if (RAdvisors[i])
                    {
                        pAdvisor = (Unit::GetCreature(*me, RAdvisors[i]));
                        if (pAdvisor && !pAdvisor->isAlive())
                        {
                            pAdvisor->Respawn();
                            pAdvisor->AI()->EnterEvadeMode();
                            pAdvisor->GetMotionMaster()->MoveTargetedHome();
                        }
                    }
                instance->SetData(DATA_KARATHRESSEVENT, NOT_STARTED);
            }
        }
Example #26
0
    bool OnGossipHello(Player* player, GameObject* pGO)
    {
        Creature* pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_HUMAN, 5.0f, true);
        if (!pPrisoner)
        {
            pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_TROLL, 5.0f, true);
            if (!pPrisoner)
            {
                pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_ORC, 5.0f, true);
                if (!pPrisoner)
                    pPrisoner = pGO->FindNearestCreature(NPC_EBON_BLADE_PRISONER_NE, 5.0f, true);
            }
        }
        if (!pPrisoner || !pPrisoner->isAlive())
            return false;

        pPrisoner->DisappearAndDie();
        player->KilledMonsterCredit(NPC_EBON_BLADE_PRISONER_HUMAN, 0);
        switch (pPrisoner->GetEntry())
        {
            case NPC_EBON_BLADE_PRISONER_HUMAN:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_H, true);
                break;
            case NPC_EBON_BLADE_PRISONER_NE:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_NE, true);
                break;
            case NPC_EBON_BLADE_PRISONER_TROLL:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_TROLL, true);
                break;
            case NPC_EBON_BLADE_PRISONER_ORC:
                player->CastSpell(player, SPELL_SUMMON_BLADE_KNIGHT_ORC, true);
                break;
        }
        return true;
    }
Example #27
0
// This function lets a slave refollow his master
bool CreatureLinkingHolder::TryFollowMaster(Creature* pCreature)
{
    CreatureLinkingInfo const*  pInfo = sCreatureLinkingMgr.GetLinkedTriggerInformation(pCreature);
    if (!pInfo || !(pInfo->linkingFlag & FLAG_FOLLOW))
        return false;

    Creature* pMaster = NULL;
    if (pInfo->mapId != INVALID_MAP_ID)                     // entry case
    {
        BossGuidMapBounds finds = m_masterGuid.equal_range(pInfo->masterId);
        for (BossGuidMap::iterator itr = finds.first; itr != finds.second; ++itr)
        {
            pMaster = pCreature->GetMap()->GetCreature(itr->second);
            if (pMaster && IsSlaveInRangeOfBoss(pCreature, pMaster, pInfo->searchRange))
                break;
        }
    }
    else                                                    // guid case
    {
        CreatureData const* masterData = sObjectMgr.GetCreatureData(pInfo->masterDBGuid);
        CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(masterData->id);
        pMaster = pCreature->GetMap()->GetCreature(ObjectGuid(cInfo->GetHighGuid(), cInfo->Entry, pInfo->masterDBGuid));
    }

    if (pMaster && pMaster->isAlive())
    {
        SetFollowing(pCreature, pMaster);
        return true;
    }

    return false;
}
void WaypointMovementGenerator<Creature>::StartMove(Creature& creature)
{
    if (!i_path || i_path->empty())
        return;

    if (Stopped(creature))
        return;

    if (!creature.isAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE))
        return;

    WaypointPath::const_iterator currPoint = i_path->find(i_currentNode);
    MANGOS_ASSERT(currPoint != i_path->end());

    if (WaypointBehavior* behavior = currPoint->second.behavior)
    {
        if (behavior->model2 != 0)
            creature.SetDisplayId(behavior->model2);
        creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
    }

    if (m_isArrivalDone)
    {
        bool reachedLast = false;
        ++currPoint;
        if (currPoint == i_path->end())
        {
            reachedLast = true;
            currPoint = i_path->begin();
        }

        // Inform AI
        if (creature.AI() && m_PathOrigin == PATH_FROM_EXTERNAL &&  m_pathId > 0)
        {
            if (!reachedLast)
                creature.AI()->MovementInform(EXTERNAL_WAYPOINT_MOVE_START + m_pathId, currPoint->first);
            else
                creature.AI()->MovementInform(EXTERNAL_WAYPOINT_FINISHED_LAST + m_pathId, currPoint->first);

            if (creature.isDead() || !creature.IsInWorld()) // Might have happened with above calls
                return;
        }

        i_currentNode = currPoint->first;
    }

    m_isArrivalDone = false;

    creature.addUnitState(UNIT_STAT_ROAMING_MOVE);

    WaypointNode const& nextNode = currPoint->second;;
    Movement::MoveSplineInit init(creature);
    init.MoveTo(nextNode.x, nextNode.y, nextNode.z, true);

    if (nextNode.orientation != 100 && nextNode.delay != 0)
        init.SetFacing(nextNode.orientation);
    creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE) && !creature.IsLevitating(), false);
    init.Launch();
}
Example #29
0
void instance_zulfarrak::OnPlayerDeath(Player * /*pPlayer*/)
{
	//Wipe during pyramide event: reset!
	if (GetData(TYPE_PYRAMIDE) != IN_PROGRESS && GetData(TYPE_PYRAMIDE) != SPECIAL)
		return;
	Map::PlayerList const& L = instance->GetPlayers();
	uint32 i = 0;
	for (Map::PlayerList::const_iterator itr = L.begin(); itr != L.end(); ++itr) {
		Player* P = itr->getSource();
		if (!P || P->isDead() || !P->isAlive())
			i++;
	}
	if (i < L.getSize()-1)
		return;
    //Reset Event
	SetData(TYPE_PYRAMIDE, NOT_STARTED);
	//despawn summons
    if (!m_uiPyramideTrash.empty())
    {
        for(GUIDList::iterator itr = m_uiPyramideTrash.begin(); itr != m_uiPyramideTrash.end(); ++itr)
        {
			if (Creature* pTroll = instance->GetCreature(*itr))
            {
				pTroll->ForcedDespawn();
				pTroll->RemoveFromWorld();
            }
        }
    }
	m_uiPyramideTrash.clear();
	m_uiPyramideTrashTemp.clear();
	m_uiWave = 0;
	m_uiCheckPyramideTrash_Timer = 15000;
	//Reset troll cages and prisoners so event can be restarted
	for (int i = 0; i < 5; i++)
    {
		m_uiPyramideNPCs[i].clear();
		DoUseDoorOrButton(m_mGoEntryGuidStore[GO_TROLL_CAGE1+i],0,false);
		Creature* C = GetSingleCreatureFromStorage(NPC_SERGEANT_BLY+i);
		C->SetDeathState(JUST_DIED);
		C->Respawn();
		C->setFaction(FACTION_FRIENDLY);
    }
	//Set respawn time of executioner
	Creature* C = GetSingleCreatureFromStorage(NPC_SANDFURY_EXECUTIONER);
	if (C && C->IsInWorld() && !C->isAlive())
    {
        C->RemoveCorpse();
        C->SetRespawnTime(35);
        C->SaveRespawnTime();
        C->SetRespawnDelay(10 * 24 * 3600);
    }
	//Despawn Nekrum aswell
	C = GetSingleCreatureFromStorage(NPC_NEKRUM_GUTCHEWER);
	if (C && C->IsInWorld())
    {
		C->ForcedDespawn();
		C->RemoveFromWorld();
    }
}
void RandomMovementGenerator<Creature>::Initialize(Creature &creature)
{
    if (!creature.isAlive())
        return;

    creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE);
    _setRandomLocation(creature);
}